forked from aniani/vim
patch 9.1.1148: Vim9: finding imported scripts can be further improved
Problem: Vim9: finding imported scripts can be further improved (after v9.1.1146) Solution: Eliminate extra find_imported() call (Hirohito Higashi) related: #16602 related: #16660 closes: #16731 Signed-off-by: Hirohito Higashi <h.east.727@gmail.com> Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
00a00f5d3f
commit
6c0128385e
@@ -2,7 +2,7 @@
|
|||||||
int generate_ppconst(cctx_T *cctx, ppconst_T *ppconst);
|
int generate_ppconst(cctx_T *cctx, ppconst_T *ppconst);
|
||||||
void clear_ppconst(ppconst_T *ppconst);
|
void clear_ppconst(ppconst_T *ppconst);
|
||||||
int compile_member(int is_slice, int *keeping_dict, cctx_T *cctx);
|
int compile_member(int is_slice, int *keeping_dict, cctx_T *cctx);
|
||||||
int compile_load_scriptvar(cctx_T *cctx, char_u *name, char_u *start, char_u **end);
|
int compile_load_scriptvar(cctx_T *cctx, char_u *name, char_u *start, char_u **end, imported_T *import);
|
||||||
int compile_load(char_u **arg, char_u *end_arg, cctx_T *cctx, int is_expr, int error);
|
int compile_load(char_u **arg, char_u *end_arg, cctx_T *cctx, int is_expr, int error);
|
||||||
int compile_arguments(char_u **arg, cctx_T *cctx, int *argcount, ca_special_T special_fn);
|
int compile_arguments(char_u **arg, cctx_T *cctx, int *argcount, ca_special_T special_fn);
|
||||||
char_u *to_name_end(char_u *arg, int use_namespace);
|
char_u *to_name_end(char_u *arg, int use_namespace);
|
||||||
|
@@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1148,
|
||||||
/**/
|
/**/
|
||||||
1147,
|
1147,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -1374,7 +1374,7 @@ generate_loadvar(cctx_T *cctx, lhs_T *lhs)
|
|||||||
case dest_script:
|
case dest_script:
|
||||||
case dest_script_v9:
|
case dest_script_v9:
|
||||||
res = compile_load_scriptvar(cctx,
|
res = compile_load_scriptvar(cctx,
|
||||||
name + (name[1] == ':' ? 2 : 0), NULL, NULL);
|
name + (name[1] == ':' ? 2 : 0), NULL, NULL, NULL);
|
||||||
break;
|
break;
|
||||||
case dest_env:
|
case dest_env:
|
||||||
// Include $ in the name here
|
// Include $ in the name here
|
||||||
|
@@ -538,11 +538,12 @@ compile_load_scriptvar(
|
|||||||
cctx_T *cctx,
|
cctx_T *cctx,
|
||||||
char_u *name, // variable NUL terminated
|
char_u *name, // variable NUL terminated
|
||||||
char_u *start, // start of variable
|
char_u *start, // start of variable
|
||||||
char_u **end) // end of variable, may be NULL
|
char_u **end, // end of variable, may be NULL
|
||||||
|
imported_T *import) // found imported item, can be NULL
|
||||||
{
|
{
|
||||||
scriptitem_T *si;
|
scriptitem_T *si;
|
||||||
int idx;
|
int idx;
|
||||||
imported_T *import;
|
imported_T *imp;
|
||||||
|
|
||||||
if (!SCRIPT_ID_VALID(current_sctx.sc_sid))
|
if (!SCRIPT_ID_VALID(current_sctx.sc_sid))
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -557,8 +558,14 @@ compile_load_scriptvar(
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
import = end == NULL ? NULL : find_imported(name, 0, FALSE);
|
if (end == NULL)
|
||||||
if (import != NULL)
|
imp = NULL;
|
||||||
|
else if (import == NULL)
|
||||||
|
imp = find_imported(name, 0, FALSE);
|
||||||
|
else
|
||||||
|
imp = import;
|
||||||
|
|
||||||
|
if (imp != NULL)
|
||||||
{
|
{
|
||||||
char_u *p = skipwhite(*end);
|
char_u *p = skipwhite(*end);
|
||||||
char_u *exp_name;
|
char_u *exp_name;
|
||||||
@@ -568,8 +575,8 @@ compile_load_scriptvar(
|
|||||||
int done = FALSE;
|
int done = FALSE;
|
||||||
int res = OK;
|
int res = OK;
|
||||||
|
|
||||||
check_script_symlink(import->imp_sid);
|
check_script_symlink(imp->imp_sid);
|
||||||
import_check_sourced_sid(&import->imp_sid);
|
import_check_sourced_sid(&imp->imp_sid);
|
||||||
|
|
||||||
// Need to lookup the member.
|
// Need to lookup the member.
|
||||||
if (*p != '.')
|
if (*p != '.')
|
||||||
@@ -591,11 +598,11 @@ compile_load_scriptvar(
|
|||||||
cc = *p;
|
cc = *p;
|
||||||
*p = NUL;
|
*p = NUL;
|
||||||
|
|
||||||
si = SCRIPT_ITEM(import->imp_sid);
|
si = SCRIPT_ITEM(imp->imp_sid);
|
||||||
if (si->sn_import_autoload && si->sn_state == SN_STATE_NOT_LOADED)
|
if (si->sn_import_autoload && si->sn_state == SN_STATE_NOT_LOADED)
|
||||||
// "import autoload './dir/script.vim'" or
|
// "import autoload './dir/script.vim'" or
|
||||||
// "import autoload './autoload/script.vim'" - load script first
|
// "import autoload './autoload/script.vim'" - load script first
|
||||||
res = generate_SOURCE(cctx, import->imp_sid);
|
res = generate_SOURCE(cctx, imp->imp_sid);
|
||||||
|
|
||||||
if (res == OK)
|
if (res == OK)
|
||||||
{
|
{
|
||||||
@@ -624,17 +631,17 @@ compile_load_scriptvar(
|
|||||||
{
|
{
|
||||||
char_u sid_name[MAX_FUNC_NAME_LEN];
|
char_u sid_name[MAX_FUNC_NAME_LEN];
|
||||||
|
|
||||||
func_name_with_sid(exp_name, import->imp_sid, sid_name);
|
func_name_with_sid(exp_name, imp->imp_sid, sid_name);
|
||||||
res = generate_PUSHFUNC(cctx, sid_name, &t_func_any, TRUE);
|
res = generate_PUSHFUNC(cctx, sid_name, &t_func_any, TRUE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
res = generate_OLDSCRIPT(cctx, ISN_LOADEXPORT, exp_name,
|
res = generate_OLDSCRIPT(cctx, ISN_LOADEXPORT, exp_name,
|
||||||
import->imp_sid, &t_any);
|
imp->imp_sid, &t_any);
|
||||||
done = TRUE;
|
done = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
idx = find_exported(import->imp_sid, exp_name, &ufunc, &type,
|
idx = find_exported(imp->imp_sid, exp_name, &ufunc, &type,
|
||||||
cctx, NULL, TRUE);
|
cctx, NULL, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -656,7 +663,7 @@ compile_load_scriptvar(
|
|||||||
}
|
}
|
||||||
|
|
||||||
generate_VIM9SCRIPT(cctx, ISN_LOADSCRIPT,
|
generate_VIM9SCRIPT(cctx, ISN_LOADSCRIPT,
|
||||||
import->imp_sid,
|
imp->imp_sid,
|
||||||
idx,
|
idx,
|
||||||
type);
|
type);
|
||||||
return OK;
|
return OK;
|
||||||
@@ -771,7 +778,7 @@ compile_load(
|
|||||||
res = generate_funcref(cctx, name, FALSE);
|
res = generate_funcref(cctx, name, FALSE);
|
||||||
else
|
else
|
||||||
res = compile_load_scriptvar(cctx, name,
|
res = compile_load_scriptvar(cctx, name,
|
||||||
NULL, &end);
|
NULL, &end, NULL);
|
||||||
break;
|
break;
|
||||||
case 'g': if (vim_strchr(name, AUTOLOAD_CHAR) == NULL)
|
case 'g': if (vim_strchr(name, AUTOLOAD_CHAR) == NULL)
|
||||||
{
|
{
|
||||||
@@ -887,11 +894,13 @@ compile_load(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
imported_T *imp = NULL;
|
||||||
|
|
||||||
// "var" can be script-local even without using "s:" if it
|
// "var" can be script-local even without using "s:" if it
|
||||||
// already exists in a Vim9 script or when it's imported.
|
// already exists in a Vim9 script or when it's imported.
|
||||||
if (script_var_exists(*arg, len, cctx, NULL) == OK
|
if (script_var_exists(*arg, len, cctx, NULL) == OK
|
||||||
|| find_imported(name, 0, FALSE) != NULL)
|
|| (imp = find_imported(name, 0, FALSE)) != NULL)
|
||||||
res = compile_load_scriptvar(cctx, name, *arg, &end);
|
res = compile_load_scriptvar(cctx, name, *arg, &end, imp);
|
||||||
|
|
||||||
// When evaluating an expression and the name starts with an
|
// When evaluating an expression and the name starts with an
|
||||||
// uppercase letter it can be a user defined function.
|
// uppercase letter it can be a user defined function.
|
||||||
|
Reference in New Issue
Block a user