From fa8891ffe017ae890f0ef07915cf8b52acd7304a Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 20 Jun 2024 21:45:57 +0100 Subject: add true, false, nil keywords --- vm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'vm.c') 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; } -- cgit v1.2.3