| author | |
| committer | |
| log | 3b390e4f139220ed11918524288238c289ce0c6d |
| tree | 54ba9c72bdba89fa0286cdc99c7afe9e60bbb30a |
| parent | a4fdda6ae04ffc72234d2c6baf22e13d9a5a99a3 |
71 files changed, 430 insertions(+), 438 deletions(-)
lib/std/zig/string_literal.zig+2-2| ... | @@ -44,7 +44,7 @@ pub const Error = union(enum) { | ... | @@ -44,7 +44,7 @@ pub const Error = union(enum) { |
| 44 | raw_string: []const u8, | 44 | raw_string: []const u8, |
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| 47 | fn formatMessage(self: FormatMessage, bw: *std.io.BufferedWriter, comptime f: []const u8) anyerror!void { | 47 | fn formatMessage(self: FormatMessage, bw: *std.io.BufferedWriter, comptime f: []const u8) !void { |
| 48 | _ = f; | 48 | _ = f; |
| 49 | switch (self.err) { | 49 | switch (self.err) { |
| 50 | .invalid_escape_character => |bad_index| try bw.print( | 50 | .invalid_escape_character => |bad_index| try bw.print( |
| ... | @@ -318,7 +318,7 @@ test parseCharLiteral { | ... | @@ -318,7 +318,7 @@ test parseCharLiteral { |
| 318 | 318 | ||
| 319 | /// Parses `bytes` as a Zig string literal and writes the result to the `std.io.Writer` type. | 319 | /// Parses `bytes` as a Zig string literal and writes the result to the `std.io.Writer` type. |
| 320 | /// Asserts `bytes` has '"' at beginning and end. | 320 | /// Asserts `bytes` has '"' at beginning and end. |
| 321 | pub fn parseWrite(writer: *std.io.BufferedWriter, bytes: []const u8) anyerror!Result { | 321 | pub fn parseWrite(writer: *std.io.BufferedWriter, bytes: []const u8) std.io.Writer.Error!Result { |
| 322 | assert(bytes.len >= 2 and bytes[0] == '"' and bytes[bytes.len - 1] == '"'); | 322 | assert(bytes.len >= 2 and bytes[0] == '"' and bytes[bytes.len - 1] == '"'); |
| 323 | 323 | ||
| 324 | var index: usize = 1; | 324 | var index: usize = 1; |
lib/std/zon/stringify.zig+46-44| ... | @@ -40,7 +40,7 @@ pub const SerializeOptions = struct { | ... | @@ -40,7 +40,7 @@ pub const SerializeOptions = struct { |
| 40 | /// Serialize the given value as ZON. | 40 | /// Serialize the given value as ZON. |
| 41 | /// | 41 | /// |
| 42 | /// It is asserted at comptime that `@TypeOf(val)` is not a recursive type. | 42 | /// It is asserted at comptime that `@TypeOf(val)` is not a recursive type. |
| 43 | pub fn serialize(val: anytype, options: SerializeOptions, writer: *std.io.BufferedWriter) anyerror!void { | 43 | pub fn serialize(val: anytype, options: SerializeOptions, writer: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 44 | var s: Serializer = .{ | 44 | var s: Serializer = .{ |
| 45 | .writer = writer, | 45 | .writer = writer, |
| 46 | .options = .{ .whitespace = options.whitespace }, | 46 | .options = .{ .whitespace = options.whitespace }, |
| ... | @@ -61,7 +61,7 @@ pub fn serializeMaxDepth( | ... | @@ -61,7 +61,7 @@ pub fn serializeMaxDepth( |
| 61 | options: SerializeOptions, | 61 | options: SerializeOptions, |
| 62 | writer: *std.io.BufferedWriter, | 62 | writer: *std.io.BufferedWriter, |
| 63 | depth: usize, | 63 | depth: usize, |
| 64 | ) anyerror!void { | 64 | ) std.io.Writer.Error!void { |
| 65 | var s: Serializer = .{ | 65 | var s: Serializer = .{ |
| 66 | .writer = writer, | 66 | .writer = writer, |
| 67 | .options = .{ .whitespace = options.whitespace }, | 67 | .options = .{ .whitespace = options.whitespace }, |
| ... | @@ -80,7 +80,7 @@ pub fn serializeArbitraryDepth( | ... | @@ -80,7 +80,7 @@ pub fn serializeArbitraryDepth( |
| 80 | val: anytype, | 80 | val: anytype, |
| 81 | options: SerializeOptions, | 81 | options: SerializeOptions, |
| 82 | writer: *std.io.BufferedWriter, | 82 | writer: *std.io.BufferedWriter, |
| 83 | ) anyerror!void { | 83 | ) std.io.Writer.Error!void { |
| 84 | var s: Serializer = .{ | 84 | var s: Serializer = .{ |
| 85 | .writer = writer, | 85 | .writer = writer, |
| 86 | .options = .{ .whitespace = options.whitespace }, | 86 | .options = .{ .whitespace = options.whitespace }, |
| ... | @@ -438,26 +438,28 @@ pub const Serializer = struct { | ... | @@ -438,26 +438,28 @@ pub const Serializer = struct { |
| 438 | indent_level: u8 = 0, | 438 | indent_level: u8 = 0, |
| 439 | writer: *std.io.BufferedWriter, | 439 | writer: *std.io.BufferedWriter, |
| 440 | 440 | ||
| 441 | pub const Error = std.io.Writer.Error; | ||
| 442 | |||
| 441 | pub const Options = struct { | 443 | pub const Options = struct { |
| 442 | /// If false, only syntactically necessary whitespace is emitted. | 444 | /// If false, only syntactically necessary whitespace is emitted. |
| 443 | whitespace: bool = true, | 445 | whitespace: bool = true, |
| 444 | }; | 446 | }; |
| 445 | 447 | ||
| 446 | /// Serialize a value, similar to `serialize`. | 448 | /// Serialize a value, similar to `serialize`. |
| 447 | pub fn value(self: *Serializer, val: anytype, options: ValueOptions) anyerror!void { | 449 | pub fn value(self: *Serializer, val: anytype, options: ValueOptions) Error!void { |
| 448 | comptime assert(!typeIsRecursive(@TypeOf(val))); | 450 | comptime assert(!typeIsRecursive(@TypeOf(val))); |
| 449 | return self.valueArbitraryDepth(val, options); | 451 | return self.valueArbitraryDepth(val, options); |
| 450 | } | 452 | } |
| 451 | 453 | ||
| 452 | /// Serialize a value, similar to `serializeMaxDepth`. | 454 | /// Serialize a value, similar to `serializeMaxDepth`. |
| 453 | /// Can return `error.ExceededMaxDepth`. | 455 | /// Can return `error.ExceededMaxDepth`. |
| 454 | pub fn valueMaxDepth(self: *Serializer, val: anytype, options: ValueOptions, depth: usize) anyerror!void { | 456 | pub fn valueMaxDepth(self: *Serializer, val: anytype, options: ValueOptions, depth: usize) Error!void { |
| 455 | try checkValueDepth(val, depth); | 457 | try checkValueDepth(val, depth); |
| 456 | return self.valueArbitraryDepth(val, options); | 458 | return self.valueArbitraryDepth(val, options); |
| 457 | } | 459 | } |
| 458 | 460 | ||
| 459 | /// Serialize a value, similar to `serializeArbitraryDepth`. | 461 | /// Serialize a value, similar to `serializeArbitraryDepth`. |
| 460 | pub fn valueArbitraryDepth(self: *Serializer, val: anytype, options: ValueOptions) anyerror!void { | 462 | pub fn valueArbitraryDepth(self: *Serializer, val: anytype, options: ValueOptions) Error!void { |
| 461 | comptime assert(canSerializeType(@TypeOf(val))); | 463 | comptime assert(canSerializeType(@TypeOf(val))); |
| 462 | switch (@typeInfo(@TypeOf(val))) { | 464 | switch (@typeInfo(@TypeOf(val))) { |
| 463 | .int, .comptime_int => if (options.emit_codepoint_literals.emitAsCodepoint(val)) |c| { | 465 | .int, .comptime_int => if (options.emit_codepoint_literals.emitAsCodepoint(val)) |c| { |
| ... | @@ -582,12 +584,12 @@ pub const Serializer = struct { | ... | @@ -582,12 +584,12 @@ pub const Serializer = struct { |
| 582 | } | 584 | } |
| 583 | 585 | ||
| 584 | /// Serialize an integer. | 586 | /// Serialize an integer. |
| 585 | pub fn int(self: *Serializer, val: anytype) anyerror!void { | 587 | pub fn int(self: *Serializer, val: anytype) Error!void { |
| 586 | try self.writer.printIntOptions(val, 10, .lower, .{}); | 588 | try self.writer.printIntOptions(val, 10, .lower, .{}); |
| 587 | } | 589 | } |
| 588 | 590 | ||
| 589 | /// Serialize a float. | 591 | /// Serialize a float. |
| 590 | pub fn float(self: *Serializer, val: anytype) anyerror!void { | 592 | pub fn float(self: *Serializer, val: anytype) Error!void { |
| 591 | switch (@typeInfo(@TypeOf(val))) { | 593 | switch (@typeInfo(@TypeOf(val))) { |
| 592 | .float => if (std.math.isNan(val)) { | 594 | .float => if (std.math.isNan(val)) { |
| 593 | return self.writer.writeAll("nan"); | 595 | return self.writer.writeAll("nan"); |
| ... | @@ -612,7 +614,7 @@ pub const Serializer = struct { | ... | @@ -612,7 +614,7 @@ pub const Serializer = struct { |
| 612 | /// Serialize `name` as an identifier prefixed with `.`. | 614 | /// Serialize `name` as an identifier prefixed with `.`. |
| 613 | /// | 615 | /// |
| 614 | /// Escapes the identifier if necessary. | 616 | /// Escapes the identifier if necessary. |
| 615 | pub fn ident(self: *Serializer, name: []const u8) anyerror!void { | 617 | pub fn ident(self: *Serializer, name: []const u8) Error!void { |
| 616 | try self.writer.print(".{fp_}", .{std.zig.fmtId(name)}); | 618 | try self.writer.print(".{fp_}", .{std.zig.fmtId(name)}); |
| 617 | } | 619 | } |
| 618 | 620 | ||
| ... | @@ -622,7 +624,7 @@ pub const Serializer = struct { | ... | @@ -622,7 +624,7 @@ pub const Serializer = struct { |
| 622 | pub fn codePoint( | 624 | pub fn codePoint( |
| 623 | self: *Serializer, | 625 | self: *Serializer, |
| 624 | val: u21, | 626 | val: u21, |
| 625 | ) anyerror!void { | 627 | ) Error!void { |
| 626 | var buf: [8]u8 = undefined; | 628 | var buf: [8]u8 = undefined; |
| 627 | const len = std.unicode.utf8Encode(val, &buf) catch return error.InvalidCodepoint; | 629 | const len = std.unicode.utf8Encode(val, &buf) catch return error.InvalidCodepoint; |
| 628 | const str = buf[0..len]; | 630 | const str = buf[0..len]; |
| ... | @@ -632,7 +634,7 @@ pub const Serializer = struct { | ... | @@ -632,7 +634,7 @@ pub const Serializer = struct { |
| 632 | /// Like `value`, but always serializes `val` as a tuple. | 634 | /// Like `value`, but always serializes `val` as a tuple. |
| 633 | /// | 635 | /// |
| 634 | /// Will fail at comptime if `val` is not a tuple, array, pointer to an array, or slice. | 636 | /// Will fail at comptime if `val` is not a tuple, array, pointer to an array, or slice. |
| 635 | pub fn tuple(self: *Serializer, val: anytype, options: ValueOptions) anyerror!void { | 637 | pub fn tuple(self: *Serializer, val: anytype, options: ValueOptions) Error!void { |
| 636 | comptime assert(!typeIsRecursive(@TypeOf(val))); | 638 | comptime assert(!typeIsRecursive(@TypeOf(val))); |
| 637 | try self.tupleArbitraryDepth(val, options); | 639 | try self.tupleArbitraryDepth(val, options); |
| 638 | } | 640 | } |
| ... | @@ -645,7 +647,7 @@ pub const Serializer = struct { | ... | @@ -645,7 +647,7 @@ pub const Serializer = struct { |
| 645 | val: anytype, | 647 | val: anytype, |
| 646 | options: ValueOptions, | 648 | options: ValueOptions, |
| 647 | depth: usize, | 649 | depth: usize, |
| 648 | ) anyerror!void { | 650 | ) Error!void { |
| 649 | try checkValueDepth(val, depth); | 651 | try checkValueDepth(val, depth); |
| 650 | try self.tupleArbitraryDepth(val, options); | 652 | try self.tupleArbitraryDepth(val, options); |
| 651 | } | 653 | } |
| ... | @@ -657,11 +659,11 @@ pub const Serializer = struct { | ... | @@ -657,11 +659,11 @@ pub const Serializer = struct { |
| 657 | self: *Serializer, | 659 | self: *Serializer, |
| 658 | val: anytype, | 660 | val: anytype, |
| 659 | options: ValueOptions, | 661 | options: ValueOptions, |
| 660 | ) anyerror!void { | 662 | ) Error!void { |
| 661 | try self.tupleImpl(val, options); | 663 | try self.tupleImpl(val, options); |
| 662 | } | 664 | } |
| 663 | 665 | ||
| 664 | fn tupleImpl(self: *Serializer, val: anytype, options: ValueOptions) anyerror!void { | 666 | fn tupleImpl(self: *Serializer, val: anytype, options: ValueOptions) Error!void { |
| 665 | comptime assert(canSerializeType(@TypeOf(val))); | 667 | comptime assert(canSerializeType(@TypeOf(val))); |
| 666 | switch (@typeInfo(@TypeOf(val))) { | 668 | switch (@typeInfo(@TypeOf(val))) { |
| 667 | .@"struct" => { | 669 | .@"struct" => { |
| ... | @@ -683,7 +685,7 @@ pub const Serializer = struct { | ... | @@ -683,7 +685,7 @@ pub const Serializer = struct { |
| 683 | } | 685 | } |
| 684 | 686 | ||
| 685 | /// Like `value`, but always serializes `val` as a string. | 687 | /// Like `value`, but always serializes `val` as a string. |
| 686 | pub fn string(self: *Serializer, val: []const u8) anyerror!void { | 688 | pub fn string(self: *Serializer, val: []const u8) Error!void { |
| 687 | try std.fmt.format(self.writer, "\"{f}\"", .{std.zig.fmtEscapes(val)}); | 689 | try std.fmt.format(self.writer, "\"{f}\"", .{std.zig.fmtEscapes(val)}); |
| 688 | } | 690 | } |
| 689 | 691 | ||
| ... | @@ -703,7 +705,7 @@ pub const Serializer = struct { | ... | @@ -703,7 +705,7 @@ pub const Serializer = struct { |
| 703 | self: *Serializer, | 705 | self: *Serializer, |
| 704 | val: []const u8, | 706 | val: []const u8, |
| 705 | options: MultilineStringOptions, | 707 | options: MultilineStringOptions, |
| 706 | ) anyerror!void { | 708 | ) Error!void { |
| 707 | // Make sure the string does not contain any carriage returns not followed by a newline | 709 | // Make sure the string does not contain any carriage returns not followed by a newline |
| 708 | var i: usize = 0; | 710 | var i: usize = 0; |
| 709 | while (i < val.len) : (i += 1) { | 711 | while (i < val.len) : (i += 1) { |
| ... | @@ -744,7 +746,7 @@ pub const Serializer = struct { | ... | @@ -744,7 +746,7 @@ pub const Serializer = struct { |
| 744 | pub fn beginStruct( | 746 | pub fn beginStruct( |
| 745 | self: *Serializer, | 747 | self: *Serializer, |
| 746 | options: SerializeContainerOptions, | 748 | options: SerializeContainerOptions, |
| 747 | ) anyerror!Struct { | 749 | ) Error!Struct { |
| 748 | return Struct.begin(self, options); | 750 | return Struct.begin(self, options); |
| 749 | } | 751 | } |
| 750 | 752 | ||
| ... | @@ -752,23 +754,23 @@ pub const Serializer = struct { | ... | @@ -752,23 +754,23 @@ pub const Serializer = struct { |
| 752 | pub fn beginTuple( | 754 | pub fn beginTuple( |
| 753 | self: *Serializer, | 755 | self: *Serializer, |
| 754 | options: SerializeContainerOptions, | 756 | options: SerializeContainerOptions, |
| 755 | ) anyerror!Tuple { | 757 | ) Error!Tuple { |
| 756 | return Tuple.begin(self, options); | 758 | return Tuple.begin(self, options); |
| 757 | } | 759 | } |
| 758 | 760 | ||
| 759 | fn indent(self: *Serializer) anyerror!void { | 761 | fn indent(self: *Serializer) Error!void { |
| 760 | if (self.options.whitespace) { | 762 | if (self.options.whitespace) { |
| 761 | try self.writer.splatByteAll(' ', 4 * self.indent_level); | 763 | try self.writer.splatByteAll(' ', 4 * self.indent_level); |
| 762 | } | 764 | } |
| 763 | } | 765 | } |
| 764 | 766 | ||
| 765 | fn newline(self: *Serializer) anyerror!void { | 767 | fn newline(self: *Serializer) Error!void { |
| 766 | if (self.options.whitespace) { | 768 | if (self.options.whitespace) { |
| 767 | try self.writer.writeByte('\n'); | 769 | try self.writer.writeByte('\n'); |
| 768 | } | 770 | } |
| 769 | } | 771 | } |
| 770 | 772 | ||
| 771 | fn newlineOrSpace(self: *Serializer, len: usize) anyerror!void { | 773 | fn newlineOrSpace(self: *Serializer, len: usize) Error!void { |
| 772 | if (self.containerShouldWrap(len)) { | 774 | if (self.containerShouldWrap(len)) { |
| 773 | try self.newline(); | 775 | try self.newline(); |
| 774 | } else { | 776 | } else { |
| ... | @@ -776,7 +778,7 @@ pub const Serializer = struct { | ... | @@ -776,7 +778,7 @@ pub const Serializer = struct { |
| 776 | } | 778 | } |
| 777 | } | 779 | } |
| 778 | 780 | ||
| 779 | fn space(self: *Serializer) anyerror!void { | 781 | fn space(self: *Serializer) Error!void { |
| 780 | if (self.options.whitespace) { | 782 | if (self.options.whitespace) { |
| 781 | try self.writer.writeByte(' '); | 783 | try self.writer.writeByte(' '); |
| 782 | } | 784 | } |
| ... | @@ -786,7 +788,7 @@ pub const Serializer = struct { | ... | @@ -786,7 +788,7 @@ pub const Serializer = struct { |
| 786 | pub const Tuple = struct { | 788 | pub const Tuple = struct { |
| 787 | container: Container, | 789 | container: Container, |
| 788 | 790 | ||
| 789 | fn begin(parent: *Serializer, options: SerializeContainerOptions) anyerror!Tuple { | 791 | fn begin(parent: *Serializer, options: SerializeContainerOptions) Error!Tuple { |
| 790 | return .{ | 792 | return .{ |
| 791 | .container = try Container.begin(parent, .anon, options), | 793 | .container = try Container.begin(parent, .anon, options), |
| 792 | }; | 794 | }; |
| ... | @@ -795,7 +797,7 @@ pub const Serializer = struct { | ... | @@ -795,7 +797,7 @@ pub const Serializer = struct { |
| 795 | /// Finishes serializing the tuple. | 797 | /// Finishes serializing the tuple. |
| 796 | /// | 798 | /// |
| 797 | /// Prints a trailing comma as configured when appropriate, and the closing bracket. | 799 | /// Prints a trailing comma as configured when appropriate, and the closing bracket. |
| 798 | pub fn end(self: *Tuple) anyerror!void { | 800 | pub fn end(self: *Tuple) Error!void { |
| 799 | try self.container.end(); | 801 | try self.container.end(); |
| 800 | self.* = undefined; | 802 | self.* = undefined; |
| 801 | } | 803 | } |
| ... | @@ -805,7 +807,7 @@ pub const Serializer = struct { | ... | @@ -805,7 +807,7 @@ pub const Serializer = struct { |
| 805 | self: *Tuple, | 807 | self: *Tuple, |
| 806 | val: anytype, | 808 | val: anytype, |
| 807 | options: ValueOptions, | 809 | options: ValueOptions, |
| 808 | ) anyerror!void { | 810 | ) Error!void { |
| 809 | try self.container.field(null, val, options); | 811 | try self.container.field(null, val, options); |
| 810 | } | 812 | } |
| 811 | 813 | ||
| ... | @@ -816,7 +818,7 @@ pub const Serializer = struct { | ... | @@ -816,7 +818,7 @@ pub const Serializer = struct { |
| 816 | val: anytype, | 818 | val: anytype, |
| 817 | options: ValueOptions, | 819 | options: ValueOptions, |
| 818 | depth: usize, | 820 | depth: usize, |
| 819 | ) anyerror!void { | 821 | ) Error!void { |
| 820 | try self.container.fieldMaxDepth(null, val, options, depth); | 822 | try self.container.fieldMaxDepth(null, val, options, depth); |
| 821 | } | 823 | } |
| 822 | 824 | ||
| ... | @@ -826,7 +828,7 @@ pub const Serializer = struct { | ... | @@ -826,7 +828,7 @@ pub const Serializer = struct { |
| 826 | self: *Tuple, | 828 | self: *Tuple, |
| 827 | val: anytype, | 829 | val: anytype, |
| 828 | options: ValueOptions, | 830 | options: ValueOptions, |
| 829 | ) anyerror!void { | 831 | ) Error!void { |
| 830 | try self.container.fieldArbitraryDepth(null, val, options); | 832 | try self.container.fieldArbitraryDepth(null, val, options); |
| 831 | } | 833 | } |
| 832 | 834 | ||
| ... | @@ -834,7 +836,7 @@ pub const Serializer = struct { | ... | @@ -834,7 +836,7 @@ pub const Serializer = struct { |
| 834 | pub fn beginStructField( | 836 | pub fn beginStructField( |
| 835 | self: *Tuple, | 837 | self: *Tuple, |
| 836 | options: SerializeContainerOptions, | 838 | options: SerializeContainerOptions, |
| 837 | ) anyerror!Struct { | 839 | ) Error!Struct { |
| 838 | try self.fieldPrefix(); | 840 | try self.fieldPrefix(); |
| 839 | return self.container.serializer.beginStruct(options); | 841 | return self.container.serializer.beginStruct(options); |
| 840 | } | 842 | } |
| ... | @@ -843,14 +845,14 @@ pub const Serializer = struct { | ... | @@ -843,14 +845,14 @@ pub const Serializer = struct { |
| 843 | pub fn beginTupleField( | 845 | pub fn beginTupleField( |
| 844 | self: *Tuple, | 846 | self: *Tuple, |
| 845 | options: SerializeContainerOptions, | 847 | options: SerializeContainerOptions, |
| 846 | ) anyerror!Tuple { | 848 | ) Error!Tuple { |
| 847 | try self.fieldPrefix(); | 849 | try self.fieldPrefix(); |
| 848 | return self.container.serializer.beginTuple(options); | 850 | return self.container.serializer.beginTuple(options); |
| 849 | } | 851 | } |
| 850 | 852 | ||
| 851 | /// Print a field prefix. This prints any necessary commas, and whitespace as | 853 | /// Print a field prefix. This prints any necessary commas, and whitespace as |
| 852 | /// configured. Useful if you want to serialize the field value yourself. | 854 | /// configured. Useful if you want to serialize the field value yourself. |
| 853 | pub fn fieldPrefix(self: *Tuple) anyerror!void { | 855 | pub fn fieldPrefix(self: *Tuple) Error!void { |
| 854 | try self.container.fieldPrefix(null); | 856 | try self.container.fieldPrefix(null); |
| 855 | } | 857 | } |
| 856 | }; | 858 | }; |
| ... | @@ -859,7 +861,7 @@ pub const Serializer = struct { | ... | @@ -859,7 +861,7 @@ pub const Serializer = struct { |
| 859 | pub const Struct = struct { | 861 | pub const Struct = struct { |
| 860 | container: Container, | 862 | container: Container, |
| 861 | 863 | ||
| 862 | fn begin(parent: *Serializer, options: SerializeContainerOptions) anyerror!Struct { | 864 | fn begin(parent: *Serializer, options: SerializeContainerOptions) Error!Struct { |
| 863 | return .{ | 865 | return .{ |
| 864 | .container = try Container.begin(parent, .named, options), | 866 | .container = try Container.begin(parent, .named, options), |
| 865 | }; | 867 | }; |
| ... | @@ -868,7 +870,7 @@ pub const Serializer = struct { | ... | @@ -868,7 +870,7 @@ pub const Serializer = struct { |
| 868 | /// Finishes serializing the struct. | 870 | /// Finishes serializing the struct. |
| 869 | /// | 871 | /// |
| 870 | /// Prints a trailing comma as configured when appropriate, and the closing bracket. | 872 | /// Prints a trailing comma as configured when appropriate, and the closing bracket. |
| 871 | pub fn end(self: *Struct) anyerror!void { | 873 | pub fn end(self: *Struct) Error!void { |
| 872 | try self.container.end(); | 874 | try self.container.end(); |
| 873 | self.* = undefined; | 875 | self.* = undefined; |
| 874 | } | 876 | } |
| ... | @@ -879,7 +881,7 @@ pub const Serializer = struct { | ... | @@ -879,7 +881,7 @@ pub const Serializer = struct { |
| 879 | name: []const u8, | 881 | name: []const u8, |
| 880 | val: anytype, | 882 | val: anytype, |
| 881 | options: ValueOptions, | 883 | options: ValueOptions, |
| 882 | ) anyerror!void { | 884 | ) Error!void { |
| 883 | try self.container.field(name, val, options); | 885 | try self.container.field(name, val, options); |
| 884 | } | 886 | } |
| 885 | 887 | ||
| ... | @@ -891,7 +893,7 @@ pub const Serializer = struct { | ... | @@ -891,7 +893,7 @@ pub const Serializer = struct { |
| 891 | val: anytype, | 893 | val: anytype, |
| 892 | options: ValueOptions, | 894 | options: ValueOptions, |
| 893 | depth: usize, | 895 | depth: usize, |
| 894 | ) anyerror!void { | 896 | ) Error!void { |
| 895 | try self.container.fieldMaxDepth(name, val, options, depth); | 897 | try self.container.fieldMaxDepth(name, val, options, depth); |
| 896 | } | 898 | } |
| 897 | 899 | ||
| ... | @@ -902,7 +904,7 @@ pub const Serializer = struct { | ... | @@ -902,7 +904,7 @@ pub const Serializer = struct { |
| 902 | name: []const u8, | 904 | name: []const u8, |
| 903 | val: anytype, | 905 | val: anytype, |
| 904 | options: ValueOptions, | 906 | options: ValueOptions, |
| 905 | ) anyerror!void { | 907 | ) Error!void { |
| 906 | try self.container.fieldArbitraryDepth(name, val, options); | 908 | try self.container.fieldArbitraryDepth(name, val, options); |
| 907 | } | 909 | } |
| 908 | 910 | ||
| ... | @@ -911,7 +913,7 @@ pub const Serializer = struct { | ... | @@ -911,7 +913,7 @@ pub const Serializer = struct { |
| 911 | self: *Struct, | 913 | self: *Struct, |
| 912 | name: []const u8, | 914 | name: []const u8, |
| 913 | options: SerializeContainerOptions, | 915 | options: SerializeContainerOptions, |
| 914 | ) anyerror!Struct { | 916 | ) Error!Struct { |
| 915 | try self.fieldPrefix(name); | 917 | try self.fieldPrefix(name); |
| 916 | return self.container.serializer.beginStruct(options); | 918 | return self.container.serializer.beginStruct(options); |
| 917 | } | 919 | } |
| ... | @@ -921,7 +923,7 @@ pub const Serializer = struct { | ... | @@ -921,7 +923,7 @@ pub const Serializer = struct { |
| 921 | self: *Struct, | 923 | self: *Struct, |
| 922 | name: []const u8, | 924 | name: []const u8, |
| 923 | options: SerializeContainerOptions, | 925 | options: SerializeContainerOptions, |
| 924 | ) anyerror!Tuple { | 926 | ) Error!Tuple { |
| 925 | try self.fieldPrefix(name); | 927 | try self.fieldPrefix(name); |
| 926 | return self.container.serializer.beginTuple(options); | 928 | return self.container.serializer.beginTuple(options); |
| 927 | } | 929 | } |
| ... | @@ -929,7 +931,7 @@ pub const Serializer = struct { | ... | @@ -929,7 +931,7 @@ pub const Serializer = struct { |
| 929 | /// Print a field prefix. This prints any necessary commas, the field name (escaped if | 931 | /// Print a field prefix. This prints any necessary commas, the field name (escaped if |
| 930 | /// necessary) and whitespace as configured. Useful if you want to serialize the field | 932 | /// necessary) and whitespace as configured. Useful if you want to serialize the field |
| 931 | /// value yourself. | 933 | /// value yourself. |
| 932 | pub fn fieldPrefix(self: *Struct, name: []const u8) anyerror!void { | 934 | pub fn fieldPrefix(self: *Struct, name: []const u8) Error!void { |
| 933 | try self.container.fieldPrefix(name); | 935 | try self.container.fieldPrefix(name); |
| 934 | } | 936 | } |
| 935 | }; | 937 | }; |
| ... | @@ -946,7 +948,7 @@ pub const Serializer = struct { | ... | @@ -946,7 +948,7 @@ pub const Serializer = struct { |
| 946 | sz: *Serializer, | 948 | sz: *Serializer, |
| 947 | field_style: FieldStyle, | 949 | field_style: FieldStyle, |
| 948 | options: SerializeContainerOptions, | 950 | options: SerializeContainerOptions, |
| 949 | ) anyerror!Container { | 951 | ) Error!Container { |
| 950 | if (options.shouldWrap()) sz.indent_level +|= 1; | 952 | if (options.shouldWrap()) sz.indent_level +|= 1; |
| 951 | try sz.writer.writeAll(".{"); | 953 | try sz.writer.writeAll(".{"); |
| 952 | return .{ | 954 | return .{ |
| ... | @@ -957,7 +959,7 @@ pub const Serializer = struct { | ... | @@ -957,7 +959,7 @@ pub const Serializer = struct { |
| 957 | }; | 959 | }; |
| 958 | } | 960 | } |
| 959 | 961 | ||
| 960 | fn end(self: *Container) anyerror!void { | 962 | fn end(self: *Container) Error!void { |
| 961 | if (self.options.shouldWrap()) self.serializer.indent_level -|= 1; | 963 | if (self.options.shouldWrap()) self.serializer.indent_level -|= 1; |
| 962 | if (!self.empty) { | 964 | if (!self.empty) { |
| 963 | if (self.options.shouldWrap()) { | 965 | if (self.options.shouldWrap()) { |
| ... | @@ -974,7 +976,7 @@ pub const Serializer = struct { | ... | @@ -974,7 +976,7 @@ pub const Serializer = struct { |
| 974 | self.* = undefined; | 976 | self.* = undefined; |
| 975 | } | 977 | } |
| 976 | 978 | ||
| 977 | fn fieldPrefix(self: *Container, name: ?[]const u8) anyerror!void { | 979 | fn fieldPrefix(self: *Container, name: ?[]const u8) Error!void { |
| 978 | if (!self.empty) { | 980 | if (!self.empty) { |
| 979 | try self.serializer.writer.writeByte(','); | 981 | try self.serializer.writer.writeByte(','); |
| 980 | } | 982 | } |
| ... | @@ -998,7 +1000,7 @@ pub const Serializer = struct { | ... | @@ -998,7 +1000,7 @@ pub const Serializer = struct { |
| 998 | name: ?[]const u8, | 1000 | name: ?[]const u8, |
| 999 | val: anytype, | 1001 | val: anytype, |
| 1000 | options: ValueOptions, | 1002 | options: ValueOptions, |
| 1001 | ) anyerror!void { | 1003 | ) Error!void { |
| 1002 | comptime assert(!typeIsRecursive(@TypeOf(val))); | 1004 | comptime assert(!typeIsRecursive(@TypeOf(val))); |
| 1003 | try self.fieldArbitraryDepth(name, val, options); | 1005 | try self.fieldArbitraryDepth(name, val, options); |
| 1004 | } | 1006 | } |
| ... | @@ -1010,7 +1012,7 @@ pub const Serializer = struct { | ... | @@ -1010,7 +1012,7 @@ pub const Serializer = struct { |
| 1010 | val: anytype, | 1012 | val: anytype, |
| 1011 | options: ValueOptions, | 1013 | options: ValueOptions, |
| 1012 | depth: usize, | 1014 | depth: usize, |
| 1013 | ) anyerror!void { | 1015 | ) Error!void { |
| 1014 | try checkValueDepth(val, depth); | 1016 | try checkValueDepth(val, depth); |
| 1015 | try self.fieldArbitraryDepth(name, val, options); | 1017 | try self.fieldArbitraryDepth(name, val, options); |
| 1016 | } | 1018 | } |
| ... | @@ -1020,7 +1022,7 @@ pub const Serializer = struct { | ... | @@ -1020,7 +1022,7 @@ pub const Serializer = struct { |
| 1020 | name: ?[]const u8, | 1022 | name: ?[]const u8, |
| 1021 | val: anytype, | 1023 | val: anytype, |
| 1022 | options: ValueOptions, | 1024 | options: ValueOptions, |
| 1023 | ) anyerror!void { | 1025 | ) Error!void { |
| 1024 | try self.fieldPrefix(name); | 1026 | try self.fieldPrefix(name); |
| 1025 | try self.serializer.valueArbitraryDepth(val, options); | 1027 | try self.serializer.valueArbitraryDepth(val, options); |
| 1026 | } | 1028 | } |
src/Air.zig+1-1| ... | @@ -957,7 +957,7 @@ pub const Inst = struct { | ... | @@ -957,7 +957,7 @@ pub const Inst = struct { |
| 957 | return index.unwrap().target; | 957 | return index.unwrap().target; |
| 958 | } | 958 | } |
| 959 | 959 | ||
| 960 | pub fn format(index: Index, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void { | 960 | pub fn format(index: Index, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void { |
| 961 | try bw.writeByte('%'); | 961 | try bw.writeByte('%'); |
| 962 | switch (index.unwrap()) { | 962 | switch (index.unwrap()) { |
| 963 | .ref => {}, | 963 | .ref => {}, |
src/Air/Liveness.zig+2-2| ... | @@ -2036,7 +2036,7 @@ fn fmtInstSet(set: *const std.AutoHashMapUnmanaged(Air.Inst.Index, void)) FmtIns | ... | @@ -2036,7 +2036,7 @@ fn fmtInstSet(set: *const std.AutoHashMapUnmanaged(Air.Inst.Index, void)) FmtIns |
| 2036 | const FmtInstSet = struct { | 2036 | const FmtInstSet = struct { |
| 2037 | set: *const std.AutoHashMapUnmanaged(Air.Inst.Index, void), | 2037 | set: *const std.AutoHashMapUnmanaged(Air.Inst.Index, void), |
| 2038 | 2038 | ||
| 2039 | pub fn format(val: FmtInstSet, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void { | 2039 | pub fn format(val: FmtInstSet, bw: *std.io.BufferedWriter, comptime _: []const u8) !void { |
| 2040 | if (val.set.count() == 0) { | 2040 | if (val.set.count() == 0) { |
| 2041 | try bw.writeAll("[no instructions]"); | 2041 | try bw.writeAll("[no instructions]"); |
| 2042 | return; | 2042 | return; |
| ... | @@ -2056,7 +2056,7 @@ fn fmtInstList(list: []const Air.Inst.Index) FmtInstList { | ... | @@ -2056,7 +2056,7 @@ fn fmtInstList(list: []const Air.Inst.Index) FmtInstList { |
| 2056 | const FmtInstList = struct { | 2056 | const FmtInstList = struct { |
| 2057 | list: []const Air.Inst.Index, | 2057 | list: []const Air.Inst.Index, |
| 2058 | 2058 | ||
| 2059 | pub fn format(val: FmtInstList, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void { | 2059 | pub fn format(val: FmtInstList, bw: *std.io.BufferedWriter, comptime _: []const u8) !void { |
| 2060 | if (val.list.len == 0) { | 2060 | if (val.list.len == 0) { |
| 2061 | try bw.writeAll("[no instructions]"); | 2061 | try bw.writeAll("[no instructions]"); |
| 2062 | return; | 2062 | return; |
src/Air/print.zig+46-44| ... | @@ -91,14 +91,16 @@ const Writer = struct { | ... | @@ -91,14 +91,16 @@ const Writer = struct { |
| 91 | indent: usize, | 91 | indent: usize, |
| 92 | skip_body: bool, | 92 | skip_body: bool, |
| 93 | 93 | ||
| 94 | fn writeBody(w: *Writer, s: *std.io.BufferedWriter, body: []const Air.Inst.Index) anyerror!void { | 94 | const Error = std.io.Writer.Error; |
| 95 | |||
| 96 | fn writeBody(w: *Writer, s: *std.io.BufferedWriter, body: []const Air.Inst.Index) Error!void { | ||
| 95 | for (body) |inst| { | 97 | for (body) |inst| { |
| 96 | try w.writeInst(s, inst); | 98 | try w.writeInst(s, inst); |
| 97 | try s.writeByte('\n'); | 99 | try s.writeByte('\n'); |
| 98 | } | 100 | } |
| 99 | } | 101 | } |
| 100 | 102 | ||
| 101 | fn writeInst(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 103 | fn writeInst(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 102 | const tag = w.air.instructions.items(.tag)[@intFromEnum(inst)]; | 104 | const tag = w.air.instructions.items(.tag)[@intFromEnum(inst)]; |
| 103 | try s.splatByteAll(' ', w.indent); | 105 | try s.splatByteAll(' ', w.indent); |
| 104 | try s.print("{f}{c}= {s}(", .{ | 106 | try s.print("{f}{c}= {s}(", .{ |
| ... | @@ -338,19 +340,19 @@ const Writer = struct { | ... | @@ -338,19 +340,19 @@ const Writer = struct { |
| 338 | try s.writeByte(')'); | 340 | try s.writeByte(')'); |
| 339 | } | 341 | } |
| 340 | 342 | ||
| 341 | fn writeBinOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 343 | fn writeBinOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 342 | const bin_op = w.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; | 344 | const bin_op = w.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 343 | try w.writeOperand(s, inst, 0, bin_op.lhs); | 345 | try w.writeOperand(s, inst, 0, bin_op.lhs); |
| 344 | try s.writeAll(", "); | 346 | try s.writeAll(", "); |
| 345 | try w.writeOperand(s, inst, 1, bin_op.rhs); | 347 | try w.writeOperand(s, inst, 1, bin_op.rhs); |
| 346 | } | 348 | } |
| 347 | 349 | ||
| 348 | fn writeUnOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 350 | fn writeUnOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 349 | const un_op = w.air.instructions.items(.data)[@intFromEnum(inst)].un_op; | 351 | const un_op = w.air.instructions.items(.data)[@intFromEnum(inst)].un_op; |
| 350 | try w.writeOperand(s, inst, 0, un_op); | 352 | try w.writeOperand(s, inst, 0, un_op); |
| 351 | } | 353 | } |
| 352 | 354 | ||
| 353 | fn writeNoOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 355 | fn writeNoOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 354 | _ = w; | 356 | _ = w; |
| 355 | _ = s; | 357 | _ = s; |
| 356 | _ = inst; | 358 | _ = inst; |
| ... | @@ -361,25 +363,25 @@ const Writer = struct { | ... | @@ -361,25 +363,25 @@ const Writer = struct { |
| 361 | return ty.print(s, w.pt); | 363 | return ty.print(s, w.pt); |
| 362 | } | 364 | } |
| 363 | 365 | ||
| 364 | fn writeTy(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 366 | fn writeTy(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 365 | const ty = w.air.instructions.items(.data)[@intFromEnum(inst)].ty; | 367 | const ty = w.air.instructions.items(.data)[@intFromEnum(inst)].ty; |
| 366 | try w.writeType(s, ty); | 368 | try w.writeType(s, ty); |
| 367 | } | 369 | } |
| 368 | 370 | ||
| 369 | fn writeArg(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 371 | fn writeArg(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 370 | const arg = w.air.instructions.items(.data)[@intFromEnum(inst)].arg; | 372 | const arg = w.air.instructions.items(.data)[@intFromEnum(inst)].arg; |
| 371 | try w.writeType(s, arg.ty.toType()); | 373 | try w.writeType(s, arg.ty.toType()); |
| 372 | try s.print(", {d}", .{arg.zir_param_index}); | 374 | try s.print(", {d}", .{arg.zir_param_index}); |
| 373 | } | 375 | } |
| 374 | 376 | ||
| 375 | fn writeTyOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 377 | fn writeTyOp(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 376 | const ty_op = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; | 378 | const ty_op = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 377 | try w.writeType(s, ty_op.ty.toType()); | 379 | try w.writeType(s, ty_op.ty.toType()); |
| 378 | try s.writeAll(", "); | 380 | try s.writeAll(", "); |
| 379 | try w.writeOperand(s, inst, 0, ty_op.operand); | 381 | try w.writeOperand(s, inst, 0, ty_op.operand); |
| 380 | } | 382 | } |
| 381 | 383 | ||
| 382 | fn writeBlock(w: *Writer, s: *std.io.BufferedWriter, tag: Air.Inst.Tag, inst: Air.Inst.Index) anyerror!void { | 384 | fn writeBlock(w: *Writer, s: *std.io.BufferedWriter, tag: Air.Inst.Tag, inst: Air.Inst.Index) Error!void { |
| 383 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 385 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 384 | try w.writeType(s, ty_pl.ty.toType()); | 386 | try w.writeType(s, ty_pl.ty.toType()); |
| 385 | const body: []const Air.Inst.Index = @ptrCast(switch (tag) { | 387 | const body: []const Air.Inst.Index = @ptrCast(switch (tag) { |
| ... | @@ -420,7 +422,7 @@ const Writer = struct { | ... | @@ -420,7 +422,7 @@ const Writer = struct { |
| 420 | } | 422 | } |
| 421 | } | 423 | } |
| 422 | 424 | ||
| 423 | fn writeLoop(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 425 | fn writeLoop(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 424 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 426 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 425 | const extra = w.air.extraData(Air.Block, ty_pl.payload); | 427 | const extra = w.air.extraData(Air.Block, ty_pl.payload); |
| 426 | const body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.body_len]); | 428 | const body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.body_len]); |
| ... | @@ -436,7 +438,7 @@ const Writer = struct { | ... | @@ -436,7 +438,7 @@ const Writer = struct { |
| 436 | try s.writeAll("}"); | 438 | try s.writeAll("}"); |
| 437 | } | 439 | } |
| 438 | 440 | ||
| 439 | fn writeAggregateInit(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 441 | fn writeAggregateInit(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 440 | const zcu = w.pt.zcu; | 442 | const zcu = w.pt.zcu; |
| 441 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 443 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 442 | const vector_ty = ty_pl.ty.toType(); | 444 | const vector_ty = ty_pl.ty.toType(); |
| ... | @@ -452,7 +454,7 @@ const Writer = struct { | ... | @@ -452,7 +454,7 @@ const Writer = struct { |
| 452 | try s.writeAll("]"); | 454 | try s.writeAll("]"); |
| 453 | } | 455 | } |
| 454 | 456 | ||
| 455 | fn writeUnionInit(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 457 | fn writeUnionInit(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 456 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 458 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 457 | const extra = w.air.extraData(Air.UnionInit, ty_pl.payload).data; | 459 | const extra = w.air.extraData(Air.UnionInit, ty_pl.payload).data; |
| 458 | 460 | ||
| ... | @@ -460,7 +462,7 @@ const Writer = struct { | ... | @@ -460,7 +462,7 @@ const Writer = struct { |
| 460 | try w.writeOperand(s, inst, 0, extra.init); | 462 | try w.writeOperand(s, inst, 0, extra.init); |
| 461 | } | 463 | } |
| 462 | 464 | ||
| 463 | fn writeStructField(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 465 | fn writeStructField(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 464 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 466 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 465 | const extra = w.air.extraData(Air.StructField, ty_pl.payload).data; | 467 | const extra = w.air.extraData(Air.StructField, ty_pl.payload).data; |
| 466 | 468 | ||
| ... | @@ -468,7 +470,7 @@ const Writer = struct { | ... | @@ -468,7 +470,7 @@ const Writer = struct { |
| 468 | try s.print(", {d}", .{extra.field_index}); | 470 | try s.print(", {d}", .{extra.field_index}); |
| 469 | } | 471 | } |
| 470 | 472 | ||
| 471 | fn writeTyPlBin(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 473 | fn writeTyPlBin(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 472 | const data = w.air.instructions.items(.data); | 474 | const data = w.air.instructions.items(.data); |
| 473 | const ty_pl = data[@intFromEnum(inst)].ty_pl; | 475 | const ty_pl = data[@intFromEnum(inst)].ty_pl; |
| 474 | const extra = w.air.extraData(Air.Bin, ty_pl.payload).data; | 476 | const extra = w.air.extraData(Air.Bin, ty_pl.payload).data; |
| ... | @@ -481,7 +483,7 @@ const Writer = struct { | ... | @@ -481,7 +483,7 @@ const Writer = struct { |
| 481 | try w.writeOperand(s, inst, 1, extra.rhs); | 483 | try w.writeOperand(s, inst, 1, extra.rhs); |
| 482 | } | 484 | } |
| 483 | 485 | ||
| 484 | fn writeCmpxchg(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 486 | fn writeCmpxchg(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 485 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 487 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 486 | const extra = w.air.extraData(Air.Cmpxchg, ty_pl.payload).data; | 488 | const extra = w.air.extraData(Air.Cmpxchg, ty_pl.payload).data; |
| 487 | 489 | ||
| ... | @@ -495,7 +497,7 @@ const Writer = struct { | ... | @@ -495,7 +497,7 @@ const Writer = struct { |
| 495 | }); | 497 | }); |
| 496 | } | 498 | } |
| 497 | 499 | ||
| 498 | fn writeMulAdd(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 500 | fn writeMulAdd(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 499 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 501 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 500 | const extra = w.air.extraData(Air.Bin, pl_op.payload).data; | 502 | const extra = w.air.extraData(Air.Bin, pl_op.payload).data; |
| 501 | 503 | ||
| ... | @@ -506,7 +508,7 @@ const Writer = struct { | ... | @@ -506,7 +508,7 @@ const Writer = struct { |
| 506 | try w.writeOperand(s, inst, 2, pl_op.operand); | 508 | try w.writeOperand(s, inst, 2, pl_op.operand); |
| 507 | } | 509 | } |
| 508 | 510 | ||
| 509 | fn writeShuffleOne(w: *Writer, s: anytype, inst: Air.Inst.Index) anyerror!void { | 511 | fn writeShuffleOne(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 510 | const unwrapped = w.air.unwrapShuffleOne(w.pt.zcu, inst); | 512 | const unwrapped = w.air.unwrapShuffleOne(w.pt.zcu, inst); |
| 511 | try w.writeType(s, unwrapped.result_ty); | 513 | try w.writeType(s, unwrapped.result_ty); |
| 512 | try s.writeAll(", "); | 514 | try s.writeAll(", "); |
| ... | @@ -522,7 +524,7 @@ const Writer = struct { | ... | @@ -522,7 +524,7 @@ const Writer = struct { |
| 522 | try s.writeByte(']'); | 524 | try s.writeByte(']'); |
| 523 | } | 525 | } |
| 524 | 526 | ||
| 525 | fn writeShuffleTwo(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 527 | fn writeShuffleTwo(w: *Writer, s: anytype, inst: Air.Inst.Index) Error!void { |
| 526 | const unwrapped = w.air.unwrapShuffleTwo(w.pt.zcu, inst); | 528 | const unwrapped = w.air.unwrapShuffleTwo(w.pt.zcu, inst); |
| 527 | try w.writeType(s, unwrapped.result_ty); | 529 | try w.writeType(s, unwrapped.result_ty); |
| 528 | try s.writeAll(", "); | 530 | try s.writeAll(", "); |
| ... | @@ -541,7 +543,7 @@ const Writer = struct { | ... | @@ -541,7 +543,7 @@ const Writer = struct { |
| 541 | try s.writeByte(']'); | 543 | try s.writeByte(']'); |
| 542 | } | 544 | } |
| 543 | 545 | ||
| 544 | fn writeSelect(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 546 | fn writeSelect(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 545 | const zcu = w.pt.zcu; | 547 | const zcu = w.pt.zcu; |
| 546 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 548 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 547 | const extra = w.air.extraData(Air.Bin, pl_op.payload).data; | 549 | const extra = w.air.extraData(Air.Bin, pl_op.payload).data; |
| ... | @@ -556,14 +558,14 @@ const Writer = struct { | ... | @@ -556,14 +558,14 @@ const Writer = struct { |
| 556 | try w.writeOperand(s, inst, 2, extra.rhs); | 558 | try w.writeOperand(s, inst, 2, extra.rhs); |
| 557 | } | 559 | } |
| 558 | 560 | ||
| 559 | fn writeReduce(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 561 | fn writeReduce(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 560 | const reduce = w.air.instructions.items(.data)[@intFromEnum(inst)].reduce; | 562 | const reduce = w.air.instructions.items(.data)[@intFromEnum(inst)].reduce; |
| 561 | 563 | ||
| 562 | try w.writeOperand(s, inst, 0, reduce.operand); | 564 | try w.writeOperand(s, inst, 0, reduce.operand); |
| 563 | try s.print(", {s}", .{@tagName(reduce.operation)}); | 565 | try s.print(", {s}", .{@tagName(reduce.operation)}); |
| 564 | } | 566 | } |
| 565 | 567 | ||
| 566 | fn writeCmpVector(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 568 | fn writeCmpVector(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 567 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 569 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 568 | const extra = w.air.extraData(Air.VectorCmp, ty_pl.payload).data; | 570 | const extra = w.air.extraData(Air.VectorCmp, ty_pl.payload).data; |
| 569 | 571 | ||
| ... | @@ -573,7 +575,7 @@ const Writer = struct { | ... | @@ -573,7 +575,7 @@ const Writer = struct { |
| 573 | try w.writeOperand(s, inst, 1, extra.rhs); | 575 | try w.writeOperand(s, inst, 1, extra.rhs); |
| 574 | } | 576 | } |
| 575 | 577 | ||
| 576 | fn writeVectorStoreElem(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 578 | fn writeVectorStoreElem(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 577 | const data = w.air.instructions.items(.data)[@intFromEnum(inst)].vector_store_elem; | 579 | const data = w.air.instructions.items(.data)[@intFromEnum(inst)].vector_store_elem; |
| 578 | const extra = w.air.extraData(Air.VectorCmp, data.payload).data; | 580 | const extra = w.air.extraData(Air.VectorCmp, data.payload).data; |
| 579 | 581 | ||
| ... | @@ -584,21 +586,21 @@ const Writer = struct { | ... | @@ -584,21 +586,21 @@ const Writer = struct { |
| 584 | try w.writeOperand(s, inst, 2, extra.rhs); | 586 | try w.writeOperand(s, inst, 2, extra.rhs); |
| 585 | } | 587 | } |
| 586 | 588 | ||
| 587 | fn writeRuntimeNavPtr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) std.io.Writer.Error!void { | 589 | fn writeRuntimeNavPtr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 588 | const ip = &w.pt.zcu.intern_pool; | 590 | const ip = &w.pt.zcu.intern_pool; |
| 589 | const ty_nav = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_nav; | 591 | const ty_nav = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_nav; |
| 590 | try w.writeType(s, .fromInterned(ty_nav.ty)); | 592 | try w.writeType(s, .fromInterned(ty_nav.ty)); |
| 591 | try s.print(", '{}'", .{ip.getNav(ty_nav.nav).fqn.fmt(ip)}); | 593 | try s.print(", '{}'", .{ip.getNav(ty_nav.nav).fqn.fmt(ip)}); |
| 592 | } | 594 | } |
| 593 | 595 | ||
| 594 | fn writeAtomicLoad(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) std.io.Writer.Error!void { | 596 | fn writeAtomicLoad(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 595 | const atomic_load = w.air.instructions.items(.data)[@intFromEnum(inst)].atomic_load; | 597 | const atomic_load = w.air.instructions.items(.data)[@intFromEnum(inst)].atomic_load; |
| 596 | 598 | ||
| 597 | try w.writeOperand(s, inst, 0, atomic_load.ptr); | 599 | try w.writeOperand(s, inst, 0, atomic_load.ptr); |
| 598 | try s.print(", {s}", .{@tagName(atomic_load.order)}); | 600 | try s.print(", {s}", .{@tagName(atomic_load.order)}); |
| 599 | } | 601 | } |
| 600 | 602 | ||
| 601 | fn writePrefetch(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 603 | fn writePrefetch(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 602 | const prefetch = w.air.instructions.items(.data)[@intFromEnum(inst)].prefetch; | 604 | const prefetch = w.air.instructions.items(.data)[@intFromEnum(inst)].prefetch; |
| 603 | 605 | ||
| 604 | try w.writeOperand(s, inst, 0, prefetch.ptr); | 606 | try w.writeOperand(s, inst, 0, prefetch.ptr); |
| ... | @@ -612,7 +614,7 @@ const Writer = struct { | ... | @@ -612,7 +614,7 @@ const Writer = struct { |
| 612 | s: *std.io.BufferedWriter, | 614 | s: *std.io.BufferedWriter, |
| 613 | inst: Air.Inst.Index, | 615 | inst: Air.Inst.Index, |
| 614 | order: std.builtin.AtomicOrder, | 616 | order: std.builtin.AtomicOrder, |
| 615 | ) anyerror!void { | 617 | ) Error!void { |
| 616 | const bin_op = w.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; | 618 | const bin_op = w.air.instructions.items(.data)[@intFromEnum(inst)].bin_op; |
| 617 | try w.writeOperand(s, inst, 0, bin_op.lhs); | 619 | try w.writeOperand(s, inst, 0, bin_op.lhs); |
| 618 | try s.writeAll(", "); | 620 | try s.writeAll(", "); |
| ... | @@ -620,7 +622,7 @@ const Writer = struct { | ... | @@ -620,7 +622,7 @@ const Writer = struct { |
| 620 | try s.print(", {s}", .{@tagName(order)}); | 622 | try s.print(", {s}", .{@tagName(order)}); |
| 621 | } | 623 | } |
| 622 | 624 | ||
| 623 | fn writeAtomicRmw(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 625 | fn writeAtomicRmw(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 624 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 626 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 625 | const extra = w.air.extraData(Air.AtomicRmw, pl_op.payload).data; | 627 | const extra = w.air.extraData(Air.AtomicRmw, pl_op.payload).data; |
| 626 | 628 | ||
| ... | @@ -630,7 +632,7 @@ const Writer = struct { | ... | @@ -630,7 +632,7 @@ const Writer = struct { |
| 630 | try s.print(", {s}, {s}", .{ @tagName(extra.op()), @tagName(extra.ordering()) }); | 632 | try s.print(", {s}, {s}", .{ @tagName(extra.op()), @tagName(extra.ordering()) }); |
| 631 | } | 633 | } |
| 632 | 634 | ||
| 633 | fn writeFieldParentPtr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 635 | fn writeFieldParentPtr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 634 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 636 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 635 | const extra = w.air.extraData(Air.FieldParentPtr, ty_pl.payload).data; | 637 | const extra = w.air.extraData(Air.FieldParentPtr, ty_pl.payload).data; |
| 636 | 638 | ||
| ... | @@ -638,7 +640,7 @@ const Writer = struct { | ... | @@ -638,7 +640,7 @@ const Writer = struct { |
| 638 | try s.print(", {d}", .{extra.field_index}); | 640 | try s.print(", {d}", .{extra.field_index}); |
| 639 | } | 641 | } |
| 640 | 642 | ||
| 641 | fn writeAssembly(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 643 | fn writeAssembly(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 642 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 644 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 643 | const extra = w.air.extraData(Air.Asm, ty_pl.payload); | 645 | const extra = w.air.extraData(Air.Asm, ty_pl.payload); |
| 644 | const is_volatile = @as(u1, @truncate(extra.data.flags >> 31)) != 0; | 646 | const is_volatile = @as(u1, @truncate(extra.data.flags >> 31)) != 0; |
| ... | @@ -711,19 +713,19 @@ const Writer = struct { | ... | @@ -711,19 +713,19 @@ const Writer = struct { |
| 711 | try s.print(", \"{f}\"", .{std.zig.fmtEscapes(asm_source)}); | 713 | try s.print(", \"{f}\"", .{std.zig.fmtEscapes(asm_source)}); |
| 712 | } | 714 | } |
| 713 | 715 | ||
| 714 | fn writeDbgStmt(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 716 | fn writeDbgStmt(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 715 | const dbg_stmt = w.air.instructions.items(.data)[@intFromEnum(inst)].dbg_stmt; | 717 | const dbg_stmt = w.air.instructions.items(.data)[@intFromEnum(inst)].dbg_stmt; |
| 716 | try s.print("{d}:{d}", .{ dbg_stmt.line + 1, dbg_stmt.column + 1 }); | 718 | try s.print("{d}:{d}", .{ dbg_stmt.line + 1, dbg_stmt.column + 1 }); |
| 717 | } | 719 | } |
| 718 | 720 | ||
| 719 | fn writeDbgVar(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 721 | fn writeDbgVar(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 720 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 722 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 721 | try w.writeOperand(s, inst, 0, pl_op.operand); | 723 | try w.writeOperand(s, inst, 0, pl_op.operand); |
| 722 | const name: Air.NullTerminatedString = @enumFromInt(pl_op.payload); | 724 | const name: Air.NullTerminatedString = @enumFromInt(pl_op.payload); |
| 723 | try s.print(", \"{f}\"", .{std.zig.fmtEscapes(name.toSlice(w.air))}); | 725 | try s.print(", \"{f}\"", .{std.zig.fmtEscapes(name.toSlice(w.air))}); |
| 724 | } | 726 | } |
| 725 | 727 | ||
| 726 | fn writeCall(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 728 | fn writeCall(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 727 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 729 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 728 | const extra = w.air.extraData(Air.Call, pl_op.payload); | 730 | const extra = w.air.extraData(Air.Call, pl_op.payload); |
| 729 | const args = @as([]const Air.Inst.Ref, @ptrCast(w.air.extra.items[extra.end..][0..extra.data.args_len])); | 731 | const args = @as([]const Air.Inst.Ref, @ptrCast(w.air.extra.items[extra.end..][0..extra.data.args_len])); |
| ... | @@ -736,19 +738,19 @@ const Writer = struct { | ... | @@ -736,19 +738,19 @@ const Writer = struct { |
| 736 | try s.writeAll("]"); | 738 | try s.writeAll("]"); |
| 737 | } | 739 | } |
| 738 | 740 | ||
| 739 | fn writeBr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 741 | fn writeBr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 740 | const br = w.air.instructions.items(.data)[@intFromEnum(inst)].br; | 742 | const br = w.air.instructions.items(.data)[@intFromEnum(inst)].br; |
| 741 | try w.writeInstIndex(s, br.block_inst, false); | 743 | try w.writeInstIndex(s, br.block_inst, false); |
| 742 | try s.writeAll(", "); | 744 | try s.writeAll(", "); |
| 743 | try w.writeOperand(s, inst, 0, br.operand); | 745 | try w.writeOperand(s, inst, 0, br.operand); |
| 744 | } | 746 | } |
| 745 | 747 | ||
| 746 | fn writeRepeat(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 748 | fn writeRepeat(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 747 | const repeat = w.air.instructions.items(.data)[@intFromEnum(inst)].repeat; | 749 | const repeat = w.air.instructions.items(.data)[@intFromEnum(inst)].repeat; |
| 748 | try w.writeInstIndex(s, repeat.loop_inst, false); | 750 | try w.writeInstIndex(s, repeat.loop_inst, false); |
| 749 | } | 751 | } |
| 750 | 752 | ||
| 751 | fn writeTry(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 753 | fn writeTry(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 752 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 754 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 753 | const extra = w.air.extraData(Air.Try, pl_op.payload); | 755 | const extra = w.air.extraData(Air.Try, pl_op.payload); |
| 754 | const body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.body_len]); | 756 | const body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.body_len]); |
| ... | @@ -782,7 +784,7 @@ const Writer = struct { | ... | @@ -782,7 +784,7 @@ const Writer = struct { |
| 782 | } | 784 | } |
| 783 | } | 785 | } |
| 784 | 786 | ||
| 785 | fn writeTryPtr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 787 | fn writeTryPtr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 786 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; | 788 | const ty_pl = w.air.instructions.items(.data)[@intFromEnum(inst)].ty_pl; |
| 787 | const extra = w.air.extraData(Air.TryPtr, ty_pl.payload); | 789 | const extra = w.air.extraData(Air.TryPtr, ty_pl.payload); |
| 788 | const body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.body_len]); | 790 | const body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.body_len]); |
| ... | @@ -819,7 +821,7 @@ const Writer = struct { | ... | @@ -819,7 +821,7 @@ const Writer = struct { |
| 819 | } | 821 | } |
| 820 | } | 822 | } |
| 821 | 823 | ||
| 822 | fn writeCondBr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 824 | fn writeCondBr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 823 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 825 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 824 | const extra = w.air.extraData(Air.CondBr, pl_op.payload); | 826 | const extra = w.air.extraData(Air.CondBr, pl_op.payload); |
| 825 | const then_body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.then_body_len]); | 827 | const then_body: []const Air.Inst.Index = @ptrCast(w.air.extra.items[extra.end..][0..extra.data.then_body_len]); |
| ... | @@ -878,7 +880,7 @@ const Writer = struct { | ... | @@ -878,7 +880,7 @@ const Writer = struct { |
| 878 | try s.writeAll("}"); | 880 | try s.writeAll("}"); |
| 879 | } | 881 | } |
| 880 | 882 | ||
| 881 | fn writeSwitchBr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 883 | fn writeSwitchBr(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 882 | const switch_br = w.air.unwrapSwitch(inst); | 884 | const switch_br = w.air.unwrapSwitch(inst); |
| 883 | 885 | ||
| 884 | const liveness: Air.Liveness.SwitchBrTable = if (w.liveness) |liveness| | 886 | const liveness: Air.Liveness.SwitchBrTable = if (w.liveness) |liveness| |
| ... | @@ -964,18 +966,18 @@ const Writer = struct { | ... | @@ -964,18 +966,18 @@ const Writer = struct { |
| 964 | try s.splatByteAll(' ', old_indent); | 966 | try s.splatByteAll(' ', old_indent); |
| 965 | } | 967 | } |
| 966 | 968 | ||
| 967 | fn writeWasmMemorySize(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 969 | fn writeWasmMemorySize(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 968 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 970 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 969 | try s.print("{d}", .{pl_op.payload}); | 971 | try s.print("{d}", .{pl_op.payload}); |
| 970 | } | 972 | } |
| 971 | 973 | ||
| 972 | fn writeWasmMemoryGrow(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 974 | fn writeWasmMemoryGrow(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 973 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 975 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 974 | try s.print("{d}, ", .{pl_op.payload}); | 976 | try s.print("{d}, ", .{pl_op.payload}); |
| 975 | try w.writeOperand(s, inst, 0, pl_op.operand); | 977 | try w.writeOperand(s, inst, 0, pl_op.operand); |
| 976 | } | 978 | } |
| 977 | 979 | ||
| 978 | fn writeWorkDimension(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) anyerror!void { | 980 | fn writeWorkDimension(w: *Writer, s: *std.io.BufferedWriter, inst: Air.Inst.Index) Error!void { |
| 979 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; | 981 | const pl_op = w.air.instructions.items(.data)[@intFromEnum(inst)].pl_op; |
| 980 | try s.print("{d}", .{pl_op.payload}); | 982 | try s.print("{d}", .{pl_op.payload}); |
| 981 | } | 983 | } |
| ... | @@ -986,7 +988,7 @@ const Writer = struct { | ... | @@ -986,7 +988,7 @@ const Writer = struct { |
| 986 | inst: Air.Inst.Index, | 988 | inst: Air.Inst.Index, |
| 987 | op_index: usize, | 989 | op_index: usize, |
| 988 | operand: Air.Inst.Ref, | 990 | operand: Air.Inst.Ref, |
| 989 | ) anyerror!void { | 991 | ) Error!void { |
| 990 | const small_tomb_bits = Air.Liveness.bpi - 1; | 992 | const small_tomb_bits = Air.Liveness.bpi - 1; |
| 991 | const dies = if (w.liveness) |liveness| blk: { | 993 | const dies = if (w.liveness) |liveness| blk: { |
| 992 | if (op_index < small_tomb_bits) | 994 | if (op_index < small_tomb_bits) |
| ... | @@ -1011,7 +1013,7 @@ const Writer = struct { | ... | @@ -1011,7 +1013,7 @@ const Writer = struct { |
| 1011 | s: anytype, | 1013 | s: anytype, |
| 1012 | operand: Air.Inst.Ref, | 1014 | operand: Air.Inst.Ref, |
| 1013 | dies: bool, | 1015 | dies: bool, |
| 1014 | ) anyerror!void { | 1016 | ) Error!void { |
| 1015 | if (@intFromEnum(operand) < InternPool.static_len) { | 1017 | if (@intFromEnum(operand) < InternPool.static_len) { |
| 1016 | return s.print("@{}", .{operand}); | 1018 | return s.print("@{}", .{operand}); |
| 1017 | } else if (operand.toInterned()) |ip_index| { | 1019 | } else if (operand.toInterned()) |ip_index| { |
| ... | @@ -1031,7 +1033,7 @@ const Writer = struct { | ... | @@ -1031,7 +1033,7 @@ const Writer = struct { |
| 1031 | s: *std.io.BufferedWriter, | 1033 | s: *std.io.BufferedWriter, |
| 1032 | inst: Air.Inst.Index, | 1034 | inst: Air.Inst.Index, |
| 1033 | dies: bool, | 1035 | dies: bool, |
| 1034 | ) anyerror!void { | 1036 | ) Error!void { |
| 1035 | _ = w; | 1037 | _ = w; |
| 1036 | try s.print("{f}", .{inst}); | 1038 | try s.print("{f}", .{inst}); |
| 1037 | if (dies) try s.writeByte('!'); | 1039 | if (dies) try s.writeByte('!'); |
src/Compilation.zig+1-1| ... | @@ -6024,7 +6024,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32 | ... | @@ -6024,7 +6024,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32 |
| 6024 | 6024 | ||
| 6025 | // In .rc files, a " within a quoted string is escaped as "" | 6025 | // In .rc files, a " within a quoted string is escaped as "" |
| 6026 | const fmtRcEscape = struct { | 6026 | const fmtRcEscape = struct { |
| 6027 | fn formatRcEscape(bytes: []const u8, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void { | 6027 | fn formatRcEscape(bytes: []const u8, bw: *std.io.BufferedWriter, comptime fmt: []const u8) !void { |
| 6028 | _ = fmt; | 6028 | _ = fmt; |
| 6029 | for (bytes) |byte| switch (byte) { | 6029 | for (bytes) |byte| switch (byte) { |
| 6030 | '"' => try bw.writeAll("\"\""), | 6030 | '"' => try bw.writeAll("\"\""), |
src/InternPool.zig+1-1| ... | @@ -1888,7 +1888,7 @@ pub const NullTerminatedString = enum(u32) { | ... | @@ -1888,7 +1888,7 @@ pub const NullTerminatedString = enum(u32) { |
| 1888 | string: NullTerminatedString, | 1888 | string: NullTerminatedString, |
| 1889 | ip: *const InternPool, | 1889 | ip: *const InternPool, |
| 1890 | }; | 1890 | }; |
| 1891 | fn format(data: FormatData, bw: *std.io.BufferedWriter, comptime specifier: []const u8) anyerror!void { | 1891 | fn format(data: FormatData, bw: *std.io.BufferedWriter, comptime specifier: []const u8) std.io.Writer.Error!void { |
| 1892 | const slice = data.string.toSlice(data.ip); | 1892 | const slice = data.string.toSlice(data.ip); |
| 1893 | if (comptime std.mem.eql(u8, specifier, "")) { | 1893 | if (comptime std.mem.eql(u8, specifier, "")) { |
| 1894 | try bw.writeAll(slice); | 1894 | try bw.writeAll(slice); |
src/Package/Fetch/git.zig+1-1| ... | @@ -119,7 +119,7 @@ pub const Oid = union(Format) { | ... | @@ -119,7 +119,7 @@ pub const Oid = union(Format) { |
| 119 | } else error.InvalidOid; | 119 | } else error.InvalidOid; |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | pub fn format(oid: Oid, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void { | 122 | pub fn format(oid: Oid, bw: *std.io.BufferedWriter, comptime fmt: []const u8) std.io.Writer.Error!void { |
| 123 | _ = fmt; | 123 | _ = fmt; |
| 124 | try bw.print("{x}", .{oid.slice()}); | 124 | try bw.print("{x}", .{oid.slice()}); |
| 125 | } | 125 | } |
src/Sema.zig+2-2| ... | @@ -9544,7 +9544,7 @@ fn callConvSupportsVarArgs(cc: std.builtin.CallingConvention.Tag) bool { | ... | @@ -9544,7 +9544,7 @@ fn callConvSupportsVarArgs(cc: std.builtin.CallingConvention.Tag) bool { |
| 9544 | fn checkCallConvSupportsVarArgs(sema: *Sema, block: *Block, src: LazySrcLoc, cc: std.builtin.CallingConvention.Tag) CompileError!void { | 9544 | fn checkCallConvSupportsVarArgs(sema: *Sema, block: *Block, src: LazySrcLoc, cc: std.builtin.CallingConvention.Tag) CompileError!void { |
| 9545 | const CallingConventionsSupportingVarArgsList = struct { | 9545 | const CallingConventionsSupportingVarArgsList = struct { |
| 9546 | arch: std.Target.Cpu.Arch, | 9546 | arch: std.Target.Cpu.Arch, |
| 9547 | pub fn format(ctx: @This(), bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void { | 9547 | pub fn format(ctx: @This(), bw: *std.io.BufferedWriter, comptime fmt: []const u8) !void { |
| 9548 | _ = fmt; | 9548 | _ = fmt; |
| 9549 | var first = true; | 9549 | var first = true; |
| 9550 | for (calling_conventions_supporting_var_args) |cc_inner| { | 9550 | for (calling_conventions_supporting_var_args) |cc_inner| { |
| ... | @@ -9990,7 +9990,7 @@ fn finishFunc( | ... | @@ -9990,7 +9990,7 @@ fn finishFunc( |
| 9990 | .bad_arch => |allowed_archs| { | 9990 | .bad_arch => |allowed_archs| { |
| 9991 | const ArchListFormatter = struct { | 9991 | const ArchListFormatter = struct { |
| 9992 | archs: []const std.Target.Cpu.Arch, | 9992 | archs: []const std.Target.Cpu.Arch, |
| 9993 | pub fn format(formatter: @This(), bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void { | 9993 | pub fn format(formatter: @This(), bw: *std.io.BufferedWriter, comptime fmt: []const u8) !void { |
| 9994 | _ = fmt; | 9994 | _ = fmt; |
| 9995 | for (formatter.archs, 0..) |arch, i| { | 9995 | for (formatter.archs, 0..) |arch, i| { |
| 9996 | if (i != 0) | 9996 | if (i != 0) |
src/Type.zig+4-4| ... | @@ -121,7 +121,7 @@ pub fn eql(a: Type, b: Type, zcu: *const Zcu) bool { | ... | @@ -121,7 +121,7 @@ pub fn eql(a: Type, b: Type, zcu: *const Zcu) bool { |
| 121 | return a.toIntern() == b.toIntern(); | 121 | return a.toIntern() == b.toIntern(); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | pub fn format(ty: Type, bw: *std.io.BufferedWriter, comptime f: []const u8) anyerror!usize { | 124 | pub fn format(ty: Type, bw: *std.io.BufferedWriter, comptime f: []const u8) !usize { |
| 125 | _ = ty; | 125 | _ = ty; |
| 126 | _ = f; | 126 | _ = f; |
| 127 | _ = bw; | 127 | _ = bw; |
| ... | @@ -142,7 +142,7 @@ const FormatContext = struct { | ... | @@ -142,7 +142,7 @@ const FormatContext = struct { |
| 142 | pt: Zcu.PerThread, | 142 | pt: Zcu.PerThread, |
| 143 | }; | 143 | }; |
| 144 | 144 | ||
| 145 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime f: []const u8) anyerror!void { | 145 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime f: []const u8) !void { |
| 146 | comptime assert(f.len == 0); | 146 | comptime assert(f.len == 0); |
| 147 | try print(ctx.ty, bw, ctx.pt); | 147 | try print(ctx.ty, bw, ctx.pt); |
| 148 | } | 148 | } |
| ... | @@ -153,14 +153,14 @@ pub fn fmtDebug(ty: Type) std.fmt.Formatter(dump) { | ... | @@ -153,14 +153,14 @@ pub fn fmtDebug(ty: Type) std.fmt.Formatter(dump) { |
| 153 | 153 | ||
| 154 | /// This is a debug function. In order to print types in a meaningful way | 154 | /// This is a debug function. In order to print types in a meaningful way |
| 155 | /// we also need access to the module. | 155 | /// we also need access to the module. |
| 156 | pub fn dump(start_type: Type, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void { | 156 | pub fn dump(start_type: Type, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) !void { |
| 157 | comptime assert(unused_format_string.len == 0); | 157 | comptime assert(unused_format_string.len == 0); |
| 158 | return bw.print("{any}", .{start_type.ip_index}); | 158 | return bw.print("{any}", .{start_type.ip_index}); |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | /// Prints a name suitable for `@typeName`. | 161 | /// Prints a name suitable for `@typeName`. |
| 162 | /// TODO: take an `opt_sema` to pass to `fmtValue` when printing sentinels. | 162 | /// TODO: take an `opt_sema` to pass to `fmtValue` when printing sentinels. |
| 163 | pub fn print(ty: Type, bw: *std.io.BufferedWriter, pt: Zcu.PerThread) anyerror!void { | 163 | pub fn print(ty: Type, bw: *std.io.BufferedWriter, pt: Zcu.PerThread) std.io.Writer.Error!void { |
| 164 | const zcu = pt.zcu; | 164 | const zcu = pt.zcu; |
| 165 | const ip = &zcu.intern_pool; | 165 | const ip = &zcu.intern_pool; |
| 166 | switch (ip.indexToKey(ty.toIntern())) { | 166 | switch (ip.indexToKey(ty.toIntern())) { |
src/Zcu.zig+2-2| ... | @@ -4344,7 +4344,7 @@ pub fn fmtDependee(zcu: *Zcu, d: InternPool.Dependee) std.fmt.Formatter(formatDe | ... | @@ -4344,7 +4344,7 @@ pub fn fmtDependee(zcu: *Zcu, d: InternPool.Dependee) std.fmt.Formatter(formatDe |
| 4344 | return .{ .data = .{ .dependee = d, .zcu = zcu } }; | 4344 | return .{ .data = .{ .dependee = d, .zcu = zcu } }; |
| 4345 | } | 4345 | } |
| 4346 | 4346 | ||
| 4347 | fn formatAnalUnit(data: struct { unit: AnalUnit, zcu: *Zcu }, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void { | 4347 | fn formatAnalUnit(data: struct { unit: AnalUnit, zcu: *Zcu }, bw: *std.io.BufferedWriter, comptime fmt: []const u8) !void { |
| 4348 | _ = fmt; | 4348 | _ = fmt; |
| 4349 | const zcu = data.zcu; | 4349 | const zcu = data.zcu; |
| 4350 | const ip = &zcu.intern_pool; | 4350 | const ip = &zcu.intern_pool; |
| ... | @@ -4368,7 +4368,7 @@ fn formatAnalUnit(data: struct { unit: AnalUnit, zcu: *Zcu }, bw: *std.io.Buffer | ... | @@ -4368,7 +4368,7 @@ fn formatAnalUnit(data: struct { unit: AnalUnit, zcu: *Zcu }, bw: *std.io.Buffer |
| 4368 | .memoized_state => return bw.writeAll("memoized_state"), | 4368 | .memoized_state => return bw.writeAll("memoized_state"), |
| 4369 | } | 4369 | } |
| 4370 | } | 4370 | } |
| 4371 | fn formatDependee(data: struct { dependee: InternPool.Dependee, zcu: *Zcu }, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void { | 4371 | fn formatDependee(data: struct { dependee: InternPool.Dependee, zcu: *Zcu }, bw: *std.io.BufferedWriter, comptime fmt: []const u8) !void { |
| 4372 | _ = fmt; | 4372 | _ = fmt; |
| 4373 | const zcu = data.zcu; | 4373 | const zcu = data.zcu; |
| 4374 | const ip = &zcu.intern_pool; | 4374 | const ip = &zcu.intern_pool; |
src/arch/aarch64/Emit.zig+1-5| ... | @@ -71,10 +71,6 @@ const BranchType = enum { | ... | @@ -71,10 +71,6 @@ const BranchType = enum { |
| 71 | }; | 71 | }; |
| 72 | 72 | ||
| 73 | pub fn emitMir(emit: *Emit) InnerError!void { | 73 | pub fn emitMir(emit: *Emit) InnerError!void { |
| 74 | return @errorCast(emit.emitMirInner()); | ||
| 75 | } | ||
| 76 | |||
| 77 | fn emitMirInner(emit: *Emit) anyerror!void { | ||
| 78 | const mir_tags = emit.mir.instructions.items(.tag); | 74 | const mir_tags = emit.mir.instructions.items(.tag); |
| 79 | 75 | ||
| 80 | // Find smallest lowerings for branch instructions | 76 | // Find smallest lowerings for branch instructions |
| ... | @@ -441,7 +437,7 @@ fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError { | ... | @@ -441,7 +437,7 @@ fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError { |
| 441 | return error.EmitFail; | 437 | return error.EmitFail; |
| 442 | } | 438 | } |
| 443 | 439 | ||
| 444 | fn dbgAdvancePCAndLine(emit: *Emit, line: u32, column: u32) anyerror!void { | 440 | fn dbgAdvancePCAndLine(emit: *Emit, line: u32, column: u32) InnerError!void { |
| 445 | const delta_line = @as(i33, line) - @as(i33, emit.prev_di_line); | 441 | const delta_line = @as(i33, line) - @as(i33, emit.prev_di_line); |
| 446 | const delta_pc: usize = emit.code.items.len - emit.prev_di_pc; | 442 | const delta_pc: usize = emit.code.items.len - emit.prev_di_pc; |
| 447 | log.debug(" (advance pc={d} and line={d})", .{ delta_pc, delta_line }); | 443 | log.debug(" (advance pc={d} and line={d})", .{ delta_pc, delta_line }); |
src/arch/arm/Emit.zig-4| ... | @@ -68,10 +68,6 @@ const BranchType = enum { | ... | @@ -68,10 +68,6 @@ const BranchType = enum { |
| 68 | }; | 68 | }; |
| 69 | 69 | ||
| 70 | pub fn emitMir(emit: *Emit) InnerError!void { | 70 | pub fn emitMir(emit: *Emit) InnerError!void { |
| 71 | return @errorCast(emit.emitMirInner()); | ||
| 72 | } | ||
| 73 | |||
| 74 | fn emitMirInner(emit: *Emit) anyerror!void { | ||
| 75 | const mir_tags = emit.mir.instructions.items(.tag); | 71 | const mir_tags = emit.mir.instructions.items(.tag); |
| 76 | 72 | ||
| 77 | // Find smallest lowerings for branch instructions | 73 | // Find smallest lowerings for branch instructions |
src/arch/riscv64/CodeGen.zig+5-5| ... | @@ -566,7 +566,7 @@ const InstTracking = struct { | ... | @@ -566,7 +566,7 @@ const InstTracking = struct { |
| 566 | } | 566 | } |
| 567 | } | 567 | } |
| 568 | 568 | ||
| 569 | pub fn format(inst_tracking: InstTracking, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void { | 569 | pub fn format(inst_tracking: InstTracking, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void { |
| 570 | if (!std.meta.eql(inst_tracking.long, inst_tracking.short)) try bw.print("|{}| ", .{inst_tracking.long}); | 570 | if (!std.meta.eql(inst_tracking.long, inst_tracking.short)) try bw.print("|{}| ", .{inst_tracking.long}); |
| 571 | try bw.print("{}", .{inst_tracking.short}); | 571 | try bw.print("{}", .{inst_tracking.short}); |
| 572 | } | 572 | } |
| ... | @@ -932,7 +932,7 @@ const FormatWipMirData = struct { | ... | @@ -932,7 +932,7 @@ const FormatWipMirData = struct { |
| 932 | func: *Func, | 932 | func: *Func, |
| 933 | inst: Mir.Inst.Index, | 933 | inst: Mir.Inst.Index, |
| 934 | }; | 934 | }; |
| 935 | fn formatWipMir(data: FormatWipMirData, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void { | 935 | fn formatWipMir(data: FormatWipMirData, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void { |
| 936 | const pt = data.func.pt; | 936 | const pt = data.func.pt; |
| 937 | const comp = pt.zcu.comp; | 937 | const comp = pt.zcu.comp; |
| 938 | var lower: Lower = .{ | 938 | var lower: Lower = .{ |
| ... | @@ -980,7 +980,7 @@ const FormatNavData = struct { | ... | @@ -980,7 +980,7 @@ const FormatNavData = struct { |
| 980 | ip: *const InternPool, | 980 | ip: *const InternPool, |
| 981 | nav_index: InternPool.Nav.Index, | 981 | nav_index: InternPool.Nav.Index, |
| 982 | }; | 982 | }; |
| 983 | fn formatNav(data: FormatNavData, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void { | 983 | fn formatNav(data: FormatNavData, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void { |
| 984 | try bw.print("{f}", .{data.ip.getNav(data.nav_index).fqn.fmt(data.ip)}); | 984 | try bw.print("{f}", .{data.ip.getNav(data.nav_index).fqn.fmt(data.ip)}); |
| 985 | } | 985 | } |
| 986 | fn fmtNav(nav_index: InternPool.Nav.Index, ip: *const InternPool) std.fmt.Formatter(formatNav) { | 986 | fn fmtNav(nav_index: InternPool.Nav.Index, ip: *const InternPool) std.fmt.Formatter(formatNav) { |
| ... | @@ -994,7 +994,7 @@ const FormatAirData = struct { | ... | @@ -994,7 +994,7 @@ const FormatAirData = struct { |
| 994 | func: *Func, | 994 | func: *Func, |
| 995 | inst: Air.Inst.Index, | 995 | inst: Air.Inst.Index, |
| 996 | }; | 996 | }; |
| 997 | fn formatAir(data: FormatAirData, _: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void { | 997 | fn formatAir(data: FormatAirData, _: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void { |
| 998 | data.func.air.dumpInst(data.inst, data.func.pt, data.func.liveness); | 998 | data.func.air.dumpInst(data.inst, data.func.pt, data.func.liveness); |
| 999 | } | 999 | } |
| 1000 | fn fmtAir(func: *Func, inst: Air.Inst.Index) std.fmt.Formatter(formatAir) { | 1000 | fn fmtAir(func: *Func, inst: Air.Inst.Index) std.fmt.Formatter(formatAir) { |
| ... | @@ -1004,7 +1004,7 @@ fn fmtAir(func: *Func, inst: Air.Inst.Index) std.fmt.Formatter(formatAir) { | ... | @@ -1004,7 +1004,7 @@ fn fmtAir(func: *Func, inst: Air.Inst.Index) std.fmt.Formatter(formatAir) { |
| 1004 | const FormatTrackingData = struct { | 1004 | const FormatTrackingData = struct { |
| 1005 | func: *Func, | 1005 | func: *Func, |
| 1006 | }; | 1006 | }; |
| 1007 | fn formatTracking(data: FormatTrackingData, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void { | 1007 | fn formatTracking(data: FormatTrackingData, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void { |
| 1008 | var it = data.func.inst_tracking.iterator(); | 1008 | var it = data.func.inst_tracking.iterator(); |
| 1009 | while (it.next()) |entry| try bw.print("\n%{d} = {f}", .{ entry.key_ptr.*, entry.value_ptr.* }); | 1009 | while (it.next()) |entry| try bw.print("\n%{d} = {f}", .{ entry.key_ptr.*, entry.value_ptr.* }); |
| 1010 | } | 1010 | } |
src/arch/riscv64/Emit.zig-4| ... | @@ -18,10 +18,6 @@ pub const Error = Lower.Error || error{ | ... | @@ -18,10 +18,6 @@ pub const Error = Lower.Error || error{ |
| 18 | }; | 18 | }; |
| 19 | 19 | ||
| 20 | pub fn emitMir(emit: *Emit) Error!void { | 20 | pub fn emitMir(emit: *Emit) Error!void { |
| 21 | return @errorCast(emit.emitMirInner()); | ||
| 22 | } | ||
| 23 | |||
| 24 | fn emitMirInner(emit: *Emit) anyerror!void { | ||
| 25 | const gpa = emit.bin_file.comp.gpa; | 21 | const gpa = emit.bin_file.comp.gpa; |
| 26 | var aw: std.io.AllocatingWriter = undefined; | 22 | var aw: std.io.AllocatingWriter = undefined; |
| 27 | const bw = aw.fromArrayList(gpa, emit.code); | 23 | const bw = aw.fromArrayList(gpa, emit.code); |
src/arch/riscv64/Mir.zig+1-1| ... | @@ -92,7 +92,7 @@ pub const Inst = struct { | ... | @@ -92,7 +92,7 @@ pub const Inst = struct { |
| 92 | }, | 92 | }, |
| 93 | }; | 93 | }; |
| 94 | 94 | ||
| 95 | pub fn format(inst: Inst, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void { | 95 | pub fn format(inst: Inst, bw: *std.io.BufferedWriter, comptime fmt: []const u8) !void { |
| 96 | assert(fmt.len == 0); | 96 | assert(fmt.len == 0); |
| 97 | try bw.print("Tag: {s}, Data: {s}", .{ @tagName(inst.tag), @tagName(inst.data) }); | 97 | try bw.print("Tag: {s}, Data: {s}", .{ @tagName(inst.tag), @tagName(inst.data) }); |
| 98 | } | 98 | } |
src/arch/riscv64/bits.zig+1-1| ... | @@ -256,7 +256,7 @@ pub const FrameIndex = enum(u32) { | ... | @@ -256,7 +256,7 @@ pub const FrameIndex = enum(u32) { |
| 256 | return @intFromEnum(fi) < named_count; | 256 | return @intFromEnum(fi) < named_count; |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | pub fn format(fi: FrameIndex, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void { | 259 | pub fn format(fi: FrameIndex, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void { |
| 260 | try bw.writeAll("FrameIndex"); | 260 | try bw.writeAll("FrameIndex"); |
| 261 | if (fi.isNamed()) | 261 | if (fi.isNamed()) |
| 262 | try bw.print(".{s}", .{@tagName(fi)}) | 262 | try bw.print(".{s}", .{@tagName(fi)}) |
src/arch/wasm/Emit.zig+3-7| ... | @@ -22,10 +22,6 @@ pub const Error = error{ | ... | @@ -22,10 +22,6 @@ pub const Error = error{ |
| 22 | }; | 22 | }; |
| 23 | 23 | ||
| 24 | pub fn lowerToCode(emit: *Emit) Error!void { | 24 | pub fn lowerToCode(emit: *Emit) Error!void { |
| 25 | return @errorCast(emit.lowerToCodeInner()); | ||
| 26 | } | ||
| 27 | |||
| 28 | fn lowerToCodeInner(emit: *Emit) anyerror!void { | ||
| 29 | const mir = &emit.mir; | 25 | const mir = &emit.mir; |
| 30 | const bw = emit.bw; | 26 | const bw = emit.bw; |
| 31 | const wasm = emit.wasm; | 27 | const wasm = emit.wasm; |
| ... | @@ -897,12 +893,12 @@ fn lowerToCodeInner(emit: *Emit) anyerror!void { | ... | @@ -897,12 +893,12 @@ fn lowerToCodeInner(emit: *Emit) anyerror!void { |
| 897 | } | 893 | } |
| 898 | 894 | ||
| 899 | /// Asserts 20 unused capacity. | 895 | /// Asserts 20 unused capacity. |
| 900 | fn encodeMemArg(bw: *std.io.BufferedWriter, mem_arg: Mir.MemArg) anyerror!void { | 896 | fn encodeMemArg(bw: *std.io.BufferedWriter, mem_arg: Mir.MemArg) std.io.Writer.Error!void { |
| 901 | try bw.writeLeb128(Wasm.Alignment.fromNonzeroByteUnits(mem_arg.alignment).toLog2Units()); | 897 | try bw.writeLeb128(Wasm.Alignment.fromNonzeroByteUnits(mem_arg.alignment).toLog2Units()); |
| 902 | try bw.writeLeb128(mem_arg.offset); | 898 | try bw.writeLeb128(mem_arg.offset); |
| 903 | } | 899 | } |
| 904 | 900 | ||
| 905 | fn uavRefObj(wasm: *Wasm, bw: *std.io.BufferedWriter, value: InternPool.Index, offset: i32, is_wasm32: bool) !void { | 901 | fn uavRefObj(wasm: *Wasm, bw: *std.io.BufferedWriter, value: InternPool.Index, offset: i32, is_wasm32: bool) std.io.Writer.Error!void { |
| 906 | const comp = wasm.base.comp; | 902 | const comp = wasm.base.comp; |
| 907 | const gpa = comp.gpa; | 903 | const gpa = comp.gpa; |
| 908 | const opcode: std.wasm.Opcode = if (is_wasm32) .i32_const else .i64_const; | 904 | const opcode: std.wasm.Opcode = if (is_wasm32) .i32_const else .i64_const; |
| ... | @@ -951,6 +947,6 @@ fn navRefOff(wasm: *Wasm, bw: *std.io.BufferedWriter, data: Mir.NavRefOff, is_wa | ... | @@ -951,6 +947,6 @@ fn navRefOff(wasm: *Wasm, bw: *std.io.BufferedWriter, data: Mir.NavRefOff, is_wa |
| 951 | } | 947 | } |
| 952 | } | 948 | } |
| 953 | 949 | ||
| 954 | fn appendOutputFunctionIndex(bw: *std.io.BufferedWriter, i: Wasm.OutputFunctionIndex) anyerror!void { | 950 | fn appendOutputFunctionIndex(bw: *std.io.BufferedWriter, i: Wasm.OutputFunctionIndex) std.io.Writer.Error!void { |
| 955 | return bw.writeLeb128(@intFromEnum(i)); | 951 | return bw.writeLeb128(@intFromEnum(i)); |
| 956 | } | 952 | } |
src/arch/x86_64/CodeGen.zig+6-6| ... | @@ -524,7 +524,7 @@ pub const MCValue = union(enum) { | ... | @@ -524,7 +524,7 @@ pub const MCValue = union(enum) { |
| 524 | }; | 524 | }; |
| 525 | } | 525 | } |
| 526 | 526 | ||
| 527 | pub fn format(mcv: MCValue, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void { | 527 | pub fn format(mcv: MCValue, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void { |
| 528 | switch (mcv) { | 528 | switch (mcv) { |
| 529 | .none, .unreach, .dead, .undef => try bw.print("({s})", .{@tagName(mcv)}), | 529 | .none, .unreach, .dead, .undef => try bw.print("({s})", .{@tagName(mcv)}), |
| 530 | .immediate => |pl| try bw.print("0x{x}", .{pl}), | 530 | .immediate => |pl| try bw.print("0x{x}", .{pl}), |
| ... | @@ -811,7 +811,7 @@ const InstTracking = struct { | ... | @@ -811,7 +811,7 @@ const InstTracking = struct { |
| 811 | } | 811 | } |
| 812 | } | 812 | } |
| 813 | 813 | ||
| 814 | pub fn format(tracking: InstTracking, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void { | 814 | pub fn format(tracking: InstTracking, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void { |
| 815 | if (!std.meta.eql(tracking.long, tracking.short)) try bw.print("|{f}| ", .{tracking.long}); | 815 | if (!std.meta.eql(tracking.long, tracking.short)) try bw.print("|{f}| ", .{tracking.long}); |
| 816 | try bw.print("{f}", .{tracking.short}); | 816 | try bw.print("{f}", .{tracking.short}); |
| 817 | } | 817 | } |
| ... | @@ -1087,7 +1087,7 @@ const FormatNavData = struct { | ... | @@ -1087,7 +1087,7 @@ const FormatNavData = struct { |
| 1087 | ip: *const InternPool, | 1087 | ip: *const InternPool, |
| 1088 | nav_index: InternPool.Nav.Index, | 1088 | nav_index: InternPool.Nav.Index, |
| 1089 | }; | 1089 | }; |
| 1090 | fn formatNav(data: FormatNavData, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void { | 1090 | fn formatNav(data: FormatNavData, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void { |
| 1091 | try bw.print("{f}", .{data.ip.getNav(data.nav_index).fqn.fmt(data.ip)}); | 1091 | try bw.print("{f}", .{data.ip.getNav(data.nav_index).fqn.fmt(data.ip)}); |
| 1092 | } | 1092 | } |
| 1093 | fn fmtNav(nav_index: InternPool.Nav.Index, ip: *const InternPool) std.fmt.Formatter(formatNav) { | 1093 | fn fmtNav(nav_index: InternPool.Nav.Index, ip: *const InternPool) std.fmt.Formatter(formatNav) { |
| ... | @@ -1101,7 +1101,7 @@ const FormatAirData = struct { | ... | @@ -1101,7 +1101,7 @@ const FormatAirData = struct { |
| 1101 | self: *CodeGen, | 1101 | self: *CodeGen, |
| 1102 | inst: Air.Inst.Index, | 1102 | inst: Air.Inst.Index, |
| 1103 | }; | 1103 | }; |
| 1104 | fn formatAir(data: FormatAirData, _: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void { | 1104 | fn formatAir(data: FormatAirData, _: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void { |
| 1105 | data.self.air.dumpInst(data.inst, data.self.pt, data.self.liveness); | 1105 | data.self.air.dumpInst(data.inst, data.self.pt, data.self.liveness); |
| 1106 | } | 1106 | } |
| 1107 | fn fmtAir(self: *CodeGen, inst: Air.Inst.Index) std.fmt.Formatter(formatAir) { | 1107 | fn fmtAir(self: *CodeGen, inst: Air.Inst.Index) std.fmt.Formatter(formatAir) { |
| ... | @@ -1112,7 +1112,7 @@ const FormatWipMirData = struct { | ... | @@ -1112,7 +1112,7 @@ const FormatWipMirData = struct { |
| 1112 | self: *CodeGen, | 1112 | self: *CodeGen, |
| 1113 | inst: Mir.Inst.Index, | 1113 | inst: Mir.Inst.Index, |
| 1114 | }; | 1114 | }; |
| 1115 | fn formatWipMir(data: FormatWipMirData, bw: *std.io.BufferedWriter, comptime _: []const u8) !void { | 1115 | fn formatWipMir(data: FormatWipMirData, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void { |
| 1116 | var lower: Lower = .{ | 1116 | var lower: Lower = .{ |
| 1117 | .target = data.self.target, | 1117 | .target = data.self.target, |
| 1118 | .allocator = data.self.gpa, | 1118 | .allocator = data.self.gpa, |
| ... | @@ -1208,7 +1208,7 @@ fn fmtWipMir(self: *CodeGen, inst: Mir.Inst.Index) std.fmt.Formatter(formatWipMi | ... | @@ -1208,7 +1208,7 @@ fn fmtWipMir(self: *CodeGen, inst: Mir.Inst.Index) std.fmt.Formatter(formatWipMi |
| 1208 | const FormatTrackingData = struct { | 1208 | const FormatTrackingData = struct { |
| 1209 | self: *CodeGen, | 1209 | self: *CodeGen, |
| 1210 | }; | 1210 | }; |
| 1211 | fn formatTracking(data: FormatTrackingData, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void { | 1211 | fn formatTracking(data: FormatTrackingData, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void { |
| 1212 | var it = data.self.inst_tracking.iterator(); | 1212 | var it = data.self.inst_tracking.iterator(); |
| 1213 | while (it.next()) |entry| try bw.print("\n{f} = {f}", .{ entry.key_ptr.*, entry.value_ptr.* }); | 1213 | while (it.next()) |entry| try bw.print("\n{f} = {f}", .{ entry.key_ptr.*, entry.value_ptr.* }); |
| 1214 | } | 1214 | } |
src/arch/x86_64/Disassembler.zig+3-7| ... | @@ -31,10 +31,6 @@ pub fn init(code: []const u8) Disassembler { | ... | @@ -31,10 +31,6 @@ pub fn init(code: []const u8) Disassembler { |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | pub fn next(dis: *Disassembler) Error!?Instruction { | 33 | pub fn next(dis: *Disassembler) Error!?Instruction { |
| 34 | return @errorCast(dis.nextInner()); | ||
| 35 | } | ||
| 36 | |||
| 37 | fn nextInner(dis: *Disassembler) anyerror!?Instruction { | ||
| 38 | const prefixes = try dis.parsePrefixes(); | 34 | const prefixes = try dis.parsePrefixes(); |
| 39 | 35 | ||
| 40 | const enc = try dis.parseEncoding(prefixes) orelse return error.UnknownOpcode; | 36 | const enc = try dis.parseEncoding(prefixes) orelse return error.UnknownOpcode; |
| ... | @@ -375,7 +371,7 @@ fn parseGpRegister(low_enc: u3, is_extended: bool, rex: Rex, bit_size: u64) Regi | ... | @@ -375,7 +371,7 @@ fn parseGpRegister(low_enc: u3, is_extended: bool, rex: Rex, bit_size: u64) Regi |
| 375 | }; | 371 | }; |
| 376 | } | 372 | } |
| 377 | 373 | ||
| 378 | fn parseImm(dis: *Disassembler, kind: Encoding.Op) anyerror!Immediate { | 374 | fn parseImm(dis: *Disassembler, kind: Encoding.Op) !Immediate { |
| 379 | var br: std.io.BufferedReader = undefined; | 375 | var br: std.io.BufferedReader = undefined; |
| 380 | br.initFixed(dis.code[dis.pos..]); | 376 | br.initFixed(dis.code[dis.pos..]); |
| 381 | defer dis.pos += br.seek; | 377 | defer dis.pos += br.seek; |
| ... | @@ -391,7 +387,7 @@ fn parseImm(dis: *Disassembler, kind: Encoding.Op) anyerror!Immediate { | ... | @@ -391,7 +387,7 @@ fn parseImm(dis: *Disassembler, kind: Encoding.Op) anyerror!Immediate { |
| 391 | }; | 387 | }; |
| 392 | } | 388 | } |
| 393 | 389 | ||
| 394 | fn parseOffset(dis: *Disassembler) anyerror!u64 { | 390 | fn parseOffset(dis: *Disassembler) !u64 { |
| 395 | var br: std.io.BufferedReader = undefined; | 391 | var br: std.io.BufferedReader = undefined; |
| 396 | br.initFixed(dis.code[dis.pos..]); | 392 | br.initFixed(dis.code[dis.pos..]); |
| 397 | defer dis.pos += br.seek; | 393 | defer dis.pos += br.seek; |
| ... | @@ -467,7 +463,7 @@ fn parseSibByte(dis: *Disassembler) !Sib { | ... | @@ -467,7 +463,7 @@ fn parseSibByte(dis: *Disassembler) !Sib { |
| 467 | return Sib{ .scale = scale, .index = index, .base = base }; | 463 | return Sib{ .scale = scale, .index = index, .base = base }; |
| 468 | } | 464 | } |
| 469 | 465 | ||
| 470 | fn parseDisplacement(dis: *Disassembler, modrm: ModRm, sib: ?Sib) anyerror!i32 { | 466 | fn parseDisplacement(dis: *Disassembler, modrm: ModRm, sib: ?Sib) !i32 { |
| 471 | var br: std.io.BufferedReader = undefined; | 467 | var br: std.io.BufferedReader = undefined; |
| 472 | br.initFixed(dis.code[dis.pos..]); | 468 | br.initFixed(dis.code[dis.pos..]); |
| 473 | defer dis.pos += br.seek; | 469 | defer dis.pos += br.seek; |
src/arch/x86_64/Emit.zig+1-1| ... | @@ -909,7 +909,7 @@ const Loc = struct { | ... | @@ -909,7 +909,7 @@ const Loc = struct { |
| 909 | is_stmt: bool, | 909 | is_stmt: bool, |
| 910 | }; | 910 | }; |
| 911 | 911 | ||
| 912 | fn dbgAdvancePCAndLine(emit: *Emit, loc: Loc, pc: usize) anyerror!void { | 912 | fn dbgAdvancePCAndLine(emit: *Emit, loc: Loc, pc: usize) Error!void { |
| 913 | const delta_line = @as(i33, loc.line) - @as(i33, emit.prev_di_loc.line); | 913 | const delta_line = @as(i33, loc.line) - @as(i33, emit.prev_di_loc.line); |
| 914 | const delta_pc = pc - emit.prev_di_pc; | 914 | const delta_pc = pc - emit.prev_di_pc; |
| 915 | log.debug(" (advance pc={d} and line={d})", .{ delta_pc, delta_line }); | 915 | log.debug(" (advance pc={d} and line={d})", .{ delta_pc, delta_line }); |
src/arch/x86_64/Encoding.zig+1-1| ... | @@ -158,7 +158,7 @@ pub fn modRmExt(encoding: Encoding) u3 { | ... | @@ -158,7 +158,7 @@ pub fn modRmExt(encoding: Encoding) u3 { |
| 158 | }; | 158 | }; |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | pub fn format(encoding: Encoding, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void { | 161 | pub fn format(encoding: Encoding, bw: *std.io.BufferedWriter, comptime fmt: []const u8) !void { |
| 162 | _ = fmt; | 162 | _ = fmt; |
| 163 | 163 | ||
| 164 | var opc = encoding.opcode(); | 164 | var opc = encoding.opcode(); |
src/arch/x86_64/bits.zig+2-2| ... | @@ -728,7 +728,7 @@ pub const FrameIndex = enum(u32) { | ... | @@ -728,7 +728,7 @@ pub const FrameIndex = enum(u32) { |
| 728 | return @intFromEnum(fi) < named_count; | 728 | return @intFromEnum(fi) < named_count; |
| 729 | } | 729 | } |
| 730 | 730 | ||
| 731 | pub fn format(fi: FrameIndex, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void { | 731 | pub fn format(fi: FrameIndex, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void { |
| 732 | try bw.writeAll("FrameIndex"); | 732 | try bw.writeAll("FrameIndex"); |
| 733 | if (fi.isNamed()) | 733 | if (fi.isNamed()) |
| 734 | try bw.print(".{s}", .{@tagName(fi)}) | 734 | try bw.print(".{s}", .{@tagName(fi)}) |
| ... | @@ -835,7 +835,7 @@ pub const Memory = struct { | ... | @@ -835,7 +835,7 @@ pub const Memory = struct { |
| 835 | }; | 835 | }; |
| 836 | } | 836 | } |
| 837 | 837 | ||
| 838 | pub fn format(s: Size, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void { | 838 | pub fn format(s: Size, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void { |
| 839 | if (s == .none) return; | 839 | if (s == .none) return; |
| 840 | try bw.writeAll(@tagName(s)); | 840 | try bw.writeAll(@tagName(s)); |
| 841 | switch (s) { | 841 | switch (s) { |
src/arch/x86_64/encoder.zig+35-35| ... | @@ -226,7 +226,7 @@ pub const Instruction = struct { | ... | @@ -226,7 +226,7 @@ pub const Instruction = struct { |
| 226 | }; | 226 | }; |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | fn format(op: Operand, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void { | 229 | fn format(op: Operand, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) !void { |
| 230 | _ = op; | 230 | _ = op; |
| 231 | _ = bw; | 231 | _ = bw; |
| 232 | _ = unused_format_string; | 232 | _ = unused_format_string; |
| ... | @@ -238,7 +238,7 @@ pub const Instruction = struct { | ... | @@ -238,7 +238,7 @@ pub const Instruction = struct { |
| 238 | enc_op: Encoding.Op, | 238 | enc_op: Encoding.Op, |
| 239 | }; | 239 | }; |
| 240 | 240 | ||
| 241 | fn fmtContext(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void { | 241 | fn fmtContext(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) std.io.Writer.Error!void { |
| 242 | _ = unused_format_string; | 242 | _ = unused_format_string; |
| 243 | const op = ctx.op; | 243 | const op = ctx.op; |
| 244 | const enc_op = ctx.enc_op; | 244 | const enc_op = ctx.enc_op; |
| ... | @@ -360,7 +360,7 @@ pub const Instruction = struct { | ... | @@ -360,7 +360,7 @@ pub const Instruction = struct { |
| 360 | return inst; | 360 | return inst; |
| 361 | } | 361 | } |
| 362 | 362 | ||
| 363 | pub fn format(inst: Instruction, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void { | 363 | pub fn format(inst: Instruction, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) std.io.Writer.Error!void { |
| 364 | _ = unused_format_string; | 364 | _ = unused_format_string; |
| 365 | switch (inst.prefix) { | 365 | switch (inst.prefix) { |
| 366 | .none, .directive => {}, | 366 | .none, .directive => {}, |
| ... | @@ -794,7 +794,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -794,7 +794,7 @@ fn Encoder(comptime opts: Options) type { |
| 794 | // -------- | 794 | // -------- |
| 795 | 795 | ||
| 796 | /// Encodes legacy prefixes | 796 | /// Encodes legacy prefixes |
| 797 | pub fn legacyPrefixes(self: Self, prefixes: LegacyPrefixes) anyerror!void { | 797 | pub fn legacyPrefixes(self: Self, prefixes: LegacyPrefixes) !void { |
| 798 | if (@as(u16, @bitCast(prefixes)) != 0) { | 798 | if (@as(u16, @bitCast(prefixes)) != 0) { |
| 799 | // Hopefully this path isn't taken very often, so we'll do it the slow way for now | 799 | // Hopefully this path isn't taken very often, so we'll do it the slow way for now |
| 800 | 800 | ||
| ... | @@ -830,7 +830,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -830,7 +830,7 @@ fn Encoder(comptime opts: Options) type { |
| 830 | /// Use 16 bit operand size | 830 | /// Use 16 bit operand size |
| 831 | /// | 831 | /// |
| 832 | /// Note that this flag is overridden by REX.W, if both are present. | 832 | /// Note that this flag is overridden by REX.W, if both are present. |
| 833 | pub fn prefix16BitMode(self: Self) anyerror!void { | 833 | pub fn prefix16BitMode(self: Self) !void { |
| 834 | try self.bw.writeByte(0x66); | 834 | try self.bw.writeByte(0x66); |
| 835 | } | 835 | } |
| 836 | 836 | ||
| ... | @@ -840,7 +840,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -840,7 +840,7 @@ fn Encoder(comptime opts: Options) type { |
| 840 | /// or one of reg, index, r/m, base, or opcode-reg might be extended. | 840 | /// or one of reg, index, r/m, base, or opcode-reg might be extended. |
| 841 | /// | 841 | /// |
| 842 | /// See struct `Rex` for a description of each field. | 842 | /// See struct `Rex` for a description of each field. |
| 843 | pub fn rex(self: Self, fields: Rex) anyerror!void { | 843 | pub fn rex(self: Self, fields: Rex) !void { |
| 844 | if (!fields.present and !fields.isSet()) return; | 844 | if (!fields.present and !fields.isSet()) return; |
| 845 | 845 | ||
| 846 | var byte: u8 = 0b0100_0000; | 846 | var byte: u8 = 0b0100_0000; |
| ... | @@ -856,7 +856,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -856,7 +856,7 @@ fn Encoder(comptime opts: Options) type { |
| 856 | /// Encodes a VEX prefix given all the fields | 856 | /// Encodes a VEX prefix given all the fields |
| 857 | /// | 857 | /// |
| 858 | /// See struct `Vex` for a description of each field. | 858 | /// See struct `Vex` for a description of each field. |
| 859 | pub fn vex(self: Self, fields: Vex) anyerror!void { | 859 | pub fn vex(self: Self, fields: Vex) !void { |
| 860 | if (fields.is3Byte()) { | 860 | if (fields.is3Byte()) { |
| 861 | try self.bw.writeByte(0b1100_0100); | 861 | try self.bw.writeByte(0b1100_0100); |
| 862 | 862 | ||
| ... | @@ -889,7 +889,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -889,7 +889,7 @@ fn Encoder(comptime opts: Options) type { |
| 889 | // ------ | 889 | // ------ |
| 890 | 890 | ||
| 891 | /// Encodes a 1 byte opcode | 891 | /// Encodes a 1 byte opcode |
| 892 | pub fn opcode_1byte(self: Self, opcode: u8) anyerror!void { | 892 | pub fn opcode_1byte(self: Self, opcode: u8) !void { |
| 893 | try self.bw.writeByte(opcode); | 893 | try self.bw.writeByte(opcode); |
| 894 | } | 894 | } |
| 895 | 895 | ||
| ... | @@ -898,7 +898,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -898,7 +898,7 @@ fn Encoder(comptime opts: Options) type { |
| 898 | /// e.g. IMUL has the opcode 0x0f 0xaf, so you use | 898 | /// e.g. IMUL has the opcode 0x0f 0xaf, so you use |
| 899 | /// | 899 | /// |
| 900 | /// encoder.opcode_2byte(0x0f, 0xaf); | 900 | /// encoder.opcode_2byte(0x0f, 0xaf); |
| 901 | pub fn opcode_2byte(self: Self, prefix: u8, opcode: u8) anyerror!void { | 901 | pub fn opcode_2byte(self: Self, prefix: u8, opcode: u8) !void { |
| 902 | try self.bw.writeAll(&.{ prefix, opcode }); | 902 | try self.bw.writeAll(&.{ prefix, opcode }); |
| 903 | } | 903 | } |
| 904 | 904 | ||
| ... | @@ -907,14 +907,14 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -907,14 +907,14 @@ fn Encoder(comptime opts: Options) type { |
| 907 | /// e.g. MOVSD has the opcode 0xf2 0x0f 0x10 | 907 | /// e.g. MOVSD has the opcode 0xf2 0x0f 0x10 |
| 908 | /// | 908 | /// |
| 909 | /// encoder.opcode_3byte(0xf2, 0x0f, 0x10); | 909 | /// encoder.opcode_3byte(0xf2, 0x0f, 0x10); |
| 910 | pub fn opcode_3byte(self: Self, prefix_1: u8, prefix_2: u8, opcode: u8) anyerror!void { | 910 | pub fn opcode_3byte(self: Self, prefix_1: u8, prefix_2: u8, opcode: u8) !void { |
| 911 | try self.bw.writeAll(&.{ prefix_1, prefix_2, opcode }); | 911 | try self.bw.writeAll(&.{ prefix_1, prefix_2, opcode }); |
| 912 | } | 912 | } |
| 913 | 913 | ||
| 914 | /// Encodes a 1 byte opcode with a reg field | 914 | /// Encodes a 1 byte opcode with a reg field |
| 915 | /// | 915 | /// |
| 916 | /// Remember to add a REX prefix byte if reg is extended! | 916 | /// Remember to add a REX prefix byte if reg is extended! |
| 917 | pub fn opcode_withReg(self: Self, opcode: u8, reg: u3) anyerror!void { | 917 | pub fn opcode_withReg(self: Self, opcode: u8, reg: u3) !void { |
| 918 | assert(opcode & 0b111 == 0); | 918 | assert(opcode & 0b111 == 0); |
| 919 | try self.bw.writeByte(opcode | reg); | 919 | try self.bw.writeByte(opcode | reg); |
| 920 | } | 920 | } |
| ... | @@ -926,7 +926,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -926,7 +926,7 @@ fn Encoder(comptime opts: Options) type { |
| 926 | /// Construct a ModR/M byte given all the fields | 926 | /// Construct a ModR/M byte given all the fields |
| 927 | /// | 927 | /// |
| 928 | /// Remember to add a REX prefix byte if reg or rm are extended! | 928 | /// Remember to add a REX prefix byte if reg or rm are extended! |
| 929 | pub fn modRm(self: Self, mod: u2, reg_or_opx: u3, rm: u3) anyerror!void { | 929 | pub fn modRm(self: Self, mod: u2, reg_or_opx: u3, rm: u3) !void { |
| 930 | try self.bw.writeByte(@as(u8, mod) << 6 | @as(u8, reg_or_opx) << 3 | rm); | 930 | try self.bw.writeByte(@as(u8, mod) << 6 | @as(u8, reg_or_opx) << 3 | rm); |
| 931 | } | 931 | } |
| 932 | 932 | ||
| ... | @@ -935,7 +935,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -935,7 +935,7 @@ fn Encoder(comptime opts: Options) type { |
| 935 | /// | 935 | /// |
| 936 | /// Note reg's effective address is always just reg for the ModR/M byte. | 936 | /// Note reg's effective address is always just reg for the ModR/M byte. |
| 937 | /// Remember to add a REX prefix byte if reg or rm are extended! | 937 | /// Remember to add a REX prefix byte if reg or rm are extended! |
| 938 | pub fn modRm_direct(self: Self, reg_or_opx: u3, rm: u3) anyerror!void { | 938 | pub fn modRm_direct(self: Self, reg_or_opx: u3, rm: u3) !void { |
| 939 | try self.modRm(0b11, reg_or_opx, rm); | 939 | try self.modRm(0b11, reg_or_opx, rm); |
| 940 | } | 940 | } |
| 941 | 941 | ||
| ... | @@ -944,7 +944,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -944,7 +944,7 @@ fn Encoder(comptime opts: Options) type { |
| 944 | /// | 944 | /// |
| 945 | /// Note reg's effective address is always just reg for the ModR/M byte. | 945 | /// Note reg's effective address is always just reg for the ModR/M byte. |
| 946 | /// Remember to add a REX prefix byte if reg or rm are extended! | 946 | /// Remember to add a REX prefix byte if reg or rm are extended! |
| 947 | pub fn modRm_indirectDisp0(self: Self, reg_or_opx: u3, rm: u3) anyerror!void { | 947 | pub fn modRm_indirectDisp0(self: Self, reg_or_opx: u3, rm: u3) !void { |
| 948 | assert(rm != 4 and rm != 5); | 948 | assert(rm != 4 and rm != 5); |
| 949 | try self.modRm(0b00, reg_or_opx, rm); | 949 | try self.modRm(0b00, reg_or_opx, rm); |
| 950 | } | 950 | } |
| ... | @@ -954,7 +954,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -954,7 +954,7 @@ fn Encoder(comptime opts: Options) type { |
| 954 | /// | 954 | /// |
| 955 | /// Note reg's effective address is always just reg for the ModR/M byte. | 955 | /// Note reg's effective address is always just reg for the ModR/M byte. |
| 956 | /// Remember to add a REX prefix byte if reg or rm are extended! | 956 | /// Remember to add a REX prefix byte if reg or rm are extended! |
| 957 | pub fn modRm_SIBDisp0(self: Self, reg_or_opx: u3) anyerror!void { | 957 | pub fn modRm_SIBDisp0(self: Self, reg_or_opx: u3) !void { |
| 958 | try self.modRm(0b00, reg_or_opx, 0b100); | 958 | try self.modRm(0b00, reg_or_opx, 0b100); |
| 959 | } | 959 | } |
| 960 | 960 | ||
| ... | @@ -963,7 +963,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -963,7 +963,7 @@ fn Encoder(comptime opts: Options) type { |
| 963 | /// | 963 | /// |
| 964 | /// Note reg's effective address is always just reg for the ModR/M byte. | 964 | /// Note reg's effective address is always just reg for the ModR/M byte. |
| 965 | /// Remember to add a REX prefix byte if reg or rm are extended! | 965 | /// Remember to add a REX prefix byte if reg or rm are extended! |
| 966 | pub fn modRm_RIPDisp32(self: Self, reg_or_opx: u3) anyerror!void { | 966 | pub fn modRm_RIPDisp32(self: Self, reg_or_opx: u3) !void { |
| 967 | try self.modRm(0b00, reg_or_opx, 0b101); | 967 | try self.modRm(0b00, reg_or_opx, 0b101); |
| 968 | } | 968 | } |
| 969 | 969 | ||
| ... | @@ -972,7 +972,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -972,7 +972,7 @@ fn Encoder(comptime opts: Options) type { |
| 972 | /// | 972 | /// |
| 973 | /// Note reg's effective address is always just reg for the ModR/M byte. | 973 | /// Note reg's effective address is always just reg for the ModR/M byte. |
| 974 | /// Remember to add a REX prefix byte if reg or rm are extended! | 974 | /// Remember to add a REX prefix byte if reg or rm are extended! |
| 975 | pub fn modRm_indirectDisp8(self: Self, reg_or_opx: u3, rm: u3) anyerror!void { | 975 | pub fn modRm_indirectDisp8(self: Self, reg_or_opx: u3, rm: u3) !void { |
| 976 | assert(rm != 4); | 976 | assert(rm != 4); |
| 977 | try self.modRm(0b01, reg_or_opx, rm); | 977 | try self.modRm(0b01, reg_or_opx, rm); |
| 978 | } | 978 | } |
| ... | @@ -982,7 +982,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -982,7 +982,7 @@ fn Encoder(comptime opts: Options) type { |
| 982 | /// | 982 | /// |
| 983 | /// Note reg's effective address is always just reg for the ModR/M byte. | 983 | /// Note reg's effective address is always just reg for the ModR/M byte. |
| 984 | /// Remember to add a REX prefix byte if reg or rm are extended! | 984 | /// Remember to add a REX prefix byte if reg or rm are extended! |
| 985 | pub fn modRm_SIBDisp8(self: Self, reg_or_opx: u3) anyerror!void { | 985 | pub fn modRm_SIBDisp8(self: Self, reg_or_opx: u3) !void { |
| 986 | try self.modRm(0b01, reg_or_opx, 0b100); | 986 | try self.modRm(0b01, reg_or_opx, 0b100); |
| 987 | } | 987 | } |
| 988 | 988 | ||
| ... | @@ -991,7 +991,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -991,7 +991,7 @@ fn Encoder(comptime opts: Options) type { |
| 991 | /// | 991 | /// |
| 992 | /// Note reg's effective address is always just reg for the ModR/M byte. | 992 | /// Note reg's effective address is always just reg for the ModR/M byte. |
| 993 | /// Remember to add a REX prefix byte if reg or rm are extended! | 993 | /// Remember to add a REX prefix byte if reg or rm are extended! |
| 994 | pub fn modRm_indirectDisp32(self: Self, reg_or_opx: u3, rm: u3) anyerror!void { | 994 | pub fn modRm_indirectDisp32(self: Self, reg_or_opx: u3, rm: u3) !void { |
| 995 | assert(rm != 4); | 995 | assert(rm != 4); |
| 996 | try self.modRm(0b10, reg_or_opx, rm); | 996 | try self.modRm(0b10, reg_or_opx, rm); |
| 997 | } | 997 | } |
| ... | @@ -1001,7 +1001,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -1001,7 +1001,7 @@ fn Encoder(comptime opts: Options) type { |
| 1001 | /// | 1001 | /// |
| 1002 | /// Note reg's effective address is always just reg for the ModR/M byte. | 1002 | /// Note reg's effective address is always just reg for the ModR/M byte. |
| 1003 | /// Remember to add a REX prefix byte if reg or rm are extended! | 1003 | /// Remember to add a REX prefix byte if reg or rm are extended! |
| 1004 | pub fn modRm_SIBDisp32(self: Self, reg_or_opx: u3) anyerror!void { | 1004 | pub fn modRm_SIBDisp32(self: Self, reg_or_opx: u3) !void { |
| 1005 | try self.modRm(0b10, reg_or_opx, 0b100); | 1005 | try self.modRm(0b10, reg_or_opx, 0b100); |
| 1006 | } | 1006 | } |
| 1007 | 1007 | ||
| ... | @@ -1012,7 +1012,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -1012,7 +1012,7 @@ fn Encoder(comptime opts: Options) type { |
| 1012 | /// Construct a SIB byte given all the fields | 1012 | /// Construct a SIB byte given all the fields |
| 1013 | /// | 1013 | /// |
| 1014 | /// Remember to add a REX prefix byte if index or base are extended! | 1014 | /// Remember to add a REX prefix byte if index or base are extended! |
| 1015 | pub fn sib(self: Self, scale: u2, index: u3, base: u3) anyerror!void { | 1015 | pub fn sib(self: Self, scale: u2, index: u3, base: u3) !void { |
| 1016 | try self.bw.writeByte(@as(u8, scale) << 6 | @as(u8, index) << 3 | base); | 1016 | try self.bw.writeByte(@as(u8, scale) << 6 | @as(u8, index) << 3 | base); |
| 1017 | } | 1017 | } |
| 1018 | 1018 | ||
| ... | @@ -1020,7 +1020,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -1020,7 +1020,7 @@ fn Encoder(comptime opts: Options) type { |
| 1020 | /// r/m effective address: [base + scale * index] | 1020 | /// r/m effective address: [base + scale * index] |
| 1021 | /// | 1021 | /// |
| 1022 | /// Remember to add a REX prefix byte if index or base are extended! | 1022 | /// Remember to add a REX prefix byte if index or base are extended! |
| 1023 | pub fn sib_scaleIndexBase(self: Self, scale: u2, index: u3, base: u3) anyerror!void { | 1023 | pub fn sib_scaleIndexBase(self: Self, scale: u2, index: u3, base: u3) !void { |
| 1024 | assert(base != 5); | 1024 | assert(base != 5); |
| 1025 | 1025 | ||
| 1026 | try self.sib(scale, index, base); | 1026 | try self.sib(scale, index, base); |
| ... | @@ -1030,7 +1030,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -1030,7 +1030,7 @@ fn Encoder(comptime opts: Options) type { |
| 1030 | /// r/m effective address: [scale * index + disp32] | 1030 | /// r/m effective address: [scale * index + disp32] |
| 1031 | /// | 1031 | /// |
| 1032 | /// Remember to add a REX prefix byte if index or base are extended! | 1032 | /// Remember to add a REX prefix byte if index or base are extended! |
| 1033 | pub fn sib_scaleIndexDisp32(self: Self, scale: u2, index: u3) anyerror!void { | 1033 | pub fn sib_scaleIndexDisp32(self: Self, scale: u2, index: u3) !void { |
| 1034 | // scale is actually ignored | 1034 | // scale is actually ignored |
| 1035 | // index = 4 means no index if and only if we haven't extended the register | 1035 | // index = 4 means no index if and only if we haven't extended the register |
| 1036 | // TODO enforce this | 1036 | // TODO enforce this |
| ... | @@ -1042,7 +1042,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -1042,7 +1042,7 @@ fn Encoder(comptime opts: Options) type { |
| 1042 | /// r/m effective address: [base] | 1042 | /// r/m effective address: [base] |
| 1043 | /// | 1043 | /// |
| 1044 | /// Remember to add a REX prefix byte if index or base are extended! | 1044 | /// Remember to add a REX prefix byte if index or base are extended! |
| 1045 | pub fn sib_base(self: Self, base: u3) anyerror!void { | 1045 | pub fn sib_base(self: Self, base: u3) !void { |
| 1046 | assert(base != 5); | 1046 | assert(base != 5); |
| 1047 | 1047 | ||
| 1048 | // scale is actually ignored | 1048 | // scale is actually ignored |
| ... | @@ -1054,7 +1054,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -1054,7 +1054,7 @@ fn Encoder(comptime opts: Options) type { |
| 1054 | /// r/m effective address: [disp32] | 1054 | /// r/m effective address: [disp32] |
| 1055 | /// | 1055 | /// |
| 1056 | /// Remember to add a REX prefix byte if index or base are extended! | 1056 | /// Remember to add a REX prefix byte if index or base are extended! |
| 1057 | pub fn sib_disp32(self: Self) anyerror!void { | 1057 | pub fn sib_disp32(self: Self) !void { |
| 1058 | // scale is actually ignored | 1058 | // scale is actually ignored |
| 1059 | // index = 4 means no index | 1059 | // index = 4 means no index |
| 1060 | // base = 5 means no base, if mod == 0. | 1060 | // base = 5 means no base, if mod == 0. |
| ... | @@ -1065,7 +1065,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -1065,7 +1065,7 @@ fn Encoder(comptime opts: Options) type { |
| 1065 | /// r/m effective address: [base + scale * index + disp8] | 1065 | /// r/m effective address: [base + scale * index + disp8] |
| 1066 | /// | 1066 | /// |
| 1067 | /// Remember to add a REX prefix byte if index or base are extended! | 1067 | /// Remember to add a REX prefix byte if index or base are extended! |
| 1068 | pub fn sib_scaleIndexBaseDisp8(self: Self, scale: u2, index: u3, base: u3) anyerror!void { | 1068 | pub fn sib_scaleIndexBaseDisp8(self: Self, scale: u2, index: u3, base: u3) !void { |
| 1069 | try self.sib(scale, index, base); | 1069 | try self.sib(scale, index, base); |
| 1070 | } | 1070 | } |
| 1071 | 1071 | ||
| ... | @@ -1073,7 +1073,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -1073,7 +1073,7 @@ fn Encoder(comptime opts: Options) type { |
| 1073 | /// r/m effective address: [base + disp8] | 1073 | /// r/m effective address: [base + disp8] |
| 1074 | /// | 1074 | /// |
| 1075 | /// Remember to add a REX prefix byte if index or base are extended! | 1075 | /// Remember to add a REX prefix byte if index or base are extended! |
| 1076 | pub fn sib_baseDisp8(self: Self, base: u3) anyerror!void { | 1076 | pub fn sib_baseDisp8(self: Self, base: u3) !void { |
| 1077 | // scale is ignored | 1077 | // scale is ignored |
| 1078 | // index = 4 means no index | 1078 | // index = 4 means no index |
| 1079 | try self.sib(0, 4, base); | 1079 | try self.sib(0, 4, base); |
| ... | @@ -1083,7 +1083,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -1083,7 +1083,7 @@ fn Encoder(comptime opts: Options) type { |
| 1083 | /// r/m effective address: [base + scale * index + disp32] | 1083 | /// r/m effective address: [base + scale * index + disp32] |
| 1084 | /// | 1084 | /// |
| 1085 | /// Remember to add a REX prefix byte if index or base are extended! | 1085 | /// Remember to add a REX prefix byte if index or base are extended! |
| 1086 | pub fn sib_scaleIndexBaseDisp32(self: Self, scale: u2, index: u3, base: u3) anyerror!void { | 1086 | pub fn sib_scaleIndexBaseDisp32(self: Self, scale: u2, index: u3, base: u3) !void { |
| 1087 | try self.sib(scale, index, base); | 1087 | try self.sib(scale, index, base); |
| 1088 | } | 1088 | } |
| 1089 | 1089 | ||
| ... | @@ -1091,7 +1091,7 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -1091,7 +1091,7 @@ fn Encoder(comptime opts: Options) type { |
| 1091 | /// r/m effective address: [base + disp32] | 1091 | /// r/m effective address: [base + disp32] |
| 1092 | /// | 1092 | /// |
| 1093 | /// Remember to add a REX prefix byte if index or base are extended! | 1093 | /// Remember to add a REX prefix byte if index or base are extended! |
| 1094 | pub fn sib_baseDisp32(self: Self, base: u3) anyerror!void { | 1094 | pub fn sib_baseDisp32(self: Self, base: u3) !void { |
| 1095 | // scale is ignored | 1095 | // scale is ignored |
| 1096 | // index = 4 means no index | 1096 | // index = 4 means no index |
| 1097 | try self.sib(0, 4, base); | 1097 | try self.sib(0, 4, base); |
| ... | @@ -1104,42 +1104,42 @@ fn Encoder(comptime opts: Options) type { | ... | @@ -1104,42 +1104,42 @@ fn Encoder(comptime opts: Options) type { |
| 1104 | /// Encode an 8 bit displacement | 1104 | /// Encode an 8 bit displacement |
| 1105 | /// | 1105 | /// |
| 1106 | /// It is sign-extended to 64 bits by the cpu. | 1106 | /// It is sign-extended to 64 bits by the cpu. |
| 1107 | pub fn disp8(self: Self, disp: i8) anyerror!void { | 1107 | pub fn disp8(self: Self, disp: i8) !void { |
| 1108 | try self.bw.writeByte(@as(u8, @bitCast(disp))); | 1108 | try self.bw.writeByte(@as(u8, @bitCast(disp))); |
| 1109 | } | 1109 | } |
| 1110 | 1110 | ||
| 1111 | /// Encode an 32 bit displacement | 1111 | /// Encode an 32 bit displacement |
| 1112 | /// | 1112 | /// |
| 1113 | /// It is sign-extended to 64 bits by the cpu. | 1113 | /// It is sign-extended to 64 bits by the cpu. |
| 1114 | pub fn disp32(self: Self, disp: i32) anyerror!void { | 1114 | pub fn disp32(self: Self, disp: i32) !void { |
| 1115 | try self.bw.writeInt(i32, disp, .little); | 1115 | try self.bw.writeInt(i32, disp, .little); |
| 1116 | } | 1116 | } |
| 1117 | 1117 | ||
| 1118 | /// Encode an 8 bit immediate | 1118 | /// Encode an 8 bit immediate |
| 1119 | /// | 1119 | /// |
| 1120 | /// It is sign-extended to 64 bits by the cpu. | 1120 | /// It is sign-extended to 64 bits by the cpu. |
| 1121 | pub fn imm8(self: Self, imm: u8) anyerror!void { | 1121 | pub fn imm8(self: Self, imm: u8) !void { |
| 1122 | try self.bw.writeByte(imm); | 1122 | try self.bw.writeByte(imm); |
| 1123 | } | 1123 | } |
| 1124 | 1124 | ||
| 1125 | /// Encode an 16 bit immediate | 1125 | /// Encode an 16 bit immediate |
| 1126 | /// | 1126 | /// |
| 1127 | /// It is sign-extended to 64 bits by the cpu. | 1127 | /// It is sign-extended to 64 bits by the cpu. |
| 1128 | pub fn imm16(self: Self, imm: u16) anyerror!void { | 1128 | pub fn imm16(self: Self, imm: u16) !void { |
| 1129 | try self.bw.writeInt(u16, imm, .little); | 1129 | try self.bw.writeInt(u16, imm, .little); |
| 1130 | } | 1130 | } |
| 1131 | 1131 | ||
| 1132 | /// Encode an 32 bit immediate | 1132 | /// Encode an 32 bit immediate |
| 1133 | /// | 1133 | /// |
| 1134 | /// It is sign-extended to 64 bits by the cpu. | 1134 | /// It is sign-extended to 64 bits by the cpu. |
| 1135 | pub fn imm32(self: Self, imm: u32) anyerror!void { | 1135 | pub fn imm32(self: Self, imm: u32) !void { |
| 1136 | try self.bw.writeInt(u32, imm, .little); | 1136 | try self.bw.writeInt(u32, imm, .little); |
| 1137 | } | 1137 | } |
| 1138 | 1138 | ||
| 1139 | /// Encode an 64 bit immediate | 1139 | /// Encode an 64 bit immediate |
| 1140 | /// | 1140 | /// |
| 1141 | /// It is sign-extended to 64 bits by the cpu. | 1141 | /// It is sign-extended to 64 bits by the cpu. |
| 1142 | pub fn imm64(self: Self, imm: u64) anyerror!void { | 1142 | pub fn imm64(self: Self, imm: u64) !void { |
| 1143 | try self.bw.writeInt(u64, imm, .little); | 1143 | try self.bw.writeInt(u64, imm, .little); |
| 1144 | } | 1144 | } |
| 1145 | }; | 1145 | }; |
src/codegen.zig+8-5| ... | @@ -316,7 +316,10 @@ pub fn generateSymbol( | ... | @@ -316,7 +316,10 @@ pub fn generateSymbol( |
| 316 | var aw: std.io.AllocatingWriter = undefined; | 316 | var aw: std.io.AllocatingWriter = undefined; |
| 317 | const bw = aw.fromArrayList(pt.zcu.gpa, code); | 317 | const bw = aw.fromArrayList(pt.zcu.gpa, code); |
| 318 | defer code.* = aw.toArrayList(); | 318 | defer code.* = aw.toArrayList(); |
| 319 | return @errorCast(generateSymbolInner(bin_file, pt, src_loc, val, bw, reloc_parent)); | 319 | return generateSymbolInner(bin_file, pt, src_loc, val, bw, reloc_parent) catch |err| switch (err) { |
| 320 | error.WriteFailed => return error.OutOfMemory, | ||
| 321 | else => |e| return e, | ||
| 322 | }; | ||
| 320 | } | 323 | } |
| 321 | pub fn generateSymbolInner( | 324 | pub fn generateSymbolInner( |
| 322 | bin_file: *link.File, | 325 | bin_file: *link.File, |
| ... | @@ -325,7 +328,7 @@ pub fn generateSymbolInner( | ... | @@ -325,7 +328,7 @@ pub fn generateSymbolInner( |
| 325 | val: Value, | 328 | val: Value, |
| 326 | bw: *std.io.BufferedWriter, | 329 | bw: *std.io.BufferedWriter, |
| 327 | reloc_parent: link.File.RelocInfo.Parent, | 330 | reloc_parent: link.File.RelocInfo.Parent, |
| 328 | ) anyerror!void { | 331 | ) GenerateSymbolError!void { |
| 329 | const zcu = pt.zcu; | 332 | const zcu = pt.zcu; |
| 330 | const ip = &zcu.intern_pool; | 333 | const ip = &zcu.intern_pool; |
| 331 | const ty = val.typeOf(zcu); | 334 | const ty = val.typeOf(zcu); |
| ... | @@ -710,7 +713,7 @@ fn lowerPtr( | ... | @@ -710,7 +713,7 @@ fn lowerPtr( |
| 710 | bw: *std.io.BufferedWriter, | 713 | bw: *std.io.BufferedWriter, |
| 711 | reloc_parent: link.File.RelocInfo.Parent, | 714 | reloc_parent: link.File.RelocInfo.Parent, |
| 712 | prev_offset: u64, | 715 | prev_offset: u64, |
| 713 | ) anyerror!void { | 716 | ) GenerateSymbolError!void { |
| 714 | const zcu = pt.zcu; | 717 | const zcu = pt.zcu; |
| 715 | const ptr = zcu.intern_pool.indexToKey(ptr_val).ptr; | 718 | const ptr = zcu.intern_pool.indexToKey(ptr_val).ptr; |
| 716 | const offset: u64 = prev_offset + ptr.byte_offset; | 719 | const offset: u64 = prev_offset + ptr.byte_offset; |
| ... | @@ -763,7 +766,7 @@ fn lowerUavRef( | ... | @@ -763,7 +766,7 @@ fn lowerUavRef( |
| 763 | bw: *std.io.BufferedWriter, | 766 | bw: *std.io.BufferedWriter, |
| 764 | reloc_parent: link.File.RelocInfo.Parent, | 767 | reloc_parent: link.File.RelocInfo.Parent, |
| 765 | offset: u64, | 768 | offset: u64, |
| 766 | ) anyerror!void { | 769 | ) GenerateSymbolError!void { |
| 767 | const zcu = pt.zcu; | 770 | const zcu = pt.zcu; |
| 768 | const ip = &zcu.intern_pool; | 771 | const ip = &zcu.intern_pool; |
| 769 | const comp = lf.comp; | 772 | const comp = lf.comp; |
| ... | @@ -817,7 +820,7 @@ fn lowerNavRef( | ... | @@ -817,7 +820,7 @@ fn lowerNavRef( |
| 817 | bw: *std.io.BufferedWriter, | 820 | bw: *std.io.BufferedWriter, |
| 818 | reloc_parent: link.File.RelocInfo.Parent, | 821 | reloc_parent: link.File.RelocInfo.Parent, |
| 819 | offset: u64, | 822 | offset: u64, |
| 820 | ) anyerror!void { | 823 | ) GenerateSymbolError!void { |
| 821 | const zcu = pt.zcu; | 824 | const zcu = pt.zcu; |
| 822 | const gpa = zcu.gpa; | 825 | const gpa = zcu.gpa; |
| 823 | const ip = &zcu.intern_pool; | 826 | const ip = &zcu.intern_pool; |
src/codegen/c.zig+4-4| ... | @@ -8137,7 +8137,7 @@ const StringLiteral = struct { | ... | @@ -8137,7 +8137,7 @@ const StringLiteral = struct { |
| 8137 | }; | 8137 | }; |
| 8138 | } | 8138 | } |
| 8139 | 8139 | ||
| 8140 | pub fn start(self: *StringLiteral) anyerror!void { | 8140 | pub fn start(self: *StringLiteral) std.io.Writer.Error!void { |
| 8141 | const writer = self.writer; | 8141 | const writer = self.writer; |
| 8142 | if (self.len <= max_string_initializer_len) { | 8142 | if (self.len <= max_string_initializer_len) { |
| 8143 | self.bytes_written += try writer.writeByteCount('\"'); | 8143 | self.bytes_written += try writer.writeByteCount('\"'); |
| ... | @@ -8146,7 +8146,7 @@ const StringLiteral = struct { | ... | @@ -8146,7 +8146,7 @@ const StringLiteral = struct { |
| 8146 | } | 8146 | } |
| 8147 | } | 8147 | } |
| 8148 | 8148 | ||
| 8149 | pub fn end(self: *StringLiteral) anyerror!void { | 8149 | pub fn end(self: *StringLiteral) std.io.Writer.Error!void { |
| 8150 | const writer = self.writer; | 8150 | const writer = self.writer; |
| 8151 | if (self.len <= max_string_initializer_len) { | 8151 | if (self.len <= max_string_initializer_len) { |
| 8152 | self.bytes_written += try writer.writeByteCount('\"'); | 8152 | self.bytes_written += try writer.writeByteCount('\"'); |
| ... | @@ -8155,7 +8155,7 @@ const StringLiteral = struct { | ... | @@ -8155,7 +8155,7 @@ const StringLiteral = struct { |
| 8155 | } | 8155 | } |
| 8156 | } | 8156 | } |
| 8157 | 8157 | ||
| 8158 | fn writeStringLiteralChar(writer: *std.io.BufferedWriter, c: u8) anyerror!usize { | 8158 | fn writeStringLiteralChar(writer: *std.io.BufferedWriter, c: u8) std.io.Writer.Error!usize { |
| 8159 | switch (c) { | 8159 | switch (c) { |
| 8160 | 7 => return writer.writeAllCount("\\a"), | 8160 | 7 => return writer.writeAllCount("\\a"), |
| 8161 | 8 => return writer.writeAllCount("\\b"), | 8161 | 8 => return writer.writeAllCount("\\b"), |
| ... | @@ -8172,7 +8172,7 @@ const StringLiteral = struct { | ... | @@ -8172,7 +8172,7 @@ const StringLiteral = struct { |
| 8172 | } | 8172 | } |
| 8173 | } | 8173 | } |
| 8174 | 8174 | ||
| 8175 | pub fn writeChar(self: *StringLiteral, c: u8) anyerror!void { | 8175 | pub fn writeChar(self: *StringLiteral, c: u8) std.io.Writer.Error!void { |
| 8176 | const writer = self.writer; | 8176 | const writer = self.writer; |
| 8177 | if (self.len <= max_string_initializer_len) { | 8177 | if (self.len <= max_string_initializer_len) { |
| 8178 | if (self.cur_len == 0 and self.bytes_written > 1) | 8178 | if (self.cur_len == 0 and self.bytes_written > 1) |
src/codegen/spirv/spec.zig+1-1| ... | @@ -18,7 +18,7 @@ pub const IdResult = enum(Word) { | ... | @@ -18,7 +18,7 @@ pub const IdResult = enum(Word) { |
| 18 | none, | 18 | none, |
| 19 | _, | 19 | _, |
| 20 | 20 | ||
| 21 | pub fn format(self: IdResult, bw: *std.io.BufferedWriter, comptime _: []const u8) anyerror!void { | 21 | pub fn format(self: IdResult, bw: *std.io.BufferedWriter, comptime _: []const u8) std.io.Writer.Error!void { |
| 22 | switch (self) { | 22 | switch (self) { |
| 23 | .none => try bw.writeAll("(none)"), | 23 | .none => try bw.writeAll("(none)"), |
| 24 | else => try bw.print("%{}", .{@intFromEnum(self)}), | 24 | else => try bw.print("%{}", .{@intFromEnum(self)}), |
src/link/Coff.zig+2-2| ... | @@ -3066,14 +3066,14 @@ const ImportTable = struct { | ... | @@ -3066,14 +3066,14 @@ const ImportTable = struct { |
| 3066 | ctx: Context, | 3066 | ctx: Context, |
| 3067 | }; | 3067 | }; |
| 3068 | 3068 | ||
| 3069 | fn format(itab: ImportTable, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void { | 3069 | fn format(itab: ImportTable, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) std.io.Writer.Error!void { |
| 3070 | _ = itab; | 3070 | _ = itab; |
| 3071 | _ = bw; | 3071 | _ = bw; |
| 3072 | _ = unused_format_string; | 3072 | _ = unused_format_string; |
| 3073 | @compileError("do not format ImportTable directly; use itab.fmtDebug()"); | 3073 | @compileError("do not format ImportTable directly; use itab.fmtDebug()"); |
| 3074 | } | 3074 | } |
| 3075 | 3075 | ||
| 3076 | fn format2(fmt_ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void { | 3076 | fn format2(fmt_ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) std.io.Writer.Error!void { |
| 3077 | comptime assert(unused_format_string.len == 0); | 3077 | comptime assert(unused_format_string.len == 0); |
| 3078 | const lib_name = fmt_ctx.ctx.coff.temp_strtab.getAssumeExists(fmt_ctx.ctx.name_off); | 3078 | const lib_name = fmt_ctx.ctx.coff.temp_strtab.getAssumeExists(fmt_ctx.ctx.name_off); |
| 3079 | const base_vaddr = getBaseAddress(fmt_ctx.ctx); | 3079 | const base_vaddr = getBaseAddress(fmt_ctx.ctx); |
src/link/Dwarf.zig+65-64| ... | @@ -1,4 +1,4 @@ | ... | @@ -1,4 +1,4 @@ |
| 1 | gpa: std.mem.Allocator, | 1 | gpa: Allocator, |
| 2 | bin_file: *link.File, | 2 | bin_file: *link.File, |
| 3 | format: DW.Format, | 3 | format: DW.Format, |
| 4 | endian: std.builtin.Endian, | 4 | endian: std.builtin.Endian, |
| ... | @@ -50,7 +50,7 @@ const ModInfo = struct { | ... | @@ -50,7 +50,7 @@ const ModInfo = struct { |
| 50 | dirs: std.AutoArrayHashMapUnmanaged(Unit.Index, void), | 50 | dirs: std.AutoArrayHashMapUnmanaged(Unit.Index, void), |
| 51 | files: std.AutoArrayHashMapUnmanaged(Zcu.File.Index, void), | 51 | files: std.AutoArrayHashMapUnmanaged(Zcu.File.Index, void), |
| 52 | 52 | ||
| 53 | fn deinit(mod_info: *ModInfo, gpa: std.mem.Allocator) void { | 53 | fn deinit(mod_info: *ModInfo, gpa: Allocator) void { |
| 54 | mod_info.dirs.deinit(gpa); | 54 | mod_info.dirs.deinit(gpa); |
| 55 | mod_info.files.deinit(gpa); | 55 | mod_info.files.deinit(gpa); |
| 56 | mod_info.* = undefined; | 56 | mod_info.* = undefined; |
| ... | @@ -132,7 +132,7 @@ const DebugInfo = struct { | ... | @@ -132,7 +132,7 @@ const DebugInfo = struct { |
| 132 | return AbbrevCode.decl_bytes + dwarf.sectionOffsetBytes(); | 132 | return AbbrevCode.decl_bytes + dwarf.sectionOffsetBytes(); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | fn declAbbrevCode(debug_info: *DebugInfo, unit: Unit.Index, entry: Entry.Index) anyerror!AbbrevCode { | 135 | fn declAbbrevCode(debug_info: *DebugInfo, unit: Unit.Index, entry: Entry.Index) !AbbrevCode { |
| 136 | const dwarf: *Dwarf = @fieldParentPtr("debug_info", debug_info); | 136 | const dwarf: *Dwarf = @fieldParentPtr("debug_info", debug_info); |
| 137 | const unit_ptr = debug_info.section.getUnit(unit); | 137 | const unit_ptr = debug_info.section.getUnit(unit); |
| 138 | const entry_ptr = unit_ptr.getEntry(entry); | 138 | const entry_ptr = unit_ptr.getEntry(entry); |
| ... | @@ -221,13 +221,13 @@ const StringSection = struct { | ... | @@ -221,13 +221,13 @@ const StringSection = struct { |
| 221 | .section = Section.init, | 221 | .section = Section.init, |
| 222 | }; | 222 | }; |
| 223 | 223 | ||
| 224 | fn deinit(str_sec: *StringSection, gpa: std.mem.Allocator) void { | 224 | fn deinit(str_sec: *StringSection, gpa: Allocator) void { |
| 225 | str_sec.contents.deinit(gpa); | 225 | str_sec.contents.deinit(gpa); |
| 226 | str_sec.map.deinit(gpa); | 226 | str_sec.map.deinit(gpa); |
| 227 | str_sec.section.deinit(gpa); | 227 | str_sec.section.deinit(gpa); |
| 228 | } | 228 | } |
| 229 | 229 | ||
| 230 | fn addString(str_sec: *StringSection, dwarf: *Dwarf, str: []const u8) anyerror!Entry.Index { | 230 | fn addString(str_sec: *StringSection, dwarf: *Dwarf, str: []const u8) !Entry.Index { |
| 231 | const gop = try str_sec.map.getOrPutAdapted(dwarf.gpa, str, Adapter{ .str_sec = str_sec }); | 231 | const gop = try str_sec.map.getOrPutAdapted(dwarf.gpa, str, Adapter{ .str_sec = str_sec }); |
| 232 | const entry: Entry.Index = @enumFromInt(gop.index); | 232 | const entry: Entry.Index = @enumFromInt(gop.index); |
| 233 | if (!gop.found_existing) { | 233 | if (!gop.found_existing) { |
| ... | @@ -298,7 +298,7 @@ pub const Section = struct { | ... | @@ -298,7 +298,7 @@ pub const Section = struct { |
| 298 | .len = 0, | 298 | .len = 0, |
| 299 | }; | 299 | }; |
| 300 | 300 | ||
| 301 | fn deinit(sec: *Section, gpa: std.mem.Allocator) void { | 301 | fn deinit(sec: *Section, gpa: Allocator) void { |
| 302 | for (sec.units.items) |*unit| unit.deinit(gpa); | 302 | for (sec.units.items) |*unit| unit.deinit(gpa); |
| 303 | sec.units.deinit(gpa); | 303 | sec.units.deinit(gpa); |
| 304 | sec.* = undefined; | 304 | sec.* = undefined; |
| ... | @@ -358,7 +358,7 @@ pub const Section = struct { | ... | @@ -358,7 +358,7 @@ pub const Section = struct { |
| 358 | if (sec.last == unit.toOptional()) sec.last = unit_ptr.prev; | 358 | if (sec.last == unit.toOptional()) sec.last = unit_ptr.prev; |
| 359 | } | 359 | } |
| 360 | 360 | ||
| 361 | fn popUnit(sec: *Section, gpa: std.mem.Allocator) void { | 361 | fn popUnit(sec: *Section, gpa: Allocator) void { |
| 362 | const unit_index: Unit.Index = @enumFromInt(sec.units.items.len - 1); | 362 | const unit_index: Unit.Index = @enumFromInt(sec.units.items.len - 1); |
| 363 | sec.unlinkUnit(unit_index); | 363 | sec.unlinkUnit(unit_index); |
| 364 | var unit = sec.units.pop().?; | 364 | var unit = sec.units.pop().?; |
| ... | @@ -369,7 +369,7 @@ pub const Section = struct { | ... | @@ -369,7 +369,7 @@ pub const Section = struct { |
| 369 | return &sec.units.items[@intFromEnum(unit)]; | 369 | return &sec.units.items[@intFromEnum(unit)]; |
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | fn resizeEntry(sec: *Section, unit: Unit.Index, entry: Entry.Index, dwarf: *Dwarf, len: u32) anyerror!void { | 372 | fn resizeEntry(sec: *Section, unit: Unit.Index, entry: Entry.Index, dwarf: *Dwarf, len: u32) UpdateError!void { |
| 373 | const unit_ptr = sec.getUnit(unit); | 373 | const unit_ptr = sec.getUnit(unit); |
| 374 | const entry_ptr = unit_ptr.getEntry(entry); | 374 | const entry_ptr = unit_ptr.getEntry(entry); |
| 375 | if (len > 0) { | 375 | if (len > 0) { |
| ... | @@ -390,13 +390,13 @@ pub const Section = struct { | ... | @@ -390,13 +390,13 @@ pub const Section = struct { |
| 390 | assert(entry_ptr.len == len); | 390 | assert(entry_ptr.len == len); |
| 391 | } | 391 | } |
| 392 | 392 | ||
| 393 | fn replaceEntry(sec: *Section, unit: Unit.Index, entry: Entry.Index, dwarf: *Dwarf, contents: []const u8) anyerror!void { | 393 | fn replaceEntry(sec: *Section, unit: Unit.Index, entry: Entry.Index, dwarf: *Dwarf, contents: []const u8) UpdateError!void { |
| 394 | try sec.resizeEntry(unit, entry, dwarf, @intCast(contents.len)); | 394 | try sec.resizeEntry(unit, entry, dwarf, @intCast(contents.len)); |
| 395 | const unit_ptr = sec.getUnit(unit); | 395 | const unit_ptr = sec.getUnit(unit); |
| 396 | try unit_ptr.getEntry(entry).replace(unit_ptr, sec, dwarf, contents); | 396 | try unit_ptr.getEntry(entry).replace(unit_ptr, sec, dwarf, contents); |
| 397 | } | 397 | } |
| 398 | 398 | ||
| 399 | fn freeEntry(sec: *Section, unit: Unit.Index, entry: Entry.Index, dwarf: *Dwarf) anyerror!void { | 399 | fn freeEntry(sec: *Section, unit: Unit.Index, entry: Entry.Index, dwarf: *Dwarf) UpdateError!void { |
| 400 | const unit_ptr = sec.getUnit(unit); | 400 | const unit_ptr = sec.getUnit(unit); |
| 401 | const entry_ptr = unit_ptr.getEntry(entry); | 401 | const entry_ptr = unit_ptr.getEntry(entry); |
| 402 | if (entry_ptr.len > 0) { | 402 | if (entry_ptr.len > 0) { |
| ... | @@ -519,7 +519,7 @@ const Unit = struct { | ... | @@ -519,7 +519,7 @@ const Unit = struct { |
| 519 | unit.cross_section_relocs.clearRetainingCapacity(); | 519 | unit.cross_section_relocs.clearRetainingCapacity(); |
| 520 | } | 520 | } |
| 521 | 521 | ||
| 522 | fn deinit(unit: *Unit, gpa: std.mem.Allocator) void { | 522 | fn deinit(unit: *Unit, gpa: Allocator) void { |
| 523 | for (unit.entries.items) |*entry| entry.deinit(gpa); | 523 | for (unit.entries.items) |*entry| entry.deinit(gpa); |
| 524 | unit.entries.deinit(gpa); | 524 | unit.entries.deinit(gpa); |
| 525 | unit.cross_unit_relocs.deinit(gpa); | 525 | unit.cross_unit_relocs.deinit(gpa); |
| ... | @@ -527,7 +527,7 @@ const Unit = struct { | ... | @@ -527,7 +527,7 @@ const Unit = struct { |
| 527 | unit.* = undefined; | 527 | unit.* = undefined; |
| 528 | } | 528 | } |
| 529 | 529 | ||
| 530 | fn addEntry(unit: *Unit, gpa: std.mem.Allocator) std.mem.Allocator.Error!Entry.Index { | 530 | fn addEntry(unit: *Unit, gpa: Allocator) Allocator.Error!Entry.Index { |
| 531 | if (unit.free.unwrap()) |entry| { | 531 | if (unit.free.unwrap()) |entry| { |
| 532 | const entry_ptr = unit.getEntry(entry); | 532 | const entry_ptr = unit.getEntry(entry); |
| 533 | unit.free = entry_ptr.next; | 533 | unit.free = entry_ptr.next; |
| ... | @@ -782,7 +782,7 @@ const Entry = struct { | ... | @@ -782,7 +782,7 @@ const Entry = struct { |
| 782 | entry.external_relocs.clearRetainingCapacity(); | 782 | entry.external_relocs.clearRetainingCapacity(); |
| 783 | } | 783 | } |
| 784 | 784 | ||
| 785 | fn deinit(entry: *Entry, gpa: std.mem.Allocator) void { | 785 | fn deinit(entry: *Entry, gpa: Allocator) void { |
| 786 | entry.cross_entry_relocs.deinit(gpa); | 786 | entry.cross_entry_relocs.deinit(gpa); |
| 787 | entry.cross_unit_relocs.deinit(gpa); | 787 | entry.cross_unit_relocs.deinit(gpa); |
| 788 | entry.cross_section_relocs.deinit(gpa); | 788 | entry.cross_section_relocs.deinit(gpa); |
| ... | @@ -807,7 +807,7 @@ const Entry = struct { | ... | @@ -807,7 +807,7 @@ const Entry = struct { |
| 807 | } | 807 | } |
| 808 | }; | 808 | }; |
| 809 | 809 | ||
| 810 | fn pad(entry: *Entry, unit: *Unit, sec: *Section, dwarf: *Dwarf) anyerror!void { | 810 | fn pad(entry: *Entry, unit: *Unit, sec: *Section, dwarf: *Dwarf) UpdateError!void { |
| 811 | assert(entry.len > 0); | 811 | assert(entry.len > 0); |
| 812 | const start = entry.off + entry.len; | 812 | const start = entry.off + entry.len; |
| 813 | if (sec == &dwarf.debug_frame.section) { | 813 | if (sec == &dwarf.debug_frame.section) { |
| ... | @@ -886,7 +886,7 @@ const Entry = struct { | ... | @@ -886,7 +886,7 @@ const Entry = struct { |
| 886 | try dwarf.getFile().?.pwriteAll(bw.getWritten(), sec.off(dwarf) + unit.off + unit.header_len + start); | 886 | try dwarf.getFile().?.pwriteAll(bw.getWritten(), sec.off(dwarf) + unit.off + unit.header_len + start); |
| 887 | } | 887 | } |
| 888 | 888 | ||
| 889 | fn resize(entry_ptr: *Entry, unit: *Unit, sec: *Section, dwarf: *Dwarf, len: u32) anyerror!void { | 889 | fn resize(entry_ptr: *Entry, unit: *Unit, sec: *Section, dwarf: *Dwarf, len: u32) UpdateError!void { |
| 890 | assert(len > 0); | 890 | assert(len > 0); |
| 891 | assert(sec.alignment.check(len)); | 891 | assert(sec.alignment.check(len)); |
| 892 | if (entry_ptr.len == len) return; | 892 | if (entry_ptr.len == len) return; |
| ... | @@ -1138,7 +1138,7 @@ pub const Loc = union(enum) { | ... | @@ -1138,7 +1138,7 @@ pub const Loc = union(enum) { |
| 1138 | }; | 1138 | }; |
| 1139 | } | 1139 | } |
| 1140 | 1140 | ||
| 1141 | fn writeReg(bw: *std.io.BufferedWriter, reg: u32, op0: u8, opx: u8) anyerror!void { | 1141 | fn writeReg(bw: *std.io.BufferedWriter, reg: u32, op0: u8, opx: u8) std.io.Writer.Error!void { |
| 1142 | if (std.math.cast(u5, reg)) |small_reg| { | 1142 | if (std.math.cast(u5, reg)) |small_reg| { |
| 1143 | try bw.writeByte(op0 + small_reg); | 1143 | try bw.writeByte(op0 + small_reg); |
| 1144 | } else { | 1144 | } else { |
| ... | @@ -1147,7 +1147,7 @@ pub const Loc = union(enum) { | ... | @@ -1147,7 +1147,7 @@ pub const Loc = union(enum) { |
| 1147 | } | 1147 | } |
| 1148 | } | 1148 | } |
| 1149 | 1149 | ||
| 1150 | fn write(loc: Loc, bw: *std.io.BufferedWriter, adapter: anytype) anyerror!void { | 1150 | fn write(loc: Loc, bw: *std.io.BufferedWriter, adapter: anytype) UpdateError!void { |
| 1151 | switch (loc) { | 1151 | switch (loc) { |
| 1152 | .empty => {}, | 1152 | .empty => {}, |
| 1153 | .addr_reloc => |sym_index| { | 1153 | .addr_reloc => |sym_index| { |
| ... | @@ -1312,7 +1312,7 @@ pub const Cfa = union(enum) { | ... | @@ -1312,7 +1312,7 @@ pub const Cfa = union(enum) { |
| 1312 | const RegOff = struct { reg: u32, off: i64 }; | 1312 | const RegOff = struct { reg: u32, off: i64 }; |
| 1313 | const RegExpr = struct { reg: u32, expr: Loc }; | 1313 | const RegExpr = struct { reg: u32, expr: Loc }; |
| 1314 | 1314 | ||
| 1315 | fn write(cfa: Cfa, wip_nav: *WipNav) anyerror!void { | 1315 | fn write(cfa: Cfa, wip_nav: *WipNav) UpdateError!void { |
| 1316 | const bw = &wip_nav.debug_frame.buffered_writer; | 1316 | const bw = &wip_nav.debug_frame.buffered_writer; |
| 1317 | switch (cfa) { | 1317 | switch (cfa) { |
| 1318 | .nop => try bw.writeByte(DW.CFA.nop), | 1318 | .nop => try bw.writeByte(DW.CFA.nop), |
| ... | @@ -1586,25 +1586,25 @@ pub const WipNav = struct { | ... | @@ -1586,25 +1586,25 @@ pub const WipNav = struct { |
| 1586 | ) catch |err| return @errorCast(err); | 1586 | ) catch |err| return @errorCast(err); |
| 1587 | } | 1587 | } |
| 1588 | 1588 | ||
| 1589 | pub fn setColumn(wip_nav: *WipNav, column: u32) std.mem.Allocator.Error!void { | 1589 | pub fn setColumn(wip_nav: *WipNav, column: u32) Allocator.Error!void { |
| 1590 | const dlbw = &wip_nav.debug_line.buffered_writer; | 1590 | const dlbw = &wip_nav.debug_line.buffered_writer; |
| 1591 | dlbw.writeByte(DW.LNS.set_column) catch |err| return @errorCast(err); | 1591 | dlbw.writeByte(DW.LNS.set_column) catch |err| return @errorCast(err); |
| 1592 | dlbw.writeLeb128(column + 1) catch |err| return @errorCast(err); | 1592 | dlbw.writeLeb128(column + 1) catch |err| return @errorCast(err); |
| 1593 | } | 1593 | } |
| 1594 | 1594 | ||
| 1595 | pub fn negateStmt(wip_nav: *WipNav) std.mem.Allocator.Error!void { | 1595 | pub fn negateStmt(wip_nav: *WipNav) Allocator.Error!void { |
| 1596 | return @errorCast(wip_nav.debug_line.buffered_writer.writeByte(DW.LNS.negate_stmt)); | 1596 | return @errorCast(wip_nav.debug_line.buffered_writer.writeByte(DW.LNS.negate_stmt)); |
| 1597 | } | 1597 | } |
| 1598 | 1598 | ||
| 1599 | pub fn setPrologueEnd(wip_nav: *WipNav) std.mem.Allocator.Error!void { | 1599 | pub fn setPrologueEnd(wip_nav: *WipNav) Allocator.Error!void { |
| 1600 | return @errorCast(wip_nav.debug_line.buffered_writer.writeByte(DW.LNS.set_prologue_end)); | 1600 | return @errorCast(wip_nav.debug_line.buffered_writer.writeByte(DW.LNS.set_prologue_end)); |
| 1601 | } | 1601 | } |
| 1602 | 1602 | ||
| 1603 | pub fn setEpilogueBegin(wip_nav: *WipNav) std.mem.Allocator.Error!void { | 1603 | pub fn setEpilogueBegin(wip_nav: *WipNav) Allocator.Error!void { |
| 1604 | return @errorCast(wip_nav.debug_line.buffered_writer.writeByte(DW.LNS.set_epilogue_begin)); | 1604 | return @errorCast(wip_nav.debug_line.buffered_writer.writeByte(DW.LNS.set_epilogue_begin)); |
| 1605 | } | 1605 | } |
| 1606 | 1606 | ||
| 1607 | pub fn enterBlock(wip_nav: *WipNav, code_off: u64) anyerror!void { | 1607 | pub fn enterBlock(wip_nav: *WipNav, code_off: u64) UpdateError!void { |
| 1608 | const dwarf = wip_nav.dwarf; | 1608 | const dwarf = wip_nav.dwarf; |
| 1609 | const dibw = &wip_nav.debug_info.buffered_writer; | 1609 | const dibw = &wip_nav.debug_info.buffered_writer; |
| 1610 | const block = try wip_nav.blocks.addOne(dwarf.gpa); | 1610 | const block = try wip_nav.blocks.addOne(dwarf.gpa); |
| ... | @@ -1618,7 +1618,7 @@ pub const WipNav = struct { | ... | @@ -1618,7 +1618,7 @@ pub const WipNav = struct { |
| 1618 | wip_nav.any_children = false; | 1618 | wip_nav.any_children = false; |
| 1619 | } | 1619 | } |
| 1620 | 1620 | ||
| 1621 | pub fn leaveBlock(wip_nav: *WipNav, code_off: u64) anyerror!void { | 1621 | pub fn leaveBlock(wip_nav: *WipNav, code_off: u64) UpdateError!void { |
| 1622 | const block_bytes = comptime uleb128Bytes(@intFromEnum(AbbrevCode.block)); | 1622 | const block_bytes = comptime uleb128Bytes(@intFromEnum(AbbrevCode.block)); |
| 1623 | const block = wip_nav.blocks.pop().?; | 1623 | const block = wip_nav.blocks.pop().?; |
| 1624 | const dib = wip_nav.debug_info.getWritten(); | 1624 | const dib = wip_nav.debug_info.getWritten(); |
| ... | @@ -1640,7 +1640,7 @@ pub const WipNav = struct { | ... | @@ -1640,7 +1640,7 @@ pub const WipNav = struct { |
| 1640 | code_off: u64, | 1640 | code_off: u64, |
| 1641 | line: u32, | 1641 | line: u32, |
| 1642 | column: u32, | 1642 | column: u32, |
| 1643 | ) anyerror!void { | 1643 | ) UpdateError!void { |
| 1644 | const dwarf = wip_nav.dwarf; | 1644 | const dwarf = wip_nav.dwarf; |
| 1645 | const zcu = wip_nav.pt.zcu; | 1645 | const zcu = wip_nav.pt.zcu; |
| 1646 | const dibw = &wip_nav.debug_info.buffered_writer; | 1646 | const dibw = &wip_nav.debug_info.buffered_writer; |
| ... | @@ -1659,7 +1659,7 @@ pub const WipNav = struct { | ... | @@ -1659,7 +1659,7 @@ pub const WipNav = struct { |
| 1659 | wip_nav.any_children = false; | 1659 | wip_nav.any_children = false; |
| 1660 | } | 1660 | } |
| 1661 | 1661 | ||
| 1662 | pub fn leaveInlineFunc(wip_nav: *WipNav, func: InternPool.Index, code_off: u64) anyerror!void { | 1662 | pub fn leaveInlineFunc(wip_nav: *WipNav, func: InternPool.Index, code_off: u64) UpdateError!void { |
| 1663 | const inlined_func_bytes = comptime uleb128Bytes(@intFromEnum(AbbrevCode.inlined_func)); | 1663 | const inlined_func_bytes = comptime uleb128Bytes(@intFromEnum(AbbrevCode.inlined_func)); |
| 1664 | const block = wip_nav.blocks.pop().?; | 1664 | const block = wip_nav.blocks.pop().?; |
| 1665 | const dib = wip_nav.debug_info.getWritten(); | 1665 | const dib = wip_nav.debug_info.getWritten(); |
| ... | @@ -1676,7 +1676,7 @@ pub const WipNav = struct { | ... | @@ -1676,7 +1676,7 @@ pub const WipNav = struct { |
| 1676 | wip_nav.any_children = true; | 1676 | wip_nav.any_children = true; |
| 1677 | } | 1677 | } |
| 1678 | 1678 | ||
| 1679 | pub fn setInlineFunc(wip_nav: *WipNav, func: InternPool.Index) anyerror!void { | 1679 | pub fn setInlineFunc(wip_nav: *WipNav, func: InternPool.Index) UpdateError!void { |
| 1680 | const zcu = wip_nav.pt.zcu; | 1680 | const zcu = wip_nav.pt.zcu; |
| 1681 | const dwarf = wip_nav.dwarf; | 1681 | const dwarf = wip_nav.dwarf; |
| 1682 | if (wip_nav.func == func) return; | 1682 | if (wip_nav.func == func) return; |
| ... | @@ -1725,19 +1725,19 @@ pub const WipNav = struct { | ... | @@ -1725,19 +1725,19 @@ pub const WipNav = struct { |
| 1725 | wip_nav.func = func; | 1725 | wip_nav.func = func; |
| 1726 | } | 1726 | } |
| 1727 | 1727 | ||
| 1728 | fn externalReloc(wip_nav: *WipNav, sec: *Section, reloc: ExternalReloc) std.mem.Allocator.Error!void { | 1728 | fn externalReloc(wip_nav: *WipNav, sec: *Section, reloc: ExternalReloc) Allocator.Error!void { |
| 1729 | try sec.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs.append(wip_nav.dwarf.gpa, reloc); | 1729 | try sec.getUnit(wip_nav.unit).getEntry(wip_nav.entry).external_relocs.append(wip_nav.dwarf.gpa, reloc); |
| 1730 | } | 1730 | } |
| 1731 | 1731 | ||
| 1732 | pub fn infoExternalReloc(wip_nav: *WipNav, reloc: ExternalReloc) std.mem.Allocator.Error!void { | 1732 | pub fn infoExternalReloc(wip_nav: *WipNav, reloc: ExternalReloc) Allocator.Error!void { |
| 1733 | try wip_nav.externalReloc(&wip_nav.dwarf.debug_info.section, reloc); | 1733 | try wip_nav.externalReloc(&wip_nav.dwarf.debug_info.section, reloc); |
| 1734 | } | 1734 | } |
| 1735 | 1735 | ||
| 1736 | fn frameExternalReloc(wip_nav: *WipNav, reloc: ExternalReloc) std.mem.Allocator.Error!void { | 1736 | fn frameExternalReloc(wip_nav: *WipNav, reloc: ExternalReloc) Allocator.Error!void { |
| 1737 | try wip_nav.externalReloc(&wip_nav.dwarf.debug_frame.section, reloc); | 1737 | try wip_nav.externalReloc(&wip_nav.dwarf.debug_frame.section, reloc); |
| 1738 | } | 1738 | } |
| 1739 | 1739 | ||
| 1740 | fn abbrevCode(wip_nav: *WipNav, abbrev_code: AbbrevCode) anyerror!void { | 1740 | fn abbrevCode(wip_nav: *WipNav, abbrev_code: AbbrevCode) UpdateError!void { |
| 1741 | try wip_nav.debug_info.buffered_writer.writeLeb128(try wip_nav.dwarf.refAbbrevCode(abbrev_code)); | 1741 | try wip_nav.debug_info.buffered_writer.writeLeb128(try wip_nav.dwarf.refAbbrevCode(abbrev_code)); |
| 1742 | } | 1742 | } |
| 1743 | 1743 | ||
| ... | @@ -1748,7 +1748,7 @@ pub const WipNav = struct { | ... | @@ -1748,7 +1748,7 @@ pub const WipNav = struct { |
| 1748 | target_unit: Unit.Index, | 1748 | target_unit: Unit.Index, |
| 1749 | target_entry: Entry.Index, | 1749 | target_entry: Entry.Index, |
| 1750 | target_off: u32, | 1750 | target_off: u32, |
| 1751 | ) anyerror!void { | 1751 | ) UpdateError!void { |
| 1752 | const dwarf = wip_nav.dwarf; | 1752 | const dwarf = wip_nav.dwarf; |
| 1753 | const gpa = dwarf.gpa; | 1753 | const gpa = dwarf.gpa; |
| 1754 | const entry_ptr = @field(dwarf, @tagName(sec)).section.getUnit(wip_nav.unit).getEntry(wip_nav.entry); | 1754 | const entry_ptr = @field(dwarf, @tagName(sec)).section.getUnit(wip_nav.unit).getEntry(wip_nav.entry); |
| ... | @@ -1779,11 +1779,11 @@ pub const WipNav = struct { | ... | @@ -1779,11 +1779,11 @@ pub const WipNav = struct { |
| 1779 | try bw.splatByteAll(0, dwarf.sectionOffsetBytes()); | 1779 | try bw.splatByteAll(0, dwarf.sectionOffsetBytes()); |
| 1780 | } | 1780 | } |
| 1781 | 1781 | ||
| 1782 | fn infoSectionOffset(wip_nav: *WipNav, target_sec: Section.Index, target_unit: Unit.Index, target_entry: Entry.Index, target_off: u32) anyerror!void { | 1782 | fn infoSectionOffset(wip_nav: *WipNav, target_sec: Section.Index, target_unit: Unit.Index, target_entry: Entry.Index, target_off: u32) UpdateError!void { |
| 1783 | try wip_nav.sectionOffset(.debug_info, target_sec, target_unit, target_entry, target_off); | 1783 | try wip_nav.sectionOffset(.debug_info, target_sec, target_unit, target_entry, target_off); |
| 1784 | } | 1784 | } |
| 1785 | 1785 | ||
| 1786 | fn strp(wip_nav: *WipNav, str: []const u8) anyerror!void { | 1786 | fn strp(wip_nav: *WipNav, str: []const u8) UpdateError!void { |
| 1787 | try wip_nav.infoSectionOffset(.debug_str, StringSection.unit, try wip_nav.dwarf.debug_str.addString(wip_nav.dwarf, str), 0); | 1787 | try wip_nav.infoSectionOffset(.debug_str, StringSection.unit, try wip_nav.dwarf.debug_str.addString(wip_nav.dwarf, str), 0); |
| 1788 | } | 1788 | } |
| 1789 | 1789 | ||
| ... | @@ -1807,7 +1807,7 @@ pub const WipNav = struct { | ... | @@ -1807,7 +1807,7 @@ pub const WipNav = struct { |
| 1807 | } | 1807 | } |
| 1808 | }; | 1808 | }; |
| 1809 | 1809 | ||
| 1810 | fn infoExprLoc(wip_nav: *WipNav, loc: Loc) anyerror!void { | 1810 | fn infoExprLoc(wip_nav: *WipNav, loc: Loc) UpdateError!void { |
| 1811 | const bw = &wip_nav.debug_info.buffered_writer; | 1811 | const bw = &wip_nav.debug_info.buffered_writer; |
| 1812 | const counter: ExprLocCounter = .init(wip_nav.dwarf); | 1812 | const counter: ExprLocCounter = .init(wip_nav.dwarf); |
| 1813 | const start = bw.count; | 1813 | const start = bw.count; |
| ... | @@ -1821,10 +1821,10 @@ pub const WipNav = struct { | ... | @@ -1821,10 +1821,10 @@ pub const WipNav = struct { |
| 1821 | fn endian(ctx: @This()) std.builtin.Endian { | 1821 | fn endian(ctx: @This()) std.builtin.Endian { |
| 1822 | return ctx.wip_nav.dwarf.endian; | 1822 | return ctx.wip_nav.dwarf.endian; |
| 1823 | } | 1823 | } |
| 1824 | fn addrSym(ctx: @This(), _: *std.io.BufferedWriter, sym_index: u32) anyerror!void { | 1824 | fn addrSym(ctx: @This(), _: *std.io.BufferedWriter, sym_index: u32) UpdateError!void { |
| 1825 | try ctx.wip_nav.infoAddrSym(sym_index, 0); | 1825 | try ctx.wip_nav.infoAddrSym(sym_index, 0); |
| 1826 | } | 1826 | } |
| 1827 | fn infoEntry(ctx: @This(), _: *std.io.BufferedWriter, unit: Unit.Index, entry: Entry.Index) anyerror!void { | 1827 | fn infoEntry(ctx: @This(), _: *std.io.BufferedWriter, unit: Unit.Index, entry: Entry.Index) UpdateError!void { |
| 1828 | try ctx.wip_nav.infoSectionOffset(.debug_info, unit, entry, 0); | 1828 | try ctx.wip_nav.infoSectionOffset(.debug_info, unit, entry, 0); |
| 1829 | } | 1829 | } |
| 1830 | } = .{ .wip_nav = wip_nav }; | 1830 | } = .{ .wip_nav = wip_nav }; |
| ... | @@ -1832,7 +1832,7 @@ pub const WipNav = struct { | ... | @@ -1832,7 +1832,7 @@ pub const WipNav = struct { |
| 1832 | try loc.write(bw, adapter); | 1832 | try loc.write(bw, adapter); |
| 1833 | } | 1833 | } |
| 1834 | 1834 | ||
| 1835 | fn infoAddrSym(wip_nav: *WipNav, sym_index: u32, sym_off: u64) anyerror!void { | 1835 | fn infoAddrSym(wip_nav: *WipNav, sym_index: u32, sym_off: u64) UpdateError!void { |
| 1836 | const dibw = &wip_nav.debug_info.buffered_writer; | 1836 | const dibw = &wip_nav.debug_info.buffered_writer; |
| 1837 | try wip_nav.infoExternalReloc(.{ | 1837 | try wip_nav.infoExternalReloc(.{ |
| 1838 | .source_off = @intCast(dibw.count), | 1838 | .source_off = @intCast(dibw.count), |
| ... | @@ -1856,10 +1856,10 @@ pub const WipNav = struct { | ... | @@ -1856,10 +1856,10 @@ pub const WipNav = struct { |
| 1856 | fn endian(ctx: @This()) std.builtin.Endian { | 1856 | fn endian(ctx: @This()) std.builtin.Endian { |
| 1857 | return ctx.wip_nav.dwarf.endian; | 1857 | return ctx.wip_nav.dwarf.endian; |
| 1858 | } | 1858 | } |
| 1859 | fn addrSym(ctx: @This(), _: *std.io.BufferedWriter, sym_index: u32) anyerror!void { | 1859 | fn addrSym(ctx: @This(), _: *std.io.BufferedWriter, sym_index: u32) UpdateError!void { |
| 1860 | try ctx.wip_nav.frameAddrSym(sym_index, 0); | 1860 | try ctx.wip_nav.frameAddrSym(sym_index, 0); |
| 1861 | } | 1861 | } |
| 1862 | fn infoEntry(ctx: @This(), _: *std.io.BufferedWriter, unit: Unit.Index, entry: Entry.Index) anyerror!void { | 1862 | fn infoEntry(ctx: @This(), _: *std.io.BufferedWriter, unit: Unit.Index, entry: Entry.Index) UpdateError!void { |
| 1863 | try ctx.wip_nav.sectionOffset(.debug_frame, .debug_info, unit, entry, 0); | 1863 | try ctx.wip_nav.sectionOffset(.debug_frame, .debug_info, unit, entry, 0); |
| 1864 | } | 1864 | } |
| 1865 | } = .{ .wip_nav = wip_nav }; | 1865 | } = .{ .wip_nav = wip_nav }; |
| ... | @@ -1867,7 +1867,7 @@ pub const WipNav = struct { | ... | @@ -1867,7 +1867,7 @@ pub const WipNav = struct { |
| 1867 | try loc.write(bw, adapter); | 1867 | try loc.write(bw, adapter); |
| 1868 | } | 1868 | } |
| 1869 | 1869 | ||
| 1870 | fn frameAddrSym(wip_nav: *WipNav, sym_index: u32, sym_off: u64) anyerror!void { | 1870 | fn frameAddrSym(wip_nav: *WipNav, sym_index: u32, sym_off: u64) UpdateError!void { |
| 1871 | const dfbw = &wip_nav.debug_frame.buffered_writer; | 1871 | const dfbw = &wip_nav.debug_frame.buffered_writer; |
| 1872 | try wip_nav.frameExternalReloc(.{ | 1872 | try wip_nav.frameExternalReloc(.{ |
| 1873 | .source_off = @intCast(dfbw.count), | 1873 | .source_off = @intCast(dfbw.count), |
| ... | @@ -1877,7 +1877,7 @@ pub const WipNav = struct { | ... | @@ -1877,7 +1877,7 @@ pub const WipNav = struct { |
| 1877 | try dfbw.splatByteAll(0, @intFromEnum(wip_nav.dwarf.address_size)); | 1877 | try dfbw.splatByteAll(0, @intFromEnum(wip_nav.dwarf.address_size)); |
| 1878 | } | 1878 | } |
| 1879 | 1879 | ||
| 1880 | fn getNavEntry(wip_nav: *WipNav, nav_index: InternPool.Nav.Index) anyerror!struct { Unit.Index, Entry.Index } { | 1880 | fn getNavEntry(wip_nav: *WipNav, nav_index: InternPool.Nav.Index) UpdateError!struct { Unit.Index, Entry.Index } { |
| 1881 | const zcu = wip_nav.pt.zcu; | 1881 | const zcu = wip_nav.pt.zcu; |
| 1882 | const ip = &zcu.intern_pool; | 1882 | const ip = &zcu.intern_pool; |
| 1883 | const nav = ip.getNav(nav_index); | 1883 | const nav = ip.getNav(nav_index); |
| ... | @@ -1889,12 +1889,12 @@ pub const WipNav = struct { | ... | @@ -1889,12 +1889,12 @@ pub const WipNav = struct { |
| 1889 | return .{ unit, entry }; | 1889 | return .{ unit, entry }; |
| 1890 | } | 1890 | } |
| 1891 | 1891 | ||
| 1892 | fn refNav(wip_nav: *WipNav, nav_index: InternPool.Nav.Index) anyerror!void { | 1892 | fn refNav(wip_nav: *WipNav, nav_index: InternPool.Nav.Index) UpdateError!void { |
| 1893 | const unit, const entry = try wip_nav.getNavEntry(nav_index); | 1893 | const unit, const entry = try wip_nav.getNavEntry(nav_index); |
| 1894 | try wip_nav.infoSectionOffset(.debug_info, unit, entry, 0); | 1894 | try wip_nav.infoSectionOffset(.debug_info, unit, entry, 0); |
| 1895 | } | 1895 | } |
| 1896 | 1896 | ||
| 1897 | fn getTypeEntry(wip_nav: *WipNav, ty: Type) anyerror!struct { Unit.Index, Entry.Index } { | 1897 | fn getTypeEntry(wip_nav: *WipNav, ty: Type) UpdateError!struct { Unit.Index, Entry.Index } { |
| 1898 | const zcu = wip_nav.pt.zcu; | 1898 | const zcu = wip_nav.pt.zcu; |
| 1899 | const ip = &zcu.intern_pool; | 1899 | const ip = &zcu.intern_pool; |
| 1900 | const maybe_inst_index = ty.typeDeclInst(zcu); | 1900 | const maybe_inst_index = ty.typeDeclInst(zcu); |
| ... | @@ -1916,12 +1916,12 @@ pub const WipNav = struct { | ... | @@ -1916,12 +1916,12 @@ pub const WipNav = struct { |
| 1916 | return .{ unit, entry }; | 1916 | return .{ unit, entry }; |
| 1917 | } | 1917 | } |
| 1918 | 1918 | ||
| 1919 | fn refType(wip_nav: *WipNav, ty: Type) anyerror!void { | 1919 | fn refType(wip_nav: *WipNav, ty: Type) UpdateError!void { |
| 1920 | const unit, const entry = try wip_nav.getTypeEntry(ty); | 1920 | const unit, const entry = try wip_nav.getTypeEntry(ty); |
| 1921 | try wip_nav.infoSectionOffset(.debug_info, unit, entry, 0); | 1921 | try wip_nav.infoSectionOffset(.debug_info, unit, entry, 0); |
| 1922 | } | 1922 | } |
| 1923 | 1923 | ||
| 1924 | fn getValueEntry(wip_nav: *WipNav, value: Value) anyerror!struct { Unit.Index, Entry.Index } { | 1924 | fn getValueEntry(wip_nav: *WipNav, value: Value) UpdateError!struct { Unit.Index, Entry.Index } { |
| 1925 | const zcu = wip_nav.pt.zcu; | 1925 | const zcu = wip_nav.pt.zcu; |
| 1926 | const ip = &zcu.intern_pool; | 1926 | const ip = &zcu.intern_pool; |
| 1927 | const ty = value.typeOf(zcu); | 1927 | const ty = value.typeOf(zcu); |
| ... | @@ -1937,12 +1937,12 @@ pub const WipNav = struct { | ... | @@ -1937,12 +1937,12 @@ pub const WipNav = struct { |
| 1937 | return .{ unit, entry }; | 1937 | return .{ unit, entry }; |
| 1938 | } | 1938 | } |
| 1939 | 1939 | ||
| 1940 | fn refValue(wip_nav: *WipNav, value: Value) anyerror!void { | 1940 | fn refValue(wip_nav: *WipNav, value: Value) UpdateError!void { |
| 1941 | const unit, const entry = try wip_nav.getValueEntry(value); | 1941 | const unit, const entry = try wip_nav.getValueEntry(value); |
| 1942 | try wip_nav.infoSectionOffset(.debug_info, unit, entry, 0); | 1942 | try wip_nav.infoSectionOffset(.debug_info, unit, entry, 0); |
| 1943 | } | 1943 | } |
| 1944 | 1944 | ||
| 1945 | fn refForward(wip_nav: *WipNav) anyerror!u32 { | 1945 | fn refForward(wip_nav: *WipNav) Allocator.Error!u32 { |
| 1946 | const dwarf = wip_nav.dwarf; | 1946 | const dwarf = wip_nav.dwarf; |
| 1947 | const dibw = &wip_nav.debug_info.buffered_writer; | 1947 | const dibw = &wip_nav.debug_info.buffered_writer; |
| 1948 | const cross_entry_relocs = &dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).cross_entry_relocs; | 1948 | const cross_entry_relocs = &dwarf.debug_info.section.getUnit(wip_nav.unit).getEntry(wip_nav.entry).cross_entry_relocs; |
| ... | @@ -1962,7 +1962,7 @@ pub const WipNav = struct { | ... | @@ -1962,7 +1962,7 @@ pub const WipNav = struct { |
| 1962 | reloc.target_off = @intCast(wip_nav.debug_info.buffered_writer.count); | 1962 | reloc.target_off = @intCast(wip_nav.debug_info.buffered_writer.count); |
| 1963 | } | 1963 | } |
| 1964 | 1964 | ||
| 1965 | fn blockValue(wip_nav: *WipNav, src_loc: Zcu.LazySrcLoc, val: Value) anyerror!void { | 1965 | fn blockValue(wip_nav: *WipNav, src_loc: Zcu.LazySrcLoc, val: Value) UpdateError!void { |
| 1966 | const ty = val.typeOf(wip_nav.pt.zcu); | 1966 | const ty = val.typeOf(wip_nav.pt.zcu); |
| 1967 | const dibw = &wip_nav.debug_info.buffered_writer; | 1967 | const dibw = &wip_nav.debug_info.buffered_writer; |
| 1968 | const bytes = if (ty.hasRuntimeBits(wip_nav.pt.zcu)) ty.abiSize(wip_nav.pt.zcu) else 0; | 1968 | const bytes = if (ty.hasRuntimeBits(wip_nav.pt.zcu)) ty.abiSize(wip_nav.pt.zcu) else 0; |
| ... | @@ -1996,7 +1996,7 @@ pub const WipNav = struct { | ... | @@ -1996,7 +1996,7 @@ pub const WipNav = struct { |
| 1996 | abbrev_code: AbbrevCodeForForm, | 1996 | abbrev_code: AbbrevCodeForForm, |
| 1997 | ty: Type, | 1997 | ty: Type, |
| 1998 | big_int: std.math.big.int.Const, | 1998 | big_int: std.math.big.int.Const, |
| 1999 | ) anyerror!void { | 1999 | ) UpdateError!void { |
| 2000 | const zcu = wip_nav.pt.zcu; | 2000 | const zcu = wip_nav.pt.zcu; |
| 2001 | const dibw = &wip_nav.debug_info.buffered_writer; | 2001 | const dibw = &wip_nav.debug_info.buffered_writer; |
| 2002 | const signedness = switch (ty.toIntern()) { | 2002 | const signedness = switch (ty.toIntern()) { |
| ... | @@ -2045,7 +2045,7 @@ pub const WipNav = struct { | ... | @@ -2045,7 +2045,7 @@ pub const WipNav = struct { |
| 2045 | loaded_enum: InternPool.LoadedEnumType, | 2045 | loaded_enum: InternPool.LoadedEnumType, |
| 2046 | abbrev_code: AbbrevCodeForForm, | 2046 | abbrev_code: AbbrevCodeForForm, |
| 2047 | field_index: usize, | 2047 | field_index: usize, |
| 2048 | ) anyerror!void { | 2048 | ) UpdateError!void { |
| 2049 | const zcu = wip_nav.pt.zcu; | 2049 | const zcu = wip_nav.pt.zcu; |
| 2050 | const ip = &zcu.intern_pool; | 2050 | const ip = &zcu.intern_pool; |
| 2051 | var big_int_space: Value.BigIntSpace = undefined; | 2051 | var big_int_space: Value.BigIntSpace = undefined; |
| ... | @@ -2065,7 +2065,7 @@ pub const WipNav = struct { | ... | @@ -2065,7 +2065,7 @@ pub const WipNav = struct { |
| 2065 | nav: *const InternPool.Nav, | 2065 | nav: *const InternPool.Nav, |
| 2066 | file: Zcu.File.Index, | 2066 | file: Zcu.File.Index, |
| 2067 | decl: *const std.zig.Zir.Inst.Declaration.Unwrapped, | 2067 | decl: *const std.zig.Zir.Inst.Declaration.Unwrapped, |
| 2068 | ) anyerror!void { | 2068 | ) UpdateError!void { |
| 2069 | const zcu = wip_nav.pt.zcu; | 2069 | const zcu = wip_nav.pt.zcu; |
| 2070 | const ip = &zcu.intern_pool; | 2070 | const ip = &zcu.intern_pool; |
| 2071 | const dwarf = wip_nav.dwarf; | 2071 | const dwarf = wip_nav.dwarf; |
| ... | @@ -2143,7 +2143,7 @@ pub const WipNav = struct { | ... | @@ -2143,7 +2143,7 @@ pub const WipNav = struct { |
| 2143 | const empty: PendingLazy = .{ .types = .empty, .values = .empty }; | 2143 | const empty: PendingLazy = .{ .types = .empty, .values = .empty }; |
| 2144 | }; | 2144 | }; |
| 2145 | 2145 | ||
| 2146 | fn updateLazy(wip_nav: *WipNav, src_loc: Zcu.LazySrcLoc) anyerror!void { | 2146 | fn updateLazy(wip_nav: *WipNav, src_loc: Zcu.LazySrcLoc) UpdateError!void { |
| 2147 | while (true) if (wip_nav.pending_lazy.types.pop()) |pending_ty| | 2147 | while (true) if (wip_nav.pending_lazy.types.pop()) |pending_ty| |
| 2148 | try wip_nav.dwarf.updateLazyType(wip_nav.pt, src_loc, pending_ty, &wip_nav.pending_lazy) | 2148 | try wip_nav.dwarf.updateLazyType(wip_nav.pt, src_loc, pending_ty, &wip_nav.pending_lazy) |
| 2149 | else if (wip_nav.pending_lazy.values.pop()) |pending_val| | 2149 | else if (wip_nav.pending_lazy.values.pop()) |pending_val| |
| ... | @@ -2366,7 +2366,7 @@ pub fn deinit(dwarf: *Dwarf) void { | ... | @@ -2366,7 +2366,7 @@ pub fn deinit(dwarf: *Dwarf) void { |
| 2366 | dwarf.* = undefined; | 2366 | dwarf.* = undefined; |
| 2367 | } | 2367 | } |
| 2368 | 2368 | ||
| 2369 | fn getUnit(dwarf: *Dwarf, mod: *Module) anyerror!Unit.Index { | 2369 | fn getUnit(dwarf: *Dwarf, mod: *Module) !Unit.Index { |
| 2370 | const mod_gop = try dwarf.mods.getOrPut(dwarf.gpa, mod); | 2370 | const mod_gop = try dwarf.mods.getOrPut(dwarf.gpa, mod); |
| 2371 | const unit: Unit.Index = @enumFromInt(mod_gop.index); | 2371 | const unit: Unit.Index = @enumFromInt(mod_gop.index); |
| 2372 | if (!mod_gop.found_existing) { | 2372 | if (!mod_gop.found_existing) { |
| ... | @@ -2494,7 +2494,7 @@ fn initWipNavInner( | ... | @@ -2494,7 +2494,7 @@ fn initWipNavInner( |
| 2494 | pt: Zcu.PerThread, | 2494 | pt: Zcu.PerThread, |
| 2495 | nav_index: InternPool.Nav.Index, | 2495 | nav_index: InternPool.Nav.Index, |
| 2496 | sym_index: u32, | 2496 | sym_index: u32, |
| 2497 | ) anyerror!?WipNav { | 2497 | ) !?WipNav { |
| 2498 | const zcu = pt.zcu; | 2498 | const zcu = pt.zcu; |
| 2499 | const ip = &zcu.intern_pool; | 2499 | const ip = &zcu.intern_pool; |
| 2500 | 2500 | ||
| ... | @@ -2702,7 +2702,7 @@ fn finishWipNavFuncInner( | ... | @@ -2702,7 +2702,7 @@ fn finishWipNavFuncInner( |
| 2702 | nav_index: InternPool.Nav.Index, | 2702 | nav_index: InternPool.Nav.Index, |
| 2703 | code_size: u64, | 2703 | code_size: u64, |
| 2704 | wip_nav: *WipNav, | 2704 | wip_nav: *WipNav, |
| 2705 | ) anyerror!void { | 2705 | ) UpdateError!void { |
| 2706 | const zcu = pt.zcu; | 2706 | const zcu = pt.zcu; |
| 2707 | const ip = &zcu.intern_pool; | 2707 | const ip = &zcu.intern_pool; |
| 2708 | const nav = ip.getNav(nav_index); | 2708 | const nav = ip.getNav(nav_index); |
| ... | @@ -2802,7 +2802,7 @@ fn finishWipNavInner( | ... | @@ -2802,7 +2802,7 @@ fn finishWipNavInner( |
| 2802 | pt: Zcu.PerThread, | 2802 | pt: Zcu.PerThread, |
| 2803 | nav_index: InternPool.Nav.Index, | 2803 | nav_index: InternPool.Nav.Index, |
| 2804 | wip_nav: *WipNav, | 2804 | wip_nav: *WipNav, |
| 2805 | ) anyerror!void { | 2805 | ) UpdateError!void { |
| 2806 | const zcu = pt.zcu; | 2806 | const zcu = pt.zcu; |
| 2807 | const ip = &zcu.intern_pool; | 2807 | const ip = &zcu.intern_pool; |
| 2808 | const nav = ip.getNav(nav_index); | 2808 | const nav = ip.getNav(nav_index); |
| ... | @@ -2822,7 +2822,7 @@ fn finishWipNavInner( | ... | @@ -2822,7 +2822,7 @@ fn finishWipNavInner( |
| 2822 | try wip_nav.updateLazy(zcu.navSrcLoc(nav_index)); | 2822 | try wip_nav.updateLazy(zcu.navSrcLoc(nav_index)); |
| 2823 | } | 2823 | } |
| 2824 | 2824 | ||
| 2825 | fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) anyerror!void { | 2825 | fn updateComptimeNavInner(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool.Nav.Index) !void { |
| 2826 | const zcu = pt.zcu; | 2826 | const zcu = pt.zcu; |
| 2827 | const ip = &zcu.intern_pool; | 2827 | const ip = &zcu.intern_pool; |
| 2828 | const nav_src_loc = zcu.navSrcLoc(nav_index); | 2828 | const nav_src_loc = zcu.navSrcLoc(nav_index); |
| ... | @@ -3276,7 +3276,7 @@ fn updateLazyType( | ... | @@ -3276,7 +3276,7 @@ fn updateLazyType( |
| 3276 | src_loc: Zcu.LazySrcLoc, | 3276 | src_loc: Zcu.LazySrcLoc, |
| 3277 | type_index: InternPool.Index, | 3277 | type_index: InternPool.Index, |
| 3278 | pending_lazy: *WipNav.PendingLazy, | 3278 | pending_lazy: *WipNav.PendingLazy, |
| 3279 | ) anyerror!void { | 3279 | ) UpdateError!void { |
| 3280 | const zcu = pt.zcu; | 3280 | const zcu = pt.zcu; |
| 3281 | const ip = &zcu.intern_pool; | 3281 | const ip = &zcu.intern_pool; |
| 3282 | assert(ip.typeOf(type_index) == .type_type); | 3282 | assert(ip.typeOf(type_index) == .type_type); |
| ... | @@ -3783,7 +3783,7 @@ fn updateLazyValue( | ... | @@ -3783,7 +3783,7 @@ fn updateLazyValue( |
| 3783 | src_loc: Zcu.LazySrcLoc, | 3783 | src_loc: Zcu.LazySrcLoc, |
| 3784 | value_index: InternPool.Index, | 3784 | value_index: InternPool.Index, |
| 3785 | pending_lazy: *WipNav.PendingLazy, | 3785 | pending_lazy: *WipNav.PendingLazy, |
| 3786 | ) anyerror!void { | 3786 | ) UpdateError!void { |
| 3787 | const zcu = pt.zcu; | 3787 | const zcu = pt.zcu; |
| 3788 | const ip = &zcu.intern_pool; | 3788 | const ip = &zcu.intern_pool; |
| 3789 | assert(ip.typeOf(value_index) != .type_type); | 3789 | assert(ip.typeOf(value_index) != .type_type); |
| ... | @@ -4175,7 +4175,7 @@ fn optRepr(opt_child_type: Type, zcu: *const Zcu) enum { | ... | @@ -4175,7 +4175,7 @@ fn optRepr(opt_child_type: Type, zcu: *const Zcu) enum { |
| 4175 | }; | 4175 | }; |
| 4176 | } | 4176 | } |
| 4177 | 4177 | ||
| 4178 | fn updateContainerTypeInner(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternPool.Index) anyerror!void { | 4178 | fn updateContainerTypeInner(dwarf: *Dwarf, pt: Zcu.PerThread, type_index: InternPool.Index) UpdateError!void { |
| 4179 | const zcu = pt.zcu; | 4179 | const zcu = pt.zcu; |
| 4180 | const ip = &zcu.intern_pool; | 4180 | const ip = &zcu.intern_pool; |
| 4181 | const ty: Type = .fromInterned(type_index); | 4181 | const ty: Type = .fromInterned(type_index); |
| ... | @@ -4498,7 +4498,7 @@ pub fn freeNav(dwarf: *Dwarf, nav_index: InternPool.Nav.Index) void { | ... | @@ -4498,7 +4498,7 @@ pub fn freeNav(dwarf: *Dwarf, nav_index: InternPool.Nav.Index) void { |
| 4498 | _ = nav_index; | 4498 | _ = nav_index; |
| 4499 | } | 4499 | } |
| 4500 | 4500 | ||
| 4501 | fn refAbbrevCode(dwarf: *Dwarf, abbrev_code: AbbrevCode) anyerror!@typeInfo(AbbrevCode).@"enum".tag_type { | 4501 | fn refAbbrevCode(dwarf: *Dwarf, abbrev_code: AbbrevCode) UpdateError!@typeInfo(AbbrevCode).@"enum".tag_type { |
| 4502 | assert(abbrev_code != .null); | 4502 | assert(abbrev_code != .null); |
| 4503 | const entry: Entry.Index = @enumFromInt(@intFromEnum(abbrev_code)); | 4503 | const entry: Entry.Index = @enumFromInt(@intFromEnum(abbrev_code)); |
| 4504 | if (dwarf.debug_abbrev.section.getUnit(DebugAbbrev.unit).getEntry(entry).len > 0) return @intFromEnum(abbrev_code); | 4504 | if (dwarf.debug_abbrev.section.getUnit(DebugAbbrev.unit).getEntry(entry).len > 0) return @intFromEnum(abbrev_code); |
| ... | @@ -6063,7 +6063,7 @@ fn addCommonEntry(dwarf: *Dwarf, unit: Unit.Index) UpdateError!Entry.Index { | ... | @@ -6063,7 +6063,7 @@ fn addCommonEntry(dwarf: *Dwarf, unit: Unit.Index) UpdateError!Entry.Index { |
| 6063 | return entry; | 6063 | return entry; |
| 6064 | } | 6064 | } |
| 6065 | 6065 | ||
| 6066 | fn freeCommonEntry(dwarf: *Dwarf, unit: Unit.Index, entry: Entry.Index) anyerror!void { | 6066 | fn freeCommonEntry(dwarf: *Dwarf, unit: Unit.Index, entry: Entry.Index) UpdateError!void { |
| 6067 | try dwarf.debug_aranges.section.freeEntry(unit, entry, dwarf); | 6067 | try dwarf.debug_aranges.section.freeEntry(unit, entry, dwarf); |
| 6068 | try dwarf.debug_frame.section.freeEntry(unit, entry, dwarf); | 6068 | try dwarf.debug_frame.section.freeEntry(unit, entry, dwarf); |
| 6069 | try dwarf.debug_info.section.freeEntry(unit, entry, dwarf); | 6069 | try dwarf.debug_info.section.freeEntry(unit, entry, dwarf); |
| ... | @@ -6082,7 +6082,7 @@ fn writeInt(dwarf: *Dwarf, buf: []u8, int: u64) void { | ... | @@ -6082,7 +6082,7 @@ fn writeInt(dwarf: *Dwarf, buf: []u8, int: u64) void { |
| 6082 | } | 6082 | } |
| 6083 | } | 6083 | } |
| 6084 | 6084 | ||
| 6085 | fn writeIntTo(dwarf: *Dwarf, bw: *std.io.BufferedWriter, len: usize, int: u64) anyerror!void { | 6085 | fn writeIntTo(dwarf: *Dwarf, bw: *std.io.BufferedWriter, len: usize, int: u64) !void { |
| 6086 | dwarf.writeInt((try bw.writableSlice(len))[0..len], int); | 6086 | dwarf.writeInt((try bw.writableSlice(len))[0..len], int); |
| 6087 | bw.advance(len); | 6087 | bw.advance(len); |
| 6088 | } | 6088 | } |
| ... | @@ -6159,3 +6159,4 @@ const link = @import("../link.zig"); | ... | @@ -6159,3 +6159,4 @@ const link = @import("../link.zig"); |
| 6159 | const log = std.log.scoped(.dwarf); | 6159 | const log = std.log.scoped(.dwarf); |
| 6160 | const std = @import("std"); | 6160 | const std = @import("std"); |
| 6161 | const target_info = @import("../target.zig"); | 6161 | const target_info = @import("../target.zig"); |
| 6162 | const Allocator = std.mem.Allocator; |
src/link/Elf.zig+4-4| ... | @@ -2996,7 +2996,7 @@ fn allocateSpecialPhdrs(self: *Elf) void { | ... | @@ -2996,7 +2996,7 @@ fn allocateSpecialPhdrs(self: *Elf) void { |
| 2996 | } | 2996 | } |
| 2997 | } | 2997 | } |
| 2998 | 2998 | ||
| 2999 | fn writeAtoms(self: *Elf) anyerror!void { | 2999 | fn writeAtoms(self: *Elf) !void { |
| 3000 | const gpa = self.base.comp.gpa; | 3000 | const gpa = self.base.comp.gpa; |
| 3001 | 3001 | ||
| 3002 | var undefs: std.AutoArrayHashMap(SymbolResolver.Index, std.ArrayList(Ref)) = .init(gpa); | 3002 | var undefs: std.AutoArrayHashMap(SymbolResolver.Index, std.ArrayList(Ref)) = .init(gpa); |
| ... | @@ -3130,7 +3130,7 @@ pub fn updateSymtabSize(self: *Elf) !void { | ... | @@ -3130,7 +3130,7 @@ pub fn updateSymtabSize(self: *Elf) !void { |
| 3130 | strtab.sh_size = strsize + 1; | 3130 | strtab.sh_size = strsize + 1; |
| 3131 | } | 3131 | } |
| 3132 | 3132 | ||
| 3133 | fn writeSyntheticSections(self: *Elf) anyerror!void { | 3133 | fn writeSyntheticSections(self: *Elf) !void { |
| 3134 | const gpa = self.base.comp.gpa; | 3134 | const gpa = self.base.comp.gpa; |
| 3135 | const slice = self.sections.slice(); | 3135 | const slice = self.sections.slice(); |
| 3136 | 3136 | ||
| ... | @@ -3883,7 +3883,7 @@ fn fmtShdr(self: *Elf, shdr: elf.Elf64_Shdr) std.fmt.Formatter(formatShdr) { | ... | @@ -3883,7 +3883,7 @@ fn fmtShdr(self: *Elf, shdr: elf.Elf64_Shdr) std.fmt.Formatter(formatShdr) { |
| 3883 | } }; | 3883 | } }; |
| 3884 | } | 3884 | } |
| 3885 | 3885 | ||
| 3886 | fn formatShdr(ctx: FormatShdrCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 3886 | fn formatShdr(ctx: FormatShdrCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 3887 | _ = unused_fmt_string; | 3887 | _ = unused_fmt_string; |
| 3888 | const shdr = ctx.shdr; | 3888 | const shdr = ctx.shdr; |
| 3889 | try bw.print("{s} : @{x} ({x}) : align({x}) : size({x}) : entsize({x}) : flags({f})", .{ | 3889 | try bw.print("{s} : @{x} ({x}) : align({x}) : size({x}) : entsize({x}) : flags({f})", .{ |
| ... | @@ -4216,7 +4216,7 @@ pub const Ref = struct { | ... | @@ -4216,7 +4216,7 @@ pub const Ref = struct { |
| 4216 | return ref.index == other.index and ref.file == other.file; | 4216 | return ref.index == other.index and ref.file == other.file; |
| 4217 | } | 4217 | } |
| 4218 | 4218 | ||
| 4219 | pub fn format(ref: Ref, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 4219 | pub fn format(ref: Ref, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 4220 | _ = unused_fmt_string; | 4220 | _ = unused_fmt_string; |
| 4221 | try bw.print("ref({},{})", .{ ref.index, ref.file }); | 4221 | try bw.print("ref({},{})", .{ ref.index, ref.file }); |
| 4222 | } | 4222 | } |
src/link/Elf/Archive.zig+3-3| ... | @@ -184,7 +184,7 @@ pub const ArSymtab = struct { | ... | @@ -184,7 +184,7 @@ pub const ArSymtab = struct { |
| 184 | } | 184 | } |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | pub fn format(ar: ArSymtab, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 187 | pub fn format(ar: ArSymtab, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 188 | _ = ar; | 188 | _ = ar; |
| 189 | _ = bw; | 189 | _ = bw; |
| 190 | _ = unused_fmt_string; | 190 | _ = unused_fmt_string; |
| ... | @@ -203,7 +203,7 @@ pub const ArSymtab = struct { | ... | @@ -203,7 +203,7 @@ pub const ArSymtab = struct { |
| 203 | } }; | 203 | } }; |
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 206 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 207 | _ = unused_fmt_string; | 207 | _ = unused_fmt_string; |
| 208 | const ar = ctx.ar; | 208 | const ar = ctx.ar; |
| 209 | const elf_file = ctx.elf_file; | 209 | const elf_file = ctx.elf_file; |
| ... | @@ -251,7 +251,7 @@ pub const ArStrtab = struct { | ... | @@ -251,7 +251,7 @@ pub const ArStrtab = struct { |
| 251 | try writer.writeAll(ar.buffer.items); | 251 | try writer.writeAll(ar.buffer.items); |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | pub fn format(ar: ArStrtab, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 254 | pub fn format(ar: ArStrtab, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 255 | _ = unused_fmt_string; | 255 | _ = unused_fmt_string; |
| 256 | try bw.print("{f}", .{std.fmt.fmtSliceEscapeLower(ar.buffer.items)}); | 256 | try bw.print("{f}", .{std.fmt.fmtSliceEscapeLower(ar.buffer.items)}); |
| 257 | } | 257 | } |
src/link/Elf/Atom.zig+6-6| ... | @@ -908,7 +908,7 @@ pub fn setExtra(atom: Atom, extras: Extra, elf_file: *Elf) void { | ... | @@ -908,7 +908,7 @@ pub fn setExtra(atom: Atom, extras: Extra, elf_file: *Elf) void { |
| 908 | atom.file(elf_file).?.setAtomExtra(atom.extra_index, extras); | 908 | atom.file(elf_file).?.setAtomExtra(atom.extra_index, extras); |
| 909 | } | 909 | } |
| 910 | 910 | ||
| 911 | pub fn format(atom: Atom, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 911 | pub fn format(atom: Atom, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 912 | _ = atom; | 912 | _ = atom; |
| 913 | _ = bw; | 913 | _ = bw; |
| 914 | _ = unused_fmt_string; | 914 | _ = unused_fmt_string; |
| ... | @@ -927,7 +927,7 @@ const FormatContext = struct { | ... | @@ -927,7 +927,7 @@ const FormatContext = struct { |
| 927 | elf_file: *Elf, | 927 | elf_file: *Elf, |
| 928 | }; | 928 | }; |
| 929 | 929 | ||
| 930 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 930 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 931 | _ = unused_fmt_string; | 931 | _ = unused_fmt_string; |
| 932 | const atom = ctx.atom; | 932 | const atom = ctx.atom; |
| 933 | const elf_file = ctx.elf_file; | 933 | const elf_file = ctx.elf_file; |
| ... | @@ -1080,7 +1080,7 @@ const x86_64 = struct { | ... | @@ -1080,7 +1080,7 @@ const x86_64 = struct { |
| 1080 | args: ResolveArgs, | 1080 | args: ResolveArgs, |
| 1081 | it: *RelocsIterator, | 1081 | it: *RelocsIterator, |
| 1082 | bw: *std.io.BufferedWriter, | 1082 | bw: *std.io.BufferedWriter, |
| 1083 | ) anyerror!void { | 1083 | ) std.io.Writer.Error!void { |
| 1084 | dev.check(.x86_64_backend); | 1084 | dev.check(.x86_64_backend); |
| 1085 | const t = &elf_file.base.comp.root_mod.resolved_target.result; | 1085 | const t = &elf_file.base.comp.root_mod.resolved_target.result; |
| 1086 | const diags = &elf_file.base.comp.link_diags; | 1086 | const diags = &elf_file.base.comp.link_diags; |
| ... | @@ -1212,7 +1212,7 @@ const x86_64 = struct { | ... | @@ -1212,7 +1212,7 @@ const x86_64 = struct { |
| 1212 | target: *const Symbol, | 1212 | target: *const Symbol, |
| 1213 | args: ResolveArgs, | 1213 | args: ResolveArgs, |
| 1214 | bw: *std.io.BufferedWriter, | 1214 | bw: *std.io.BufferedWriter, |
| 1215 | ) anyerror!void { | 1215 | ) std.io.Writer.Error!void { |
| 1216 | dev.check(.x86_64_backend); | 1216 | dev.check(.x86_64_backend); |
| 1217 | 1217 | ||
| 1218 | const r_type: elf.R_X86_64 = @enumFromInt(rel.r_type()); | 1218 | const r_type: elf.R_X86_64 = @enumFromInt(rel.r_type()); |
| ... | @@ -1593,7 +1593,7 @@ const aarch64 = struct { | ... | @@ -1593,7 +1593,7 @@ const aarch64 = struct { |
| 1593 | args: ResolveArgs, | 1593 | args: ResolveArgs, |
| 1594 | it: *RelocsIterator, | 1594 | it: *RelocsIterator, |
| 1595 | bw: *std.io.BufferedWriter, | 1595 | bw: *std.io.BufferedWriter, |
| 1596 | ) anyerror!void { | 1596 | ) std.io.Writer.Error!void { |
| 1597 | _ = it; | 1597 | _ = it; |
| 1598 | 1598 | ||
| 1599 | const diags = &elf_file.base.comp.link_diags; | 1599 | const diags = &elf_file.base.comp.link_diags; |
| ... | @@ -2004,7 +2004,7 @@ const riscv = struct { | ... | @@ -2004,7 +2004,7 @@ const riscv = struct { |
| 2004 | target: *const Symbol, | 2004 | target: *const Symbol, |
| 2005 | args: ResolveArgs, | 2005 | args: ResolveArgs, |
| 2006 | bw: *std.io.BufferedWriter, | 2006 | bw: *std.io.BufferedWriter, |
| 2007 | ) anyerror!void { | 2007 | ) std.io.Writer.Error!void { |
| 2008 | const r_type: elf.R_RISCV = @enumFromInt(rel.r_type()); | 2008 | const r_type: elf.R_RISCV = @enumFromInt(rel.r_type()); |
| 2009 | 2009 | ||
| 2010 | _, const A, const S, const GOT, _, _, const DTP = args; | 2010 | _, const A, const S, const GOT, _, _, const DTP = args; |
src/link/Elf/AtomList.zig+2-2| ... | @@ -167,7 +167,7 @@ pub fn lastAtom(list: AtomList, elf_file: *Elf) *Atom { | ... | @@ -167,7 +167,7 @@ pub fn lastAtom(list: AtomList, elf_file: *Elf) *Atom { |
| 167 | return elf_file.atom(list.atoms.keys()[list.atoms.keys().len - 1]).?; | 167 | return elf_file.atom(list.atoms.keys()[list.atoms.keys().len - 1]).?; |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | pub fn format(list: AtomList, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 170 | pub fn format(list: AtomList, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 171 | _ = list; | 171 | _ = list; |
| 172 | _ = bw; | 172 | _ = bw; |
| 173 | _ = unused_fmt_string; | 173 | _ = unused_fmt_string; |
| ... | @@ -180,7 +180,7 @@ pub fn fmt(list: AtomList, elf_file: *Elf) std.fmt.Formatter(format2) { | ... | @@ -180,7 +180,7 @@ pub fn fmt(list: AtomList, elf_file: *Elf) std.fmt.Formatter(format2) { |
| 180 | return .{ .data = .{ list, elf_file } }; | 180 | return .{ .data = .{ list, elf_file } }; |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | fn format2(ctx: FormatCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 183 | fn format2(ctx: FormatCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 184 | _ = unused_fmt_string; | 184 | _ = unused_fmt_string; |
| 185 | const list, const elf_file = ctx; | 185 | const list, const elf_file = ctx; |
| 186 | try bw.print("list : @{x} : shdr({d}) : align({x}) : size({x})", .{ | 186 | try bw.print("list : @{x} : shdr({d}) : align({x}) : size({x})", .{ |
src/link/Elf/LinkerDefined.zig+1-1| ... | @@ -449,7 +449,7 @@ const FormatContext = struct { | ... | @@ -449,7 +449,7 @@ const FormatContext = struct { |
| 449 | elf_file: *Elf, | 449 | elf_file: *Elf, |
| 450 | }; | 450 | }; |
| 451 | 451 | ||
| 452 | fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 452 | fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 453 | _ = unused_fmt_string; | 453 | _ = unused_fmt_string; |
| 454 | const self = ctx.self; | 454 | const self = ctx.self; |
| 455 | const elf_file = ctx.elf_file; | 455 | const elf_file = ctx.elf_file; |
src/link/Elf/Merge.zig+4-4| ... | @@ -157,7 +157,7 @@ pub const Section = struct { | ... | @@ -157,7 +157,7 @@ pub const Section = struct { |
| 157 | } | 157 | } |
| 158 | }; | 158 | }; |
| 159 | 159 | ||
| 160 | pub fn format(msec: Section, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 160 | pub fn format(msec: Section, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 161 | _ = msec; | 161 | _ = msec; |
| 162 | _ = bw; | 162 | _ = bw; |
| 163 | _ = unused_fmt_string; | 163 | _ = unused_fmt_string; |
| ... | @@ -176,7 +176,7 @@ pub const Section = struct { | ... | @@ -176,7 +176,7 @@ pub const Section = struct { |
| 176 | elf_file: *Elf, | 176 | elf_file: *Elf, |
| 177 | }; | 177 | }; |
| 178 | 178 | ||
| 179 | pub fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 179 | pub fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 180 | _ = unused_fmt_string; | 180 | _ = unused_fmt_string; |
| 181 | const msec = ctx.msec; | 181 | const msec = ctx.msec; |
| 182 | const elf_file = ctx.elf_file; | 182 | const elf_file = ctx.elf_file; |
| ... | @@ -219,7 +219,7 @@ pub const Subsection = struct { | ... | @@ -219,7 +219,7 @@ pub const Subsection = struct { |
| 219 | return msec.bytes.items[msub.string_index..][0..msub.size]; | 219 | return msec.bytes.items[msub.string_index..][0..msub.size]; |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | pub fn format(msub: Subsection, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 222 | pub fn format(msub: Subsection, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 223 | _ = msub; | 223 | _ = msub; |
| 224 | _ = bw; | 224 | _ = bw; |
| 225 | _ = unused_fmt_string; | 225 | _ = unused_fmt_string; |
| ... | @@ -238,7 +238,7 @@ pub const Subsection = struct { | ... | @@ -238,7 +238,7 @@ pub const Subsection = struct { |
| 238 | elf_file: *Elf, | 238 | elf_file: *Elf, |
| 239 | }; | 239 | }; |
| 240 | 240 | ||
| 241 | pub fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 241 | pub fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 242 | _ = unused_fmt_string; | 242 | _ = unused_fmt_string; |
| 243 | const msub = ctx.msub; | 243 | const msub = ctx.msub; |
| 244 | const elf_file = ctx.elf_file; | 244 | const elf_file = ctx.elf_file; |
src/link/Elf/Object.zig+8-8| ... | @@ -1431,7 +1431,7 @@ pub fn group(self: *Object, index: Elf.Group.Index) *Elf.Group { | ... | @@ -1431,7 +1431,7 @@ pub fn group(self: *Object, index: Elf.Group.Index) *Elf.Group { |
| 1431 | return &self.groups.items[index]; | 1431 | return &self.groups.items[index]; |
| 1432 | } | 1432 | } |
| 1433 | 1433 | ||
| 1434 | pub fn format(self: *Object, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 1434 | pub fn format(self: *Object, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 1435 | _ = self; | 1435 | _ = self; |
| 1436 | _ = bw; | 1436 | _ = bw; |
| 1437 | _ = unused_fmt_string; | 1437 | _ = unused_fmt_string; |
| ... | @@ -1450,7 +1450,7 @@ const FormatContext = struct { | ... | @@ -1450,7 +1450,7 @@ const FormatContext = struct { |
| 1450 | elf_file: *Elf, | 1450 | elf_file: *Elf, |
| 1451 | }; | 1451 | }; |
| 1452 | 1452 | ||
| 1453 | fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 1453 | fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 1454 | _ = unused_fmt_string; | 1454 | _ = unused_fmt_string; |
| 1455 | const object = ctx.object; | 1455 | const object = ctx.object; |
| 1456 | const elf_file = ctx.elf_file; | 1456 | const elf_file = ctx.elf_file; |
| ... | @@ -1477,7 +1477,7 @@ pub fn fmtAtoms(self: *Object, elf_file: *Elf) std.fmt.Formatter(formatAtoms) { | ... | @@ -1477,7 +1477,7 @@ pub fn fmtAtoms(self: *Object, elf_file: *Elf) std.fmt.Formatter(formatAtoms) { |
| 1477 | } }; | 1477 | } }; |
| 1478 | } | 1478 | } |
| 1479 | 1479 | ||
| 1480 | fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 1480 | fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 1481 | _ = unused_fmt_string; | 1481 | _ = unused_fmt_string; |
| 1482 | const object = ctx.object; | 1482 | const object = ctx.object; |
| 1483 | try bw.writeAll(" atoms\n"); | 1483 | try bw.writeAll(" atoms\n"); |
| ... | @@ -1494,7 +1494,7 @@ pub fn fmtCies(self: *Object, elf_file: *Elf) std.fmt.Formatter(formatCies) { | ... | @@ -1494,7 +1494,7 @@ pub fn fmtCies(self: *Object, elf_file: *Elf) std.fmt.Formatter(formatCies) { |
| 1494 | } }; | 1494 | } }; |
| 1495 | } | 1495 | } |
| 1496 | 1496 | ||
| 1497 | fn formatCies(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 1497 | fn formatCies(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 1498 | _ = unused_fmt_string; | 1498 | _ = unused_fmt_string; |
| 1499 | const object = ctx.object; | 1499 | const object = ctx.object; |
| 1500 | try bw.writeAll(" cies\n"); | 1500 | try bw.writeAll(" cies\n"); |
| ... | @@ -1510,7 +1510,7 @@ pub fn fmtFdes(self: *Object, elf_file: *Elf) std.fmt.Formatter(formatFdes) { | ... | @@ -1510,7 +1510,7 @@ pub fn fmtFdes(self: *Object, elf_file: *Elf) std.fmt.Formatter(formatFdes) { |
| 1510 | } }; | 1510 | } }; |
| 1511 | } | 1511 | } |
| 1512 | 1512 | ||
| 1513 | fn formatFdes(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 1513 | fn formatFdes(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 1514 | _ = unused_fmt_string; | 1514 | _ = unused_fmt_string; |
| 1515 | const object = ctx.object; | 1515 | const object = ctx.object; |
| 1516 | try bw.writeAll(" fdes\n"); | 1516 | try bw.writeAll(" fdes\n"); |
| ... | @@ -1526,8 +1526,8 @@ pub fn fmtGroups(self: *Object, elf_file: *Elf) std.fmt.Formatter(formatGroups) | ... | @@ -1526,8 +1526,8 @@ pub fn fmtGroups(self: *Object, elf_file: *Elf) std.fmt.Formatter(formatGroups) |
| 1526 | } }; | 1526 | } }; |
| 1527 | } | 1527 | } |
| 1528 | 1528 | ||
| 1529 | fn formatGroups(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 1529 | fn formatGroups(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 1530 | _ = unused_fmt_string; | 1530 | comptime assert(unused_fmt_string.len == 0); |
| 1531 | const object = ctx.object; | 1531 | const object = ctx.object; |
| 1532 | const elf_file = ctx.elf_file; | 1532 | const elf_file = ctx.elf_file; |
| 1533 | try bw.writeAll(" groups\n"); | 1533 | try bw.writeAll(" groups\n"); |
| ... | @@ -1548,7 +1548,7 @@ pub fn fmtPath(self: Object) std.fmt.Formatter(formatPath) { | ... | @@ -1548,7 +1548,7 @@ pub fn fmtPath(self: Object) std.fmt.Formatter(formatPath) { |
| 1548 | return .{ .data = self }; | 1548 | return .{ .data = self }; |
| 1549 | } | 1549 | } |
| 1550 | 1550 | ||
| 1551 | fn formatPath(object: Object, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 1551 | fn formatPath(object: Object, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 1552 | _ = unused_fmt_string; | 1552 | _ = unused_fmt_string; |
| 1553 | if (object.archive) |ar| { | 1553 | if (object.archive) |ar| { |
| 1554 | try bw.print("{f}({f})", .{ ar.path, object.path }); | 1554 | try bw.print("{f}({f})", .{ ar.path, object.path }); |
src/link/Elf/SharedObject.zig+2-2| ... | @@ -509,7 +509,7 @@ pub fn setSymbolExtra(self: *SharedObject, index: u32, extra: Symbol.Extra) void | ... | @@ -509,7 +509,7 @@ pub fn setSymbolExtra(self: *SharedObject, index: u32, extra: Symbol.Extra) void |
| 509 | } | 509 | } |
| 510 | } | 510 | } |
| 511 | 511 | ||
| 512 | pub fn format(self: SharedObject, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 512 | pub fn format(self: SharedObject, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 513 | _ = self; | 513 | _ = self; |
| 514 | _ = bw; | 514 | _ = bw; |
| 515 | _ = unused_fmt_string; | 515 | _ = unused_fmt_string; |
| ... | @@ -528,7 +528,7 @@ const FormatContext = struct { | ... | @@ -528,7 +528,7 @@ const FormatContext = struct { |
| 528 | elf_file: *Elf, | 528 | elf_file: *Elf, |
| 529 | }; | 529 | }; |
| 530 | 530 | ||
| 531 | fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 531 | fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 532 | _ = unused_fmt_string; | 532 | _ = unused_fmt_string; |
| 533 | const shared = ctx.shared; | 533 | const shared = ctx.shared; |
| 534 | const elf_file = ctx.elf_file; | 534 | const elf_file = ctx.elf_file; |
src/link/Elf/Symbol.zig+3-3| ... | @@ -316,7 +316,7 @@ pub fn setOutputSym(symbol: Symbol, elf_file: *Elf, out: *elf.Elf64_Sym) void { | ... | @@ -316,7 +316,7 @@ pub fn setOutputSym(symbol: Symbol, elf_file: *Elf, out: *elf.Elf64_Sym) void { |
| 316 | out.st_size = esym.st_size; | 316 | out.st_size = esym.st_size; |
| 317 | } | 317 | } |
| 318 | 318 | ||
| 319 | pub fn format(symbol: Symbol, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 319 | pub fn format(symbol: Symbol, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 320 | _ = symbol; | 320 | _ = symbol; |
| 321 | _ = bw; | 321 | _ = bw; |
| 322 | _ = unused_fmt_string; | 322 | _ = unused_fmt_string; |
| ... | @@ -335,7 +335,7 @@ pub fn fmtName(symbol: Symbol, elf_file: *Elf) std.fmt.Formatter(formatName) { | ... | @@ -335,7 +335,7 @@ pub fn fmtName(symbol: Symbol, elf_file: *Elf) std.fmt.Formatter(formatName) { |
| 335 | } }; | 335 | } }; |
| 336 | } | 336 | } |
| 337 | 337 | ||
| 338 | fn formatName(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 338 | fn formatName(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 339 | _ = unused_fmt_string; | 339 | _ = unused_fmt_string; |
| 340 | const elf_file = ctx.elf_file; | 340 | const elf_file = ctx.elf_file; |
| 341 | const symbol = ctx.symbol; | 341 | const symbol = ctx.symbol; |
| ... | @@ -358,7 +358,7 @@ pub fn fmt(symbol: Symbol, elf_file: *Elf) std.fmt.Formatter(format2) { | ... | @@ -358,7 +358,7 @@ pub fn fmt(symbol: Symbol, elf_file: *Elf) std.fmt.Formatter(format2) { |
| 358 | } }; | 358 | } }; |
| 359 | } | 359 | } |
| 360 | 360 | ||
| 361 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 361 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 362 | _ = unused_fmt_string; | 362 | _ = unused_fmt_string; |
| 363 | const symbol = ctx.symbol; | 363 | const symbol = ctx.symbol; |
| 364 | const elf_file = ctx.elf_file; | 364 | const elf_file = ctx.elf_file; |
src/link/Elf/Thunk.zig+2-2| ... | @@ -65,7 +65,7 @@ fn trampolineSize(cpu_arch: std.Target.Cpu.Arch) usize { | ... | @@ -65,7 +65,7 @@ fn trampolineSize(cpu_arch: std.Target.Cpu.Arch) usize { |
| 65 | }; | 65 | }; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | pub fn format(thunk: Thunk, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 68 | pub fn format(thunk: Thunk, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 69 | _ = thunk; | 69 | _ = thunk; |
| 70 | _ = bw; | 70 | _ = bw; |
| 71 | _ = unused_fmt_string; | 71 | _ = unused_fmt_string; |
| ... | @@ -84,7 +84,7 @@ const FormatContext = struct { | ... | @@ -84,7 +84,7 @@ const FormatContext = struct { |
| 84 | elf_file: *Elf, | 84 | elf_file: *Elf, |
| 85 | }; | 85 | }; |
| 86 | 86 | ||
| 87 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 87 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 88 | _ = unused_fmt_string; | 88 | _ = unused_fmt_string; |
| 89 | const thunk = ctx.thunk; | 89 | const thunk = ctx.thunk; |
| 90 | const elf_file = ctx.elf_file; | 90 | const elf_file = ctx.elf_file; |
src/link/Elf/ZigObject.zig+2-2| ... | @@ -2198,7 +2198,7 @@ const FormatContext = struct { | ... | @@ -2198,7 +2198,7 @@ const FormatContext = struct { |
| 2198 | elf_file: *Elf, | 2198 | elf_file: *Elf, |
| 2199 | }; | 2199 | }; |
| 2200 | 2200 | ||
| 2201 | fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 2201 | fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 2202 | _ = unused_fmt_string; | 2202 | _ = unused_fmt_string; |
| 2203 | const self = ctx.self; | 2203 | const self = ctx.self; |
| 2204 | const elf_file = ctx.elf_file; | 2204 | const elf_file = ctx.elf_file; |
| ... | @@ -2221,7 +2221,7 @@ pub fn fmtAtoms(self: *ZigObject, elf_file: *Elf) std.fmt.Formatter(formatAtoms) | ... | @@ -2221,7 +2221,7 @@ pub fn fmtAtoms(self: *ZigObject, elf_file: *Elf) std.fmt.Formatter(formatAtoms) |
| 2221 | } }; | 2221 | } }; |
| 2222 | } | 2222 | } |
| 2223 | 2223 | ||
| 2224 | fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 2224 | fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 2225 | _ = unused_fmt_string; | 2225 | _ = unused_fmt_string; |
| 2226 | try bw.writeAll(" atoms\n"); | 2226 | try bw.writeAll(" atoms\n"); |
| 2227 | for (ctx.self.atoms_indexes.items) |atom_index| { | 2227 | for (ctx.self.atoms_indexes.items) |atom_index| { |
src/link/Elf/file.zig+1-1| ... | @@ -14,7 +14,7 @@ pub const File = union(enum) { | ... | @@ -14,7 +14,7 @@ pub const File = union(enum) { |
| 14 | return .{ .data = file }; | 14 | return .{ .data = file }; |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | fn formatPath(file: File, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 17 | fn formatPath(file: File, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 18 | _ = unused_fmt_string; | 18 | _ = unused_fmt_string; |
| 19 | switch (file) { | 19 | switch (file) { |
| 20 | .zig_object => |zo| try bw.writeAll(zo.basename), | 20 | .zig_object => |zo| try bw.writeAll(zo.basename), |
src/link/Elf/gc.zig+1-1| ... | @@ -185,7 +185,7 @@ const Level = struct { | ... | @@ -185,7 +185,7 @@ const Level = struct { |
| 185 | self.value += 1; | 185 | self.value += 1; |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | pub fn format(self: *const @This(), bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 188 | pub fn format(self: *const @This(), bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 189 | _ = unused_fmt_string; | 189 | _ = unused_fmt_string; |
| 190 | try bw.splatByteAll(' ', self.value); | 190 | try bw.splatByteAll(' ', self.value); |
| 191 | } | 191 | } |
src/link/Elf/relocation.zig+1-1| ... | @@ -148,7 +148,7 @@ pub fn fmtRelocType(r_type: u32, cpu_arch: std.Target.Cpu.Arch) std.fmt.Formatte | ... | @@ -148,7 +148,7 @@ pub fn fmtRelocType(r_type: u32, cpu_arch: std.Target.Cpu.Arch) std.fmt.Formatte |
| 148 | } }; | 148 | } }; |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | fn formatRelocType(ctx: FormatRelocTypeCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 151 | fn formatRelocType(ctx: FormatRelocTypeCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 152 | _ = unused_fmt_string; | 152 | _ = unused_fmt_string; |
| 153 | const r_type = ctx.r_type; | 153 | const r_type = ctx.r_type; |
| 154 | switch (ctx.cpu_arch) { | 154 | switch (ctx.cpu_arch) { |
src/link/Elf/synthetic_sections.zig+16-16| ... | @@ -94,7 +94,7 @@ pub const DynamicSection = struct { | ... | @@ -94,7 +94,7 @@ pub const DynamicSection = struct { |
| 94 | return nentries * @sizeOf(elf.Elf64_Dyn); | 94 | return nentries * @sizeOf(elf.Elf64_Dyn); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | pub fn write(dt: DynamicSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void { | 97 | pub fn write(dt: DynamicSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 98 | const shdrs = elf_file.sections.items(.shdr); | 98 | const shdrs = elf_file.sections.items(.shdr); |
| 99 | 99 | ||
| 100 | // NEEDED | 100 | // NEEDED |
| ... | @@ -360,7 +360,7 @@ pub const GotSection = struct { | ... | @@ -360,7 +360,7 @@ pub const GotSection = struct { |
| 360 | return s; | 360 | return s; |
| 361 | } | 361 | } |
| 362 | 362 | ||
| 363 | pub fn write(got: GotSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void { | 363 | pub fn write(got: GotSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 364 | const comp = elf_file.base.comp; | 364 | const comp = elf_file.base.comp; |
| 365 | const is_dyn_lib = elf_file.isEffectivelyDynLib(); | 365 | const is_dyn_lib = elf_file.isEffectivelyDynLib(); |
| 366 | const apply_relocs = true; // TODO add user option for this | 366 | const apply_relocs = true; // TODO add user option for this |
| ... | @@ -615,7 +615,7 @@ pub const GotSection = struct { | ... | @@ -615,7 +615,7 @@ pub const GotSection = struct { |
| 615 | return .{ .data = .{ .got = got, .elf_file = elf_file } }; | 615 | return .{ .data = .{ .got = got, .elf_file = elf_file } }; |
| 616 | } | 616 | } |
| 617 | 617 | ||
| 618 | pub fn format2(ctx: FormatCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 618 | pub fn format2(ctx: FormatCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 619 | _ = unused_fmt_string; | 619 | _ = unused_fmt_string; |
| 620 | const got = ctx.got; | 620 | const got = ctx.got; |
| 621 | const elf_file = ctx.elf_file; | 621 | const elf_file = ctx.elf_file; |
| ... | @@ -672,7 +672,7 @@ pub const PltSection = struct { | ... | @@ -672,7 +672,7 @@ pub const PltSection = struct { |
| 672 | }; | 672 | }; |
| 673 | } | 673 | } |
| 674 | 674 | ||
| 675 | pub fn write(plt: PltSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void { | 675 | pub fn write(plt: PltSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 676 | const cpu_arch = elf_file.getTarget().cpu.arch; | 676 | const cpu_arch = elf_file.getTarget().cpu.arch; |
| 677 | switch (cpu_arch) { | 677 | switch (cpu_arch) { |
| 678 | .x86_64 => try x86_64.write(plt, elf_file, bw), | 678 | .x86_64 => try x86_64.write(plt, elf_file, bw), |
| ... | @@ -752,7 +752,7 @@ pub const PltSection = struct { | ... | @@ -752,7 +752,7 @@ pub const PltSection = struct { |
| 752 | return .{ .data = .{ .plt = plt, .elf_file = elf_file } }; | 752 | return .{ .data = .{ .plt = plt, .elf_file = elf_file } }; |
| 753 | } | 753 | } |
| 754 | 754 | ||
| 755 | pub fn format2(ctx: FormatCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 755 | pub fn format2(ctx: FormatCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 756 | _ = unused_fmt_string; | 756 | _ = unused_fmt_string; |
| 757 | const plt = ctx.plt; | 757 | const plt = ctx.plt; |
| 758 | const elf_file = ctx.elf_file; | 758 | const elf_file = ctx.elf_file; |
| ... | @@ -770,7 +770,7 @@ pub const PltSection = struct { | ... | @@ -770,7 +770,7 @@ pub const PltSection = struct { |
| 770 | } | 770 | } |
| 771 | 771 | ||
| 772 | const x86_64 = struct { | 772 | const x86_64 = struct { |
| 773 | fn write(plt: PltSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void { | 773 | fn write(plt: PltSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 774 | const shdrs = elf_file.sections.items(.shdr); | 774 | const shdrs = elf_file.sections.items(.shdr); |
| 775 | const plt_addr = shdrs[elf_file.section_indexes.plt.?].sh_addr; | 775 | const plt_addr = shdrs[elf_file.section_indexes.plt.?].sh_addr; |
| 776 | const got_plt_addr = shdrs[elf_file.section_indexes.got_plt.?].sh_addr; | 776 | const got_plt_addr = shdrs[elf_file.section_indexes.got_plt.?].sh_addr; |
| ... | @@ -805,7 +805,7 @@ pub const PltSection = struct { | ... | @@ -805,7 +805,7 @@ pub const PltSection = struct { |
| 805 | }; | 805 | }; |
| 806 | 806 | ||
| 807 | const aarch64 = struct { | 807 | const aarch64 = struct { |
| 808 | fn write(plt: PltSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void { | 808 | fn write(plt: PltSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 809 | { | 809 | { |
| 810 | const shdrs = elf_file.sections.items(.shdr); | 810 | const shdrs = elf_file.sections.items(.shdr); |
| 811 | const plt_addr: i64 = @intCast(shdrs[elf_file.section_indexes.plt.?].sh_addr); | 811 | const plt_addr: i64 = @intCast(shdrs[elf_file.section_indexes.plt.?].sh_addr); |
| ... | @@ -871,7 +871,7 @@ pub const GotPltSection = struct { | ... | @@ -871,7 +871,7 @@ pub const GotPltSection = struct { |
| 871 | return preamble_size + elf_file.plt.symbols.items.len * 8; | 871 | return preamble_size + elf_file.plt.symbols.items.len * 8; |
| 872 | } | 872 | } |
| 873 | 873 | ||
| 874 | pub fn write(got_plt: GotPltSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void { | 874 | pub fn write(got_plt: GotPltSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 875 | _ = got_plt; | 875 | _ = got_plt; |
| 876 | { | 876 | { |
| 877 | // [0]: _DYNAMIC | 877 | // [0]: _DYNAMIC |
| ... | @@ -922,7 +922,7 @@ pub const PltGotSection = struct { | ... | @@ -922,7 +922,7 @@ pub const PltGotSection = struct { |
| 922 | }; | 922 | }; |
| 923 | } | 923 | } |
| 924 | 924 | ||
| 925 | pub fn write(plt_got: PltGotSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void { | 925 | pub fn write(plt_got: PltGotSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 926 | const cpu_arch = elf_file.getTarget().cpu.arch; | 926 | const cpu_arch = elf_file.getTarget().cpu.arch; |
| 927 | switch (cpu_arch) { | 927 | switch (cpu_arch) { |
| 928 | .x86_64 => try x86_64.write(plt_got, elf_file, bw), | 928 | .x86_64 => try x86_64.write(plt_got, elf_file, bw), |
| ... | @@ -958,7 +958,7 @@ pub const PltGotSection = struct { | ... | @@ -958,7 +958,7 @@ pub const PltGotSection = struct { |
| 958 | } | 958 | } |
| 959 | 959 | ||
| 960 | const x86_64 = struct { | 960 | const x86_64 = struct { |
| 961 | pub fn write(plt_got: PltGotSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void { | 961 | pub fn write(plt_got: PltGotSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 962 | for (plt_got.symbols.items) |ref| { | 962 | for (plt_got.symbols.items) |ref| { |
| 963 | const sym = elf_file.symbol(ref).?; | 963 | const sym = elf_file.symbol(ref).?; |
| 964 | const target_addr = sym.gotAddress(elf_file); | 964 | const target_addr = sym.gotAddress(elf_file); |
| ... | @@ -976,7 +976,7 @@ pub const PltGotSection = struct { | ... | @@ -976,7 +976,7 @@ pub const PltGotSection = struct { |
| 976 | }; | 976 | }; |
| 977 | 977 | ||
| 978 | const aarch64 = struct { | 978 | const aarch64 = struct { |
| 979 | fn write(plt_got: PltGotSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void { | 979 | fn write(plt_got: PltGotSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 980 | for (plt_got.symbols.items) |ref| { | 980 | for (plt_got.symbols.items) |ref| { |
| 981 | const sym = elf_file.symbol(ref).?; | 981 | const sym = elf_file.symbol(ref).?; |
| 982 | const target_addr = sym.gotAddress(elf_file); | 982 | const target_addr = sym.gotAddress(elf_file); |
| ... | @@ -1155,7 +1155,7 @@ pub const DynsymSection = struct { | ... | @@ -1155,7 +1155,7 @@ pub const DynsymSection = struct { |
| 1155 | return @as(u32, @intCast(dynsym.entries.items.len + 1)); | 1155 | return @as(u32, @intCast(dynsym.entries.items.len + 1)); |
| 1156 | } | 1156 | } |
| 1157 | 1157 | ||
| 1158 | pub fn write(dynsym: DynsymSection, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void { | 1158 | pub fn write(dynsym: DynsymSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 1159 | try bw.writeStruct(Elf.null_sym); | 1159 | try bw.writeStruct(Elf.null_sym); |
| 1160 | for (dynsym.entries.items) |entry| { | 1160 | for (dynsym.entries.items) |entry| { |
| 1161 | const sym = elf_file.symbol(entry.ref).?; | 1161 | const sym = elf_file.symbol(entry.ref).?; |
| ... | @@ -1458,7 +1458,7 @@ pub const VerneedSection = struct { | ... | @@ -1458,7 +1458,7 @@ pub const VerneedSection = struct { |
| 1458 | return vern.verneed.items.len * @sizeOf(elf.Elf64_Verneed) + vern.vernaux.items.len * @sizeOf(elf.Vernaux); | 1458 | return vern.verneed.items.len * @sizeOf(elf.Elf64_Verneed) + vern.vernaux.items.len * @sizeOf(elf.Vernaux); |
| 1459 | } | 1459 | } |
| 1460 | 1460 | ||
| 1461 | pub fn write(vern: VerneedSection, bw: *std.io.BufferedWriter) anyerror!void { | 1461 | pub fn write(vern: VerneedSection, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 1462 | try bw.writeAll(mem.sliceAsBytes(vern.verneed.items)); | 1462 | try bw.writeAll(mem.sliceAsBytes(vern.verneed.items)); |
| 1463 | try bw.writeAll(mem.sliceAsBytes(vern.vernaux.items)); | 1463 | try bw.writeAll(mem.sliceAsBytes(vern.vernaux.items)); |
| 1464 | } | 1464 | } |
| ... | @@ -1486,8 +1486,8 @@ pub const GroupSection = struct { | ... | @@ -1486,8 +1486,8 @@ pub const GroupSection = struct { |
| 1486 | return (members.len + 1) * @sizeOf(u32); | 1486 | return (members.len + 1) * @sizeOf(u32); |
| 1487 | } | 1487 | } |
| 1488 | 1488 | ||
| 1489 | pub fn write(cgs: GroupSection, elf_file: *Elf, bw: *std.io.BufferedWriter) !void { | 1489 | pub fn write(cgs: GroupSection, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 1490 | const cg = cgs.group(elf_file); | 1490 | const cg = cgs.comdatGroup(elf_file); |
| 1491 | const object = cg.file(elf_file).object; | 1491 | const object = cg.file(elf_file).object; |
| 1492 | const members = cg.members(elf_file); | 1492 | const members = cg.members(elf_file); |
| 1493 | try bw.writeInt(u32, if (cg.is_comdat) elf.GRP_COMDAT else 0, .little); | 1493 | try bw.writeInt(u32, if (cg.is_comdat) elf.GRP_COMDAT else 0, .little); |
| ... | @@ -1514,7 +1514,7 @@ pub const GroupSection = struct { | ... | @@ -1514,7 +1514,7 @@ pub const GroupSection = struct { |
| 1514 | } | 1514 | } |
| 1515 | }; | 1515 | }; |
| 1516 | 1516 | ||
| 1517 | fn writeInt(value: anytype, elf_file: *Elf, bw: *std.io.BufferedWriter) anyerror!void { | 1517 | fn writeInt(value: anytype, elf_file: *Elf, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 1518 | const entry_size = elf_file.archPtrWidthBytes(); | 1518 | const entry_size = elf_file.archPtrWidthBytes(); |
| 1519 | const target = elf_file.getTarget(); | 1519 | const target = elf_file.getTarget(); |
| 1520 | const endian = target.cpu.arch.endian(); | 1520 | const endian = target.cpu.arch.endian(); |
src/link/MachO.zig+7-7| ... | @@ -2822,7 +2822,7 @@ fn calcSymtabSize(self: *MachO) !void { | ... | @@ -2822,7 +2822,7 @@ fn calcSymtabSize(self: *MachO) !void { |
| 2822 | } | 2822 | } |
| 2823 | } | 2823 | } |
| 2824 | 2824 | ||
| 2825 | fn writeLoadCommands(self: *MachO) anyerror!struct { usize, usize, u64 } { | 2825 | fn writeLoadCommands(self: *MachO) std.io.Writer.Error!struct { usize, usize, u64 } { |
| 2826 | const comp = self.base.comp; | 2826 | const comp = self.base.comp; |
| 2827 | const gpa = comp.gpa; | 2827 | const gpa = comp.gpa; |
| 2828 | 2828 | ||
| ... | @@ -3910,7 +3910,7 @@ pub fn dumpState(self: *MachO) std.fmt.Formatter(fmtDumpState) { | ... | @@ -3910,7 +3910,7 @@ pub fn dumpState(self: *MachO) std.fmt.Formatter(fmtDumpState) { |
| 3910 | return .{ .data = self }; | 3910 | return .{ .data = self }; |
| 3911 | } | 3911 | } |
| 3912 | 3912 | ||
| 3913 | fn fmtDumpState(self: *MachO, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 3913 | fn fmtDumpState(self: *MachO, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 3914 | _ = unused_fmt_string; | 3914 | _ = unused_fmt_string; |
| 3915 | if (self.getZigObject()) |zo| { | 3915 | if (self.getZigObject()) |zo| { |
| 3916 | try bw.print("zig_object({d}) : {s}\n", .{ zo.index, zo.basename }); | 3916 | try bw.print("zig_object({d}) : {s}\n", .{ zo.index, zo.basename }); |
| ... | @@ -3969,7 +3969,7 @@ fn fmtSections(self: *MachO) std.fmt.Formatter(formatSections) { | ... | @@ -3969,7 +3969,7 @@ fn fmtSections(self: *MachO) std.fmt.Formatter(formatSections) { |
| 3969 | return .{ .data = self }; | 3969 | return .{ .data = self }; |
| 3970 | } | 3970 | } |
| 3971 | 3971 | ||
| 3972 | fn formatSections(self: *MachO, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 3972 | fn formatSections(self: *MachO, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 3973 | _ = unused_fmt_string; | 3973 | _ = unused_fmt_string; |
| 3974 | const slice = self.sections.slice(); | 3974 | const slice = self.sections.slice(); |
| 3975 | for (slice.items(.header), slice.items(.segment_id), 0..) |header, seg_id, i| { | 3975 | for (slice.items(.header), slice.items(.segment_id), 0..) |header, seg_id, i| { |
| ... | @@ -3987,7 +3987,7 @@ fn fmtSegments(self: *MachO) std.fmt.Formatter(formatSegments) { | ... | @@ -3987,7 +3987,7 @@ fn fmtSegments(self: *MachO) std.fmt.Formatter(formatSegments) { |
| 3987 | return .{ .data = self }; | 3987 | return .{ .data = self }; |
| 3988 | } | 3988 | } |
| 3989 | 3989 | ||
| 3990 | fn formatSegments(self: *MachO, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 3990 | fn formatSegments(self: *MachO, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 3991 | _ = unused_fmt_string; | 3991 | _ = unused_fmt_string; |
| 3992 | for (self.segments.items, 0..) |seg, i| { | 3992 | for (self.segments.items, 0..) |seg, i| { |
| 3993 | try bw.print("seg({d}) : {s} : @{x}-{x} ({x}-{x})\n", .{ | 3993 | try bw.print("seg({d}) : {s} : @{x}-{x} ({x}-{x})\n", .{ |
| ... | @@ -4001,7 +4001,7 @@ pub fn fmtSectType(tt: u8) std.fmt.Formatter(formatSectType) { | ... | @@ -4001,7 +4001,7 @@ pub fn fmtSectType(tt: u8) std.fmt.Formatter(formatSectType) { |
| 4001 | return .{ .data = tt }; | 4001 | return .{ .data = tt }; |
| 4002 | } | 4002 | } |
| 4003 | 4003 | ||
| 4004 | fn formatSectType(tt: u8, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 4004 | fn formatSectType(tt: u8, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 4005 | _ = unused_fmt_string; | 4005 | _ = unused_fmt_string; |
| 4006 | const name = switch (tt) { | 4006 | const name = switch (tt) { |
| 4007 | macho.S_REGULAR => "REGULAR", | 4007 | macho.S_REGULAR => "REGULAR", |
| ... | @@ -4270,7 +4270,7 @@ pub const Platform = struct { | ... | @@ -4270,7 +4270,7 @@ pub const Platform = struct { |
| 4270 | cpu_arch: std.Target.Cpu.Arch, | 4270 | cpu_arch: std.Target.Cpu.Arch, |
| 4271 | }; | 4271 | }; |
| 4272 | 4272 | ||
| 4273 | pub fn formatTarget(ctx: FmtCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 4273 | pub fn formatTarget(ctx: FmtCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 4274 | _ = unused_fmt_string; | 4274 | _ = unused_fmt_string; |
| 4275 | try bw.print("{s}-{s}", .{ @tagName(ctx.cpu_arch), @tagName(ctx.platform.os_tag) }); | 4275 | try bw.print("{s}-{s}", .{ @tagName(ctx.cpu_arch), @tagName(ctx.platform.os_tag) }); |
| 4276 | if (ctx.platform.abi != .none) { | 4276 | if (ctx.platform.abi != .none) { |
| ... | @@ -4483,7 +4483,7 @@ pub const Ref = struct { | ... | @@ -4483,7 +4483,7 @@ pub const Ref = struct { |
| 4483 | }; | 4483 | }; |
| 4484 | } | 4484 | } |
| 4485 | 4485 | ||
| 4486 | pub fn format(ref: Ref, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 4486 | pub fn format(ref: Ref, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 4487 | _ = unused_fmt_string; | 4487 | _ = unused_fmt_string; |
| 4488 | try bw.print("%{d} in file({d})", .{ ref.index, ref.file }); | 4488 | try bw.print("%{d} in file({d})", .{ ref.index, ref.file }); |
| 4489 | } | 4489 | } |
src/link/MachO/Archive.zig+4-4| ... | @@ -82,7 +82,7 @@ pub fn writeHeader( | ... | @@ -82,7 +82,7 @@ pub fn writeHeader( |
| 82 | object_name: []const u8, | 82 | object_name: []const u8, |
| 83 | object_size: usize, | 83 | object_size: usize, |
| 84 | format: Format, | 84 | format: Format, |
| 85 | ) anyerror!void { | 85 | ) std.io.Writer.Error!void { |
| 86 | var hdr: ar_hdr = undefined; | 86 | var hdr: ar_hdr = undefined; |
| 87 | @memset(mem.asBytes(&hdr), ' '); | 87 | @memset(mem.asBytes(&hdr), ' '); |
| 88 | inline for (@typeInfo(ar_hdr).@"struct".fields) |field| @field(hdr, field.name)[0] = '0'; | 88 | inline for (@typeInfo(ar_hdr).@"struct".fields) |field| @field(hdr, field.name)[0] = '0'; |
| ... | @@ -177,7 +177,7 @@ pub const ArSymtab = struct { | ... | @@ -177,7 +177,7 @@ pub const ArSymtab = struct { |
| 177 | return ptr_width + ar.entries.items.len * 2 * ptr_width + ptr_width + mem.alignForward(usize, ar.strtab.buffer.items.len, ptr_width); | 177 | return ptr_width + ar.entries.items.len * 2 * ptr_width + ptr_width + mem.alignForward(usize, ar.strtab.buffer.items.len, ptr_width); |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | pub fn write(ar: ArSymtab, bw: *std.io.BufferedWriter, format: Format, macho_file: *MachO) anyerror!void { | 180 | pub fn write(ar: ArSymtab, bw: *std.io.BufferedWriter, format: Format, macho_file: *MachO) std.io.Writer.Error!void { |
| 181 | const ptr_width = ptrWidth(format); | 181 | const ptr_width = ptrWidth(format); |
| 182 | // Header | 182 | // Header |
| 183 | try writeHeader(bw, SYMDEF, ar.size(format), format); | 183 | try writeHeader(bw, SYMDEF, ar.size(format), format); |
| ... | @@ -212,7 +212,7 @@ pub const ArSymtab = struct { | ... | @@ -212,7 +212,7 @@ pub const ArSymtab = struct { |
| 212 | return .{ .data = .{ .ar = ar, .macho_file = macho_file } }; | 212 | return .{ .data = .{ .ar = ar, .macho_file = macho_file } }; |
| 213 | } | 213 | } |
| 214 | 214 | ||
| 215 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 215 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 216 | _ = unused_fmt_string; | 216 | _ = unused_fmt_string; |
| 217 | const ar = ctx.ar; | 217 | const ar = ctx.ar; |
| 218 | const macho_file = ctx.macho_file; | 218 | const macho_file = ctx.macho_file; |
| ... | @@ -249,7 +249,7 @@ pub fn ptrWidth(format: Format) usize { | ... | @@ -249,7 +249,7 @@ pub fn ptrWidth(format: Format) usize { |
| 249 | }; | 249 | }; |
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | pub fn writeInt(bw: *std.io.BufferedWriter, format: Format, value: u64) anyerror!void { | 252 | pub fn writeInt(bw: *std.io.BufferedWriter, format: Format, value: u64) std.io.Writer.Error!void { |
| 253 | switch (format) { | 253 | switch (format) { |
| 254 | .p32 => try bw.writeInt(u32, std.math.cast(u32, value) orelse return error.Overflow, .little), | 254 | .p32 => try bw.writeInt(u32, std.math.cast(u32, value) orelse return error.Overflow, .little), |
| 255 | .p64 => try bw.writeInt(u64, value, .little), | 255 | .p64 => try bw.writeInt(u64, value, .little), |
src/link/MachO/Atom.zig+2-2| ... | @@ -639,7 +639,7 @@ fn resolveRelocInner( | ... | @@ -639,7 +639,7 @@ fn resolveRelocInner( |
| 639 | code: []u8, | 639 | code: []u8, |
| 640 | macho_file: *MachO, | 640 | macho_file: *MachO, |
| 641 | bw: *std.io.BufferedWriter, | 641 | bw: *std.io.BufferedWriter, |
| 642 | ) anyerror!void { | 642 | ) std.io.Writer.Error!void { |
| 643 | const t = &macho_file.base.comp.root_mod.resolved_target.result; | 643 | const t = &macho_file.base.comp.root_mod.resolved_target.result; |
| 644 | const cpu_arch = t.cpu.arch; | 644 | const cpu_arch = t.cpu.arch; |
| 645 | const rel_offset = math.cast(usize, rel.offset - self.off) orelse return error.Overflow; | 645 | const rel_offset = math.cast(usize, rel.offset - self.off) orelse return error.Overflow; |
| ... | @@ -1140,7 +1140,7 @@ const FormatContext = struct { | ... | @@ -1140,7 +1140,7 @@ const FormatContext = struct { |
| 1140 | macho_file: *MachO, | 1140 | macho_file: *MachO, |
| 1141 | }; | 1141 | }; |
| 1142 | 1142 | ||
| 1143 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 1143 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 1144 | _ = unused_fmt_string; | 1144 | _ = unused_fmt_string; |
| 1145 | const atom = ctx.atom; | 1145 | const atom = ctx.atom; |
| 1146 | const macho_file = ctx.macho_file; | 1146 | const macho_file = ctx.macho_file; |
src/link/MachO/Dylib.zig+1-1| ... | @@ -676,7 +676,7 @@ const FormatContext = struct { | ... | @@ -676,7 +676,7 @@ const FormatContext = struct { |
| 676 | macho_file: *MachO, | 676 | macho_file: *MachO, |
| 677 | }; | 677 | }; |
| 678 | 678 | ||
| 679 | fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 679 | fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 680 | _ = unused_fmt_string; | 680 | _ = unused_fmt_string; |
| 681 | const dylib = ctx.dylib; | 681 | const dylib = ctx.dylib; |
| 682 | const macho_file = ctx.macho_file; | 682 | const macho_file = ctx.macho_file; |
src/link/MachO/InternalObject.zig+2-2| ... | @@ -848,7 +848,7 @@ pub fn fmtAtoms(self: *InternalObject, macho_file: *MachO) std.fmt.Formatter(for | ... | @@ -848,7 +848,7 @@ pub fn fmtAtoms(self: *InternalObject, macho_file: *MachO) std.fmt.Formatter(for |
| 848 | } }; | 848 | } }; |
| 849 | } | 849 | } |
| 850 | 850 | ||
| 851 | fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 851 | fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 852 | _ = unused_fmt_string; | 852 | _ = unused_fmt_string; |
| 853 | try bw.writeAll(" atoms\n"); | 853 | try bw.writeAll(" atoms\n"); |
| 854 | for (ctx.self.getAtoms()) |atom_index| { | 854 | for (ctx.self.getAtoms()) |atom_index| { |
| ... | @@ -864,7 +864,7 @@ pub fn fmtSymtab(self: *InternalObject, macho_file: *MachO) std.fmt.Formatter(fo | ... | @@ -864,7 +864,7 @@ pub fn fmtSymtab(self: *InternalObject, macho_file: *MachO) std.fmt.Formatter(fo |
| 864 | } }; | 864 | } }; |
| 865 | } | 865 | } |
| 866 | 866 | ||
| 867 | fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 867 | fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 868 | _ = unused_fmt_string; | 868 | _ = unused_fmt_string; |
| 869 | const macho_file = ctx.macho_file; | 869 | const macho_file = ctx.macho_file; |
| 870 | const self = ctx.self; | 870 | const self = ctx.self; |
src/link/MachO/Object.zig+9-9| ... | @@ -2513,7 +2513,7 @@ pub fn readSectionData(self: Object, allocator: Allocator, file: File.Handle, n_ | ... | @@ -2513,7 +2513,7 @@ pub fn readSectionData(self: Object, allocator: Allocator, file: File.Handle, n_ |
| 2513 | return data; | 2513 | return data; |
| 2514 | } | 2514 | } |
| 2515 | 2515 | ||
| 2516 | pub fn format(self: *Object, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 2516 | pub fn format(self: *Object, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 2517 | _ = self; | 2517 | _ = self; |
| 2518 | _ = bw; | 2518 | _ = bw; |
| 2519 | _ = unused_fmt_string; | 2519 | _ = unused_fmt_string; |
| ... | @@ -2532,7 +2532,7 @@ pub fn fmtAtoms(self: *Object, macho_file: *MachO) std.fmt.Formatter(formatAtoms | ... | @@ -2532,7 +2532,7 @@ pub fn fmtAtoms(self: *Object, macho_file: *MachO) std.fmt.Formatter(formatAtoms |
| 2532 | } }; | 2532 | } }; |
| 2533 | } | 2533 | } |
| 2534 | 2534 | ||
| 2535 | fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 2535 | fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 2536 | _ = unused_fmt_string; | 2536 | _ = unused_fmt_string; |
| 2537 | const object = ctx.object; | 2537 | const object = ctx.object; |
| 2538 | const macho_file = ctx.macho_file; | 2538 | const macho_file = ctx.macho_file; |
| ... | @@ -2550,7 +2550,7 @@ pub fn fmtCies(self: *Object, macho_file: *MachO) std.fmt.Formatter(formatCies) | ... | @@ -2550,7 +2550,7 @@ pub fn fmtCies(self: *Object, macho_file: *MachO) std.fmt.Formatter(formatCies) |
| 2550 | } }; | 2550 | } }; |
| 2551 | } | 2551 | } |
| 2552 | 2552 | ||
| 2553 | fn formatCies(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 2553 | fn formatCies(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 2554 | _ = unused_fmt_string; | 2554 | _ = unused_fmt_string; |
| 2555 | const object = ctx.object; | 2555 | const object = ctx.object; |
| 2556 | try bw.writeAll(" cies\n"); | 2556 | try bw.writeAll(" cies\n"); |
| ... | @@ -2566,7 +2566,7 @@ pub fn fmtFdes(self: *Object, macho_file: *MachO) std.fmt.Formatter(formatFdes) | ... | @@ -2566,7 +2566,7 @@ pub fn fmtFdes(self: *Object, macho_file: *MachO) std.fmt.Formatter(formatFdes) |
| 2566 | } }; | 2566 | } }; |
| 2567 | } | 2567 | } |
| 2568 | 2568 | ||
| 2569 | fn formatFdes(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 2569 | fn formatFdes(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 2570 | _ = unused_fmt_string; | 2570 | _ = unused_fmt_string; |
| 2571 | const object = ctx.object; | 2571 | const object = ctx.object; |
| 2572 | try bw.writeAll(" fdes\n"); | 2572 | try bw.writeAll(" fdes\n"); |
| ... | @@ -2582,7 +2582,7 @@ pub fn fmtUnwindRecords(self: *Object, macho_file: *MachO) std.fmt.Formatter(for | ... | @@ -2582,7 +2582,7 @@ pub fn fmtUnwindRecords(self: *Object, macho_file: *MachO) std.fmt.Formatter(for |
| 2582 | } }; | 2582 | } }; |
| 2583 | } | 2583 | } |
| 2584 | 2584 | ||
| 2585 | fn formatUnwindRecords(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 2585 | fn formatUnwindRecords(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 2586 | _ = unused_fmt_string; | 2586 | _ = unused_fmt_string; |
| 2587 | const object = ctx.object; | 2587 | const object = ctx.object; |
| 2588 | const macho_file = ctx.macho_file; | 2588 | const macho_file = ctx.macho_file; |
| ... | @@ -2599,7 +2599,7 @@ pub fn fmtSymtab(self: *Object, macho_file: *MachO) std.fmt.Formatter(formatSymt | ... | @@ -2599,7 +2599,7 @@ pub fn fmtSymtab(self: *Object, macho_file: *MachO) std.fmt.Formatter(formatSymt |
| 2599 | } }; | 2599 | } }; |
| 2600 | } | 2600 | } |
| 2601 | 2601 | ||
| 2602 | fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 2602 | fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 2603 | _ = unused_fmt_string; | 2603 | _ = unused_fmt_string; |
| 2604 | const object = ctx.object; | 2604 | const object = ctx.object; |
| 2605 | const macho_file = ctx.macho_file; | 2605 | const macho_file = ctx.macho_file; |
| ... | @@ -2629,7 +2629,7 @@ pub fn fmtPath(self: Object) std.fmt.Formatter(formatPath) { | ... | @@ -2629,7 +2629,7 @@ pub fn fmtPath(self: Object) std.fmt.Formatter(formatPath) { |
| 2629 | return .{ .data = self }; | 2629 | return .{ .data = self }; |
| 2630 | } | 2630 | } |
| 2631 | 2631 | ||
| 2632 | fn formatPath(object: Object, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 2632 | fn formatPath(object: Object, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 2633 | _ = unused_fmt_string; | 2633 | _ = unused_fmt_string; |
| 2634 | if (object.in_archive) |ar| { | 2634 | if (object.in_archive) |ar| { |
| 2635 | try bw.print("{f}({s})", .{ | 2635 | try bw.print("{f}({s})", .{ |
| ... | @@ -2690,7 +2690,7 @@ const StabFile = struct { | ... | @@ -2690,7 +2690,7 @@ const StabFile = struct { |
| 2690 | return object.symbols.items[index]; | 2690 | return object.symbols.items[index]; |
| 2691 | } | 2691 | } |
| 2692 | 2692 | ||
| 2693 | pub fn format(stab: Stab, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 2693 | pub fn format(stab: Stab, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 2694 | _ = stab; | 2694 | _ = stab; |
| 2695 | _ = bw; | 2695 | _ = bw; |
| 2696 | _ = unused_fmt_string; | 2696 | _ = unused_fmt_string; |
| ... | @@ -2703,7 +2703,7 @@ const StabFile = struct { | ... | @@ -2703,7 +2703,7 @@ const StabFile = struct { |
| 2703 | return .{ .data = .{ stab, object } }; | 2703 | return .{ .data = .{ stab, object } }; |
| 2704 | } | 2704 | } |
| 2705 | 2705 | ||
| 2706 | fn format2(ctx: StabFormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 2706 | fn format2(ctx: StabFormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 2707 | _ = unused_fmt_string; | 2707 | _ = unused_fmt_string; |
| 2708 | const stab, const object = ctx; | 2708 | const stab, const object = ctx; |
| 2709 | const sym = stab.getSymbol(object).?; | 2709 | const sym = stab.getSymbol(object).?; |
src/link/MachO/Relocation.zig+1-1| ... | @@ -76,7 +76,7 @@ pub fn fmtPretty(rel: Relocation, cpu_arch: std.Target.Cpu.Arch) std.fmt.Formatt | ... | @@ -76,7 +76,7 @@ pub fn fmtPretty(rel: Relocation, cpu_arch: std.Target.Cpu.Arch) std.fmt.Formatt |
| 76 | return .{ .data = .{ rel, cpu_arch } }; | 76 | return .{ .data = .{ rel, cpu_arch } }; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | fn formatPretty(ctx: FormatCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 79 | fn formatPretty(ctx: FormatCtx, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 80 | _ = unused_fmt_string; | 80 | _ = unused_fmt_string; |
| 81 | const rel, const cpu_arch = ctx; | 81 | const rel, const cpu_arch = ctx; |
| 82 | try bw.writeAll(switch (rel.type) { | 82 | try bw.writeAll(switch (rel.type) { |
src/link/MachO/Symbol.zig+2-2| ... | @@ -286,7 +286,7 @@ pub fn setOutputSym(symbol: Symbol, macho_file: *MachO, out: *macho.nlist_64) vo | ... | @@ -286,7 +286,7 @@ pub fn setOutputSym(symbol: Symbol, macho_file: *MachO, out: *macho.nlist_64) vo |
| 286 | } | 286 | } |
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | pub fn format(symbol: Symbol, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 289 | pub fn format(symbol: Symbol, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 290 | _ = symbol; | 290 | _ = symbol; |
| 291 | _ = bw; | 291 | _ = bw; |
| 292 | _ = unused_fmt_string; | 292 | _ = unused_fmt_string; |
| ... | @@ -305,7 +305,7 @@ pub fn fmt(symbol: Symbol, macho_file: *MachO) std.fmt.Formatter(format2) { | ... | @@ -305,7 +305,7 @@ pub fn fmt(symbol: Symbol, macho_file: *MachO) std.fmt.Formatter(format2) { |
| 305 | } }; | 305 | } }; |
| 306 | } | 306 | } |
| 307 | 307 | ||
| 308 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 308 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 309 | _ = unused_fmt_string; | 309 | _ = unused_fmt_string; |
| 310 | const symbol = ctx.symbol; | 310 | const symbol = ctx.symbol; |
| 311 | try bw.print("%{d} : {s} : @{x}", .{ | 311 | try bw.print("%{d} : {s} : @{x}", .{ |
src/link/MachO/Thunk.zig+2-2| ... | @@ -61,7 +61,7 @@ pub fn writeSymtab(thunk: Thunk, macho_file: *MachO, ctx: anytype) void { | ... | @@ -61,7 +61,7 @@ pub fn writeSymtab(thunk: Thunk, macho_file: *MachO, ctx: anytype) void { |
| 61 | } | 61 | } |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | pub fn format(thunk: Thunk, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 64 | pub fn format(thunk: Thunk, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 65 | _ = thunk; | 65 | _ = thunk; |
| 66 | _ = bw; | 66 | _ = bw; |
| 67 | _ = unused_fmt_string; | 67 | _ = unused_fmt_string; |
| ... | @@ -80,7 +80,7 @@ const FormatContext = struct { | ... | @@ -80,7 +80,7 @@ const FormatContext = struct { |
| 80 | macho_file: *MachO, | 80 | macho_file: *MachO, |
| 81 | }; | 81 | }; |
| 82 | 82 | ||
| 83 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 83 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 84 | _ = unused_fmt_string; | 84 | _ = unused_fmt_string; |
| 85 | const thunk = ctx.thunk; | 85 | const thunk = ctx.thunk; |
| 86 | const macho_file = ctx.macho_file; | 86 | const macho_file = ctx.macho_file; |
src/link/MachO/UnwindInfo.zig+6-6| ... | @@ -289,7 +289,7 @@ pub fn calcSize(info: UnwindInfo) usize { | ... | @@ -289,7 +289,7 @@ pub fn calcSize(info: UnwindInfo) usize { |
| 289 | return total_size; | 289 | return total_size; |
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | pub fn write(info: UnwindInfo, macho_file: *MachO, bw: *std.io.BufferedWriter) anyerror!void { | 292 | pub fn write(info: UnwindInfo, macho_file: *MachO, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 293 | const seg = macho_file.getTextSegment(); | 293 | const seg = macho_file.getTextSegment(); |
| 294 | const header = macho_file.sections.items(.header)[macho_file.unwind_info_sect_index.?]; | 294 | const header = macho_file.sections.items(.header)[macho_file.unwind_info_sect_index.?]; |
| 295 | 295 | ||
| ... | @@ -449,7 +449,7 @@ pub const Encoding = extern struct { | ... | @@ -449,7 +449,7 @@ pub const Encoding = extern struct { |
| 449 | return enc.enc == other.enc; | 449 | return enc.enc == other.enc; |
| 450 | } | 450 | } |
| 451 | 451 | ||
| 452 | pub fn format(enc: Encoding, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 452 | pub fn format(enc: Encoding, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 453 | _ = unused_fmt_string; | 453 | _ = unused_fmt_string; |
| 454 | try bw.print("0x{x:0>8}", .{enc.enc}); | 454 | try bw.print("0x{x:0>8}", .{enc.enc}); |
| 455 | } | 455 | } |
| ... | @@ -505,7 +505,7 @@ pub const Record = struct { | ... | @@ -505,7 +505,7 @@ pub const Record = struct { |
| 505 | return lsda.getAddress(macho_file) + rec.lsda_offset; | 505 | return lsda.getAddress(macho_file) + rec.lsda_offset; |
| 506 | } | 506 | } |
| 507 | 507 | ||
| 508 | pub fn format(rec: Record, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 508 | pub fn format(rec: Record, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 509 | _ = rec; | 509 | _ = rec; |
| 510 | _ = bw; | 510 | _ = bw; |
| 511 | _ = unused_fmt_string; | 511 | _ = unused_fmt_string; |
| ... | @@ -524,7 +524,7 @@ pub const Record = struct { | ... | @@ -524,7 +524,7 @@ pub const Record = struct { |
| 524 | macho_file: *MachO, | 524 | macho_file: *MachO, |
| 525 | }; | 525 | }; |
| 526 | 526 | ||
| 527 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 527 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 528 | _ = unused_fmt_string; | 528 | _ = unused_fmt_string; |
| 529 | const rec = ctx.rec; | 529 | const rec = ctx.rec; |
| 530 | const macho_file = ctx.macho_file; | 530 | const macho_file = ctx.macho_file; |
| ... | @@ -589,7 +589,7 @@ const Page = struct { | ... | @@ -589,7 +589,7 @@ const Page = struct { |
| 589 | return null; | 589 | return null; |
| 590 | } | 590 | } |
| 591 | 591 | ||
| 592 | fn format(page: *const Page, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void { | 592 | fn format(page: *const Page, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) std.io.Writer.Error!void { |
| 593 | _ = page; | 593 | _ = page; |
| 594 | _ = bw; | 594 | _ = bw; |
| 595 | _ = unused_format_string; | 595 | _ = unused_format_string; |
| ... | @@ -601,7 +601,7 @@ const Page = struct { | ... | @@ -601,7 +601,7 @@ const Page = struct { |
| 601 | info: UnwindInfo, | 601 | info: UnwindInfo, |
| 602 | }; | 602 | }; |
| 603 | 603 | ||
| 604 | fn format2(ctx: FormatPageContext, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void { | 604 | fn format2(ctx: FormatPageContext, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) std.io.Writer.Error!void { |
| 605 | _ = unused_format_string; | 605 | _ = unused_format_string; |
| 606 | try bw.writeAll("Page:\n"); | 606 | try bw.writeAll("Page:\n"); |
| 607 | try bw.print(" kind: {s}\n", .{@tagName(ctx.page.kind)}); | 607 | try bw.print(" kind: {s}\n", .{@tagName(ctx.page.kind)}); |
src/link/MachO/ZigObject.zig+3-3| ... | @@ -317,7 +317,7 @@ pub fn updateArSize(self: *ZigObject) void { | ... | @@ -317,7 +317,7 @@ pub fn updateArSize(self: *ZigObject) void { |
| 317 | self.output_ar_state.size = self.data.items.len; | 317 | self.output_ar_state.size = self.data.items.len; |
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | pub fn writeAr(self: ZigObject, bw: *std.io.BufferedWriter, ar_format: Archive.Format) anyerror!void { | 320 | pub fn writeAr(self: ZigObject, bw: *std.io.BufferedWriter, ar_format: Archive.Format) std.io.Writer.Error!void { |
| 321 | // Header | 321 | // Header |
| 322 | const size = std.math.cast(usize, self.output_ar_state.size) orelse return error.Overflow; | 322 | const size = std.math.cast(usize, self.output_ar_state.size) orelse return error.Overflow; |
| 323 | try Archive.writeHeader(bw, self.basename, size, ar_format); | 323 | try Archive.writeHeader(bw, self.basename, size, ar_format); |
| ... | @@ -1688,7 +1688,7 @@ const FormatContext = struct { | ... | @@ -1688,7 +1688,7 @@ const FormatContext = struct { |
| 1688 | macho_file: *MachO, | 1688 | macho_file: *MachO, |
| 1689 | }; | 1689 | }; |
| 1690 | 1690 | ||
| 1691 | fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 1691 | fn formatSymtab(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 1692 | _ = unused_fmt_string; | 1692 | _ = unused_fmt_string; |
| 1693 | try bw.writeAll(" symbols\n"); | 1693 | try bw.writeAll(" symbols\n"); |
| 1694 | const self = ctx.self; | 1694 | const self = ctx.self; |
| ... | @@ -1711,7 +1711,7 @@ pub fn fmtAtoms(self: *ZigObject, macho_file: *MachO) std.fmt.Formatter(formatAt | ... | @@ -1711,7 +1711,7 @@ pub fn fmtAtoms(self: *ZigObject, macho_file: *MachO) std.fmt.Formatter(formatAt |
| 1711 | } }; | 1711 | } }; |
| 1712 | } | 1712 | } |
| 1713 | 1713 | ||
| 1714 | fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 1714 | fn formatAtoms(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 1715 | _ = unused_fmt_string; | 1715 | _ = unused_fmt_string; |
| 1716 | const self = ctx.self; | 1716 | const self = ctx.self; |
| 1717 | const macho_file = ctx.macho_file; | 1717 | const macho_file = ctx.macho_file; |
src/link/MachO/dead_strip.zig+1-1| ... | @@ -196,7 +196,7 @@ const Level = struct { | ... | @@ -196,7 +196,7 @@ const Level = struct { |
| 196 | self.value += 1; | 196 | self.value += 1; |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | pub fn format(self: *const @This(), bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 199 | pub fn format(self: *const @This(), bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 200 | _ = unused_fmt_string; | 200 | _ = unused_fmt_string; |
| 201 | try bw.splatByteAll(' ', self.value); | 201 | try bw.splatByteAll(' ', self.value); |
| 202 | } | 202 | } |
src/link/MachO/dyld_info/Rebase.zig+9-9| ... | @@ -133,7 +133,7 @@ fn finalize(rebase: *Rebase, gpa: Allocator) !void { | ... | @@ -133,7 +133,7 @@ fn finalize(rebase: *Rebase, gpa: Allocator) !void { |
| 133 | try done(bw); | 133 | try done(bw); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | fn finalizeSegment(entries: []const Entry, bw: *std.io.BufferedWriter) anyerror!void { | 136 | fn finalizeSegment(entries: []const Entry, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 137 | if (entries.len == 0) return; | 137 | if (entries.len == 0) return; |
| 138 | 138 | ||
| 139 | const segment_id = entries[0].segment_id; | 139 | const segment_id = entries[0].segment_id; |
| ... | @@ -220,24 +220,24 @@ fn finalizeSegment(entries: []const Entry, bw: *std.io.BufferedWriter) anyerror! | ... | @@ -220,24 +220,24 @@ fn finalizeSegment(entries: []const Entry, bw: *std.io.BufferedWriter) anyerror! |
| 220 | } | 220 | } |
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | fn setTypePointer(bw: *std.io.BufferedWriter) anyerror!void { | 223 | fn setTypePointer(bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 224 | log.debug(">>> set type: {d}", .{macho.REBASE_TYPE_POINTER}); | 224 | log.debug(">>> set type: {d}", .{macho.REBASE_TYPE_POINTER}); |
| 225 | try bw.writeByte(macho.REBASE_OPCODE_SET_TYPE_IMM | @as(u4, @intCast(macho.REBASE_TYPE_POINTER))); | 225 | try bw.writeByte(macho.REBASE_OPCODE_SET_TYPE_IMM | @as(u4, @intCast(macho.REBASE_TYPE_POINTER))); |
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | fn setSegmentOffset(segment_id: u4, offset: u64, bw: *std.io.BufferedWriter) anyerror!void { | 228 | fn setSegmentOffset(segment_id: u4, offset: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 229 | log.debug(">>> set segment: {d} and offset: {x}", .{ segment_id, offset }); | 229 | log.debug(">>> set segment: {d} and offset: {x}", .{ segment_id, offset }); |
| 230 | try bw.writeByte(macho.REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | @as(u4, @truncate(segment_id))); | 230 | try bw.writeByte(macho.REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | @as(u4, @truncate(segment_id))); |
| 231 | try bw.writeLeb128(offset); | 231 | try bw.writeLeb128(offset); |
| 232 | } | 232 | } |
| 233 | 233 | ||
| 234 | fn rebaseAddAddr(addr: u64, bw: *std.io.BufferedWriter) anyerror!void { | 234 | fn rebaseAddAddr(addr: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 235 | log.debug(">>> rebase with add: {x}", .{addr}); | 235 | log.debug(">>> rebase with add: {x}", .{addr}); |
| 236 | try bw.writeByte(macho.REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB); | 236 | try bw.writeByte(macho.REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB); |
| 237 | try bw.writeLeb128(addr); | 237 | try bw.writeLeb128(addr); |
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | fn rebaseTimes(count: usize, bw: *std.io.BufferedWriter) anyerror!void { | 240 | fn rebaseTimes(count: usize, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 241 | log.debug(">>> rebase with count: {d}", .{count}); | 241 | log.debug(">>> rebase with count: {d}", .{count}); |
| 242 | if (count <= 0xf) { | 242 | if (count <= 0xf) { |
| 243 | try bw.writeByte(macho.REBASE_OPCODE_DO_REBASE_IMM_TIMES | @as(u4, @truncate(count))); | 243 | try bw.writeByte(macho.REBASE_OPCODE_DO_REBASE_IMM_TIMES | @as(u4, @truncate(count))); |
| ... | @@ -247,14 +247,14 @@ fn rebaseTimes(count: usize, bw: *std.io.BufferedWriter) anyerror!void { | ... | @@ -247,14 +247,14 @@ fn rebaseTimes(count: usize, bw: *std.io.BufferedWriter) anyerror!void { |
| 247 | } | 247 | } |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | fn rebaseTimesSkip(count: usize, skip: u64, bw: *std.io.BufferedWriter) anyerror!void { | 250 | fn rebaseTimesSkip(count: usize, skip: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 251 | log.debug(">>> rebase with count: {d} and skip: {x}", .{ count, skip }); | 251 | log.debug(">>> rebase with count: {d} and skip: {x}", .{ count, skip }); |
| 252 | try bw.writeByte(macho.REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB); | 252 | try bw.writeByte(macho.REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB); |
| 253 | try bw.writeLeb128(count); | 253 | try bw.writeLeb128(count); |
| 254 | try bw.writeLeb128(skip); | 254 | try bw.writeLeb128(skip); |
| 255 | } | 255 | } |
| 256 | 256 | ||
| 257 | fn addAddr(addr: u64, bw: *std.io.BufferedWriter) anyerror!void { | 257 | fn addAddr(addr: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 258 | log.debug(">>> add: {x}", .{addr}); | 258 | log.debug(">>> add: {x}", .{addr}); |
| 259 | if (std.math.divExact(u64, addr, @sizeOf(u64))) |scaled| { | 259 | if (std.math.divExact(u64, addr, @sizeOf(u64))) |scaled| { |
| 260 | if (std.math.cast(u4, scaled)) |imm_scaled| return bw.writeByte( | 260 | if (std.math.cast(u4, scaled)) |imm_scaled| return bw.writeByte( |
| ... | @@ -265,12 +265,12 @@ fn addAddr(addr: u64, bw: *std.io.BufferedWriter) anyerror!void { | ... | @@ -265,12 +265,12 @@ fn addAddr(addr: u64, bw: *std.io.BufferedWriter) anyerror!void { |
| 265 | try bw.writeLeb128(addr); | 265 | try bw.writeLeb128(addr); |
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | fn done(bw: *std.io.BufferedWriter) anyerror!void { | 268 | fn done(bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 269 | log.debug(">>> done", .{}); | 269 | log.debug(">>> done", .{}); |
| 270 | try bw.writeByte(macho.REBASE_OPCODE_DONE); | 270 | try bw.writeByte(macho.REBASE_OPCODE_DONE); |
| 271 | } | 271 | } |
| 272 | 272 | ||
| 273 | pub fn write(rebase: Rebase, bw: *std.io.BufferedWriter) anyerror!void { | 273 | pub fn write(rebase: Rebase, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 274 | try bw.writeAll(rebase.buffer.items); | 274 | try bw.writeAll(rebase.buffer.items); |
| 275 | } | 275 | } |
| 276 | 276 |
src/link/MachO/dyld_info/Trie.zig+1-1| ... | @@ -232,7 +232,7 @@ pub fn deinit(self: *Trie, allocator: Allocator) void { | ... | @@ -232,7 +232,7 @@ pub fn deinit(self: *Trie, allocator: Allocator) void { |
| 232 | allocator.free(self.buffer); | 232 | allocator.free(self.buffer); |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | pub fn write(self: Trie, bw: *std.io.BufferedWriter) anyerror!void { | 235 | pub fn write(self: Trie, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 236 | try bw.writeAll(self.buffer); | 236 | try bw.writeAll(self.buffer); |
| 237 | } | 237 | } |
| 238 | 238 |
src/link/MachO/dyld_info/bind.zig+15-15| ... | @@ -139,7 +139,7 @@ pub const Bind = struct { | ... | @@ -139,7 +139,7 @@ pub const Bind = struct { |
| 139 | try done(bw); | 139 | try done(bw); |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | fn finalizeSegment(entries: []const Entry, ctx: *MachO, bw: *std.io.BufferedWriter) anyerror!void { | 142 | fn finalizeSegment(entries: []const Entry, ctx: *MachO, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 143 | if (entries.len == 0) return; | 143 | if (entries.len == 0) return; |
| 144 | 144 | ||
| 145 | const seg_id = entries[0].segment_id; | 145 | const seg_id = entries[0].segment_id; |
| ... | @@ -251,7 +251,7 @@ pub const Bind = struct { | ... | @@ -251,7 +251,7 @@ pub const Bind = struct { |
| 251 | } | 251 | } |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | pub fn write(bind: Bind, bw: *std.io.BufferedWriter) anyerror!void { | 254 | pub fn write(bind: Bind, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 255 | try bw.writeAll(bind.buffer.items); | 255 | try bw.writeAll(bind.buffer.items); |
| 256 | } | 256 | } |
| 257 | }; | 257 | }; |
| ... | @@ -380,7 +380,7 @@ pub const WeakBind = struct { | ... | @@ -380,7 +380,7 @@ pub const WeakBind = struct { |
| 380 | try done(bw); | 380 | try done(bw); |
| 381 | } | 381 | } |
| 382 | 382 | ||
| 383 | fn finalizeSegment(entries: []const Entry, ctx: *MachO, bw: *std.io.BufferedWriter) anyerror!void { | 383 | fn finalizeSegment(entries: []const Entry, ctx: *MachO, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 384 | if (entries.len == 0) return; | 384 | if (entries.len == 0) return; |
| 385 | 385 | ||
| 386 | const seg_id = entries[0].segment_id; | 386 | const seg_id = entries[0].segment_id; |
| ... | @@ -481,7 +481,7 @@ pub const WeakBind = struct { | ... | @@ -481,7 +481,7 @@ pub const WeakBind = struct { |
| 481 | } | 481 | } |
| 482 | } | 482 | } |
| 483 | 483 | ||
| 484 | pub fn write(bind: WeakBind, bw: *std.io.BufferedWriter) anyerror!void { | 484 | pub fn write(bind: WeakBind, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 485 | try bw.writeAll(bind.buffer.items); | 485 | try bw.writeAll(bind.buffer.items); |
| 486 | } | 486 | } |
| 487 | }; | 487 | }; |
| ... | @@ -565,30 +565,30 @@ pub const LazyBind = struct { | ... | @@ -565,30 +565,30 @@ pub const LazyBind = struct { |
| 565 | } | 565 | } |
| 566 | } | 566 | } |
| 567 | 567 | ||
| 568 | pub fn write(bind: LazyBind, bw: *std.io.BufferedWriter) anyerror!void { | 568 | pub fn write(bind: LazyBind, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 569 | try bw.writeAll(bind.buffer.items); | 569 | try bw.writeAll(bind.buffer.items); |
| 570 | } | 570 | } |
| 571 | }; | 571 | }; |
| 572 | 572 | ||
| 573 | fn setSegmentOffset(segment_id: u4, offset: u64, bw: *std.io.BufferedWriter) anyerror!void { | 573 | fn setSegmentOffset(segment_id: u4, offset: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 574 | log.debug(">>> set segment: {d} and offset: {x}", .{ segment_id, offset }); | 574 | log.debug(">>> set segment: {d} and offset: {x}", .{ segment_id, offset }); |
| 575 | try bw.writeByte(macho.BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | segment_id); | 575 | try bw.writeByte(macho.BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | segment_id); |
| 576 | try bw.writeLeb128(offset); | 576 | try bw.writeLeb128(offset); |
| 577 | } | 577 | } |
| 578 | 578 | ||
| 579 | fn setSymbol(name: []const u8, flags: u4, bw: *std.io.BufferedWriter) anyerror!void { | 579 | fn setSymbol(name: []const u8, flags: u4, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 580 | log.debug(">>> set symbol: {s} with flags: {x}", .{ name, flags }); | 580 | log.debug(">>> set symbol: {s} with flags: {x}", .{ name, flags }); |
| 581 | try bw.writeByte(macho.BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM | flags); | 581 | try bw.writeByte(macho.BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM | flags); |
| 582 | try bw.writeAll(name); | 582 | try bw.writeAll(name); |
| 583 | try bw.writeByte(0); | 583 | try bw.writeByte(0); |
| 584 | } | 584 | } |
| 585 | 585 | ||
| 586 | fn setTypePointer(bw: *std.io.BufferedWriter) anyerror!void { | 586 | fn setTypePointer(bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 587 | log.debug(">>> set type: {d}", .{macho.BIND_TYPE_POINTER}); | 587 | log.debug(">>> set type: {d}", .{macho.BIND_TYPE_POINTER}); |
| 588 | try bw.writeByte(macho.BIND_OPCODE_SET_TYPE_IMM | @as(u4, @intCast(macho.BIND_TYPE_POINTER))); | 588 | try bw.writeByte(macho.BIND_OPCODE_SET_TYPE_IMM | @as(u4, @intCast(macho.BIND_TYPE_POINTER))); |
| 589 | } | 589 | } |
| 590 | 590 | ||
| 591 | fn setDylibOrdinal(ordinal: i16, bw: *std.io.BufferedWriter) anyerror!void { | 591 | fn setDylibOrdinal(ordinal: i16, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 592 | switch (ordinal) { | 592 | switch (ordinal) { |
| 593 | else => unreachable, // Invalid dylib special binding | 593 | else => unreachable, // Invalid dylib special binding |
| 594 | macho.BIND_SPECIAL_DYLIB_SELF, | 594 | macho.BIND_SPECIAL_DYLIB_SELF, |
| ... | @@ -610,18 +610,18 @@ fn setDylibOrdinal(ordinal: i16, bw: *std.io.BufferedWriter) anyerror!void { | ... | @@ -610,18 +610,18 @@ fn setDylibOrdinal(ordinal: i16, bw: *std.io.BufferedWriter) anyerror!void { |
| 610 | } | 610 | } |
| 611 | } | 611 | } |
| 612 | 612 | ||
| 613 | fn setAddend(addend: i64, bw: *std.io.BufferedWriter) anyerror!void { | 613 | fn setAddend(addend: i64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 614 | log.debug(">>> set addend: {x}", .{addend}); | 614 | log.debug(">>> set addend: {x}", .{addend}); |
| 615 | try bw.writeByte(macho.BIND_OPCODE_SET_ADDEND_SLEB); | 615 | try bw.writeByte(macho.BIND_OPCODE_SET_ADDEND_SLEB); |
| 616 | try bw.writeLeb128(addend); | 616 | try bw.writeLeb128(addend); |
| 617 | } | 617 | } |
| 618 | 618 | ||
| 619 | fn doBind(bw: *std.io.BufferedWriter) anyerror!void { | 619 | fn doBind(bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 620 | log.debug(">>> bind", .{}); | 620 | log.debug(">>> bind", .{}); |
| 621 | try bw.writeByte(macho.BIND_OPCODE_DO_BIND); | 621 | try bw.writeByte(macho.BIND_OPCODE_DO_BIND); |
| 622 | } | 622 | } |
| 623 | 623 | ||
| 624 | fn doBindAddAddr(addr: u64, bw: *std.io.BufferedWriter) anyerror!void { | 624 | fn doBindAddAddr(addr: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 625 | log.debug(">>> bind with add: {x}", .{addr}); | 625 | log.debug(">>> bind with add: {x}", .{addr}); |
| 626 | if (std.math.divExact(u64, addr, @sizeOf(u64))) |scaled| { | 626 | if (std.math.divExact(u64, addr, @sizeOf(u64))) |scaled| { |
| 627 | if (std.math.cast(u4, scaled)) |imm_scaled| return bw.writeByte( | 627 | if (std.math.cast(u4, scaled)) |imm_scaled| return bw.writeByte( |
| ... | @@ -632,20 +632,20 @@ fn doBindAddAddr(addr: u64, bw: *std.io.BufferedWriter) anyerror!void { | ... | @@ -632,20 +632,20 @@ fn doBindAddAddr(addr: u64, bw: *std.io.BufferedWriter) anyerror!void { |
| 632 | try bw.writeLeb128(addr); | 632 | try bw.writeLeb128(addr); |
| 633 | } | 633 | } |
| 634 | 634 | ||
| 635 | fn doBindTimesSkip(count: usize, skip: u64, bw: *std.io.BufferedWriter) anyerror!void { | 635 | fn doBindTimesSkip(count: usize, skip: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 636 | log.debug(">>> bind with count: {d} and skip: {x}", .{ count, skip }); | 636 | log.debug(">>> bind with count: {d} and skip: {x}", .{ count, skip }); |
| 637 | try bw.writeByte(macho.BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB); | 637 | try bw.writeByte(macho.BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB); |
| 638 | try bw.writeLeb128(count); | 638 | try bw.writeLeb128(count); |
| 639 | try bw.writeLeb128(skip); | 639 | try bw.writeLeb128(skip); |
| 640 | } | 640 | } |
| 641 | 641 | ||
| 642 | fn addAddr(addr: u64, bw: *std.io.BufferedWriter) anyerror!void { | 642 | fn addAddr(addr: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 643 | log.debug(">>> add: {x}", .{addr}); | 643 | log.debug(">>> add: {x}", .{addr}); |
| 644 | try bw.writeByte(macho.BIND_OPCODE_ADD_ADDR_ULEB); | 644 | try bw.writeByte(macho.BIND_OPCODE_ADD_ADDR_ULEB); |
| 645 | try bw.writeLeb128(addr); | 645 | try bw.writeLeb128(addr); |
| 646 | } | 646 | } |
| 647 | 647 | ||
| 648 | fn done(bw: *std.io.BufferedWriter) anyerror!void { | 648 | fn done(bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 649 | log.debug(">>> done", .{}); | 649 | log.debug(">>> done", .{}); |
| 650 | try bw.writeByte(macho.BIND_OPCODE_DONE); | 650 | try bw.writeByte(macho.BIND_OPCODE_DONE); |
| 651 | } | 651 | } |
src/link/MachO/eh_frame.zig+2-2| ... | @@ -104,7 +104,7 @@ pub const Cie = struct { | ... | @@ -104,7 +104,7 @@ pub const Cie = struct { |
| 104 | macho_file: *MachO, | 104 | macho_file: *MachO, |
| 105 | }; | 105 | }; |
| 106 | 106 | ||
| 107 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 107 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 108 | _ = unused_fmt_string; | 108 | _ = unused_fmt_string; |
| 109 | const cie = ctx.cie; | 109 | const cie = ctx.cie; |
| 110 | try bw.print("@{x} : size({x})", .{ | 110 | try bw.print("@{x} : size({x})", .{ |
| ... | @@ -250,7 +250,7 @@ pub const Fde = struct { | ... | @@ -250,7 +250,7 @@ pub const Fde = struct { |
| 250 | macho_file: *MachO, | 250 | macho_file: *MachO, |
| 251 | }; | 251 | }; |
| 252 | 252 | ||
| 253 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 253 | fn format2(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 254 | _ = unused_fmt_string; | 254 | _ = unused_fmt_string; |
| 255 | const fde = ctx.fde; | 255 | const fde = ctx.fde; |
| 256 | const macho_file = ctx.macho_file; | 256 | const macho_file = ctx.macho_file; |
src/link/MachO/file.zig+2-2| ... | @@ -14,7 +14,7 @@ pub const File = union(enum) { | ... | @@ -14,7 +14,7 @@ pub const File = union(enum) { |
| 14 | return .{ .data = file }; | 14 | return .{ .data = file }; |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | fn formatPath(file: File, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) anyerror!void { | 17 | fn formatPath(file: File, bw: *std.io.BufferedWriter, comptime unused_fmt_string: []const u8) std.io.Writer.Error!void { |
| 18 | _ = unused_fmt_string; | 18 | _ = unused_fmt_string; |
| 19 | switch (file) { | 19 | switch (file) { |
| 20 | .zig_object => |zo| try bw.writeAll(zo.basename), | 20 | .zig_object => |zo| try bw.writeAll(zo.basename), |
| ... | @@ -322,7 +322,7 @@ pub const File = union(enum) { | ... | @@ -322,7 +322,7 @@ pub const File = union(enum) { |
| 322 | }; | 322 | }; |
| 323 | } | 323 | } |
| 324 | 324 | ||
| 325 | pub fn writeAr(file: File, bw: *std.io.BufferedWriter, ar_format: Archive.Format, macho_file: *MachO) anyerror!void { | 325 | pub fn writeAr(file: File, bw: *std.io.BufferedWriter, ar_format: Archive.Format, macho_file: *MachO) std.io.Writer.Error!void { |
| 326 | return switch (file) { | 326 | return switch (file) { |
| 327 | .dylib, .internal => unreachable, | 327 | .dylib, .internal => unreachable, |
| 328 | .zig_object => |x| x.writeAr(bw, ar_format), | 328 | .zig_object => |x| x.writeAr(bw, ar_format), |
src/link/MachO/load_commands.zig+3-3| ... | @@ -180,7 +180,7 @@ pub fn calcMinHeaderPadSize(macho_file: *MachO) !u32 { | ... | @@ -180,7 +180,7 @@ pub fn calcMinHeaderPadSize(macho_file: *MachO) !u32 { |
| 180 | return offset; | 180 | return offset; |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | pub fn writeDylinkerLC(bw: *std.io.BufferedWriter) anyerror!void { | 183 | pub fn writeDylinkerLC(bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 184 | const name_len = mem.sliceTo(default_dyld_path, 0).len; | 184 | const name_len = mem.sliceTo(default_dyld_path, 0).len; |
| 185 | const cmdsize = @as(u32, @intCast(mem.alignForward( | 185 | const cmdsize = @as(u32, @intCast(mem.alignForward( |
| 186 | u64, | 186 | u64, |
| ... | @@ -268,7 +268,7 @@ pub fn writeRpathLC(bw: *std.io.BufferedWriter, rpath: []const u8) !void { | ... | @@ -268,7 +268,7 @@ pub fn writeRpathLC(bw: *std.io.BufferedWriter, rpath: []const u8) !void { |
| 268 | try bw.splatByteAll(0, cmdsize - @sizeOf(macho.rpath_command) - rpath_len); | 268 | try bw.splatByteAll(0, cmdsize - @sizeOf(macho.rpath_command) - rpath_len); |
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | pub fn writeVersionMinLC(bw: *std.io.BufferedWriter, platform: MachO.Platform, sdk_version: ?std.SemanticVersion) anyerror!void { | 271 | pub fn writeVersionMinLC(bw: *std.io.BufferedWriter, platform: MachO.Platform, sdk_version: ?std.SemanticVersion) std.io.Writer.Error!void { |
| 272 | const cmd: macho.LC = switch (platform.os_tag) { | 272 | const cmd: macho.LC = switch (platform.os_tag) { |
| 273 | .macos => .VERSION_MIN_MACOSX, | 273 | .macos => .VERSION_MIN_MACOSX, |
| 274 | .ios => .VERSION_MIN_IPHONEOS, | 274 | .ios => .VERSION_MIN_IPHONEOS, |
| ... | @@ -286,7 +286,7 @@ pub fn writeVersionMinLC(bw: *std.io.BufferedWriter, platform: MachO.Platform, s | ... | @@ -286,7 +286,7 @@ pub fn writeVersionMinLC(bw: *std.io.BufferedWriter, platform: MachO.Platform, s |
| 286 | })); | 286 | })); |
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | pub fn writeBuildVersionLC(bw: *std.io.BufferedWriter, platform: MachO.Platform, sdk_version: ?std.SemanticVersion) anyerror!void { | 289 | pub fn writeBuildVersionLC(bw: *std.io.BufferedWriter, platform: MachO.Platform, sdk_version: ?std.SemanticVersion) std.io.Writer.Error!void { |
| 290 | const cmdsize = @sizeOf(macho.build_version_command) + @sizeOf(macho.build_tool_version); | 290 | const cmdsize = @sizeOf(macho.build_version_command) + @sizeOf(macho.build_tool_version); |
| 291 | try bw.writeStruct(macho.build_version_command{ | 291 | try bw.writeStruct(macho.build_version_command{ |
| 292 | .cmdsize = cmdsize, | 292 | .cmdsize = cmdsize, |
src/link/Wasm.zig+2-2| ... | @@ -2125,7 +2125,7 @@ pub const FunctionType = extern struct { | ... | @@ -2125,7 +2125,7 @@ pub const FunctionType = extern struct { |
| 2125 | wasm: *const Wasm, | 2125 | wasm: *const Wasm, |
| 2126 | ft: FunctionType, | 2126 | ft: FunctionType, |
| 2127 | 2127 | ||
| 2128 | pub fn format(self: Formatter, bw: *std.io.BufferedWriter, comptime format_string: []const u8) anyerror!void { | 2128 | pub fn format(self: Formatter, bw: *std.io.BufferedWriter, comptime format_string: []const u8) std.io.Writer.Error!void { |
| 2129 | if (format_string.len != 0) std.fmt.invalidFmtError(format_string, self); | 2129 | if (format_string.len != 0) std.fmt.invalidFmtError(format_string, self); |
| 2130 | const params = self.ft.params.slice(self.wasm); | 2130 | const params = self.ft.params.slice(self.wasm); |
| 2131 | const returns = self.ft.returns.slice(self.wasm); | 2131 | const returns = self.ft.returns.slice(self.wasm); |
| ... | @@ -2905,7 +2905,7 @@ pub const Feature = packed struct(u8) { | ... | @@ -2905,7 +2905,7 @@ pub const Feature = packed struct(u8) { |
| 2905 | @"=", | 2905 | @"=", |
| 2906 | }; | 2906 | }; |
| 2907 | 2907 | ||
| 2908 | pub fn format(feature: Feature, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void { | 2908 | pub fn format(feature: Feature, bw: *std.io.BufferedWriter, comptime fmt: []const u8) std.io.Writer.Error!void { |
| 2909 | _ = fmt; | 2909 | _ = fmt; |
| 2910 | try bw.print("{s} {s}", .{ @tagName(feature.prefix), @tagName(feature.tag) }); | 2910 | try bw.print("{s} {s}", .{ @tagName(feature.prefix), @tagName(feature.tag) }); |
| 2911 | } | 2911 | } |
src/link/Wasm/Flush.zig+15-15| ... | @@ -1065,7 +1065,7 @@ fn emitNameSection( | ... | @@ -1065,7 +1065,7 @@ fn emitNameSection( |
| 1065 | wasm: *Wasm, | 1065 | wasm: *Wasm, |
| 1066 | aw: *std.io.AllocatingWriter, | 1066 | aw: *std.io.AllocatingWriter, |
| 1067 | data_segment_groups: []const DataSegmentGroup, | 1067 | data_segment_groups: []const DataSegmentGroup, |
| 1068 | ) anyerror!void { | 1068 | ) !void { |
| 1069 | const f = &wasm.flush_buffer; | 1069 | const f = &wasm.flush_buffer; |
| 1070 | const bw = &aw.buffered_writer; | 1070 | const bw = &aw.buffered_writer; |
| 1071 | const header_offset = try reserveSectionHeader(bw); | 1071 | const header_offset = try reserveSectionHeader(bw); |
| ... | @@ -1127,7 +1127,7 @@ fn emitNameSection( | ... | @@ -1127,7 +1127,7 @@ fn emitNameSection( |
| 1127 | } | 1127 | } |
| 1128 | } | 1128 | } |
| 1129 | 1129 | ||
| 1130 | fn emitFeaturesSection(aw: *std.io.AllocatingWriter, target: *const std.Target) anyerror!void { | 1130 | fn emitFeaturesSection(aw: *std.io.AllocatingWriter, target: *const std.Target) Allocator.Error!void { |
| 1131 | const feature_count = target.cpu.features.count(); | 1131 | const feature_count = target.cpu.features.count(); |
| 1132 | if (feature_count == 0) return; | 1132 | if (feature_count == 0) return; |
| 1133 | 1133 | ||
| ... | @@ -1251,7 +1251,7 @@ fn wantSegmentMerge( | ... | @@ -1251,7 +1251,7 @@ fn wantSegmentMerge( |
| 1251 | /// section id + fixed leb contents size + fixed leb vector length | 1251 | /// section id + fixed leb contents size + fixed leb vector length |
| 1252 | const vec_section_header_size = section_header_size + size_header_size; | 1252 | const vec_section_header_size = section_header_size + size_header_size; |
| 1253 | 1253 | ||
| 1254 | fn reserveVecSectionHeader(bw: *std.io.BufferedWriter) anyerror!u32 { | 1254 | fn reserveVecSectionHeader(bw: *std.io.BufferedWriter) std.io.Writer.Error!u32 { |
| 1255 | const offset = bw.count; | 1255 | const offset = bw.count; |
| 1256 | _ = try bw.writableSlice(vec_section_header_size); | 1256 | _ = try bw.writableSlice(vec_section_header_size); |
| 1257 | bw.advance(vec_section_header_size); | 1257 | bw.advance(vec_section_header_size); |
| ... | @@ -1272,7 +1272,7 @@ fn replaceVecSectionHeader( | ... | @@ -1272,7 +1272,7 @@ fn replaceVecSectionHeader( |
| 1272 | 1272 | ||
| 1273 | const section_header_size = 1 + size_header_size; | 1273 | const section_header_size = 1 + size_header_size; |
| 1274 | 1274 | ||
| 1275 | fn reserveSectionHeader(bw: *std.io.BufferedWriter) anyerror!u32 { | 1275 | fn reserveSectionHeader(bw: *std.io.BufferedWriter) std.io.Writer.Error!u32 { |
| 1276 | const offset = bw.count; | 1276 | const offset = bw.count; |
| 1277 | _ = try bw.writableSlice(section_header_size); | 1277 | _ = try bw.writableSlice(section_header_size); |
| 1278 | bw.advance(section_header_size); | 1278 | bw.advance(section_header_size); |
| ... | @@ -1287,7 +1287,7 @@ fn replaceSectionHeader(aw: *std.io.AllocatingWriter, offset: u32, section: u8) | ... | @@ -1287,7 +1287,7 @@ fn replaceSectionHeader(aw: *std.io.AllocatingWriter, offset: u32, section: u8) |
| 1287 | 1287 | ||
| 1288 | const size_header_size = 5; | 1288 | const size_header_size = 5; |
| 1289 | 1289 | ||
| 1290 | fn reserveSizeHeader(bw: *std.io.BufferedWriter) anyerror!u32 { | 1290 | fn reserveSizeHeader(bw: *std.io.BufferedWriter) std.io.Writer.Error!u32 { |
| 1291 | const offset = bw.count; | 1291 | const offset = bw.count; |
| 1292 | _ = try bw.writableSlice(size_header_size); | 1292 | _ = try bw.writableSlice(size_header_size); |
| 1293 | bw.advance(size_header_size); | 1293 | bw.advance(size_header_size); |
| ... | @@ -1299,7 +1299,7 @@ fn replaceSizeHeader(aw: *std.io.AllocatingWriter, offset: u32) void { | ... | @@ -1299,7 +1299,7 @@ fn replaceSizeHeader(aw: *std.io.AllocatingWriter, offset: u32) void { |
| 1299 | std.leb.writeUnsignedFixed(5, header[0..5], @intCast(aw.buffered_writer.count - offset - size_header_size)); | 1299 | std.leb.writeUnsignedFixed(5, header[0..5], @intCast(aw.buffered_writer.count - offset - size_header_size)); |
| 1300 | } | 1300 | } |
| 1301 | 1301 | ||
| 1302 | fn emitLimits(bw: *std.io.BufferedWriter, limits: std.wasm.Limits) anyerror!void { | 1302 | fn emitLimits(bw: *std.io.BufferedWriter, limits: std.wasm.Limits) std.io.Writer.Error!void { |
| 1303 | try bw.writeByte(@bitCast(limits.flags)); | 1303 | try bw.writeByte(@bitCast(limits.flags)); |
| 1304 | try bw.writeLeb128(limits.min); | 1304 | try bw.writeLeb128(limits.min); |
| 1305 | if (limits.flags.has_max) try bw.writeLeb128(limits.max); | 1305 | if (limits.flags.has_max) try bw.writeLeb128(limits.max); |
| ... | @@ -1310,7 +1310,7 @@ fn emitMemoryImport( | ... | @@ -1310,7 +1310,7 @@ fn emitMemoryImport( |
| 1310 | bw: *std.io.BufferedWriter, | 1310 | bw: *std.io.BufferedWriter, |
| 1311 | name_index: String, | 1311 | name_index: String, |
| 1312 | memory_import: *const Wasm.MemoryImport, | 1312 | memory_import: *const Wasm.MemoryImport, |
| 1313 | ) anyerror!void { | 1313 | ) std.io.Writer.Error!void { |
| 1314 | const module_name = memory_import.module_name.slice(wasm); | 1314 | const module_name = memory_import.module_name.slice(wasm); |
| 1315 | try bw.writeLeb128(module_name.len); | 1315 | try bw.writeLeb128(module_name.len); |
| 1316 | try bw.writeAll(module_name); | 1316 | try bw.writeAll(module_name); |
| ... | @@ -1323,7 +1323,7 @@ fn emitMemoryImport( | ... | @@ -1323,7 +1323,7 @@ fn emitMemoryImport( |
| 1323 | try emitLimits(bw, memory_import.limits()); | 1323 | try emitLimits(bw, memory_import.limits()); |
| 1324 | } | 1324 | } |
| 1325 | 1325 | ||
| 1326 | pub fn emitInit(bw: *std.io.BufferedWriter, init_expr: std.wasm.InitExpression) anyerror!void { | 1326 | pub fn emitInit(bw: *std.io.BufferedWriter, init_expr: std.wasm.InitExpression) std.io.Writer.Error!void { |
| 1327 | switch (init_expr) { | 1327 | switch (init_expr) { |
| 1328 | inline else => |val, tag| { | 1328 | inline else => |val, tag| { |
| 1329 | try bw.writeByte(@intFromEnum(@field(std.wasm.Opcode, @tagName(tag)))); | 1329 | try bw.writeByte(@intFromEnum(@field(std.wasm.Opcode, @tagName(tag)))); |
| ... | @@ -1341,12 +1341,12 @@ pub fn emitInit(bw: *std.io.BufferedWriter, init_expr: std.wasm.InitExpression) | ... | @@ -1341,12 +1341,12 @@ pub fn emitInit(bw: *std.io.BufferedWriter, init_expr: std.wasm.InitExpression) |
| 1341 | try bw.writeByte(@intFromEnum(std.wasm.Opcode.end)); | 1341 | try bw.writeByte(@intFromEnum(std.wasm.Opcode.end)); |
| 1342 | } | 1342 | } |
| 1343 | 1343 | ||
| 1344 | pub fn emitExpr(wasm: *const Wasm, bw: *std.io.BufferedWriter, expr: Wasm.Expr) anyerror!void { | 1344 | pub fn emitExpr(wasm: *const Wasm, bw: *std.io.BufferedWriter, expr: Wasm.Expr) std.io.Writer.Error!void { |
| 1345 | const slice = expr.slice(wasm); | 1345 | const slice = expr.slice(wasm); |
| 1346 | try bw.writeAll(slice[0 .. slice.len + 1]); // +1 to include end opcode | 1346 | try bw.writeAll(slice[0 .. slice.len + 1]); // +1 to include end opcode |
| 1347 | } | 1347 | } |
| 1348 | 1348 | ||
| 1349 | fn emitSegmentInfo(wasm: *Wasm, aw: *std.io.BufferedWriter) anyerror!void { | 1349 | fn emitSegmentInfo(wasm: *Wasm, aw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 1350 | const bw = &aw.buffered_writer; | 1350 | const bw = &aw.buffered_writer; |
| 1351 | const header_offset = try reserveSectionHeader(bw); | 1351 | const header_offset = try reserveSectionHeader(bw); |
| 1352 | defer replaceSectionHeader(aw, header_offset, @intFromEnum(Wasm.SubsectionType.segment_info)); | 1352 | defer replaceSectionHeader(aw, header_offset, @intFromEnum(Wasm.SubsectionType.segment_info)); |
| ... | @@ -1371,7 +1371,7 @@ fn emitTagNameTable( | ... | @@ -1371,7 +1371,7 @@ fn emitTagNameTable( |
| 1371 | tag_name_bytes: []const u8, | 1371 | tag_name_bytes: []const u8, |
| 1372 | base: u32, | 1372 | base: u32, |
| 1373 | comptime Int: type, | 1373 | comptime Int: type, |
| 1374 | ) anyerror!void { | 1374 | ) std.io.Writer.Error!void { |
| 1375 | for (tag_name_offs) |off| { | 1375 | for (tag_name_offs) |off| { |
| 1376 | const name_len: u32 = @intCast(mem.indexOfScalar(u8, tag_name_bytes[off..], 0).?); | 1376 | const name_len: u32 = @intCast(mem.indexOfScalar(u8, tag_name_bytes[off..], 0).?); |
| 1377 | try bw.writeInt(Int, base + off, .little); | 1377 | try bw.writeInt(Int, base + off, .little); |
| ... | @@ -1539,7 +1539,7 @@ fn reloc_leb_type(code: []u8, index: FuncTypeIndex) void { | ... | @@ -1539,7 +1539,7 @@ fn reloc_leb_type(code: []u8, index: FuncTypeIndex) void { |
| 1539 | std.leb.writeUnsignedFixed(5, code[0..5], @intFromEnum(index)); | 1539 | std.leb.writeUnsignedFixed(5, code[0..5], @intFromEnum(index)); |
| 1540 | } | 1540 | } |
| 1541 | 1541 | ||
| 1542 | fn emitCallCtorsFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter) anyerror!void { | 1542 | fn emitCallCtorsFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 1543 | try bw.writeUleb128(0); // no locals | 1543 | try bw.writeUleb128(0); // no locals |
| 1544 | for (wasm.object_init_funcs.items) |init_func| { | 1544 | for (wasm.object_init_funcs.items) |init_func| { |
| 1545 | const func = init_func.function_index.ptr(wasm); | 1545 | const func = init_func.function_index.ptr(wasm); |
| ... | @@ -1558,7 +1558,7 @@ fn emitCallCtorsFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter) anyerror | ... | @@ -1558,7 +1558,7 @@ fn emitCallCtorsFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter) anyerror |
| 1558 | try bw.writeByte(@intFromEnum(std.wasm.Opcode.end)); // end function body | 1558 | try bw.writeByte(@intFromEnum(std.wasm.Opcode.end)); // end function body |
| 1559 | } | 1559 | } |
| 1560 | 1560 | ||
| 1561 | fn emitInitMemoryFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter, virtual_addrs: *const VirtualAddrs) anyerror!void { | 1561 | fn emitInitMemoryFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter, virtual_addrs: *const VirtualAddrs) std.io.Writer.Error!void { |
| 1562 | const comp = wasm.base.comp; | 1562 | const comp = wasm.base.comp; |
| 1563 | const shared_memory = comp.config.shared_memory; | 1563 | const shared_memory = comp.config.shared_memory; |
| 1564 | 1564 | ||
| ... | @@ -1710,7 +1710,7 @@ fn emitInitMemoryFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter, virtual | ... | @@ -1710,7 +1710,7 @@ fn emitInitMemoryFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter, virtual |
| 1710 | try bw.writeByte(@intFromEnum(std.wasm.Opcode.end)); | 1710 | try bw.writeByte(@intFromEnum(std.wasm.Opcode.end)); |
| 1711 | } | 1711 | } |
| 1712 | 1712 | ||
| 1713 | fn emitInitTlsFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter) anyerror!void { | 1713 | fn emitInitTlsFunction(wasm: *const Wasm, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 1714 | const comp = wasm.base.comp; | 1714 | const comp = wasm.base.comp; |
| 1715 | assert(comp.config.shared_memory); | 1715 | assert(comp.config.shared_memory); |
| 1716 | 1716 | ||
| ... | @@ -1888,7 +1888,7 @@ fn emitTagNameFunction( | ... | @@ -1888,7 +1888,7 @@ fn emitTagNameFunction( |
| 1888 | try bw.writeByte(@intFromEnum(std.wasm.Opcode.end)); | 1888 | try bw.writeByte(@intFromEnum(std.wasm.Opcode.end)); |
| 1889 | } | 1889 | } |
| 1890 | 1890 | ||
| 1891 | fn appendGlobal(bw: *std.io.BufferedWriter, mutable: bool, val: u32) anyerror!void { | 1891 | fn appendGlobal(bw: *std.io.BufferedWriter, mutable: bool, val: u32) std.io.Writer.Error!void { |
| 1892 | try bw.writeAll(&.{ | 1892 | try bw.writeAll(&.{ |
| 1893 | @intFromEnum(std.wasm.Valtype.i32), | 1893 | @intFromEnum(std.wasm.Valtype.i32), |
| 1894 | @intFromBool(mutable), | 1894 | @intFromBool(mutable), |
src/link/Wasm/Object.zig+5-5| ... | @@ -259,7 +259,7 @@ pub fn parse( | ... | @@ -259,7 +259,7 @@ pub fn parse( |
| 259 | ss: *ScratchSpace, | 259 | ss: *ScratchSpace, |
| 260 | must_link: bool, | 260 | must_link: bool, |
| 261 | gc_sections: bool, | 261 | gc_sections: bool, |
| 262 | ) anyerror!Object { | 262 | ) !Object { |
| 263 | const comp = wasm.base.comp; | 263 | const comp = wasm.base.comp; |
| 264 | const gpa = comp.gpa; | 264 | const gpa = comp.gpa; |
| 265 | const diags = &comp.link_diags; | 265 | const diags = &comp.link_diags; |
| ... | @@ -1402,7 +1402,7 @@ pub fn parse( | ... | @@ -1402,7 +1402,7 @@ pub fn parse( |
| 1402 | /// Based on the "features" custom section, parses it into a list of | 1402 | /// Based on the "features" custom section, parses it into a list of |
| 1403 | /// features that tell the linker what features were enabled and may be mandatory | 1403 | /// features that tell the linker what features were enabled and may be mandatory |
| 1404 | /// to be able to link. | 1404 | /// to be able to link. |
| 1405 | fn parseFeatures(wasm: *Wasm, br: *std.io.BufferedReader, path: Path) anyerror!Wasm.Feature.Set { | 1405 | fn parseFeatures(wasm: *Wasm, br: *std.io.BufferedReader, path: Path) error{ OutOfMemory, LinkFailure }!Wasm.Feature.Set { |
| 1406 | const gpa = wasm.base.comp.gpa; | 1406 | const gpa = wasm.base.comp.gpa; |
| 1407 | const diags = &wasm.base.comp.link_diags; | 1407 | const diags = &wasm.base.comp.link_diags; |
| 1408 | const features_len = try br.takeLeb128(u32); | 1408 | const features_len = try br.takeLeb128(u32); |
| ... | @@ -1430,7 +1430,7 @@ fn parseFeatures(wasm: *Wasm, br: *std.io.BufferedReader, path: Path) anyerror!W | ... | @@ -1430,7 +1430,7 @@ fn parseFeatures(wasm: *Wasm, br: *std.io.BufferedReader, path: Path) anyerror!W |
| 1430 | return .fromString(try wasm.internString(@ptrCast(feature_buffer))); | 1430 | return .fromString(try wasm.internString(@ptrCast(feature_buffer))); |
| 1431 | } | 1431 | } |
| 1432 | 1432 | ||
| 1433 | fn readLimits(br: *std.io.BufferedReader) anyerror!std.wasm.Limits { | 1433 | fn readLimits(br: *std.io.BufferedReader) std.io.Reader.Error!std.wasm.Limits { |
| 1434 | const flags: std.wasm.Limits.Flags = @bitCast(try br.takeByte()); | 1434 | const flags: std.wasm.Limits.Flags = @bitCast(try br.takeByte()); |
| 1435 | const min = try br.takeLeb128(u32); | 1435 | const min = try br.takeLeb128(u32); |
| 1436 | const max = if (flags.has_max) try br.takeLeb128(u32) else 0; | 1436 | const max = if (flags.has_max) try br.takeLeb128(u32) else 0; |
| ... | @@ -1441,13 +1441,13 @@ fn readLimits(br: *std.io.BufferedReader) anyerror!std.wasm.Limits { | ... | @@ -1441,13 +1441,13 @@ fn readLimits(br: *std.io.BufferedReader) anyerror!std.wasm.Limits { |
| 1441 | }; | 1441 | }; |
| 1442 | } | 1442 | } |
| 1443 | 1443 | ||
| 1444 | fn readInit(wasm: *Wasm, br: *std.io.BufferedReader) anyerror!Wasm.Expr { | 1444 | fn readInit(wasm: *Wasm, br: *std.io.BufferedReader) std.io.Reader.Error!Wasm.Expr { |
| 1445 | const start = br.seek; | 1445 | const start = br.seek; |
| 1446 | try skipInit(br); // one after the end opcode | 1446 | try skipInit(br); // one after the end opcode |
| 1447 | return wasm.addExpr(br.storageBuffer()[start..br.seek]); | 1447 | return wasm.addExpr(br.storageBuffer()[start..br.seek]); |
| 1448 | } | 1448 | } |
| 1449 | 1449 | ||
| 1450 | pub fn skipInit(br: *std.io.BufferedReader) anyerror!void { | 1450 | pub fn skipInit(br: *std.io.BufferedReader) std.io.Reader.Error!void { |
| 1451 | switch (try br.takeEnum(std.wasm.Opcode, .little)) { | 1451 | switch (try br.takeEnum(std.wasm.Opcode, .little)) { |
| 1452 | .i32_const => _ = try br.takeLeb128(i32), | 1452 | .i32_const => _ = try br.takeLeb128(i32), |
| 1453 | .i64_const => _ = try br.takeLeb128(i64), | 1453 | .i64_const => _ = try br.takeLeb128(i64), |
src/link/riscv.zig+4-4| ... | @@ -1,4 +1,4 @@ | ... | @@ -1,4 +1,4 @@ |
| 1 | pub fn writeSetSub6(comptime op: enum { set, sub }, addend: anytype, bw: *std.io.BufferedWriter) anyerror!void { | 1 | pub fn writeSetSub6(comptime op: enum { set, sub }, addend: anytype, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 2 | const mask: u8 = 0b11_000000; | 2 | const mask: u8 = 0b11_000000; |
| 3 | const actual: i8 = @truncate(addend); | 3 | const actual: i8 = @truncate(addend); |
| 4 | const old_value = (try bw.writableSlice(1))[0]; | 4 | const old_value = (try bw.writableSlice(1))[0]; |
| ... | @@ -9,7 +9,7 @@ pub fn writeSetSub6(comptime op: enum { set, sub }, addend: anytype, bw: *std.io | ... | @@ -9,7 +9,7 @@ pub fn writeSetSub6(comptime op: enum { set, sub }, addend: anytype, bw: *std.io |
| 9 | try bw.writeByte(new_value); | 9 | try bw.writeByte(new_value); |
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | pub fn writeSetSubUleb(comptime op: enum { set, sub }, addend: i64, bw: *std.io.BufferedWriter) anyerror!void { | 12 | pub fn writeSetSubUleb(comptime op: enum { set, sub }, addend: i64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 13 | switch (op) { | 13 | switch (op) { |
| 14 | .set => try overwriteUleb(@intCast(addend), bw), | 14 | .set => try overwriteUleb(@intCast(addend), bw), |
| 15 | .sub => { | 15 | .sub => { |
| ... | @@ -21,7 +21,7 @@ pub fn writeSetSubUleb(comptime op: enum { set, sub }, addend: i64, bw: *std.io. | ... | @@ -21,7 +21,7 @@ pub fn writeSetSubUleb(comptime op: enum { set, sub }, addend: i64, bw: *std.io. |
| 21 | } | 21 | } |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | fn overwriteUleb(new_value: u64, bw: *std.io.BufferedWriter) anyerror!void { | 24 | fn overwriteUleb(new_value: u64, bw: *std.io.BufferedWriter) std.io.Writer.Error!void { |
| 25 | var value: u64 = new_value; | 25 | var value: u64 = new_value; |
| 26 | while (true) { | 26 | while (true) { |
| 27 | const byte = (try bw.writableSlice(1))[0]; | 27 | const byte = (try bw.writableSlice(1))[0]; |
| ... | @@ -36,7 +36,7 @@ pub fn writeAddend( | ... | @@ -36,7 +36,7 @@ pub fn writeAddend( |
| 36 | comptime op: enum { add, sub }, | 36 | comptime op: enum { add, sub }, |
| 37 | value: anytype, | 37 | value: anytype, |
| 38 | bw: *std.io.BufferedWriter, | 38 | bw: *std.io.BufferedWriter, |
| 39 | ) anyerror!void { | 39 | ) std.io.Writer.Error!void { |
| 40 | const n = @divExact(@bitSizeOf(Int), 8); | 40 | const n = @divExact(@bitSizeOf(Int), 8); |
| 41 | var V: Int = mem.readInt(Int, (try bw.writableSlice(n))[0..n], .little); | 41 | var V: Int = mem.readInt(Int, (try bw.writableSlice(n))[0..n], .little); |
| 42 | const addend: Int = @truncate(value); | 42 | const addend: Int = @truncate(value); |
src/link/table_section.zig+1-1| ... | @@ -39,7 +39,7 @@ pub fn TableSection(comptime Entry: type) type { | ... | @@ -39,7 +39,7 @@ pub fn TableSection(comptime Entry: type) type { |
| 39 | return self.entries.items.len; | 39 | return self.entries.items.len; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | pub fn format(self: Self, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) anyerror!void { | 42 | pub fn format(self: Self, bw: *std.io.BufferedWriter, comptime unused_format_string: []const u8) std.io.Writer.Error!void { |
| 43 | comptime assert(unused_format_string.len == 0); | 43 | comptime assert(unused_format_string.len == 0); |
| 44 | try bw.writeAll("TableSection:\n"); | 44 | try bw.writeAll("TableSection:\n"); |
| 45 | for (self.entries.items, 0..) |entry, i| { | 45 | for (self.entries.items, 0..) |entry, i| { |
src/print_targets.zig+2-2| ... | @@ -11,7 +11,7 @@ const assert = std.debug.assert; | ... | @@ -11,7 +11,7 @@ const assert = std.debug.assert; |
| 11 | const glibc = @import("libs/glibc.zig"); | 11 | const glibc = @import("libs/glibc.zig"); |
| 12 | const introspect = @import("introspect.zig"); | 12 | const introspect = @import("introspect.zig"); |
| 13 | 13 | ||
| 14 | pub fn cmdTargets(arena: Allocator, args: []const []const u8) anyerror!void { | 14 | pub fn cmdTargets(arena: Allocator, args: []const []const u8) !void { |
| 15 | _ = args; | 15 | _ = args; |
| 16 | const host = std.zig.resolveTargetQueryOrFatal(.{}); | 16 | const host = std.zig.resolveTargetQueryOrFatal(.{}); |
| 17 | var buffer: [1024]u8 = undefined; | 17 | var buffer: [1024]u8 = undefined; |
| ... | @@ -20,7 +20,7 @@ pub fn cmdTargets(arena: Allocator, args: []const []const u8) anyerror!void { | ... | @@ -20,7 +20,7 @@ pub fn cmdTargets(arena: Allocator, args: []const []const u8) anyerror!void { |
| 20 | try bw.flush(); | 20 | try bw.flush(); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | fn print(arena: Allocator, output: *std.io.BufferedWriter, host: *const Target) anyerror!void { | 23 | fn print(arena: Allocator, output: *std.io.BufferedWriter, host: *const Target) std.io.Writer.Error!void { |
| 24 | var zig_lib_directory = introspect.findZigLibDir(arena) catch |err| { | 24 | var zig_lib_directory = introspect.findZigLibDir(arena) catch |err| { |
| 25 | fatal("unable to find zig installation directory: {s}\n", .{@errorName(err)}); | 25 | fatal("unable to find zig installation directory: {s}\n", .{@errorName(err)}); |
| 26 | }; | 26 | }; |
src/print_value.zig+6-6| ... | @@ -20,7 +20,7 @@ pub const FormatContext = struct { | ... | @@ -20,7 +20,7 @@ pub const FormatContext = struct { |
| 20 | depth: u8, | 20 | depth: u8, |
| 21 | }; | 21 | }; |
| 22 | 22 | ||
| 23 | pub fn formatSema(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void { | 23 | pub fn formatSema(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime fmt: []const u8) std.io.Writer.Error!void { |
| 24 | const sema = ctx.opt_sema.?; | 24 | const sema = ctx.opt_sema.?; |
| 25 | comptime std.debug.assert(fmt.len == 0); | 25 | comptime std.debug.assert(fmt.len == 0); |
| 26 | return print(ctx.val, bw, ctx.depth, ctx.pt, sema) catch |err| switch (err) { | 26 | return print(ctx.val, bw, ctx.depth, ctx.pt, sema) catch |err| switch (err) { |
| ... | @@ -31,7 +31,7 @@ pub fn formatSema(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime fmt: | ... | @@ -31,7 +31,7 @@ pub fn formatSema(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime fmt: |
| 31 | }; | 31 | }; |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | pub fn format(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime fmt: []const u8) anyerror!void { | 34 | pub fn format(ctx: FormatContext, bw: *std.io.BufferedWriter, comptime fmt: []const u8) std.io.Writer.Error!void { |
| 35 | std.debug.assert(ctx.opt_sema == null); | 35 | std.debug.assert(ctx.opt_sema == null); |
| 36 | comptime std.debug.assert(fmt.len == 0); | 36 | comptime std.debug.assert(fmt.len == 0); |
| 37 | return print(ctx.val, bw, ctx.depth, ctx.pt, null) catch |err| switch (err) { | 37 | return print(ctx.val, bw, ctx.depth, ctx.pt, null) catch |err| switch (err) { |
| ... | @@ -47,7 +47,7 @@ pub fn print( | ... | @@ -47,7 +47,7 @@ pub fn print( |
| 47 | level: u8, | 47 | level: u8, |
| 48 | pt: Zcu.PerThread, | 48 | pt: Zcu.PerThread, |
| 49 | opt_sema: ?*Sema, | 49 | opt_sema: ?*Sema, |
| 50 | ) anyerror!void { | 50 | ) std.io.Writer.Error!void { |
| 51 | const zcu = pt.zcu; | 51 | const zcu = pt.zcu; |
| 52 | const ip = &zcu.intern_pool; | 52 | const ip = &zcu.intern_pool; |
| 53 | switch (ip.indexToKey(val.toIntern())) { | 53 | switch (ip.indexToKey(val.toIntern())) { |
| ... | @@ -190,7 +190,7 @@ fn printAggregate( | ... | @@ -190,7 +190,7 @@ fn printAggregate( |
| 190 | level: u8, | 190 | level: u8, |
| 191 | pt: Zcu.PerThread, | 191 | pt: Zcu.PerThread, |
| 192 | opt_sema: ?*Sema, | 192 | opt_sema: ?*Sema, |
| 193 | ) anyerror!void { | 193 | ) std.io.Writer.Error!void { |
| 194 | if (level == 0) { | 194 | if (level == 0) { |
| 195 | if (is_ref) try bw.writeByte('&'); | 195 | if (is_ref) try bw.writeByte('&'); |
| 196 | return bw.writeAll(".{ ... }"); | 196 | return bw.writeAll(".{ ... }"); |
| ... | @@ -276,7 +276,7 @@ fn printPtr( | ... | @@ -276,7 +276,7 @@ fn printPtr( |
| 276 | level: u8, | 276 | level: u8, |
| 277 | pt: Zcu.PerThread, | 277 | pt: Zcu.PerThread, |
| 278 | opt_sema: ?*Sema, | 278 | opt_sema: ?*Sema, |
| 279 | ) anyerror!void { | 279 | ) std.io.Writer.Error!void { |
| 280 | const ptr = switch (pt.zcu.intern_pool.indexToKey(ptr_val.toIntern())) { | 280 | const ptr = switch (pt.zcu.intern_pool.indexToKey(ptr_val.toIntern())) { |
| 281 | .undef => return bw.writeAll("undefined"), | 281 | .undef => return bw.writeAll("undefined"), |
| 282 | .ptr => |ptr| ptr, | 282 | .ptr => |ptr| ptr, |
| ... | @@ -336,7 +336,7 @@ pub fn printPtrDerivation( | ... | @@ -336,7 +336,7 @@ pub fn printPtrDerivation( |
| 336 | /// The maximum recursion depth. We can never recurse infinitely here, but the depth can be arbitrary, | 336 | /// The maximum recursion depth. We can never recurse infinitely here, but the depth can be arbitrary, |
| 337 | /// so at this depth we just write "..." to prevent stack overflow. | 337 | /// so at this depth we just write "..." to prevent stack overflow. |
| 338 | ptr_depth: u8, | 338 | ptr_depth: u8, |
| 339 | ) anyerror!Value.PointerDeriveStep { | 339 | ) std.io.Writer.Error!Value.PointerDeriveStep { |
| 340 | const zcu = pt.zcu; | 340 | const zcu = pt.zcu; |
| 341 | const ip = &zcu.intern_pool; | 341 | const ip = &zcu.intern_pool; |
| 342 | 342 |
src/print_zir.zig+14-12| ... | @@ -10,7 +10,7 @@ const Zcu = @import("Zcu.zig"); | ... | @@ -10,7 +10,7 @@ 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. | 12 | /// Write human-readable, debug formatted ZIR code. |
| 13 | pub fn renderAsText(gpa: Allocator, tree: ?Ast, zir: Zir, bw: *std.io.BufferedWriter) anyerror!void { | 13 | pub fn renderAsText(gpa: Allocator, tree: ?Ast, zir: Zir, bw: *std.io.BufferedWriter) !void { |
| 14 | var arena = std.heap.ArenaAllocator.init(gpa); | 14 | var arena = std.heap.ArenaAllocator.init(gpa); |
| 15 | defer arena.deinit(); | 15 | defer arena.deinit(); |
| 16 | 16 | ||
| ... | @@ -176,11 +176,13 @@ const Writer = struct { | ... | @@ -176,11 +176,13 @@ const Writer = struct { |
| 176 | } | 176 | } |
| 177 | } = .{}, | 177 | } = .{}, |
| 178 | 178 | ||
| 179 | const Error = std.io.Writer.Error; | ||
| 180 | |||
| 179 | fn writeInstToStream( | 181 | fn writeInstToStream( |
| 180 | self: *Writer, | 182 | self: *Writer, |
| 181 | stream: *std.io.BufferedWriter, | 183 | stream: *std.io.BufferedWriter, |
| 182 | inst: Zir.Inst.Index, | 184 | inst: Zir.Inst.Index, |
| 183 | ) anyerror!void { | 185 | ) Error!void { |
| 184 | const tags = self.code.instructions.items(.tag); | 186 | const tags = self.code.instructions.items(.tag); |
| 185 | const tag = tags[@intFromEnum(inst)]; | 187 | const tag = tags[@intFromEnum(inst)]; |
| 186 | try stream.print("= {s}(", .{@tagName(tags[@intFromEnum(inst)])}); | 188 | try stream.print("= {s}(", .{@tagName(tags[@intFromEnum(inst)])}); |
| ... | @@ -633,7 +635,7 @@ const Writer = struct { | ... | @@ -633,7 +635,7 @@ const Writer = struct { |
| 633 | self: *Writer, | 635 | self: *Writer, |
| 634 | stream: *std.io.BufferedWriter, | 636 | stream: *std.io.BufferedWriter, |
| 635 | inst: Zir.Inst.Index, | 637 | inst: Zir.Inst.Index, |
| 636 | ) anyerror!void { | 638 | ) Error!void { |
| 637 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 639 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 638 | try self.writeInstRef(stream, inst_data.operand); | 640 | try self.writeInstRef(stream, inst_data.operand); |
| 639 | try stream.writeAll(") "); | 641 | try stream.writeAll(") "); |
| ... | @@ -644,7 +646,7 @@ const Writer = struct { | ... | @@ -644,7 +646,7 @@ const Writer = struct { |
| 644 | self: *Writer, | 646 | self: *Writer, |
| 645 | stream: *std.io.BufferedWriter, | 647 | stream: *std.io.BufferedWriter, |
| 646 | inst: Zir.Inst.Index, | 648 | inst: Zir.Inst.Index, |
| 647 | ) anyerror!void { | 649 | ) Error!void { |
| 648 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].un_tok; | 650 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].un_tok; |
| 649 | try self.writeInstRef(stream, inst_data.operand); | 651 | try self.writeInstRef(stream, inst_data.operand); |
| 650 | try stream.writeAll(") "); | 652 | try stream.writeAll(") "); |
| ... | @@ -655,7 +657,7 @@ const Writer = struct { | ... | @@ -655,7 +657,7 @@ const Writer = struct { |
| 655 | self: *Writer, | 657 | self: *Writer, |
| 656 | stream: *std.io.BufferedWriter, | 658 | stream: *std.io.BufferedWriter, |
| 657 | inst: Zir.Inst.Index, | 659 | inst: Zir.Inst.Index, |
| 658 | ) anyerror!void { | 660 | ) Error!void { |
| 659 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 661 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 660 | const extra = self.code.extraData(Zir.Inst.ValidateDestructure, inst_data.payload_index).data; | 662 | const extra = self.code.extraData(Zir.Inst.ValidateDestructure, inst_data.payload_index).data; |
| 661 | try self.writeInstRef(stream, extra.operand); | 663 | try self.writeInstRef(stream, extra.operand); |
| ... | @@ -669,7 +671,7 @@ const Writer = struct { | ... | @@ -669,7 +671,7 @@ const Writer = struct { |
| 669 | self: *Writer, | 671 | self: *Writer, |
| 670 | stream: *std.io.BufferedWriter, | 672 | stream: *std.io.BufferedWriter, |
| 671 | inst: Zir.Inst.Index, | 673 | inst: Zir.Inst.Index, |
| 672 | ) anyerror!void { | 674 | ) Error!void { |
| 673 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 675 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 674 | const extra = self.code.extraData(Zir.Inst.ArrayInit, inst_data.payload_index).data; | 676 | const extra = self.code.extraData(Zir.Inst.ArrayInit, inst_data.payload_index).data; |
| 675 | try self.writeInstRef(stream, extra.ty); | 677 | try self.writeInstRef(stream, extra.ty); |
| ... | @@ -681,7 +683,7 @@ const Writer = struct { | ... | @@ -681,7 +683,7 @@ const Writer = struct { |
| 681 | self: *Writer, | 683 | self: *Writer, |
| 682 | stream: *std.io.BufferedWriter, | 684 | stream: *std.io.BufferedWriter, |
| 683 | inst: Zir.Inst.Index, | 685 | inst: Zir.Inst.Index, |
| 684 | ) anyerror!void { | 686 | ) Error!void { |
| 685 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; | 687 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].pl_node; |
| 686 | const extra = self.code.extraData(Zir.Inst.ArrayTypeSentinel, inst_data.payload_index).data; | 688 | const extra = self.code.extraData(Zir.Inst.ArrayTypeSentinel, inst_data.payload_index).data; |
| 687 | try self.writeInstRef(stream, extra.len); | 689 | try self.writeInstRef(stream, extra.len); |
| ... | @@ -697,7 +699,7 @@ const Writer = struct { | ... | @@ -697,7 +699,7 @@ const Writer = struct { |
| 697 | self: *Writer, | 699 | self: *Writer, |
| 698 | stream: *std.io.BufferedWriter, | 700 | stream: *std.io.BufferedWriter, |
| 699 | inst: Zir.Inst.Index, | 701 | inst: Zir.Inst.Index, |
| 700 | ) anyerror!void { | 702 | ) Error!void { |
| 701 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].ptr_type; | 703 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].ptr_type; |
| 702 | const str_allowzero = if (inst_data.flags.is_allowzero) "allowzero, " else ""; | 704 | const str_allowzero = if (inst_data.flags.is_allowzero) "allowzero, " else ""; |
| 703 | const str_const = if (!inst_data.flags.is_mutable) "const, " else ""; | 705 | const str_const = if (!inst_data.flags.is_mutable) "const, " else ""; |
| ... | @@ -780,7 +782,7 @@ const Writer = struct { | ... | @@ -780,7 +782,7 @@ const Writer = struct { |
| 780 | self: *Writer, | 782 | self: *Writer, |
| 781 | stream: *std.io.BufferedWriter, | 783 | stream: *std.io.BufferedWriter, |
| 782 | inst: Zir.Inst.Index, | 784 | inst: Zir.Inst.Index, |
| 783 | ) anyerror!void { | 785 | ) Error!void { |
| 784 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str; | 786 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str; |
| 785 | const str = inst_data.get(self.code); | 787 | const str = inst_data.get(self.code); |
| 786 | try stream.print("\"{f}\")", .{std.zig.fmtEscapes(str)}); | 788 | try stream.print("\"{f}\")", .{std.zig.fmtEscapes(str)}); |
| ... | @@ -1185,7 +1187,7 @@ const Writer = struct { | ... | @@ -1185,7 +1187,7 @@ const Writer = struct { |
| 1185 | self: *Writer, | 1187 | self: *Writer, |
| 1186 | stream: *std.io.BufferedWriter, | 1188 | stream: *std.io.BufferedWriter, |
| 1187 | inst: Zir.Inst.Index, | 1189 | inst: Zir.Inst.Index, |
| 1188 | ) anyerror!void { | 1190 | ) Error!void { |
| 1189 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].inst_node; | 1191 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].inst_node; |
| 1190 | try self.writeInstIndex(stream, inst_data.inst); | 1192 | try self.writeInstIndex(stream, inst_data.inst); |
| 1191 | try stream.writeAll(") "); | 1193 | try stream.writeAll(") "); |
| ... | @@ -2238,7 +2240,7 @@ const Writer = struct { | ... | @@ -2238,7 +2240,7 @@ const Writer = struct { |
| 2238 | self: *Writer, | 2240 | self: *Writer, |
| 2239 | stream: *std.io.BufferedWriter, | 2241 | stream: *std.io.BufferedWriter, |
| 2240 | inst: Zir.Inst.Index, | 2242 | inst: Zir.Inst.Index, |
| 2241 | ) anyerror!void { | 2243 | ) Error!void { |
| 2242 | const src_node = self.code.instructions.items(.data)[@intFromEnum(inst)].node; | 2244 | const src_node = self.code.instructions.items(.data)[@intFromEnum(inst)].node; |
| 2243 | try stream.writeAll(") "); | 2245 | try stream.writeAll(") "); |
| 2244 | try self.writeSrcNode(stream, src_node); | 2246 | try self.writeSrcNode(stream, src_node); |
| ... | @@ -2248,7 +2250,7 @@ const Writer = struct { | ... | @@ -2248,7 +2250,7 @@ const Writer = struct { |
| 2248 | self: *Writer, | 2250 | self: *Writer, |
| 2249 | stream: *std.io.BufferedWriter, | 2251 | stream: *std.io.BufferedWriter, |
| 2250 | inst: Zir.Inst.Index, | 2252 | inst: Zir.Inst.Index, |
| 2251 | ) anyerror!void { | 2253 | ) Error!void { |
| 2252 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str_tok; | 2254 | const inst_data = self.code.instructions.items(.data)[@intFromEnum(inst)].str_tok; |
| 2253 | const str = inst_data.get(self.code); | 2255 | const str = inst_data.get(self.code); |
| 2254 | try stream.print("\"{f}\") ", .{std.zig.fmtEscapes(str)}); | 2256 | try stream.print("\"{f}\") ", .{std.zig.fmtEscapes(str)}); |
src/print_zoir.zig+6-4| ... | @@ -1,4 +1,4 @@ | ... | @@ -1,4 +1,4 @@ |
| 1 | pub fn renderToWriter(zoir: Zoir, arena: Allocator, w: *std.io.BufferedWriter) anyerror!void { | 1 | pub fn renderToWriter(zoir: Zoir, arena: Allocator, w: *std.io.BufferedWriter) error{ WriteFailed, OutOfMemory }!void { |
| 2 | assert(!zoir.hasCompileErrors()); | 2 | assert(!zoir.hasCompileErrors()); |
| 3 | 3 | ||
| 4 | const bytes_per_node = comptime n: { | 4 | const bytes_per_node = comptime n: { |
| ... | @@ -37,7 +37,7 @@ pub fn renderToWriter(zoir: Zoir, arena: Allocator, w: *std.io.BufferedWriter) a | ... | @@ -37,7 +37,7 @@ pub fn renderToWriter(zoir: Zoir, arena: Allocator, w: *std.io.BufferedWriter) a |
| 37 | .indent = 0, | 37 | .indent = 0, |
| 38 | }; | 38 | }; |
| 39 | 39 | ||
| 40 | return @errorCast(pz.renderRoot()); | 40 | return pz.renderRoot(); |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | const PrintZon = struct { | 43 | const PrintZon = struct { |
| ... | @@ -46,12 +46,14 @@ const PrintZon = struct { | ... | @@ -46,12 +46,14 @@ const PrintZon = struct { |
| 46 | zoir: Zoir, | 46 | zoir: Zoir, |
| 47 | indent: u32, | 47 | indent: u32, |
| 48 | 48 | ||
| 49 | fn renderRoot(pz: *PrintZon) anyerror!void { | 49 | const Error = std.io.Writer.Error; |
| 50 | |||
| 51 | fn renderRoot(pz: *PrintZon) Error!void { | ||
| 50 | try pz.renderNode(.root); | 52 | try pz.renderNode(.root); |
| 51 | try pz.w.writeByte('\n'); | 53 | try pz.w.writeByte('\n'); |
| 52 | } | 54 | } |
| 53 | 55 | ||
| 54 | fn renderNode(pz: *PrintZon, node: Zoir.Node.Index) anyerror!void { | 56 | fn renderNode(pz: *PrintZon, node: Zoir.Node.Index) Error!void { |
| 55 | const zoir = pz.zoir; | 57 | const zoir = pz.zoir; |
| 56 | try pz.w.print("%{d} = ", .{@intFromEnum(node)}); | 58 | try pz.w.print("%{d} = ", .{@intFromEnum(node)}); |
| 57 | switch (node.get(zoir)) { | 59 | switch (node.get(zoir)) { |