diff options
| author | antlilja <liljaanton2001@gmail.com> | 2022-07-30 18:43:15 +0200 |
|---|---|---|
| committer | antlilja <liljaanton2001@gmail.com> | 2022-08-01 14:51:54 +0200 |
| commit | ab3b614a335ffac9eac4f824ee18fba262ad988e (patch) | |
| tree | 4851f9b4df1bbd93db44377625b78179dc2549eb /src/Module.zig | |
| parent | cd8070f94f6865959949dbcec6e0e32cd88bb544 (diff) | |
| download | zig-ab3b614a335ffac9eac4f824ee18fba262ad988e.tar.gz zig-ab3b614a335ffac9eac4f824ee18fba262ad988e.zip | |
Removed anytype_args field from Fn
anytype_args field was replaced with isAnytypeParam function.
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 21 |
1 files changed, 16 insertions, 5 deletions
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(); |
