1
0
forked from aniani/vim

patch 8.2.4375: ctx_imports is not used

Problem:    ctx_imports is not used.
Solution:   Delete ctx_imports.  Add missing dependency.
This commit is contained in:
Bram Moolenaar 2022-02-13 21:51:08 +00:00
parent 0631bb4ed7
commit 4b1d963972
11 changed files with 24 additions and 63 deletions

View 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 \

View 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)
{

View 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))
{

View 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);

View 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);

View 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)

View File

@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4375,
/**/
4374,
/**/

View 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"

View 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;

View 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);

View 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);