summaryrefslogtreecommitdiffstats
path: root/src/vim9compile.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-04-19 14:32:17 +0200
committerBram Moolenaar <Bram@vim.org>2020-04-19 14:32:17 +0200
commitd3aac2917db38f8590648ee76eebfa178fc4c069 (patch)
tree180c8d574d69cb48d60418ca974a3d146272460d /src/vim9compile.c
parent173d841e86cf205d8e398091b1da7bb4951714f9 (diff)
patch 8.2.0600: Vim9: cannot read or write w:, t: and b: variablesv8.2.0600
Problem: Vim9: cannot read or write w:, t: and b: variables. Solution: Implement load and store for w:, t: and b: variables. (closes #5950)
Diffstat (limited to 'src/vim9compile.c')
-rw-r--r--src/vim9compile.c72
1 files changed, 66 insertions, 6 deletions
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 64f7dd59b1..c99d39602e 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -2235,18 +2235,21 @@ compile_load(char_u **arg, char_u *end_arg, cctx_T *cctx, int error)
}
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 *eap, cmdidx_T cmdidx, cctx_T *cctx)
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 *eap, cmdidx_T cmdidx, cctx_T *cctx)
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 *eap, cmdidx_T cmdidx, cctx_T *cctx)
// 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;