-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
metadata/GenericMethod.cpp
std::string get_klsname(Il2CppClass *klass) {
char name[512]{0};
strcat(name, klass->name);
if (klass->generic_class) {
const Il2CppGenericInst* inst = klass->generic_class->context.class_inst;
for (int i = 0; i < inst->type_argc; ++i) {
Il2CppClass *inst_kls = Class::FromIl2CppType(inst->type_argv[i]);
if (i == 0) strcat(name, "<");
if (i != 0) strcat(name, ", ");
strcat(name, inst_kls->name);
if (i == inst->type_argc - 1) strcat(name, ">");
}
}
return name;
}
const MethodInfo* GenericMethod::CreateMethodLocked(const Il2CppGenericMethod* gmethod, bool copyMethodPtr)
{
// We need to inflate a new generic method, take the metadata mutex
// All code below this point can and does assume mutual exclusion
FastAutoLock lock(&il2cpp::vm::g_MetadataLock);
// Recheck the s_GenericMethodMap in case there was a race to add this generic method
MethodInfo* existingMethod;
if (s_GenericMethodMap.TryGet(gmethod, &existingMethod))
return existingMethod;
// GetMethodLocked may be called recursively, we keep tracking of pending inflations
if (s_PendingGenericMethodMap.TryGet(gmethod, &existingMethod))
return existingMethod;
if (copyMethodPtr)
gmethod = MetadataCache::GetGenericMethod(gmethod->methodDefinition, gmethod->context.class_inst, gmethod->context.method_inst);
const MethodInfo* methodDefinition = gmethod->methodDefinition;
Il2CppClass* declaringClass = methodDefinition->klass;
if (gmethod->context.class_inst)
{
Il2CppGenericClass* genericClassDeclaringType = GenericMetadata::GetGenericClass(methodDefinition->klass, gmethod->context.class_inst);
declaringClass = GenericClass::GetClass(genericClassDeclaringType);
// we may fail if we cannot construct generic type
if (!declaringClass)
return NULL;
}
//add by tp
auto loger = FLog::Get("generic_method");
loger->write("%s\t%s\n", get_klsname(declaringClass).c_str(), methodDefinition->name);
loger->flush();
//end addMetadata
Metadata
Assignees
Labels
No labels