mirror of
https://github.com/Perfare/Il2CppDumper.git
synced 2025-01-09 19:27:17 -03:00
优化GenericParameter创建
This commit is contained in:
parent
d1e0b2bced
commit
b9fc241260
1 changed files with 15 additions and 26 deletions
|
@ -184,13 +184,9 @@ namespace Il2CppDumper
|
|||
for (int j = 0; j < genericContainer.type_argc; j++)
|
||||
{
|
||||
var genericParameterIndex = genericContainer.genericParameterStart + j;
|
||||
var param = metadata.genericParameters[genericParameterIndex];
|
||||
var genericName = metadata.GetStringFromIndex(param.nameIndex);
|
||||
if (!genericParameterDic.TryGetValue(genericParameterIndex, out var genericParameter))
|
||||
{
|
||||
genericParameter = new GenericParameter(genericName, methodDefinition);
|
||||
methodDefinition.GenericParameters.Add(genericParameter);
|
||||
genericParameterDic.Add(genericParameterIndex, genericParameter);
|
||||
CreateGenericParameter(genericParameterIndex, methodDefinition);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -275,13 +271,9 @@ namespace Il2CppDumper
|
|||
for (int i = 0; i < genericContainer.type_argc; i++)
|
||||
{
|
||||
var genericParameterIndex = genericContainer.genericParameterStart + i;
|
||||
var param = metadata.genericParameters[genericParameterIndex];
|
||||
var genericName = metadata.GetStringFromIndex(param.nameIndex);
|
||||
if (!genericParameterDic.TryGetValue(genericParameterIndex, out var genericParameter))
|
||||
{
|
||||
genericParameter = new GenericParameter(genericName, typeDefinition);
|
||||
typeDefinition.GenericParameters.Add(genericParameter);
|
||||
genericParameterDic.Add(genericParameterIndex, genericParameter);
|
||||
CreateGenericParameter(genericParameterIndex, typeDefinition);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -458,20 +450,12 @@ namespace Il2CppDumper
|
|||
{
|
||||
return genericParameter;
|
||||
}
|
||||
var param = metadata.genericParameters[il2CppType.data.genericParameterIndex];
|
||||
var genericName = metadata.GetStringFromIndex(param.nameIndex);
|
||||
if (memberReference is MethodDefinition methodDefinition)
|
||||
{
|
||||
genericParameter = new GenericParameter(genericName, methodDefinition.DeclaringType);
|
||||
methodDefinition.DeclaringType.GenericParameters.Add(genericParameter);
|
||||
genericParameterDic.Add(il2CppType.data.genericParameterIndex, genericParameter);
|
||||
return genericParameter;
|
||||
return CreateGenericParameter(il2CppType.data.genericParameterIndex, methodDefinition.DeclaringType);
|
||||
}
|
||||
var typeDefinition = (TypeDefinition)memberReference;
|
||||
genericParameter = new GenericParameter(genericName, typeDefinition);
|
||||
typeDefinition.GenericParameters.Add(genericParameter);
|
||||
genericParameterDic.Add(il2CppType.data.genericParameterIndex, genericParameter);
|
||||
return genericParameter;
|
||||
return CreateGenericParameter(il2CppType.data.genericParameterIndex, typeDefinition);
|
||||
}
|
||||
case Il2CppTypeEnum.IL2CPP_TYPE_MVAR:
|
||||
{
|
||||
|
@ -480,12 +464,7 @@ namespace Il2CppDumper
|
|||
return genericParameter;
|
||||
}
|
||||
var methodDefinition = (MethodDefinition)memberReference;
|
||||
var param = metadata.genericParameters[il2CppType.data.genericParameterIndex];
|
||||
var genericName = metadata.GetStringFromIndex(param.nameIndex);
|
||||
genericParameter = new GenericParameter(genericName, methodDefinition);
|
||||
methodDefinition.GenericParameters.Add(genericParameter);
|
||||
genericParameterDic.Add(il2CppType.data.genericParameterIndex, genericParameter);
|
||||
return genericParameter;
|
||||
return CreateGenericParameter(il2CppType.data.genericParameterIndex, methodDefinition);
|
||||
}
|
||||
case Il2CppTypeEnum.IL2CPP_TYPE_PTR:
|
||||
{
|
||||
|
@ -630,5 +609,15 @@ namespace Il2CppDumper
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private GenericParameter CreateGenericParameter(long genericParameterIndex, IGenericParameterProvider iGenericParameterProvider)
|
||||
{
|
||||
var param = metadata.genericParameters[genericParameterIndex];
|
||||
var genericName = metadata.GetStringFromIndex(param.nameIndex);
|
||||
var genericParameter = new GenericParameter(genericName, iGenericParameterProvider);
|
||||
iGenericParameterProvider.GenericParameters.Add(genericParameter);
|
||||
genericParameterDic.Add(genericParameterIndex, genericParameter);
|
||||
return genericParameter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue