0
0
mirror of https://github.com/vim/vim.git synced 2025-10-03 05:14:07 -04:00

patch 9.0.1982: vim9: clean up from v9.0.1955

Problem:  vim9: clean up from v9.0.1955
Solution: Fix a few remaining issues, improve error message

- Use `cl_exec`, the executing class, to check permissions in `get_lval()`.
- Handle lockvar of script variable from class.
- Add 'in class "Xxx"' to e_cannot_access_private_variable_str.

closes: #13222

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ernie Rael <errael@raelity.com>
This commit is contained in:
Ernie Rael
2023-10-04 20:16:22 +02:00
committed by Christian Brabandt
parent 0583491277
commit 64885645e7
13 changed files with 278 additions and 114 deletions

View File

@@ -2170,7 +2170,11 @@ generate_PUT(cctx_T *cctx, int regname, linenr_T lnum)
}
/*
* Generate an EXEC instruction that takes a string argument.
* Generate a LOCKUNLOCK instruction.The root item, where the indexing starts
* to find the variable, is on the stack. The instr takes
* - the string to parse, "root.b[idx1][idx2].d.val", to find the variable
* - the class, if any, in which the string executes.
* - if the root item is a function argument
* A copy is made of "line".
*/
int
@@ -2181,8 +2185,12 @@ generate_LOCKUNLOCK(cctx_T *cctx, char_u *line, int is_arg)
RETURN_OK_IF_SKIP(cctx);
if ((isn = generate_instr(cctx, ISN_LOCKUNLOCK)) == NULL)
return FAIL;
isn->isn_arg.lockunlock.string = vim_strsave(line);
isn->isn_arg.lockunlock.is_arg = is_arg;
class_T *cl = cctx->ctx_ufunc != NULL ? cctx->ctx_ufunc->uf_class : NULL;
isn->isn_arg.lockunlock.lu_string = vim_strsave(line);
isn->isn_arg.lockunlock.lu_cl_exec = cl;
if (cl != NULL)
++cl->class_refcount;
isn->isn_arg.lockunlock.lu_is_arg = is_arg;
return OK;
}
@@ -2490,7 +2498,6 @@ delete_instr(isn_T *isn)
case ISN_LOADOPT:
case ISN_LOADT:
case ISN_LOADW:
case ISN_LOCKUNLOCK:
case ISN_PUSHEXC:
case ISN_PUSHFUNC:
case ISN_PUSHS:
@@ -2505,6 +2512,11 @@ delete_instr(isn_T *isn)
vim_free(isn->isn_arg.string);
break;
case ISN_LOCKUNLOCK:
class_unref(isn->isn_arg.lockunlock.lu_cl_exec);
vim_free(isn->isn_arg.lockunlock.lu_string);
break;
case ISN_SUBSTITUTE:
{
int idx;