aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode/debug.h
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-10-24 16:47:15 +0200
committerBad Diode <bd@badd10de.dev>2021-10-24 16:47:15 +0200
commitabdcae0f839d0bd772c5f7211cb1cb2034355b62 (patch)
treeee3b8c8811a1383cfb453b5638acc20997876a4c /src/bytecode/debug.h
parentdd5210368634e2b322435385eaaaccaa5125b5a9 (diff)
downloadbdl-abdcae0f839d0bd772c5f7211cb1cb2034355b62.tar.gz
bdl-abdcae0f839d0bd772c5f7211cb1cb2034355b62.zip
Cleanup IF jump code in compiler
Diffstat (limited to 'src/bytecode/debug.h')
-rwxr-xr-xsrc/bytecode/debug.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/bytecode/debug.h b/src/bytecode/debug.h
index 674d469..bc736f9 100755
--- a/src/bytecode/debug.h
+++ b/src/bytecode/debug.h
@@ -71,11 +71,19 @@ disassemble_instruction(Chunk *chunk, size_t offset) {
71 switch (instruction) { 71 switch (instruction) {
72 case OP_CONSTANT: { 72 case OP_CONSTANT: {
73 u8 constant = chunk->code[offset + 1]; 73 u8 constant = chunk->code[offset + 1];
74 printf("%-16s %4d -> ", "OP_CONSTANT", constant); 74 printf("%-16s %4d -> ", ops_str[instruction], constant);
75 display(chunk->constants[constant]); 75 display(chunk->constants[constant]);
76 printf("\n"); 76 printf("\n");
77 return offset + 2; 77 return offset + 2;
78 } break; 78 } break;
79 case OP_JUMP:
80 case OP_JUMP_IF_FALSE: {
81 u16 a = chunk->code[offset + 1];
82 u16 b = chunk->code[offset + 2];
83 u16 jmp = (a << 8) | b;
84 printf("%-16s %4d\n", ops_str[instruction], jmp);
85 return offset + 3;
86 } break;
79 default: { 87 default: {
80 printf("%s\n", ops_str[instruction]); 88 printf("%s\n", ops_str[instruction]);
81 return offset + 1; 89 return offset + 1;