comparison src/vim9compile.c @ 23233:657216220293 v8.2.2162

patch 8.2.2162: Vim9: Cannot load or store autoload variables Commit: https://github.com/vim/vim/commit/03290b8444b69c6d7307755770467bc488384e1a Author: Bram Moolenaar <Bram@vim.org> Date: Sat Dec 19 16:30:44 2020 +0100 patch 8.2.2162: Vim9: Cannot load or store autoload variables Problem: Vim9: Cannot load or store autoload variables. Solution: Add ISN_LOADAUTO and ISN_STOREAUTO. (closes https://github.com/vim/vim/issues/7485)
author Bram Moolenaar <Bram@vim.org>
date Sat, 19 Dec 2020 16:45:06 +0100
parents b545334ae654
children ac934fbacc0e
comparison
equal deleted inserted replaced
23232:adecb0541bb3 23233:657216220293
2533 case 'v': res = generate_LOADV(cctx, name, error); 2533 case 'v': res = generate_LOADV(cctx, name, error);
2534 break; 2534 break;
2535 case 's': res = compile_load_scriptvar(cctx, name, 2535 case 's': res = compile_load_scriptvar(cctx, name,
2536 NULL, NULL, error); 2536 NULL, NULL, error);
2537 break; 2537 break;
2538 case 'g': isn_type = ISN_LOADG; break; 2538 case 'g': if (vim_strchr(name, AUTOLOAD_CHAR) == NULL)
2539 isn_type = ISN_LOADG;
2540 else
2541 {
2542 isn_type = ISN_LOADAUTO;
2543 vim_free(name);
2544 name = vim_strnsave(*arg, end - *arg);
2545 if (name == NULL)
2546 return FAIL;
2547 }
2548 break;
2539 case 'w': isn_type = ISN_LOADW; break; 2549 case 'w': isn_type = ISN_LOADW; break;
2540 case 't': isn_type = ISN_LOADT; break; 2550 case 't': isn_type = ISN_LOADT; break;
2541 case 'b': isn_type = ISN_LOADB; break; 2551 case 'b': isn_type = ISN_LOADB; break;
2542 default: // cannot happen, just in case 2552 default: // cannot happen, just in case
2543 semsg(_(e_namespace_not_supported_str), *arg); 2553 semsg(_(e_namespace_not_supported_str), *arg);
2736 2746
2737 *arg = skipwhite(*arg + varlen + 1); 2747 *arg = skipwhite(*arg + varlen + 1);
2738 if (compile_arguments(arg, cctx, &argcount) == FAIL) 2748 if (compile_arguments(arg, cctx, &argcount) == FAIL)
2739 goto theend; 2749 goto theend;
2740 2750
2741 is_autoload = vim_strchr(name, '#') != NULL; 2751 is_autoload = vim_strchr(name, AUTOLOAD_CHAR) != NULL;
2742 if (ASCII_ISLOWER(*name) && name[1] != ':' && !is_autoload) 2752 if (ASCII_ISLOWER(*name) && name[1] != ':' && !is_autoload)
2743 { 2753 {
2744 int idx; 2754 int idx;
2745 2755
2746 // builtin function 2756 // builtin function
4984 case dest_option: 4994 case dest_option:
4985 // TODO: check the option exists 4995 // TODO: check the option exists
4986 generate_LOAD(cctx, ISN_LOADOPT, 0, name, type); 4996 generate_LOAD(cctx, ISN_LOADOPT, 0, name, type);
4987 break; 4997 break;
4988 case dest_global: 4998 case dest_global:
4989 generate_LOAD(cctx, ISN_LOADG, 0, name + 2, type); 4999 if (vim_strchr(name, AUTOLOAD_CHAR) == NULL)
5000 generate_LOAD(cctx, ISN_LOADG, 0, name + 2, type);
5001 else
5002 generate_LOAD(cctx, ISN_LOADAUTO, 0, name, type);
4990 break; 5003 break;
4991 case dest_buffer: 5004 case dest_buffer:
4992 generate_LOAD(cctx, ISN_LOADB, 0, name + 2, type); 5005 generate_LOAD(cctx, ISN_LOADB, 0, name + 2, type);
4993 break; 5006 break;
4994 case dest_window: 5007 case dest_window:
5196 case dest_option: 5209 case dest_option:
5197 return generate_STOREOPT(cctx, skip_option_env_lead(name), 5210 return generate_STOREOPT(cctx, skip_option_env_lead(name),
5198 opt_flags); 5211 opt_flags);
5199 case dest_global: 5212 case dest_global:
5200 // include g: with the name, easier to execute that way 5213 // include g: with the name, easier to execute that way
5201 return generate_STORE(cctx, ISN_STOREG, 0, name); 5214 return generate_STORE(cctx, vim_strchr(name, AUTOLOAD_CHAR) == NULL
5215 ? ISN_STOREG : ISN_STOREAUTO, 0, name);
5202 case dest_buffer: 5216 case dest_buffer:
5203 // include b: with the name, easier to execute that way 5217 // include b: with the name, easier to execute that way
5204 return generate_STORE(cctx, ISN_STOREB, 0, name); 5218 return generate_STORE(cctx, ISN_STOREB, 0, name);
5205 case dest_window: 5219 case dest_window:
5206 // include w: with the name, easier to execute that way 5220 // include w: with the name, easier to execute that way
8005 { 8019 {
8006 switch (isn->isn_type) 8020 switch (isn->isn_type)
8007 { 8021 {
8008 case ISN_DEF: 8022 case ISN_DEF:
8009 case ISN_EXEC: 8023 case ISN_EXEC:
8024 case ISN_LOADAUTO:
8010 case ISN_LOADB: 8025 case ISN_LOADB:
8011 case ISN_LOADENV: 8026 case ISN_LOADENV:
8012 case ISN_LOADG: 8027 case ISN_LOADG:
8013 case ISN_LOADOPT: 8028 case ISN_LOADOPT:
8014 case ISN_LOADT: 8029 case ISN_LOADT:
8015 case ISN_LOADW: 8030 case ISN_LOADW:
8016 case ISN_PUSHEXC: 8031 case ISN_PUSHEXC:
8017 case ISN_PUSHFUNC: 8032 case ISN_PUSHFUNC:
8018 case ISN_PUSHS: 8033 case ISN_PUSHS:
8019 case ISN_RANGE: 8034 case ISN_RANGE:
8035 case ISN_STOREAUTO:
8020 case ISN_STOREB: 8036 case ISN_STOREB:
8021 case ISN_STOREENV: 8037 case ISN_STOREENV:
8022 case ISN_STOREG: 8038 case ISN_STOREG:
8023 case ISN_STORET: 8039 case ISN_STORET:
8024 case ISN_STOREW: 8040 case ISN_STOREW: