| ... | @@ -9,13 +9,8 @@ const Zir = std.zig.Zir; | ... | @@ -9,13 +9,8 @@ const Zir = std.zig.Zir; |
| 9 | const Zcu = @import("Zcu.zig"); | 9 | const Zcu = @import("Zcu.zig"); |
| 10 | const LazySrcLoc = Zcu.LazySrcLoc; | 10 | const LazySrcLoc = Zcu.LazySrcLoc; |
| 11 | | 11 | |
| 12 | /// Write human-readable, debug formatted ZIR code to a file. | 12 | /// Write human-readable, debug formatted ZIR code. |
| 13 | pub fn renderAsTextToFile( | 13 | pub fn renderAsText(gpa: Allocator, tree: ?Ast, zir: Zir, bw: *std.io.Writer) !void { |
| 14 | gpa: Allocator, | | |
| 15 | tree: ?Ast, | | |
| 16 | zir: Zir, | | |
| 17 | fs_file: std.fs.File, | | |
| 18 | ) !void { | | |
| 19 | var arena = std.heap.ArenaAllocator.init(gpa); | 14 | var arena = std.heap.ArenaAllocator.init(gpa); |
| 20 | defer arena.deinit(); | 15 | defer arena.deinit(); |
| 21 | | 16 | |
| ... | @@ -30,16 +25,13 @@ pub fn renderAsTextToFile( | ... | @@ -30,16 +25,13 @@ pub fn renderAsTextToFile( |
| 30 | .recurse_blocks = true, | 25 | .recurse_blocks = true, |
| 31 | }; | 26 | }; |
| 32 | | 27 | |
| 33 | var raw_stream = std.io.bufferedWriter(fs_file.deprecatedWriter()); | | |
| 34 | const stream = raw_stream.writer(); | | |
| 35 | | | |
| 36 | const main_struct_inst: Zir.Inst.Index = .main_struct_inst; | 28 | const main_struct_inst: Zir.Inst.Index = .main_struct_inst; |
| 37 | try stream.print("%{d} ", .{@intFromEnum(main_struct_inst)}); | 29 | try bw.print("%{d} ", .{@intFromEnum(main_struct_inst)}); |
| 38 | try writer.writeInstToStream(stream, main_struct_inst); | 30 | try writer.writeInstToStream(bw, main_struct_inst); |
| 39 | try stream.writeAll("\n"); | 31 | try bw.writeAll("\n"); |
| 40 | const imports_index = zir.extra[@intFromEnum(Zir.ExtraIndex.imports)]; | 32 | const imports_index = zir.extra[@intFromEnum(Zir.ExtraIndex.imports)]; |
| 41 | if (imports_index != 0) { | 33 | if (imports_index != 0) { |
| 42 | try stream.writeAll("Imports:\n"); | 34 | try bw.writeAll("Imports:\n"); |
| 43 | | 35 | |
| 44 | const extra = zir.extraData(Zir.Inst.Imports, imports_index); | 36 | const extra = zir.extraData(Zir.Inst.Imports, imports_index); |
| 45 | var extra_index = extra.end; | 37 | var extra_index = extra.end; |
| ... | @@ -49,15 +41,13 @@ pub fn renderAsTextToFile( | ... | @@ -49,15 +41,13 @@ pub fn renderAsTextToFile( |
| 49 | extra_index = item.end; | 41 | extra_index = item.end; |
| 50 | | 42 | |
| 51 | const import_path = zir.nullTerminatedString(item.data.name); | 43 | const import_path = zir.nullTerminatedString(item.data.name); |
| 52 | try stream.print(" @import(\"{f}\") ", .{ | 44 | try bw.print(" @import(\"{f}\") ", .{ |
| 53 | std.zig.fmtString(import_path), | 45 | std.zig.fmtString(import_path), |
| 54 | }); | 46 | }); |
| 55 | try writer.writeSrcTokAbs(stream, item.data.token); | 47 | try writer.writeSrcTokAbs(bw, item.data.token); |
| 56 | try stream.writeAll("\n"); | 48 | try bw.writeAll("\n"); |
| 57 | } | 49 | } |
| 58 | } | 50 | } |
| 59 | | | |
| 60 | try raw_stream.flush(); | | |
| 61 | } | 51 | } |
| 62 | | 52 | |
| 63 | pub fn renderInstructionContext( | 53 | pub fn renderInstructionContext( |
| ... | @@ -67,7 +57,7 @@ pub fn renderInstructionContext( | ... | @@ -67,7 +57,7 @@ pub fn renderInstructionContext( |
| 67 | scope_file: *Zcu.File, | 57 | scope_file: *Zcu.File, |
| 68 | parent_decl_node: Ast.Node.Index, | 58 | parent_decl_node: Ast.Node.Index, |
| 69 | indent: u32, | 59 | indent: u32, |
| 70 | stream: anytype, | 60 | bw: *std.io.Writer, |
| 71 | ) !void { | 61 | ) !void { |
| 72 | var arena = std.heap.ArenaAllocator.init(gpa); | 62 | var arena = std.heap.ArenaAllocator.init(gpa); |
| 73 | defer arena.deinit(); | 63 | defer arena.deinit(); |
| ... | @@ -83,13 +73,13 @@ pub fn renderInstructionContext( | ... | @@ -83,13 +73,13 @@ pub fn renderInstructionContext( |
| 83 | .recurse_blocks = true, | 73 | .recurse_blocks = true, |
| 84 | }; | 74 | }; |
| 85 | | 75 | |
| 86 | try writer.writeBody(stream, block[0..block_index]); | 76 | try writer.writeBody(bw, block[0..block_index]); |
| 87 | try stream.writeByteNTimes(' ', writer.indent - 2); | 77 | try bw.splatByteAll(' ', writer.indent - 2); |
| 88 | try stream.print("> %{d} ", .{@intFromEnum(block[block_index])}); | 78 | try bw.print("> %{d} ", .{@intFromEnum(block[block_index])}); |
| 89 | try writer.writeInstToStream(stream, block[block_index]); | 79 | try writer.writeInstToStream(bw, block[block_index]); |
| 90 | try stream.writeByte('\n'); | 80 | try bw.writeByte('\n'); |
| 91 | if (block_index + 1 < block.len) { | 81 | if (block_index + 1 < block.len) { |
| 92 | try writer.writeBody(stream, block[block_index + 1 ..]); | 82 | try writer.writeBody(bw, block[block_index + 1 ..]); |
| 93 | } | 83 | } |
| 94 | } | 84 | } |
| 95 | | 85 | |
| ... | @@ -99,7 +89,7 @@ pub fn renderSingleInstruction( | ... | @@ -99,7 +89,7 @@ pub fn renderSingleInstruction( |
| 99 | scope_file: *Zcu.File, | 89 | scope_file: *Zcu.File, |
| 100 | parent_decl_node: Ast.Node.Index, | 90 | parent_decl_node: Ast.Node.Index, |
| 101 | indent: u32, | 91 | indent: u32, |
| 102 | stream: anytype, | 92 | bw: *std.io.Writer, |
| 103 | ) !void { | 93 | ) !void { |
| 104 | var arena = std.heap.ArenaAllocator.init(gpa); | 94 | var arena = std.heap.ArenaAllocator.init(gpa); |
| 105 | defer arena.deinit(); | 95 | defer arena.deinit(); |
| ... | @@ -115,8 +105,8 @@ pub fn renderSingleInstruction( | ... | @@ -115,8 +105,8 @@ pub fn renderSingleInstruction( |
| 115 | .recurse_blocks = false, | 105 | .recurse_blocks = false, |
| 116 | }; | 106 | }; |
| 117 | | 107 | |
| 118 | try stream.print("%{d} ", .{@intFromEnum(inst)}); | 108 | try bw.print("%{d} ", .{@intFromEnum(inst)}); |
| 119 | try writer.writeInstToStream(stream, inst); | 109 | try writer.writeInstToStream(bw, inst); |
| 120 | } | 110 | } |
| 121 | | 111 | |
| 122 | const Writer = struct { | 112 | const Writer = struct { |
| ... | @@ -186,11 +176,13 @@ const Writer = struct { | ... | @@ -186,11 +176,13 @@ const Writer = struct { |
| 186 | } | 176 | } |
| 187 | } = .{}, | 177 | } = .{}, |
| 188 | | 178 | |
| | 179 | const Error = std.io.Writer.Error || Allocator.Error; |
| | 180 | |
| 189 | fn writeInstToStream( | 181 | fn writeInstToStream( |
| 190 | self: *Writer, | 182 | self: *Writer, |
| 191 | stream: anytype, | 183 | stream: *std.io.Writer, |
| 192 | inst: Zir.Inst.Index, | 184 | inst: Zir.Inst.Index, |
| 193 | ) (@TypeOf(stream).Error || error{OutOfMemory})!void { | 185 | ) Error!void { |
| 194 | const tags = self.code.instructions.items(.tag); | 186 | const tags = self.code.instructions.items(.tag); |
| 195 | const tag = tags[@intFromEnum(inst)]; | 187 | const tag = tags[@intFromEnum(inst)]; |
| 196 | try stream.print("= {s}(", .{@tagName(tags[@intFromEnum(inst)])}); | 188 | try stream.print("= {s}(", .{@tagName(tags[@intFromEnum(inst)])}); |
| ... | @@ -516,7 +508,7 @@ const Writer = struct { | ... | @@ -516,7 +508,7 @@ const Writer = struct { |
| 516 | } | 508 | } |
| 517 | } | 509 | } |
| 518 | | 510 | |
| 519 | fn writeExtended(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 511 | fn writeExtended(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 520 | const extended = self.code.instructions.items(.data)[@intFromEnum(inst)].extended; | 512 | const extended = self.code.instructions.items(.data)[@intFromEnum(inst)].extended; |
| 521 | try stream.print("{s}(", .{@tagName(extended.opcode)}); | 513 | try stream.print("{s}(", .{@tagName(extended.opcode)}); |
| 522 | switch (extended.opcode) { | 514 | switch (extended.opcode) { |
| ... | @@ -623,13 +615,13 @@ const Writer = struct { | ... | @@ -623,13 +615,13 @@ const Writer = struct { |
| 623 | } | 615 | } |
| 624 | } | 616 | } |
| 625 | | 617 | |
| 626 | fn writeExtNode(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 618 | fn writeExtNode(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 627 | try stream.writeAll(")) "); | 619 | try stream.writeAll(")) "); |
| 628 | const src_node: Ast.Node.Offset = @enumFromInt(@as(i32, @bitCast(extended.operand))); | 620 | const src_node: Ast.Node.Offset = @enumFromInt(@as(i32, @bitCast(extended.operand))); |
| 629 | try self.writeSrcNode(stream, src_node); | 621 | try self.writeSrcNode(stream, src_node); |
| 630 | } | 622 | } |
| 631 | | 623 | |
| 632 | fn writeArrayInitElemType(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 624 | fn writeArrayInitElemType(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 633 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].bin; | 625 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].bin; |
| 634 | try self.writeInstRef(stream, inst_data.lhs); | 626 | try self.writeInstRef(stream, inst_data.lhs); |
| 635 | try stream.print(", {d})", .{@intFromEnum(inst_data.rhs)}); | 627 | try stream.print(", {d})", .{@intFromEnum(inst_data.rhs)}); |
| ... | @@ -637,9 +629,9 @@ const Writer = struct { | ... | @@ -637,9 +629,9 @@ const Writer = struct { |
| 637 | | 629 | |
| 638 | fn writeUnNode( | 630 | fn writeUnNode( |
| 639 | self: *Writer, | 631 | self: *Writer, |
| 640 | stream: anytype, | 632 | stream: *std.io.Writer, |
| 641 | inst: Zir.Inst.Index, | 633 | inst: Zir.Inst.Index, |
| 642 | ) (@TypeOf(stream).Error || error{OutOfMemory})!void { | 634 | ) Error!void { |
| 643 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 635 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 644 | try self.writeInstRef(stream, inst_data.operand); | 636 | try self.writeInstRef(stream, inst_data.operand); |
| 645 | try stream.writeAll(") "); | 637 | try stream.writeAll(") "); |
| ... | @@ -648,9 +640,9 @@ const Writer = struct { | ... | @@ -648,9 +640,9 @@ const Writer = struct { |
| 648 | | 640 | |
| 649 | fn writeUnTok( | 641 | fn writeUnTok( |
| 650 | self: *Writer, | 642 | self: *Writer, |
| 651 | stream: anytype, | 643 | stream: *std.io.Writer, |
| 652 | inst: Zir.Inst.Index, | 644 | inst: Zir.Inst.Index, |
| 653 | ) (@TypeOf(stream).Error || error{OutOfMemory})!void { | 645 | ) Error!void { |
| 654 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].un_tok; | 646 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].un_tok; |
| 655 | try self.writeInstRef(stream, inst_data.operand); | 647 | try self.writeInstRef(stream, inst_data.operand); |
| 656 | try stream.writeAll(") "); | 648 | try stream.writeAll(") "); |
| ... | @@ -659,9 +651,9 @@ const Writer = struct { | ... | @@ -659,9 +651,9 @@ const Writer = struct { |
| 659 | | 651 | |
| 660 | fn writeValidateDestructure( | 652 | fn writeValidateDestructure( |
| 661 | self: *Writer, | 653 | self: *Writer, |
| 662 | stream: anytype, | 654 | stream: *std.io.Writer, |
| 663 | inst: Zir.Inst.Index, | 655 | inst: Zir.Inst.Index, |
| 664 | ) (@TypeOf(stream).Error || error{OutOfMemory})!void { | 656 | ) Error!void { |
| 665 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 657 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 666 | const extra = self.code.extraData(Zir.Inst.ValidateDestructure, inst_data.payload_index).data; | 658 | const extra = self.code.extraData(Zir.Inst.ValidateDestructure, inst_data.payload_index).data; |
| 667 | try self.writeInstRef(stream, extra.operand); | 659 | try self.writeInstRef(stream, extra.operand); |
| ... | @@ -673,9 +665,9 @@ const Writer = struct { | ... | @@ -673,9 +665,9 @@ const Writer = struct { |
| 673 | | 665 | |
| 674 | fn writeValidateArrayInitTy( | 666 | fn writeValidateArrayInitTy( |
| 675 | self: *Writer, | 667 | self: *Writer, |
| 676 | stream: anytype, | 668 | stream: *std.io.Writer, |
| 677 | inst: Zir.Inst.Index, | 669 | inst: Zir.Inst.Index, |
| 678 | ) (@TypeOf(stream).Error || error{OutOfMemory})!void { | 670 | ) Error!void { |
| 679 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 671 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 680 | const extra = self.code.extraData(Zir.Inst.ArrayInit, inst_data.payload_index).data; | 672 | const extra = self.code.extraData(Zir.Inst.ArrayInit, inst_data.payload_index).data; |
| 681 | try self.writeInstRef(stream, extra.ty); | 673 | try self.writeInstRef(stream, extra.ty); |
| ... | @@ -685,9 +677,9 @@ const Writer = struct { | ... | @@ -685,9 +677,9 @@ const Writer = struct { |
| 685 | | 677 | |
| 686 | fn writeArrayTypeSentinel( | 678 | fn writeArrayTypeSentinel( |
| 687 | self: *Writer, | 679 | self: *Writer, |
| 688 | stream: anytype, | 680 | stream: *std.io.Writer, |
| 689 | inst: Zir.Inst.Index, | 681 | inst: Zir.Inst.Index, |
| 690 | ) (@TypeOf(stream).Error || error{OutOfMemory})!void { | 682 | ) Error!void { |
| 691 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 683 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 692 | const extra = self.code.extraData(Zir.Inst.ArrayTypeSentinel, inst_data.payload_index).data; | 684 | const extra = self.code.extraData(Zir.Inst.ArrayTypeSentinel, inst_data.payload_index).data; |
| 693 | try self.writeInstRef(stream, extra.len); | 685 | try self.writeInstRef(stream, extra.len); |
| ... | @@ -701,9 +693,9 @@ const Writer = struct { | ... | @@ -701,9 +693,9 @@ const Writer = struct { |
| 701 | | 693 | |
| 702 | fn writePtrType( | 694 | fn writePtrType( |
| 703 | self: *Writer, | 695 | self: *Writer, |
| 704 | stream: anytype, | 696 | stream: *std.io.Writer, |
| 705 | inst: Zir.Inst.Index, | 697 | inst: Zir.Inst.Index, |
| 706 | ) (@TypeOf(stream).Error || error{OutOfMemory})!void { | 698 | ) Error!void { |
| 707 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].ptr_type; | 699 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].ptr_type; |
| 708 | const str_allowzero = if (inst_data.flags.is_allowzero) "allowzero, " else ""; | 700 | const str_allowzero = if (inst_data.flags.is_allowzero) "allowzero, " else ""; |
| 709 | const str_const = if (!inst_data.flags.is_mutable) "const, " else ""; | 701 | const str_const = if (!inst_data.flags.is_mutable) "const, " else ""; |
| ... | @@ -744,12 +736,12 @@ const Writer = struct { | ... | @@ -744,12 +736,12 @@ const Writer = struct { |
| 744 | try self.writeSrcNode(stream, extra.data.src_node); | 736 | try self.writeSrcNode(stream, extra.data.src_node); |
| 745 | } | 737 | } |
| 746 | | 738 | |
| 747 | fn writeInt(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 739 | fn writeInt(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 748 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].int; | 740 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].int; |
| 749 | try stream.print("{d})", .{inst_data}); | 741 | try stream.print("{d})", .{inst_data}); |
| 750 | } | 742 | } |
| 751 | | 743 | |
| 752 | fn writeIntBig(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 744 | fn writeIntBig(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 753 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str; | 745 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str; |
| 754 | const byte_count = inst_data.len * @sizeOf(std.math.big.Limb); | 746 | const byte_count = inst_data.len * @sizeOf(std.math.big.Limb); |
| 755 | const limb_bytes = self.code.string_bytes[@intFromEnum(inst_data.start)..][0..byte_count]; | 747 | const limb_bytes = self.code.string_bytes[@intFromEnum(inst_data.start)..][0..byte_count]; |
| ... | @@ -768,12 +760,12 @@ const Writer = struct { | ... | @@ -768,12 +760,12 @@ const Writer = struct { |
| 768 | try stream.print("{s})", .{as_string}); | 760 | try stream.print("{s})", .{as_string}); |
| 769 | } | 761 | } |
| 770 | | 762 | |
| 771 | fn writeFloat(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 763 | fn writeFloat(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 772 | const number = self.code.instructions.items(.data)[@intFromEnum(inst)].float; | 764 | const number = self.code.instructions.items(.data)[@intFromEnum(inst)].float; |
| 773 | try stream.print("{d})", .{number}); | 765 | try stream.print("{d})", .{number}); |
| 774 | } | 766 | } |
| 775 | | 767 | |
| 776 | fn writeFloat128(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 768 | fn writeFloat128(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 777 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 769 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 778 | const extra = self.code.extraData(Zir.Inst.Float128, inst_data.payload_index).data; | 770 | const extra = self.code.extraData(Zir.Inst.Float128, inst_data.payload_index).data; |
| 779 | const number = extra.get(); | 771 | const number = extra.get(); |
| ... | @@ -784,15 +776,15 @@ const Writer = struct { | ... | @@ -784,15 +776,15 @@ const Writer = struct { |
| 784 | | 776 | |
| 785 | fn writeStr( | 777 | fn writeStr( |
| 786 | self: *Writer, | 778 | self: *Writer, |
| 787 | stream: anytype, | 779 | stream: *std.io.Writer, |
| 788 | inst: Zir.Inst.Index, | 780 | inst: Zir.Inst.Index, |
| 789 | ) (@TypeOf(stream).Error || error{OutOfMemory})!void { | 781 | ) Error!void { |
| 790 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str; | 782 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str; |
| 791 | const str = inst_data.get(self.code); | 783 | const str = inst_data.get(self.code); |
| 792 | try stream.print("\"{f}\")", .{std.zig.fmtString(str)}); | 784 | try stream.print("\"{f}\")", .{std.zig.fmtString(str)}); |
| 793 | } | 785 | } |
| 794 | | 786 | |
| 795 | fn writeSliceStart(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 787 | fn writeSliceStart(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 796 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 788 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 797 | const extra = self.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data; | 789 | const extra = self.code.extraData(Zir.Inst.SliceStart, inst_data.payload_index).data; |
| 798 | try self.writeInstRef(stream, extra.lhs); | 790 | try self.writeInstRef(stream, extra.lhs); |
| ... | @@ -802,7 +794,7 @@ const Writer = struct { | ... | @@ -802,7 +794,7 @@ const Writer = struct { |
| 802 | try self.writeSrcNode(stream, inst_data.src_node); | 794 | try self.writeSrcNode(stream, inst_data.src_node); |
| 803 | } | 795 | } |
| 804 | | 796 | |
| 805 | fn writeSliceEnd(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 797 | fn writeSliceEnd(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 806 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 798 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 807 | const extra = self.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data; | 799 | const extra = self.code.extraData(Zir.Inst.SliceEnd, inst_data.payload_index).data; |
| 808 | try self.writeInstRef(stream, extra.lhs); | 800 | try self.writeInstRef(stream, extra.lhs); |
| ... | @@ -814,7 +806,7 @@ const Writer = struct { | ... | @@ -814,7 +806,7 @@ const Writer = struct { |
| 814 | try self.writeSrcNode(stream, inst_data.src_node); | 806 | try self.writeSrcNode(stream, inst_data.src_node); |
| 815 | } | 807 | } |
| 816 | | 808 | |
| 817 | fn writeSliceSentinel(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 809 | fn writeSliceSentinel(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 818 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 810 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 819 | const extra = self.code.extraData(Zir.Inst.SliceSentinel, inst_data.payload_index).data; | 811 | const extra = self.code.extraData(Zir.Inst.SliceSentinel, inst_data.payload_index).data; |
| 820 | try self.writeInstRef(stream, extra.lhs); | 812 | try self.writeInstRef(stream, extra.lhs); |
| ... | @@ -828,7 +820,7 @@ const Writer = struct { | ... | @@ -828,7 +820,7 @@ const Writer = struct { |
| 828 | try self.writeSrcNode(stream, inst_data.src_node); | 820 | try self.writeSrcNode(stream, inst_data.src_node); |
| 829 | } | 821 | } |
| 830 | | 822 | |
| 831 | fn writeSliceLength(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 823 | fn writeSliceLength(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 832 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 824 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 833 | const extra = self.code.extraData(Zir.Inst.SliceLength, inst_data.payload_index).data; | 825 | const extra = self.code.extraData(Zir.Inst.SliceLength, inst_data.payload_index).data; |
| 834 | try self.writeInstRef(stream, extra.lhs); | 826 | try self.writeInstRef(stream, extra.lhs); |
| ... | @@ -844,7 +836,7 @@ const Writer = struct { | ... | @@ -844,7 +836,7 @@ const Writer = struct { |
| 844 | try self.writeSrcNode(stream, inst_data.src_node); | 836 | try self.writeSrcNode(stream, inst_data.src_node); |
| 845 | } | 837 | } |
| 846 | | 838 | |
| 847 | fn writeUnionInit(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 839 | fn writeUnionInit(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 848 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 840 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 849 | const extra = self.code.extraData(Zir.Inst.UnionInit, inst_data.payload_index).data; | 841 | const extra = self.code.extraData(Zir.Inst.UnionInit, inst_data.payload_index).data; |
| 850 | try self.writeInstRef(stream, extra.union_type); | 842 | try self.writeInstRef(stream, extra.union_type); |
| ... | @@ -856,7 +848,7 @@ const Writer = struct { | ... | @@ -856,7 +848,7 @@ const Writer = struct { |
| 856 | try self.writeSrcNode(stream, inst_data.src_node); | 848 | try self.writeSrcNode(stream, inst_data.src_node); |
| 857 | } | 849 | } |
| 858 | | 850 | |
| 859 | fn writeShuffle(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 851 | fn writeShuffle(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 860 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 852 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 861 | const extra = self.code.extraData(Zir.Inst.Shuffle, inst_data.payload_index).data; | 853 | const extra = self.code.extraData(Zir.Inst.Shuffle, inst_data.payload_index).data; |
| 862 | try self.writeInstRef(stream, extra.elem_type); | 854 | try self.writeInstRef(stream, extra.elem_type); |
| ... | @@ -870,7 +862,7 @@ const Writer = struct { | ... | @@ -870,7 +862,7 @@ const Writer = struct { |
| 870 | try self.writeSrcNode(stream, inst_data.src_node); | 862 | try self.writeSrcNode(stream, inst_data.src_node); |
| 871 | } | 863 | } |
| 872 | | 864 | |
| 873 | fn writeSelect(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 865 | fn writeSelect(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 874 | const extra = self.code.extraData(Zir.Inst.Select, extended.operand).data; | 866 | const extra = self.code.extraData(Zir.Inst.Select, extended.operand).data; |
| 875 | try self.writeInstRef(stream, extra.elem_type); | 867 | try self.writeInstRef(stream, extra.elem_type); |
| 876 | try stream.writeAll(", "); | 868 | try stream.writeAll(", "); |
| ... | @@ -883,7 +875,7 @@ const Writer = struct { | ... | @@ -883,7 +875,7 @@ const Writer = struct { |
| 883 | try self.writeSrcNode(stream, extra.node); | 875 | try self.writeSrcNode(stream, extra.node); |
| 884 | } | 876 | } |
| 885 | | 877 | |
| 886 | fn writeMulAdd(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 878 | fn writeMulAdd(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 887 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 879 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 888 | const extra = self.code.extraData(Zir.Inst.MulAdd, inst_data.payload_index).data; | 880 | const extra = self.code.extraData(Zir.Inst.MulAdd, inst_data.payload_index).data; |
| 889 | try self.writeInstRef(stream, extra.mulend1); | 881 | try self.writeInstRef(stream, extra.mulend1); |
| ... | @@ -895,7 +887,7 @@ const Writer = struct { | ... | @@ -895,7 +887,7 @@ const Writer = struct { |
| 895 | try self.writeSrcNode(stream, inst_data.src_node); | 887 | try self.writeSrcNode(stream, inst_data.src_node); |
| 896 | } | 888 | } |
| 897 | | 889 | |
| 898 | fn writeBuiltinCall(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 890 | fn writeBuiltinCall(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 899 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 891 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 900 | const extra = self.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data; | 892 | const extra = self.code.extraData(Zir.Inst.BuiltinCall, inst_data.payload_index).data; |
| 901 | | 893 | |
| ... | @@ -911,7 +903,7 @@ const Writer = struct { | ... | @@ -911,7 +903,7 @@ const Writer = struct { |
| 911 | try self.writeSrcNode(stream, inst_data.src_node); | 903 | try self.writeSrcNode(stream, inst_data.src_node); |
| 912 | } | 904 | } |
| 913 | | 905 | |
| 914 | fn writeFieldParentPtr(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 906 | fn writeFieldParentPtr(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 915 | const extra = self.code.extraData(Zir.Inst.FieldParentPtr, extended.operand).data; | 907 | const extra = self.code.extraData(Zir.Inst.FieldParentPtr, extended.operand).data; |
| 916 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?; | 908 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?; |
| 917 | const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small))); | 909 | const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small))); |
| ... | @@ -928,7 +920,7 @@ const Writer = struct { | ... | @@ -928,7 +920,7 @@ const Writer = struct { |
| 928 | try self.writeSrcNode(stream, extra.src_node); | 920 | try self.writeSrcNode(stream, extra.src_node); |
| 929 | } | 921 | } |
| 930 | | 922 | |
| 931 | fn writeParam(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 923 | fn writeParam(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 932 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_tok; | 924 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_tok; |
| 933 | const extra = self.code.extraData(Zir.Inst.Param, inst_data.payload_index); | 925 | const extra = self.code.extraData(Zir.Inst.Param, inst_data.payload_index); |
| 934 | const body = self.code.bodySlice(extra.end, extra.data.type.body_len); | 926 | const body = self.code.bodySlice(extra.end, extra.data.type.body_len); |
| ... | @@ -943,7 +935,7 @@ const Writer = struct { | ... | @@ -943,7 +935,7 @@ const Writer = struct { |
| 943 | try self.writeSrcTok(stream, inst_data.src_tok); | 935 | try self.writeSrcTok(stream, inst_data.src_tok); |
| 944 | } | 936 | } |
| 945 | | 937 | |
| 946 | fn writePlNodeBin(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 938 | fn writePlNodeBin(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 947 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 939 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 948 | const extra = self.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; | 940 | const extra = self.code.extraData(Zir.Inst.Bin, inst_data.payload_index).data; |
| 949 | try self.writeInstRef(stream, extra.lhs); | 941 | try self.writeInstRef(stream, extra.lhs); |
| ... | @@ -953,7 +945,7 @@ const Writer = struct { | ... | @@ -953,7 +945,7 @@ const Writer = struct { |
| 953 | try self.writeSrcNode(stream, inst_data.src_node); | 945 | try self.writeSrcNode(stream, inst_data.src_node); |
| 954 | } | 946 | } |
| 955 | | 947 | |
| 956 | fn writePlNodeMultiOp(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 948 | fn writePlNodeMultiOp(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 957 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 949 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 958 | const extra = self.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index); | 950 | const extra = self.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index); |
| 959 | const args = self.code.refSlice(extra.end, extra.data.operands_len); | 951 | const args = self.code.refSlice(extra.end, extra.data.operands_len); |
| ... | @@ -966,7 +958,7 @@ const Writer = struct { | ... | @@ -966,7 +958,7 @@ const Writer = struct { |
| 966 | try self.writeSrcNode(stream, inst_data.src_node); | 958 | try self.writeSrcNode(stream, inst_data.src_node); |
| 967 | } | 959 | } |
| 968 | | 960 | |
| 969 | fn writeArrayMul(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 961 | fn writeArrayMul(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 970 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 962 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 971 | const extra = self.code.extraData(Zir.Inst.ArrayMul, inst_data.payload_index).data; | 963 | const extra = self.code.extraData(Zir.Inst.ArrayMul, inst_data.payload_index).data; |
| 972 | try self.writeInstRef(stream, extra.res_ty); | 964 | try self.writeInstRef(stream, extra.res_ty); |
| ... | @@ -978,13 +970,13 @@ const Writer = struct { | ... | @@ -978,13 +970,13 @@ const Writer = struct { |
| 978 | try self.writeSrcNode(stream, inst_data.src_node); | 970 | try self.writeSrcNode(stream, inst_data.src_node); |
| 979 | } | 971 | } |
| 980 | | 972 | |
| 981 | fn writeElemValImm(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 973 | fn writeElemValImm(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 982 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].elem_val_imm; | 974 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].elem_val_imm; |
| 983 | try self.writeInstRef(stream, inst_data.operand); | 975 | try self.writeInstRef(stream, inst_data.operand); |
| 984 | try stream.print(", {d})", .{inst_data.idx}); | 976 | try stream.print(", {d})", .{inst_data.idx}); |
| 985 | } | 977 | } |
| 986 | | 978 | |
| 987 | fn writeArrayInitElemPtr(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 979 | fn writeArrayInitElemPtr(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 988 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 980 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 989 | const extra = self.code.extraData(Zir.Inst.ElemPtrImm, inst_data.payload_index).data; | 981 | const extra = self.code.extraData(Zir.Inst.ElemPtrImm, inst_data.payload_index).data; |
| 990 | | 982 | |
| ... | @@ -993,7 +985,7 @@ const Writer = struct { | ... | @@ -993,7 +985,7 @@ const Writer = struct { |
| 993 | try self.writeSrcNode(stream, inst_data.src_node); | 985 | try self.writeSrcNode(stream, inst_data.src_node); |
| 994 | } | 986 | } |
| 995 | | 987 | |
| 996 | fn writePlNodeExport(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 988 | fn writePlNodeExport(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 997 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 989 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 998 | const extra = self.code.extraData(Zir.Inst.Export, inst_data.payload_index).data; | 990 | const extra = self.code.extraData(Zir.Inst.Export, inst_data.payload_index).data; |
| 999 | | 991 | |
| ... | @@ -1004,7 +996,7 @@ const Writer = struct { | ... | @@ -1004,7 +996,7 @@ const Writer = struct { |
| 1004 | try self.writeSrcNode(stream, inst_data.src_node); | 996 | try self.writeSrcNode(stream, inst_data.src_node); |
| 1005 | } | 997 | } |
| 1006 | | 998 | |
| 1007 | fn writeValidateArrayInitRefTy(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 999 | fn writeValidateArrayInitRefTy(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 1008 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 1000 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 1009 | const extra = self.code.extraData(Zir.Inst.ArrayInitRefTy, inst_data.payload_index).data; | 1001 | const extra = self.code.extraData(Zir.Inst.ArrayInitRefTy, inst_data.payload_index).data; |
| 1010 | | 1002 | |
| ... | @@ -1014,7 +1006,7 @@ const Writer = struct { | ... | @@ -1014,7 +1006,7 @@ const Writer = struct { |
| 1014 | try self.writeSrcNode(stream, inst_data.src_node); | 1006 | try self.writeSrcNode(stream, inst_data.src_node); |
| 1015 | } | 1007 | } |
| 1016 | | 1008 | |
| 1017 | fn writeStructInit(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 1009 | fn writeStructInit(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 1018 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 1010 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 1019 | const extra = self.code.extraData(Zir.Inst.StructInit, inst_data.payload_index); | 1011 | const extra = self.code.extraData(Zir.Inst.StructInit, inst_data.payload_index); |
| 1020 | var field_i: u32 = 0; | 1012 | var field_i: u32 = 0; |
| ... | @@ -1038,7 +1030,7 @@ const Writer = struct { | ... | @@ -1038,7 +1030,7 @@ const Writer = struct { |
| 1038 | try self.writeSrcNode(stream, inst_data.src_node); | 1030 | try self.writeSrcNode(stream, inst_data.src_node); |
| 1039 | } | 1031 | } |
| 1040 | | 1032 | |
| 1041 | fn writeCmpxchg(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 1033 | fn writeCmpxchg(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 1042 | const extra = self.code.extraData(Zir.Inst.Cmpxchg, extended.operand).data; | 1034 | const extra = self.code.extraData(Zir.Inst.Cmpxchg, extended.operand).data; |
| 1043 | | 1035 | |
| 1044 | try self.writeInstRef(stream, extra.ptr); | 1036 | try self.writeInstRef(stream, extra.ptr); |
| ... | @@ -1054,7 +1046,7 @@ const Writer = struct { | ... | @@ -1054,7 +1046,7 @@ const Writer = struct { |
| 1054 | try self.writeSrcNode(stream, extra.node); | 1046 | try self.writeSrcNode(stream, extra.node); |
| 1055 | } | 1047 | } |
| 1056 | | 1048 | |
| 1057 | fn writePtrCastFull(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 1049 | fn writePtrCastFull(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 1058 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?; | 1050 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?; |
| 1059 | const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small))); | 1051 | const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small))); |
| 1060 | const extra = self.code.extraData(Zir.Inst.BinNode, extended.operand).data; | 1052 | const extra = self.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| ... | @@ -1070,7 +1062,7 @@ const Writer = struct { | ... | @@ -1070,7 +1062,7 @@ const Writer = struct { |
| 1070 | try self.writeSrcNode(stream, extra.node); | 1062 | try self.writeSrcNode(stream, extra.node); |
| 1071 | } | 1063 | } |
| 1072 | | 1064 | |
| 1073 | fn writePtrCastNoDest(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 1065 | fn writePtrCastNoDest(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 1074 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?; | 1066 | const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?; |
| 1075 | const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small))); | 1067 | const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small))); |
| 1076 | const extra = self.code.extraData(Zir.Inst.UnNode, extended.operand).data; | 1068 | const extra = self.code.extraData(Zir.Inst.UnNode, extended.operand).data; |
| ... | @@ -1081,7 +1073,7 @@ const Writer = struct { | ... | @@ -1081,7 +1073,7 @@ const Writer = struct { |
| 1081 | try self.writeSrcNode(stream, extra.node); | 1073 | try self.writeSrcNode(stream, extra.node); |
| 1082 | } | 1074 | } |
| 1083 | | 1075 | |
| 1084 | fn writeAtomicLoad(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 1076 | fn writeAtomicLoad(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 1085 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 1077 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 1086 | const extra = self.code.extraData(Zir.Inst.AtomicLoad, inst_data.payload_index).data; | 1078 | const extra = self.code.extraData(Zir.Inst.AtomicLoad, inst_data.payload_index).data; |
| 1087 | | 1079 | |
| ... | @@ -1094,7 +1086,7 @@ const Writer = struct { | ... | @@ -1094,7 +1086,7 @@ const Writer = struct { |
| 1094 | try self.writeSrcNode(stream, inst_data.src_node); | 1086 | try self.writeSrcNode(stream, inst_data.src_node); |
| 1095 | } | 1087 | } |
| 1096 | | 1088 | |
| 1097 | fn writeAtomicStore(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 1089 | fn writeAtomicStore(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 1098 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 1090 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 1099 | const extra = self.code.extraData(Zir.Inst.AtomicStore, inst_data.payload_index).data; | 1091 | const extra = self.code.extraData(Zir.Inst.AtomicStore, inst_data.payload_index).data; |
| 1100 | | 1092 | |
| ... | @@ -1107,7 +1099,7 @@ const Writer = struct { | ... | @@ -1107,7 +1099,7 @@ const Writer = struct { |
| 1107 | try self.writeSrcNode(stream, inst_data.src_node); | 1099 | try self.writeSrcNode(stream, inst_data.src_node); |
| 1108 | } | 1100 | } |
| 1109 | | 1101 | |
| 1110 | fn writeAtomicRmw(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 1102 | fn writeAtomicRmw(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 1111 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 1103 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 1112 | const extra = self.code.extraData(Zir.Inst.AtomicRmw, inst_data.payload_index).data; | 1104 | const extra = self.code.extraData(Zir.Inst.AtomicRmw, inst_data.payload_index).data; |
| 1113 | | 1105 | |
| ... | @@ -1122,7 +1114,7 @@ const Writer = struct { | ... | @@ -1122,7 +1114,7 @@ const Writer = struct { |
| 1122 | try self.writeSrcNode(stream, inst_data.src_node); | 1114 | try self.writeSrcNode(stream, inst_data.src_node); |
| 1123 | } | 1115 | } |
| 1124 | | 1116 | |
| 1125 | fn writeStructInitAnon(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 1117 | fn writeStructInitAnon(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 1126 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 1118 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 1127 | const extra = self.code.extraData(Zir.Inst.StructInitAnon, inst_data.payload_index); | 1119 | const extra = self.code.extraData(Zir.Inst.StructInitAnon, inst_data.payload_index); |
| 1128 | var field_i: u32 = 0; | 1120 | var field_i: u32 = 0; |
| ... | @@ -1143,7 +1135,7 @@ const Writer = struct { | ... | @@ -1143,7 +1135,7 @@ const Writer = struct { |
| 1143 | try self.writeSrcNode(stream, inst_data.src_node); | 1135 | try self.writeSrcNode(stream, inst_data.src_node); |
| 1144 | } | 1136 | } |
| 1145 | | 1137 | |
| 1146 | fn writeStructInitFieldType(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 1138 | fn writeStructInitFieldType(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 1147 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 1139 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 1148 | const extra = self.code.extraData(Zir.Inst.FieldType, inst_data.payload_index).data; | 1140 | const extra = self.code.extraData(Zir.Inst.FieldType, inst_data.payload_index).data; |
| 1149 | try self.writeInstRef(stream, extra.container_type); | 1141 | try self.writeInstRef(stream, extra.container_type); |
| ... | @@ -1152,7 +1144,7 @@ const Writer = struct { | ... | @@ -1152,7 +1144,7 @@ const Writer = struct { |
| 1152 | try self.writeSrcNode(stream, inst_data.src_node); | 1144 | try self.writeSrcNode(stream, inst_data.src_node); |
| 1153 | } | 1145 | } |
| 1154 | | 1146 | |
| 1155 | fn writeFieldTypeRef(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 1147 | fn writeFieldTypeRef(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 1156 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 1148 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 1157 | const extra = self.code.extraData(Zir.Inst.FieldTypeRef, inst_data.payload_index).data; | 1149 | const extra = self.code.extraData(Zir.Inst.FieldTypeRef, inst_data.payload_index).data; |
| 1158 | try self.writeInstRef(stream, extra.container_type); | 1150 | try self.writeInstRef(stream, extra.container_type); |
| ... | @@ -1162,7 +1154,7 @@ const Writer = struct { | ... | @@ -1162,7 +1154,7 @@ const Writer = struct { |
| 1162 | try self.writeSrcNode(stream, inst_data.src_node); | 1154 | try self.writeSrcNode(stream, inst_data.src_node); |
| 1163 | } | 1155 | } |
| 1164 | | 1156 | |
| 1165 | fn writeNodeMultiOp(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 1157 | fn writeNodeMultiOp(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 1166 | const extra = self.code.extraData(Zir.Inst.NodeMultiOp, extended.operand); | 1158 | const extra = self.code.extraData(Zir.Inst.NodeMultiOp, extended.operand); |
| 1167 | const operands = self.code.refSlice(extra.end, extended.small); | 1159 | const operands = self.code.refSlice(extra.end, extended.small); |
| 1168 | | 1160 | |
| ... | @@ -1176,9 +1168,9 @@ const Writer = struct { | ... | @@ -1176,9 +1168,9 @@ const Writer = struct { |
| 1176 | | 1168 | |
| 1177 | fn writeInstNode( | 1169 | fn writeInstNode( |
| 1178 | self: *Writer, | 1170 | self: *Writer, |
| 1179 | stream: anytype, | 1171 | stream: *std.io.Writer, |
| 1180 | inst: Zir.Inst.Index, | 1172 | inst: Zir.Inst.Index, |
| 1181 | ) (@TypeOf(stream).Error || error{OutOfMemory})!void { | 1173 | ) Error!void { |
| 1182 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].inst_node; | 1174 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].inst_node; |
| 1183 | try self.writeInstIndex(stream, inst_data.inst); | 1175 | try self.writeInstIndex(stream, inst_data.inst); |
| 1184 | try stream.writeAll(") "); | 1176 | try stream.writeAll(") "); |
| ... | @@ -1187,7 +1179,7 @@ const Writer = struct { | ... | @@ -1187,7 +1179,7 @@ const Writer = struct { |
| 1187 | | 1179 | |
| 1188 | fn writeAsm( | 1180 | fn writeAsm( |
| 1189 | self: *Writer, | 1181 | self: *Writer, |
| 1190 | stream: anytype, | 1182 | stream: *std.io.Writer, |
| 1191 | extended: Zir.Inst.Extended.InstData, | 1183 | extended: Zir.Inst.Extended.InstData, |
| 1192 | tmpl_is_expr: bool, | 1184 | tmpl_is_expr: bool, |
| 1193 | ) !void { | 1185 | ) !void { |
| ... | @@ -1220,8 +1212,8 @@ const Writer = struct { | ... | @@ -1220,8 +1212,8 @@ const Writer = struct { |
| 1220 | | 1212 | |
| 1221 | const name = self.code.nullTerminatedString(output.data.name); | 1213 | const name = self.code.nullTerminatedString(output.data.name); |
| 1222 | const constraint = self.code.nullTerminatedString(output.data.constraint); | 1214 | const constraint = self.code.nullTerminatedString(output.data.constraint); |
| 1223 | try stream.print("output({f}, \"{f}\", ", .{ | 1215 | try stream.print("output({fp}, \"{f}\", ", .{ |
| 1224 | std.zig.fmtIdFlags(name, .{ .allow_primitive = true }), std.zig.fmtString(constraint), | 1216 | std.zig.fmtId(name), std.zig.fmtString(constraint), |
| 1225 | }); | 1217 | }); |
| 1226 | try self.writeFlag(stream, "->", is_type); | 1218 | try self.writeFlag(stream, "->", is_type); |
| 1227 | try self.writeInstRef(stream, output.data.operand); | 1219 | try self.writeInstRef(stream, output.data.operand); |
| ... | @@ -1239,8 +1231,8 @@ const Writer = struct { | ... | @@ -1239,8 +1231,8 @@ const Writer = struct { |
| 1239 | | 1231 | |
| 1240 | const name = self.code.nullTerminatedString(input.data.name); | 1232 | const name = self.code.nullTerminatedString(input.data.name); |
| 1241 | const constraint = self.code.nullTerminatedString(input.data.constraint); | 1233 | const constraint = self.code.nullTerminatedString(input.data.constraint); |
| 1242 | try stream.print("input({f}, \"{f}\", ", .{ | 1234 | try stream.print("input({fp}, \"{f}\", ", .{ |
| 1243 | std.zig.fmtIdFlags(name, .{ .allow_primitive = true }), std.zig.fmtString(constraint), | 1235 | std.zig.fmtId(name), std.zig.fmtString(constraint), |
| 1244 | }); | 1236 | }); |
| 1245 | try self.writeInstRef(stream, input.data.operand); | 1237 | try self.writeInstRef(stream, input.data.operand); |
| 1246 | try stream.writeAll(")"); | 1238 | try stream.writeAll(")"); |
| ... | @@ -1255,7 +1247,7 @@ const Writer = struct { | ... | @@ -1255,7 +1247,7 @@ const Writer = struct { |
| 1255 | const str_index = self.code.extra[extra_i]; | 1247 | const str_index = self.code.extra[extra_i]; |
| 1256 | extra_i += 1; | 1248 | extra_i += 1; |
| 1257 | const clobber = self.code.nullTerminatedString(@enumFromInt(str_index)); | 1249 | const clobber = self.code.nullTerminatedString(@enumFromInt(str_index)); |
| 1258 | try stream.print("{f}", .{std.zig.fmtIdFlags(clobber, .{ .allow_primitive = true })}); | 1250 | try stream.print("{fp}", .{std.zig.fmtId(clobber)}); |
| 1259 | if (i + 1 < clobbers_len) { | 1251 | if (i + 1 < clobbers_len) { |
| 1260 | try stream.writeAll(", "); | 1252 | try stream.writeAll(", "); |
| 1261 | } | 1253 | } |
| ... | @@ -1265,7 +1257,7 @@ const Writer = struct { | ... | @@ -1265,7 +1257,7 @@ const Writer = struct { |
| 1265 | try self.writeSrcNode(stream, extra.data.src_node); | 1257 | try self.writeSrcNode(stream, extra.data.src_node); |
| 1266 | } | 1258 | } |
| 1267 | | 1259 | |
| 1268 | fn writeOverflowArithmetic(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 1260 | fn writeOverflowArithmetic(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 1269 | const extra = self.code.extraData(Zir.Inst.BinNode, extended.operand).data; | 1261 | const extra = self.code.extraData(Zir.Inst.BinNode, extended.operand).data; |
| 1270 | | 1262 | |
| 1271 | try self.writeInstRef(stream, extra.lhs); | 1263 | try self.writeInstRef(stream, extra.lhs); |
| ... | @@ -1277,7 +1269,7 @@ const Writer = struct { | ... | @@ -1277,7 +1269,7 @@ const Writer = struct { |
| 1277 | | 1269 | |
| 1278 | fn writeCall( | 1270 | fn writeCall( |
| 1279 | self: *Writer, | 1271 | self: *Writer, |
| 1280 | stream: anytype, | 1272 | stream: *std.io.Writer, |
| 1281 | inst: Zir.Inst.Index, | 1273 | inst: Zir.Inst.Index, |
| 1282 | comptime kind: enum { direct, field }, | 1274 | comptime kind: enum { direct, field }, |
| 1283 | ) !void { | 1275 | ) !void { |
| ... | @@ -1311,7 +1303,7 @@ const Writer = struct { | ... | @@ -1311,7 +1303,7 @@ const Writer = struct { |
| 1311 | var i: usize = 0; | 1303 | var i: usize = 0; |
| 1312 | var arg_start: u32 = args_len; | 1304 | var arg_start: u32 = args_len; |
| 1313 | while (i < args_len) : (i += 1) { | 1305 | while (i < args_len) : (i += 1) { |
| 1314 | try stream.writeByteNTimes(' ', self.indent); | 1306 | try stream.splatByteAll(' ', self.indent); |
| 1315 | const arg_end = self.code.extra[extra.end + i]; | 1307 | const arg_end = self.code.extra[extra.end + i]; |
| 1316 | defer arg_start = arg_end; | 1308 | defer arg_start = arg_end; |
| 1317 | const arg_body = body[arg_start..arg_end]; | 1309 | const arg_body = body[arg_start..arg_end]; |
| ... | @@ -1321,14 +1313,14 @@ const Writer = struct { | ... | @@ -1321,14 +1313,14 @@ const Writer = struct { |
| 1321 | } | 1313 | } |
| 1322 | self.indent -= 2; | 1314 | self.indent -= 2; |
| 1323 | if (args_len != 0) { | 1315 | if (args_len != 0) { |
| 1324 | try stream.writeByteNTimes(' ', self.indent); | 1316 | try stream.splatByteAll(' ', self.indent); |
| 1325 | } | 1317 | } |
| 1326 | | 1318 | |
| 1327 | try stream.writeAll("]) "); | 1319 | try stream.writeAll("]) "); |
| 1328 | try self.writeSrcNode(stream, inst_data.src_node); | 1320 | try self.writeSrcNode(stream, inst_data.src_node); |
| 1329 | } | 1321 | } |
| 1330 | | 1322 | |
| 1331 | fn writeBlock(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 1323 | fn writeBlock(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 1332 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 1324 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 1333 | const extra = self.code.extraData(Zir.Inst.Block, inst_data.payload_index); | 1325 | const extra = self.code.extraData(Zir.Inst.Block, inst_data.payload_index); |
| 1334 | const body = self.code.bodySlice(extra.end, extra.data.body_len); | 1326 | const body = self.code.bodySlice(extra.end, extra.data.body_len); |
| ... | @@ -1337,7 +1329,7 @@ const Writer = struct { | ... | @@ -1337,7 +1329,7 @@ const Writer = struct { |
| 1337 | try self.writeSrcNode(stream, inst_data.src_node); | 1329 | try self.writeSrcNode(stream, inst_data.src_node); |
| 1338 | } | 1330 | } |
| 1339 | | 1331 | |
| 1340 | fn writeBlockComptime(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 1332 | fn writeBlockComptime(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 1341 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 1333 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 1342 | const extra = self.code.extraData(Zir.Inst.BlockComptime, inst_data.payload_index); | 1334 | const extra = self.code.extraData(Zir.Inst.BlockComptime, inst_data.payload_index); |
| 1343 | const body = self.code.bodySlice(extra.end, extra.data.body_len); | 1335 | const body = self.code.bodySlice(extra.end, extra.data.body_len); |
| ... | @@ -1347,7 +1339,7 @@ const Writer = struct { | ... | @@ -1347,7 +1339,7 @@ const Writer = struct { |
| 1347 | try self.writeSrcNode(stream, inst_data.src_node); | 1339 | try self.writeSrcNode(stream, inst_data.src_node); |
| 1348 | } | 1340 | } |
| 1349 | | 1341 | |
| 1350 | fn writeCondBr(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 1342 | fn writeCondBr(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 1351 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 1343 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 1352 | const extra = self.code.extraData(Zir.Inst.CondBr, inst_data.payload_index); | 1344 | const extra = self.code.extraData(Zir.Inst.CondBr, inst_data.payload_index); |
| 1353 | const then_body = self.code.bodySlice(extra.end, extra.data.then_body_len); | 1345 | const then_body = self.code.bodySlice(extra.end, extra.data.then_body_len); |
| ... | @@ -1361,7 +1353,7 @@ const Writer = struct { | ... | @@ -1361,7 +1353,7 @@ const Writer = struct { |
| 1361 | try self.writeSrcNode(stream, inst_data.src_node); | 1353 | try self.writeSrcNode(stream, inst_data.src_node); |
| 1362 | } | 1354 | } |
| 1363 | | 1355 | |
| 1364 | fn writeTry(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 1356 | fn writeTry(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 1365 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 1357 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 1366 | const extra = self.code.extraData(Zir.Inst.Try, inst_data.payload_index); | 1358 | const extra = self.code.extraData(Zir.Inst.Try, inst_data.payload_index); |
| 1367 | const body = self.code.bodySlice(extra.end, extra.data.body_len); | 1359 | const body = self.code.bodySlice(extra.end, extra.data.body_len); |
| ... | @@ -1372,7 +1364,7 @@ const Writer = struct { | ... | @@ -1372,7 +1364,7 @@ const Writer = struct { |
| 1372 | try self.writeSrcNode(stream, inst_data.src_node); | 1364 | try self.writeSrcNode(stream, inst_data.src_node); |
| 1373 | } | 1365 | } |
| 1374 | | 1366 | |
| 1375 | fn writeStructDecl(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 1367 | fn writeStructDecl(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 1376 | const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small); | 1368 | const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small); |
| 1377 | | 1369 | |
| 1378 | const extra = self.code.extraData(Zir.Inst.StructDecl, extended.operand); | 1370 | const extra = self.code.extraData(Zir.Inst.StructDecl, extended.operand); |
| ... | @@ -1446,7 +1438,7 @@ const Writer = struct { | ... | @@ -1446,7 +1438,7 @@ const Writer = struct { |
| 1446 | try self.writeBody(stream, self.code.bodySlice(extra_index, decls_len)); | 1438 | try self.writeBody(stream, self.code.bodySlice(extra_index, decls_len)); |
| 1447 | self.indent -= 2; | 1439 | self.indent -= 2; |
| 1448 | extra_index += decls_len; | 1440 | extra_index += decls_len; |
| 1449 | try stream.writeByteNTimes(' ', self.indent); | 1441 | try stream.splatByteAll(' ', self.indent); |
| 1450 | try stream.writeAll("}, "); | 1442 | try stream.writeAll("}, "); |
| 1451 | } | 1443 | } |
| 1452 | | 1444 | |
| ... | @@ -1515,11 +1507,11 @@ const Writer = struct { | ... | @@ -1515,11 +1507,11 @@ const Writer = struct { |
| 1515 | self.indent += 2; | 1507 | self.indent += 2; |
| 1516 | | 1508 | |
| 1517 | for (fields, 0..) |field, i| { | 1509 | for (fields, 0..) |field, i| { |
| 1518 | try stream.writeByteNTimes(' ', self.indent); | 1510 | try stream.splatByteAll(' ', self.indent); |
| 1519 | try self.writeFlag(stream, "comptime ", field.is_comptime); | 1511 | try self.writeFlag(stream, "comptime ", field.is_comptime); |
| 1520 | if (field.name != .empty) { | 1512 | if (field.name != .empty) { |
| 1521 | const field_name = self.code.nullTerminatedString(field.name); | 1513 | const field_name = self.code.nullTerminatedString(field.name); |
| 1522 | try stream.print("{f}: ", .{std.zig.fmtIdFlags(field_name, .{ .allow_primitive = true })}); | 1514 | try stream.print("{fp}: ", .{std.zig.fmtId(field_name)}); |
| 1523 | } else { | 1515 | } else { |
| 1524 | try stream.print("@\"{d}\": ", .{i}); | 1516 | try stream.print("@\"{d}\": ", .{i}); |
| 1525 | } | 1517 | } |
| ... | @@ -1558,13 +1550,13 @@ const Writer = struct { | ... | @@ -1558,13 +1550,13 @@ const Writer = struct { |
| 1558 | } | 1550 | } |
| 1559 | | 1551 | |
| 1560 | self.indent -= 2; | 1552 | self.indent -= 2; |
| 1561 | try stream.writeByteNTimes(' ', self.indent); | 1553 | try stream.splatByteAll(' ', self.indent); |
| 1562 | try stream.writeAll("}) "); | 1554 | try stream.writeAll("}) "); |
| 1563 | } | 1555 | } |
| 1564 | try self.writeSrcNode(stream, .zero); | 1556 | try self.writeSrcNode(stream, .zero); |
| 1565 | } | 1557 | } |
| 1566 | | 1558 | |
| 1567 | fn writeUnionDecl(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 1559 | fn writeUnionDecl(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 1568 | const small = @as(Zir.Inst.UnionDecl.Small, @bitCast(extended.small)); | 1560 | const small = @as(Zir.Inst.UnionDecl.Small, @bitCast(extended.small)); |
| 1569 | | 1561 | |
| 1570 | const extra = self.code.extraData(Zir.Inst.UnionDecl, extended.operand); | 1562 | const extra = self.code.extraData(Zir.Inst.UnionDecl, extended.operand); |
| ... | @@ -1630,7 +1622,7 @@ const Writer = struct { | ... | @@ -1630,7 +1622,7 @@ const Writer = struct { |
| 1630 | try self.writeBody(stream, self.code.bodySlice(extra_index, decls_len)); | 1622 | try self.writeBody(stream, self.code.bodySlice(extra_index, decls_len)); |
| 1631 | self.indent -= 2; | 1623 | self.indent -= 2; |
| 1632 | extra_index += decls_len; | 1624 | extra_index += decls_len; |
| 1633 | try stream.writeByteNTimes(' ', self.indent); | 1625 | try stream.splatByteAll(' ', self.indent); |
| 1634 | try stream.writeAll("}"); | 1626 | try stream.writeAll("}"); |
| 1635 | } | 1627 | } |
| 1636 | | 1628 | |
| ... | @@ -1681,8 +1673,8 @@ const Writer = struct { | ... | @@ -1681,8 +1673,8 @@ const Writer = struct { |
| 1681 | const field_name = self.code.nullTerminatedString(field_name_index); | 1673 | const field_name = self.code.nullTerminatedString(field_name_index); |
| 1682 | extra_index += 1; | 1674 | extra_index += 1; |
| 1683 | | 1675 | |
| 1684 | try stream.writeByteNTimes(' ', self.indent); | 1676 | try stream.splatByteAll(' ', self.indent); |
| 1685 | try stream.print("{f}", .{std.zig.fmtIdFlags(field_name, .{ .allow_primitive = true })}); | 1677 | try stream.print("{fp}", .{std.zig.fmtId(field_name)}); |
| 1686 | | 1678 | |
| 1687 | if (has_type) { | 1679 | if (has_type) { |
| 1688 | const field_type = @as(Zir.Inst.Ref, @enumFromInt(self.code.extra[extra_index])); | 1680 | const field_type = @as(Zir.Inst.Ref, @enumFromInt(self.code.extra[extra_index])); |
| ... | @@ -1710,12 +1702,12 @@ const Writer = struct { | ... | @@ -1710,12 +1702,12 @@ const Writer = struct { |
| 1710 | } | 1702 | } |
| 1711 | | 1703 | |
| 1712 | self.indent -= 2; | 1704 | self.indent -= 2; |
| 1713 | try stream.writeByteNTimes(' ', self.indent); | 1705 | try stream.splatByteAll(' ', self.indent); |
| 1714 | try stream.writeAll("}) "); | 1706 | try stream.writeAll("}) "); |
| 1715 | try self.writeSrcNode(stream, .zero); | 1707 | try self.writeSrcNode(stream, .zero); |
| 1716 | } | 1708 | } |
| 1717 | | 1709 | |
| 1718 | fn writeEnumDecl(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 1710 | fn writeEnumDecl(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 1719 | const small = @as(Zir.Inst.EnumDecl.Small, @bitCast(extended.small)); | 1711 | const small = @as(Zir.Inst.EnumDecl.Small, @bitCast(extended.small)); |
| 1720 | | 1712 | |
| 1721 | const extra = self.code.extraData(Zir.Inst.EnumDecl, extended.operand); | 1713 | const extra = self.code.extraData(Zir.Inst.EnumDecl, extended.operand); |
| ... | @@ -1779,7 +1771,7 @@ const Writer = struct { | ... | @@ -1779,7 +1771,7 @@ const Writer = struct { |
| 1779 | try self.writeBody(stream, self.code.bodySlice(extra_index, decls_len)); | 1771 | try self.writeBody(stream, self.code.bodySlice(extra_index, decls_len)); |
| 1780 | self.indent -= 2; | 1772 | self.indent -= 2; |
| 1781 | extra_index += decls_len; | 1773 | extra_index += decls_len; |
| 1782 | try stream.writeByteNTimes(' ', self.indent); | 1774 | try stream.splatByteAll(' ', self.indent); |
| 1783 | try stream.writeAll("}, "); | 1775 | try stream.writeAll("}, "); |
| 1784 | } | 1776 | } |
| 1785 | | 1777 | |
| ... | @@ -1815,8 +1807,8 @@ const Writer = struct { | ... | @@ -1815,8 +1807,8 @@ const Writer = struct { |
| 1815 | const field_name = self.code.nullTerminatedString(@enumFromInt(self.code.extra[extra_index])); | 1807 | const field_name = self.code.nullTerminatedString(@enumFromInt(self.code.extra[extra_index])); |
| 1816 | extra_index += 1; | 1808 | extra_index += 1; |
| 1817 | | 1809 | |
| 1818 | try stream.writeByteNTimes(' ', self.indent); | 1810 | try stream.splatByteAll(' ', self.indent); |
| 1819 | try stream.print("{f}", .{std.zig.fmtIdFlags(field_name, .{ .allow_primitive = true })}); | 1811 | try stream.print("{fp}", .{std.zig.fmtId(field_name)}); |
| 1820 | | 1812 | |
| 1821 | if (has_tag_value) { | 1813 | if (has_tag_value) { |
| 1822 | const tag_value_ref = @as(Zir.Inst.Ref, @enumFromInt(self.code.extra[extra_index])); | 1814 | const tag_value_ref = @as(Zir.Inst.Ref, @enumFromInt(self.code.extra[extra_index])); |
| ... | @@ -1828,7 +1820,7 @@ const Writer = struct { | ... | @@ -1828,7 +1820,7 @@ const Writer = struct { |
| 1828 | try stream.writeAll(",\n"); | 1820 | try stream.writeAll(",\n"); |
| 1829 | } | 1821 | } |
| 1830 | self.indent -= 2; | 1822 | self.indent -= 2; |
| 1831 | try stream.writeByteNTimes(' ', self.indent); | 1823 | try stream.splatByteAll(' ', self.indent); |
| 1832 | try stream.writeAll("}) "); | 1824 | try stream.writeAll("}) "); |
| 1833 | } | 1825 | } |
| 1834 | try self.writeSrcNode(stream, .zero); | 1826 | try self.writeSrcNode(stream, .zero); |
| ... | @@ -1836,7 +1828,7 @@ const Writer = struct { | ... | @@ -1836,7 +1828,7 @@ const Writer = struct { |
| 1836 | | 1828 | |
| 1837 | fn writeOpaqueDecl( | 1829 | fn writeOpaqueDecl( |
| 1838 | self: *Writer, | 1830 | self: *Writer, |
| 1839 | stream: anytype, | 1831 | stream: *std.io.Writer, |
| 1840 | extended: Zir.Inst.Extended.InstData, | 1832 | extended: Zir.Inst.Extended.InstData, |
| 1841 | ) !void { | 1833 | ) !void { |
| 1842 | const small = @as(Zir.Inst.OpaqueDecl.Small, @bitCast(extended.small)); | 1834 | const small = @as(Zir.Inst.OpaqueDecl.Small, @bitCast(extended.small)); |
| ... | @@ -1872,13 +1864,13 @@ const Writer = struct { | ... | @@ -1872,13 +1864,13 @@ const Writer = struct { |
| 1872 | self.indent += 2; | 1864 | self.indent += 2; |
| 1873 | try self.writeBody(stream, self.code.bodySlice(extra_index, decls_len)); | 1865 | try self.writeBody(stream, self.code.bodySlice(extra_index, decls_len)); |
| 1874 | self.indent -= 2; | 1866 | self.indent -= 2; |
| 1875 | try stream.writeByteNTimes(' ', self.indent); | 1867 | try stream.splatByteAll(' ', self.indent); |
| 1876 | try stream.writeAll("}) "); | 1868 | try stream.writeAll("}) "); |
| 1877 | } | 1869 | } |
| 1878 | try self.writeSrcNode(stream, .zero); | 1870 | try self.writeSrcNode(stream, .zero); |
| 1879 | } | 1871 | } |
| 1880 | | 1872 | |
| 1881 | fn writeTupleDecl(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 1873 | fn writeTupleDecl(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 1882 | const fields_len = extended.small; | 1874 | const fields_len = extended.small; |
| 1883 | assert(fields_len != 0); | 1875 | assert(fields_len != 0); |
| 1884 | const extra = self.code.extraData(Zir.Inst.TupleDecl, extended.operand); | 1876 | const extra = self.code.extraData(Zir.Inst.TupleDecl, extended.operand); |
| ... | @@ -1906,7 +1898,7 @@ const Writer = struct { | ... | @@ -1906,7 +1898,7 @@ const Writer = struct { |
| 1906 | | 1898 | |
| 1907 | fn writeErrorSetDecl( | 1899 | fn writeErrorSetDecl( |
| 1908 | self: *Writer, | 1900 | self: *Writer, |
| 1909 | stream: anytype, | 1901 | stream: *std.io.Writer, |
| 1910 | inst: Zir.Inst.Index, | 1902 | inst: Zir.Inst.Index, |
| 1911 | ) !void { | 1903 | ) !void { |
| 1912 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 1904 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| ... | @@ -1920,18 +1912,18 @@ const Writer = struct { | ... | @@ -1920,18 +1912,18 @@ const Writer = struct { |
| 1920 | while (extra_index < extra_index_end) : (extra_index += 1) { | 1912 | while (extra_index < extra_index_end) : (extra_index += 1) { |
| 1921 | const name_index: Zir.NullTerminatedString = @enumFromInt(self.code.extra[extra_index]); | 1913 | const name_index: Zir.NullTerminatedString = @enumFromInt(self.code.extra[extra_index]); |
| 1922 | const name = self.code.nullTerminatedString(name_index); | 1914 | const name = self.code.nullTerminatedString(name_index); |
| 1923 | try stream.writeByteNTimes(' ', self.indent); | 1915 | try stream.splatByteAll(' ', self.indent); |
| 1924 | try stream.print("{f},\n", .{std.zig.fmtIdFlags(name, .{ .allow_primitive = true })}); | 1916 | try stream.print("{fp},\n", .{std.zig.fmtId(name)}); |
| 1925 | } | 1917 | } |
| 1926 | | 1918 | |
| 1927 | self.indent -= 2; | 1919 | self.indent -= 2; |
| 1928 | try stream.writeByteNTimes(' ', self.indent); | 1920 | try stream.splatByteAll(' ', self.indent); |
| 1929 | try stream.writeAll("}) "); | 1921 | try stream.writeAll("}) "); |
| 1930 | | 1922 | |
| 1931 | try self.writeSrcNode(stream, inst_data.src_node); | 1923 | try self.writeSrcNode(stream, inst_data.src_node); |
| 1932 | } | 1924 | } |
| 1933 | | 1925 | |
| 1934 | fn writeSwitchBlockErrUnion(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 1926 | fn writeSwitchBlockErrUnion(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 1935 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 1927 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 1936 | const extra = self.code.extraData(Zir.Inst.SwitchBlockErrUnion, inst_data.payload_index); | 1928 | const extra = self.code.extraData(Zir.Inst.SwitchBlockErrUnion, inst_data.payload_index); |
| 1937 | | 1929 | |
| ... | @@ -1967,7 +1959,7 @@ const Writer = struct { | ... | @@ -1967,7 +1959,7 @@ const Writer = struct { |
| 1967 | extra_index += body.len; | 1959 | extra_index += body.len; |
| 1968 | | 1960 | |
| 1969 | try stream.writeAll(",\n"); | 1961 | try stream.writeAll(",\n"); |
| 1970 | try stream.writeByteNTimes(' ', self.indent); | 1962 | try stream.splatByteAll(' ', self.indent); |
| 1971 | try stream.writeAll("non_err => "); | 1963 | try stream.writeAll("non_err => "); |
| 1972 | try self.writeBracedBody(stream, body); | 1964 | try self.writeBracedBody(stream, body); |
| 1973 | } | 1965 | } |
| ... | @@ -1985,7 +1977,7 @@ const Writer = struct { | ... | @@ -1985,7 +1977,7 @@ const Writer = struct { |
| 1985 | extra_index += body.len; | 1977 | extra_index += body.len; |
| 1986 | | 1978 | |
| 1987 | try stream.writeAll(",\n"); | 1979 | try stream.writeAll(",\n"); |
| 1988 | try stream.writeByteNTimes(' ', self.indent); | 1980 | try stream.splatByteAll(' ', self.indent); |
| 1989 | try stream.print("{s}{s}else => ", .{ capture_text, inline_text }); | 1981 | try stream.print("{s}{s}else => ", .{ capture_text, inline_text }); |
| 1990 | try self.writeBracedBody(stream, body); | 1982 | try self.writeBracedBody(stream, body); |
| 1991 | } | 1983 | } |
| ... | @@ -2002,7 +1994,7 @@ const Writer = struct { | ... | @@ -2002,7 +1994,7 @@ const Writer = struct { |
| 2002 | extra_index += info.body_len; | 1994 | extra_index += info.body_len; |
| 2003 | | 1995 | |
| 2004 | try stream.writeAll(",\n"); | 1996 | try stream.writeAll(",\n"); |
| 2005 | try stream.writeByteNTimes(' ', self.indent); | 1997 | try stream.splatByteAll(' ', self.indent); |
| 2006 | switch (info.capture) { | 1998 | switch (info.capture) { |
| 2007 | .none => {}, | 1999 | .none => {}, |
| 2008 | .by_val => try stream.writeAll("by_val "), | 2000 | .by_val => try stream.writeAll("by_val "), |
| ... | @@ -2027,7 +2019,7 @@ const Writer = struct { | ... | @@ -2027,7 +2019,7 @@ const Writer = struct { |
| 2027 | extra_index += items_len; | 2019 | extra_index += items_len; |
| 2028 | | 2020 | |
| 2029 | try stream.writeAll(",\n"); | 2021 | try stream.writeAll(",\n"); |
| 2030 | try stream.writeByteNTimes(' ', self.indent); | 2022 | try stream.splatByteAll(' ', self.indent); |
| 2031 | switch (info.capture) { | 2023 | switch (info.capture) { |
| 2032 | .none => {}, | 2024 | .none => {}, |
| 2033 | .by_val => try stream.writeAll("by_val "), | 2025 | .by_val => try stream.writeAll("by_val "), |
| ... | @@ -2068,7 +2060,7 @@ const Writer = struct { | ... | @@ -2068,7 +2060,7 @@ const Writer = struct { |
| 2068 | try self.writeSrcNode(stream, inst_data.src_node); | 2060 | try self.writeSrcNode(stream, inst_data.src_node); |
| 2069 | } | 2061 | } |
| 2070 | | 2062 | |
| 2071 | fn writeSwitchBlock(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2063 | fn writeSwitchBlock(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2072 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 2064 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 2073 | const extra = self.code.extraData(Zir.Inst.SwitchBlock, inst_data.payload_index); | 2065 | const extra = self.code.extraData(Zir.Inst.SwitchBlock, inst_data.payload_index); |
| 2074 | | 2066 | |
| ... | @@ -2115,7 +2107,7 @@ const Writer = struct { | ... | @@ -2115,7 +2107,7 @@ const Writer = struct { |
| 2115 | extra_index += body.len; | 2107 | extra_index += body.len; |
| 2116 | | 2108 | |
| 2117 | try stream.writeAll(",\n"); | 2109 | try stream.writeAll(",\n"); |
| 2118 | try stream.writeByteNTimes(' ', self.indent); | 2110 | try stream.splatByteAll(' ', self.indent); |
| 2119 | try stream.print("{s}{s}{s} => ", .{ capture_text, inline_text, prong_name }); | 2111 | try stream.print("{s}{s}{s} => ", .{ capture_text, inline_text, prong_name }); |
| 2120 | try self.writeBracedBody(stream, body); | 2112 | try self.writeBracedBody(stream, body); |
| 2121 | } | 2113 | } |
| ... | @@ -2132,7 +2124,7 @@ const Writer = struct { | ... | @@ -2132,7 +2124,7 @@ const Writer = struct { |
| 2132 | extra_index += info.body_len; | 2124 | extra_index += info.body_len; |
| 2133 | | 2125 | |
| 2134 | try stream.writeAll(",\n"); | 2126 | try stream.writeAll(",\n"); |
| 2135 | try stream.writeByteNTimes(' ', self.indent); | 2127 | try stream.splatByteAll(' ', self.indent); |
| 2136 | switch (info.capture) { | 2128 | switch (info.capture) { |
| 2137 | .none => {}, | 2129 | .none => {}, |
| 2138 | .by_val => try stream.writeAll("by_val "), | 2130 | .by_val => try stream.writeAll("by_val "), |
| ... | @@ -2157,7 +2149,7 @@ const Writer = struct { | ... | @@ -2157,7 +2149,7 @@ const Writer = struct { |
| 2157 | extra_index += items_len; | 2149 | extra_index += items_len; |
| 2158 | | 2150 | |
| 2159 | try stream.writeAll(",\n"); | 2151 | try stream.writeAll(",\n"); |
| 2160 | try stream.writeByteNTimes(' ', self.indent); | 2152 | try stream.splatByteAll(' ', self.indent); |
| 2161 | switch (info.capture) { | 2153 | switch (info.capture) { |
| 2162 | .none => {}, | 2154 | .none => {}, |
| 2163 | .by_val => try stream.writeAll("by_val "), | 2155 | .by_val => try stream.writeAll("by_val "), |
| ... | @@ -2198,7 +2190,7 @@ const Writer = struct { | ... | @@ -2198,7 +2190,7 @@ const Writer = struct { |
| 2198 | try self.writeSrcNode(stream, inst_data.src_node); | 2190 | try self.writeSrcNode(stream, inst_data.src_node); |
| 2199 | } | 2191 | } |
| 2200 | | 2192 | |
| 2201 | fn writePlNodeField(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2193 | fn writePlNodeField(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2202 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 2194 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 2203 | const extra = self.code.extraData(Zir.Inst.Field, inst_data.payload_index).data; | 2195 | const extra = self.code.extraData(Zir.Inst.Field, inst_data.payload_index).data; |
| 2204 | const name = self.code.nullTerminatedString(extra.field_name_start); | 2196 | const name = self.code.nullTerminatedString(extra.field_name_start); |
| ... | @@ -2207,7 +2199,7 @@ const Writer = struct { | ... | @@ -2207,7 +2199,7 @@ const Writer = struct { |
| 2207 | try self.writeSrcNode(stream, inst_data.src_node); | 2199 | try self.writeSrcNode(stream, inst_data.src_node); |
| 2208 | } | 2200 | } |
| 2209 | | 2201 | |
| 2210 | fn writePlNodeFieldNamed(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2202 | fn writePlNodeFieldNamed(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2211 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 2203 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 2212 | const extra = self.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data; | 2204 | const extra = self.code.extraData(Zir.Inst.FieldNamed, inst_data.payload_index).data; |
| 2213 | try self.writeInstRef(stream, extra.lhs); | 2205 | try self.writeInstRef(stream, extra.lhs); |
| ... | @@ -2217,7 +2209,7 @@ const Writer = struct { | ... | @@ -2217,7 +2209,7 @@ const Writer = struct { |
| 2217 | try self.writeSrcNode(stream, inst_data.src_node); | 2209 | try self.writeSrcNode(stream, inst_data.src_node); |
| 2218 | } | 2210 | } |
| 2219 | | 2211 | |
| 2220 | fn writeAs(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2212 | fn writeAs(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2221 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 2213 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 2222 | const extra = self.code.extraData(Zir.Inst.As, inst_data.payload_index).data; | 2214 | const extra = self.code.extraData(Zir.Inst.As, inst_data.payload_index).data; |
| 2223 | try self.writeInstRef(stream, extra.dest_type); | 2215 | try self.writeInstRef(stream, extra.dest_type); |
| ... | @@ -2229,9 +2221,9 @@ const Writer = struct { | ... | @@ -2229,9 +2221,9 @@ const Writer = struct { |
| 2229 | | 2221 | |
| 2230 | fn writeNode( | 2222 | fn writeNode( |
| 2231 | self: *Writer, | 2223 | self: *Writer, |
| 2232 | stream: anytype, | 2224 | stream: *std.io.Writer, |
| 2233 | inst: Zir.Inst.Index, | 2225 | inst: Zir.Inst.Index, |
| 2234 | ) (@TypeOf(stream).Error || error{OutOfMemory})!void { | 2226 | ) Error!void { |
| 2235 | const src_node = self.code.instructions.items(.data)[@intFromEnum(inst)].node; | 2227 | const src_node = self.code.instructions.items(.data)[@intFromEnum(inst)].node; |
| 2236 | try stream.writeAll(") "); | 2228 | try stream.writeAll(") "); |
| 2237 | try self.writeSrcNode(stream, src_node); | 2229 | try self.writeSrcNode(stream, src_node); |
| ... | @@ -2239,16 +2231,16 @@ const Writer = struct { | ... | @@ -2239,16 +2231,16 @@ const Writer = struct { |
| 2239 | | 2231 | |
| 2240 | fn writeStrTok( | 2232 | fn writeStrTok( |
| 2241 | self: *Writer, | 2233 | self: *Writer, |
| 2242 | stream: anytype, | 2234 | stream: *std.io.Writer, |
| 2243 | inst: Zir.Inst.Index, | 2235 | inst: Zir.Inst.Index, |
| 2244 | ) (@TypeOf(stream).Error || error{OutOfMemory})!void { | 2236 | ) Error!void { |
| 2245 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str_tok; | 2237 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str_tok; |
| 2246 | const str = inst_data.get(self.code); | 2238 | const str = inst_data.get(self.code); |
| 2247 | try stream.print("\"{f}\") ", .{std.zig.fmtString(str)}); | 2239 | try stream.print("\"{f}\") ", .{std.zig.fmtString(str)}); |
| 2248 | try self.writeSrcTok(stream, inst_data.src_tok); | 2240 | try self.writeSrcTok(stream, inst_data.src_tok); |
| 2249 | } | 2241 | } |
| 2250 | | 2242 | |
| 2251 | fn writeStrOp(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2243 | fn writeStrOp(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2252 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str_op; | 2244 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str_op; |
| 2253 | const str = inst_data.getStr(self.code); | 2245 | const str = inst_data.getStr(self.code); |
| 2254 | try self.writeInstRef(stream, inst_data.operand); | 2246 | try self.writeInstRef(stream, inst_data.operand); |
| ... | @@ -2257,7 +2249,7 @@ const Writer = struct { | ... | @@ -2257,7 +2249,7 @@ const Writer = struct { |
| 2257 | | 2249 | |
| 2258 | fn writeFunc( | 2250 | fn writeFunc( |
| 2259 | self: *Writer, | 2251 | self: *Writer, |
| 2260 | stream: anytype, | 2252 | stream: *std.io.Writer, |
| 2261 | inst: Zir.Inst.Index, | 2253 | inst: Zir.Inst.Index, |
| 2262 | inferred_error_set: bool, | 2254 | inferred_error_set: bool, |
| 2263 | ) !void { | 2255 | ) !void { |
| ... | @@ -2308,7 +2300,7 @@ const Writer = struct { | ... | @@ -2308,7 +2300,7 @@ const Writer = struct { |
| 2308 | ); | 2300 | ); |
| 2309 | } | 2301 | } |
| 2310 | | 2302 | |
| 2311 | fn writeFuncFancy(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2303 | fn writeFuncFancy(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2312 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 2304 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 2313 | const extra = self.code.extraData(Zir.Inst.FuncFancy, inst_data.payload_index); | 2305 | const extra = self.code.extraData(Zir.Inst.FuncFancy, inst_data.payload_index); |
| 2314 | | 2306 | |
| ... | @@ -2367,7 +2359,7 @@ const Writer = struct { | ... | @@ -2367,7 +2359,7 @@ const Writer = struct { |
| 2367 | ); | 2359 | ); |
| 2368 | } | 2360 | } |
| 2369 | | 2361 | |
| 2370 | fn writeAllocExtended(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 2362 | fn writeAllocExtended(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 2371 | const extra = self.code.extraData(Zir.Inst.AllocExtended, extended.operand); | 2363 | const extra = self.code.extraData(Zir.Inst.AllocExtended, extended.operand); |
| 2372 | const small = @as(Zir.Inst.AllocExtended.Small, @bitCast(extended.small)); | 2364 | const small = @as(Zir.Inst.AllocExtended.Small, @bitCast(extended.small)); |
| 2373 | | 2365 | |
| ... | @@ -2390,7 +2382,7 @@ const Writer = struct { | ... | @@ -2390,7 +2382,7 @@ const Writer = struct { |
| 2390 | try self.writeSrcNode(stream, extra.data.src_node); | 2382 | try self.writeSrcNode(stream, extra.data.src_node); |
| 2391 | } | 2383 | } |
| 2392 | | 2384 | |
| 2393 | fn writeTypeofPeer(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 2385 | fn writeTypeofPeer(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 2394 | const extra = self.code.extraData(Zir.Inst.TypeOfPeer, extended.operand); | 2386 | const extra = self.code.extraData(Zir.Inst.TypeOfPeer, extended.operand); |
| 2395 | const body = self.code.bodySlice(extra.data.body_index, extra.data.body_len); | 2387 | const body = self.code.bodySlice(extra.data.body_index, extra.data.body_len); |
| 2396 | try self.writeBracedBody(stream, body); | 2388 | try self.writeBracedBody(stream, body); |
| ... | @@ -2403,7 +2395,7 @@ const Writer = struct { | ... | @@ -2403,7 +2395,7 @@ const Writer = struct { |
| 2403 | try stream.writeAll("])"); | 2395 | try stream.writeAll("])"); |
| 2404 | } | 2396 | } |
| 2405 | | 2397 | |
| 2406 | fn writeBoolBr(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2398 | fn writeBoolBr(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2407 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 2399 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 2408 | const extra = self.code.extraData(Zir.Inst.BoolBr, inst_data.payload_index); | 2400 | const extra = self.code.extraData(Zir.Inst.BoolBr, inst_data.payload_index); |
| 2409 | const body = self.code.bodySlice(extra.end, extra.data.body_len); | 2401 | const body = self.code.bodySlice(extra.end, extra.data.body_len); |
| ... | @@ -2414,7 +2406,7 @@ const Writer = struct { | ... | @@ -2414,7 +2406,7 @@ const Writer = struct { |
| 2414 | try self.writeSrcNode(stream, inst_data.src_node); | 2406 | try self.writeSrcNode(stream, inst_data.src_node); |
| 2415 | } | 2407 | } |
| 2416 | | 2408 | |
| 2417 | fn writeIntType(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2409 | fn writeIntType(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2418 | const int_type = self.code.instructions.items(.data)[@intFromEnum(inst)].int_type; | 2410 | const int_type = self.code.instructions.items(.data)[@intFromEnum(inst)].int_type; |
| 2419 | const prefix: u8 = switch (int_type.signedness) { | 2411 | const prefix: u8 = switch (int_type.signedness) { |
| 2420 | .signed => 'i', | 2412 | .signed => 'i', |
| ... | @@ -2424,7 +2416,7 @@ const Writer = struct { | ... | @@ -2424,7 +2416,7 @@ const Writer = struct { |
| 2424 | try self.writeSrcNode(stream, int_type.src_node); | 2416 | try self.writeSrcNode(stream, int_type.src_node); |
| 2425 | } | 2417 | } |
| 2426 | | 2418 | |
| 2427 | fn writeSaveErrRetIndex(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2419 | fn writeSaveErrRetIndex(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2428 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].save_err_ret_index; | 2420 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].save_err_ret_index; |
| 2429 | | 2421 | |
| 2430 | try self.writeInstRef(stream, inst_data.operand); | 2422 | try self.writeInstRef(stream, inst_data.operand); |
| ... | @@ -2432,7 +2424,7 @@ const Writer = struct { | ... | @@ -2432,7 +2424,7 @@ const Writer = struct { |
| 2432 | try stream.writeAll(")"); | 2424 | try stream.writeAll(")"); |
| 2433 | } | 2425 | } |
| 2434 | | 2426 | |
| 2435 | fn writeRestoreErrRetIndex(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 2427 | fn writeRestoreErrRetIndex(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 2436 | const extra = self.code.extraData(Zir.Inst.RestoreErrRetIndex, extended.operand).data; | 2428 | const extra = self.code.extraData(Zir.Inst.RestoreErrRetIndex, extended.operand).data; |
| 2437 | | 2429 | |
| 2438 | try self.writeInstRef(stream, extra.block); | 2430 | try self.writeInstRef(stream, extra.block); |
| ... | @@ -2442,7 +2434,7 @@ const Writer = struct { | ... | @@ -2442,7 +2434,7 @@ const Writer = struct { |
| 2442 | try self.writeSrcNode(stream, extra.src_node); | 2434 | try self.writeSrcNode(stream, extra.src_node); |
| 2443 | } | 2435 | } |
| 2444 | | 2436 | |
| 2445 | fn writeBreak(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2437 | fn writeBreak(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2446 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].@"break"; | 2438 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].@"break"; |
| 2447 | const extra = self.code.extraData(Zir.Inst.Break, inst_data.payload_index).data; | 2439 | const extra = self.code.extraData(Zir.Inst.Break, inst_data.payload_index).data; |
| 2448 | | 2440 | |
| ... | @@ -2452,7 +2444,7 @@ const Writer = struct { | ... | @@ -2452,7 +2444,7 @@ const Writer = struct { |
| 2452 | try stream.writeAll(")"); | 2444 | try stream.writeAll(")"); |
| 2453 | } | 2445 | } |
| 2454 | | 2446 | |
| 2455 | fn writeArrayInit(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2447 | fn writeArrayInit(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2456 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 2448 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 2457 | | 2449 | |
| 2458 | const extra = self.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index); | 2450 | const extra = self.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index); |
| ... | @@ -2468,7 +2460,7 @@ const Writer = struct { | ... | @@ -2468,7 +2460,7 @@ const Writer = struct { |
| 2468 | try self.writeSrcNode(stream, inst_data.src_node); | 2460 | try self.writeSrcNode(stream, inst_data.src_node); |
| 2469 | } | 2461 | } |
| 2470 | | 2462 | |
| 2471 | fn writeArrayInitAnon(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2463 | fn writeArrayInitAnon(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2472 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 2464 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 2473 | | 2465 | |
| 2474 | const extra = self.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index); | 2466 | const extra = self.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index); |
| ... | @@ -2483,7 +2475,7 @@ const Writer = struct { | ... | @@ -2483,7 +2475,7 @@ const Writer = struct { |
| 2483 | try self.writeSrcNode(stream, inst_data.src_node); | 2475 | try self.writeSrcNode(stream, inst_data.src_node); |
| 2484 | } | 2476 | } |
| 2485 | | 2477 | |
| 2486 | fn writeArrayInitSent(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2478 | fn writeArrayInitSent(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2487 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 2479 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 2488 | | 2480 | |
| 2489 | const extra = self.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index); | 2481 | const extra = self.code.extraData(Zir.Inst.MultiOp, inst_data.payload_index); |
| ... | @@ -2503,7 +2495,7 @@ const Writer = struct { | ... | @@ -2503,7 +2495,7 @@ const Writer = struct { |
| 2503 | try self.writeSrcNode(stream, inst_data.src_node); | 2495 | try self.writeSrcNode(stream, inst_data.src_node); |
| 2504 | } | 2496 | } |
| 2505 | | 2497 | |
| 2506 | fn writeUnreachable(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2498 | fn writeUnreachable(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2507 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].@"unreachable"; | 2499 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].@"unreachable"; |
| 2508 | try stream.writeAll(") "); | 2500 | try stream.writeAll(") "); |
| 2509 | try self.writeSrcNode(stream, inst_data.src_node); | 2501 | try self.writeSrcNode(stream, inst_data.src_node); |
| ... | @@ -2511,7 +2503,7 @@ const Writer = struct { | ... | @@ -2511,7 +2503,7 @@ const Writer = struct { |
| 2511 | | 2503 | |
| 2512 | fn writeFuncCommon( | 2504 | fn writeFuncCommon( |
| 2513 | self: *Writer, | 2505 | self: *Writer, |
| 2514 | stream: anytype, | 2506 | stream: *std.io.Writer, |
| 2515 | inferred_error_set: bool, | 2507 | inferred_error_set: bool, |
| 2516 | var_args: bool, | 2508 | var_args: bool, |
| 2517 | is_noinline: bool, | 2509 | is_noinline: bool, |
| ... | @@ -2548,19 +2540,19 @@ const Writer = struct { | ... | @@ -2548,19 +2540,19 @@ const Writer = struct { |
| 2548 | try self.writeSrcNode(stream, src_node); | 2540 | try self.writeSrcNode(stream, src_node); |
| 2549 | } | 2541 | } |
| 2550 | | 2542 | |
| 2551 | fn writeDbgStmt(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2543 | fn writeDbgStmt(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2552 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].dbg_stmt; | 2544 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].dbg_stmt; |
| 2553 | try stream.print("{d}, {d})", .{ inst_data.line + 1, inst_data.column + 1 }); | 2545 | try stream.print("{d}, {d})", .{ inst_data.line + 1, inst_data.column + 1 }); |
| 2554 | } | 2546 | } |
| 2555 | | 2547 | |
| 2556 | fn writeDefer(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2548 | fn writeDefer(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2557 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].@"defer"; | 2549 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].@"defer"; |
| 2558 | const body = self.code.bodySlice(inst_data.index, inst_data.len); | 2550 | const body = self.code.bodySlice(inst_data.index, inst_data.len); |
| 2559 | try self.writeBracedBody(stream, body); | 2551 | try self.writeBracedBody(stream, body); |
| 2560 | try stream.writeByte(')'); | 2552 | try stream.writeByte(')'); |
| 2561 | } | 2553 | } |
| 2562 | | 2554 | |
| 2563 | fn writeDeferErrCode(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2555 | fn writeDeferErrCode(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2564 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].defer_err_code; | 2556 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].defer_err_code; |
| 2565 | const extra = self.code.extraData(Zir.Inst.DeferErrCode, inst_data.payload_index).data; | 2557 | const extra = self.code.extraData(Zir.Inst.DeferErrCode, inst_data.payload_index).data; |
| 2566 | | 2558 | |
| ... | @@ -2573,7 +2565,7 @@ const Writer = struct { | ... | @@ -2573,7 +2565,7 @@ const Writer = struct { |
| 2573 | try stream.writeByte(')'); | 2565 | try stream.writeByte(')'); |
| 2574 | } | 2566 | } |
| 2575 | | 2567 | |
| 2576 | fn writeDeclaration(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2568 | fn writeDeclaration(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2577 | const decl = self.code.getDeclaration(inst); | 2569 | const decl = self.code.getDeclaration(inst); |
| 2578 | | 2570 | |
| 2579 | const prev_parent_decl_node = self.parent_decl_node; | 2571 | const prev_parent_decl_node = self.parent_decl_node; |
| ... | @@ -2594,7 +2586,9 @@ const Writer = struct { | ... | @@ -2594,7 +2586,9 @@ const Writer = struct { |
| 2594 | }, | 2586 | }, |
| 2595 | } | 2587 | } |
| 2596 | const src_hash = self.code.getAssociatedSrcHash(inst).?; | 2588 | const src_hash = self.code.getAssociatedSrcHash(inst).?; |
| 2597 | try stream.print(" line({d}) column({d}) hash({x})", .{ decl.src_line, decl.src_column, &src_hash }); | 2589 | try stream.print(" line({d}) column({d}) hash({x})", .{ |
| | 2590 | decl.src_line, decl.src_column, &src_hash, |
| | 2591 | }); |
| 2598 | | 2592 | |
| 2599 | { | 2593 | { |
| 2600 | if (decl.type_body) |b| { | 2594 | if (decl.type_body) |b| { |
| ... | @@ -2627,26 +2621,26 @@ const Writer = struct { | ... | @@ -2627,26 +2621,26 @@ const Writer = struct { |
| 2627 | try self.writeSrcNode(stream, .zero); | 2621 | try self.writeSrcNode(stream, .zero); |
| 2628 | } | 2622 | } |
| 2629 | | 2623 | |
| 2630 | fn writeClosureGet(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 2624 | fn writeClosureGet(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 2631 | try stream.print("{d})) ", .{extended.small}); | 2625 | try stream.print("{d})) ", .{extended.small}); |
| 2632 | const src_node: Ast.Node.Offset = @enumFromInt(@as(i32, @bitCast(extended.operand))); | 2626 | const src_node: Ast.Node.Offset = @enumFromInt(@as(i32, @bitCast(extended.operand))); |
| 2633 | try self.writeSrcNode(stream, src_node); | 2627 | try self.writeSrcNode(stream, src_node); |
| 2634 | } | 2628 | } |
| 2635 | | 2629 | |
| 2636 | fn writeBuiltinValue(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 2630 | fn writeBuiltinValue(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 2637 | const val: Zir.Inst.BuiltinValue = @enumFromInt(extended.small); | 2631 | const val: Zir.Inst.BuiltinValue = @enumFromInt(extended.small); |
| 2638 | try stream.print("{s})) ", .{@tagName(val)}); | 2632 | try stream.print("{s})) ", .{@tagName(val)}); |
| 2639 | const src_node: Ast.Node.Offset = @enumFromInt(@as(i32, @bitCast(extended.operand))); | 2633 | const src_node: Ast.Node.Offset = @enumFromInt(@as(i32, @bitCast(extended.operand))); |
| 2640 | try self.writeSrcNode(stream, src_node); | 2634 | try self.writeSrcNode(stream, src_node); |
| 2641 | } | 2635 | } |
| 2642 | | 2636 | |
| 2643 | fn writeInplaceArithResultTy(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void { | 2637 | fn writeInplaceArithResultTy(self: *Writer, stream: *std.io.Writer, extended: Zir.Inst.Extended.InstData) !void { |
| 2644 | const op: Zir.Inst.InplaceOp = @enumFromInt(extended.small); | 2638 | const op: Zir.Inst.InplaceOp = @enumFromInt(extended.small); |
| 2645 | try self.writeInstRef(stream, @enumFromInt(extended.operand)); | 2639 | try self.writeInstRef(stream, @enumFromInt(extended.operand)); |
| 2646 | try stream.print(", {s}))", .{@tagName(op)}); | 2640 | try stream.print(", {s}))", .{@tagName(op)}); |
| 2647 | } | 2641 | } |
| 2648 | | 2642 | |
| 2649 | fn writeInstRef(self: *Writer, stream: anytype, ref: Zir.Inst.Ref) !void { | 2643 | fn writeInstRef(self: *Writer, stream: *std.io.Writer, ref: Zir.Inst.Ref) !void { |
| 2650 | if (ref == .none) { | 2644 | if (ref == .none) { |
| 2651 | return stream.writeAll(".none"); | 2645 | return stream.writeAll(".none"); |
| 2652 | } else if (ref.toIndex()) |i| { | 2646 | } else if (ref.toIndex()) |i| { |
| ... | @@ -2657,12 +2651,12 @@ const Writer = struct { | ... | @@ -2657,12 +2651,12 @@ const Writer = struct { |
| 2657 | } | 2651 | } |
| 2658 | } | 2652 | } |
| 2659 | | 2653 | |
| 2660 | fn writeInstIndex(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2654 | fn writeInstIndex(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2661 | _ = self; | 2655 | _ = self; |
| 2662 | return stream.print("%{d}", .{@intFromEnum(inst)}); | 2656 | return stream.print("%{d}", .{@intFromEnum(inst)}); |
| 2663 | } | 2657 | } |
| 2664 | | 2658 | |
| 2665 | fn writeCaptures(self: *Writer, stream: anytype, extra_index: usize, captures_len: u32) !usize { | 2659 | fn writeCaptures(self: *Writer, stream: *std.io.Writer, extra_index: usize, captures_len: u32) !usize { |
| 2666 | if (captures_len == 0) { | 2660 | if (captures_len == 0) { |
| 2667 | try stream.writeAll("{}"); | 2661 | try stream.writeAll("{}"); |
| 2668 | return extra_index; | 2662 | return extra_index; |
| ... | @@ -2682,7 +2676,7 @@ const Writer = struct { | ... | @@ -2682,7 +2676,7 @@ const Writer = struct { |
| 2682 | return extra_index + 2 * captures_len; | 2676 | return extra_index + 2 * captures_len; |
| 2683 | } | 2677 | } |
| 2684 | | 2678 | |
| 2685 | fn writeCapture(self: *Writer, stream: anytype, capture: Zir.Inst.Capture) !void { | 2679 | fn writeCapture(self: *Writer, stream: *std.io.Writer, capture: Zir.Inst.Capture) !void { |
| 2686 | switch (capture.unwrap()) { | 2680 | switch (capture.unwrap()) { |
| 2687 | .nested => |i| return stream.print("[{d}]", .{i}), | 2681 | .nested => |i| return stream.print("[{d}]", .{i}), |
| 2688 | .instruction => |inst| return self.writeInstIndex(stream, inst), | 2682 | .instruction => |inst| return self.writeInstIndex(stream, inst), |
| ... | @@ -2701,7 +2695,7 @@ const Writer = struct { | ... | @@ -2701,7 +2695,7 @@ const Writer = struct { |
| 2701 | | 2695 | |
| 2702 | fn writeOptionalInstRef( | 2696 | fn writeOptionalInstRef( |
| 2703 | self: *Writer, | 2697 | self: *Writer, |
| 2704 | stream: anytype, | 2698 | stream: *std.io.Writer, |
| 2705 | prefix: []const u8, | 2699 | prefix: []const u8, |
| 2706 | inst: Zir.Inst.Ref, | 2700 | inst: Zir.Inst.Ref, |
| 2707 | ) !void { | 2701 | ) !void { |
| ... | @@ -2712,7 +2706,7 @@ const Writer = struct { | ... | @@ -2712,7 +2706,7 @@ const Writer = struct { |
| 2712 | | 2706 | |
| 2713 | fn writeOptionalInstRefOrBody( | 2707 | fn writeOptionalInstRefOrBody( |
| 2714 | self: *Writer, | 2708 | self: *Writer, |
| 2715 | stream: anytype, | 2709 | stream: *std.io.Writer, |
| 2716 | prefix: []const u8, | 2710 | prefix: []const u8, |
| 2717 | ref: Zir.Inst.Ref, | 2711 | ref: Zir.Inst.Ref, |
| 2718 | body: []const Zir.Inst.Index, | 2712 | body: []const Zir.Inst.Index, |
| ... | @@ -2730,7 +2724,7 @@ const Writer = struct { | ... | @@ -2730,7 +2724,7 @@ const Writer = struct { |
| 2730 | | 2724 | |
| 2731 | fn writeFlag( | 2725 | fn writeFlag( |
| 2732 | self: *Writer, | 2726 | self: *Writer, |
| 2733 | stream: anytype, | 2727 | stream: *std.io.Writer, |
| 2734 | name: []const u8, | 2728 | name: []const u8, |
| 2735 | flag: bool, | 2729 | flag: bool, |
| 2736 | ) !void { | 2730 | ) !void { |
| ... | @@ -2739,7 +2733,7 @@ const Writer = struct { | ... | @@ -2739,7 +2733,7 @@ const Writer = struct { |
| 2739 | try stream.writeAll(name); | 2733 | try stream.writeAll(name); |
| 2740 | } | 2734 | } |
| 2741 | | 2735 | |
| 2742 | fn writeSrcNode(self: *Writer, stream: anytype, src_node: Ast.Node.Offset) !void { | 2736 | fn writeSrcNode(self: *Writer, stream: *std.io.Writer, src_node: Ast.Node.Offset) !void { |
| 2743 | const tree = self.tree orelse return; | 2737 | const tree = self.tree orelse return; |
| 2744 | const abs_node = src_node.toAbsolute(self.parent_decl_node); | 2738 | const abs_node = src_node.toAbsolute(self.parent_decl_node); |
| 2745 | const src_span = tree.nodeToSpan(abs_node); | 2739 | const src_span = tree.nodeToSpan(abs_node); |
| ... | @@ -2751,7 +2745,7 @@ const Writer = struct { | ... | @@ -2751,7 +2745,7 @@ const Writer = struct { |
| 2751 | }); | 2745 | }); |
| 2752 | } | 2746 | } |
| 2753 | | 2747 | |
| 2754 | fn writeSrcTok(self: *Writer, stream: anytype, src_tok: Ast.TokenOffset) !void { | 2748 | fn writeSrcTok(self: *Writer, stream: *std.io.Writer, src_tok: Ast.TokenOffset) !void { |
| 2755 | const tree = self.tree orelse return; | 2749 | const tree = self.tree orelse return; |
| 2756 | const abs_tok = src_tok.toAbsolute(tree.firstToken(self.parent_decl_node)); | 2750 | const abs_tok = src_tok.toAbsolute(tree.firstToken(self.parent_decl_node)); |
| 2757 | const span_start = tree.tokenStart(abs_tok); | 2751 | const span_start = tree.tokenStart(abs_tok); |
| ... | @@ -2764,7 +2758,7 @@ const Writer = struct { | ... | @@ -2764,7 +2758,7 @@ const Writer = struct { |
| 2764 | }); | 2758 | }); |
| 2765 | } | 2759 | } |
| 2766 | | 2760 | |
| 2767 | fn writeSrcTokAbs(self: *Writer, stream: anytype, src_tok: Ast.TokenIndex) !void { | 2761 | fn writeSrcTokAbs(self: *Writer, stream: *std.io.Writer, src_tok: Ast.TokenIndex) !void { |
| 2768 | const tree = self.tree orelse return; | 2762 | const tree = self.tree orelse return; |
| 2769 | const span_start = tree.tokenStart(src_tok); | 2763 | const span_start = tree.tokenStart(src_tok); |
| 2770 | const span_end = span_start + @as(u32, @intCast(tree.tokenSlice(src_tok).len)); | 2764 | const span_end = span_start + @as(u32, @intCast(tree.tokenSlice(src_tok).len)); |
| ... | @@ -2776,15 +2770,15 @@ const Writer = struct { | ... | @@ -2776,15 +2770,15 @@ const Writer = struct { |
| 2776 | }); | 2770 | }); |
| 2777 | } | 2771 | } |
| 2778 | | 2772 | |
| 2779 | fn writeBracedDecl(self: *Writer, stream: anytype, body: []const Zir.Inst.Index) !void { | 2773 | fn writeBracedDecl(self: *Writer, stream: *std.io.Writer, body: []const Zir.Inst.Index) !void { |
| 2780 | try self.writeBracedBodyConditional(stream, body, self.recurse_decls); | 2774 | try self.writeBracedBodyConditional(stream, body, self.recurse_decls); |
| 2781 | } | 2775 | } |
| 2782 | | 2776 | |
| 2783 | fn writeBracedBody(self: *Writer, stream: anytype, body: []const Zir.Inst.Index) !void { | 2777 | fn writeBracedBody(self: *Writer, stream: *std.io.Writer, body: []const Zir.Inst.Index) !void { |
| 2784 | try self.writeBracedBodyConditional(stream, body, self.recurse_blocks); | 2778 | try self.writeBracedBodyConditional(stream, body, self.recurse_blocks); |
| 2785 | } | 2779 | } |
| 2786 | | 2780 | |
| 2787 | fn writeBracedBodyConditional(self: *Writer, stream: anytype, body: []const Zir.Inst.Index, enabled: bool) !void { | 2781 | fn writeBracedBodyConditional(self: *Writer, stream: *std.io.Writer, body: []const Zir.Inst.Index, enabled: bool) !void { |
| 2788 | if (body.len == 0) { | 2782 | if (body.len == 0) { |
| 2789 | try stream.writeAll("{}"); | 2783 | try stream.writeAll("{}"); |
| 2790 | } else if (enabled) { | 2784 | } else if (enabled) { |
| ... | @@ -2792,7 +2786,7 @@ const Writer = struct { | ... | @@ -2792,7 +2786,7 @@ const Writer = struct { |
| 2792 | self.indent += 2; | 2786 | self.indent += 2; |
| 2793 | try self.writeBody(stream, body); | 2787 | try self.writeBody(stream, body); |
| 2794 | self.indent -= 2; | 2788 | self.indent -= 2; |
| 2795 | try stream.writeByteNTimes(' ', self.indent); | 2789 | try stream.splatByteAll(' ', self.indent); |
| 2796 | try stream.writeAll("}"); | 2790 | try stream.writeAll("}"); |
| 2797 | } else if (body.len == 1) { | 2791 | } else if (body.len == 1) { |
| 2798 | try stream.writeByte('{'); | 2792 | try stream.writeByte('{'); |
| ... | @@ -2813,16 +2807,16 @@ const Writer = struct { | ... | @@ -2813,16 +2807,16 @@ const Writer = struct { |
| 2813 | } | 2807 | } |
| 2814 | } | 2808 | } |
| 2815 | | 2809 | |
| 2816 | fn writeBody(self: *Writer, stream: anytype, body: []const Zir.Inst.Index) !void { | 2810 | fn writeBody(self: *Writer, stream: *std.io.Writer, body: []const Zir.Inst.Index) !void { |
| 2817 | for (body) |inst| { | 2811 | for (body) |inst| { |
| 2818 | try stream.writeByteNTimes(' ', self.indent); | 2812 | try stream.splatByteAll(' ', self.indent); |
| 2819 | try stream.print("%{d} ", .{@intFromEnum(inst)}); | 2813 | try stream.print("%{d} ", .{@intFromEnum(inst)}); |
| 2820 | try self.writeInstToStream(stream, inst); | 2814 | try self.writeInstToStream(stream, inst); |
| 2821 | try stream.writeByte('\n'); | 2815 | try stream.writeByte('\n'); |
| 2822 | } | 2816 | } |
| 2823 | } | 2817 | } |
| 2824 | | 2818 | |
| 2825 | fn writeImport(self: *Writer, stream: anytype, inst: Zir.Inst.Index) !void { | 2819 | fn writeImport(self: *Writer, stream: *std.io.Writer, inst: Zir.Inst.Index) !void { |
| 2826 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_tok; | 2820 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_tok; |
| 2827 | const extra = self.code.extraData(Zir.Inst.Import, inst_data.payload_index).data; | 2821 | const extra = self.code.extraData(Zir.Inst.Import, inst_data.payload_index).data; |
| 2828 | try self.writeInstRef(stream, extra.res_ty); | 2822 | try self.writeInstRef(stream, extra.res_ty); |