diff options
author | ubq323 <ubq323@ubq323.website> | 2024-06-26 22:45:16 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2024-06-26 22:45:16 +0100 |
commit | a559125a2d7af771784614b7a2092cc7fb707345 (patch) | |
tree | 4e4f31197d28a41b5c62fdd19086295cf0acad84 /vm.c | |
parent | 2e62b41072738142dea9f0b5dd5d2d22455c7616 (diff) |
array literals
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -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; |