diff options
author | ubq323 <ubq323@ubq323.website> | 2024-06-21 12:56:30 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2024-06-21 12:56:30 +0100 |
commit | 21994864559386f1d11c001d6d27714cbf624a15 (patch) | |
tree | b9a5e76bdc8be9a41970cd6620aab7a3637b7e6a /vm.c | |
parent | 671645c370498955eb101695bd9099bf4caf5aea (diff) |
add tests, and make dumping disasm optional
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -57,7 +57,10 @@ int runvm(State *S) { int status = 1; - disasm_chunk(ch); + if (S->do_disasm) { + disasm_chunk(ch); + puts("---"); + } #define RBYTE() (ch->bc.d[th->ip++]) #define RSHORT() (th->ip += 2, (uint16_t)( ch->bc.d[th->ip-2] | ch->bc.d[th->ip-1] << 8 )) @@ -66,13 +69,11 @@ int runvm(State *S) { #define POP() (th->stack[--th->sp]) #define PEEK() (th->stack[th->sp-1]) - puts("---"); while (1) { uint8_t instr = RBYTE(); switch (instr) { case OP_RET: status = 0; - printf("done!\n"); goto done; break; case OP_LOADK: { |