comparison 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
comparison
equal deleted inserted replaced
22690:3b5c9b442a73 22691:dda110a14be4
139 // function 139 // function
140 int ctx_outer_used; // var in ctx_outer was used 140 int ctx_outer_used; // var in ctx_outer was used
141 141
142 garray_T ctx_type_stack; // type of each item on the stack 142 garray_T ctx_type_stack; // type of each item on the stack
143 garray_T *ctx_type_list; // list of pointers to allocated types 143 garray_T *ctx_type_list; // list of pointers to allocated types
144
145 int ctx_silent; // set when ISN_SILENT was generated
144 }; 146 };
145 147
146 static void delete_def_function_contents(dfunc_T *dfunc); 148 static void delete_def_function_contents(dfunc_T *dfunc);
147 149
148 /* 150 /*
1815 isn_T *isn; 1817 isn_T *isn;
1816 1818
1817 if ((isn = generate_instr_drop(cctx, ISN_EXECCONCAT, count)) == NULL) 1819 if ((isn = generate_instr_drop(cctx, ISN_EXECCONCAT, count)) == NULL)
1818 return FAIL; 1820 return FAIL;
1819 isn->isn_arg.number = count; 1821 isn->isn_arg.number = count;
1822 return OK;
1823 }
1824
1825 /*
1826 * Generate any instructions for side effects of "cmdmod".
1827 */
1828 static int
1829 generate_cmdmods(cctx_T *cctx)
1830 {
1831 isn_T *isn;
1832
1833 // TODO: use more modifiers in the command
1834 if (cmdmod.msg_silent || cmdmod.emsg_silent)
1835 {
1836 if ((isn = generate_instr(cctx, ISN_SILENT)) == NULL)
1837 return FAIL;
1838 isn->isn_arg.number = cmdmod.emsg_silent;
1839 cctx->ctx_silent = cmdmod.emsg_silent ? 2 : 1;
1840 }
1841 return OK;
1842 }
1843
1844 static int
1845 generate_restore_cmdmods(cctx_T *cctx)
1846 {
1847 isn_T *isn;
1848
1849 if (cctx->ctx_silent > 0)
1850 {
1851 if ((isn = generate_instr(cctx, ISN_UNSILENT)) == NULL)
1852 return FAIL;
1853 isn->isn_arg.number = cctx->ctx_silent == 2;
1854 cctx->ctx_silent = 0;
1855 }
1820 return OK; 1856 return OK;
1821 } 1857 }
1822 1858
1823 /* 1859 /*
1824 * Reserve space for a local variable. 1860 * Reserve space for a local variable.
7147 goto erret; 7183 goto erret;
7148 // empty line or comment 7184 // empty line or comment
7149 line = (char_u *)""; 7185 line = (char_u *)"";
7150 continue; 7186 continue;
7151 } 7187 }
7152 // TODO: use modifiers in the command 7188 generate_cmdmods(&cctx);
7189
7153 undo_cmdmod(&ea, save_msg_scroll); 7190 undo_cmdmod(&ea, save_msg_scroll);
7154 cmdmod = save_cmdmod; 7191 cmdmod = save_cmdmod;
7155 7192
7156 // Skip ":call" to get to the function name. 7193 // Skip ":call" to get to the function name.
7157 p = ea.cmd; 7194 p = ea.cmd;
7458 } 7495 }
7459 nextline: 7496 nextline:
7460 if (line == NULL) 7497 if (line == NULL)
7461 goto erret; 7498 goto erret;
7462 line = skipwhite(line); 7499 line = skipwhite(line);
7500
7501 // Undo any command modifiers.
7502 generate_restore_cmdmods(&cctx);
7463 7503
7464 if (cctx.ctx_type_stack.ga_len < 0) 7504 if (cctx.ctx_type_stack.ga_len < 0)
7465 { 7505 {
7466 iemsg("Type stack underflow"); 7506 iemsg("Type stack underflow");
7467 goto erret; 7507 goto erret;
7765 case ISN_PUSHNR: 7805 case ISN_PUSHNR:
7766 case ISN_PUSHSPEC: 7806 case ISN_PUSHSPEC:
7767 case ISN_PUT: 7807 case ISN_PUT:
7768 case ISN_RETURN: 7808 case ISN_RETURN:
7769 case ISN_SHUFFLE: 7809 case ISN_SHUFFLE:
7810 case ISN_SILENT:
7770 case ISN_SLICE: 7811 case ISN_SLICE:
7771 case ISN_STORE: 7812 case ISN_STORE:
7772 case ISN_STOREDICT: 7813 case ISN_STOREDICT:
7773 case ISN_STORELIST: 7814 case ISN_STORELIST:
7774 case ISN_STORENR: 7815 case ISN_STORENR:
7778 case ISN_STOREV: 7819 case ISN_STOREV:
7779 case ISN_STRINDEX: 7820 case ISN_STRINDEX:
7780 case ISN_STRSLICE: 7821 case ISN_STRSLICE:
7781 case ISN_THROW: 7822 case ISN_THROW:
7782 case ISN_TRY: 7823 case ISN_TRY:
7824 case ISN_UNSILENT:
7783 // nothing allocated 7825 // nothing allocated
7784 break; 7826 break;
7785 } 7827 }
7786 } 7828 }
7787 7829