authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-15 22:07:37-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-15 22:07:37-07:00
log09c954a663ffee83b7aac2a22a56e3e4effc8360
tree68fd8f832228be9d6b10c2202f52059726f2fe64
parentcea82a4b94d3eec6e204df0f4bcb82a1446b24ec

sync


2 files changed, 15 insertions(+), 15 deletions(-)

lib/std/zig/ZonGen.zig+14-14
...@@ -1,5 +1,16 @@...@@ -1,5 +1,16 @@
1//! Ingests an `Ast` and produces a `Zoir`.1//! Ingests an `Ast` and produces a `Zoir`.
22
3const std = @import("std");
4const assert = std.debug.assert;
5const mem = std.mem;
6const Allocator = mem.Allocator;
7const StringIndexAdapter = std.hash_map.StringIndexAdapter;
8const StringIndexContext = std.hash_map.StringIndexContext;
9const ZonGen = @This();
10const Zoir = @import("Zoir.zig");
11const Ast = @import("Ast.zig");
12const Writer = std.io.Writer;
13
3gpa: Allocator,14gpa: Allocator,
4tree: Ast,15tree: Ast,
516
...@@ -463,7 +474,7 @@ fn appendIdentStr(zg: *ZonGen, ident_token: Ast.TokenIndex) error{ OutOfMemory,...@@ -463,7 +474,7 @@ fn appendIdentStr(zg: *ZonGen, ident_token: Ast.TokenIndex) error{ OutOfMemory,
463 const result = r: {474 const result = r: {
464 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &zg.string_bytes);475 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &zg.string_bytes);
465 defer zg.string_bytes = aw.toArrayList();476 defer zg.string_bytes = aw.toArrayList();
466 break :r std.zig.string_literal.parseWrite(&aw.interface, raw_string) catch |err| switch (err) {477 break :r std.zig.string_literal.parseWrite(&aw.writer, raw_string) catch |err| switch (err) {
467 error.WriteFailed => return error.OutOfMemory,478 error.WriteFailed => return error.OutOfMemory,
468 };479 };
469 };480 };
...@@ -561,7 +572,7 @@ fn strLitAsString(zg: *ZonGen, str_node: Ast.Node.Index) error{ OutOfMemory, Bad...@@ -561,7 +572,7 @@ fn strLitAsString(zg: *ZonGen, str_node: Ast.Node.Index) error{ OutOfMemory, Bad
561 const result = r: {572 const result = r: {
562 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &zg.string_bytes);573 var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &zg.string_bytes);
563 defer zg.string_bytes = aw.toArrayList();574 defer zg.string_bytes = aw.toArrayList();
564 break :r parseStrLit(zg.tree, str_node, &aw.interface) catch |err| switch (err) {575 break :r parseStrLit(zg.tree, str_node, &aw.writer) catch |err| switch (err) {
565 error.WriteFailed => return error.OutOfMemory,576 error.WriteFailed => return error.OutOfMemory,
566 };577 };
567 };578 };
...@@ -876,7 +887,7 @@ fn lowerAstErrors(zg: *ZonGen) Allocator.Error!void {...@@ -876,7 +887,7 @@ fn lowerAstErrors(zg: *ZonGen) Allocator.Error!void {
876887
877 var msg: std.io.Writer.Allocating = .init(gpa);888 var msg: std.io.Writer.Allocating = .init(gpa);
878 defer msg.deinit();889 defer msg.deinit();
879 const msg_bw = &msg.interface;890 const msg_bw = &msg.writer;
880891
881 var notes: std.ArrayListUnmanaged(Zoir.CompileError.Note) = .empty;892 var notes: std.ArrayListUnmanaged(Zoir.CompileError.Note) = .empty;
882 defer notes.deinit(gpa);893 defer notes.deinit(gpa);
...@@ -908,14 +919,3 @@ fn lowerAstErrors(zg: *ZonGen) Allocator.Error!void {...@@ -908,14 +919,3 @@ fn lowerAstErrors(zg: *ZonGen) Allocator.Error!void {
908 tree.renderError(cur_err, msg_bw) catch return error.OutOfMemory;919 tree.renderError(cur_err, msg_bw) catch return error.OutOfMemory;
909 try zg.addErrorTokNotesOff(cur_err.token, extra_offset, "{s}", .{msg.getWritten()}, notes.items);920 try zg.addErrorTokNotesOff(cur_err.token, extra_offset, "{s}", .{msg.getWritten()}, notes.items);
910}921}
911
912const std = @import("std");
913const assert = std.debug.assert;
914const mem = std.mem;
915const Allocator = mem.Allocator;
916const StringIndexAdapter = std.hash_map.StringIndexAdapter;
917const StringIndexContext = std.hash_map.StringIndexContext;
918const ZonGen = @This();
919const Zoir = @import("Zoir.zig");
920const Ast = @import("Ast.zig");
921const Writer = std.io.Writer;
lib/std/zig/string_literal.zig+1-1
...@@ -360,7 +360,7 @@ pub fn parseWrite(writer: *Writer, bytes: []const u8) Writer.Error!Result {...@@ -360,7 +360,7 @@ pub fn parseWrite(writer: *Writer, bytes: []const u8) Writer.Error!Result {
360pub fn parseAlloc(allocator: std.mem.Allocator, bytes: []const u8) ParseError![]u8 {360pub fn parseAlloc(allocator: std.mem.Allocator, bytes: []const u8) ParseError![]u8 {
361 var aw: std.io.Writer.Allocating = .init(allocator);361 var aw: std.io.Writer.Allocating = .init(allocator);
362 defer aw.deinit();362 defer aw.deinit();
363 const result = parseWrite(&aw.interface, bytes) catch |err| switch (err) {363 const result = parseWrite(&aw.writer, bytes) catch |err| switch (err) {
364 error.WriteFailed => return error.OutOfMemory,364 error.WriteFailed => return error.OutOfMemory,
365 };365 };
366 switch (result) {366 switch (result) {