diff --git a/src/chunk.zig b/src/chunk.zig index 476b63f..f744cfc 100644 --- a/src/chunk.zig +++ b/src/chunk.zig @@ -73,18 +73,18 @@ pub const Chunk = struct { debug.print("== end of chunk dump \n\n", .{}); } - pub fn dissassemble(self: Chunk, name: []const u8) void { + pub fn disassemble(self: Chunk, name: []const u8) void { debug.print("== {s} ==\n", .{name}); var offset: usize = 0; while (offset < self.count) { - offset = self.dissassemble_instruction(offset); + offset = self.disassemble_instruction(offset); } debug.print("== end of {s} ==\n\n", .{name}); } - pub fn dissassemble_instruction(self: Chunk, offset: usize) usize { + pub fn disassemble_instruction(self: Chunk, offset: usize) usize { var current_offset = offset; debug.print("{d:0>4} ", .{offset}); diff --git a/src/compile.zig b/src/compile.zig index fdece35..3be1f1f 100644 --- a/src/compile.zig +++ b/src/compile.zig @@ -158,8 +158,14 @@ pub const Parser = struct { fn end_parser(self: *Parser) !*Obj.Function { try self.emit_return(); + const compiler_function = self.compiler.function; + if (!self.had_error and constants.DEBUG_PRINT_CODE) { - self.current_chunk().dissassemble("code"); + var label: []const u8 = "