diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/hash.zig | 14 | ||||
| -rw-r--r-- | lib/std/hash_map.zig | 13 | ||||
| -rw-r--r-- | lib/std/special/compiler_rt/int.zig | 7 | ||||
| -rw-r--r-- | lib/std/special/compiler_rt/multi3.zig | 2 | ||||
| -rw-r--r-- | lib/std/special/compiler_rt/negsi2_test.zig | 5 | ||||
| -rw-r--r-- | lib/std/special/compiler_rt/paritydi2_test.zig | 5 | ||||
| -rw-r--r-- | lib/std/special/compiler_rt/paritysi2_test.zig | 5 | ||||
| -rw-r--r-- | lib/std/special/compiler_rt/parityti2_test.zig | 5 | ||||
| -rw-r--r-- | lib/std/special/compiler_rt/popcountdi2_test.zig | 5 | ||||
| -rw-r--r-- | lib/std/special/compiler_rt/popcountsi2_test.zig | 5 | ||||
| -rw-r--r-- | lib/std/special/compiler_rt/popcountti2_test.zig | 5 | ||||
| -rw-r--r-- | lib/std/special/compiler_rt/truncXfYf2_test.zig | 5 | ||||
| -rw-r--r-- | lib/std/special/compiler_rt/udivmod.zig | 7 | ||||
| -rw-r--r-- | lib/std/time.zig | 2 | ||||
| -rw-r--r-- | lib/std/valgrind.zig | 4 | ||||
| -rw-r--r-- | lib/std/zig/Ast.zig | 148 | ||||
| -rw-r--r-- | lib/std/zig/system/darwin.zig | 2 |
17 files changed, 128 insertions, 111 deletions
diff --git a/lib/std/hash.zig b/lib/std/hash.zig index f96d331d0f..2680a8e263 100644 --- a/lib/std/hash.zig +++ b/lib/std/hash.zig @@ -33,11 +33,11 @@ const wyhash = @import("hash/wyhash.zig"); pub const Wyhash = wyhash.Wyhash; test "hash" { - _ = @import("hash/adler.zig"); - _ = @import("hash/auto_hash.zig"); - _ = @import("hash/crc.zig"); - _ = @import("hash/fnv.zig"); - _ = @import("hash/murmur.zig"); - _ = @import("hash/cityhash.zig"); - _ = @import("hash/wyhash.zig"); + _ = adler; + _ = auto_hash; + _ = crc; + _ = fnv; + _ = murmur; + _ = cityhash; + _ = wyhash; } diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig index 851df83f84..15b62e0d40 100644 --- a/lib/std/hash_map.zig +++ b/lib/std/hash_map.zig @@ -750,12 +750,19 @@ pub fn HashMapUnmanaged( fingerprint: FingerPrint = free, used: u1 = 0, + const slot_free = @bitCast(u8, Metadata{ .fingerprint = free }); + const slot_tombstone = @bitCast(u8, Metadata{ .fingerprint = tombstone }); + pub fn isUsed(self: Metadata) bool { return self.used == 1; } pub fn isTombstone(self: Metadata) bool { - return !self.isUsed() and self.fingerprint == tombstone; + return @bitCast(u8, self) == slot_tombstone; + } + + pub fn isFree(self: Metadata) bool { + return @bitCast(u8, self) == slot_free; } pub fn takeFingerprint(hash: Hash) FingerPrint { @@ -1115,7 +1122,7 @@ pub fn HashMapUnmanaged( var idx = @truncate(usize, hash & mask); var metadata = self.metadata.? + idx; - while ((metadata[0].isUsed() or metadata[0].isTombstone()) and limit != 0) { + while (!metadata[0].isFree() and limit != 0) { if (metadata[0].isUsed() and metadata[0].fingerprint == fingerprint) { const test_key = &self.keys()[idx]; // If you get a compile error on this line, it means that your generic eql @@ -1294,7 +1301,7 @@ pub fn HashMapUnmanaged( var first_tombstone_idx: usize = self.capacity(); // invalid index var metadata = self.metadata.? + idx; - while ((metadata[0].isUsed() or metadata[0].isTombstone()) and limit != 0) { + while (!metadata[0].isFree() and limit != 0) { if (metadata[0].isUsed() and metadata[0].fingerprint == fingerprint) { const test_key = &self.keys()[idx]; // If you get a compile error on this line, it means that your generic eql diff --git a/lib/std/special/compiler_rt/int.zig b/lib/std/special/compiler_rt/int.zig index e4d9df7a22..0f3400d37e 100644 --- a/lib/std/special/compiler_rt/int.zig +++ b/lib/std/special/compiler_rt/int.zig @@ -1,8 +1,9 @@ // Builtin functions that operate on integer types const builtin = @import("builtin"); -const testing = @import("std").testing; -const maxInt = @import("std").math.maxInt; -const minInt = @import("std").math.minInt; +const std = @import("std"); +const testing = std.testing; +const maxInt = std.math.maxInt; +const minInt = std.math.minInt; const udivmod = @import("udivmod.zig").udivmod; diff --git a/lib/std/special/compiler_rt/multi3.zig b/lib/std/special/compiler_rt/multi3.zig index a05fb3bd6d..4e5c49730a 100644 --- a/lib/std/special/compiler_rt/multi3.zig +++ b/lib/std/special/compiler_rt/multi3.zig @@ -17,7 +17,7 @@ pub fn __multi3(a: i128, b: i128) callconv(.C) i128 { return r.all; } -const v128 = @import("std").meta.Vector(2, u64); +const v128 = std.meta.Vector(2, u64); pub fn __multi3_windows_x86_64(a: v128, b: v128) callconv(.C) v128 { return @bitCast(v128, @call(.{ .modifier = .always_inline }, __multi3, .{ @bitCast(i128, a), diff --git a/lib/std/special/compiler_rt/negsi2_test.zig b/lib/std/special/compiler_rt/negsi2_test.zig index 9458ea995c..608a44c12f 100644 --- a/lib/std/special/compiler_rt/negsi2_test.zig +++ b/lib/std/special/compiler_rt/negsi2_test.zig @@ -1,7 +1,8 @@ +const std = @import("std"); const neg = @import("negXi2.zig"); -const testing = @import("std").testing; +const testing = std.testing; -const print = @import("std").debug.print; +const print = std.debug.print; fn test__negsi2(a: i32, expected: i32) !void { var result = neg.__negsi2(a); diff --git a/lib/std/special/compiler_rt/paritydi2_test.zig b/lib/std/special/compiler_rt/paritydi2_test.zig index 7c481bbaef..a13abda5fe 100644 --- a/lib/std/special/compiler_rt/paritydi2_test.zig +++ b/lib/std/special/compiler_rt/paritydi2_test.zig @@ -1,5 +1,6 @@ +const std = @import("std"); const parity = @import("parity.zig"); -const testing = @import("std").testing; +const testing = std.testing; fn paritydi2Naive(a: i64) i32 { var x = @bitCast(u64, a); @@ -25,7 +26,7 @@ test "paritydi2" { try test__paritydi2(@bitCast(i64, @as(u64, 0xffffffff_fffffffe))); try test__paritydi2(@bitCast(i64, @as(u64, 0xffffffff_ffffffff))); - const RndGen = @import("std").rand.DefaultPrng; + const RndGen = std.rand.DefaultPrng; var rnd = RndGen.init(42); var i: u32 = 0; while (i < 10_000) : (i += 1) { diff --git a/lib/std/special/compiler_rt/paritysi2_test.zig b/lib/std/special/compiler_rt/paritysi2_test.zig index c4386bcf1f..f63854e34f 100644 --- a/lib/std/special/compiler_rt/paritysi2_test.zig +++ b/lib/std/special/compiler_rt/paritysi2_test.zig @@ -1,5 +1,6 @@ +const std = @import("std"); const parity = @import("parity.zig"); -const testing = @import("std").testing; +const testing = std.testing; fn paritysi2Naive(a: i32) i32 { var x = @bitCast(u32, a); @@ -25,7 +26,7 @@ test "paritysi2" { try test__paritysi2(@bitCast(i32, @as(u32, 0xfffffffe))); try test__paritysi2(@bitCast(i32, @as(u32, 0xffffffff))); - const RndGen = @import("std").rand.DefaultPrng; + const RndGen = std.rand.DefaultPrng; var rnd = RndGen.init(42); var i: u32 = 0; while (i < 10_000) : (i += 1) { diff --git a/lib/std/special/compiler_rt/parityti2_test.zig b/lib/std/special/compiler_rt/parityti2_test.zig index 0de07df31a..e018932555 100644 --- a/lib/std/special/compiler_rt/parityti2_test.zig +++ b/lib/std/special/compiler_rt/parityti2_test.zig @@ -1,5 +1,6 @@ +const std = @import("std"); const parity = @import("parity.zig"); -const testing = @import("std").testing; +const testing = std.testing; fn parityti2Naive(a: i128) i32 { var x = @bitCast(u128, a); @@ -25,7 +26,7 @@ test "parityti2" { try test__parityti2(@bitCast(i128, @as(u128, 0xffffffff_ffffffff_ffffffff_fffffffe))); try test__parityti2(@bitCast(i128, @as(u128, 0xffffffff_ffffffff_ffffffff_ffffffff))); - const RndGen = @import("std").rand.DefaultPrng; + const RndGen = std.rand.DefaultPrng; var rnd = RndGen.init(42); var i: u32 = 0; while (i < 10_000) : (i += 1) { diff --git a/lib/std/special/compiler_rt/popcountdi2_test.zig b/lib/std/special/compiler_rt/popcountdi2_test.zig index e20693987a..e02628e636 100644 --- a/lib/std/special/compiler_rt/popcountdi2_test.zig +++ b/lib/std/special/compiler_rt/popcountdi2_test.zig @@ -1,5 +1,6 @@ +const std = @import("std"); const popcount = @import("popcount.zig"); -const testing = @import("std").testing; +const testing = std.testing; fn popcountdi2Naive(a: i64) i32 { var x = a; @@ -24,7 +25,7 @@ test "popcountdi2" { try test__popcountdi2(@bitCast(i64, @as(u64, 0xffffffff_fffffffe))); try test__popcountdi2(@bitCast(i64, @as(u64, 0xffffffff_ffffffff))); - const RndGen = @import("std").rand.DefaultPrng; + const RndGen = std.rand.DefaultPrng; var rnd = RndGen.init(42); var i: u32 = 0; while (i < 10_000) : (i += 1) { diff --git a/lib/std/special/compiler_rt/popcountsi2_test.zig b/lib/std/special/compiler_rt/popcountsi2_test.zig index c0c92e396e..7606b1a97e 100644 --- a/lib/std/special/compiler_rt/popcountsi2_test.zig +++ b/lib/std/special/compiler_rt/popcountsi2_test.zig @@ -1,5 +1,6 @@ +const std = @import("std"); const popcount = @import("popcount.zig"); -const testing = @import("std").testing; +const testing = std.testing; fn popcountsi2Naive(a: i32) i32 { var x = a; @@ -24,7 +25,7 @@ test "popcountsi2" { try test__popcountsi2(@bitCast(i32, @as(u32, 0xfffffffe))); try test__popcountsi2(@bitCast(i32, @as(u32, 0xffffffff))); - const RndGen = @import("std").rand.DefaultPrng; + const RndGen = std.rand.DefaultPrng; var rnd = RndGen.init(42); var i: u32 = 0; while (i < 10_000) : (i += 1) { diff --git a/lib/std/special/compiler_rt/popcountti2_test.zig b/lib/std/special/compiler_rt/popcountti2_test.zig index 83f2a18e7d..fae2beccd4 100644 --- a/lib/std/special/compiler_rt/popcountti2_test.zig +++ b/lib/std/special/compiler_rt/popcountti2_test.zig @@ -1,5 +1,6 @@ +const std = @import("std"); const popcount = @import("popcount.zig"); -const testing = @import("std").testing; +const testing = std.testing; fn popcountti2Naive(a: i128) i32 { var x = a; @@ -24,7 +25,7 @@ test "popcountti2" { try test__popcountti2(@bitCast(i128, @as(u128, 0xffffffff_ffffffff_ffffffff_fffffffe))); try test__popcountti2(@bitCast(i128, @as(u128, 0xffffffff_ffffffff_ffffffff_ffffffff))); - const RndGen = @import("std").rand.DefaultPrng; + const RndGen = std.rand.DefaultPrng; var rnd = RndGen.init(42); var i: u32 = 0; while (i < 10_000) : (i += 1) { diff --git a/lib/std/special/compiler_rt/truncXfYf2_test.zig b/lib/std/special/compiler_rt/truncXfYf2_test.zig index 1464c3bfcb..3f11dd0380 100644 --- a/lib/std/special/compiler_rt/truncXfYf2_test.zig +++ b/lib/std/special/compiler_rt/truncXfYf2_test.zig @@ -1,3 +1,4 @@ +const std = @import("std"); const __truncsfhf2 = @import("truncXfYf2.zig").__truncsfhf2; fn test__truncsfhf2(a: u32, expected: u16) !void { @@ -217,7 +218,7 @@ fn test__truncdfsf2(a: f64, expected: u32) void { } } - @import("std").debug.print("got 0x{x} wanted 0x{x}\n", .{ rep, expected }); + std.debug.print("got 0x{x} wanted 0x{x}\n", .{ rep, expected }); @panic("__trunctfsf2 test failure"); } @@ -248,7 +249,7 @@ fn test__trunctfhf2(a: f128, expected: u16) void { return; } - @import("std").debug.print("got 0x{x} wanted 0x{x}\n", .{ rep, expected }); + std.debug.print("got 0x{x} wanted 0x{x}\n", .{ rep, expected }); @panic("__trunctfhf2 test failure"); } diff --git a/lib/std/special/compiler_rt/udivmod.zig b/lib/std/special/compiler_rt/udivmod.zig index b2fe2048d4..d941c242d2 100644 --- a/lib/std/special/compiler_rt/udivmod.zig +++ b/lib/std/special/compiler_rt/udivmod.zig @@ -1,6 +1,7 @@ const builtin = @import("builtin"); const is_test = builtin.is_test; const native_endian = builtin.cpu.arch.endian(); +const std = @import("std"); const low = switch (native_endian) { .Big => 1, @@ -13,9 +14,9 @@ pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem: const double_int_bits = @typeInfo(DoubleInt).Int.bits; const single_int_bits = @divExact(double_int_bits, 2); - const SingleInt = @import("std").meta.Int(.unsigned, single_int_bits); - const SignedDoubleInt = @import("std").meta.Int(.signed, double_int_bits); - const Log2SingleInt = @import("std").math.Log2Int(SingleInt); + const SingleInt = std.meta.Int(.unsigned, single_int_bits); + const SignedDoubleInt = std.meta.Int(.signed, double_int_bits); + const Log2SingleInt = std.math.Log2Int(SingleInt); const n = @ptrCast(*const [2]SingleInt, &a).*; // TODO issue #421 const d = @ptrCast(*const [2]SingleInt, &b).*; // TODO issue #421 diff --git a/lib/std/time.zig b/lib/std/time.zig index b9580f5f3e..e8e1d1010c 100644 --- a/lib/std/time.zig +++ b/lib/std/time.zig @@ -287,5 +287,5 @@ test "Timer" { } test { - _ = @import("time/epoch.zig"); + _ = epoch; } diff --git a/lib/std/valgrind.zig b/lib/std/valgrind.zig index 91034fa03e..7532e73e49 100644 --- a/lib/std/valgrind.zig +++ b/lib/std/valgrind.zig @@ -258,6 +258,6 @@ pub const memcheck = @import("valgrind/memcheck.zig"); pub const callgrind = @import("valgrind/callgrind.zig"); test { - _ = @import("valgrind/memcheck.zig"); - _ = @import("valgrind/callgrind.zig"); + _ = memcheck; + _ = callgrind; } diff --git a/lib/std/zig/Ast.zig b/lib/std/zig/Ast.zig index da8616ed9e..65772c87a8 100644 --- a/lib/std/zig/Ast.zig +++ b/lib/std/zig/Ast.zig @@ -16,7 +16,7 @@ const assert = std.debug.assert; const testing = std.testing; const mem = std.mem; const Token = std.zig.Token; -const Tree = @This(); +const Ast = @This(); pub const TokenIndex = u32; pub const ByteOffset = u32; @@ -34,7 +34,7 @@ pub const Location = struct { line_end: usize, }; -pub fn deinit(tree: *Tree, gpa: mem.Allocator) void { +pub fn deinit(tree: *Ast, gpa: mem.Allocator) void { tree.tokens.deinit(gpa); tree.nodes.deinit(gpa); gpa.free(tree.extra_data); @@ -52,7 +52,7 @@ pub const RenderError = error{ /// for allocating extra stack memory if needed, because this function utilizes recursion. /// Note: that's not actually true yet, see https://github.com/ziglang/zig/issues/1006. /// Caller owns the returned slice of bytes, allocated with `gpa`. -pub fn render(tree: Tree, gpa: mem.Allocator) RenderError![]u8 { +pub fn render(tree: Ast, gpa: mem.Allocator) RenderError![]u8 { var buffer = std.ArrayList(u8).init(gpa); defer buffer.deinit(); @@ -60,11 +60,11 @@ pub fn render(tree: Tree, gpa: mem.Allocator) RenderError![]u8 { return buffer.toOwnedSlice(); } -pub fn renderToArrayList(tree: Tree, buffer: *std.ArrayList(u8)) RenderError!void { +pub fn renderToArrayList(tree: Ast, buffer: *std.ArrayList(u8)) RenderError!void { return @import("./render.zig").renderTree(buffer, tree); } -pub fn tokenLocation(self: Tree, start_offset: ByteOffset, token_index: TokenIndex) Location { +pub fn tokenLocation(self: Ast, start_offset: ByteOffset, token_index: TokenIndex) Location { var loc = Location{ .line = 0, .column = 0, @@ -91,7 +91,7 @@ pub fn tokenLocation(self: Tree, start_offset: ByteOffset, token_index: TokenInd return loc; } -pub fn tokenSlice(tree: Tree, token_index: TokenIndex) []const u8 { +pub fn tokenSlice(tree: Ast, token_index: TokenIndex) []const u8 { const token_starts = tree.tokens.items(.start); const token_tags = tree.tokens.items(.tag); const token_tag = token_tags[token_index]; @@ -112,7 +112,7 @@ pub fn tokenSlice(tree: Tree, token_index: TokenIndex) []const u8 { return tree.source[token.loc.start..token.loc.end]; } -pub fn extraData(tree: Tree, index: usize, comptime T: type) T { +pub fn extraData(tree: Ast, index: usize, comptime T: type) T { const fields = std.meta.fields(T); var result: T = undefined; inline for (fields) |field, i| { @@ -122,13 +122,13 @@ pub fn extraData(tree: Tree, index: usize, comptime T: type) T { return result; } -pub fn rootDecls(tree: Tree) []const Node.Index { +pub fn rootDecls(tree: Ast) []const Node.Index { // Root is always index 0. const nodes_data = tree.nodes.items(.data); return tree.extra_data[nodes_data[0].lhs..nodes_data[0].rhs]; } -pub fn renderError(tree: Tree, parse_error: Error, stream: anytype) !void { +pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void { const token_tags = tree.tokens.items(.tag); switch (parse_error.tag) { .asterisk_after_ptr_deref => { @@ -321,7 +321,7 @@ pub fn renderError(tree: Tree, parse_error: Error, stream: anytype) !void { } } -pub fn firstToken(tree: Tree, node: Node.Index) TokenIndex { +pub fn firstToken(tree: Ast, node: Node.Index) TokenIndex { const tags = tree.nodes.items(.tag); const datas = tree.nodes.items(.data); const main_tokens = tree.nodes.items(.main_token); @@ -625,7 +625,7 @@ pub fn firstToken(tree: Tree, node: Node.Index) TokenIndex { }; } -pub fn lastToken(tree: Tree, node: Node.Index) TokenIndex { +pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex { const tags = tree.nodes.items(.tag); const datas = tree.nodes.items(.data); const main_tokens = tree.nodes.items(.main_token); @@ -1157,13 +1157,13 @@ pub fn lastToken(tree: Tree, node: Node.Index) TokenIndex { }; } -pub fn tokensOnSameLine(tree: Tree, token1: TokenIndex, token2: TokenIndex) bool { +pub fn tokensOnSameLine(tree: Ast, token1: TokenIndex, token2: TokenIndex) bool { const token_starts = tree.tokens.items(.start); const source = tree.source[token_starts[token1]..token_starts[token2]]; return mem.indexOfScalar(u8, source, '\n') == null; } -pub fn getNodeSource(tree: Tree, node: Node.Index) []const u8 { +pub fn getNodeSource(tree: Ast, node: Node.Index) []const u8 { const token_starts = tree.tokens.items(.start); const first_token = tree.firstToken(node); const last_token = tree.lastToken(node); @@ -1172,7 +1172,7 @@ pub fn getNodeSource(tree: Tree, node: Node.Index) []const u8 { return tree.source[start..end]; } -pub fn globalVarDecl(tree: Tree, node: Node.Index) full.VarDecl { +pub fn globalVarDecl(tree: Ast, node: Node.Index) full.VarDecl { assert(tree.nodes.items(.tag)[node] == .global_var_decl); const data = tree.nodes.items(.data)[node]; const extra = tree.extraData(data.lhs, Node.GlobalVarDecl); @@ -1186,7 +1186,7 @@ pub fn globalVarDecl(tree: Tree, node: Node.Index) full.VarDecl { }); } -pub fn localVarDecl(tree: Tree, node: Node.Index) full.VarDecl { +pub fn localVarDecl(tree: Ast, node: Node.Index) full.VarDecl { assert(tree.nodes.items(.tag)[node] == .local_var_decl); const data = tree.nodes.items(.data)[node]; const extra = tree.extraData(data.lhs, Node.LocalVarDecl); @@ -1200,7 +1200,7 @@ pub fn localVarDecl(tree: Tree, node: Node.Index) full.VarDecl { }); } -pub fn simpleVarDecl(tree: Tree, node: Node.Index) full.VarDecl { +pub fn simpleVarDecl(tree: Ast, node: Node.Index) full.VarDecl { assert(tree.nodes.items(.tag)[node] == .simple_var_decl); const data = tree.nodes.items(.data)[node]; return tree.fullVarDecl(.{ @@ -1213,7 +1213,7 @@ pub fn simpleVarDecl(tree: Tree, node: Node.Index) full.VarDecl { }); } -pub fn alignedVarDecl(tree: Tree, node: Node.Index) full.VarDecl { +pub fn alignedVarDecl(tree: Ast, node: Node.Index) full.VarDecl { assert(tree.nodes.items(.tag)[node] == .aligned_var_decl); const data = tree.nodes.items(.data)[node]; return tree.fullVarDecl(.{ @@ -1226,7 +1226,7 @@ pub fn alignedVarDecl(tree: Tree, node: Node.Index) full.VarDecl { }); } -pub fn ifSimple(tree: Tree, node: Node.Index) full.If { +pub fn ifSimple(tree: Ast, node: Node.Index) full.If { assert(tree.nodes.items(.tag)[node] == .if_simple); const data = tree.nodes.items(.data)[node]; return tree.fullIf(.{ @@ -1237,7 +1237,7 @@ pub fn ifSimple(tree: Tree, node: Node.Index) full.If { }); } -pub fn ifFull(tree: Tree, node: Node.Index) full.If { +pub fn ifFull(tree: Ast, node: Node.Index) full.If { assert(tree.nodes.items(.tag)[node] == .@"if"); const data = tree.nodes.items(.data)[node]; const extra = tree.extraData(data.rhs, Node.If); @@ -1249,7 +1249,7 @@ pub fn ifFull(tree: Tree, node: Node.Index) full.If { }); } -pub fn containerField(tree: Tree, node: Node.Index) full.ContainerField { +pub fn containerField(tree: Ast, node: Node.Index) full.ContainerField { assert(tree.nodes.items(.tag)[node] == .container_field); const data = tree.nodes.items(.data)[node]; const extra = tree.extraData(data.rhs, Node.ContainerField); @@ -1261,7 +1261,7 @@ pub fn containerField(tree: Tree, node: Node.Index) full.ContainerField { }); } -pub fn containerFieldInit(tree: Tree, node: Node.Index) full.ContainerField { +pub fn containerFieldInit(tree: Ast, node: Node.Index) full.ContainerField { assert(tree.nodes.items(.tag)[node] == .container_field_init); const data = tree.nodes.items(.data)[node]; return tree.fullContainerField(.{ @@ -1272,7 +1272,7 @@ pub fn containerFieldInit(tree: Tree, node: Node.Index) full.ContainerField { }); } -pub fn containerFieldAlign(tree: Tree, node: Node.Index) full.ContainerField { +pub fn containerFieldAlign(tree: Ast, node: Node.Index) full.ContainerField { assert(tree.nodes.items(.tag)[node] == .container_field_align); const data = tree.nodes.items(.data)[node]; return tree.fullContainerField(.{ @@ -1283,7 +1283,7 @@ pub fn containerFieldAlign(tree: Tree, node: Node.Index) full.ContainerField { }); } -pub fn fnProtoSimple(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnProto { +pub fn fnProtoSimple(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.FnProto { assert(tree.nodes.items(.tag)[node] == .fn_proto_simple); const data = tree.nodes.items(.data)[node]; buffer[0] = data.lhs; @@ -1300,7 +1300,7 @@ pub fn fnProtoSimple(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full. }); } -pub fn fnProtoMulti(tree: Tree, node: Node.Index) full.FnProto { +pub fn fnProtoMulti(tree: Ast, node: Node.Index) full.FnProto { assert(tree.nodes.items(.tag)[node] == .fn_proto_multi); const data = tree.nodes.items(.data)[node]; const params_range = tree.extraData(data.lhs, Node.SubRange); @@ -1317,7 +1317,7 @@ pub fn fnProtoMulti(tree: Tree, node: Node.Index) full.FnProto { }); } -pub fn fnProtoOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnProto { +pub fn fnProtoOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.FnProto { assert(tree.nodes.items(.tag)[node] == .fn_proto_one); const data = tree.nodes.items(.data)[node]; const extra = tree.extraData(data.lhs, Node.FnProtoOne); @@ -1335,7 +1335,7 @@ pub fn fnProtoOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnP }); } -pub fn fnProto(tree: Tree, node: Node.Index) full.FnProto { +pub fn fnProto(tree: Ast, node: Node.Index) full.FnProto { assert(tree.nodes.items(.tag)[node] == .fn_proto); const data = tree.nodes.items(.data)[node]; const extra = tree.extraData(data.lhs, Node.FnProto); @@ -1352,7 +1352,7 @@ pub fn fnProto(tree: Tree, node: Node.Index) full.FnProto { }); } -pub fn structInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.StructInit { +pub fn structInitOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.StructInit { assert(tree.nodes.items(.tag)[node] == .struct_init_one or tree.nodes.items(.tag)[node] == .struct_init_one_comma); const data = tree.nodes.items(.data)[node]; @@ -1365,7 +1365,7 @@ pub fn structInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full. }); } -pub fn structInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.StructInit { +pub fn structInitDotTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full.StructInit { assert(tree.nodes.items(.tag)[node] == .struct_init_dot_two or tree.nodes.items(.tag)[node] == .struct_init_dot_two_comma); const data = tree.nodes.items(.data)[node]; @@ -1383,7 +1383,7 @@ pub fn structInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) fu }); } -pub fn structInitDot(tree: Tree, node: Node.Index) full.StructInit { +pub fn structInitDot(tree: Ast, node: Node.Index) full.StructInit { assert(tree.nodes.items(.tag)[node] == .struct_init_dot or tree.nodes.items(.tag)[node] == .struct_init_dot_comma); const data = tree.nodes.items(.data)[node]; @@ -1394,7 +1394,7 @@ pub fn structInitDot(tree: Tree, node: Node.Index) full.StructInit { }); } -pub fn structInit(tree: Tree, node: Node.Index) full.StructInit { +pub fn structInit(tree: Ast, node: Node.Index) full.StructInit { assert(tree.nodes.items(.tag)[node] == .struct_init or tree.nodes.items(.tag)[node] == .struct_init_comma); const data = tree.nodes.items(.data)[node]; @@ -1406,7 +1406,7 @@ pub fn structInit(tree: Tree, node: Node.Index) full.StructInit { }); } -pub fn arrayInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.ArrayInit { +pub fn arrayInitOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.ArrayInit { assert(tree.nodes.items(.tag)[node] == .array_init_one or tree.nodes.items(.tag)[node] == .array_init_one_comma); const data = tree.nodes.items(.data)[node]; @@ -1421,7 +1421,7 @@ pub fn arrayInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.A }; } -pub fn arrayInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ArrayInit { +pub fn arrayInitDotTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full.ArrayInit { assert(tree.nodes.items(.tag)[node] == .array_init_dot_two or tree.nodes.items(.tag)[node] == .array_init_dot_two_comma); const data = tree.nodes.items(.data)[node]; @@ -1441,7 +1441,7 @@ pub fn arrayInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) ful }; } -pub fn arrayInitDot(tree: Tree, node: Node.Index) full.ArrayInit { +pub fn arrayInitDot(tree: Ast, node: Node.Index) full.ArrayInit { assert(tree.nodes.items(.tag)[node] == .array_init_dot or tree.nodes.items(.tag)[node] == .array_init_dot_comma); const data = tree.nodes.items(.data)[node]; @@ -1454,7 +1454,7 @@ pub fn arrayInitDot(tree: Tree, node: Node.Index) full.ArrayInit { }; } -pub fn arrayInit(tree: Tree, node: Node.Index) full.ArrayInit { +pub fn arrayInit(tree: Ast, node: Node.Index) full.ArrayInit { assert(tree.nodes.items(.tag)[node] == .array_init or tree.nodes.items(.tag)[node] == .array_init_comma); const data = tree.nodes.items(.data)[node]; @@ -1468,7 +1468,7 @@ pub fn arrayInit(tree: Tree, node: Node.Index) full.ArrayInit { }; } -pub fn arrayType(tree: Tree, node: Node.Index) full.ArrayType { +pub fn arrayType(tree: Ast, node: Node.Index) full.ArrayType { assert(tree.nodes.items(.tag)[node] == .array_type); const data = tree.nodes.items(.data)[node]; return .{ @@ -1481,7 +1481,7 @@ pub fn arrayType(tree: Tree, node: Node.Index) full.ArrayType { }; } -pub fn arrayTypeSentinel(tree: Tree, node: Node.Index) full.ArrayType { +pub fn arrayTypeSentinel(tree: Ast, node: Node.Index) full.ArrayType { assert(tree.nodes.items(.tag)[node] == .array_type_sentinel); const data = tree.nodes.items(.data)[node]; const extra = tree.extraData(data.rhs, Node.ArrayTypeSentinel); @@ -1496,7 +1496,7 @@ pub fn arrayTypeSentinel(tree: Tree, node: Node.Index) full.ArrayType { }; } -pub fn ptrTypeAligned(tree: Tree, node: Node.Index) full.PtrType { +pub fn ptrTypeAligned(tree: Ast, node: Node.Index) full.PtrType { assert(tree.nodes.items(.tag)[node] == .ptr_type_aligned); const data = tree.nodes.items(.data)[node]; return tree.fullPtrType(.{ @@ -1510,7 +1510,7 @@ pub fn ptrTypeAligned(tree: Tree, node: Node.Index) full.PtrType { }); } -pub fn ptrTypeSentinel(tree: Tree, node: Node.Index) full.PtrType { +pub fn ptrTypeSentinel(tree: Ast, node: Node.Index) full.PtrType { assert(tree.nodes.items(.tag)[node] == .ptr_type_sentinel); const data = tree.nodes.items(.data)[node]; return tree.fullPtrType(.{ @@ -1524,7 +1524,7 @@ pub fn ptrTypeSentinel(tree: Tree, node: Node.Index) full.PtrType { }); } -pub fn ptrType(tree: Tree, node: Node.Index) full.PtrType { +pub fn ptrType(tree: Ast, node: Node.Index) full.PtrType { assert(tree.nodes.items(.tag)[node] == .ptr_type); const data = tree.nodes.items(.data)[node]; const extra = tree.extraData(data.lhs, Node.PtrType); @@ -1539,7 +1539,7 @@ pub fn ptrType(tree: Tree, node: Node.Index) full.PtrType { }); } -pub fn ptrTypeBitRange(tree: Tree, node: Node.Index) full.PtrType { +pub fn ptrTypeBitRange(tree: Ast, node: Node.Index) full.PtrType { assert(tree.nodes.items(.tag)[node] == .ptr_type_bit_range); const data = tree.nodes.items(.data)[node]; const extra = tree.extraData(data.lhs, Node.PtrTypeBitRange); @@ -1554,7 +1554,7 @@ pub fn ptrTypeBitRange(tree: Tree, node: Node.Index) full.PtrType { }); } -pub fn sliceOpen(tree: Tree, node: Node.Index) full.Slice { +pub fn sliceOpen(tree: Ast, node: Node.Index) full.Slice { assert(tree.nodes.items(.tag)[node] == .slice_open); const data = tree.nodes.items(.data)[node]; return .{ @@ -1568,7 +1568,7 @@ pub fn sliceOpen(tree: Tree, node: Node.Index) full.Slice { }; } -pub fn slice(tree: Tree, node: Node.Index) full.Slice { +pub fn slice(tree: Ast, node: Node.Index) full.Slice { assert(tree.nodes.items(.tag)[node] == .slice); const data = tree.nodes.items(.data)[node]; const extra = tree.extraData(data.rhs, Node.Slice); @@ -1583,7 +1583,7 @@ pub fn slice(tree: Tree, node: Node.Index) full.Slice { }; } -pub fn sliceSentinel(tree: Tree, node: Node.Index) full.Slice { +pub fn sliceSentinel(tree: Ast, node: Node.Index) full.Slice { assert(tree.nodes.items(.tag)[node] == .slice_sentinel); const data = tree.nodes.items(.data)[node]; const extra = tree.extraData(data.rhs, Node.SliceSentinel); @@ -1598,7 +1598,7 @@ pub fn sliceSentinel(tree: Tree, node: Node.Index) full.Slice { }; } -pub fn containerDeclTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl { +pub fn containerDeclTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl { assert(tree.nodes.items(.tag)[node] == .container_decl_two or tree.nodes.items(.tag)[node] == .container_decl_two_trailing); const data = tree.nodes.items(.data)[node]; @@ -1617,7 +1617,7 @@ pub fn containerDeclTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) fu }); } -pub fn containerDecl(tree: Tree, node: Node.Index) full.ContainerDecl { +pub fn containerDecl(tree: Ast, node: Node.Index) full.ContainerDecl { assert(tree.nodes.items(.tag)[node] == .container_decl or tree.nodes.items(.tag)[node] == .container_decl_trailing); const data = tree.nodes.items(.data)[node]; @@ -1629,7 +1629,7 @@ pub fn containerDecl(tree: Tree, node: Node.Index) full.ContainerDecl { }); } -pub fn containerDeclArg(tree: Tree, node: Node.Index) full.ContainerDecl { +pub fn containerDeclArg(tree: Ast, node: Node.Index) full.ContainerDecl { assert(tree.nodes.items(.tag)[node] == .container_decl_arg or tree.nodes.items(.tag)[node] == .container_decl_arg_trailing); const data = tree.nodes.items(.data)[node]; @@ -1642,7 +1642,7 @@ pub fn containerDeclArg(tree: Tree, node: Node.Index) full.ContainerDecl { }); } -pub fn taggedUnionTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl { +pub fn taggedUnionTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl { assert(tree.nodes.items(.tag)[node] == .tagged_union_two or tree.nodes.items(.tag)[node] == .tagged_union_two_trailing); const data = tree.nodes.items(.data)[node]; @@ -1662,7 +1662,7 @@ pub fn taggedUnionTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full }); } -pub fn taggedUnion(tree: Tree, node: Node.Index) full.ContainerDecl { +pub fn taggedUnion(tree: Ast, node: Node.Index) full.ContainerDecl { assert(tree.nodes.items(.tag)[node] == .tagged_union or tree.nodes.items(.tag)[node] == .tagged_union_trailing); const data = tree.nodes.items(.data)[node]; @@ -1675,7 +1675,7 @@ pub fn taggedUnion(tree: Tree, node: Node.Index) full.ContainerDecl { }); } -pub fn taggedUnionEnumTag(tree: Tree, node: Node.Index) full.ContainerDecl { +pub fn taggedUnionEnumTag(tree: Ast, node: Node.Index) full.ContainerDecl { assert(tree.nodes.items(.tag)[node] == .tagged_union_enum_tag or tree.nodes.items(.tag)[node] == .tagged_union_enum_tag_trailing); const data = tree.nodes.items(.data)[node]; @@ -1689,7 +1689,7 @@ pub fn taggedUnionEnumTag(tree: Tree, node: Node.Index) full.ContainerDecl { }); } -pub fn switchCaseOne(tree: Tree, node: Node.Index) full.SwitchCase { +pub fn switchCaseOne(tree: Ast, node: Node.Index) full.SwitchCase { const data = &tree.nodes.items(.data)[node]; const values: *[1]Node.Index = &data.lhs; return tree.fullSwitchCase(.{ @@ -1699,7 +1699,7 @@ pub fn switchCaseOne(tree: Tree, node: Node.Index) full.SwitchCase { }); } -pub fn switchCase(tree: Tree, node: Node.Index) full.SwitchCase { +pub fn switchCase(tree: Ast, node: Node.Index) full.SwitchCase { const data = tree.nodes.items(.data)[node]; const extra = tree.extraData(data.lhs, Node.SubRange); return tree.fullSwitchCase(.{ @@ -1709,7 +1709,7 @@ pub fn switchCase(tree: Tree, node: Node.Index) full.SwitchCase { }); } -pub fn asmSimple(tree: Tree, node: Node.Index) full.Asm { +pub fn asmSimple(tree: Ast, node: Node.Index) full.Asm { const data = tree.nodes.items(.data)[node]; return tree.fullAsm(.{ .asm_token = tree.nodes.items(.main_token)[node], @@ -1719,7 +1719,7 @@ pub fn asmSimple(tree: Tree, node: Node.Index) full.Asm { }); } -pub fn asmFull(tree: Tree, node: Node.Index) full.Asm { +pub fn asmFull(tree: Ast, node: Node.Index) full.Asm { const data = tree.nodes.items(.data)[node]; const extra = tree.extraData(data.rhs, Node.Asm); return tree.fullAsm(.{ @@ -1730,7 +1730,7 @@ pub fn asmFull(tree: Tree, node: Node.Index) full.Asm { }); } -pub fn whileSimple(tree: Tree, node: Node.Index) full.While { +pub fn whileSimple(tree: Ast, node: Node.Index) full.While { const data = tree.nodes.items(.data)[node]; return tree.fullWhile(.{ .while_token = tree.nodes.items(.main_token)[node], @@ -1741,7 +1741,7 @@ pub fn whileSimple(tree: Tree, node: Node.Index) full.While { }); } -pub fn whileCont(tree: Tree, node: Node.Index) full.While { +pub fn whileCont(tree: Ast, node: Node.Index) full.While { const data = tree.nodes.items(.data)[node]; const extra = tree.extraData(data.rhs, Node.WhileCont); return tree.fullWhile(.{ @@ -1753,7 +1753,7 @@ pub fn whileCont(tree: Tree, node: Node.Index) full.While { }); } -pub fn whileFull(tree: Tree, node: Node.Index) full.While { +pub fn whileFull(tree: Ast, node: Node.Index) full.While { const data = tree.nodes.items(.data)[node]; const extra = tree.extraData(data.rhs, Node.While); return tree.fullWhile(.{ @@ -1765,7 +1765,7 @@ pub fn whileFull(tree: Tree, node: Node.Index) full.While { }); } -pub fn forSimple(tree: Tree, node: Node.Index) full.While { +pub fn forSimple(tree: Ast, node: Node.Index) full.While { const data = tree.nodes.items(.data)[node]; return tree.fullWhile(.{ .while_token = tree.nodes.items(.main_token)[node], @@ -1776,7 +1776,7 @@ pub fn forSimple(tree: Tree, node: Node.Index) full.While { }); } -pub fn forFull(tree: Tree, node: Node.Index) full.While { +pub fn forFull(tree: Ast, node: Node.Index) full.While { const data = tree.nodes.items(.data)[node]; const extra = tree.extraData(data.rhs, Node.If); return tree.fullWhile(.{ @@ -1788,7 +1788,7 @@ pub fn forFull(tree: Tree, node: Node.Index) full.While { }); } -pub fn callOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.Call { +pub fn callOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.Call { const data = tree.nodes.items(.data)[node]; buffer.* = .{data.rhs}; const params = if (data.rhs != 0) buffer[0..1] else buffer[0..0]; @@ -1799,7 +1799,7 @@ pub fn callOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.Call { }); } -pub fn callFull(tree: Tree, node: Node.Index) full.Call { +pub fn callFull(tree: Ast, node: Node.Index) full.Call { const data = tree.nodes.items(.data)[node]; const extra = tree.extraData(data.rhs, Node.SubRange); return tree.fullCall(.{ @@ -1809,7 +1809,7 @@ pub fn callFull(tree: Tree, node: Node.Index) full.Call { }); } -fn fullVarDecl(tree: Tree, info: full.VarDecl.Components) full.VarDecl { +fn fullVarDecl(tree: Ast, info: full.VarDecl.Components) full.VarDecl { const token_tags = tree.tokens.items(.tag); var result: full.VarDecl = .{ .ast = info, @@ -1834,7 +1834,7 @@ fn fullVarDecl(tree: Tree, info: full.VarDecl.Components) full.VarDecl { return result; } -fn fullIf(tree: Tree, info: full.If.Components) full.If { +fn fullIf(tree: Ast, info: full.If.Components) full.If { const token_tags = tree.tokens.items(.tag); var result: full.If = .{ .ast = info, @@ -1859,7 +1859,7 @@ fn fullIf(tree: Tree, info: full.If.Components) full.If { return result; } -fn fullContainerField(tree: Tree, info: full.ContainerField.Components) full.ContainerField { +fn fullContainerField(tree: Ast, info: full.ContainerField.Components) full.ContainerField { const token_tags = tree.tokens.items(.tag); var result: full.ContainerField = .{ .ast = info, @@ -1873,7 +1873,7 @@ fn fullContainerField(tree: Tree, info: full.ContainerField.Components) full.Con return result; } -fn fullFnProto(tree: Tree, info: full.FnProto.Components) full.FnProto { +fn fullFnProto(tree: Ast, info: full.FnProto.Components) full.FnProto { const token_tags = tree.tokens.items(.tag); var result: full.FnProto = .{ .ast = info, @@ -1909,7 +1909,7 @@ fn fullFnProto(tree: Tree, info: full.FnProto.Components) full.FnProto { return result; } -fn fullStructInit(tree: Tree, info: full.StructInit.Components) full.StructInit { +fn fullStructInit(tree: Ast, info: full.StructInit.Components) full.StructInit { _ = tree; var result: full.StructInit = .{ .ast = info, @@ -1917,7 +1917,7 @@ fn fullStructInit(tree: Tree, info: full.StructInit.Components) full.StructInit return result; } -fn fullPtrType(tree: Tree, info: full.PtrType.Components) full.PtrType { +fn fullPtrType(tree: Ast, info: full.PtrType.Components) full.PtrType { const token_tags = tree.tokens.items(.tag); // TODO: looks like stage1 isn't quite smart enough to handle enum // literals in some places here @@ -1966,7 +1966,7 @@ fn fullPtrType(tree: Tree, info: full.PtrType.Components) full.PtrType { return result; } -fn fullContainerDecl(tree: Tree, info: full.ContainerDecl.Components) full.ContainerDecl { +fn fullContainerDecl(tree: Ast, info: full.ContainerDecl.Components) full.ContainerDecl { const token_tags = tree.tokens.items(.tag); var result: full.ContainerDecl = .{ .ast = info, @@ -1979,7 +1979,7 @@ fn fullContainerDecl(tree: Tree, info: full.ContainerDecl.Components) full.Conta return result; } -fn fullSwitchCase(tree: Tree, info: full.SwitchCase.Components) full.SwitchCase { +fn fullSwitchCase(tree: Ast, info: full.SwitchCase.Components) full.SwitchCase { const token_tags = tree.tokens.items(.tag); var result: full.SwitchCase = .{ .ast = info, @@ -1991,7 +1991,7 @@ fn fullSwitchCase(tree: Tree, info: full.SwitchCase.Components) full.SwitchCase return result; } -fn fullAsm(tree: Tree, info: full.Asm.Components) full.Asm { +fn fullAsm(tree: Ast, info: full.Asm.Components) full.Asm { const token_tags = tree.tokens.items(.tag); const node_tags = tree.nodes.items(.tag); var result: full.Asm = .{ @@ -2054,7 +2054,7 @@ fn fullAsm(tree: Tree, info: full.Asm.Components) full.Asm { return result; } -fn fullWhile(tree: Tree, info: full.While.Components) full.While { +fn fullWhile(tree: Ast, info: full.While.Components) full.While { const token_tags = tree.tokens.items(.tag); var result: full.While = .{ .ast = info, @@ -2089,7 +2089,7 @@ fn fullWhile(tree: Tree, info: full.While.Components) full.While { return result; } -fn fullCall(tree: Tree, info: full.Call.Components) full.Call { +fn fullCall(tree: Ast, info: full.Call.Components) full.Call { const token_tags = tree.tokens.items(.tag); var result: full.Call = .{ .ast = info, @@ -2201,7 +2201,7 @@ pub const full = struct { /// in the params slice, since they are simple identifiers and /// not sub-expressions. pub const Iterator = struct { - tree: *const Tree, + tree: *const Ast, fn_proto: *const FnProto, param_i: usize, tok_i: TokenIndex, @@ -2291,7 +2291,7 @@ pub const full = struct { } }; - pub fn iterate(fn_proto: FnProto, tree: Tree) Iterator { + pub fn iterate(fn_proto: FnProto, tree: Ast) Iterator { return .{ .tree = &tree, .fn_proto = &fn_proto, @@ -2485,7 +2485,7 @@ pub const Node = struct { } /// Note: The FooComma/FooSemicolon variants exist to ease the implementation of - /// Tree.lastToken() + /// Ast.lastToken() pub const Tag = enum { /// sub_list[lhs...rhs] root, diff --git a/lib/std/zig/system/darwin.zig b/lib/std/zig/system/darwin.zig index c20607440d..52abddc06a 100644 --- a/lib/std/zig/system/darwin.zig +++ b/lib/std/zig/system/darwin.zig @@ -88,5 +88,5 @@ pub const DarwinSDK = struct { }; test "" { - _ = @import("darwin/macos.zig"); + _ = macos; } |
