diff options
author | Tom Willemse | 2022-08-14 19:56:32 -0700 |
---|---|---|
committer | Tom Willemse | 2022-08-14 19:56:32 -0700 |
commit | 62858b60e43803477e898c7993e109a94701ce70 (patch) | |
tree | 30d12b56bdf4e489372b68698252d4296fc5be4d /clox/src/debug.c | |
parent | e91006b59a143ad0083b3fb303a493f9d97e6c9b (diff) | |
download | crafting-interpreters-62858b60e43803477e898c7993e109a94701ce70.tar.gz crafting-interpreters-62858b60e43803477e898c7993e109a94701ce70.zip |
Chapter 28.5
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++]; |