diff options
Diffstat (limited to 'clox/src/debug.c')
-rw-r--r-- | clox/src/debug.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clox/src/debug.c b/clox/src/debug.c index 74be178..079f0e9 100644 --- a/clox/src/debug.c +++ b/clox/src/debug.c @@ -20,6 +20,15 @@ static int constantInstruction(const char *name, Chunk *chunk, int offset) { return offset + 2; } +static int invokeInstruction(const char *name, Chunk *chunk, int offset) { + uint8_t constant = chunk->code[offset + 1]; + uint8_t argCount = chunk->code[offset + 2]; + printf("%-16s (%d args) %4d '", name, argCount, constant); + printValue(chunk->constants.values[constant]); + printf("'\n'"); + return offset + 3; +} + static int simpleInstruction(const char *name, int offset) { printf("%s\n", name); return offset + 1; @@ -105,6 +114,8 @@ int disassembleInstruction(Chunk *chunk, int offset) { return jumpInstruction("OP_LOOP", -1, chunk, offset); case OP_CALL: return byteInstruction("OP_CALL", chunk, offset); + case OP_INVOKE: + return invokeInstruction("OP_INVOKE", chunk, offset); case OP_CLOSURE: { offset++; uint8_t constant = chunk->code[offset++]; |