Mercurial > vim
diff src/vim9execute.c @ 24606:a4fda40e0bb9 v8.2.2842
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Commit: https://github.com/vim/vim/commit/f18332fb9e2e4208a97d800f096b02c6681780e7
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri May 7 17:55:55 2021 +0200
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Problem: Vim9: skip argument to searchpair() is not compiled.
Solution: Add VAR_INSTR.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 07 May 2021 18:00:04 +0200 |
parents | 5c456a88f651 |
children | 07b3d21a8b4b |
line wrap: on
line diff
--- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -1259,6 +1259,12 @@ fill_partial_and_closure(partial_T *pt, 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 *inst } #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;