Mercurial > vim
diff src/vim9compile.c @ 22691:dda110a14be4 v8.2.1894
patch 8.2.1894: Vim9: command modifiers are not supported
Commit: https://github.com/vim/vim/commit/f4c6e1e75c2a7f2ca3a7f4529e7da31dc98557e9
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Oct 23 18:02:32 2020 +0200
patch 8.2.1894: Vim9: command modifiers are not supported
Problem: Vim9: command modifiers are not supported.
Solution: Support "silent" and "silent!".
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 23 Oct 2020 18:15:03 +0200 |
parents | 80b4e604d1d5 |
children | c996700d569f |
line wrap: on
line diff
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -141,6 +141,8 @@ struct cctx_S { garray_T ctx_type_stack; // type of each item on the stack garray_T *ctx_type_list; // list of pointers to allocated types + + int ctx_silent; // set when ISN_SILENT was generated }; static void delete_def_function_contents(dfunc_T *dfunc); @@ -1821,6 +1823,40 @@ generate_EXECCONCAT(cctx_T *cctx, int co } /* + * Generate any instructions for side effects of "cmdmod". + */ + static int +generate_cmdmods(cctx_T *cctx) +{ + isn_T *isn; + + // TODO: use more modifiers in the command + if (cmdmod.msg_silent || cmdmod.emsg_silent) + { + if ((isn = generate_instr(cctx, ISN_SILENT)) == NULL) + return FAIL; + isn->isn_arg.number = cmdmod.emsg_silent; + cctx->ctx_silent = cmdmod.emsg_silent ? 2 : 1; + } + return OK; +} + + static int +generate_restore_cmdmods(cctx_T *cctx) +{ + isn_T *isn; + + if (cctx->ctx_silent > 0) + { + if ((isn = generate_instr(cctx, ISN_UNSILENT)) == NULL) + return FAIL; + isn->isn_arg.number = cctx->ctx_silent == 2; + cctx->ctx_silent = 0; + } + return OK; +} + +/* * Reserve space for a local variable. * Return the variable or NULL if it failed. */ @@ -7149,7 +7185,8 @@ compile_def_function(ufunc_T *ufunc, int line = (char_u *)""; continue; } - // TODO: use modifiers in the command + generate_cmdmods(&cctx); + undo_cmdmod(&ea, save_msg_scroll); cmdmod = save_cmdmod; @@ -7461,6 +7498,9 @@ nextline: goto erret; line = skipwhite(line); + // Undo any command modifiers. + generate_restore_cmdmods(&cctx); + if (cctx.ctx_type_stack.ga_len < 0) { iemsg("Type stack underflow"); @@ -7767,6 +7807,7 @@ delete_instr(isn_T *isn) case ISN_PUT: case ISN_RETURN: case ISN_SHUFFLE: + case ISN_SILENT: case ISN_SLICE: case ISN_STORE: case ISN_STOREDICT: @@ -7780,6 +7821,7 @@ delete_instr(isn_T *isn) case ISN_STRSLICE: case ISN_THROW: case ISN_TRY: + case ISN_UNSILENT: // nothing allocated break; }