]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.4375: ctx_imports is not used v8.2.4375
authorBram Moolenaar <Bram@vim.org>
Sun, 13 Feb 2022 21:51:08 +0000 (21:51 +0000)
committerBram Moolenaar <Bram@vim.org>
Sun, 13 Feb 2022 21:51:08 +0000 (21:51 +0000)
Problem:    ctx_imports is not used.
Solution:   Delete ctx_imports.  Add missing dependency.

src/Makefile
src/eval.c
src/evalfunc.c
src/evalvars.c
src/proto/vim9compile.pro
src/userfunc.c
src/version.c
src/vim9.h
src/vim9compile.c
src/vim9expr.c
src/vim9script.c

index 46af6c3babc63c152c79dbfb23957b82bf4646ee..3288c5b4781f3bba80ba1abb29f0d93c4aea5255 100644 (file)
@@ -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 \
index 91e9bbbf7122c15a9495f83a389d8173c8a21ab5..c4c403c19dcc4b58bbfc6cf24e789d9905054211 100644 (file)
@@ -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)
        {
index 31205ea5ae245b850964c5c8a424c8b8b28b9263..88b8f89e26ee96cc1de6f8e5ae1091e22e25c862 100644 (file)
@@ -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))
        {
index d182a0e85a148310fc8beeada16a41b12a86f23c..8e862df8bb8166721f17808832acc1044e196435 100644 (file)
@@ -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);
index 9effb1744b09719f086724ad35be8b49e5447964..0e71b93fa0997fd0cfcf56e7cbbcd0db2b43852c 100644 (file)
@@ -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);
index 6007ab7c7cdee8d6331d6e95daf6db77addf0e1f..10a529e03f9bb0c4a531f0e7d22200283311e537 100644 (file)
@@ -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)
index efa15b834143f17dc4598bf98ecd9803915c82ec..a7a39e943ce35c3dee9236042776b239422d8bbc 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4375,
 /**/
     4374,
 /**/
index 45e97a2db94feda2a1d7cf3c5cb1a6f31610a6b0..87ee6b163f1677655b140c63ea1dc8ad5a657ba4 100644 (file)
@@ -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"
index 2494d239f1d82f03b48c9d7572737d8bb7be6e61..edbd33e4b185af877ff3ca4300ec21cf0a4315c5 100644 (file)
@@ -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;
@@ -636,23 +618,6 @@ find_imported(char_u *name, size_t len, int load, cctx_T *cctx)
     return ret;
 }
 
-/*
- * 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
@@ -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;
index 1e53478a50b6d5a02ae33b27831f5ebf281a4c9d..46d14dc05e100a809e4a95c8adf5abdcb2febead 100644 (file)
@@ -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);
index fde51c91f969dbf8be91dded498b81a007eaf560..74f93258918afad64efccf5241748bfa7746b290 100644 (file)
@@ -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);