summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-07-02 17:17:01 +0100
committerubq323 <ubq323@ubq323.website>2024-07-02 17:17:01 +0100
commit033a9cbb66d65a0918e2c095d12937afb82fd4b2 (patch)
tree29d5314ff15aa677b732d2631d555c2a6b1d942d /vm.c
parent6e8123763241efcb259f68d6e0e6d3ffcbc32795 (diff)
add (each (x arr) ...) array-loop form
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/vm.c b/vm.c
index 0857571..2131c5a 100644
--- a/vm.c
+++ b/vm.c
@@ -274,6 +274,13 @@ int runvm(State *S) {
objarr_append(S, arr, v);
break;
}
+ case OP_ARRLEN: {
+ Val v = POP();
+ CHECK(IS_ARR(v), "can only get length of array");
+ ObjArr *arr = AS_ARR(v);
+ PUSH(VAL_NUM(arr->len));
+ break;
+ }
default:
ERROR("unknown opcode");