comparison src/structs.h @ 33393:016d8f863230 v9.0.1955

patch 9.0.1955: Vim9: lockvar issues with objects/classes Commit: https://github.com/vim/vim/commit/ee865f37acab6cac2cee6a171d60e1b365f852b0 Author: Ernie Rael <errael@raelity.com> Date: Fri Sep 29 19:53:55 2023 +0200 patch 9.0.1955: Vim9: lockvar issues with objects/classes Problem: Vim9: lockvar issues with objects/classes Solution: fix `get_lhs()` object/class access and avoid `SEGV`, make error messages more accurate. - `get_lval()` detects/returns object/class access - `compile_lock_unlock()` generate code for bare static and obj_arg access - `do_lock_var()` check lval for `ll_object`/`ll_class` and fail if so. Details: - Add `ll_object`/`ll_class`/`ll_oi` to `lval_T`. - Add `lockunlock_T` to `isn_T` for `is_arg` to specify handling of `lval_root` in `get_lval()`. - In `get_lval()`, fill in `ll_object`/`ll_class`/`ll_oi` as needed; when no `[idx] or .key`, check lval_root on the way out. - In `do_lock_var()` check for `ll_object`/`ll_class`; also bullet proof ll_dict case and give `Dictionay required` if problem. (not needed to avoid lockvar crash anymore) - In `compile_lock_unlock()` compile for the class variable and func arg cases. closes: #13174 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Ernie Rael <errael@raelity.com>
author Christian Brabandt <cb@256bit.org>
date Fri, 29 Sep 2023 20:00:07 +0200
parents 6340c608ca54
children 55fefd9848e3
comparison
equal deleted inserted replaced
33392:3d3d0492824e 33393:016d8f863230
4533 * "name" points to the (expanded) variable name. 4533 * "name" points to the (expanded) variable name.
4534 * "exp_name" NULL or non-NULL, to be freed later. 4534 * "exp_name" NULL or non-NULL, to be freed later.
4535 * "tv" points to the (first) list item value 4535 * "tv" points to the (first) list item value
4536 * "li" points to the (first) list item 4536 * "li" points to the (first) list item
4537 * "range", "n1", "n2" and "empty2" indicate what items are used. 4537 * "range", "n1", "n2" and "empty2" indicate what items are used.
4538 * For a member in a class/object: TODO: verify fields
4539 * "name" points to the (expanded) variable name.
4540 * "exp_name" NULL or non-NULL, to be freed later.
4541 * "tv" points to the (first) list item value
4542 * "oi" index into member array, see _type to determine which array
4538 * For an existing Dict item: 4543 * For an existing Dict item:
4539 * "name" points to the (expanded) variable name. 4544 * "name" points to the (expanded) variable name.
4540 * "exp_name" NULL or non-NULL, to be freed later. 4545 * "exp_name" NULL or non-NULL, to be freed later.
4541 * "tv" points to the dict item value 4546 * "tv" points to the dict item value
4542 * "newkey" is NULL 4547 * "newkey" is NULL
4569 dictitem_T *ll_di; // The dictitem or NULL 4574 dictitem_T *ll_di; // The dictitem or NULL
4570 char_u *ll_newkey; // New key for Dict in alloc. mem or NULL. 4575 char_u *ll_newkey; // New key for Dict in alloc. mem or NULL.
4571 type_T *ll_valtype; // type expected for the value or NULL 4576 type_T *ll_valtype; // type expected for the value or NULL
4572 blob_T *ll_blob; // The Blob or NULL 4577 blob_T *ll_blob; // The Blob or NULL
4573 ufunc_T *ll_ufunc; // The function or NULL 4578 ufunc_T *ll_ufunc; // The function or NULL
4579 object_T *ll_object; // The object or NULL, class is not NULL
4580 class_T *ll_class; // The class or NULL, object may be NULL
4581 int ll_oi; // The object/class member index
4582 int ll_is_root; // Special case. ll_tv is lval_root,
4583 // ignore the rest.
4574 } lval_T; 4584 } lval_T;
4575 4585
4576 // Structure used to save the current state. Used when executing Normal mode 4586 // Structure used to save the current state. Used when executing Normal mode
4577 // commands while in any other mode. 4587 // commands while in any other mode.
4578 typedef struct { 4588 typedef struct {