traces: using decimals offsets
This commit is contained in:
parent
3a20f5e04a
commit
16640b6d07
@ -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(" | ", .{});
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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]);
|
||||
|
Loading…
Reference in New Issue
Block a user