comparison src/vim9execute.c @ 20538:9f921ba86d05 v8.2.0823

patch 8.2.0823: Vim9: script reload test is disabled Commit: https://github.com/vim/vim/commit/25e0f5863e9010a75a1ff0d04e8f886403968755 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 25 22:36:50 2020 +0200 patch 8.2.0823: Vim9: script reload test is disabled Problem: Vim9: script reload test is disabled. Solution: Compile a function in the context of the script where it was defined. Set execution stack for compiled function. Add a test that an error is reported for the right file/function.
author Bram Moolenaar <Bram@vim.org>
date Mon, 25 May 2020 22:45:03 +0200
parents 489cb75c76b6
children 876e16c48bd1
comparison
equal deleted inserted replaced
20537:cceaa5ec43aa 20538:9f921ba86d05
228 + dfunc->df_varcount + dfunc->df_closure_count; 228 + dfunc->df_varcount + dfunc->df_closure_count;
229 229
230 // Set execution state to the start of the called function. 230 // Set execution state to the start of the called function.
231 ectx->ec_dfunc_idx = cdf_idx; 231 ectx->ec_dfunc_idx = cdf_idx;
232 ectx->ec_instr = dfunc->df_instr; 232 ectx->ec_instr = dfunc->df_instr;
233 estack_push_ufunc(ETYPE_UFUNC, dfunc->df_ufunc, 1); 233 estack_push_ufunc(dfunc->df_ufunc, 1);
234 234
235 // Decide where to start execution, handles optional arguments. 235 // Decide where to start execution, handles optional arguments.
236 init_instr_idx(ufunc, argcount, ectx); 236 init_instr_idx(ufunc, argcount, ectx);
237 237
238 return OK; 238 return OK;
654 int idx; 654 int idx;
655 int ret = FAIL; 655 int ret = FAIL;
656 int defcount = ufunc->uf_args.ga_len - argc; 656 int defcount = ufunc->uf_args.ga_len - argc;
657 int save_sc_version = current_sctx.sc_version; 657 int save_sc_version = current_sctx.sc_version;
658 int breakcheck_count = 0; 658 int breakcheck_count = 0;
659 int called_emsg_before = called_emsg;
659 660
660 // Get pointer to item in the stack. 661 // Get pointer to item in the stack.
661 #define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx) 662 #define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx)
662 663
663 // Get pointer to item at the bottom of the stack, -1 is the bottom. 664 // Get pointer to item at the bottom of the stack, -1 is the bottom.
671 #define STACK_OUT_TV_VAR(idx) (((typval_T *)ectx.ec_outer_stack->ga_data) + ectx.ec_outer_frame + STACK_FRAME_SIZE + idx) 672 #define STACK_OUT_TV_VAR(idx) (((typval_T *)ectx.ec_outer_stack->ga_data) + ectx.ec_outer_frame + STACK_FRAME_SIZE + idx)
672 673
673 if (ufunc->uf_dfunc_idx == UF_NOT_COMPILED 674 if (ufunc->uf_dfunc_idx == UF_NOT_COMPILED
674 || (ufunc->uf_dfunc_idx == UF_TO_BE_COMPILED 675 || (ufunc->uf_dfunc_idx == UF_TO_BE_COMPILED
675 && compile_def_function(ufunc, FALSE, NULL) == FAIL)) 676 && compile_def_function(ufunc, FALSE, NULL) == FAIL))
677 {
678 if (called_emsg == called_emsg_before)
679 semsg(_("E1091: Function is not compiled: %s"),
680 ufunc->uf_name_exp == NULL
681 ? ufunc->uf_name : ufunc->uf_name_exp);
676 return FAIL; 682 return FAIL;
683 }
677 684
678 { 685 {
679 // Check the function was really compiled. 686 // Check the function was really compiled.
680 dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) 687 dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
681 + ufunc->uf_dfunc_idx; 688 + ufunc->uf_dfunc_idx;