Mercurial > vim
diff src/vim9instr.c @ 33456:4a62e78803db v9.0.1982
patch 9.0.1982: vim9: clean up from v9.0.1955
Commit: https://github.com/vim/vim/commit/64885645e76b301a6c34fe762c4e29c7a0f63881
Author: Ernie Rael <errael@raelity.com>
Date: Wed Oct 4 20:16:22 2023 +0200
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>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 04 Oct 2023 20:30:03 +0200 |
parents | 016d8f863230 |
children | 86dbcbb94fdb |
line wrap: on
line diff
--- a/src/vim9instr.c +++ b/src/vim9instr.c @@ -2170,7 +2170,11 @@ generate_PUT(cctx_T *cctx, int regname, } /* - * 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 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;