summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
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");