forked from aniani/vim
patch 8.2.2834: Vim9: :cexpr does not work with local variables
Problem: Vim9: :cexpr does not work with local variables. Solution: Compile :cexpr.
This commit is contained in:
@@ -8704,6 +8704,34 @@ compile_redir(char_u *line, exarg_T *eap, cctx_T *cctx)
|
||||
return compile_exec(line, eap, cctx);
|
||||
}
|
||||
|
||||
static char_u *
|
||||
compile_cexpr(char_u *line, exarg_T *eap, cctx_T *cctx)
|
||||
{
|
||||
isn_T *isn;
|
||||
char_u *p;
|
||||
|
||||
isn = generate_instr(cctx, ISN_CEXPR_AUCMD);
|
||||
if (isn == NULL)
|
||||
return NULL;
|
||||
isn->isn_arg.number = eap->cmdidx;
|
||||
|
||||
p = eap->arg;
|
||||
if (compile_expr0(&p, cctx) == FAIL)
|
||||
return NULL;
|
||||
|
||||
isn = generate_instr(cctx, ISN_CEXPR_CORE);
|
||||
if (isn == NULL)
|
||||
return NULL;
|
||||
isn->isn_arg.cexpr.cexpr_ref = ALLOC_ONE(cexprref_T);
|
||||
if (isn->isn_arg.cexpr.cexpr_ref == NULL)
|
||||
return NULL;
|
||||
isn->isn_arg.cexpr.cexpr_ref->cer_cmdidx = eap->cmdidx;
|
||||
isn->isn_arg.cexpr.cexpr_ref->cer_forceit = eap->forceit;
|
||||
isn->isn_arg.cexpr.cexpr_ref->cer_cmdline = vim_strsave(skipwhite(line));
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a function to the list of :def functions.
|
||||
* This sets "ufunc->uf_dfunc_idx" but the function isn't compiled yet.
|
||||
@@ -9262,6 +9290,16 @@ compile_def_function(
|
||||
line = compile_redir(line, &ea, &cctx);
|
||||
break;
|
||||
|
||||
case CMD_cexpr:
|
||||
case CMD_lexpr:
|
||||
case CMD_caddexpr:
|
||||
case CMD_laddexpr:
|
||||
case CMD_cgetexpr:
|
||||
case CMD_lgetexpr:
|
||||
ea.arg = p;
|
||||
line = compile_cexpr(line, &ea, &cctx);
|
||||
break;
|
||||
|
||||
// TODO: any other commands with an expression argument?
|
||||
|
||||
case CMD_append:
|
||||
@@ -9602,6 +9640,10 @@ delete_instr(isn_T *isn)
|
||||
vim_free(isn->isn_arg.try.try_ref);
|
||||
break;
|
||||
|
||||
case ISN_CEXPR_CORE:
|
||||
vim_free(isn->isn_arg.cexpr.cexpr_ref);
|
||||
break;
|
||||
|
||||
case ISN_2BOOL:
|
||||
case ISN_2STRING:
|
||||
case ISN_2STRING_ANY:
|
||||
@@ -9614,6 +9656,7 @@ delete_instr(isn_T *isn)
|
||||
case ISN_BLOBINDEX:
|
||||
case ISN_BLOBSLICE:
|
||||
case ISN_CATCH:
|
||||
case ISN_CEXPR_AUCMD:
|
||||
case ISN_CHECKLEN:
|
||||
case ISN_CHECKNR:
|
||||
case ISN_CMDMOD_REV:
|
||||
|
Reference in New Issue
Block a user