summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-06-26 22:45:16 +0100
committerubq323 <ubq323@ubq323.website>2024-06-26 22:45:16 +0100
commita559125a2d7af771784614b7a2092cc7fb707345 (patch)
tree4e4f31197d28a41b5c62fdd19086295cf0acad84 /vm.c
parent2e62b41072738142dea9f0b5dd5d2d22455c7616 (diff)
array literals
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/vm.c b/vm.c
index 679a6a5..023d2c3 100644
--- a/vm.c
+++ b/vm.c
@@ -233,8 +233,23 @@ int runvm(State *S) {
goto done;
break;
+ case OP_ARRNEW: {
+ ObjArr *a = objarr_new(S);
+ PUSH(VAL_OBJ(a));
+ break;
+ }
+ case OP_ARRAPPEND: {
+ Val v = POP();
+ Val a = PEEK();
+ CHECK(IS_ARR(a), "can only append to array");
+ ObjArr *arr = AS_ARR(a);
+ objarr_append(S, arr, v);
+ break;
}
+ }
+
+
}
done:;
return status;