summaryrefslogtreecommitdiff
path: root/src/vim9execute.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/vim9execute.c
parent173d841e86cf205d8e398091b1da7bb4951714f9 (diff)
downloadvim-git-8.2.0600.tar.gz
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/vim9execute.c')
-rw-r--r--src/vim9execute.c80
1 files changed, 73 insertions, 7 deletions
diff --git a/src/vim9execute.c b/src/vim9execute.c
index dbc5d22ba..b0e35b6f3 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -446,6 +446,7 @@ store_var(char_u *name, typval_T *tv)
restore_funccal();
}
+
/*
* Execute a function by "name".
* This can be a builtin function, user function or a funcref.
@@ -757,16 +758,42 @@ call_def_function(
}
break;
- // load g: variable
+ // load g:/b:/w:/t: variable
case ISN_LOADG:
+ case ISN_LOADB:
+ case ISN_LOADW:
+ case ISN_LOADT:
{
- dictitem_T *di = find_var_in_ht(get_globvar_ht(), 0,
- iptr->isn_arg.string, TRUE);
+ dictitem_T *di = NULL;
+ hashtab_T *ht = NULL;
+ char namespace;
+ switch (iptr->isn_type)
+ {
+ case ISN_LOADG:
+ ht = get_globvar_ht();
+ namespace = 'g';
+ break;
+ case ISN_LOADB:
+ ht = &curbuf->b_vars->dv_hashtab;
+ namespace = 'b';
+ break;
+ case ISN_LOADW:
+ ht = &curwin->w_vars->dv_hashtab;
+ namespace = 'w';
+ break;
+ case ISN_LOADT:
+ ht = &curtab->tp_vars->dv_hashtab;
+ namespace = 't';
+ break;
+ default: // Cannot reach here
+ goto failed;
+ }
+ di = find_var_in_ht(ht, 0, iptr->isn_arg.string, TRUE);
if (di == NULL)
{
- semsg(_("E121: Undefined variable: g:%s"),
- iptr->isn_arg.string);
+ semsg(_("E121: Undefined variable: %c:%s"),
+ namespace, iptr->isn_arg.string);
goto failed;
}
else
@@ -925,13 +952,34 @@ call_def_function(
goto failed;
break;
- // store g: variable
+ // store g:/b:/w:/t: variable
case ISN_STOREG:
+ case ISN_STOREB:
+ case ISN_STOREW:
+ case ISN_STORET:
{
dictitem_T *di;
+ hashtab_T *ht;
+ switch (iptr->isn_type)
+ {
+ case ISN_STOREG:
+ ht = get_globvar_ht();
+ break;
+ case ISN_STOREB:
+ ht = &curbuf->b_vars->dv_hashtab;
+ break;
+ case ISN_STOREW:
+ ht = &curwin->w_vars->dv_hashtab;
+ break;
+ case ISN_STORET:
+ ht = &curtab->tp_vars->dv_hashtab;
+ break;
+ default: // Cannot reach here
+ goto failed;
+ }
--ectx.ec_stack.ga_len;
- di = find_var_in_ht(get_globvar_ht(), 0,
+ di = find_var_in_ht(ht, 0,
iptr->isn_arg.string + 2, TRUE);
if (di == NULL)
store_var(iptr->isn_arg.string, STACK_TV_BOT(0));
@@ -1918,6 +1966,15 @@ ex_disassemble(exarg_T *eap)
case ISN_LOADG:
smsg("%4d LOADG g:%s", current, iptr->isn_arg.string);
break;
+ case ISN_LOADB:
+ smsg("%4d LOADB b:%s", current, iptr->isn_arg.string);
+ break;
+ case ISN_LOADW:
+ smsg("%4d LOADW w:%s", current, iptr->isn_arg.string);
+ break;
+ case ISN_LOADT:
+ smsg("%4d LOADT t:%s", current, iptr->isn_arg.string);
+ break;
case ISN_LOADOPT:
smsg("%4d LOADOPT %s", current, iptr->isn_arg.string);
break;
@@ -1943,6 +2000,15 @@ ex_disassemble(exarg_T *eap)
case ISN_STOREG:
smsg("%4d STOREG %s", current, iptr->isn_arg.string);
break;
+ case ISN_STOREB:
+ smsg("%4d STOREB %s", current, iptr->isn_arg.string);
+ break;
+ case ISN_STOREW:
+ smsg("%4d STOREW %s", current, iptr->isn_arg.string);
+ break;
+ case ISN_STORET:
+ smsg("%4d STORET %s", current, iptr->isn_arg.string);
+ break;
case ISN_STORES:
{
scriptitem_T *si = SCRIPT_ITEM(