0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 9.0.1209: getting interface member does not always work

Problem:    Getting interface member does not always work.
Solution:   Convert the index on the interface to the index on the object.
            (closes #11825)
This commit is contained in:
Bram Moolenaar
2023-01-16 19:43:47 +00:00
parent a41e221935
commit 29ac5df37b
11 changed files with 162 additions and 20 deletions

View File

@@ -149,6 +149,26 @@ generate_GET_OBJ_MEMBER(cctx_T *cctx, int idx, type_T *type)
return push_type_stack2(cctx, type, &t_any);
}
/*
* Generate ISN_GET_ITF_MEMBER - access member of interface at bottom of stack
* by index.
*/
int
generate_GET_ITF_MEMBER(cctx_T *cctx, class_T *itf, int idx, type_T *type)
{
RETURN_OK_IF_SKIP(cctx);
// drop the object type
isn_T *isn = generate_instr_drop(cctx, ISN_GET_ITF_MEMBER, 1);
if (isn == NULL)
return FAIL;
isn->isn_arg.classmember.cm_class = itf;
++itf->class_refcount;
isn->isn_arg.classmember.cm_idx = idx;
return push_type_stack2(cctx, type, &t_any);
}
/*
* Generate ISN_STORE_THIS - store value in member of "this" object with member
* index "idx".
@@ -2497,6 +2517,7 @@ delete_instr(isn_T *isn)
case ISN_LOAD_CLASSMEMBER:
case ISN_STORE_CLASSMEMBER:
case ISN_GET_ITF_MEMBER:
class_unref(isn->isn_arg.classmember.cm_class);
break;