Runtime.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 void 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 std::string GetConfigDir();
  32. static const char *GetFrameworkVersion();
  33. static const MethodInfo* GetDelegateInvoke(Il2CppClass* klass);
  34. static Il2CppObject* DelegateInvoke(Il2CppDelegate *obj, void **params, Il2CppException **exc);
  35. static Il2CppObject* Invoke(const MethodInfo *method, void *obj, void **params, Il2CppException **exc);
  36. static Il2CppObject* InvokeWithThrow(const MethodInfo *method, void *obj, void **params);
  37. static Il2CppObject* InvokeConvertArgs(const MethodInfo *method, void *obj, Il2CppObject **params, int paramCount, Il2CppException **exc);
  38. static Il2CppObject* InvokeArray(const MethodInfo *method, void *obj, Il2CppArray *params, Il2CppException **exc);
  39. static void ObjectInit(Il2CppObject* object);
  40. static void ObjectInitException(Il2CppObject* object, Il2CppException **exc);
  41. static void SetUnhandledExceptionPolicy(Il2CppRuntimeUnhandledExceptionPolicy value);
  42. static const MethodInfo* GetGenericVirtualMethod(const MethodInfo* methodDefinition, const MethodInfo* inflatedMethod);
  43. static void RaiseExecutionEngineExceptionIfMethodIsNotFound(const MethodInfo* method);
  44. static void AlwaysRaiseExecutionEngineException(const MethodInfo* method);
  45. public:
  46. // internal
  47. static Il2CppRuntimeUnhandledExceptionPolicy GetUnhandledExceptionPolicy();
  48. static void UnhandledException(Il2CppException* exc);
  49. static void ClassInit(Il2CppClass *klass);
  50. static const char *GetBundledMachineConfig();
  51. static void RegisterBundledMachineConfig(const char *config_xml);
  52. private:
  53. static void CallUnhandledExceptionDelegate(Il2CppDomain* domain, Il2CppDelegate* delegate, Il2CppException* exc);
  54. static Il2CppObject* CreateUnhandledExceptionEventArgs(Il2CppException* exc);
  55. static void VerifyApiVersion();
  56. static inline void RaiseExecutionEngineExceptionIfMethodIsNotFound(const MethodInfo* method, const Il2CppGenericMethod* genericMethod)
  57. {
  58. if (method->methodPointer == NULL)
  59. RaiseExecutionEngineException(metadata::GenericMethod::GetFullName(genericMethod).c_str());
  60. }
  61. static inline void RaiseExecutionEngineException(const char* methodFullName)
  62. {
  63. 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()));
  64. }
  65. };
  66. } /* namespace vm */
  67. } /* namespace il2cpp */