Model: Add basic concrete generic method definitions from MethodSpecs
This commit is contained in:
@@ -91,10 +91,7 @@ namespace Il2CppInspector.Reflection
|
||||
if (!GenericMethods.ContainsKey(declaringType))
|
||||
GenericMethods.Add(declaringType, new List<MethodInfo>());
|
||||
|
||||
// TODO: Add generic method resolver here
|
||||
|
||||
// Get list of pointers to type parameters (both unresolved and concrete)
|
||||
var genericTypeArguments = ResolveGenericArguments(spec.methodIndexIndex);
|
||||
GenericMethods[declaringType].Add(new MethodInfo(this, spec, declaringType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ namespace Il2CppInspector.Reflection
|
||||
// Regular method
|
||||
: Name;
|
||||
|
||||
// Initialize a method from a method definition (MethodDef)
|
||||
protected MethodBase(Il2CppInspector pkg, int methodIndex, TypeInfo declaringType) : base(declaringType) {
|
||||
Definition = pkg.Methods[methodIndex];
|
||||
Index = methodIndex;
|
||||
@@ -141,6 +142,20 @@ namespace Il2CppInspector.Reflection
|
||||
DeclaredParameters.Add(new ParameterInfo(pkg, p, this));
|
||||
}
|
||||
|
||||
// Initialize a method from a concrete generic method (MethodSpec)
|
||||
protected MethodBase(Il2CppModel model, Il2CppMethodSpec spec, TypeInfo declaringType) : base(declaringType) {
|
||||
var methodDef = model.MethodsByDefinitionIndex[spec.methodDefinitionIndex];
|
||||
|
||||
Name = methodDef.Name;
|
||||
Attributes = methodDef.Attributes;
|
||||
|
||||
IsGenericMethod = true;
|
||||
genericArguments = model.ResolveGenericArguments(spec.methodIndexIndex);
|
||||
|
||||
// TODO: Substitute generic type arguments for concrete type arguments
|
||||
// TODO: Populate VirtualAddress via Il2CppGenericMethodFunctionsDefinitions
|
||||
}
|
||||
|
||||
public string GetAccessModifierString() => this switch {
|
||||
// Static constructors can not have an access level modifier
|
||||
{ IsConstructor: true, IsStatic: true } => "",
|
||||
|
||||
@@ -30,6 +30,14 @@ namespace Il2CppInspector.Reflection
|
||||
ReturnParameter = new ParameterInfo(pkg, -1, this);
|
||||
}
|
||||
|
||||
public MethodInfo(Il2CppModel model, Il2CppMethodSpec spec, TypeInfo declaringType) : base(model, spec, declaringType) {
|
||||
var methodDef = model.MethodsByDefinitionIndex[spec.methodDefinitionIndex];
|
||||
|
||||
// Add return parameter
|
||||
returnTypeReference = methodDef.Definition.returnType;
|
||||
ReturnParameter = ((MethodInfo) methodDef).ReturnParameter;
|
||||
}
|
||||
|
||||
public override string ToString() => ReturnType.Name + " " + Name + GetFullTypeParametersString() + "(" + string.Join(", ",
|
||||
DeclaredParameters.Select(x => x.ParameterType.IsByRef? x.ParameterType.Name.TrimEnd('&') + " ByRef" : x.ParameterType.Name)) + ")";
|
||||
|
||||
|
||||
@@ -95,6 +95,11 @@ namespace Il2CppInspector.Reflection
|
||||
}
|
||||
}
|
||||
|
||||
// Create a concrete type parameter from a generic type parameter
|
||||
public ParameterInfo(Il2CppModel model, ParameterInfo generic, TypeInfo concrete) {
|
||||
// TODO: Implement generic parameter substitution
|
||||
}
|
||||
|
||||
// ref will be handled as part of the type name
|
||||
public string GetModifierString() =>
|
||||
(IsIn ? "in " : "")
|
||||
|
||||
Reference in New Issue
Block a user