1
0
forked from aniani/vim

patch 9.0.1031: Vim9 class is not implemented yet

Problem:    Vim9 class is not implemented yet.
Solution:   Add very basic class support.
This commit is contained in:
Bram Moolenaar
2022-12-08 15:32:33 +00:00
parent 038e6d20e6
commit 00b28d6c23
29 changed files with 1066 additions and 74 deletions

View File

@@ -113,6 +113,24 @@ generate_instr_debug(cctx_T *cctx)
return isn;
}
/*
* Generate an ISN_CONSTRUCT instruction.
* The object will have "size" members.
*/
int
generate_CONSTRUCT(cctx_T *cctx, class_T *cl)
{
isn_T *isn;
RETURN_OK_IF_SKIP(cctx);
if ((isn = generate_instr(cctx, ISN_CONSTRUCT)) == NULL)
return FAIL;
isn->isn_arg.construct.construct_size = sizeof(object_T)
+ cl->class_obj_member_count * sizeof(typval_T);
isn->isn_arg.construct.construct_class = cl;
return OK;
}
/*
* If type at "offset" isn't already VAR_STRING then generate ISN_2STRING.
* But only for simple types.
@@ -163,6 +181,8 @@ may_generate_2STRING(int offset, int tolerant, cctx_T *cctx)
case VAR_JOB:
case VAR_CHANNEL:
case VAR_INSTR:
case VAR_CLASS:
case VAR_OBJECT:
to_string_error(type->tt_type);
return FAIL;
}
@@ -2403,6 +2423,7 @@ delete_instr(isn_T *isn)
case ISN_COMPARESPECIAL:
case ISN_COMPARESTRING:
case ISN_CONCAT:
case ISN_CONSTRUCT:
case ISN_COND2BOOL:
case ISN_DEBUG:
case ISN_DEFER:
@@ -2457,6 +2478,7 @@ delete_instr(isn_T *isn)
case ISN_REDIRSTART:
case ISN_RETURN:
case ISN_RETURN_VOID:
case ISN_RETURN_OBJECT:
case ISN_SHUFFLE:
case ISN_SLICE:
case ISN_SOURCE: