/src/WasmEdge/include/runtime/callingframe.h
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 | | //===-- wasmedge/runtime/callingframe.h - Calling frame definition --------===// |
5 | | // |
6 | | // Part of the WasmEdge Project. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | /// |
10 | | /// \file |
11 | | /// This file contains the definition of CallingFrame class. |
12 | | /// |
13 | | //===----------------------------------------------------------------------===// |
14 | | #pragma once |
15 | | |
16 | | #include "runtime/instance/module.h" |
17 | | |
18 | | namespace WasmEdge { |
19 | | |
20 | | namespace Executor { |
21 | | class Executor; |
22 | | } |
23 | | |
24 | | namespace Runtime { |
25 | | |
26 | | class CallingFrame { |
27 | | public: |
28 | | CallingFrame(Executor::Executor *E, |
29 | | const Instance::ModuleInstance *M) noexcept |
30 | 0 | : Exec(E), Module(M) {} |
31 | | |
32 | 0 | Executor::Executor *getExecutor() const noexcept { return Exec; } |
33 | 0 | const Instance::ModuleInstance *getModule() const noexcept { return Module; } |
34 | 0 | Instance::MemoryInstance *getMemoryByIndex(uint32_t Index) const noexcept { |
35 | 0 | if (Module == nullptr) { |
36 | 0 | return nullptr; |
37 | 0 | } |
38 | 0 | if (auto Res = Module->getMemory(Index); Res) { |
39 | 0 | return *Res; |
40 | 0 | } |
41 | 0 | return nullptr; |
42 | 0 | } |
43 | | |
44 | | private: |
45 | | Executor::Executor *Exec; |
46 | | const Instance::ModuleInstance *Module; |
47 | | }; |
48 | | |
49 | | } // namespace Runtime |
50 | | } // namespace WasmEdge |