From 033a9cbb66d65a0918e2c095d12937afb82fd4b2 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Tue, 2 Jul 2024 17:17:01 +0100 Subject: add (each (x arr) ...) array-loop form --- vm.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'vm.c') 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"); -- cgit v1.2.3