Model: Add ParameterInfo.Definition and Index

This commit is contained in:
Katy Coe
2019-11-03 06:34:00 +01:00
parent 614f5c0e01
commit bec404d801

View File

@@ -11,6 +11,10 @@ namespace Il2CppInspector.Reflection
{ {
public class ParameterInfo public class ParameterInfo
{ {
// IL2CPP-specific data
public Il2CppParameterDefinition Definition { get; }
public int Index { get; }
// Information/flags about the parameter // Information/flags about the parameter
public ParameterAttributes Attributes { get; } public ParameterAttributes Attributes { get; }
@@ -42,6 +46,7 @@ namespace Il2CppInspector.Reflection
// Create a parameter. Specify paramIndex == -1 for a return type parameter // Create a parameter. Specify paramIndex == -1 for a return type parameter
public ParameterInfo(Il2CppInspector pkg, int paramIndex, MethodBase declaringMethod) { public ParameterInfo(Il2CppInspector pkg, int paramIndex, MethodBase declaringMethod) {
Index = paramIndex;
Member = declaringMethod; Member = declaringMethod;
if (paramIndex == -1) { if (paramIndex == -1) {
@@ -51,10 +56,10 @@ namespace Il2CppInspector.Reflection
return; return;
} }
var param = pkg.Params[paramIndex]; Definition = pkg.Params[Index];
Name = pkg.Strings[param.nameIndex]; Name = pkg.Strings[Definition.nameIndex];
Position = paramIndex - declaringMethod.Definition.parameterStart; Position = paramIndex - declaringMethod.Definition.parameterStart;
paramTypeUsage = param.typeIndex; paramTypeUsage = Definition.typeIndex;
var paramType = pkg.TypeUsages[paramTypeUsage]; var paramType = pkg.TypeUsages[paramTypeUsage];
if ((paramType.attrs & Il2CppConstants.PARAM_ATTRIBUTE_OPTIONAL) != 0) if ((paramType.attrs & Il2CppConstants.PARAM_ATTRIBUTE_OPTIONAL) != 0)