summaryrefslogtreecommitdiff
path: root/src/vim9execute.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-05-07 17:55:55 +0200
committerBram Moolenaar <Bram@vim.org>2021-05-07 17:55:55 +0200
commitf18332fb9e2e4208a97d800f096b02c6681780e7 (patch)
tree8cbfcb58bfbe67b2549d76ba721b2db9c33a602b /src/vim9execute.c
parente08795e1ecf0b85751e9f41021603c39ef026d92 (diff)
downloadvim-git-f18332fb9e2e4208a97d800f096b02c6681780e7.tar.gz
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiledv8.2.2842
Problem: Vim9: skip argument to searchpair() is not compiled. Solution: Add VAR_INSTR.
Diffstat (limited to 'src/vim9execute.c')
-rw-r--r--src/vim9execute.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/vim9execute.c b/src/vim9execute.c
index c8586b384..29cd5fc67 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -1259,6 +1259,12 @@ fill_partial_and_closure(partial_T *pt, ufunc_T *ufunc, ectx_T *ectx)
return OK;
}
+// used for v_instr of typval of VAR_INSTR
+struct instr_S {
+ ectx_T *instr_ectx;
+ isn_T *instr_instr;
+};
+
// used for substitute_instr
typedef struct subs_expr_S {
ectx_T *subs_ectx;
@@ -1379,6 +1385,23 @@ exec_instructions(ectx_T *ectx)
}
break;
+ // push typeval VAR_INSTR with instructions to be executed
+ case ISN_INSTR:
+ {
+ if (GA_GROW(&ectx->ec_stack, 1) == FAIL)
+ return FAIL;
+ tv = STACK_TV_BOT(0);
+ tv->vval.v_instr = ALLOC_ONE(instr_T);
+ if (tv->vval.v_instr == NULL)
+ goto on_error;
+ ++ectx->ec_stack.ga_len;
+
+ tv->v_type = VAR_INSTR;
+ tv->vval.v_instr->instr_ectx = ectx;
+ tv->vval.v_instr->instr_instr = iptr->isn_arg.instr;
+ }
+ break;
+
// execute :substitute with an expression
case ISN_SUBSTITUTE:
{
@@ -3997,6 +4020,33 @@ done:
}
/*
+ * Execute the instructions from a VAR_INSTR typeval and put the result in
+ * "rettv".
+ * Return OK or FAIL.
+ */
+ int
+exe_typval_instr(typval_T *tv, typval_T *rettv)
+{
+ ectx_T *ectx = tv->vval.v_instr->instr_ectx;
+ isn_T *save_instr = ectx->ec_instr;
+ int save_iidx = ectx->ec_iidx;
+ int res;
+
+ ectx->ec_instr = tv->vval.v_instr->instr_instr;
+ res = exec_instructions(ectx);
+ if (res == OK)
+ {
+ *rettv = *STACK_TV_BOT(-1);
+ --ectx->ec_stack.ga_len;
+ }
+
+ ectx->ec_instr = save_instr;
+ ectx->ec_iidx = save_iidx;
+
+ return res;
+}
+
+/*
* Execute the instructions from an ISN_SUBSTITUTE command, which are in
* "substitute_instr".
*/
@@ -4436,6 +4486,14 @@ list_instructions(char *pfx, isn_T *instr, int instr_count, ufunc_T *ufunc)
}
#endif
break;
+ case ISN_INSTR:
+ {
+ smsg("%s%4d INSTR", pfx, current);
+ list_instructions(" ", iptr->isn_arg.instr,
+ INT_MAX, NULL);
+ msg(" -------------");
+ }
+ break;
case ISN_SUBSTITUTE:
{
subs_T *subs = &iptr->isn_arg.subs;
@@ -5225,6 +5283,7 @@ tv2bool(typval_T *tv)
case VAR_UNKNOWN:
case VAR_ANY:
case VAR_VOID:
+ case VAR_INSTR:
break;
}
return FALSE;