Method boilerplate code / minor re-factoring

This commit is contained in:
Katy Coe
2017-11-08 01:59:26 +01:00
parent 5e652606b2
commit e1fa8c8bfd
5 changed files with 125 additions and 23 deletions

View File

@@ -10,10 +10,40 @@ namespace Il2CppInspector.Reflection
{
public class MethodInfo : MethodBase
{
// TODO
// IL2CPP-specific data
public Il2CppMethodDefinition Definition { get; }
public int Index { get; }
public uint VirtualAddress { get; }
public override MemberTypes MemberType => MemberTypes.Method;
// Info about the return parameter
public ParameterInfo ReturnParameter { get; }
// Return type of the method
private readonly Il2CppType returnType;
public TypeInfo ReturnType => Assembly.Model.GetType(returnType, MemberTypes.TypeInfo);
// TODO: ReturnTypeCustomAttributes
public MethodInfo(Il2CppInspector pkg, int methodIndex, TypeInfo declaringType) :
base(declaringType) { }
base(declaringType) {
Definition = pkg.Metadata.Methods[methodIndex];
Index = methodIndex;
VirtualAddress = pkg.Binary.MethodPointers[methodIndex];
Name = pkg.Strings[Definition.nameIndex];
returnType = pkg.TypeUsages[Definition.returnType];
if ((Definition.flags & DefineConstants.METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == DefineConstants.METHOD_ATTRIBUTE_PRIVATE)
Attributes |= MethodAttributes.Private;
if ((Definition.flags & DefineConstants.METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == DefineConstants.METHOD_ATTRIBUTE_PUBLIC)
Attributes |= MethodAttributes.Public;
if ((Definition.flags & DefineConstants.METHOD_ATTRIBUTE_VIRTUAL) != 0)
Attributes |= MethodAttributes.Virtual;
if ((Definition.flags & DefineConstants.METHOD_ATTRIBUTE_STATIC) != 0)
Attributes |= MethodAttributes.Static;
}
}
}