mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
Update uses of @fieldParentPtr to pass a pointer type
This commit is contained in:
parent
9b2345e182
commit
e409afb79b
12
lib/compiler/aro/aro/pragmas/gcc.zig
vendored
12
lib/compiler/aro/aro/pragmas/gcc.zig
vendored
@ -37,18 +37,18 @@ const Directive = enum {
|
||||
};
|
||||
|
||||
fn beforePreprocess(pragma: *Pragma, comp: *Compilation) void {
|
||||
var self = @fieldParentPtr(GCC, "pragma", pragma);
|
||||
var self = @fieldParentPtr(*GCC, "pragma", pragma);
|
||||
self.original_options = comp.diagnostics.options;
|
||||
}
|
||||
|
||||
fn beforeParse(pragma: *Pragma, comp: *Compilation) void {
|
||||
var self = @fieldParentPtr(GCC, "pragma", pragma);
|
||||
var self = @fieldParentPtr(*GCC, "pragma", pragma);
|
||||
comp.diagnostics.options = self.original_options;
|
||||
self.options_stack.items.len = 0;
|
||||
}
|
||||
|
||||
fn afterParse(pragma: *Pragma, comp: *Compilation) void {
|
||||
var self = @fieldParentPtr(GCC, "pragma", pragma);
|
||||
var self = @fieldParentPtr(*GCC, "pragma", pragma);
|
||||
comp.diagnostics.options = self.original_options;
|
||||
self.options_stack.items.len = 0;
|
||||
}
|
||||
@ -60,7 +60,7 @@ pub fn init(allocator: mem.Allocator) !*Pragma {
|
||||
}
|
||||
|
||||
fn deinit(pragma: *Pragma, comp: *Compilation) void {
|
||||
var self = @fieldParentPtr(GCC, "pragma", pragma);
|
||||
var self = @fieldParentPtr(*GCC, "pragma", pragma);
|
||||
self.options_stack.deinit(comp.gpa);
|
||||
comp.gpa.destroy(self);
|
||||
}
|
||||
@ -108,7 +108,7 @@ fn diagnosticHandler(self: *GCC, pp: *Preprocessor, start_idx: TokenIndex) Pragm
|
||||
}
|
||||
|
||||
fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex) Pragma.Error!void {
|
||||
var self = @fieldParentPtr(GCC, "pragma", pragma);
|
||||
var self = @fieldParentPtr(*GCC, "pragma", pragma);
|
||||
const directive_tok = pp.tokens.get(start_idx + 1);
|
||||
if (directive_tok.id == .nl) return;
|
||||
|
||||
@ -174,7 +174,7 @@ fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex
|
||||
}
|
||||
|
||||
fn parserHandler(pragma: *Pragma, p: *Parser, start_idx: TokenIndex) Compilation.Error!void {
|
||||
var self = @fieldParentPtr(GCC, "pragma", pragma);
|
||||
var self = @fieldParentPtr(*GCC, "pragma", pragma);
|
||||
const directive_tok = p.pp.tokens.get(start_idx + 1);
|
||||
if (directive_tok.id == .nl) return;
|
||||
const name = p.pp.expandedSlice(directive_tok);
|
||||
|
||||
2
lib/compiler/aro/aro/pragmas/message.zig
vendored
2
lib/compiler/aro/aro/pragmas/message.zig
vendored
@ -22,7 +22,7 @@ pub fn init(allocator: mem.Allocator) !*Pragma {
|
||||
}
|
||||
|
||||
fn deinit(pragma: *Pragma, comp: *Compilation) void {
|
||||
const self = @fieldParentPtr(Message, "pragma", pragma);
|
||||
const self = @fieldParentPtr(*Message, "pragma", pragma);
|
||||
comp.gpa.destroy(self);
|
||||
}
|
||||
|
||||
|
||||
6
lib/compiler/aro/aro/pragmas/once.zig
vendored
6
lib/compiler/aro/aro/pragmas/once.zig
vendored
@ -27,18 +27,18 @@ pub fn init(allocator: mem.Allocator) !*Pragma {
|
||||
}
|
||||
|
||||
fn afterParse(pragma: *Pragma, _: *Compilation) void {
|
||||
var self = @fieldParentPtr(Once, "pragma", pragma);
|
||||
var self = @fieldParentPtr(*Once, "pragma", pragma);
|
||||
self.pragma_once.clearRetainingCapacity();
|
||||
}
|
||||
|
||||
fn deinit(pragma: *Pragma, comp: *Compilation) void {
|
||||
var self = @fieldParentPtr(Once, "pragma", pragma);
|
||||
var self = @fieldParentPtr(*Once, "pragma", pragma);
|
||||
self.pragma_once.deinit();
|
||||
comp.gpa.destroy(self);
|
||||
}
|
||||
|
||||
fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex) Pragma.Error!void {
|
||||
var self = @fieldParentPtr(Once, "pragma", pragma);
|
||||
var self = @fieldParentPtr(*Once, "pragma", pragma);
|
||||
const name_tok = pp.tokens.get(start_idx);
|
||||
const next = pp.tokens.get(start_idx + 1);
|
||||
if (next.id != .nl) {
|
||||
|
||||
4
lib/compiler/aro/aro/pragmas/pack.zig
vendored
4
lib/compiler/aro/aro/pragmas/pack.zig
vendored
@ -24,13 +24,13 @@ pub fn init(allocator: mem.Allocator) !*Pragma {
|
||||
}
|
||||
|
||||
fn deinit(pragma: *Pragma, comp: *Compilation) void {
|
||||
var self = @fieldParentPtr(Pack, "pragma", pragma);
|
||||
var self = @fieldParentPtr(*Pack, "pragma", pragma);
|
||||
self.stack.deinit(comp.gpa);
|
||||
comp.gpa.destroy(self);
|
||||
}
|
||||
|
||||
fn parserHandler(pragma: *Pragma, p: *Parser, start_idx: TokenIndex) Compilation.Error!void {
|
||||
var pack = @fieldParentPtr(Pack, "pragma", pragma);
|
||||
var pack = @fieldParentPtr(*Pack, "pragma", pragma);
|
||||
var idx = start_idx + 1;
|
||||
const l_paren = p.pp.tokens.get(idx);
|
||||
if (l_paren.id != .l_paren) {
|
||||
|
||||
@ -1103,8 +1103,8 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
|
||||
while (true) {
|
||||
switch (scope.id) {
|
||||
.root => unreachable,
|
||||
.block => return @fieldParentPtr(Block, "base", scope),
|
||||
.condition => return @fieldParentPtr(Condition, "base", scope).getBlockScope(c),
|
||||
.block => return @fieldParentPtr(*Block, "base", scope),
|
||||
.condition => return @fieldParentPtr(*Condition, "base", scope).getBlockScope(c),
|
||||
else => scope = scope.parent.?,
|
||||
}
|
||||
}
|
||||
@ -1116,7 +1116,7 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
|
||||
switch (scope.id) {
|
||||
.root => unreachable,
|
||||
.block => {
|
||||
const block = @fieldParentPtr(Block, "base", scope);
|
||||
const block = @fieldParentPtr(*Block, "base", scope);
|
||||
if (block.return_type) |ty| return ty;
|
||||
scope = scope.parent.?;
|
||||
},
|
||||
@ -1128,15 +1128,15 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
|
||||
pub fn getAlias(scope: *ScopeExtraScope, name: []const u8) []const u8 {
|
||||
return switch (scope.id) {
|
||||
.root => return name,
|
||||
.block => @fieldParentPtr(Block, "base", scope).getAlias(name),
|
||||
.block => @fieldParentPtr(*Block, "base", scope).getAlias(name),
|
||||
.loop, .do_loop, .condition => scope.parent.?.getAlias(name),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn contains(scope: *ScopeExtraScope, name: []const u8) bool {
|
||||
return switch (scope.id) {
|
||||
.root => @fieldParentPtr(Root, "base", scope).contains(name),
|
||||
.block => @fieldParentPtr(Block, "base", scope).contains(name),
|
||||
.root => @fieldParentPtr(*Root, "base", scope).contains(name),
|
||||
.block => @fieldParentPtr(*Block, "base", scope).contains(name),
|
||||
.loop, .do_loop, .condition => scope.parent.?.contains(name),
|
||||
};
|
||||
}
|
||||
@ -1158,11 +1158,11 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
|
||||
while (true) {
|
||||
switch (scope.id) {
|
||||
.root => {
|
||||
const root = @fieldParentPtr(Root, "base", scope);
|
||||
const root = @fieldParentPtr(*Root, "base", scope);
|
||||
return root.nodes.append(node);
|
||||
},
|
||||
.block => {
|
||||
const block = @fieldParentPtr(Block, "base", scope);
|
||||
const block = @fieldParentPtr(*Block, "base", scope);
|
||||
return block.statements.append(node);
|
||||
},
|
||||
else => scope = scope.parent.?,
|
||||
@ -1184,7 +1184,7 @@ pub fn ScopeExtra(comptime ScopeExtraContext: type, comptime ScopeExtraType: typ
|
||||
switch (scope.id) {
|
||||
.root => return,
|
||||
.block => {
|
||||
const block = @fieldParentPtr(Block, "base", scope);
|
||||
const block = @fieldParentPtr(*Block, "base", scope);
|
||||
if (block.variable_discards.get(name)) |discard| {
|
||||
discard.data.should_skip = true;
|
||||
return;
|
||||
|
||||
@ -409,7 +409,7 @@ pub const Node = extern union {
|
||||
return null;
|
||||
|
||||
if (self.ptr_otherwise.tag == t)
|
||||
return @fieldParentPtr(t.Type(), "base", self.ptr_otherwise);
|
||||
return @alignCast(@fieldParentPtr(*align(1) t.Type(), "base", self.ptr_otherwise));
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -1220,7 +1220,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
|
||||
});
|
||||
},
|
||||
.pub_var_simple, .var_simple => {
|
||||
const payload = @fieldParentPtr(Payload.SimpleVarDecl, "base", node.ptr_otherwise).data;
|
||||
const payload = @as(*Payload.SimpleVarDecl, @alignCast(@fieldParentPtr(*align(1) Payload.SimpleVarDecl, "base", node.ptr_otherwise))).data;
|
||||
if (node.tag() == .pub_var_simple) _ = try c.addToken(.keyword_pub, "pub");
|
||||
const const_tok = try c.addToken(.keyword_const, "const");
|
||||
_ = try c.addIdentifier(payload.name);
|
||||
@ -1293,7 +1293,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
|
||||
},
|
||||
.var_decl => return renderVar(c, node),
|
||||
.arg_redecl, .alias => {
|
||||
const payload = @fieldParentPtr(Payload.ArgRedecl, "base", node.ptr_otherwise).data;
|
||||
const payload = @as(*Payload.ArgRedecl, @alignCast(@fieldParentPtr(*align(1) Payload.ArgRedecl, "base", node.ptr_otherwise))).data;
|
||||
if (node.tag() == .alias) _ = try c.addToken(.keyword_pub, "pub");
|
||||
const mut_tok = if (node.tag() == .alias)
|
||||
try c.addToken(.keyword_const, "const")
|
||||
@ -1492,7 +1492,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
|
||||
});
|
||||
},
|
||||
.c_pointer, .single_pointer => {
|
||||
const payload = @fieldParentPtr(Payload.Pointer, "base", node.ptr_otherwise).data;
|
||||
const payload = @as(*Payload.Pointer, @alignCast(@fieldParentPtr(*align(1) Payload.Pointer, "base", node.ptr_otherwise))).data;
|
||||
|
||||
const asterisk = if (node.tag() == .single_pointer)
|
||||
try c.addToken(.asterisk, "*")
|
||||
@ -2085,7 +2085,7 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex {
|
||||
}
|
||||
|
||||
fn renderRecord(c: *Context, node: Node) !NodeIndex {
|
||||
const payload = @fieldParentPtr(Payload.Record, "base", node.ptr_otherwise).data;
|
||||
const payload = @as(*Payload.Record, @alignCast(@fieldParentPtr(*align(1) Payload.Record, "base", node.ptr_otherwise))).data;
|
||||
if (payload.layout == .@"packed")
|
||||
_ = try c.addToken(.keyword_packed, "packed")
|
||||
else if (payload.layout == .@"extern")
|
||||
@ -2487,7 +2487,7 @@ fn renderNodeGrouped(c: *Context, node: Node) !NodeIndex {
|
||||
}
|
||||
|
||||
fn renderPrefixOp(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {
|
||||
const payload = @fieldParentPtr(Payload.UnOp, "base", node.ptr_otherwise).data;
|
||||
const payload = @as(*Payload.UnOp, @alignCast(@fieldParentPtr(*align(1) Payload.UnOp, "base", node.ptr_otherwise))).data;
|
||||
return c.addNode(.{
|
||||
.tag = tag,
|
||||
.main_token = try c.addToken(tok_tag, bytes),
|
||||
@ -2499,7 +2499,7 @@ fn renderPrefixOp(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: T
|
||||
}
|
||||
|
||||
fn renderBinOpGrouped(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {
|
||||
const payload = @fieldParentPtr(Payload.BinOp, "base", node.ptr_otherwise).data;
|
||||
const payload = @as(*Payload.BinOp, @alignCast(@fieldParentPtr(*align(1) Payload.BinOp, "base", node.ptr_otherwise))).data;
|
||||
const lhs = try renderNodeGrouped(c, payload.lhs);
|
||||
return c.addNode(.{
|
||||
.tag = tag,
|
||||
@ -2512,7 +2512,7 @@ fn renderBinOpGrouped(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_ta
|
||||
}
|
||||
|
||||
fn renderBinOp(c: *Context, node: Node, tag: std.zig.Ast.Node.Tag, tok_tag: TokenTag, bytes: []const u8) !NodeIndex {
|
||||
const payload = @fieldParentPtr(Payload.BinOp, "base", node.ptr_otherwise).data;
|
||||
const payload = @as(*Payload.BinOp, @alignCast(@fieldParentPtr(*align(1) Payload.BinOp, "base", node.ptr_otherwise))).data;
|
||||
const lhs = try renderNode(c, payload.lhs);
|
||||
return c.addNode(.{
|
||||
.tag = tag,
|
||||
|
||||
@ -1062,8 +1062,8 @@ pub fn getUninstallStep(self: *Build) *Step {
|
||||
|
||||
fn makeUninstall(uninstall_step: *Step, prog_node: *std.Progress.Node) anyerror!void {
|
||||
_ = prog_node;
|
||||
const uninstall_tls = @fieldParentPtr(TopLevelStep, "step", uninstall_step);
|
||||
const self = @fieldParentPtr(Build, "uninstall_tls", uninstall_tls);
|
||||
const uninstall_tls = @fieldParentPtr(*TopLevelStep, "step", uninstall_step);
|
||||
const self = @fieldParentPtr(*Build, "uninstall_tls", uninstall_tls);
|
||||
|
||||
for (self.installed_files.items) |installed_file| {
|
||||
const full_path = self.getInstallPath(installed_file.dir, installed_file.path);
|
||||
|
||||
@ -231,7 +231,7 @@ fn makeNoOp(step: *Step, prog_node: *std.Progress.Node) anyerror!void {
|
||||
|
||||
pub fn cast(step: *Step, comptime T: type) ?*T {
|
||||
if (step.id == T.base_id) {
|
||||
return @fieldParentPtr(T, "step", step);
|
||||
return @fieldParentPtr(*T, "step", step);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ pub fn setName(self: *CheckFile, name: []const u8) void {
|
||||
fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
||||
_ = prog_node;
|
||||
const b = step.owner;
|
||||
const self = @fieldParentPtr(CheckFile, "step", step);
|
||||
const self = @fieldParentPtr(*CheckFile, "step", step);
|
||||
|
||||
const src_path = self.source.getPath(b);
|
||||
const contents = fs.cwd().readFileAlloc(b.allocator, src_path, self.max_bytes) catch |err| {
|
||||
|
||||
@ -530,7 +530,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
||||
_ = prog_node;
|
||||
const b = step.owner;
|
||||
const gpa = b.allocator;
|
||||
const self = @fieldParentPtr(CheckObject, "step", step);
|
||||
const self = @fieldParentPtr(*CheckObject, "step", step);
|
||||
|
||||
const src_path = self.source.getPath(b);
|
||||
const contents = fs.cwd().readFileAllocOptions(
|
||||
|
||||
@ -918,7 +918,7 @@ fn getGeneratedFilePath(self: *Compile, comptime tag_name: []const u8, asking_st
|
||||
fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
||||
const b = step.owner;
|
||||
const arena = b.allocator;
|
||||
const self = @fieldParentPtr(Compile, "step", step);
|
||||
const self = @fieldParentPtr(*Compile, "step", step);
|
||||
|
||||
var zig_args = ArrayList([]const u8).init(arena);
|
||||
defer zig_args.deinit();
|
||||
|
||||
@ -167,7 +167,7 @@ fn putValue(self: *ConfigHeader, field_name: []const u8, comptime T: type, v: T)
|
||||
fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
||||
_ = prog_node;
|
||||
const b = step.owner;
|
||||
const self = @fieldParentPtr(ConfigHeader, "step", step);
|
||||
const self = @fieldParentPtr(*ConfigHeader, "step", step);
|
||||
const gpa = b.allocator;
|
||||
const arena = b.allocator;
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
||||
|
||||
const b = step.owner;
|
||||
const arena = b.allocator;
|
||||
const self = @fieldParentPtr(Fmt, "step", step);
|
||||
const self = @fieldParentPtr(*Fmt, "step", step);
|
||||
|
||||
var argv: std.ArrayListUnmanaged([]const u8) = .{};
|
||||
try argv.ensureUnusedCapacity(arena, 2 + 1 + self.paths.len + 2 * self.exclude_paths.len);
|
||||
|
||||
@ -121,7 +121,7 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins
|
||||
|
||||
fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
||||
_ = prog_node;
|
||||
const self = @fieldParentPtr(InstallArtifact, "step", step);
|
||||
const self = @fieldParentPtr(*InstallArtifact, "step", step);
|
||||
const dest_builder = step.owner;
|
||||
const cwd = fs.cwd();
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ pub fn create(owner: *std.Build, options: Options) *InstallDirStep {
|
||||
|
||||
fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
||||
_ = prog_node;
|
||||
const self = @fieldParentPtr(InstallDirStep, "step", step);
|
||||
const self = @fieldParentPtr(*InstallDirStep, "step", step);
|
||||
const dest_builder = self.dest_builder;
|
||||
const arena = dest_builder.allocator;
|
||||
const dest_prefix = dest_builder.getInstallPath(self.options.install_dir, self.options.install_subdir);
|
||||
|
||||
@ -43,7 +43,7 @@ pub fn create(
|
||||
fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
||||
_ = prog_node;
|
||||
const src_builder = step.owner;
|
||||
const self = @fieldParentPtr(InstallFile, "step", step);
|
||||
const self = @fieldParentPtr(*InstallFile, "step", step);
|
||||
const dest_builder = self.dest_builder;
|
||||
const full_src_path = self.source.getPath2(src_builder, step);
|
||||
const full_dest_path = dest_builder.getInstallPath(self.dir, self.dest_rel_path);
|
||||
|
||||
@ -92,7 +92,7 @@ pub fn getOutputSeparatedDebug(self: *const ObjCopy) ?std.Build.LazyPath {
|
||||
|
||||
fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
||||
const b = step.owner;
|
||||
const self = @fieldParentPtr(ObjCopy, "step", step);
|
||||
const self = @fieldParentPtr(*ObjCopy, "step", step);
|
||||
|
||||
var man = b.graph.cache.obtain();
|
||||
defer man.deinit();
|
||||
|
||||
@ -415,7 +415,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
||||
_ = prog_node;
|
||||
|
||||
const b = step.owner;
|
||||
const self = @fieldParentPtr(Options, "step", step);
|
||||
const self = @fieldParentPtr(*Options, "step", step);
|
||||
|
||||
for (self.args.items) |item| {
|
||||
self.addOption(
|
||||
|
||||
@ -28,7 +28,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
||||
_ = prog_node;
|
||||
|
||||
const b = step.owner;
|
||||
const self = @fieldParentPtr(RemoveDir, "step", step);
|
||||
const self = @fieldParentPtr(*RemoveDir, "step", step);
|
||||
|
||||
b.build_root.handle.deleteTree(self.dir_path) catch |err| {
|
||||
if (b.build_root.path) |base| {
|
||||
|
||||
@ -497,7 +497,7 @@ const IndexedOutput = struct {
|
||||
fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
||||
const b = step.owner;
|
||||
const arena = b.allocator;
|
||||
const self = @fieldParentPtr(Run, "step", step);
|
||||
const self = @fieldParentPtr(*Run, "step", step);
|
||||
const has_side_effects = self.hasSideEffects();
|
||||
|
||||
var argv_list = ArrayList([]const u8).init(arena);
|
||||
|
||||
@ -118,7 +118,7 @@ pub fn defineCMacroRaw(self: *TranslateC, name_and_value: []const u8) void {
|
||||
|
||||
fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
||||
const b = step.owner;
|
||||
const self = @fieldParentPtr(TranslateC, "step", step);
|
||||
const self = @fieldParentPtr(*TranslateC, "step", step);
|
||||
|
||||
var argv_list = std.ArrayList([]const u8).init(b.allocator);
|
||||
try argv_list.append(b.graph.zig_exe);
|
||||
|
||||
@ -141,7 +141,7 @@ fn maybeUpdateName(wf: *WriteFile) void {
|
||||
fn make(step: *Step, prog_node: *std.Progress.Node) !void {
|
||||
_ = prog_node;
|
||||
const b = step.owner;
|
||||
const wf = @fieldParentPtr(WriteFile, "step", step);
|
||||
const wf = @fieldParentPtr(*WriteFile, "step", step);
|
||||
|
||||
// Writing to source files is kind of an extra capability of this
|
||||
// WriteFile - arguably it should be a different step. But anyway here
|
||||
|
||||
@ -88,8 +88,8 @@ pub fn spawn(pool: *Pool, comptime func: anytype, args: anytype) !void {
|
||||
run_node: RunQueue.Node = .{ .data = .{ .runFn = runFn } },
|
||||
|
||||
fn runFn(runnable: *Runnable) void {
|
||||
const run_node = @fieldParentPtr(RunQueue.Node, "data", runnable);
|
||||
const closure = @fieldParentPtr(@This(), "run_node", run_node);
|
||||
const run_node = @fieldParentPtr(*RunQueue.Node, "data", runnable);
|
||||
const closure = @fieldParentPtr(*@This(), "run_node", run_node);
|
||||
@call(.auto, func, closure.arguments);
|
||||
|
||||
// The thread pool's allocator is protected by the mutex.
|
||||
|
||||
@ -108,7 +108,7 @@ pub const ConnectionPool = struct {
|
||||
pool.mutex.lock();
|
||||
defer pool.mutex.unlock();
|
||||
|
||||
const node = @fieldParentPtr(Node, "data", connection);
|
||||
const node = @fieldParentPtr(*Node, "data", connection);
|
||||
|
||||
pool.used.remove(node);
|
||||
|
||||
|
||||
@ -11686,20 +11686,20 @@ const Scope = struct {
|
||||
fn cast(base: *Scope, comptime T: type) ?*T {
|
||||
if (T == Defer) {
|
||||
switch (base.tag) {
|
||||
.defer_normal, .defer_error => return @fieldParentPtr(T, "base", base),
|
||||
.defer_normal, .defer_error => return @alignCast(@fieldParentPtr(*align(1) T, "base", base)),
|
||||
else => return null,
|
||||
}
|
||||
}
|
||||
if (T == Namespace) {
|
||||
switch (base.tag) {
|
||||
.namespace => return @fieldParentPtr(T, "base", base),
|
||||
.namespace => return @alignCast(@fieldParentPtr(*align(1) T, "base", base)),
|
||||
else => return null,
|
||||
}
|
||||
}
|
||||
if (base.tag != T.base_tag)
|
||||
return null;
|
||||
|
||||
return @fieldParentPtr(T, "base", base);
|
||||
return @alignCast(@fieldParentPtr(*align(1) T, "base", base));
|
||||
}
|
||||
|
||||
fn parent(base: *Scope) ?*Scope {
|
||||
|
||||
@ -414,7 +414,7 @@ pub const Macros = struct {
|
||||
}
|
||||
|
||||
pub fn WL_CONTAINER_OF(ptr: anytype, sample: anytype, comptime member: []const u8) @TypeOf(sample) {
|
||||
return @fieldParentPtr(@TypeOf(sample.*), member, ptr);
|
||||
return @fieldParentPtr(@TypeOf(sample), member, ptr);
|
||||
}
|
||||
|
||||
/// A 2-argument function-like macro defined as #define FOO(A, B) (A)(B)
|
||||
|
||||
46
src/link.zig
46
src/link.zig
@ -226,7 +226,7 @@ pub const File = struct {
|
||||
if (base.tag != T.base_tag)
|
||||
return null;
|
||||
|
||||
return @fieldParentPtr(T, "base", base);
|
||||
return @fieldParentPtr(*T, "base", base);
|
||||
}
|
||||
|
||||
pub fn makeWritable(base: *File) !void {
|
||||
@ -383,7 +383,7 @@ pub const File = struct {
|
||||
.c => unreachable,
|
||||
.nvptx => unreachable,
|
||||
inline else => |t| {
|
||||
return @fieldParentPtr(t.Type(), "base", base).lowerUnnamedConst(val, decl_index);
|
||||
return @fieldParentPtr(*t.Type(), "base", base).lowerUnnamedConst(val, decl_index);
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -402,7 +402,7 @@ pub const File = struct {
|
||||
.c => unreachable,
|
||||
.nvptx => unreachable,
|
||||
inline else => |t| {
|
||||
return @fieldParentPtr(t.Type(), "base", base).getGlobalSymbol(name, lib_name);
|
||||
return @fieldParentPtr(*t.Type(), "base", base).getGlobalSymbol(name, lib_name);
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -413,11 +413,11 @@ pub const File = struct {
|
||||
assert(decl.has_tv);
|
||||
switch (base.tag) {
|
||||
.c => {
|
||||
return @fieldParentPtr(C, "base", base).updateDecl(module, decl_index);
|
||||
return @fieldParentPtr(*C, "base", base).updateDecl(module, decl_index);
|
||||
},
|
||||
inline else => |tag| {
|
||||
if (build_options.only_c) unreachable;
|
||||
return @fieldParentPtr(tag.Type(), "base", base).updateDecl(module, decl_index);
|
||||
return @fieldParentPtr(*tag.Type(), "base", base).updateDecl(module, decl_index);
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -432,11 +432,11 @@ pub const File = struct {
|
||||
) UpdateDeclError!void {
|
||||
switch (base.tag) {
|
||||
.c => {
|
||||
return @fieldParentPtr(C, "base", base).updateFunc(module, func_index, air, liveness);
|
||||
return @fieldParentPtr(*C, "base", base).updateFunc(module, func_index, air, liveness);
|
||||
},
|
||||
inline else => |tag| {
|
||||
if (build_options.only_c) unreachable;
|
||||
return @fieldParentPtr(tag.Type(), "base", base).updateFunc(module, func_index, air, liveness);
|
||||
return @fieldParentPtr(*tag.Type(), "base", base).updateFunc(module, func_index, air, liveness);
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -447,11 +447,11 @@ pub const File = struct {
|
||||
switch (base.tag) {
|
||||
.spirv, .nvptx => {},
|
||||
.c => {
|
||||
return @fieldParentPtr(C, "base", base).updateDeclLineNumber(module, decl_index);
|
||||
return @fieldParentPtr(*C, "base", base).updateDeclLineNumber(module, decl_index);
|
||||
},
|
||||
inline else => |tag| {
|
||||
if (build_options.only_c) unreachable;
|
||||
return @fieldParentPtr(tag.Type(), "base", base).updateDeclLineNumber(module, decl_index);
|
||||
return @fieldParentPtr(*tag.Type(), "base", base).updateDeclLineNumber(module, decl_index);
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -473,11 +473,11 @@ pub const File = struct {
|
||||
base.releaseLock();
|
||||
if (base.file) |f| f.close();
|
||||
switch (base.tag) {
|
||||
.c => @fieldParentPtr(C, "base", base).deinit(),
|
||||
.c => @fieldParentPtr(*C, "base", base).deinit(),
|
||||
|
||||
inline else => |tag| {
|
||||
if (build_options.only_c) unreachable;
|
||||
@fieldParentPtr(tag.Type(), "base", base).deinit();
|
||||
@fieldParentPtr(*tag.Type(), "base", base).deinit();
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -560,7 +560,7 @@ pub const File = struct {
|
||||
pub fn flush(base: *File, arena: Allocator, prog_node: *std.Progress.Node) FlushError!void {
|
||||
if (build_options.only_c) {
|
||||
assert(base.tag == .c);
|
||||
return @fieldParentPtr(C, "base", base).flush(arena, prog_node);
|
||||
return @fieldParentPtr(*C, "base", base).flush(arena, prog_node);
|
||||
}
|
||||
const comp = base.comp;
|
||||
if (comp.clang_preprocessor_mode == .yes or comp.clang_preprocessor_mode == .pch) {
|
||||
@ -587,7 +587,7 @@ pub const File = struct {
|
||||
}
|
||||
switch (base.tag) {
|
||||
inline else => |tag| {
|
||||
return @fieldParentPtr(tag.Type(), "base", base).flush(arena, prog_node);
|
||||
return @fieldParentPtr(*tag.Type(), "base", base).flush(arena, prog_node);
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -597,11 +597,11 @@ pub const File = struct {
|
||||
pub fn flushModule(base: *File, arena: Allocator, prog_node: *std.Progress.Node) FlushError!void {
|
||||
switch (base.tag) {
|
||||
.c => {
|
||||
return @fieldParentPtr(C, "base", base).flushModule(arena, prog_node);
|
||||
return @fieldParentPtr(*C, "base", base).flushModule(arena, prog_node);
|
||||
},
|
||||
inline else => |tag| {
|
||||
if (build_options.only_c) unreachable;
|
||||
return @fieldParentPtr(tag.Type(), "base", base).flushModule(arena, prog_node);
|
||||
return @fieldParentPtr(*tag.Type(), "base", base).flushModule(arena, prog_node);
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -610,11 +610,11 @@ pub const File = struct {
|
||||
pub fn freeDecl(base: *File, decl_index: InternPool.DeclIndex) void {
|
||||
switch (base.tag) {
|
||||
.c => {
|
||||
@fieldParentPtr(C, "base", base).freeDecl(decl_index);
|
||||
@fieldParentPtr(*C, "base", base).freeDecl(decl_index);
|
||||
},
|
||||
inline else => |tag| {
|
||||
if (build_options.only_c) unreachable;
|
||||
@fieldParentPtr(tag.Type(), "base", base).freeDecl(decl_index);
|
||||
@fieldParentPtr(*tag.Type(), "base", base).freeDecl(decl_index);
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -636,11 +636,11 @@ pub const File = struct {
|
||||
) UpdateExportsError!void {
|
||||
switch (base.tag) {
|
||||
.c => {
|
||||
return @fieldParentPtr(C, "base", base).updateExports(module, exported, exports);
|
||||
return @fieldParentPtr(*C, "base", base).updateExports(module, exported, exports);
|
||||
},
|
||||
inline else => |tag| {
|
||||
if (build_options.only_c) unreachable;
|
||||
return @fieldParentPtr(tag.Type(), "base", base).updateExports(module, exported, exports);
|
||||
return @fieldParentPtr(*tag.Type(), "base", base).updateExports(module, exported, exports);
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -664,7 +664,7 @@ pub const File = struct {
|
||||
.spirv => unreachable,
|
||||
.nvptx => unreachable,
|
||||
inline else => |tag| {
|
||||
return @fieldParentPtr(tag.Type(), "base", base).getDeclVAddr(decl_index, reloc_info);
|
||||
return @fieldParentPtr(*tag.Type(), "base", base).getDeclVAddr(decl_index, reloc_info);
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -683,7 +683,7 @@ pub const File = struct {
|
||||
.spirv => unreachable,
|
||||
.nvptx => unreachable,
|
||||
inline else => |tag| {
|
||||
return @fieldParentPtr(tag.Type(), "base", base).lowerAnonDecl(decl_val, decl_align, src_loc);
|
||||
return @fieldParentPtr(*tag.Type(), "base", base).lowerAnonDecl(decl_val, decl_align, src_loc);
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -695,7 +695,7 @@ pub const File = struct {
|
||||
.spirv => unreachable,
|
||||
.nvptx => unreachable,
|
||||
inline else => |tag| {
|
||||
return @fieldParentPtr(tag.Type(), "base", base).getAnonDeclVAddr(decl_val, reloc_info);
|
||||
return @fieldParentPtr(*tag.Type(), "base", base).getAnonDeclVAddr(decl_val, reloc_info);
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -714,7 +714,7 @@ pub const File = struct {
|
||||
=> {},
|
||||
|
||||
inline else => |tag| {
|
||||
return @fieldParentPtr(tag.Type(), "base", base).deleteDeclExport(decl_index, name);
|
||||
return @fieldParentPtr(*tag.Type(), "base", base).deleteDeclExport(decl_index, name);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,28 +35,28 @@ pub const Node = struct {
|
||||
if (self.tag != T.base_tag) {
|
||||
return null;
|
||||
}
|
||||
return @fieldParentPtr(T, "base", self);
|
||||
return @fieldParentPtr(*const T, "base", self);
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Node, allocator: Allocator) void {
|
||||
switch (self.tag) {
|
||||
.doc => {
|
||||
const parent = @fieldParentPtr(Node.Doc, "base", self);
|
||||
const parent = @fieldParentPtr(*Node.Doc, "base", self);
|
||||
parent.deinit(allocator);
|
||||
allocator.destroy(parent);
|
||||
},
|
||||
.map => {
|
||||
const parent = @fieldParentPtr(Node.Map, "base", self);
|
||||
const parent = @fieldParentPtr(*Node.Map, "base", self);
|
||||
parent.deinit(allocator);
|
||||
allocator.destroy(parent);
|
||||
},
|
||||
.list => {
|
||||
const parent = @fieldParentPtr(Node.List, "base", self);
|
||||
const parent = @fieldParentPtr(*Node.List, "base", self);
|
||||
parent.deinit(allocator);
|
||||
allocator.destroy(parent);
|
||||
},
|
||||
.value => {
|
||||
const parent = @fieldParentPtr(Node.Value, "base", self);
|
||||
const parent = @fieldParentPtr(*Node.Value, "base", self);
|
||||
parent.deinit(allocator);
|
||||
allocator.destroy(parent);
|
||||
},
|
||||
@ -70,10 +70,10 @@ pub const Node = struct {
|
||||
writer: anytype,
|
||||
) !void {
|
||||
return switch (self.tag) {
|
||||
.doc => @fieldParentPtr(Node.Doc, "base", self).format(fmt, options, writer),
|
||||
.map => @fieldParentPtr(Node.Map, "base", self).format(fmt, options, writer),
|
||||
.list => @fieldParentPtr(Node.List, "base", self).format(fmt, options, writer),
|
||||
.value => @fieldParentPtr(Node.Value, "base", self).format(fmt, options, writer),
|
||||
.doc => @fieldParentPtr(*Node.Doc, "base", self).format(fmt, options, writer),
|
||||
.map => @fieldParentPtr(*Node.Map, "base", self).format(fmt, options, writer),
|
||||
.list => @fieldParentPtr(*Node.List, "base", self).format(fmt, options, writer),
|
||||
.value => @fieldParentPtr(*Node.Value, "base", self).format(fmt, options, writer),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ pub fn RegisterManager(
|
||||
pub const RegisterBitSet = StaticBitSet(tracked_registers.len);
|
||||
|
||||
fn getFunction(self: *Self) *Function {
|
||||
return @fieldParentPtr(Function, "register_manager", self);
|
||||
return @alignCast(@fieldParentPtr(*align(1) Function, "register_manager", self));
|
||||
}
|
||||
|
||||
fn excludeRegister(reg: Register, register_class: RegisterBitSet) bool {
|
||||
|
||||
@ -86,7 +86,7 @@ fn compare_headers(step: *std.Build.Step, prog_node: *std.Progress.Node) !void {
|
||||
const expected_fmt = "expected_{s}";
|
||||
|
||||
for (step.dependencies.items) |config_header_step| {
|
||||
const config_header = @fieldParentPtr(ConfigHeader, "step", config_header_step);
|
||||
const config_header = @fieldParentPtr(*ConfigHeader, "step", config_header_step);
|
||||
|
||||
const zig_header_path = config_header.output_file.path orelse @panic("Could not locate header file");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user