Runtime.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #pragma once
  2. #include <stdint.h>
  3. #include <vector>
  4. #include <string>
  5. #include "il2cpp-config.h"
  6. #include "il2cpp-metadata.h"
  7. #include "il2cpp-object-internals.h"
  8. #include "metadata/GenericMethod.h"
  9. #include "vm/Exception.h"
  10. #include "vm/Class.h"
  11. #include "vm/MetadataCache.h"
  12. #include "utils/StringUtils.h"
  13. struct Il2CppArray;
  14. struct Il2CppDelegate;
  15. struct Il2CppObject;
  16. struct MethodInfo;
  17. struct Il2CppClass;
  18. typedef void (*MetadataInitializerCleanupFunc)();
  19. namespace il2cpp
  20. {
  21. namespace vm
  22. {
  23. class LIBIL2CPP_CODEGEN_API Runtime
  24. {
  25. public:
  26. static bool Init(const char* domainName = "IL2CPP Root Domain");
  27. static void Shutdown();
  28. static bool IsShuttingDown();
  29. static void SetConfigDir(const char *path);
  30. static void SetConfigUtf16(const Il2CppChar* executablePath);
  31. static void SetConfig(const char* executablePath);
  32. static void SetUnityTlsInterface(const void* unitytlsInterface);
  33. static std::string GetConfigDir();
  34. static const void* GetUnityTlsInterface();
  35. static const char *GetFrameworkVersion();
  36. static const MethodInfo* GetDelegateInvoke(Il2CppClass* klass);
  37. static Il2CppObject* DelegateInvoke(Il2CppDelegate *obj, void **params, Il2CppException **exc);
  38. static Il2CppObject* Invoke(const MethodInfo *method, void *obj, void **params, Il2CppException **exc);
  39. static Il2CppObject* InvokeWithThrow(const MethodInfo *method, void *obj, void **params);
  40. static Il2CppObject* InvokeConvertArgs(const MethodInfo *method, void *obj, Il2CppObject **params, int paramCount, Il2CppException **exc);
  41. static Il2CppObject* InvokeArray(const MethodInfo *method, void *obj, Il2CppArray *params, Il2CppException **exc);
  42. static void ObjectInit(Il2CppObject* object);
  43. static void ObjectInitException(Il2CppObject* object, Il2CppException **exc);
  44. static void SetUnhandledExceptionPolicy(Il2CppRuntimeUnhandledExceptionPolicy value);
  45. static void AlwaysRaiseExecutionEngineException(const MethodInfo* method);
  46. static void AlwaysRaiseExecutionEngineExceptionOnVirtualCall(const MethodInfo* method);
  47. static inline bool IsFullGenericSharingEnabled()
  48. {
  49. return il2cpp_defaults.il2cpp_fully_shared_type != NULL;
  50. }
  51. static inline bool IsLazyRGCTXInflationEnabled()
  52. {
  53. return il2cpp_defaults.il2cpp_fully_shared_type != NULL;
  54. }
  55. public:
  56. // internal
  57. static Il2CppRuntimeUnhandledExceptionPolicy GetUnhandledExceptionPolicy();
  58. static void UnhandledException(Il2CppException* exc);
  59. static void ClassInit(Il2CppClass *klass);
  60. static const char *GetBundledMachineConfig();
  61. static void RegisterBundledMachineConfig(const char *config_xml);
  62. static int32_t GetExitCode();
  63. static void SetExitCode(int32_t value);
  64. static InvokerMethod GetMissingMethodInvoker();
  65. static void RaiseAmbiguousImplementationException(const MethodInfo* method);
  66. static void RaiseExecutionEngineException(const MethodInfo* method, bool virtualCall);
  67. static void RaiseExecutionEngineException(const MethodInfo* method, const char* methodFullName, bool virtualCall);
  68. #if IL2CPP_TINY
  69. static void FailFast(const std::string& message);
  70. #endif
  71. private:
  72. static void CallUnhandledExceptionDelegate(Il2CppDomain* domain, Il2CppDelegate* delegate, Il2CppException* exc);
  73. static Il2CppObject* CreateUnhandledExceptionEventArgs(Il2CppException* exc);
  74. static void VerifyApiVersion();
  75. };
  76. } /* namespace vm */
  77. } /* namespace il2cpp */