/src/WasmEdge/lib/executor/engine/variableInstr.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | // SPDX-License-Identifier: Apache-2.0 |
2 | | // SPDX-FileCopyrightText: 2019-2024 Second State INC |
3 | | |
4 | | #include "executor/executor.h" |
5 | | |
6 | | #include <cstdint> |
7 | | |
8 | | namespace WasmEdge { |
9 | | namespace Executor { |
10 | | |
11 | | Expect<void> Executor::runLocalGetOp(Runtime::StackManager &StackMgr, |
12 | 0 | uint32_t StackOffset) const noexcept { |
13 | 0 | StackMgr.push(StackMgr.getTopN(StackOffset)); |
14 | 0 | return {}; |
15 | 0 | } |
16 | | |
17 | | Expect<void> Executor::runLocalSetOp(Runtime::StackManager &StackMgr, |
18 | 0 | uint32_t StackOffset) const noexcept { |
19 | 0 | StackMgr.getTopN(StackOffset - 1) = StackMgr.pop(); |
20 | 0 | return {}; |
21 | 0 | } |
22 | | |
23 | | Expect<void> Executor::runLocalTeeOp(Runtime::StackManager &StackMgr, |
24 | 0 | uint32_t StackOffset) const noexcept { |
25 | 0 | const ValVariant &Val = StackMgr.getTop(); |
26 | 0 | StackMgr.getTopN(StackOffset) = Val; |
27 | 0 | return {}; |
28 | 0 | } |
29 | | |
30 | | Expect<void> Executor::runGlobalGetOp(Runtime::StackManager &StackMgr, |
31 | 0 | uint32_t Idx) const noexcept { |
32 | 0 | auto *GlobInst = getGlobInstByIdx(StackMgr, Idx); |
33 | 0 | assuming(GlobInst); |
34 | 0 | StackMgr.push(GlobInst->getValue()); |
35 | 0 | return {}; |
36 | 0 | } |
37 | | |
38 | | Expect<void> Executor::runGlobalSetOp(Runtime::StackManager &StackMgr, |
39 | 0 | uint32_t Idx) const noexcept { |
40 | 0 | auto *GlobInst = getGlobInstByIdx(StackMgr, Idx); |
41 | 0 | assuming(GlobInst); |
42 | 0 | GlobInst->setValue(StackMgr.pop()); |
43 | 0 | return {}; |
44 | 0 | } |
45 | | |
46 | | } // namespace Executor |
47 | | } // namespace WasmEdge |