From a559125a2d7af771784614b7a2092cc7fb707345 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Wed, 26 Jun 2024 22:45:16 +0100 Subject: array literals --- vm.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'vm.c') 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; -- cgit v1.2.3