Removed anytype_args field from Fn

anytype_args field was replaced with isAnytypeParam function.
This commit is contained in:
antlilja
2022-07-30 18:43:15 +02:00
parent cd8070f94f
commit ab3b614a33
2 changed files with 18 additions and 14 deletions

View File

@@ -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();