| ... | ... | @@ -1,5 +1,16 @@ |
| 1 | 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 | 14 | gpa: Allocator, |
| 4 | 15 | tree: Ast, |
| 5 | 16 | |
| ... | ... | @@ -463,7 +474,7 @@ fn appendIdentStr(zg: *ZonGen, ident_token: Ast.TokenIndex) error{ OutOfMemory, |
| 463 | 474 | const result = r: { |
| 464 | 475 | var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &zg.string_bytes); |
| 465 | 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 | 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 | 572 | const result = r: { |
| 562 | 573 | var aw: std.io.Writer.Allocating = .fromArrayList(gpa, &zg.string_bytes); |
| 563 | 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 | 576 | error.WriteFailed => return error.OutOfMemory, |
| 566 | 577 | }; |
| 567 | 578 | }; |
| ... | ... | @@ -876,7 +887,7 @@ fn lowerAstErrors(zg: *ZonGen) Allocator.Error!void { |
| 876 | 887 | |
| 877 | 888 | var msg: std.io.Writer.Allocating = .init(gpa); |
| 878 | 889 | defer msg.deinit(); |
| 879 | | const msg_bw = &msg.interface; |
| 890 | const msg_bw = &msg.writer; |
| 880 | 891 | |
| 881 | 892 | var notes: std.ArrayListUnmanaged(Zoir.CompileError.Note) = .empty; |
| 882 | 893 | defer notes.deinit(gpa); |
| ... | ... | @@ -908,14 +919,3 @@ fn lowerAstErrors(zg: *ZonGen) Allocator.Error!void { |
| 908 | 919 | tree.renderError(cur_err, msg_bw) catch return error.OutOfMemory; |
| 909 | 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; |