Mercurial > vim
diff src/vim9compile.c @ 19528:3b026343f398 v8.2.0321
patch 8.2.0321: Vim9: ":execute" does not work yet
Commit: https://github.com/vim/vim/commit/ad39c094d261109a695aba2c4f19fe336736cc55
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Feb 26 18:23:43 2020 +0100
patch 8.2.0321: Vim9: ":execute" does not work yet
Problem: Vim9: ":execute" does not work yet.
Solution: Add ISN_EXECUTE. (closes https://github.com/vim/vim/issues/5699) Also make :echo work with more
than one argument.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 26 Feb 2020 18:30:04 +0100 |
parents | 860b39ed0e0b |
children | 48e71f948360 |
line wrap: on
line diff
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -1116,6 +1116,21 @@ generate_ECHO(cctx_T *cctx, int with_whi 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 @@ compile_echo(char_u *arg, int with_white 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 @@ compile_def_function(ufunc_T *ufunc, int 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 @@ delete_instr(isn_T *isn) case ISN_DCALL: case ISN_DROP: case ISN_ECHO: + case ISN_EXECUTE: case ISN_ENDTRY: case ISN_FOR: case ISN_FUNCREF: