MetadataCache.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #pragma once
  2. #include <stdint.h>
  3. #include <vector>
  4. #include "il2cpp-config.h"
  5. #include "Assembly.h"
  6. #include "metadata/Il2CppTypeVector.h"
  7. #include "il2cpp-class-internals.h"
  8. struct MethodInfo;
  9. struct Il2CppClass;
  10. struct Il2CppGenericContainer;
  11. struct Il2CppGenericContext;
  12. struct Il2CppGenericInst;
  13. struct Il2CppGenericMethod;
  14. struct Il2CppType;
  15. struct Il2CppString;
  16. namespace il2cpp
  17. {
  18. namespace vm
  19. {
  20. class LIBIL2CPP_CODEGEN_API MetadataCache
  21. {
  22. public:
  23. static void Register(const Il2CppCodeRegistration * const codeRegistration, const Il2CppMetadataRegistration * const metadataRegistration, const Il2CppCodeGenOptions* const codeGenOptions);
  24. static void Initialize();
  25. static void InitializeGCSafe();
  26. static Il2CppClass* GetGenericInstanceType(Il2CppClass* genericTypeDefinition, const il2cpp::metadata::Il2CppTypeVector& genericArgumentTypes);
  27. static const MethodInfo* GetGenericInstanceMethod(const MethodInfo* genericMethodDefinition, const Il2CppGenericContext* context);
  28. static const MethodInfo* GetGenericInstanceMethod(const MethodInfo* genericMethodDefinition, const il2cpp::metadata::Il2CppTypeVector& genericArgumentTypes);
  29. static const Il2CppGenericContext* GetMethodGenericContext(const MethodInfo* method);
  30. static const Il2CppGenericContainer* GetMethodGenericContainer(const MethodInfo* method);
  31. static const MethodInfo* GetGenericMethodDefinition(const MethodInfo* method);
  32. static Il2CppClass* GetPointerType(Il2CppClass* type);
  33. static Il2CppClass* GetWindowsRuntimeClass(const std::string& fullName);
  34. static const char* GetWindowsRuntimeClassName(const Il2CppClass* klass);
  35. static void AddPointerType(Il2CppClass* type, Il2CppClass* pointerType);
  36. static const Il2CppGenericInst* GetGenericInst(const Il2CppType* const* types, uint32_t typeCount);
  37. static const Il2CppGenericInst* GetGenericInst(const il2cpp::metadata::Il2CppTypeVector& types);
  38. static const Il2CppGenericMethod* GetGenericMethod(const MethodInfo* methodDefinition, const Il2CppGenericInst* classInst, const Il2CppGenericInst* methodInst);
  39. static InvokerMethod GetInvokerMethodPointer(const MethodInfo* methodDefinition, const Il2CppGenericContext* context);
  40. static Il2CppMethodPointer GetMethodPointer(const MethodInfo* methodDefinition, const Il2CppGenericContext* context);
  41. static Il2CppClass* GetTypeInfoFromTypeIndex(TypeIndex index);
  42. static const Il2CppType* GetIl2CppTypeFromIndex(TypeIndex index);
  43. static const MethodInfo* GetMethodInfoFromIndex(EncodedMethodIndex index);
  44. static const Il2CppGenericMethod* GetGenericMethodFromIndex(GenericMethodIndex index);
  45. static Il2CppString* GetStringLiteralFromIndex(StringLiteralIndex index);
  46. static const char* GetStringFromIndex(StringIndex index);
  47. static FieldInfo* GetFieldInfoFromIndex(EncodedMethodIndex index);
  48. static void InitializeMethodMetadata(uint32_t index);
  49. static Il2CppMethodPointer GetMethodPointerFromIndex(MethodIndex index);
  50. static InvokerMethod GetMethodInvokerFromIndex(MethodIndex index);
  51. static const Il2CppInteropData* GetInteropDataForType(const Il2CppType* type);
  52. static Il2CppMethodPointer GetReversePInvokeWrapperFromIndex(MethodIndex index);
  53. static Il2CppMethodPointer GetUnresolvedVirtualCallStub(const MethodInfo* method);
  54. static const Il2CppAssembly* GetAssemblyFromIndex(AssemblyIndex index);
  55. static const Il2CppAssembly* GetAssemblyByName(const std::string& name);
  56. static Il2CppImage* GetImageFromIndex(ImageIndex index);
  57. static Il2CppClass* GetTypeInfoFromTypeDefinitionIndex(TypeDefinitionIndex index);
  58. static const Il2CppTypeDefinition* GetTypeDefinitionFromIndex(TypeDefinitionIndex index);
  59. static TypeDefinitionIndex GetExportedTypeFromIndex(TypeDefinitionIndex index);
  60. static const Il2CppGenericContainer* GetGenericContainerFromIndex(GenericContainerIndex index);
  61. static const Il2CppGenericParameter* GetGenericParameterFromIndex(GenericParameterIndex index);
  62. static const Il2CppType* GetGenericParameterConstraintFromIndex(GenericParameterConstraintIndex index);
  63. static Il2CppClass* GetNestedTypeFromIndex(NestedTypeIndex index);
  64. static const Il2CppType* GetInterfaceFromIndex(InterfacesIndex index);
  65. static EncodedMethodIndex GetVTableMethodFromIndex(VTableIndex index);
  66. static Il2CppInterfaceOffsetPair GetInterfaceOffsetIndex(InterfaceOffsetIndex index);
  67. static const Il2CppRGCTXDefinition* GetRGCTXDefinitionFromIndex(RGCTXIndex index);
  68. static const Il2CppEventDefinition* GetEventDefinitionFromIndex(EventIndex index);
  69. static const Il2CppFieldDefinition* GetFieldDefinitionFromIndex(FieldIndex index);
  70. static const Il2CppFieldDefaultValue* GetFieldDefaultValueFromIndex(FieldIndex index);
  71. static const uint8_t* GetFieldDefaultValueDataFromIndex(FieldIndex index);
  72. static const Il2CppFieldDefaultValue* GetFieldDefaultValueForField(const FieldInfo* field);
  73. static const uint8_t* GetParameterDefaultValueDataFromIndex(ParameterIndex index);
  74. static const Il2CppParameterDefaultValue* GetParameterDefaultValueForParameter(const MethodInfo* method, const ParameterInfo* parameter);
  75. static int GetFieldMarshaledSizeForField(const FieldInfo* field);
  76. static const Il2CppMethodDefinition* GetMethodDefinitionFromIndex(MethodIndex index);
  77. static const MethodInfo* GetMethodInfoFromMethodDefinitionIndex(MethodIndex index);
  78. static const Il2CppPropertyDefinition* GetPropertyDefinitionFromIndex(PropertyIndex index);
  79. static const Il2CppParameterDefinition* GetParameterDefinitionFromIndex(ParameterIndex index);
  80. // returns the compiler computer field offset for type definition fields
  81. static int32_t GetFieldOffsetFromIndex(TypeIndex typeIndex, int32_t fieldIndexInType);
  82. static int32_t GetReferenceAssemblyIndexIntoAssemblyTable(int32_t referencedAssemblyTableIndex);
  83. static const TypeDefinitionIndex GetIndexForTypeDefinition(const Il2CppClass* typeDefinition);
  84. static const GenericParameterIndex GetIndexForGenericParameter(const Il2CppGenericParameter* genericParameter);
  85. static CustomAttributesCache* GenerateCustomAttributesCache(CustomAttributeIndex index);
  86. static CustomAttributeTypeCache* GenerateCustomAttributeTypeCache(CustomAttributeIndex index);
  87. typedef void(*WalkTypesCallback)(Il2CppClass* type, void* context);
  88. static void WalkPointerTypes(WalkTypesCallback callback, void* context);
  89. private:
  90. static void InitializeUnresolvedSignatureTable();
  91. static void InitializeStringLiteralTable();
  92. static void InitializeGenericMethodTable();
  93. static void InitializeWindowsRuntimeTypeNamesTables();
  94. };
  95. } // namespace vm
  96. } // namespace il2cpp