summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/vm.c b/vm.c
index b8fcbd6..679a6a5 100644
--- a/vm.c
+++ b/vm.c
@@ -10,6 +10,7 @@
#include "mem.h"
#include "dis.h"
#include "com.h"
+#include "util.h"
@@ -196,6 +197,17 @@ int runvm(State *S) {
Val res = AS_CFUNC(callee)(S, len - 1, firstarg);
th->sp -= len;
PUSH(res);
+ } else if (IS_ARR(callee)) {
+ ObjArr *arr = AS_ARR(callee);
+ CHECK(len == 2, "can only index arr with single argument");
+ Val vix = PEEK();
+ CHECK(IS_NUM(vix), "can only index numerically");
+ size_t ix = (size_t)AS_NUM(vix);
+ Val res = objarr_get(S, arr, ix);
+ th->sp -= 2;
+ PUSH(res);
+ } else {
+ ERROR("cannot call %s",typename_str(callee));
}
break;
}