Mercurial > vim
diff src/vim9compile.c @ 20089:7fc5d62fe2a5 v8.2.0600
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Commit: https://github.com/vim/vim/commit/d3aac2917db38f8590648ee76eebfa178fc4c069
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Apr 19 14:32:17 2020 +0200
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variables
Problem: Vim9: cannot read or write w:, t: and b: variables.
Solution: Implement load and store for w:, t: and b: variables.
(closes #5950)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 19 Apr 2020 14:45:03 +0200 |
parents | 336483164ca6 |
children | a64c16ff98b8 |
line wrap: on
line diff
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -2235,18 +2235,21 @@ compile_load(char_u **arg, char_u *end_a } else if (**arg == 'b') { - semsg("Namespace b: not supported yet: %s", *arg); - goto theend; + // Buffer-local variables can be defined later, thus we don't check + // if it exists, give error at runtime. + res = generate_LOAD(cctx, ISN_LOADB, 0, name, &t_any); } else if (**arg == 'w') { - semsg("Namespace w: not supported yet: %s", *arg); - goto theend; + // Window-local variables can be defined later, thus we don't check + // if it exists, give error at runtime. + res = generate_LOAD(cctx, ISN_LOADW, 0, name, &t_any); } else if (**arg == 't') { - semsg("Namespace t: not supported yet: %s", *arg); - goto theend; + // Tabpage-local variables can be defined later, thus we don't + // check if it exists, give error at runtime. + res = generate_LOAD(cctx, ISN_LOADT, 0, name, &t_any); } else { @@ -3958,6 +3961,9 @@ typedef enum { dest_option, dest_env, dest_global, + dest_buffer, + dest_window, + dest_tab, dest_vimvar, dest_script, dest_reg, @@ -4087,6 +4093,33 @@ compile_assignment(char_u *arg, exarg_T goto theend; } } + else if (STRNCMP(arg, "b:", 2) == 0) + { + dest = dest_buffer; + if (is_decl) + { + semsg(_("E1078: Cannot declare a buffer variable: %s"), name); + goto theend; + } + } + else if (STRNCMP(arg, "w:", 2) == 0) + { + dest = dest_window; + if (is_decl) + { + semsg(_("E1079: Cannot declare a window variable: %s"), name); + goto theend; + } + } + else if (STRNCMP(arg, "t:", 2) == 0) + { + dest = dest_tab; + if (is_decl) + { + semsg(_("E1080: Cannot declare a tab variable: %s"), name); + goto theend; + } + } else if (STRNCMP(arg, "v:", 2) == 0) { typval_T *vtv; @@ -4245,6 +4278,15 @@ compile_assignment(char_u *arg, exarg_T case dest_global: generate_LOAD(cctx, ISN_LOADG, 0, name + 2, type); break; + case dest_buffer: + generate_LOAD(cctx, ISN_LOADB, 0, name + 2, type); + break; + case dest_window: + generate_LOAD(cctx, ISN_LOADW, 0, name + 2, type); + break; + case dest_tab: + generate_LOAD(cctx, ISN_LOADT, 0, name + 2, type); + break; case dest_script: compile_load_scriptvar(cctx, name + (name[1] == ':' ? 2 : 0), NULL, NULL, TRUE); @@ -4410,6 +4452,18 @@ compile_assignment(char_u *arg, exarg_T // include g: with the name, easier to execute that way generate_STORE(cctx, ISN_STOREG, 0, name); break; + case dest_buffer: + // include b: with the name, easier to execute that way + generate_STORE(cctx, ISN_STOREB, 0, name); + break; + case dest_window: + // include w: with the name, easier to execute that way + generate_STORE(cctx, ISN_STOREW, 0, name); + break; + case dest_tab: + // include t: with the name, easier to execute that way + generate_STORE(cctx, ISN_STORET, 0, name); + break; case dest_env: generate_STORE(cctx, ISN_STOREENV, 0, name + 1); break; @@ -6189,12 +6243,18 @@ delete_instr(isn_T *isn) case ISN_EXEC: case ISN_LOADENV: case ISN_LOADG: + case ISN_LOADB: + case ISN_LOADW: + case ISN_LOADT: case ISN_LOADOPT: case ISN_MEMBER: case ISN_PUSHEXC: case ISN_PUSHS: case ISN_STOREENV: case ISN_STOREG: + case ISN_STOREB: + case ISN_STOREW: + case ISN_STORET: case ISN_PUSHFUNC: vim_free(isn->isn_arg.string); break;