authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-02-23 13:24:54+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-03-10 10:26:13+00:00
log82be338964ed5bbc596a48075e52724fdf92cde4
tree9536f08d24c56911d5a304b2d8e89930c841d659
parent2651b5ccdf2485172e9ba0345b9529733ee39273
signaturelock-open Commit is signed but in an unrecognized format.

aro: stop depending on ArrayList default field values


3 files changed, 19 insertions(+), 13 deletions(-)

lib/compiler/aro/aro/InitList.zig+13-7
...@@ -22,9 +22,15 @@ const Item = struct {...@@ -22,9 +22,15 @@ const Item = struct {
2222
23const InitList = @This();23const InitList = @This();
2424
25list: std.ArrayList(Item) = .empty,25list: std.ArrayList(Item),
26node: Node.OptIndex = .null,26node: Node.OptIndex,
27tok: TokenIndex = 0,27tok: TokenIndex,
28
29pub const empty: InitList = .{
30 .list = .empty,
31 .node = .null,
32 .tok = 0,
33};
2834
29/// Deinitialize freeing all memory.35/// Deinitialize freeing all memory.
30pub fn deinit(il: *InitList, gpa: Allocator) void {36pub fn deinit(il: *InitList, gpa: Allocator) void {
...@@ -43,7 +49,7 @@ pub fn find(il: *InitList, gpa: Allocator, index: u64) !*InitList {...@@ -43,7 +49,7 @@ pub fn find(il: *InitList, gpa: Allocator, index: u64) !*InitList {
43 if (il.list.items.len == 0) {49 if (il.list.items.len == 0) {
44 const item = try il.list.addOne(gpa);50 const item = try il.list.addOne(gpa);
45 item.* = .{51 item.* = .{
46 .list = .{},52 .list = .empty,
47 .index = index,53 .index = index,
48 };54 };
49 return &item.list;55 return &item.list;
...@@ -51,7 +57,7 @@ pub fn find(il: *InitList, gpa: Allocator, index: u64) !*InitList {...@@ -51,7 +57,7 @@ pub fn find(il: *InitList, gpa: Allocator, index: u64) !*InitList {
51 // Append a new value to the end of the list.57 // Append a new value to the end of the list.
52 const new = try il.list.addOne(gpa);58 const new = try il.list.addOne(gpa);
53 new.* = .{59 new.* = .{
54 .list = .{},60 .list = .empty,
55 .index = index,61 .index = index,
56 };62 };
57 return &new.list;63 return &new.list;
...@@ -70,7 +76,7 @@ pub fn find(il: *InitList, gpa: Allocator, index: u64) !*InitList {...@@ -70,7 +76,7 @@ pub fn find(il: *InitList, gpa: Allocator, index: u64) !*InitList {
7076
71 // Insert a new value into a sorted position.77 // Insert a new value into a sorted position.
72 try il.list.insert(gpa, left, .{78 try il.list.insert(gpa, left, .{
73 .list = .{},79 .list = .empty,
74 .index = index,80 .index = index,
75 });81 });
76 return &il.list.items[left].list;82 return &il.list.items[left].list;
...@@ -78,7 +84,7 @@ pub fn find(il: *InitList, gpa: Allocator, index: u64) !*InitList {...@@ -78,7 +84,7 @@ pub fn find(il: *InitList, gpa: Allocator, index: u64) !*InitList {
7884
79test "basic usage" {85test "basic usage" {
80 const gpa = testing.allocator;86 const gpa = testing.allocator;
81 var il: InitList = .{};87 var il: InitList = .empty;
82 defer il.deinit(gpa);88 defer il.deinit(gpa);
8389
84 {90 {
lib/compiler/aro/aro/Parser.zig+3-3
...@@ -3977,7 +3977,7 @@ fn initializer(p: *Parser, init_qt: QualType) Error!Result {...@@ -3977,7 +3977,7 @@ fn initializer(p: *Parser, init_qt: QualType) Error!Result {
3977 final_init_qt = .invalid;3977 final_init_qt = .invalid;
3978 }3978 }
39793979
3980 var il: InitList = .{};3980 var il: InitList = .empty;
3981 defer il.deinit(p.comp.gpa);3981 defer il.deinit(p.comp.gpa);
39823982
3983 try p.initializerItem(&il, final_init_qt, l_brace);3983 try p.initializerItem(&il, final_init_qt, l_brace);
...@@ -4028,12 +4028,12 @@ fn initializerItem(p: *Parser, il: *InitList, init_qt: QualType, l_brace: TokenI...@@ -4028,12 +4028,12 @@ fn initializerItem(p: *Parser, il: *InitList, init_qt: QualType, l_brace: TokenI
4028 try p.err(first_tok, .initializer_overrides, .{});4028 try p.err(first_tok, .initializer_overrides, .{});
4029 try p.err(item.il.tok, .previous_initializer, .{});4029 try p.err(item.il.tok, .previous_initializer, .{});
4030 item.il.deinit(gpa);4030 item.il.deinit(gpa);
4031 item.il.* = .{};4031 item.il.* = .empty;
4032 }4032 }
4033 try p.initializerItem(item.il, item.qt, inner_l_brace);4033 try p.initializerItem(item.il, item.qt, inner_l_brace);
4034 } else {4034 } else {
4035 // discard further values4035 // discard further values
4036 var tmp_il: InitList = .{};4036 var tmp_il: InitList = .empty;
4037 defer tmp_il.deinit(gpa);4037 defer tmp_il.deinit(gpa);
4038 try p.initializerItem(&tmp_il, .invalid, inner_l_brace);4038 try p.initializerItem(&tmp_il, .invalid, inner_l_brace);
4039 if (!warned_excess) try p.err(first_tok, switch (init_qt.base(p.comp).type) {4039 if (!warned_excess) try p.err(first_tok, switch (init_qt.base(p.comp).type) {
lib/compiler/aro/aro/Toolchain.zig+3-3
...@@ -43,13 +43,13 @@ const Toolchain = @This();...@@ -43,13 +43,13 @@ const Toolchain = @This();
43driver: *Driver,43driver: *Driver,
4444
45/// The list of toolchain specific path prefixes to search for libraries.45/// The list of toolchain specific path prefixes to search for libraries.
46library_paths: PathList = .{},46library_paths: PathList = .empty,
4747
48/// The list of toolchain specific path prefixes to search for files.48/// The list of toolchain specific path prefixes to search for files.
49file_paths: PathList = .{},49file_paths: PathList = .empty,
5050
51/// The list of toolchain specific path prefixes to search for programs.51/// The list of toolchain specific path prefixes to search for programs.
52program_paths: PathList = .{},52program_paths: PathList = .empty,
5353
54selected_multilib: Multilib = .{},54selected_multilib: Multilib = .{},
5555