diff src/vim9compile.c @ 27698:3813036f19cb v8.2.4375

patch 8.2.4375: ctx_imports is not used Commit: https://github.com/vim/vim/commit/4b1d9639726ebe1630991488a1314db628b6b854 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 13 21:51:08 2022 +0000 patch 8.2.4375: ctx_imports is not used Problem: ctx_imports is not used. Solution: Delete ctx_imports. Add missing dependency.
author Bram Moolenaar <Bram@vim.org>
date Sun, 13 Feb 2022 23:00:04 +0100
parents 78d4f843521a
children 072c7ae27b06
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -281,7 +281,7 @@ variable_exists(char_u *name, size_t len
 		&& (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, si
 }
 
 /*
- * 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, 
 }
 
 /*
- * 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;