diff options
Diffstat (limited to 'clox/src/debug.c')
-rw-r--r-- | clox/src/debug.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/clox/src/debug.c b/clox/src/debug.c index 68fdbc5..91fe139 100644 --- a/clox/src/debug.c +++ b/clox/src/debug.c @@ -3,7 +3,7 @@ #include "debug.h" #include "value.h" -void disassembleChunk(Chunk* chunk, const char* name) { +void disassembleChunk(Chunk *chunk, const char *name) { printf("== %s ==\n", name); for (int offset = 0; offset < chunk->count;) { @@ -11,7 +11,7 @@ void disassembleChunk(Chunk* chunk, const char* name) { } } -static int constantInstruction(const char* name, Chunk* chunk, int offset) { +static int constantInstruction(const char *name, Chunk *chunk, int offset) { uint8_t constant = chunk->code[offset + 1]; printf("%-16s %4d '", name, constant); printValue(chunk->constants.values[constant]); @@ -19,15 +19,14 @@ static int constantInstruction(const char* name, Chunk* chunk, int offset) { return offset + 2; } -static int simpleInstruction(const char* name, int offset) { +static int simpleInstruction(const char *name, int offset) { printf("%s\n", name); return offset + 1; } -int disassembleInstruction(Chunk* chunk, int offset) { +int disassembleInstruction(Chunk *chunk, int offset) { printf("%04d ", offset); - if (offset > 0 && - chunk->lines[offset] == chunk->lines[offset - 1]) { + if (offset > 0 && chunk->lines[offset] == chunk->lines[offset - 1]) { printf(" | "); } else { printf("%4d ", chunk->lines[offset]); @@ -37,6 +36,8 @@ int disassembleInstruction(Chunk* chunk, int offset) { switch (instruction) { case OP_CONSTANT: return constantInstruction("OP_CONSTANT", chunk, offset); + case OP_NEGATE: + return simpleInstruction("OP_NEGATE", offset); case OP_RETURN: return simpleInstruction("OP_RETURN", offset); default: |