0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

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)
This commit is contained in:
Bram Moolenaar
2020-04-19 14:32:17 +02:00
parent 173d841e86
commit d3aac2917d
7 changed files with 203 additions and 18 deletions

View File

@@ -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;