aboutsummaryrefslogtreecommitdiff
path: root/src/print_zir.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/print_zir.zig')
-rw-r--r--src/print_zir.zig23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/print_zir.zig b/src/print_zir.zig
index 976d012138..fb1d2960c4 100644
--- a/src/print_zir.zig
+++ b/src/print_zir.zig
@@ -446,6 +446,9 @@ const Writer = struct {
.closure_get => try self.writeInstNode(stream, inst),
+ .@"defer" => try self.writeDefer(stream, inst),
+ .defer_err_code => try self.writeDeferErrCode(stream, inst),
+
.extended => try self.writeExtended(stream, inst),
}
}
@@ -2364,6 +2367,26 @@ const Writer = struct {
try stream.print("{d}, {d})", .{ inst_data.line + 1, inst_data.column + 1 });
}
+ fn writeDefer(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
+ const inst_data = self.code.instructions.items(.data)[inst].@"defer";
+ const body = self.code.extra[inst_data.index..][0..inst_data.len];
+ try self.writeBracedBody(stream, body);
+ try stream.writeByte(')');
+ }
+
+ fn writeDeferErrCode(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void {
+ const inst_data = self.code.instructions.items(.data)[inst].defer_err_code;
+ const extra = self.code.extraData(Zir.Inst.DeferErrCode, inst_data.payload_index).data;
+
+ try self.writeInstRef(stream, Zir.indexToRef(extra.remapped_err_code));
+ try stream.writeAll(" = ");
+ try self.writeInstRef(stream, inst_data.err_code);
+ try stream.writeAll(", ");
+ const body = self.code.extra[extra.index..][0..extra.len];
+ try self.writeBracedBody(stream, body);
+ try stream.writeByte(')');
+ }
+
fn writeInstRef(self: *Writer, stream: anytype, ref: Zir.Inst.Ref) !void {
var i: usize = @enumToInt(ref);