| ... | @@ -1,5 +1,16 @@ | ... | @@ -1,5 +1,16 @@ |
| 1 | //! Ingests an `Ast` and produces a `Zoir`. | 1 | //! Ingests an `Ast` and produces a `Zoir`. |
| 2 | | 2 | |
| | 3 | const std = @import("std"); |
| | 4 | const assert = std.debug.assert; |
| | 5 | const mem = std.mem; |
| | 6 | const Allocator = mem.Allocator; |
| | 7 | const StringIndexAdapter = std.hash_map.StringIndexAdapter; |
| | 8 | const StringIndexContext = std.hash_map.StringIndexContext; |
| | 9 | const ZonGen = @This(); |
| | 10 | const Zoir = @import("Zoir.zig"); |
| | 11 | const Ast = @import("Ast.zig"); |
| | 12 | const Writer = std.io.Writer; |
| | 13 | |
| 3 | gpa: Allocator, | 14 | gpa: Allocator, |
| 4 | tree: Ast, | 15 | tree: Ast, |
| 5 | | 16 | |
| ... | @@ -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 { |
| 876 | | 887 | |
| 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; |
| 880 | | 891 | |
| 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 | | | |
| 912 | const std = @import("std"); | | |
| 913 | const assert = std.debug.assert; | | |
| 914 | const mem = std.mem; | | |
| 915 | const Allocator = mem.Allocator; | | |
| 916 | const StringIndexAdapter = std.hash_map.StringIndexAdapter; | | |
| 917 | const StringIndexContext = std.hash_map.StringIndexContext; | | |
| 918 | const ZonGen = @This(); | | |
| 919 | const Zoir = @import("Zoir.zig"); | | |
| 920 | const Ast = @import("Ast.zig"); | | |
| 921 | const Writer = std.io.Writer; | | |