authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-05-05 18:34:52-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-10 20:42:28-07:00
log80bf5af3458b25ae7375b548dc7f42150fbef3c8
tree7e3225a8095877a395d8b7604c7e889bd87af912
parent3e6dd0da7a9aae1e6e3d3e0d897a2b3a28bfc043

fix AIR printing of interned constants


2 files changed, 7 insertions(+), 3 deletions(-)

src/TypedValue.zig+6-2
...@@ -413,8 +413,12 @@ pub fn print(...@@ -413,8 +413,12 @@ pub fn print(
413 .runtime_value => return writer.writeAll("[runtime value]"),413 .runtime_value => return writer.writeAll("[runtime value]"),
414 },414 },
415 else => {415 else => {
416 try writer.print("(interned: {})", .{val.ip_index});416 const key = mod.intern_pool.indexToKey(val.ip_index);
417 return;417 if (key.typeOf() == .type_type) {
418 return Type.print(val.toType(), writer, mod);
419 } else {
420 return writer.print("{}", .{val.ip_index});
421 }
418 },422 },
419 };423 };
420}424}
src/print_air.zig+1-1
...@@ -621,7 +621,7 @@ const Writer = struct {...@@ -621,7 +621,7 @@ const Writer = struct {
621 fn writeInterned(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {621 fn writeInterned(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
622 const mod = w.module;622 const mod = w.module;
623 const ip_index = w.air.instructions.items(.data)[inst].interned;623 const ip_index = w.air.instructions.items(.data)[inst].interned;
624 const ty = ip_index.toType();624 const ty = mod.intern_pool.indexToKey(ip_index).typeOf().toType();
625 try w.writeType(s, ty);625 try w.writeType(s, ty);
626 try s.print(", {}", .{ip_index.toValue().fmtValue(ty, mod)});626 try s.print(", {}", .{ip_index.toValue().fmtValue(ty, mod)});
627 }627 }