patch 8.2.0321: Vim9: ":execute" does not work yet
Problem: Vim9: ":execute" does not work yet.
Solution: Add ISN_EXECUTE. (closes #5699) Also make :echo work with more
than one argument.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index d62df6e..32d6349 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -1116,6 +1116,21 @@
return OK;
}
+/*
+ * Generate an ISN_EXECUTE instruction.
+ */
+ static int
+generate_EXECUTE(cctx_T *cctx, int count)
+{
+ isn_T *isn;
+
+ if ((isn = generate_instr_drop(cctx, ISN_EXECUTE, count)) == NULL)
+ return FAIL;
+ isn->isn_arg.number = count;
+
+ return OK;
+}
+
static int
generate_EXEC(cctx_T *cctx, char_u *line)
{
@@ -4671,14 +4686,40 @@
char_u *p = arg;
int count = 0;
- // for ()
+ for (;;)
{
if (compile_expr1(&p, cctx) == FAIL)
return NULL;
++count;
+ p = skipwhite(p);
+ if (ends_excmd(*p))
+ break;
}
generate_ECHO(cctx, with_white, count);
+ return p;
+}
+
+/*
+ * compile "execute expr"
+ */
+ static char_u *
+compile_execute(char_u *arg, cctx_T *cctx)
+{
+ char_u *p = arg;
+ int count = 0;
+
+ for (;;)
+ {
+ if (compile_expr1(&p, cctx) == FAIL)
+ return NULL;
+ ++count;
+ p = skipwhite(p);
+ if (ends_excmd(*p))
+ break;
+ }
+
+ generate_EXECUTE(cctx, count);
return p;
}
@@ -5017,12 +5058,14 @@
case CMD_echon:
line = compile_echo(p, FALSE, &cctx);
break;
+ case CMD_execute:
+ line = compile_execute(p, &cctx);
+ break;
default:
// Not recognized, execute with do_cmdline_cmd().
// TODO:
// CMD_echomsg
- // CMD_execute
// etc.
generate_EXEC(&cctx, line);
line = (char_u *)"";
@@ -5150,6 +5193,7 @@
case ISN_DCALL:
case ISN_DROP:
case ISN_ECHO:
+ case ISN_EXECUTE:
case ISN_ENDTRY:
case ISN_FOR:
case ISN_FUNCREF: