WasmGlobal.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft Corporation and contributors. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #include "WasmReaderPch.h"
  6. #ifdef ENABLE_WASM
  7. namespace Wasm
  8. {
  9. Wasm::WasmConstLitNode WasmGlobal::GetConstInit() const
  10. {
  11. if (GetReferenceType() != GlobalReferenceTypes::Const)
  12. {
  13. throw WasmCompilationException(_u("Global must be initialized from a const to retrieve the const value"));
  14. }
  15. return m_init.cnst;
  16. }
  17. uint32 WasmGlobal::GetGlobalIndexInit() const
  18. {
  19. if (GetReferenceType() != GlobalReferenceTypes::LocalReference)
  20. {
  21. throw WasmCompilationException(_u("Global must be initialized from another global to retrieve its index"));
  22. }
  23. return m_init.var.num;
  24. }
  25. } // namespace Wasm
  26. #endif // ENABLE_WASM