-
-
Notifications
You must be signed in to change notification settings - Fork 204
/
Cpp2IlMethodRef.cs
55 lines (44 loc) · 1.92 KB
/
Cpp2IlMethodRef.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System.Linq;
using System.Text;
using LibCpp2IL.BinaryStructures;
using LibCpp2IL.Metadata;
using LibCpp2IL.Reflection;
namespace LibCpp2IL;
public class Cpp2IlMethodRef(Il2CppMethodSpec methodSpec)
{
public Il2CppTypeDefinition DeclaringType => BaseMethod.DeclaringType!;
public Il2CppTypeReflectionData[] TypeGenericParams => methodSpec.GenericClassParams;
public Il2CppMethodDefinition BaseMethod => methodSpec.MethodDefinition!;
public Il2CppTypeReflectionData[] MethodGenericParams => methodSpec.GenericMethodParams;
public ulong GenericVariantPtr;
// var declaringTypeGenericParams = Array.Empty<Il2CppTypeReflectionData>();
// if (methodSpec.classIndexIndex != -1)
// {
// var classInst = methodSpec.GenericClassInst;
// declaringTypeGenericParams = LibCpp2ILUtils.GetGenericTypeParams(classInst!)!;
// }
//
// var genericMethodParameters = Array.Empty<Il2CppTypeReflectionData>();
// if (methodSpec.methodIndexIndex != -1)
// {
// var methodInst = methodSpec.GenericMethodInst;
// genericMethodParameters = LibCpp2ILUtils.GetGenericTypeParams(methodInst!)!;
// }
//
// BaseMethod = methodSpec.MethodDefinition!;
// DeclaringType = methodSpec.MethodDefinition!.DeclaringType!;
// TypeGenericParams = declaringTypeGenericParams;
// MethodGenericParams = genericMethodParameters;
public override string ToString()
{
var sb = new StringBuilder();
sb.Append(BaseMethod.ReturnType).Append(" ");
sb.Append(DeclaringType.FullName);
if (TypeGenericParams.Length > 0)
sb.Append("<").Append(string.Join(", ", TypeGenericParams.AsEnumerable())).Append(">");
sb.Append(".").Append(BaseMethod.Name);
if (MethodGenericParams.Length > 0)
sb.Append("<").Append(string.Join(", ", MethodGenericParams.AsEnumerable())).Append(">");
return sb.ToString();
}
}