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

patch 9.0.1041: cannot define a method in a class

Problem:    Cannot define a method in a class.
Solution:   Implement defining an object method.  Make calling an object
            method work.
This commit is contained in:
Bram Moolenaar
2022-12-09 21:41:48 +00:00
parent 148bcd3610
commit ffdaca9e6f
17 changed files with 267 additions and 86 deletions

View File

@@ -131,6 +131,23 @@ generate_CONSTRUCT(cctx_T *cctx, class_T *cl)
return OK;
}
/*
* Generate ISN_OBJ_MEMBER - access object member by indes.
*/
int
generate_OBJ_MEMBER(cctx_T *cctx, int idx, type_T *type)
{
RETURN_OK_IF_SKIP(cctx);
// drop the object type
isn_T *isn = generate_instr_drop(cctx, ISN_OBJ_MEMBER, 1);
if (isn == NULL)
return FAIL;
isn->isn_arg.number = idx;
return push_type_stack2(cctx, type, &t_any);
}
/*
* If type at "offset" isn't already VAR_STRING then generate ISN_2STRING.
* But only for simple types.
@@ -2460,6 +2477,7 @@ delete_instr(isn_T *isn)
case ISN_NEWDICT:
case ISN_NEWLIST:
case ISN_NEWPARTIAL:
case ISN_OBJ_MEMBER:
case ISN_OPANY:
case ISN_OPFLOAT:
case ISN_OPNR: