From f4113cbcdc192b23f9b6e5e14b0a3e4afac35272 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Fri, 22 Oct 2021 10:57:23 +0200 Subject: Add line/col information for debugging purposes. --- src/bytecode/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/bytecode/main.c') diff --git a/src/bytecode/main.c b/src/bytecode/main.c index ce196c8..c994e08 100644 --- a/src/bytecode/main.c +++ b/src/bytecode/main.c @@ -32,12 +32,13 @@ process_source(const StringView *source) { Chunk chunk = {0}; array_init(chunk.code, 0); array_init(chunk.constants, 0); + array_init(chunk.lines, 0); // Push some test instructions. size_t const_idx = add_constant(chunk, 7); - array_push(chunk.code, OP_CONSTANT); - array_push(chunk.code, const_idx); - array_push(chunk.code, OP_RETURN); + add_code(chunk, OP_CONSTANT, 1, 1); + add_code(chunk, const_idx, 1, 1); + add_code(chunk, OP_RETURN, 1, 1); // Disassemble the chunk. disassemble_chunk(chunk, "test chunk"); @@ -45,6 +46,7 @@ process_source(const StringView *source) { // Free chunk. array_free(chunk.code); array_free(chunk.constants); + array_free(chunk.lines); array_free(tokens); } -- cgit v1.2.1