diff --git a/src/chunk.zig b/src/chunk.zig index 7f9d6aa..aaee6e1 100644 --- a/src/chunk.zig +++ b/src/chunk.zig @@ -67,7 +67,7 @@ pub const Chunk = struct { } pub fn dissassemble_instruction(self: Chunk, offset: usize) usize { - debug.print("{x:0>4} ", .{offset}); + debug.print("{d:0>4} ", .{offset}); if (offset > 0 and self.lines[offset] == self.lines[offset - 1]) { debug.print(" | ", .{}); diff --git a/src/utils.zig b/src/utils.zig index d900cd3..7a3e01b 100644 --- a/src/utils.zig +++ b/src/utils.zig @@ -14,14 +14,14 @@ pub fn grow_capacity(capacity: usize) usize { } pub fn simple_instruction(opcode_name: []const u8, offset: usize) usize { - debug.print("{s:16}\n", .{opcode_name}); + debug.print("{s:<16}\n", .{opcode_name}); return offset + 1; } pub fn constant_instruction(opcode_name: []const u8, chunk: Chunk, offset: usize) usize { const constant = chunk.code[offset + 1]; - debug.print("{s:16} {d:4} '", .{ opcode_name, constant }); + debug.print("{s:<16} {d:4} '", .{ opcode_name, constant }); print_value(chunk.constants.values[constant]); debug.print("'\n", .{}); return offset + 2; @@ -29,7 +29,7 @@ pub fn constant_instruction(opcode_name: []const u8, chunk: Chunk, offset: usize pub fn byte_instruction(opcode_name: []const u8, chunk: Chunk, offset: usize) usize { const slot = chunk.code[offset + 1]; - debug.print("{s:16} {d:4}\n", .{ opcode_name, slot }); + debug.print("{s:<16} {d:4}\n", .{ opcode_name, slot }); return offset + 2; } @@ -40,7 +40,7 @@ pub fn jump_instruction(opcode_name: []const u8, sign: i32, chunk: Chunk, offset const address: i32 = @as(i32, @intCast(offset)) + 3 + sign * jump; - debug.print("{s:16} {d:4} -> {x}\n", .{ opcode_name, offset, address }); + debug.print("{s:<16} {d:4} -> {d}\n", .{ opcode_name, offset, address }); return offset + 3; } diff --git a/src/vm.zig b/src/vm.zig index e187449..26544a9 100644 --- a/src/vm.zig +++ b/src/vm.zig @@ -97,7 +97,7 @@ pub const VM = struct { while (true) { if (constants.DEBUG_TRACE_EXECUTION) { if (self.stack_top > 0) { - debug.print("{s:32}", .{""}); + debug.print("{s:10}", .{""}); for (0..self.stack_top) |item_idx| { debug.print("[ ", .{}); print_value(self.stack[item_idx]);