Problem: ctx_imports is not used.
Solution: Delete ctx_imports. Add missing dependency.
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 \
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)
{
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))
{
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)
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);
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)
{
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);
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);
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)
{
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)
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 4375,
/**/
4374,
/**/
} 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 {
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"
&& (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;
}
/*
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.
}
/*
- * 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;
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
: 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)
{
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;
estack_pop();
ga_clear_strings(&lines_to_free);
- free_imported(&cctx);
free_locals(&cctx);
ga_clear(&cctx.ctx_type_stack);
return ret;
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);
// "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
}
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);
{
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);