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