mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 12:59:04 +00:00
print_zir: fix more crashes during printing
This commit is contained in:
parent
46d3e5bb04
commit
7b1a644d6e
@ -6492,6 +6492,7 @@ pub fn cmdDumpZir(
|
||||
.mod = undefined,
|
||||
.root_decl = .none,
|
||||
};
|
||||
defer file.zir.deinit(gpa);
|
||||
|
||||
{
|
||||
const instruction_bytes = file.zir.instructions.len *
|
||||
|
||||
@ -2456,20 +2456,15 @@ const Writer = struct {
|
||||
const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].save_err_ret_index;
|
||||
|
||||
try self.writeInstRef(stream, inst_data.operand);
|
||||
|
||||
try stream.writeAll(")");
|
||||
}
|
||||
|
||||
fn writeRestoreErrRetIndex(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
|
||||
const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].restore_err_ret_index;
|
||||
|
||||
if (inst_data.block != .none) {
|
||||
try self.writeInstRef(stream, inst_data.block);
|
||||
}
|
||||
|
||||
if (inst_data.operand != .none) {
|
||||
if (inst_data.block != .none) try stream.writeAll(", ");
|
||||
try self.writeInstRef(stream, inst_data.operand);
|
||||
}
|
||||
try self.writeInstRef(stream, inst_data.block);
|
||||
try self.writeInstRef(stream, inst_data.operand);
|
||||
|
||||
try stream.writeAll(")");
|
||||
}
|
||||
@ -2615,7 +2610,9 @@ const Writer = struct {
|
||||
}
|
||||
|
||||
fn writeInstRef(self: *Writer, stream: anytype, ref: Zir.Inst.Ref) !void {
|
||||
if (ref.toIndex()) |i| {
|
||||
if (ref == .none) {
|
||||
return stream.writeAll(".none");
|
||||
} else if (ref.toIndex()) |i| {
|
||||
return self.writeInstIndex(stream, i);
|
||||
} else {
|
||||
const val: InternPool.Index = @enumFromInt(@intFromEnum(ref));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user