diff options
author | ubq323 <ubq323@ubq323.website> | 2024-06-20 21:45:57 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2024-06-20 21:45:57 +0100 |
commit | fa8891ffe017ae890f0ef07915cf8b52acd7304a (patch) | |
tree | 7478faee1981c1c98ee5e88e6c56529f83a64817 /vm.c | |
parent | 9a7d1b1d41f4b3bb3387e7bbe77105d0089803d0 (diff) |
add true, false, nil keywords
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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; } |