diff options
-rw-r--r-- | src/Makefile | 2 | ||||
-rw-r--r-- | src/eval.c | 3 | ||||
-rw-r--r-- | src/evalfunc.c | 2 | ||||
-rw-r--r-- | src/evalvars.c | 8 | ||||
-rw-r--r-- | src/proto/vim9compile.pro | 2 | ||||
-rw-r--r-- | src/userfunc.c | 5 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9.h | 4 | ||||
-rw-r--r-- | src/vim9compile.c | 51 | ||||
-rw-r--r-- | src/vim9expr.c | 6 | ||||
-rw-r--r-- | src/vim9script.c | 2 |
11 files changed, 24 insertions, 63 deletions
diff --git a/src/Makefile b/src/Makefile index 46af6c3bab..3288c5b478 100644 --- a/src/Makefile +++ b/src/Makefile @@ -4187,7 +4187,7 @@ objects/vim9script.o: vim9script.c vim.h protodef.h auto/config.h feature.h \ objects/vim9type.o: vim9type.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h termdefs.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ - proto.h globals.h errors.h + proto.h globals.h errors.h vim9.h objects/viminfo.o: viminfo.c vim.h protodef.h auto/config.h feature.h os_unix.h \ auto/osdef.h ascii.h keymap.h termdefs.h macros.h option.h beval.h \ proto/gui_beval.pro structs.h regexp.h gui.h alloc.h ex_cmds.h spell.h \ diff --git a/src/eval.c b/src/eval.c index 91e9bbbf71..c4c403c19d 100644 --- a/src/eval.c +++ b/src/eval.c @@ -967,8 +967,7 @@ get_lval( if (*p == '.') { - imported_T *import = find_imported(lp->ll_name, p - lp->ll_name, - TRUE, NULL); + imported_T *import = find_imported(lp->ll_name, p - lp->ll_name, TRUE); if (import != NULL) { diff --git a/src/evalfunc.c b/src/evalfunc.c index 31205ea5ae..88b8f89e26 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -3131,7 +3131,7 @@ f_call(typval_T *argvars, typval_T *rettv) dot = vim_strchr(func, '.'); if (dot != NULL) { - imported_T *import = find_imported(func, dot - func, TRUE, NULL); + imported_T *import = find_imported(func, dot - func, TRUE); if (import != NULL && SCRIPT_ID_VALID(import->imp_sid)) { diff --git a/src/evalvars.c b/src/evalvars.c index d182a0e85a..8e862df8bb 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -2735,7 +2735,7 @@ eval_variable( char_u *p = STRNCMP(name, "s:", 2) == 0 ? name + 2 : name; if (sid == 0) - import = find_imported(p, 0, TRUE, NULL); + import = find_imported(p, 0, TRUE); // imported variable from another script if (import != NULL || sid != 0) @@ -3096,7 +3096,7 @@ lookup_scriptitem( res = HASHITEM_EMPTY(hi) ? FAIL : OK; // if not script-local, then perhaps imported - if (res == FAIL && find_imported(p, 0, FALSE, NULL) != NULL) + if (res == FAIL && find_imported(p, 0, FALSE) != NULL) res = OK; if (p != buffer) vim_free(p); @@ -3491,7 +3491,7 @@ set_var_const( if (di == NULL && var_in_vim9script) { - imported_T *import = find_imported(varname, 0, FALSE, NULL); + imported_T *import = find_imported(varname, 0, FALSE); if (import != NULL) { @@ -4696,7 +4696,7 @@ expand_autload_callback(callback_T *cb) p = vim_strchr(name, '.'); if (p == NULL) return; - import = find_imported(name, p - name, FALSE, NULL); + import = find_imported(name, p - name, FALSE); if (import != NULL && SCRIPT_ID_VALID(import->imp_sid)) { scriptitem_T *si = SCRIPT_ITEM(import->imp_sid); diff --git a/src/proto/vim9compile.pro b/src/proto/vim9compile.pro index 9effb1744b..0e71b93fa0 100644 --- a/src/proto/vim9compile.pro +++ b/src/proto/vim9compile.pro @@ -8,7 +8,7 @@ int need_type_where(type_T *actual, type_T *expected, int offset, where_T where, int need_type(type_T *actual, type_T *expected, int offset, int arg_idx, cctx_T *cctx, int silent, int actual_is_const); lvar_T *reserve_local(cctx_T *cctx, char_u *name, size_t len, int isConst, type_T *type); int get_script_item_idx(int sid, char_u *name, int check_writable, cctx_T *cctx, cstack_T *cstack); -imported_T *find_imported(char_u *name, size_t len, int load, cctx_T *cctx); +imported_T *find_imported(char_u *name, size_t len, int load); char_u *may_peek_next_line(cctx_T *cctx, char_u *arg, char_u **nextp); char_u *peek_next_line_from_context(cctx_T *cctx); char_u *next_line_from_context(cctx_T *cctx, int skip_comment); diff --git a/src/userfunc.c b/src/userfunc.c index 6007ab7c7c..10a529e03f 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -1614,7 +1614,7 @@ deref_func_name( p = name + 2; len -= 2; } - import = find_imported(p, len, FALSE, NULL); + import = find_imported(p, len, FALSE); // imported function from another script if (import != NULL) @@ -4591,8 +4591,7 @@ define_function(exarg_T *eap, char_u *name_arg, garray_T *lines_to_free) { char_u *uname = untrans_function_name(name); - import = find_imported(uname == NULL ? name : uname, 0, - FALSE, NULL); + import = find_imported(uname == NULL ? name : uname, 0, FALSE); } if (fp != NULL || import != NULL) diff --git a/src/version.c b/src/version.c index efa15b8341..a7a39e943c 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4375, +/**/ 4374, /**/ 4373, diff --git a/src/vim9.h b/src/vim9.h index 45e97a2db9..87ee6b163f 100644 --- a/src/vim9.h +++ b/src/vim9.h @@ -691,7 +691,7 @@ typedef struct { } lhs_T; /* - * Context for compiling lines of Vim script. + * Context for compiling lines of a :def function. * Stores info about the local variables and condition stack. */ struct cctx_S { @@ -710,8 +710,6 @@ struct cctx_S { int ctx_has_closure; // set to one if a closure was created in // the function - garray_T ctx_imports; // imported items - skip_T ctx_skip; scope_T *ctx_scope; // current scope, NULL at toplevel int ctx_had_return; // last seen statement was "return" diff --git a/src/vim9compile.c b/src/vim9compile.c index 2494d239f1..edbd33e4b1 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -281,7 +281,7 @@ variable_exists(char_u *name, size_t len, cctx_T *cctx) && (lookup_local(name, len, NULL, cctx) == OK || arg_exists(name, len, NULL, NULL, NULL, cctx) == OK)) || script_var_exists(name, len, cctx, NULL) == OK - || find_imported(name, len, FALSE, cctx) != NULL; + || find_imported(name, len, FALSE) != NULL; } /* @@ -329,7 +329,7 @@ check_defined( if ((cctx != NULL && (lookup_local(p, len, NULL, cctx) == OK || arg_exists(p, len, NULL, NULL, NULL, cctx) == OK)) - || find_imported(p, len, FALSE, cctx) != NULL + || find_imported(p, len, FALSE) != NULL || (ufunc = find_func_even_dead(p, 0)) != NULL) { // A local or script-local function can shadow a global function. @@ -594,36 +594,18 @@ find_imported_in_script(char_u *name, size_t len, int sid) } /* - * Find "name" in imported items of the current script or in "cctx" if not - * NULL. + * Find "name" in imported items of the current script. * If "load" is TRUE and the script was not loaded yet, load it now. */ imported_T * -find_imported(char_u *name, size_t len, int load, cctx_T *cctx) +find_imported(char_u *name, size_t len, int load) { - int idx; - imported_T *ret = NULL; + imported_T *ret; if (!SCRIPT_ID_VALID(current_sctx.sc_sid)) return NULL; - if (cctx != NULL) - for (idx = 0; idx < cctx->ctx_imports.ga_len; ++idx) - { - imported_T *import = ((imported_T *)cctx->ctx_imports.ga_data) - + idx; - - if (len == 0 ? STRCMP(name, import->imp_name) == 0 - : STRLEN(import->imp_name) == len - && STRNCMP(name, import->imp_name, len) == 0) - { - ret = import; - break; - } - } - - if (ret == NULL) - ret = find_imported_in_script(name, len, current_sctx.sc_sid); + ret = find_imported_in_script(name, len, current_sctx.sc_sid); if (ret != NULL && load && (ret->imp_flags & IMP_FLAGS_AUTOLOAD)) { scid_T dummy; @@ -637,23 +619,6 @@ find_imported(char_u *name, size_t len, int load, cctx_T *cctx) } /* - * Free all imported variables. - */ - static void -free_imported(cctx_T *cctx) -{ - int idx; - - for (idx = 0; idx < cctx->ctx_imports.ga_len; ++idx) - { - imported_T *import = ((imported_T *)cctx->ctx_imports.ga_data) + idx; - - vim_free(import->imp_name); - } - ga_clear(&cctx->ctx_imports); -} - -/* * Called when checking for a following operator at "arg". When the rest of * the line is empty or only a comment, peek the next line. If there is a next * line return a pointer to it and set "nextp". @@ -1364,7 +1329,7 @@ compile_lhs( : script_var_exists(var_start, lhs->lhs_varlen, cctx, NULL)) == OK; imported_T *import = - find_imported(var_start, lhs->lhs_varlen, FALSE, cctx); + find_imported(var_start, lhs->lhs_varlen, FALSE); if (script_namespace || script_var || import != NULL) { @@ -2600,7 +2565,6 @@ compile_def_function( ga_init2(&cctx.ctx_locals, sizeof(lvar_T), 10); // Each entry on the type stack consists of two type pointers. ga_init2(&cctx.ctx_type_stack, sizeof(type2_T), 50); - ga_init2(&cctx.ctx_imports, sizeof(imported_T), 10); cctx.ctx_type_list = &ufunc->uf_type_list; ga_init2(&cctx.ctx_instr, sizeof(isn_T), 50); instr = &cctx.ctx_instr; @@ -3291,7 +3255,6 @@ erret: estack_pop(); ga_clear_strings(&lines_to_free); - free_imported(&cctx); free_locals(&cctx); ga_clear(&cctx.ctx_type_stack); return ret; diff --git a/src/vim9expr.c b/src/vim9expr.c index 1e53478a50..46d14dc05e 100644 --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -266,7 +266,7 @@ compile_load_scriptvar( return OK; } - import = end == NULL ? NULL : find_imported(name, 0, FALSE, cctx); + import = end == NULL ? NULL : find_imported(name, 0, FALSE); if (import != NULL) { char_u *p = skipwhite(*end); @@ -502,7 +502,7 @@ compile_load( // "var" can be script-local even without using "s:" if it // already exists in a Vim9 script or when it's imported. if (script_var_exists(*arg, len, cctx, NULL) == OK - || find_imported(name, 0, FALSE, cctx) != NULL) + || find_imported(name, 0, FALSE) != NULL) res = compile_load_scriptvar(cctx, name, *arg, &end, FALSE); // When evaluating an expression and the name starts with an @@ -681,7 +681,7 @@ compile_call( } vim_strncpy(namebuf, *arg, varlen); - import = find_imported(name, varlen, FALSE, cctx); + import = find_imported(name, varlen, FALSE); if (import != NULL) { semsg(_(e_cannot_use_str_itself_it_is_imported), namebuf); diff --git a/src/vim9script.c b/src/vim9script.c index fde51c91f9..74f9325891 100644 --- a/src/vim9script.c +++ b/src/vim9script.c @@ -593,7 +593,7 @@ handle_import( { imported_T *imported; - imported = find_imported(as_name, STRLEN(as_name), FALSE, cctx); + imported = find_imported(as_name, STRLEN(as_name), FALSE); if (imported != NULL && imported->imp_sid != sid) { semsg(_(e_name_already_defined_str), as_name); |