0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

patch 8.2.4333: cstack not always passed to where it is needed

Problem:    cstack not always passed to where it is needed.
Solution:   Pass ctack through functions.
This commit is contained in:
Bram Moolenaar 2022-02-08 21:17:22 +00:00
parent dce2441a60
commit b6a138eb33
7 changed files with 19 additions and 10 deletions

View File

@ -975,7 +975,7 @@ get_lval(
cc = *p; cc = *p;
*p = NUL; *p = NUL;
if (find_exported(import->imp_sid, lp->ll_name, &ufunc, &type, if (find_exported(import->imp_sid, lp->ll_name, &ufunc, &type,
NULL, TRUE) == -1) NULL, NULL, TRUE) == -1)
{ {
*p = cc; *p = cc;
return NULL; return NULL;
@ -6056,7 +6056,7 @@ handle_subscript(
**arg = NUL; **arg = NUL;
idx = find_exported(rettv->vval.v_number, exp_name, &ufunc, &type, idx = find_exported(rettv->vval.v_number, exp_name, &ufunc, &type,
evalarg->eval_cctx, verbose); evalarg->eval_cctx, evalarg->eval_cstack, verbose);
**arg = cc; **arg = cc;
if (idx < 0 && ufunc == NULL) if (idx < 0 && ufunc == NULL)

View File

@ -7,7 +7,7 @@ int check_defined(char_u *p, size_t len, cctx_T *cctx, cstack_T *cstack, int is_
int need_type_where(type_T *actual, type_T *expected, int offset, where_T where, cctx_T *cctx, int silent, int actual_is_const); int need_type_where(type_T *actual, type_T *expected, int offset, where_T where, cctx_T *cctx, int silent, int actual_is_const);
int need_type(type_T *actual, type_T *expected, int offset, int arg_idx, cctx_T *cctx, int silent, int actual_is_const); 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); 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); 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, cctx_T *cctx);
char_u *may_peek_next_line(cctx_T *cctx, char_u *arg, char_u **nextp); 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 *peek_next_line_from_context(cctx_T *cctx);

View File

@ -11,7 +11,7 @@ void ex_export(exarg_T *eap);
void free_imports_and_script_vars(int sid); void free_imports_and_script_vars(int sid);
void mark_imports_for_reload(int sid); void mark_imports_for_reload(int sid);
void ex_import(exarg_T *eap); void ex_import(exarg_T *eap);
int find_exported(int sid, char_u *name, ufunc_T **ufunc, type_T **type, cctx_T *cctx, int verbose); int find_exported(int sid, char_u *name, ufunc_T **ufunc, type_T **type, cctx_T *cctx, cstack_T *cstack, int verbose);
char_u *vim9_declare_scriptvar(exarg_T *eap, char_u *arg); char_u *vim9_declare_scriptvar(exarg_T *eap, char_u *arg);
void update_vim9_script_var(int create, dictitem_T *di, char_u *name, int flags, typval_T *tv, type_T **type, int do_member); void update_vim9_script_var(int create, dictitem_T *di, char_u *name, int flags, typval_T *tv, type_T **type, int do_member);
void hide_script_var(scriptitem_T *si, int idx, int func_defined); void hide_script_var(scriptitem_T *si, int idx, int func_defined);

View File

@ -746,6 +746,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 */
/**/
4333,
/**/ /**/
4332, 4332,
/**/ /**/

View File

@ -532,7 +532,12 @@ check_item_writable(svar_T *sv, int check_writable, char_u *name)
* If not found or the variable is not writable returns -2. * If not found or the variable is not writable returns -2.
*/ */
int int
get_script_item_idx(int sid, char_u *name, int check_writable, cctx_T *cctx) get_script_item_idx(
int sid,
char_u *name,
int check_writable,
cctx_T *cctx,
cstack_T *cstack)
{ {
hashtab_T *ht; hashtab_T *ht;
dictitem_T *di; dictitem_T *di;
@ -544,7 +549,7 @@ get_script_item_idx(int sid, char_u *name, int check_writable, cctx_T *cctx)
return -1; return -1;
if (sid == current_sctx.sc_sid) if (sid == current_sctx.sc_sid)
{ {
sallvar_T *sav = find_script_var(name, 0, cctx, NULL); sallvar_T *sav = find_script_var(name, 0, cctx, cstack);
if (sav == NULL) if (sav == NULL)
return -2; return -2;
@ -1449,7 +1454,7 @@ compile_lhs(
lhs->lhs_scriptvar_idx = get_script_item_idx( lhs->lhs_scriptvar_idx = get_script_item_idx(
lhs->lhs_scriptvar_sid, rawname, lhs->lhs_scriptvar_sid, rawname,
lhs->lhs_has_index ? ASSIGN_FINAL : ASSIGN_CONST, lhs->lhs_has_index ? ASSIGN_FINAL : ASSIGN_CONST,
cctx); cctx, NULL);
if (lhs->lhs_scriptvar_idx >= 0) if (lhs->lhs_scriptvar_idx >= 0)
{ {
scriptitem_T *si = SCRIPT_ITEM( scriptitem_T *si = SCRIPT_ITEM(

View File

@ -256,7 +256,7 @@ compile_load_scriptvar(
if (!SCRIPT_ID_VALID(current_sctx.sc_sid)) if (!SCRIPT_ID_VALID(current_sctx.sc_sid))
return FAIL; return FAIL;
si = SCRIPT_ITEM(current_sctx.sc_sid); si = SCRIPT_ITEM(current_sctx.sc_sid);
idx = get_script_item_idx(current_sctx.sc_sid, name, 0, cctx); idx = get_script_item_idx(current_sctx.sc_sid, name, 0, cctx, NULL);
if (idx >= 0) if (idx >= 0)
{ {
svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + idx; svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + idx;
@ -316,7 +316,7 @@ compile_load_scriptvar(
else else
{ {
idx = find_exported(import->imp_sid, exp_name, &ufunc, &type, idx = find_exported(import->imp_sid, exp_name, &ufunc, &type,
cctx, TRUE); cctx, NULL, TRUE);
} }
*p = cc; *p = cc;
*end = p; *end = p;

View File

@ -649,6 +649,7 @@ ex_import(exarg_T *eap)
/* /*
* Find an exported item in "sid" matching "name". * Find an exported item in "sid" matching "name".
* Either "cctx" or "cstack" is NULL.
* When it is a variable return the index. * When it is a variable return the index.
* When it is a user function return "*ufunc". * When it is a user function return "*ufunc".
* When not found returns -1 and "*ufunc" is NULL. * When not found returns -1 and "*ufunc" is NULL.
@ -660,6 +661,7 @@ find_exported(
ufunc_T **ufunc, ufunc_T **ufunc,
type_T **type, type_T **type,
cctx_T *cctx, cctx_T *cctx,
cstack_T *cstack,
int verbose) int verbose)
{ {
int idx = -1; int idx = -1;
@ -667,7 +669,7 @@ find_exported(
scriptitem_T *script = SCRIPT_ITEM(sid); scriptitem_T *script = SCRIPT_ITEM(sid);
// Find name in "script". // Find name in "script".
idx = get_script_item_idx(sid, name, 0, cctx); idx = get_script_item_idx(sid, name, 0, cctx, cstack);
if (idx >= 0) if (idx >= 0)
{ {
sv = ((svar_T *)script->sn_var_vals.ga_data) + idx; sv = ((svar_T *)script->sn_var_vals.ga_data) + idx;