Runtime.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. namespace il2cpp
  19. {
  20. namespace vm
  21. {
  22. class LIBIL2CPP_CODEGEN_API Runtime
  23. {
  24. public:
  25. static bool Init(const char* filename, const char *runtime_version);
  26. static void Shutdown();
  27. static bool IsShuttingDown();
  28. static void SetConfigDir(const char *path);
  29. static void SetConfigUtf16(const Il2CppChar* executablePath);
  30. static void SetConfig(const char* executablePath);
  31. static void SetUnityTlsInterface(const void* unitytlsInterface);
  32. static std::string GetConfigDir();
  33. static const void* GetUnityTlsInterface();
  34. static const char *GetFrameworkVersion();
  35. static const MethodInfo* GetDelegateInvoke(Il2CppClass* klass);
  36. static Il2CppObject* DelegateInvoke(Il2CppDelegate *obj, void **params, Il2CppException **exc);
  37. static Il2CppObject* Invoke(const MethodInfo *method, void *obj, void **params, Il2CppException **exc);
  38. static Il2CppObject* InvokeWithThrow(const MethodInfo *method, void *obj, void **params);
  39. static Il2CppObject* InvokeConvertArgs(const MethodInfo *method, void *obj, Il2CppObject **params, int paramCount, Il2CppException **exc);
  40. static Il2CppObject* InvokeArray(const MethodInfo *method, void *obj, Il2CppArray *params, Il2CppException **exc);
  41. static void ObjectInit(Il2CppObject* object);
  42. static void ObjectInitException(Il2CppObject* object, Il2CppException **exc);
  43. static void SetUnhandledExceptionPolicy(Il2CppRuntimeUnhandledExceptionPolicy value);
  44. static const MethodInfo* GetGenericVirtualMethod(const MethodInfo* methodDefinition, const MethodInfo* inflatedMethod);
  45. static void RaiseExecutionEngineExceptionIfMethodIsNotFound(const MethodInfo* method);
  46. static void AlwaysRaiseExecutionEngineException(const MethodInfo* method);
  47. public:
  48. // internal
  49. static Il2CppRuntimeUnhandledExceptionPolicy GetUnhandledExceptionPolicy();
  50. static void UnhandledException(Il2CppException* exc);
  51. static void ClassInit(Il2CppClass *klass);
  52. static const char *GetBundledMachineConfig();
  53. static void RegisterBundledMachineConfig(const char *config_xml);
  54. static int32_t GetExitCode();
  55. static void SetExitCode(int32_t value);
  56. private:
  57. static void CallUnhandledExceptionDelegate(Il2CppDomain* domain, Il2CppDelegate* delegate, Il2CppException* exc);
  58. static Il2CppObject* CreateUnhandledExceptionEventArgs(Il2CppException* exc);
  59. static void VerifyApiVersion();
  60. static inline void RaiseExecutionEngineExceptionIfMethodIsNotFound(const MethodInfo* method, const Il2CppGenericMethod* genericMethod)
  61. {
  62. if (method->methodPointer == NULL)
  63. RaiseExecutionEngineException(metadata::GenericMethod::GetFullName(genericMethod).c_str());
  64. }
  65. static inline void RaiseExecutionEngineException(const char* methodFullName)
  66. {
  67. Exception::Raise(Exception::GetExecutionEngineException(utils::StringUtils::Printf("Attempting to call method '%s' for which no ahead of time (AOT) code was generated.", methodFullName).c_str()));
  68. }
  69. };
  70. } /* namespace vm */
  71. } /* namespace il2cpp */