Model: Add basic concrete generic method definitions from MethodSpecs

This commit is contained in:
Katy Coe
2020-02-02 03:56:50 +01:00
parent e33206a360
commit d2cb63dc95
4 changed files with 29 additions and 4 deletions

View File

@@ -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 } => "",