From ab3b614a335ffac9eac4f824ee18fba262ad988e Mon Sep 17 00:00:00 2001 From: antlilja Date: Sat, 30 Jul 2022 18:43:15 +0200 Subject: Removed anytype_args field from Fn anytype_args field was replaced with isAnytypeParam function. --- src/Module.zig | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index b80e00ad59..625af7ca07 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -1464,12 +1464,8 @@ pub const Fn = struct { /// These never have .generic_poison for the Type /// because the Type is needed to pass to `Type.eql` and for inserting comptime arguments /// into the inst_map when analyzing the body of a generic function instantiation. - /// Instead, the is_anytype knowledge is communicated via `anytype_args`. + /// Instead, the is_anytype knowledge is communicated via `isAnytypeParam`. comptime_args: ?[*]TypedValue, - /// When comptime_args is null, this is undefined. Otherwise, this flags each - /// parameter and tells whether it is anytype. - /// TODO apply the same enhancement for param_names below to this field. - anytype_args: [*]bool, /// Precomputed hash for monomorphed_funcs. /// This is important because it may be accessed when resizing monomorphed_funcs @@ -1584,6 +1580,21 @@ pub const Fn = struct { } } + pub fn isAnytypeParam(func: Fn, mod: *Module, index: u32) bool { + const file = mod.declPtr(func.owner_decl).getFileScope(); + + const tags = file.zir.instructions.items(.tag); + + const param_body = file.zir.getParamBody(func.zir_body_inst); + const param = param_body[index]; + + return switch (tags[param]) { + .param, .param_comptime => false, + .param_anytype, .param_anytype_comptime => true, + else => unreachable, + }; + } + pub fn getParamName(func: Fn, mod: *Module, index: u32) [:0]const u8 { const file = mod.declPtr(func.owner_decl).getFileScope(); -- cgit v1.2.3