| author | |
| committer | |
| log | a249cc1c7e5d9ac580d8f0cace9c7e3bfffffe57 |
| tree | 3e012a2f1aa6842eae671537c8644b9b7240fcc0 |
| parent | ef8d7aa25110699aa5ba9d4e0825155faa8c4319 |
44 files changed, 181 insertions(+), 237 deletions(-)
lib/docs/wasm/Walk.zig+2-2| ... | ... | @@ -444,9 +444,9 @@ fn parse(file_name: []const u8, source: []u8) Oom!Ast { |
| 444 | 444 | const err_loc = std.zig.findLineColumn(ast.source, err_offset); |
| 445 | 445 | rendered_err.clearRetainingCapacity(); |
| 446 | 446 | { |
| 447 | var aw: std.io.AllocatingWriter = undefined; | |
| 447 | var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &rendered_err); | |
| 448 | 448 | defer rendered_err = aw.toArrayList(); |
| 449 | ast.renderError(err, aw.fromArrayList(gpa, &rendered_err)) catch |e| switch (e) { | |
| 449 | ast.renderError(err, &aw.interface) catch |e| switch (e) { | |
| 450 | 450 | error.WriteFailed => return error.OutOfMemory, |
| 451 | 451 | }; |
| 452 | 452 | } |
lib/docs/wasm/main.zig+2-2| ... | ... | @@ -733,9 +733,9 @@ fn render_docs( |
| 733 | 733 | } |
| 734 | 734 | }.render, |
| 735 | 735 | }; |
| 736 | var aw: std.io.AllocatingWriter = undefined; | |
| 736 | var aw: std.io.Writer.Allocating = .fromArrayList(gpa, out); | |
| 737 | 737 | defer out.* = aw.toArrayList(); |
| 738 | render.render(parsed_doc, aw.fromArrayList(gpa, out)) catch |err| switch (err) { | |
| 738 | render.render(parsed_doc, &aw.interface) catch |err| switch (err) { | |
| 739 | 739 | error.WriteFailed => return error.OutOfMemory, |
| 740 | 740 | }; |
| 741 | 741 | } |
lib/std/Build/Step/CheckObject.zig+8-12| ... | ... | @@ -1592,10 +1592,9 @@ const MachODumper = struct { |
| 1592 | 1592 | var ctx = ObjectContext{ .gpa = gpa, .data = bytes, .header = hdr }; |
| 1593 | 1593 | try ctx.parse(); |
| 1594 | 1594 | |
| 1595 | var aw: std.io.AllocatingWriter = undefined; | |
| 1596 | aw.init(gpa); | |
| 1595 | var aw: std.io.Writer.Allocating = .init(gpa); | |
| 1597 | 1596 | defer aw.deinit(); |
| 1598 | const bw = &aw.buffered_writer; | |
| 1597 | const bw = &aw.interface; | |
| 1599 | 1598 | |
| 1600 | 1599 | switch (check.kind) { |
| 1601 | 1600 | .headers => { |
| ... | ... | @@ -1746,10 +1745,9 @@ const ElfDumper = struct { |
| 1746 | 1745 | }); |
| 1747 | 1746 | } |
| 1748 | 1747 | |
| 1749 | var aw: std.io.AllocatingWriter = undefined; | |
| 1750 | aw.init(gpa); | |
| 1748 | var aw: std.io.Writer.Allocating = .init(gpa); | |
| 1751 | 1749 | defer aw.deinit(); |
| 1752 | const bw = &aw.buffered_writer; | |
| 1750 | const bw = &aw.interface; | |
| 1753 | 1751 | |
| 1754 | 1752 | switch (check.kind) { |
| 1755 | 1753 | .archive_symtab => if (ctx.symtab.len > 0) { |
| ... | ... | @@ -1894,10 +1892,9 @@ const ElfDumper = struct { |
| 1894 | 1892 | else => {}, |
| 1895 | 1893 | }; |
| 1896 | 1894 | |
| 1897 | var aw: std.io.AllocatingWriter = undefined; | |
| 1898 | aw.init(gpa); | |
| 1895 | var aw: std.io.Writer.Allocating = .init(gpa); | |
| 1899 | 1896 | defer aw.deinit(); |
| 1900 | const bw = &aw.buffered_writer; | |
| 1897 | const bw = &aw.interface; | |
| 1901 | 1898 | |
| 1902 | 1899 | switch (check.kind) { |
| 1903 | 1900 | .headers => { |
| ... | ... | @@ -2355,10 +2352,9 @@ const WasmDumper = struct { |
| 2355 | 2352 | if (!mem.eql(u8, buf[0..4], &std.wasm.magic)) return error.InvalidMagicByte; |
| 2356 | 2353 | if (!mem.eql(u8, buf[4..8], &std.wasm.version)) return error.UnsupportedWasmVersion; |
| 2357 | 2354 | |
| 2358 | var aw: std.io.AllocatingWriter = undefined; | |
| 2359 | aw.init(gpa); | |
| 2355 | var aw: std.io.Writer.Allocating = .init(gpa); | |
| 2360 | 2356 | defer aw.deinit(); |
| 2361 | const bw = &aw.buffered_writer; | |
| 2357 | const bw = &aw.interface; | |
| 2362 | 2358 | |
| 2363 | 2359 | parseAndDumpInner(step, check, &br, bw) catch |err| switch (err) { |
| 2364 | 2360 | error.EndOfStream => try bw.writeAll("\n<UnexpectedEndOfStream>"), |
lib/std/Build/Step/Compile.zig+2-3| ... | ... | @@ -1969,14 +1969,13 @@ fn checkCompileErrors(compile: *Compile) !void { |
| 1969 | 1969 | const arena = compile.step.owner.allocator; |
| 1970 | 1970 | |
| 1971 | 1971 | const actual_errors = ae: { |
| 1972 | var aw: std.io.AllocatingWriter = undefined; | |
| 1973 | aw.init(arena); | |
| 1972 | var aw: std.io.Writer.Allocating = .init(arena); | |
| 1974 | 1973 | defer aw.deinit(); |
| 1975 | 1974 | try actual_eb.renderToWriter(.{ |
| 1976 | 1975 | .ttyconf = .no_color, |
| 1977 | 1976 | .include_reference_trace = false, |
| 1978 | 1977 | .include_source_line = false, |
| 1979 | }, &aw.buffered_writer); | |
| 1978 | }, &aw.interface); | |
| 1980 | 1979 | break :ae try aw.toOwnedSlice(); |
| 1981 | 1980 | }; |
| 1982 | 1981 |
lib/std/Build/Step/ConfigHeader.zig+4-5| ... | ... | @@ -196,10 +196,9 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 196 | 196 | man.hash.addBytes(config_header.include_path); |
| 197 | 197 | man.hash.addOptionalBytes(config_header.include_guard_override); |
| 198 | 198 | |
| 199 | var aw: std.io.AllocatingWriter = undefined; | |
| 200 | aw.init(gpa); | |
| 199 | var aw: std.io.Writer.Allocating = .init(gpa); | |
| 201 | 200 | defer aw.deinit(); |
| 202 | const bw = &aw.buffered_writer; | |
| 201 | const bw = &aw.interface; | |
| 203 | 202 | |
| 204 | 203 | const header_text = "This file was generated by ConfigHeader using the Zig Build System."; |
| 205 | 204 | const c_generated_line = "/* " ++ header_text ++ " */\n"; |
| ... | ... | @@ -330,13 +329,13 @@ fn render_autoconf_undef( |
| 330 | 329 | fn render_autoconf_at( |
| 331 | 330 | step: *Step, |
| 332 | 331 | contents: []const u8, |
| 333 | aw: *std.io.AllocatingWriter, | |
| 332 | aw: *std.io.Writer.Allocating, | |
| 334 | 333 | values: std.StringArrayHashMap(Value), |
| 335 | 334 | src_path: []const u8, |
| 336 | 335 | ) !void { |
| 337 | 336 | const build = step.owner; |
| 338 | 337 | const allocator = build.allocator; |
| 339 | const bw = &aw.buffered_writer; | |
| 338 | const bw = &aw.interface; | |
| 340 | 339 | |
| 341 | 340 | const used = allocator.alloc(bool, values.count()) catch @panic("OOM"); |
| 342 | 341 | for (used) |*u| u.* = false; |
lib/std/array_list.zig+1-1| ... | ... | @@ -905,7 +905,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?mem.Alig |
| 905 | 905 | pub fn print(self: *Self, gpa: Allocator, comptime fmt: []const u8, args: anytype) error{OutOfMemory}!void { |
| 906 | 906 | comptime assert(T == u8); |
| 907 | 907 | try self.ensureUnusedCapacity(gpa, fmt.len); |
| 908 | var aw: std.io.AllocatingWriter = .fromArrayList(gpa, self); | |
| 908 | var aw: std.io.Writer.Allocating = .fromArrayList(gpa, self); | |
| 909 | 909 | defer self.* = aw.toArrayList(); |
| 910 | 910 | return aw.interface.print(fmt, args) catch |err| switch (err) { |
| 911 | 911 | error.WriteFailed => return error.OutOfMemory, |
lib/std/compress/flate.zig+2-3| ... | ... | @@ -341,11 +341,10 @@ test "compress/decompress" { |
| 341 | 341 | |
| 342 | 342 | fn testDecompress(comptime container: Container, compressed: []const u8, expected_plain: []const u8) !void { |
| 343 | 343 | var in: std.io.Reader = .fixed(compressed); |
| 344 | var out: std.io.AllocatingWriter = undefined; | |
| 345 | out.init(testing.allocator); | |
| 344 | var out: std.io.Writer.Allocating = .init(testing.allocator); | |
| 346 | 345 | defer out.deinit(); |
| 347 | 346 | |
| 348 | try Decompress.pump(container, &in, &out.buffered_writer); | |
| 347 | try Decompress.pump(container, &in, &out.interface); | |
| 349 | 348 | try testing.expectEqualSlices(u8, expected_plain, out.items); |
| 350 | 349 | } |
| 351 | 350 |
lib/std/compress/flate/Decompress.zig+11-16| ... | ... | @@ -729,13 +729,12 @@ test "decompress" { |
| 729 | 729 | }; |
| 730 | 730 | for (cases) |c| { |
| 731 | 731 | var fb: std.io.Reader = .fixed(c.in); |
| 732 | var aw: std.io.AllocatingWriter = undefined; | |
| 733 | aw.init(testing.allocator); | |
| 732 | var aw: std.io.Writer.Allocating = .init(testing.allocator); | |
| 734 | 733 | defer aw.deinit(); |
| 735 | 734 | |
| 736 | 735 | var decompress: Decompress = .init(&fb, .raw); |
| 737 | 736 | var decompress_br = decompress.readable(&.{}); |
| 738 | _ = try decompress_br.readRemaining(&aw.buffered_writer); | |
| 737 | _ = try decompress_br.readRemaining(&aw.interface); | |
| 739 | 738 | try testing.expectEqualStrings(c.out, aw.getWritten()); |
| 740 | 739 | } |
| 741 | 740 | } |
| ... | ... | @@ -789,13 +788,12 @@ test "gzip decompress" { |
| 789 | 788 | }; |
| 790 | 789 | for (cases) |c| { |
| 791 | 790 | var fb: std.io.Reader = .fixed(c.in); |
| 792 | var aw: std.io.AllocatingWriter = undefined; | |
| 793 | aw.init(testing.allocator); | |
| 791 | var aw: std.io.Writer.Allocating = .init(testing.allocator); | |
| 794 | 792 | defer aw.deinit(); |
| 795 | 793 | |
| 796 | 794 | var decompress: Decompress = .init(&fb, .gzip); |
| 797 | 795 | var decompress_br = decompress.readable(&.{}); |
| 798 | _ = try decompress_br.readRemaining(&aw.buffered_writer); | |
| 796 | _ = try decompress_br.readRemaining(&aw.interface); | |
| 799 | 797 | try testing.expectEqualStrings(c.out, aw.getWritten()); |
| 800 | 798 | } |
| 801 | 799 | } |
| ... | ... | @@ -818,13 +816,12 @@ test "zlib decompress" { |
| 818 | 816 | }; |
| 819 | 817 | for (cases) |c| { |
| 820 | 818 | var fb: std.io.Reader = .fixed(c.in); |
| 821 | var aw: std.io.AllocatingWriter = undefined; | |
| 822 | aw.init(testing.allocator); | |
| 819 | var aw: std.io.Writer.Allocating = .init(testing.allocator); | |
| 823 | 820 | defer aw.deinit(); |
| 824 | 821 | |
| 825 | 822 | var decompress: Decompress = .init(&fb, .zlib); |
| 826 | 823 | var decompress_br = decompress.readable(&.{}); |
| 827 | _ = try decompress_br.readRemaining(&aw.buffered_writer); | |
| 824 | _ = try decompress_br.readRemaining(&aw.interface); | |
| 828 | 825 | try testing.expectEqualStrings(c.out, aw.getWritten()); |
| 829 | 826 | } |
| 830 | 827 | } |
| ... | ... | @@ -879,18 +876,17 @@ test "fuzzing tests" { |
| 879 | 876 | |
| 880 | 877 | inline for (cases, 0..) |c, case_no| { |
| 881 | 878 | var in: std.io.Reader = .fixed(@embedFile("testdata/fuzz/" ++ c.input ++ ".input")); |
| 882 | var aw: std.io.AllocatingWriter = undefined; | |
| 883 | aw.init(testing.allocator); | |
| 879 | var aw: std.io.Writer.Allocating = .init(testing.allocator); | |
| 884 | 880 | defer aw.deinit(); |
| 885 | 881 | errdefer std.debug.print("test case failed {}\n", .{case_no}); |
| 886 | 882 | |
| 887 | 883 | var decompress: Decompress = .init(&in, .raw); |
| 888 | 884 | var decompress_br = decompress.readable(&.{}); |
| 889 | 885 | if (c.err) |expected_err| { |
| 890 | try testing.expectError(error.ReadFailed, decompress_br.readRemaining(&aw.buffered_writer)); | |
| 886 | try testing.expectError(error.ReadFailed, decompress_br.readRemaining(&aw.interface)); | |
| 891 | 887 | try testing.expectError(expected_err, decompress.read_err.?); |
| 892 | 888 | } else { |
| 893 | _ = try decompress_br.readRemaining(&aw.buffered_writer); | |
| 889 | _ = try decompress_br.readRemaining(&aw.interface); | |
| 894 | 890 | try testing.expectEqualStrings(c.out, aw.getWritten()); |
| 895 | 891 | } |
| 896 | 892 | } |
| ... | ... | @@ -901,13 +897,12 @@ test "bug 18966" { |
| 901 | 897 | const expect = @embedFile("testdata/fuzz/bug_18966.expect"); |
| 902 | 898 | |
| 903 | 899 | var in: std.io.Reader = .fixed(input); |
| 904 | var aw: std.io.AllocatingWriter = undefined; | |
| 905 | aw.init(testing.allocator); | |
| 900 | var aw: std.io.Writer.Allocating = .init(testing.allocator); | |
| 906 | 901 | defer aw.deinit(); |
| 907 | 902 | |
| 908 | 903 | var decompress: Decompress = .init(&in, .gzip); |
| 909 | 904 | var decompress_br = decompress.readable(&.{}); |
| 910 | _ = try decompress_br.readRemaining(&aw.buffered_writer); | |
| 905 | _ = try decompress_br.readRemaining(&aw.interface); | |
| 911 | 906 | try testing.expectEqualStrings(expect, aw.getWritten()); |
| 912 | 907 | } |
| 913 | 908 |
lib/std/compress/lzma2.zig+2-3| ... | ... | @@ -278,9 +278,8 @@ test decompress { |
| 278 | 278 | 0x00, 0x06, 0x57, 0x6F, 0x72, 0x6C, 0x64, 0x21, 0x0A, 0x00, |
| 279 | 279 | }; |
| 280 | 280 | var stream: std.io.Reader = .fixed(&compressed); |
| 281 | var decomp: std.io.AllocatingWriter = undefined; | |
| 282 | const decomp_bw = decomp.init(std.testing.allocator); | |
| 281 | var decomp: std.io.Writer.Allocating = .init(std.testing.allocator); | |
| 283 | 282 | defer decomp.deinit(); |
| 284 | try decompress(std.testing.allocator, &stream, decomp_bw); | |
| 283 | try decompress(std.testing.allocator, &stream, &decomp.interface); | |
| 285 | 284 | try std.testing.expectEqualSlices(u8, expected, decomp.getWritten()); |
| 286 | 285 | } |
lib/std/debug.zig+2-3| ... | ... | @@ -304,11 +304,10 @@ pub fn dumpHexFallible(bw: *Writer, ttyconf: std.io.tty.Config, bytes: []const u |
| 304 | 304 | |
| 305 | 305 | test dumpHexFallible { |
| 306 | 306 | const bytes: []const u8 = &.{ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x01, 0x12, 0x13 }; |
| 307 | var aw: std.io.AllocatingWriter = undefined; | |
| 308 | var bw = aw.init(std.testing.allocator); | |
| 307 | var aw: std.io.Writer.Allocating = .init(std.testing.allocator); | |
| 309 | 308 | defer aw.deinit(); |
| 310 | 309 | |
| 311 | try dumpHexFallible(&bw, .no_color, bytes); | |
| 310 | try dumpHexFallible(&aw.interface, .no_color, bytes); | |
| 312 | 311 | const expected = try std.fmt.allocPrint(std.testing.allocator, |
| 313 | 312 | \\{x:0>[2]} 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF .."3DUfw........ |
| 314 | 313 | \\{x:0>[2]} 01 12 13 ... |
lib/std/fmt.zig+4-6| ... | ... | @@ -853,10 +853,9 @@ pub fn count(comptime fmt: []const u8, args: anytype) usize { |
| 853 | 853 | } |
| 854 | 854 | |
| 855 | 855 | pub fn allocPrint(gpa: Allocator, comptime fmt: []const u8, args: anytype) Allocator.Error![]u8 { |
| 856 | var aw: std.io.AllocatingWriter = undefined; | |
| 857 | try aw.initCapacity(gpa, fmt.len); | |
| 856 | var aw = try std.io.Writer.Allocating.initCapacity(gpa, fmt.len); | |
| 858 | 857 | defer aw.deinit(); |
| 859 | aw.buffered_writer.print(fmt, args) catch |err| switch (err) { | |
| 858 | aw.interface.print(fmt, args) catch |err| switch (err) { | |
| 860 | 859 | error.WriteFailed => return error.OutOfMemory, |
| 861 | 860 | }; |
| 862 | 861 | return aw.toOwnedSlice(); |
| ... | ... | @@ -868,10 +867,9 @@ pub fn allocPrintSentinel( |
| 868 | 867 | args: anytype, |
| 869 | 868 | comptime sentinel: u8, |
| 870 | 869 | ) Allocator.Error![:sentinel]u8 { |
| 871 | var aw: std.io.AllocatingWriter = undefined; | |
| 872 | try aw.initCapacity(gpa, fmt.len); | |
| 870 | var aw = try std.io.Writer.Allocating.initCapacity(gpa, fmt.len); | |
| 873 | 871 | defer aw.deinit(); |
| 874 | aw.buffered_writer.print(fmt, args) catch |err| switch (err) { | |
| 872 | aw.interface.print(fmt, args) catch |err| switch (err) { | |
| 875 | 873 | error.WriteFailed => return error.OutOfMemory, |
| 876 | 874 | }; |
| 877 | 875 | return aw.toOwnedSliceSentinel(sentinel); |
lib/std/json.zig+2-2| ... | ... | @@ -42,9 +42,9 @@ test Value { |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | test Stringify { |
| 45 | var out: std.io.AllocatingWriter = undefined; | |
| 45 | var out: std.io.Writer.Allocating = .init(testing.allocator); | |
| 46 | 46 | var write_stream: Stringify = .{ |
| 47 | .writer = out.init(testing.allocator), | |
| 47 | .writer = &out.interface, | |
| 48 | 48 | .options = .{ .whitespace = .indent_2 }, |
| 49 | 49 | }; |
| 50 | 50 | defer out.deinit(); |
lib/std/json/Stringify.zig+4-4| ... | ... | @@ -576,8 +576,8 @@ pub fn value(v: anytype, options: Options, writer: *Writer) Error!void { |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | test value { |
| 579 | var out: std.io.AllocatingWriter = undefined; | |
| 580 | const writer = out.init(std.testing.allocator); | |
| 579 | var out: std.io.Writer.Allocating = .init(std.testing.allocator); | |
| 580 | const writer = &out.interface; | |
| 581 | 581 | defer out.deinit(); |
| 582 | 582 | |
| 583 | 583 | const T = struct { a: i32, b: []const u8 }; |
| ... | ... | @@ -616,8 +616,8 @@ test value { |
| 616 | 616 | /// |
| 617 | 617 | /// Caller owns returned memory. |
| 618 | 618 | pub fn valueAlloc(gpa: Allocator, v: anytype, options: Options) error{OutOfMemory}![]u8 { |
| 619 | var aw: std.io.AllocatingWriter = undefined; | |
| 620 | const writer = aw.init(gpa); | |
| 619 | var aw: std.io.Writer.Allocating = .init(gpa); | |
| 620 | const writer = &aw.interface; | |
| 621 | 621 | defer aw.deinit(); |
| 622 | 622 | value(v, options, writer) catch return error.OutOfMemory; |
| 623 | 623 | return aw.toOwnedSlice(); |
lib/std/tar/Writer.zig+4-5| ... | ... | @@ -433,8 +433,8 @@ test "write files" { |
| 433 | 433 | { |
| 434 | 434 | const root = "root"; |
| 435 | 435 | |
| 436 | var output: std.io.AllocatingWriter = .init(testing.allocator); | |
| 437 | var wrt: Writer = .{ .underlying_writer = &output.buffered_writer }; | |
| 436 | var output: std.io.Writer.Allocating = .init(testing.allocator); | |
| 437 | var wrt: Writer = .{ .underlying_writer = &output.interface }; | |
| 438 | 438 | defer output.deinit(); |
| 439 | 439 | try wrt.setRoot(root); |
| 440 | 440 | for (files) |file| |
| ... | ... | @@ -469,9 +469,8 @@ test "write files" { |
| 469 | 469 | } |
| 470 | 470 | // without root |
| 471 | 471 | { |
| 472 | var output: std.io.AllocatingWriter = undefined; | |
| 473 | output.init(testing.allocator); | |
| 474 | var wrt: Writer = .{ .underlying_writer = &output.buffered_writer }; | |
| 472 | var output: std.io.Writer.Allocating = .init(testing.allocator); | |
| 473 | var wrt: Writer = .{ .underlying_writer = &output.interface }; | |
| 475 | 474 | defer output.deinit(); |
| 476 | 475 | for (files) |file| { |
| 477 | 476 | var content: std.io.Reader = .fixed(file.content); |
lib/std/zig/Ast.zig+2-3| ... | ... | @@ -204,10 +204,9 @@ pub fn parse(gpa: Allocator, source: [:0]const u8, mode: Mode) Allocator.Error!A |
| 204 | 204 | /// `gpa` is used for allocating the resulting formatted source code. |
| 205 | 205 | /// Caller owns the returned slice of bytes, allocated with `gpa`. |
| 206 | 206 | pub fn renderAlloc(tree: Ast, gpa: Allocator) error{OutOfMemory}![]u8 { |
| 207 | var aw: std.io.AllocatingWriter = undefined; | |
| 208 | const bw = aw.init(gpa); | |
| 207 | var aw: std.io.Writer.Allocating = .init(gpa); | |
| 209 | 208 | errdefer aw.deinit(); |
| 210 | render(tree, gpa, bw, .{}) catch |err| switch (err) { | |
| 209 | render(tree, gpa, &aw.interface, .{}) catch |err| switch (err) { | |
| 211 | 210 | error.WriteFailed => return error.OutOfMemory, |
| 212 | 211 | }; |
| 213 | 212 | return aw.toOwnedSlice(); |
lib/std/zig/Ast/Render.zig+2-3| ... | ... | @@ -2142,14 +2142,13 @@ fn renderArrayInit( |
| 2142 | 2142 | |
| 2143 | 2143 | const section_exprs = row_exprs[0..section_end]; |
| 2144 | 2144 | |
| 2145 | var sub_expr_buffer: std.io.AllocatingWriter = undefined; | |
| 2146 | sub_expr_buffer.init(gpa); | |
| 2145 | var sub_expr_buffer: std.io.Writer.Allocating = .init(gpa); | |
| 2147 | 2146 | defer sub_expr_buffer.deinit(); |
| 2148 | 2147 | |
| 2149 | 2148 | const sub_expr_buffer_starts = try gpa.alloc(usize, section_exprs.len + 1); |
| 2150 | 2149 | defer gpa.free(sub_expr_buffer_starts); |
| 2151 | 2150 | |
| 2152 | var auto_indenting_stream: AutoIndentingStream = .init(gpa, &sub_expr_buffer.buffered_writer, indent_delta); | |
| 2151 | var auto_indenting_stream: AutoIndentingStream = .init(gpa, &sub_expr_buffer.interface, indent_delta); | |
| 2153 | 2152 | defer auto_indenting_stream.deinit(); |
| 2154 | 2153 | var sub_render: Render = .{ |
| 2155 | 2154 | .gpa = r.gpa, |
lib/std/zig/AstGen.zig+4-6| ... | ... | @@ -11442,10 +11442,9 @@ fn parseStrLit( |
| 11442 | 11442 | ) InnerError!void { |
| 11443 | 11443 | const raw_string = bytes[offset..]; |
| 11444 | 11444 | const result = r: { |
| 11445 | var aw: std.io.AllocatingWriter = undefined; | |
| 11446 | const bw = aw.fromArrayList(astgen.gpa, buf); | |
| 11445 | var aw: std.io.Writer.Allocating = .fromArrayList(astgen.gpa, buf); | |
| 11447 | 11446 | defer buf.* = aw.toArrayList(); |
| 11448 | break :r std.zig.string_literal.parseWrite(bw, raw_string) catch |err| switch (err) { | |
| 11447 | break :r std.zig.string_literal.parseWrite(&aw.interface, raw_string) catch |err| switch (err) { | |
| 11449 | 11448 | error.WriteFailed => return error.OutOfMemory, |
| 11450 | 11449 | }; |
| 11451 | 11450 | }; |
| ... | ... | @@ -13899,10 +13898,9 @@ fn lowerAstErrors(astgen: *AstGen) error{OutOfMemory}!void { |
| 13899 | 13898 | const tree = astgen.tree; |
| 13900 | 13899 | assert(tree.errors.len > 0); |
| 13901 | 13900 | |
| 13902 | var msg: std.io.AllocatingWriter = undefined; | |
| 13903 | msg.init(gpa); | |
| 13901 | var msg: std.io.Writer.Allocating = .init(gpa); | |
| 13904 | 13902 | defer msg.deinit(); |
| 13905 | const msg_bw = &msg.buffered_writer; | |
| 13903 | const msg_bw = &msg.interface; | |
| 13906 | 13904 | |
| 13907 | 13905 | var notes: std.ArrayListUnmanaged(u32) = .empty; |
| 13908 | 13906 | defer notes.deinit(gpa); |
lib/std/zig/ErrorBundle.zig+4-4| ... | ... | @@ -788,8 +788,8 @@ pub const Wip = struct { |
| 788 | 788 | |
| 789 | 789 | const ttyconf: std.io.tty.Config = .no_color; |
| 790 | 790 | |
| 791 | var bundle_buf: std.io.AllocatingWriter = undefined; | |
| 792 | const bundle_bw = bundle_buf.init(std.testing.allocator); | |
| 791 | var bundle_buf: std.io.Writer.Allocating = .init(std.testing.allocator); | |
| 792 | const bundle_bw = &bundle_buf.interface; | |
| 793 | 793 | defer bundle_buf.deinit(); |
| 794 | 794 | try bundle.renderToWriter(.{ .ttyconf = ttyconf }, bundle_bw); |
| 795 | 795 | |
| ... | ... | @@ -804,8 +804,8 @@ pub const Wip = struct { |
| 804 | 804 | }; |
| 805 | 805 | defer copy.deinit(std.testing.allocator); |
| 806 | 806 | |
| 807 | var copy_buf: std.io.AllocatingWriter = undefined; | |
| 808 | const copy_bw = copy_buf.init(std.testing.allocator); | |
| 807 | var copy_buf: std.io.Writer.Allocating = .init(std.testing.allocator); | |
| 808 | const copy_bw = &copy_buf.interface; | |
| 809 | 809 | defer copy_buf.deinit(); |
| 810 | 810 | try copy.renderToWriter(.{ .ttyconf = ttyconf }, copy_bw); |
| 811 | 811 |
lib/std/zig/ZonGen.zig+6-9| ... | ... | @@ -467,10 +467,9 @@ fn appendIdentStr(zg: *ZonGen, ident_token: Ast.TokenIndex) error{ OutOfMemory, |
| 467 | 467 | const raw_string = zg.tree.tokenSlice(ident_token)[offset..]; |
| 468 | 468 | try zg.string_bytes.ensureUnusedCapacity(gpa, raw_string.len); |
| 469 | 469 | const result = r: { |
| 470 | var aw: std.io.AllocatingWriter = undefined; | |
| 471 | const bw = aw.fromArrayList(gpa, &zg.string_bytes); | |
| 470 | var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &zg.string_bytes); | |
| 472 | 471 | defer zg.string_bytes = aw.toArrayList(); |
| 473 | break :r std.zig.string_literal.parseWrite(bw, raw_string) catch |err| switch (err) { | |
| 472 | break :r std.zig.string_literal.parseWrite(&aw.interface, raw_string) catch |err| switch (err) { | |
| 474 | 473 | error.WriteFailed => return error.OutOfMemory, |
| 475 | 474 | }; |
| 476 | 475 | }; |
| ... | ... | @@ -566,10 +565,9 @@ fn strLitAsString(zg: *ZonGen, str_node: Ast.Node.Index) error{ OutOfMemory, Bad |
| 566 | 565 | const size_hint = strLitSizeHint(zg.tree, str_node); |
| 567 | 566 | try string_bytes.ensureUnusedCapacity(gpa, size_hint); |
| 568 | 567 | const result = r: { |
| 569 | var aw: std.io.AllocatingWriter = undefined; | |
| 570 | const bw = aw.fromArrayList(gpa, &zg.string_bytes); | |
| 568 | var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &zg.string_bytes); | |
| 571 | 569 | defer zg.string_bytes = aw.toArrayList(); |
| 572 | break :r parseStrLit(zg.tree, str_node, bw) catch |err| switch (err) { | |
| 570 | break :r parseStrLit(zg.tree, str_node, &aw.interface) catch |err| switch (err) { | |
| 573 | 571 | error.WriteFailed => return error.OutOfMemory, |
| 574 | 572 | }; |
| 575 | 573 | }; |
| ... | ... | @@ -888,10 +886,9 @@ fn lowerAstErrors(zg: *ZonGen) Allocator.Error!void { |
| 888 | 886 | const tree = zg.tree; |
| 889 | 887 | assert(tree.errors.len > 0); |
| 890 | 888 | |
| 891 | var msg: std.io.AllocatingWriter = undefined; | |
| 892 | msg.init(gpa); | |
| 889 | var msg: std.io.Writer.Allocating = .init(gpa); | |
| 893 | 890 | defer msg.deinit(); |
| 894 | const msg_bw = &msg.buffered_writer; | |
| 891 | const msg_bw = &msg.interface; | |
| 895 | 892 | |
| 896 | 893 | var notes: std.ArrayListUnmanaged(Zoir.CompileError.Note) = .empty; |
| 897 | 894 | defer notes.deinit(gpa); |
lib/std/zig/llvm/Builder.zig+3-12| ... | ... | @@ -8619,16 +8619,7 @@ pub fn deinit(self: *Builder) void { |
| 8619 | 8619 | self.* = undefined; |
| 8620 | 8620 | } |
| 8621 | 8621 | |
| 8622 | pub fn setModuleAsm(self: *Builder, aw: *std.io.AllocatingWriter) *Writer { | |
| 8623 | self.module_asm.clearRetainingCapacity(); | |
| 8624 | return self.appendModuleAsm(aw); | |
| 8625 | } | |
| 8626 | ||
| 8627 | pub fn appendModuleAsm(self: *Builder, aw: *std.io.AllocatingWriter) *Writer { | |
| 8628 | return aw.fromArrayList(self.gpa, &self.module_asm); | |
| 8629 | } | |
| 8630 | ||
| 8631 | pub fn finishModuleAsm(self: *Builder, aw: *std.io.AllocatingWriter) Allocator.Error!void { | |
| 8622 | pub fn finishModuleAsm(self: *Builder, aw: *std.io.Writer.Allocating) Allocator.Error!void { | |
| 8632 | 8623 | self.module_asm = aw.toArrayList(); |
| 8633 | 8624 | if (self.module_asm.getLastOrNull()) |last| if (last != '\n') |
| 8634 | 8625 | try self.module_asm.append(self.gpa, '\n'); |
| ... | ... | @@ -8938,8 +8929,8 @@ pub fn getIntrinsic( |
| 8938 | 8929 | |
| 8939 | 8930 | const name = name: { |
| 8940 | 8931 | { |
| 8941 | var aw: std.io.AllocatingWriter = undefined; | |
| 8942 | const bw = aw.fromArrayList(self.gpa, &self.strtab_string_bytes); | |
| 8932 | var aw: std.io.Writer.Allocating = .fromArrayList(self.gpa, &self.strtab_string_bytes); | |
| 8933 | const bw = &aw.interface; | |
| 8943 | 8934 | defer self.strtab_string_bytes = aw.toArrayList(); |
| 8944 | 8935 | bw.print("llvm.{s}", .{@tagName(id)}) catch return error.OutOfMemory; |
| 8945 | 8936 | for (overload) |ty| bw.print(".{fm}", .{ty.fmt(self)}) catch return error.OutOfMemory; |
lib/std/zig/string_literal.zig+2-3| ... | ... | @@ -358,10 +358,9 @@ pub fn parseWrite(writer: *Writer, bytes: []const u8) Writer.Error!Result { |
| 358 | 358 | /// Higher level API. Does not return extra info about parse errors. |
| 359 | 359 | /// Caller owns returned memory. |
| 360 | 360 | pub fn parseAlloc(allocator: std.mem.Allocator, bytes: []const u8) ParseError![]u8 { |
| 361 | var aw: std.io.AllocatingWriter = undefined; | |
| 362 | aw.init(allocator); | |
| 361 | var aw: std.io.Writer.Allocating = .init(allocator); | |
| 363 | 362 | defer aw.deinit(); |
| 364 | const result = parseWrite(&aw.buffered_writer, bytes) catch |err| switch (err) { | |
| 363 | const result = parseWrite(&aw.interface, bytes) catch |err| switch (err) { | |
| 365 | 364 | error.WriteFailed => return error.OutOfMemory, |
| 366 | 365 | }; |
| 367 | 366 | switch (result) { |
lib/std/zon/parse.zig+2-3| ... | ... | @@ -638,10 +638,9 @@ const Parser = struct { |
| 638 | 638 | if (pointer.sentinel() != null) size_hint += 1; |
| 639 | 639 | const gpa = self.gpa; |
| 640 | 640 | |
| 641 | var aw: std.io.AllocatingWriter = undefined; | |
| 642 | try aw.initCapacity(gpa, size_hint); | |
| 641 | var aw = try std.io.Writer.Allocating.initCapacity(gpa, size_hint); | |
| 643 | 642 | defer aw.deinit(); |
| 644 | const parsed = ZonGen.parseStrLit(self.ast, ast_node, &aw.buffered_writer) catch |err| switch (err) { | |
| 643 | const parsed = ZonGen.parseStrLit(self.ast, ast_node, &aw.interface) catch |err| switch (err) { | |
| 645 | 644 | error.WriteFailed => return error.OutOfMemory, |
| 646 | 645 | }; |
| 647 | 646 | switch (parsed) { |
lib/std/zon/stringify.zig+20-30| ... | ... | @@ -1054,9 +1054,8 @@ fn expectSerializeEqual( |
| 1054 | 1054 | value: anytype, |
| 1055 | 1055 | options: SerializeOptions, |
| 1056 | 1056 | ) !void { |
| 1057 | var aw: std.io.AllocatingWriter = undefined; | |
| 1058 | aw.init(std.testing.allocator); | |
| 1059 | const bw = &aw.buffered_writer; | |
| 1057 | var aw: std.io.Writer.Allocating = .init(std.testing.allocator); | |
| 1058 | const bw = &aw.interface; | |
| 1060 | 1059 | defer aw.deinit(); |
| 1061 | 1060 | |
| 1062 | 1061 | try serialize(value, options, bw); |
| ... | ... | @@ -1157,9 +1156,8 @@ test "std.zon stringify whitespace, high level API" { |
| 1157 | 1156 | } |
| 1158 | 1157 | |
| 1159 | 1158 | test "std.zon stringify whitespace, low level API" { |
| 1160 | var aw: std.io.AllocatingWriter = undefined; | |
| 1161 | aw.init(std.testing.allocator); | |
| 1162 | var s: Serializer = .{ .writer = &aw.buffered_writer }; | |
| 1159 | var aw: std.io.Writer.Allocating = .init(std.testing.allocator); | |
| 1160 | var s: Serializer = .{ .writer = &aw.interface }; | |
| 1163 | 1161 | defer aw.deinit(); |
| 1164 | 1162 | |
| 1165 | 1163 | for ([2]bool{ true, false }) |whitespace| { |
| ... | ... | @@ -1515,9 +1513,8 @@ test "std.zon stringify whitespace, low level API" { |
| 1515 | 1513 | } |
| 1516 | 1514 | |
| 1517 | 1515 | test "std.zon stringify utf8 codepoints" { |
| 1518 | var aw: std.io.AllocatingWriter = undefined; | |
| 1519 | aw.init(std.testing.allocator); | |
| 1520 | var s: Serializer = .{ .writer = &aw.buffered_writer }; | |
| 1516 | var aw: std.io.Writer.Allocating = .init(std.testing.allocator); | |
| 1517 | var s: Serializer = .{ .writer = &aw.interface }; | |
| 1521 | 1518 | defer aw.deinit(); |
| 1522 | 1519 | |
| 1523 | 1520 | // Printable ASCII |
| ... | ... | @@ -1626,9 +1623,8 @@ test "std.zon stringify utf8 codepoints" { |
| 1626 | 1623 | } |
| 1627 | 1624 | |
| 1628 | 1625 | test "std.zon stringify strings" { |
| 1629 | var aw: std.io.AllocatingWriter = undefined; | |
| 1630 | aw.init(std.testing.allocator); | |
| 1631 | var s: Serializer = .{ .writer = &aw.buffered_writer }; | |
| 1626 | var aw: std.io.Writer.Allocating = .init(std.testing.allocator); | |
| 1627 | var s: Serializer = .{ .writer = &aw.interface }; | |
| 1632 | 1628 | defer aw.deinit(); |
| 1633 | 1629 | |
| 1634 | 1630 | // Minimal case |
| ... | ... | @@ -1697,9 +1693,8 @@ test "std.zon stringify strings" { |
| 1697 | 1693 | } |
| 1698 | 1694 | |
| 1699 | 1695 | test "std.zon stringify multiline strings" { |
| 1700 | var aw: std.io.AllocatingWriter = undefined; | |
| 1701 | aw.init(std.testing.allocator); | |
| 1702 | var s: Serializer = .{ .writer = &aw.buffered_writer }; | |
| 1696 | var aw: std.io.Writer.Allocating = .init(std.testing.allocator); | |
| 1697 | var s: Serializer = .{ .writer = &aw.interface }; | |
| 1703 | 1698 | defer aw.deinit(); |
| 1704 | 1699 | |
| 1705 | 1700 | inline for (.{ true, false }) |whitespace| { |
| ... | ... | @@ -1918,9 +1913,8 @@ test "std.zon stringify skip default fields" { |
| 1918 | 1913 | } |
| 1919 | 1914 | |
| 1920 | 1915 | test "std.zon depth limits" { |
| 1921 | var aw: std.io.AllocatingWriter = undefined; | |
| 1922 | aw.init(std.testing.allocator); | |
| 1923 | const bw = &aw.buffered_writer; | |
| 1916 | var aw: std.io.Writer.Allocating = .init(std.testing.allocator); | |
| 1917 | const bw = &aw.interface; | |
| 1924 | 1918 | defer aw.deinit(); |
| 1925 | 1919 | |
| 1926 | 1920 | const Recurse = struct { r: []const @This() }; |
| ... | ... | @@ -2180,9 +2174,8 @@ test "std.zon stringify primitives" { |
| 2180 | 2174 | } |
| 2181 | 2175 | |
| 2182 | 2176 | test "std.zon stringify ident" { |
| 2183 | var aw: std.io.AllocatingWriter = undefined; | |
| 2184 | aw.init(std.testing.allocator); | |
| 2185 | var s: Serializer = .{ .writer = &aw.buffered_writer }; | |
| 2177 | var aw: std.io.Writer.Allocating = .init(std.testing.allocator); | |
| 2178 | var s: Serializer = .{ .writer = &aw.interface }; | |
| 2186 | 2179 | defer aw.deinit(); |
| 2187 | 2180 | |
| 2188 | 2181 | try expectSerializeEqual(".{ .a = 0 }", .{ .a = 0 }, .{}); |
| ... | ... | @@ -2228,9 +2221,8 @@ test "std.zon stringify ident" { |
| 2228 | 2221 | } |
| 2229 | 2222 | |
| 2230 | 2223 | test "std.zon stringify as tuple" { |
| 2231 | var aw: std.io.AllocatingWriter = undefined; | |
| 2232 | aw.init(std.testing.allocator); | |
| 2233 | var s: Serializer = .{ .writer = &aw.buffered_writer }; | |
| 2224 | var aw: std.io.Writer.Allocating = .init(std.testing.allocator); | |
| 2225 | var s: Serializer = .{ .writer = &aw.interface }; | |
| 2234 | 2226 | defer aw.deinit(); |
| 2235 | 2227 | |
| 2236 | 2228 | // Tuples |
| ... | ... | @@ -2250,9 +2242,8 @@ test "std.zon stringify as tuple" { |
| 2250 | 2242 | } |
| 2251 | 2243 | |
| 2252 | 2244 | test "std.zon stringify as float" { |
| 2253 | var aw: std.io.AllocatingWriter = undefined; | |
| 2254 | aw.init(std.testing.allocator); | |
| 2255 | var s: Serializer = .{ .writer = &aw.buffered_writer }; | |
| 2245 | var aw: std.io.Writer.Allocating = .init(std.testing.allocator); | |
| 2246 | var s: Serializer = .{ .writer = &aw.interface }; | |
| 2256 | 2247 | defer aw.deinit(); |
| 2257 | 2248 | |
| 2258 | 2249 | // Comptime float |
| ... | ... | @@ -2355,9 +2346,8 @@ test "std.zon pointers" { |
| 2355 | 2346 | } |
| 2356 | 2347 | |
| 2357 | 2348 | test "std.zon tuple/struct field" { |
| 2358 | var aw: std.io.AllocatingWriter = undefined; | |
| 2359 | aw.init(std.testing.allocator); | |
| 2360 | var s: Serializer = .{ .writer = &aw.buffered_writer }; | |
| 2349 | var aw: std.io.Writer.Allocating = .init(std.testing.allocator); | |
| 2350 | var s: Serializer = .{ .writer = &aw.interface }; | |
| 2361 | 2351 | defer aw.deinit(); |
| 2362 | 2352 | |
| 2363 | 2353 | // Test on structs |
src/Package/Fetch/git.zig+4-4| ... | ... | @@ -857,8 +857,8 @@ pub const Session = struct { |
| 857 | 857 | upload_pack_uri.query = null; |
| 858 | 858 | upload_pack_uri.fragment = null; |
| 859 | 859 | |
| 860 | var body: std.io.AllocatingWriter = undefined; | |
| 861 | const body_writer = body.init(session.allocator); | |
| 860 | var body: std.io.Writer.Allocating = .init(session.allocator); | |
| 861 | const body_writer = &body.interface; | |
| 862 | 862 | defer body.deinit(); |
| 863 | 863 | try Packet.write(.{ .data = "command=ls-refs\n" }, body_writer); |
| 864 | 864 | if (session.supports_agent) { |
| ... | ... | @@ -974,9 +974,9 @@ pub const Session = struct { |
| 974 | 974 | upload_pack_uri.query = null; |
| 975 | 975 | upload_pack_uri.fragment = null; |
| 976 | 976 | |
| 977 | var body: std.io.AllocatingWriter = undefined; | |
| 978 | const body_writer = body.init(session.allocator); | |
| 977 | var body: std.io.Writer.Allocating = .init(session.allocator); | |
| 979 | 978 | defer body.deinit(); |
| 979 | const body_writer = &body.interface; | |
| 980 | 980 | try Packet.write(.{ .data = "command=fetch\n" }, body_writer); |
| 981 | 981 | if (session.supports_agent) { |
| 982 | 982 | try Packet.write(.{ .data = agent_capability }, body_writer); |
src/Package/Manifest.zig+2-3| ... | ... | @@ -471,9 +471,8 @@ const Parse = struct { |
| 471 | 471 | offset: u32, |
| 472 | 472 | ) InnerError!void { |
| 473 | 473 | const raw_string = bytes[offset..]; |
| 474 | var aw: std.io.AllocatingWriter = undefined; | |
| 475 | const bw = aw.fromArrayList(p.gpa, buf); | |
| 476 | const result = std.zig.string_literal.parseWrite(bw, raw_string); | |
| 474 | var aw: std.io.Writer.Allocating = .fromArrayList(p.gpa, buf); | |
| 475 | const result = std.zig.string_literal.parseWrite(&aw.interface, raw_string); | |
| 477 | 476 | buf.* = aw.toArrayList(); |
| 478 | 477 | switch (result catch return error.OutOfMemory) { |
| 479 | 478 | .success => {}, |
src/Sema.zig+6-8| ... | ... | @@ -3028,10 +3028,9 @@ pub fn createTypeName( |
| 3028 | 3028 | const fn_info = sema.code.getFnInfo(ip.funcZirBodyInst(sema.func_index).resolve(ip) orelse return error.AnalysisFail); |
| 3029 | 3029 | const zir_tags = sema.code.instructions.items(.tag); |
| 3030 | 3030 | |
| 3031 | var aw: std.io.AllocatingWriter = undefined; | |
| 3032 | aw.init(gpa); | |
| 3031 | var aw: std.io.Writer.Allocating = .init(gpa); | |
| 3033 | 3032 | defer aw.deinit(); |
| 3034 | const bw = &aw.buffered_writer; | |
| 3033 | const bw = &aw.interface; | |
| 3035 | 3034 | bw.print("{f}(", .{block.type_name_ctx.fmt(ip)}) catch return error.OutOfMemory; |
| 3036 | 3035 | |
| 3037 | 3036 | var arg_i: usize = 0; |
| ... | ... | @@ -5911,9 +5910,9 @@ fn zirCompileLog( |
| 5911 | 5910 | const zcu = pt.zcu; |
| 5912 | 5911 | const gpa = zcu.gpa; |
| 5913 | 5912 | |
| 5914 | var aw: std.io.AllocatingWriter = undefined; | |
| 5913 | var aw: std.io.Writer.Allocating = .init(gpa); | |
| 5915 | 5914 | defer aw.deinit(); |
| 5916 | const bw = &aw.buffered_writer; | |
| 5915 | const bw = &aw.interface; | |
| 5917 | 5916 | |
| 5918 | 5917 | const extra = sema.code.extraData(Zir.Inst.NodeMultiOp, extended.operand); |
| 5919 | 5918 | const src_node = extra.data.src_node; |
| ... | ... | @@ -37369,13 +37368,12 @@ fn notePathToComptimeAllocPtr(sema: *Sema, msg: *Zcu.ErrorMsg, src: LazySrcLoc, |
| 37369 | 37368 | error.AnalysisFail => unreachable, |
| 37370 | 37369 | }; |
| 37371 | 37370 | |
| 37372 | var second_path_aw: std.io.AllocatingWriter = undefined; | |
| 37373 | second_path_aw.init(arena); | |
| 37371 | var second_path_aw: std.io.Writer.Allocating = .init(arena); | |
| 37374 | 37372 | defer second_path_aw.deinit(); |
| 37375 | 37373 | const inter_name = try std.fmt.allocPrint(arena, "v{d}", .{intermediate_value_count}); |
| 37376 | 37374 | const deriv_start = @import("print_value.zig").printPtrDerivation( |
| 37377 | 37375 | derivation, |
| 37378 | &second_path_aw.buffered_writer, | |
| 37376 | &second_path_aw.interface, | |
| 37379 | 37377 | pt, |
| 37380 | 37378 | .lvalue, |
| 37381 | 37379 | .{ .str = inter_name }, |
src/arch/aarch64/Emit.zig+2-2| ... | ... | @@ -452,8 +452,8 @@ fn dbgAdvancePCAndLine(emit: *Emit, line: u32, column: u32) InnerError!void { |
| 452 | 452 | .plan9 => |dbg_out| { |
| 453 | 453 | if (delta_pc <= 0) return; // only do this when the pc changes |
| 454 | 454 | |
| 455 | var aw: std.io.AllocatingWriter = undefined; | |
| 456 | const bw = aw.fromArrayList(emit.bin_file.comp.gpa, &dbg_out.dbg_line); | |
| 455 | var aw: std.io.Writer.Allocating = .fromArrayList(emit.bin_file.comp.gpa, &dbg_out.dbg_line); | |
| 456 | const bw = &aw.interface; | |
| 457 | 457 | defer dbg_out.dbg_line = aw.toArrayList(); |
| 458 | 458 | |
| 459 | 459 | // increasing the line number |
src/arch/arm/Emit.zig+2-2| ... | ... | @@ -368,8 +368,8 @@ fn dbgAdvancePCAndLine(self: *Emit, line: u32, column: u32) !void { |
| 368 | 368 | .plan9 => |dbg_out| { |
| 369 | 369 | if (delta_pc <= 0) return; // only do this when the pc changes |
| 370 | 370 | |
| 371 | var aw: std.io.AllocatingWriter = undefined; | |
| 372 | const bw = aw.fromArrayList(self.bin_file.comp.gpa, &dbg_out.dbg_line); | |
| 371 | var aw: std.io.Writer.Allocating = .fromArrayList(self.bin_file.comp.gpa, &dbg_out.dbg_line); | |
| 372 | const bw = &aw.interface; | |
| 373 | 373 | defer dbg_out.dbg_line = aw.toArrayList(); |
| 374 | 374 | |
| 375 | 375 | // increasing the line number |
src/arch/riscv64/Emit.zig+2-2| ... | ... | @@ -19,8 +19,8 @@ pub const Error = Lower.Error || error{ |
| 19 | 19 | |
| 20 | 20 | pub fn emitMir(emit: *Emit) Error!void { |
| 21 | 21 | const gpa = emit.bin_file.comp.gpa; |
| 22 | var aw: std.io.AllocatingWriter = undefined; | |
| 23 | const bw = aw.fromArrayList(gpa, emit.code); | |
| 22 | var aw: std.io.Writer.Allocating = .fromArrayList(gpa, emit.code); | |
| 23 | const bw = &aw.interface; | |
| 24 | 24 | defer emit.code.* = aw.toArrayList(); |
| 25 | 25 | |
| 26 | 26 | log.debug("mir instruction len: {}", .{emit.lower.mir.instructions.len}); |
src/arch/x86_64/Emit.zig+2-2| ... | ... | @@ -924,8 +924,8 @@ fn dbgAdvancePCAndLine(emit: *Emit, loc: Loc, pc: usize) Error!void { |
| 924 | 924 | .plan9 => |dbg_out| { |
| 925 | 925 | if (delta_pc <= 0) return; // only do this when the pc changes |
| 926 | 926 | |
| 927 | var aw: std.io.AllocatingWriter = undefined; | |
| 928 | const bw = aw.fromArrayList(emit.lower.bin_file.comp.gpa, &dbg_out.dbg_line); | |
| 927 | var aw: std.io.Writer.Allocating = .fromArrayList(emit.lower.bin_file.comp.gpa, &dbg_out.dbg_line); | |
| 928 | const bw = &aw.interface; | |
| 929 | 929 | defer dbg_out.dbg_line = aw.toArrayList(); |
| 930 | 930 | |
| 931 | 931 | // increasing the line number |
src/codegen.zig+2-3| ... | ... | @@ -314,10 +314,9 @@ pub fn generateSymbol( |
| 314 | 314 | const tracy = trace(@src()); |
| 315 | 315 | defer tracy.end(); |
| 316 | 316 | |
| 317 | var aw: std.io.AllocatingWriter = undefined; | |
| 318 | const bw = aw.fromArrayList(pt.zcu.gpa, code); | |
| 317 | var aw: std.io.Writer.Allocating = .fromArrayList(pt.zcu.gpa, code); | |
| 319 | 318 | defer code.* = aw.toArrayList(); |
| 320 | return generateSymbolInner(bin_file, pt, src_loc, val, bw, reloc_parent) catch |err| switch (err) { | |
| 319 | return generateSymbolInner(bin_file, pt, src_loc, val, &aw.interface, reloc_parent) catch |err| switch (err) { | |
| 321 | 320 | error.WriteFailed => return error.OutOfMemory, |
| 322 | 321 | else => |e| return e, |
| 323 | 322 | }; |
src/codegen/c.zig+3-3| ... | ... | @@ -694,8 +694,8 @@ pub const Function = struct { |
| 694 | 694 | /// It is not available when generating .h file. |
| 695 | 695 | pub const Object = struct { |
| 696 | 696 | dg: DeclGen, |
| 697 | code_header: std.io.AllocatingWriter, | |
| 698 | code: std.io.AllocatingWriter, | |
| 697 | code_header: std.io.Writer.Allocating, | |
| 698 | code: std.io.Writer.Allocating, | |
| 699 | 699 | indent_counter: usize, |
| 700 | 700 | |
| 701 | 701 | const indent_width = 1; |
| ... | ... | @@ -731,7 +731,7 @@ pub const DeclGen = struct { |
| 731 | 731 | pass: Pass, |
| 732 | 732 | is_naked_fn: bool, |
| 733 | 733 | expected_block: ?u32, |
| 734 | fwd_decl: std.io.AllocatingWriter, | |
| 734 | fwd_decl: std.io.Writer.Allocating, | |
| 735 | 735 | error_msg: ?*Zcu.ErrorMsg, |
| 736 | 736 | ctype_pool: CType.Pool, |
| 737 | 737 | scratch: std.ArrayListUnmanaged(u32), |
src/codegen/llvm.zig+11-8| ... | ... | @@ -747,13 +747,17 @@ pub const Object = struct { |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | fn genModuleLevelAssembly(object: *Object) Allocator.Error!void { |
| 750 | var aw: std.io.AllocatingWriter = undefined; | |
| 751 | const bw = object.builder.setModuleAsm(&aw); | |
| 752 | errdefer aw.deinit(); | |
| 750 | const b = &object.builder; | |
| 751 | const gpa = b.gpa; | |
| 752 | b.module_asm.clearRetainingCapacity(); | |
| 753 | 753 | for (object.pt.zcu.global_assembly.values()) |assembly| { |
| 754 | bw.print("{s}\n", .{assembly}) catch return error.OutOfMemory; | |
| 754 | try b.module_asm.ensureUnusedCapacity(gpa, assembly.len + 1); | |
| 755 | b.module_asm.appendSliceAssumeCapacity(assembly); | |
| 756 | b.module_asm.appendAssumeCapacity('\n'); | |
| 757 | } | |
| 758 | if (b.module_asm.getLastOrNull()) |last| { | |
| 759 | if (last != '\n') try b.module_asm.append(gpa, '\n'); | |
| 755 | 760 | } |
| 756 | try object.builder.finishModuleAsm(&aw); | |
| 757 | 761 | } |
| 758 | 762 | |
| 759 | 763 | pub const EmitOptions = struct { |
| ... | ... | @@ -2678,10 +2682,9 @@ pub const Object = struct { |
| 2678 | 2682 | } |
| 2679 | 2683 | |
| 2680 | 2684 | fn allocTypeName(o: *Object, ty: Type) Allocator.Error![:0]const u8 { |
| 2681 | var aw: std.io.AllocatingWriter = undefined; | |
| 2682 | aw.init(o.gpa); | |
| 2685 | var aw: std.io.Writer.Allocating = .init(o.gpa); | |
| 2683 | 2686 | defer aw.deinit(); |
| 2684 | ty.print(&aw.buffered_writer, o.pt) catch return error.OutOfMemory; | |
| 2687 | ty.print(&aw.interface, o.pt) catch return error.OutOfMemory; | |
| 2685 | 2688 | return aw.toOwnedSliceSentinel(0); |
| 2686 | 2689 | } |
| 2687 | 2690 |
src/codegen/spirv.zig+2-3| ... | ... | @@ -1260,10 +1260,9 @@ const NavGen = struct { |
| 1260 | 1260 | |
| 1261 | 1261 | // Turn a Zig type's name into a cache reference. |
| 1262 | 1262 | fn resolveTypeName(self: *NavGen, ty: Type) Allocator.Error![]const u8 { |
| 1263 | var aw: std.io.AllocatingWriter = undefined; | |
| 1264 | aw.init(self.gpa); | |
| 1263 | var aw: std.io.Writer.Allocating = .init(self.gpa); | |
| 1265 | 1264 | defer aw.deinit(); |
| 1266 | ty.print(&aw.buffered_writer, self.pt) catch return error.OutOfMemory; | |
| 1265 | ty.print(&aw.interface, self.pt) catch return error.OutOfMemory; | |
| 1267 | 1266 | return aw.toOwnedSlice(); |
| 1268 | 1267 | } |
| 1269 | 1268 |
src/fmt.zig+3-4| ... | ... | @@ -142,7 +142,7 @@ pub fn run(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { |
| 142 | 142 | try std.zig.printAstErrorsToStderr(gpa, tree, "<stdin>", color); |
| 143 | 143 | process.exit(2); |
| 144 | 144 | } |
| 145 | var aw: std.io.AllocatingWriter = .init(gpa); | |
| 145 | var aw: std.io.Writer.Allocating = .init(gpa); | |
| 146 | 146 | defer aw.deinit(); |
| 147 | 147 | try tree.render(gpa, &aw.interface, .{}); |
| 148 | 148 | const formatted = aw.getWritten(); |
| ... | ... | @@ -336,10 +336,9 @@ fn fmtPathFile( |
| 336 | 336 | try fmt.out_buffer.ensureTotalCapacity(gpa, source_code.len); |
| 337 | 337 | |
| 338 | 338 | { |
| 339 | var aw: std.io.AllocatingWriter = undefined; | |
| 340 | const bw = aw.fromArrayList(gpa, &fmt.out_buffer); | |
| 339 | var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &fmt.out_buffer); | |
| 341 | 340 | defer fmt.out_buffer = aw.toArrayList(); |
| 342 | try tree.render(gpa, bw, .{}); | |
| 341 | try tree.render(gpa, &aw.interface, .{}); | |
| 343 | 342 | } |
| 344 | 343 | if (mem.eql(u8, fmt.out_buffer.items, source_code)) |
| 345 | 344 | return; |
src/libs/mingw.zig+5-6| ... | ... | @@ -400,8 +400,7 @@ fn findDef( |
| 400 | 400 | else => unreachable, |
| 401 | 401 | }; |
| 402 | 402 | |
| 403 | var override_path: std.io.AllocatingWriter = undefined; | |
| 404 | override_path.init(gpa); | |
| 403 | var override_path: std.io.Writer.Allocating = .init(gpa); | |
| 405 | 404 | defer override_path.deinit(); |
| 406 | 405 | |
| 407 | 406 | const s = path.sep_str; |
| ... | ... | @@ -410,9 +409,9 @@ fn findDef( |
| 410 | 409 | // Try the archtecture-specific path first. |
| 411 | 410 | const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "{s}" ++ s ++ "{s}.def"; |
| 412 | 411 | if (zig_lib_directory.path) |p| { |
| 413 | try override_path.buffered_writer.print("{s}" ++ s ++ fmt_path, .{ p, lib_path, lib_name }); | |
| 412 | try override_path.interface.print("{s}" ++ s ++ fmt_path, .{ p, lib_path, lib_name }); | |
| 414 | 413 | } else { |
| 415 | try override_path.buffered_writer.print(fmt_path, .{ lib_path, lib_name }); | |
| 414 | try override_path.interface.print(fmt_path, .{ lib_path, lib_name }); | |
| 416 | 415 | } |
| 417 | 416 | if (std.fs.cwd().access(override_path.getWritten(), .{})) |_| { |
| 418 | 417 | return override_path.toOwnedSlice(); |
| ... | ... | @@ -444,9 +443,9 @@ fn findDef( |
| 444 | 443 | override_path.clearRetainingCapacity(); |
| 445 | 444 | const fmt_path = "libc" ++ s ++ "mingw" ++ s ++ "lib-common" ++ s ++ "{s}.def.in"; |
| 446 | 445 | if (zig_lib_directory.path) |p| { |
| 447 | try override_path.buffered_writer.print("{s}" ++ s ++ fmt_path, .{ p, lib_name }); | |
| 446 | try override_path.interface.print("{s}" ++ s ++ fmt_path, .{ p, lib_name }); | |
| 448 | 447 | } else { |
| 449 | try override_path.buffered_writer.print(fmt_path, .{lib_name}); | |
| 448 | try override_path.interface.print(fmt_path, .{lib_name}); | |
| 450 | 449 | } |
| 451 | 450 | if (std.fs.cwd().access(override_path.getWritten(), .{})) |_| { |
| 452 | 451 | return override_path.toOwnedSlice(); |
src/libs/musl.zig+4-5| ... | ... | @@ -115,8 +115,7 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro |
| 115 | 115 | var c_source_files = std.ArrayList(Compilation.CSourceFile).init(comp.gpa); |
| 116 | 116 | defer c_source_files.deinit(); |
| 117 | 117 | |
| 118 | var override_path: std.io.AllocatingWriter = undefined; | |
| 119 | override_path.init(comp.gpa); | |
| 118 | var override_path: std.io.Writer.Allocating = .init(comp.gpa); | |
| 120 | 119 | defer override_path.deinit(); |
| 121 | 120 | |
| 122 | 121 | const s = path.sep_str; |
| ... | ... | @@ -141,19 +140,19 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro |
| 141 | 140 | if (!is_arch_specific) { |
| 142 | 141 | // Look for an arch specific override. |
| 143 | 142 | override_path.clearRetainingCapacity(); |
| 144 | try override_path.buffered_writer.print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.s", .{ | |
| 143 | try override_path.interface.print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.s", .{ | |
| 145 | 144 | dirname, arch_name, noextbasename, |
| 146 | 145 | }); |
| 147 | 146 | if (source_table.contains(override_path.getWritten())) continue; |
| 148 | 147 | |
| 149 | 148 | override_path.clearRetainingCapacity(); |
| 150 | try override_path.buffered_writer.print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.S", .{ | |
| 149 | try override_path.interface.print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.S", .{ | |
| 151 | 150 | dirname, arch_name, noextbasename, |
| 152 | 151 | }); |
| 153 | 152 | if (source_table.contains(override_path.getWritten())) continue; |
| 154 | 153 | |
| 155 | 154 | override_path.clearRetainingCapacity(); |
| 156 | try override_path.buffered_writer.print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.c", .{ | |
| 155 | try override_path.interface.print("{s}" ++ s ++ "{s}" ++ s ++ "{s}.c", .{ | |
| 157 | 156 | dirname, arch_name, noextbasename, |
| 158 | 157 | }); |
| 159 | 158 | if (source_table.contains(override_path.getWritten())) continue; |
src/link/Dwarf.zig+6-7| ... | ... | @@ -1446,10 +1446,10 @@ pub const WipNav = struct { |
| 1446 | 1446 | loc: u32, |
| 1447 | 1447 | cfa: Cfa.RegOff, |
| 1448 | 1448 | }, |
| 1449 | debug_frame: std.io.AllocatingWriter, | |
| 1450 | debug_info: std.io.AllocatingWriter, | |
| 1451 | debug_line: std.io.AllocatingWriter, | |
| 1452 | debug_loclists: std.io.AllocatingWriter, | |
| 1449 | debug_frame: std.io.Writer.Allocating, | |
| 1450 | debug_info: std.io.Writer.Allocating, | |
| 1451 | debug_line: std.io.Writer.Allocating, | |
| 1452 | debug_loclists: std.io.Writer.Allocating, | |
| 1453 | 1453 | pending_lazy: PendingLazy, |
| 1454 | 1454 | |
| 1455 | 1455 | pub fn init(wip_nav: *WipNav) void { |
| ... | ... | @@ -4494,10 +4494,9 @@ fn refAbbrevCode(dwarf: *Dwarf, abbrev_code: AbbrevCode) UpdateError!@typeInfo(A |
| 4494 | 4494 | assert(abbrev_code != .null); |
| 4495 | 4495 | const entry: Entry.Index = @enumFromInt(@intFromEnum(abbrev_code)); |
| 4496 | 4496 | if (dwarf.debug_abbrev.section.getUnit(DebugAbbrev.unit).getEntry(entry).len > 0) return @intFromEnum(abbrev_code); |
| 4497 | var daaw: std.io.AllocatingWriter = undefined; | |
| 4498 | daaw.init(dwarf.gpa); | |
| 4497 | var daaw: std.io.Writer.Allocating = .init(dwarf.gpa); | |
| 4499 | 4498 | defer daaw.deinit(); |
| 4500 | const dabw = &daaw.buffered_writer; | |
| 4499 | const dabw = &daaw.interface; | |
| 4501 | 4500 | const abbrev = AbbrevCode.abbrevs.get(abbrev_code); |
| 4502 | 4501 | try dabw.writeLeb128(@intFromEnum(abbrev_code)); |
| 4503 | 4502 | try dabw.writeLeb128(@intFromEnum(abbrev.tag)); |
src/link/MachO/CodeSignature.zig+4-6| ... | ... | @@ -304,11 +304,10 @@ pub fn writeAdhocSignature( |
| 304 | 304 | var hash: [hash_size]u8 = undefined; |
| 305 | 305 | |
| 306 | 306 | if (self.requirements) |*req| { |
| 307 | var aw: std.io.AllocatingWriter = undefined; | |
| 308 | aw.init(allocator); | |
| 307 | var aw: std.io.Writer.Allocating = .init(allocator); | |
| 309 | 308 | defer aw.deinit(); |
| 310 | 309 | |
| 311 | try req.write(&aw.buffered_writer); | |
| 310 | try req.write(&aw.interface); | |
| 312 | 311 | Sha256.hash(aw.getWritten(), &hash, .{}); |
| 313 | 312 | self.code_directory.addSpecialHash(req.slotType(), hash); |
| 314 | 313 | |
| ... | ... | @@ -318,11 +317,10 @@ pub fn writeAdhocSignature( |
| 318 | 317 | } |
| 319 | 318 | |
| 320 | 319 | if (self.entitlements) |*ents| { |
| 321 | var aw: std.io.AllocatingWriter = undefined; | |
| 322 | aw.init(allocator); | |
| 320 | var aw: std.io.Writer.Allocating = .init(allocator); | |
| 323 | 321 | defer aw.deinit(); |
| 324 | 322 | |
| 325 | try ents.write(&aw.buffered_writer); | |
| 323 | try ents.write(&aw.interface); | |
| 326 | 324 | Sha256.hash(aw.getWritten(), &hash, .{}); |
| 327 | 325 | self.code_directory.addSpecialHash(ents.slotType(), hash); |
| 328 | 326 |
src/link/MachO/dyld_info/Rebase.zig+2-2| ... | ... | @@ -110,8 +110,8 @@ pub fn updateSize(rebase: *Rebase, macho_file: *MachO) !void { |
| 110 | 110 | fn finalize(rebase: *Rebase, gpa: Allocator) !void { |
| 111 | 111 | if (rebase.entries.items.len == 0) return; |
| 112 | 112 | |
| 113 | var aw: std.io.AllocatingWriter = undefined; | |
| 114 | const bw = aw.fromArrayList(gpa, &rebase.buffer); | |
| 113 | var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &rebase.buffer); | |
| 114 | const bw = &aw.interface; | |
| 115 | 115 | defer rebase.buffer = aw.toArrayList(); |
| 116 | 116 | |
| 117 | 117 | log.debug("rebase opcodes", .{}); |
src/link/MachO/dyld_info/bind.zig+6-6| ... | ... | @@ -118,8 +118,8 @@ pub const Bind = struct { |
| 118 | 118 | fn finalize(bind: *Bind, gpa: Allocator, ctx: *MachO) !void { |
| 119 | 119 | if (bind.entries.items.len == 0) return; |
| 120 | 120 | |
| 121 | var aw: std.io.AllocatingWriter = undefined; | |
| 122 | const bw = aw.fromArrayList(gpa, &bind.buffer); | |
| 121 | var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &bind.buffer); | |
| 122 | const bw = &aw.interface; | |
| 123 | 123 | defer bind.buffer = aw.toArrayList(); |
| 124 | 124 | |
| 125 | 125 | log.debug("bind opcodes", .{}); |
| ... | ... | @@ -359,8 +359,8 @@ pub const WeakBind = struct { |
| 359 | 359 | fn finalize(bind: *WeakBind, gpa: Allocator, ctx: *MachO) !void { |
| 360 | 360 | if (bind.entries.items.len == 0) return; |
| 361 | 361 | |
| 362 | var aw: std.io.AllocatingWriter = undefined; | |
| 363 | const bw = aw.fromArrayList(gpa, &bind.buffer); | |
| 362 | var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &bind.buffer); | |
| 363 | const bw = &aw.interface; | |
| 364 | 364 | defer bind.buffer = aw.toArrayList(); |
| 365 | 365 | |
| 366 | 366 | log.debug("weak bind opcodes", .{}); |
| ... | ... | @@ -526,8 +526,8 @@ pub const LazyBind = struct { |
| 526 | 526 | fn finalize(bind: *LazyBind, gpa: Allocator, ctx: *MachO) !void { |
| 527 | 527 | try bind.offsets.ensureTotalCapacityPrecise(gpa, bind.entries.items.len); |
| 528 | 528 | |
| 529 | var aw: std.io.AllocatingWriter = undefined; | |
| 530 | const bw = aw.fromArrayList(gpa, &bind.buffer); | |
| 529 | var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &bind.buffer); | |
| 530 | const bw = &aw.interface; | |
| 531 | 531 | defer bind.buffer = aw.toArrayList(); |
| 532 | 532 | |
| 533 | 533 | log.debug("lazy bind opcodes", .{}); |
src/link/Plan9.zig+5-7| ... | ... | @@ -337,7 +337,7 @@ fn putFn(self: *Plan9, nav_index: InternPool.Nav.Index, out: FnNavOutput) !void |
| 337 | 337 | }; |
| 338 | 338 | try fn_map_res.value_ptr.functions.put(gpa, nav_index, out); |
| 339 | 339 | |
| 340 | var aw: std.io.AllocatingWriter = .init(arena); | |
| 340 | var aw: std.io.Writer.Allocating = .init(arena); | |
| 341 | 341 | defer aw.deinit(); |
| 342 | 342 | const w = &aw.interface; |
| 343 | 343 | |
| ... | ... | @@ -646,12 +646,11 @@ pub fn flush( |
| 646 | 646 | var iovecs_i: usize = 1; |
| 647 | 647 | var text_i: u64 = 0; |
| 648 | 648 | |
| 649 | var linecountinfo_aw: std.io.AllocatingWriter = undefined; | |
| 650 | linecountinfo_aw.init(gpa); | |
| 649 | var linecountinfo_aw: std.io.Writer.Allocating = .init(gpa); | |
| 651 | 650 | defer linecountinfo_aw.deinit(); |
| 652 | 651 | // text |
| 653 | 652 | { |
| 654 | const linecountinfo_bw = &linecountinfo_aw.buffered_writer; | |
| 653 | const linecountinfo_bw = &linecountinfo_aw.interface; | |
| 655 | 654 | var linecount: i64 = -1; |
| 656 | 655 | var it_file = self.fn_nav_table.iterator(); |
| 657 | 656 | while (it_file.next()) |fentry| { |
| ... | ... | @@ -819,10 +818,9 @@ pub fn flush( |
| 819 | 818 | } |
| 820 | 819 | } |
| 821 | 820 | } |
| 822 | var syms_aw: std.io.AllocatingWriter = undefined; | |
| 823 | syms_aw.init(gpa); | |
| 821 | var syms_aw: std.io.Writer.Allocating = .init(gpa); | |
| 824 | 822 | defer syms_aw.deinit(); |
| 825 | try self.writeSyms(&syms_aw.buffered_writer); | |
| 823 | try self.writeSyms(&syms_aw.interface); | |
| 826 | 824 | const syms = syms_aw.getWritten(); |
| 827 | 825 | assert(2 + self.atomCount() - self.externCount() == iovecs_i); // we didn't write all the decls |
| 828 | 826 | iovecs[iovecs_i] = .{ .base = syms.ptr, .len = syms.len }; |
src/link/SpirV.zig+4-5| ... | ... | @@ -203,11 +203,10 @@ pub fn flush( |
| 203 | 203 | // We need to export the list of error names somewhere so that we can pretty-print them in the |
| 204 | 204 | // executor. This is not really an important thing though, so we can just dump it in any old |
| 205 | 205 | // nonsemantic instruction. For now, just put it in OpSourceExtension with a special name. |
| 206 | var error_info: std.io.AllocatingWriter = undefined; | |
| 207 | error_info.init(self.object.gpa); | |
| 206 | var error_info: std.io.Writer.Allocating = .init(self.object.gpa); | |
| 208 | 207 | defer error_info.deinit(); |
| 209 | 208 | |
| 210 | try error_info.buffered_writer.writeAll("zig_errors:"); | |
| 209 | try error_info.interface.writeAll("zig_errors:"); | |
| 211 | 210 | const ip = &self.base.comp.zcu.?.intern_pool; |
| 212 | 211 | for (ip.global_error_set.getNamesFromMainThread()) |name| { |
| 213 | 212 | // Errors can contain pretty much any character - to encode them in a string we must escape |
| ... | ... | @@ -215,9 +214,9 @@ pub fn flush( |
| 215 | 214 | // name if it contains no strange characters is nice for debugging. URI encoding fits the bill. |
| 216 | 215 | // We're using : as separator, which is a reserved character. |
| 217 | 216 | |
| 218 | try error_info.buffered_writer.writeByte(':'); | |
| 217 | try error_info.interface.writeByte(':'); | |
| 219 | 218 | try std.Uri.Component.percentEncode( |
| 220 | &error_info.buffered_writer, | |
| 219 | &error_info.interface, | |
| 221 | 220 | name.toSlice(ip), |
| 222 | 221 | struct { |
| 223 | 222 | fn isValidChar(c: u8) bool { |
src/link/Wasm/Flush.zig+9-9| ... | ... | @@ -558,7 +558,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { |
| 558 | 558 | var data_section_index: ?u32 = null; |
| 559 | 559 | |
| 560 | 560 | assert(f.binary_bytes.items.len == 0); |
| 561 | var aw: std.io.AllocatingWriter = .fromArrayList(gpa, &f.binary_bytes); | |
| 561 | var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &f.binary_bytes); | |
| 562 | 562 | defer f.binary_bytes = aw.toArrayList(); |
| 563 | 563 | const w = &aw.interface; |
| 564 | 564 | |
| ... | ... | @@ -1064,7 +1064,7 @@ const VirtualAddrs = struct { |
| 1064 | 1064 | |
| 1065 | 1065 | fn emitNameSection( |
| 1066 | 1066 | wasm: *Wasm, |
| 1067 | aw: *std.io.AllocatingWriter, | |
| 1067 | aw: *std.io.Writer.Allocating, | |
| 1068 | 1068 | data_segment_groups: []const DataSegmentGroup, |
| 1069 | 1069 | ) !void { |
| 1070 | 1070 | const f = &wasm.flush_buffer; |
| ... | ... | @@ -1128,7 +1128,7 @@ fn emitNameSection( |
| 1128 | 1128 | } |
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | fn emitFeaturesSection(aw: *std.io.AllocatingWriter, target: *const std.Target) Allocator.Error!void { | |
| 1131 | fn emitFeaturesSection(aw: *std.io.Writer.Allocating, target: *const std.Target) Allocator.Error!void { | |
| 1132 | 1132 | const feature_count = target.cpu.features.count(); |
| 1133 | 1133 | if (feature_count == 0) return; |
| 1134 | 1134 | |
| ... | ... | @@ -1155,7 +1155,7 @@ fn emitFeaturesSection(aw: *std.io.AllocatingWriter, target: *const std.Target) |
| 1155 | 1155 | assert(safety_count == 0); |
| 1156 | 1156 | } |
| 1157 | 1157 | |
| 1158 | fn emitBuildIdSection(aw: *std.io.AllocatingWriter, build_id: []const u8) !void { | |
| 1158 | fn emitBuildIdSection(aw: *std.io.Writer.Allocating, build_id: []const u8) !void { | |
| 1159 | 1159 | const w = &aw.interface; |
| 1160 | 1160 | const header_offset = try reserveSectionHeader(w); |
| 1161 | 1161 | defer replaceSectionHeader(aw, header_offset, @intFromEnum(std.wasm.Section.custom)); |
| ... | ... | @@ -1169,7 +1169,7 @@ fn emitBuildIdSection(aw: *std.io.AllocatingWriter, build_id: []const u8) !void |
| 1169 | 1169 | try w.writeAll(build_id); |
| 1170 | 1170 | } |
| 1171 | 1171 | |
| 1172 | fn emitProducerSection(aw: *std.io.AllocatingWriter) !void { | |
| 1172 | fn emitProducerSection(aw: *std.io.Writer.Allocating) !void { | |
| 1173 | 1173 | const w = &aw.interface; |
| 1174 | 1174 | const header_offset = try reserveSectionHeader(w); |
| 1175 | 1175 | defer replaceSectionHeader(aw, header_offset, @intFromEnum(std.wasm.Section.custom)); |
| ... | ... | @@ -1259,7 +1259,7 @@ fn reserveVecSectionHeader(w: *Writer) Writer.Error!u32 { |
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | 1261 | fn replaceVecSectionHeader( |
| 1262 | aw: *std.io.AllocatingWriter, | |
| 1262 | aw: *std.io.Writer.Allocating, | |
| 1263 | 1263 | offset: u32, |
| 1264 | 1264 | section: std.wasm.Section, |
| 1265 | 1265 | n_items: u32, |
| ... | ... | @@ -1278,7 +1278,7 @@ fn reserveSectionHeader(w: *Writer) Writer.Error!u32 { |
| 1278 | 1278 | return @intCast(offset); |
| 1279 | 1279 | } |
| 1280 | 1280 | |
| 1281 | fn replaceSectionHeader(aw: *std.io.AllocatingWriter, offset: u32, section: u8) void { | |
| 1281 | fn replaceSectionHeader(aw: *std.io.Writer.Allocating, offset: u32, section: u8) void { | |
| 1282 | 1282 | const header = aw.getWritten()[offset..][0..section_header_size]; |
| 1283 | 1283 | header[0] = section; |
| 1284 | 1284 | std.leb.writeUnsignedFixed(5, header[1..6], @intCast(aw.interface.count - offset - section_header_size)); |
| ... | ... | @@ -1292,7 +1292,7 @@ fn reserveSizeHeader(w: *Writer) Writer.Error!u32 { |
| 1292 | 1292 | return @intCast(offset); |
| 1293 | 1293 | } |
| 1294 | 1294 | |
| 1295 | fn replaceSizeHeader(aw: *std.io.AllocatingWriter, offset: u32) void { | |
| 1295 | fn replaceSizeHeader(aw: *std.io.Writer.Allocating, offset: u32) void { | |
| 1296 | 1296 | const header = aw.getWritten()[offset..][0..size_header_size]; |
| 1297 | 1297 | std.leb.writeUnsignedFixed(5, header[0..5], @intCast(aw.interface.count - offset - size_header_size)); |
| 1298 | 1298 | } |
| ... | ... | @@ -1764,7 +1764,7 @@ fn emitInitTlsFunction(wasm: *const Wasm, w: *Writer) Writer.Error!void { |
| 1764 | 1764 | try w.writeByte(@intFromEnum(std.wasm.Opcode.end)); |
| 1765 | 1765 | } |
| 1766 | 1766 | |
| 1767 | fn emitStartSection(aw: *std.io.AllocatingWriter, i: Wasm.OutputFunctionIndex) !void { | |
| 1767 | fn emitStartSection(aw: *std.io.Writer.Allocating, i: Wasm.OutputFunctionIndex) !void { | |
| 1768 | 1768 | const header_offset = try reserveVecSectionHeader(&aw.interface); |
| 1769 | 1769 | defer replaceVecSectionHeader(aw, header_offset, .start, @intFromEnum(i)); |
| 1770 | 1770 | } |