summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/vm.c b/vm.c
index 9f6ece6..205e0fd 100644
--- a/vm.c
+++ b/vm.c
@@ -46,10 +46,12 @@ Thread thread_new(State *S) {
}
-void runvm(State *S) {
+int runvm(State *S) {
Thread *th = S->th;
Chunk *ch = th->ch;
+ int status = 1;
+
disasm_chunk(ch);
#define RBYTE() (ch->bc.d[th->ip++])
@@ -63,6 +65,7 @@ void runvm(State *S) {
uint8_t instr = RBYTE();
switch (instr) {
case OP_RET:
+ status = 0;
printf("done!\n");
goto done;
break;
@@ -127,10 +130,15 @@ void runvm(State *S) {
ARITH_OP(OP_DIV, /)
#undef ARITH_OP
+ case OP_NIL: PUSH(VAL_NIL); break;
+ case OP_TRUE: PUSH(VAL_TRUE); break;
+ case OP_FALSE: PUSH(VAL_FALSE); break;
+
}
}
done:;
+ return status;
}