il2cpp-vm-support.h 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include "il2cpp-config.h"
  3. // This file is a compile-time abstraction for VM support needed by code in the os and utils namespaces that is used by both the
  4. // libil2cpp and the libil2cpptiny runtimes. Code in those namespaces should never depend up on the vm namespace directly.
  5. #if RUNTIME_NONE // OS layer compiled with no runtime
  6. #define IL2CPP_VM_RAISE_EXCEPTION(exception) IL2CPP_ASSERT(0 && "This is not implemented without a VM runtime backend.")
  7. #define IL2CPP_VM_RAISE_COM_EXCEPTION(hresult, defaultToCOMException) IL2CPP_ASSERT(0 && "This is not implemented without a VM runtime backend.")
  8. #define IL2CPP_VM_RAISE_UNAUTHORIZED_ACCESS_EXCEPTION(message) IL2CPP_ASSERT(0 && message)
  9. #define IL2CPP_VM_RAISE_PLATFORM_NOT_SUPPORTED_EXCEPTION(message) IL2CPP_ASSERT(0 && message)
  10. #define IL2CPP_VM_RAISE_IF_FAILED(hresult, defaultToCOMException) IL2CPP_ASSERT(0 && "This is not implemented without a VM runtime backend.")
  11. #define IL2CPP_VM_STRING_EMPTY() NULL
  12. #define IL2CPP_VM_STRING_NEW_UTF16(value, length) NULL
  13. #define IL2CPP_VM_STRING_NEW_LEN(value, length) NULL
  14. #define IL2CPP_VM_NOT_SUPPORTED(func, reason) IL2CPP_ASSERT(0 && "This is not implemented without a VM runtime backend.")
  15. #define IL2CPP_VM_NOT_IMPLEMENTED(func) IL2CPP_ASSERT(0 && "This is not implemented without a VM runtime backend.")
  16. #define IL2CPP_VM_METHOD_METADATA_FROM_METHOD_KEY(key) IL2CPP_ASSERT(0 && "This is not implemented wihout a VM runtime backend.")
  17. #define IL2CPP_VM_GET_CREATE_CCW_EXCEPTION(ex) NULL
  18. #define IL2CPP_VM_PROFILE_FILEIO(kind, count) NULL
  19. #elif RUNTIME_TINY
  20. #include "vm/StackTrace.h"
  21. #include "vm/DebugMetadata.h"
  22. #define IL2CPP_VM_RAISE_COM_EXCEPTION(hresult, defaultToCOMException) IL2CPP_ASSERT(0 && "This is not implemented without a VM runtime backend.")
  23. #define IL2CPP_VM_NOT_SUPPORTED(func, reason) IL2CPP_ASSERT(0 && "This is not implemented without a VM runtime backend.")
  24. #if IL2CPP_TINY_DEBUG_METADATA
  25. #define IL2CPP_VM_METHOD_METADATA_FROM_METHOD_KEY(key) tiny::vm::DebugMetadata::GetMethodNameFromMethodDefinitionIndex(key->methodIndex)
  26. #else
  27. #define IL2CPP_VM_METHOD_METADATA_FROM_METHOD_KEY(key) NULL
  28. #endif
  29. typedef TinyMethod VmMethod;
  30. #else // Assume the libil2cpp runtime
  31. #include "vm/Exception.h"
  32. #include "vm/MetadataCache.h"
  33. #include "vm/StackTrace.h"
  34. #include "vm/String.h"
  35. #include "vm/Profiler.h"
  36. #define IL2CPP_VM_RAISE_EXCEPTION(exception) il2cpp::vm::Exception::Raise(exception)
  37. #define IL2CPP_VM_RAISE_COM_EXCEPTION(hresult, defaultToCOMException) il2cpp::vm::Exception::Raise(hresult, defaultToCOMException)
  38. #define IL2CPP_VM_RAISE_UNAUTHORIZED_ACCESS_EXCEPTION(message) il2cpp::vm::Exception::Raise(il2cpp::vm::Exception::GetUnauthorizedAccessException(message))
  39. #define IL2CPP_VM_RAISE_PLATFORM_NOT_SUPPORTED_EXCEPTION(message) il2cpp::vm::Exception::Raise(il2cpp::vm::Exception::GetPlatformNotSupportedException(message))
  40. #define IL2CPP_VM_RAISE_IF_FAILED(hresult, defaultToCOMException) il2cpp::vm::Exception::RaiseIfFailed(hresult, defaultToCOMException)
  41. #define IL2CPP_VM_STRING_EMPTY() il2cpp::vm::String::Empty()
  42. #define IL2CPP_VM_STRING_NEW_UTF16(value, length) il2cpp::vm::String::NewUtf16(value, length)
  43. #define IL2CPP_VM_STRING_NEW_LEN(value, length) il2cpp::vm::String::NewLen(value, length)
  44. #define IL2CPP_VM_NOT_SUPPORTED(func, reason) NOT_SUPPORTED_IL2CPP(func, reason)
  45. #define IL2CPP_VM_NOT_IMPLEMENTED(func) IL2CPP_NOT_IMPLEMENTED_ICALL(func)
  46. #define IL2CPP_VM_METHOD_METADATA_FROM_METHOD_KEY(key) il2cpp::vm::MetadataCache::GetMethodInfoFromMethodHandle (key->methodHandle)
  47. #define IL2CPP_VM_GET_CREATE_CCW_EXCEPTION(ex) vm::CCW::GetOrCreate(reinterpret_cast<Il2CppObject*>(ex), Il2CppIUnknown::IID)
  48. #define IL2CPP_VM_PROFILE_FILEIO(kind, count) if (il2cpp::vm::Profiler::ProfileFileIO()) il2cpp::vm::Profiler::FileIO(kind, count);
  49. typedef Il2CppString VmString;
  50. typedef MethodInfo VmMethod;
  51. #endif