Add non-generic methods in generic types to GenericMethods

GenericMethods should contain all MethodSpec-referenced methods,
including those which are non-generic methods inside generic types. This
patch adds those methods, and also implements parameter substitution for
type arguments in parameters & return types.
This commit is contained in:
Robert Xiao
2020-04-11 17:57:46 -07:00
committed by Katy
parent 50ea6dac36
commit c73aad08b8
4 changed files with 32 additions and 32 deletions

View File

@@ -97,20 +97,29 @@ namespace Il2CppInspector.Reflection
}
// Create a concrete type parameter from a generic type parameter
public ParameterInfo(Il2CppModel model, ParameterInfo generic, TypeInfo concrete) {
public ParameterInfo(ParameterInfo generic, TypeInfo concrete) {
DeclaringMethod = generic.DeclaringMethod;
Name = generic.Name;
Position = generic.Position;
Attributes = generic.Attributes;
// TODO substitute concrete params?
paramTypeReference = TypeRef.FromTypeInfo(concrete);
DefaultValue = generic.DefaultValue;
DefaultValueMetadataAddress = generic.DefaultValueMetadataAddress;
}
public ParameterInfo SubstituteGenericArguments(TypeInfo[] typeArguments, TypeInfo[] methodArguments) {
/* TODO: Deep substitution */
if (ParameterType.IsGenericTypeParameter)
return new ParameterInfo(this, typeArguments[ParameterType.GenericParameterPosition]);
else if (ParameterType.IsGenericMethodParameter)
return new ParameterInfo(this, methodArguments[ParameterType.GenericParameterPosition]);
else
return this;
}
// ref will be handled as part of the type name
public string GetModifierString() =>
(IsIn && !IsOut ? "in " : "")