summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-06-21 12:56:30 +0100
committerubq323 <ubq323@ubq323.website>2024-06-21 12:56:30 +0100
commit21994864559386f1d11c001d6d27714cbf624a15 (patch)
treeb9a5e76bdc8be9a41970cd6620aab7a3637b7e6a /vm.c
parent671645c370498955eb101695bd9099bf4caf5aea (diff)
add tests, and make dumping disasm optional
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/vm.c b/vm.c
index 1dc40e0..667ceed 100644
--- a/vm.c
+++ b/vm.c
@@ -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: {