patch 9.0.1031: Vim9 class is not implemented yet
Problem: Vim9 class is not implemented yet.
Solution: Add very basic class support.
diff --git a/src/vim9instr.c b/src/vim9instr.c
index 600fab4..cd5597d 100644
--- a/src/vim9instr.c
+++ b/src/vim9instr.c
@@ -114,6 +114,24 @@
}
/*
+ * 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.
* When "tolerant" is TRUE convert most types to string, e.g. a List.
@@ -163,6 +181,8 @@
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 @@
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 @@
case ISN_REDIRSTART:
case ISN_RETURN:
case ISN_RETURN_VOID:
+ case ISN_RETURN_OBJECT:
case ISN_SHUFFLE:
case ISN_SLICE:
case ISN_SOURCE: