diff options
Diffstat (limited to 'clox/src/debug.c')
-rw-r--r-- | clox/src/debug.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clox/src/debug.c b/clox/src/debug.c index 61deb52..5a3cedc 100644 --- a/clox/src/debug.c +++ b/clox/src/debug.c @@ -24,6 +24,12 @@ static int simpleInstruction(const char *name, int offset) { return offset + 1; } +static int byteInstruction(const char *name, Chunk *chunk, int offset) { + uint8_t slot = chunk->code[offset + 1]; + printf("%-16s %4d\n", name, slot); + return offset + 2; +} + int disassembleInstruction(Chunk *chunk, int offset) { printf("%04d ", offset); if (offset > 0 && chunk->lines[offset] == chunk->lines[offset - 1]) { @@ -44,6 +50,10 @@ int disassembleInstruction(Chunk *chunk, int offset) { return simpleInstruction("OP_FALSE", offset); case OP_POP: return simpleInstruction("OP_POP", offset); + case OP_GET_LOCAL: + return byteInstruction("OP_GET_LOCAL", chunk, offset); + case OP_SET_LOCAL: + return byteInstruction("OP_SET_LOCAL", chunk, offset); case OP_GET_GLOBAL: return constantInstruction("OP_GET_GLOBAL", chunk, offset); case OP_DEFINE_GLOBAL: |