mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 03:04:52 +01:00
aro: stop depending on ArrayList default field values
This commit is contained in:
parent
29aa32e206
commit
9f596f9dfd
3 changed files with 19 additions and 13 deletions
20
lib/compiler/aro/aro/InitList.zig
vendored
20
lib/compiler/aro/aro/InitList.zig
vendored
|
|
@ -22,9 +22,15 @@ const Item = struct {
|
|||
|
||||
const InitList = @This();
|
||||
|
||||
list: std.ArrayList(Item) = .empty,
|
||||
node: Node.OptIndex = .null,
|
||||
tok: TokenIndex = 0,
|
||||
list: std.ArrayList(Item),
|
||||
node: Node.OptIndex,
|
||||
tok: TokenIndex,
|
||||
|
||||
pub const empty: InitList = .{
|
||||
.list = .empty,
|
||||
.node = .null,
|
||||
.tok = 0,
|
||||
};
|
||||
|
||||
/// Deinitialize freeing all memory.
|
||||
pub fn deinit(il: *InitList, gpa: Allocator) void {
|
||||
|
|
@ -43,7 +49,7 @@ pub fn find(il: *InitList, gpa: Allocator, index: u64) !*InitList {
|
|||
if (il.list.items.len == 0) {
|
||||
const item = try il.list.addOne(gpa);
|
||||
item.* = .{
|
||||
.list = .{},
|
||||
.list = .empty,
|
||||
.index = index,
|
||||
};
|
||||
return &item.list;
|
||||
|
|
@ -51,7 +57,7 @@ pub fn find(il: *InitList, gpa: Allocator, index: u64) !*InitList {
|
|||
// Append a new value to the end of the list.
|
||||
const new = try il.list.addOne(gpa);
|
||||
new.* = .{
|
||||
.list = .{},
|
||||
.list = .empty,
|
||||
.index = index,
|
||||
};
|
||||
return &new.list;
|
||||
|
|
@ -70,7 +76,7 @@ pub fn find(il: *InitList, gpa: Allocator, index: u64) !*InitList {
|
|||
|
||||
// Insert a new value into a sorted position.
|
||||
try il.list.insert(gpa, left, .{
|
||||
.list = .{},
|
||||
.list = .empty,
|
||||
.index = index,
|
||||
});
|
||||
return &il.list.items[left].list;
|
||||
|
|
@ -78,7 +84,7 @@ pub fn find(il: *InitList, gpa: Allocator, index: u64) !*InitList {
|
|||
|
||||
test "basic usage" {
|
||||
const gpa = testing.allocator;
|
||||
var il: InitList = .{};
|
||||
var il: InitList = .empty;
|
||||
defer il.deinit(gpa);
|
||||
|
||||
{
|
||||
|
|
|
|||
6
lib/compiler/aro/aro/Parser.zig
vendored
6
lib/compiler/aro/aro/Parser.zig
vendored
|
|
@ -3977,7 +3977,7 @@ fn initializer(p: *Parser, init_qt: QualType) Error!Result {
|
|||
final_init_qt = .invalid;
|
||||
}
|
||||
|
||||
var il: InitList = .{};
|
||||
var il: InitList = .empty;
|
||||
defer il.deinit(p.comp.gpa);
|
||||
|
||||
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
|
|||
try p.err(first_tok, .initializer_overrides, .{});
|
||||
try p.err(item.il.tok, .previous_initializer, .{});
|
||||
item.il.deinit(gpa);
|
||||
item.il.* = .{};
|
||||
item.il.* = .empty;
|
||||
}
|
||||
try p.initializerItem(item.il, item.qt, inner_l_brace);
|
||||
} else {
|
||||
// discard further values
|
||||
var tmp_il: InitList = .{};
|
||||
var tmp_il: InitList = .empty;
|
||||
defer tmp_il.deinit(gpa);
|
||||
try p.initializerItem(&tmp_il, .invalid, inner_l_brace);
|
||||
if (!warned_excess) try p.err(first_tok, switch (init_qt.base(p.comp).type) {
|
||||
|
|
|
|||
6
lib/compiler/aro/aro/Toolchain.zig
vendored
6
lib/compiler/aro/aro/Toolchain.zig
vendored
|
|
@ -43,13 +43,13 @@ const Toolchain = @This();
|
|||
driver: *Driver,
|
||||
|
||||
/// The list of toolchain specific path prefixes to search for libraries.
|
||||
library_paths: PathList = .{},
|
||||
library_paths: PathList = .empty,
|
||||
|
||||
/// The list of toolchain specific path prefixes to search for files.
|
||||
file_paths: PathList = .{},
|
||||
file_paths: PathList = .empty,
|
||||
|
||||
/// The list of toolchain specific path prefixes to search for programs.
|
||||
program_paths: PathList = .{},
|
||||
program_paths: PathList = .empty,
|
||||
|
||||
selected_multilib: Multilib = .{},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue