/src/WasmEdge/include/runtime/instance/component/function.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 | | #pragma once |
4 | | |
5 | | #include "ast/instruction.h" |
6 | | #include "common/symbol.h" |
7 | | #include "runtime/component/hostfunc.h" |
8 | | |
9 | | #include <memory> |
10 | | #include <numeric> |
11 | | #include <string> |
12 | | #include <vector> |
13 | | |
14 | | namespace WasmEdge { |
15 | | namespace Runtime { |
16 | | namespace Instance { |
17 | | namespace Component { |
18 | | |
19 | | class FunctionInstance { |
20 | | public: |
21 | | FunctionInstance() = delete; |
22 | | /// Move constructor. |
23 | | FunctionInstance(FunctionInstance &&Inst) noexcept |
24 | 0 | : FuncType(Inst.FuncType), Data(std::move(Inst.Data)) {} |
25 | | |
26 | | FunctionInstance( |
27 | | std::unique_ptr<WasmEdge::Runtime::Component::HostFunctionBase> |
28 | | &&Func) noexcept |
29 | 0 | : FuncType(Func->getFuncType()), Data(std::move(Func)) {} |
30 | | |
31 | 0 | const AST::FunctionType &getFuncType() const noexcept { return FuncType; } |
32 | | |
33 | 0 | WasmEdge::Runtime::Component::HostFunctionBase &getHostFunc() const noexcept { |
34 | 0 | return *Data; |
35 | 0 | } |
36 | | |
37 | | private: |
38 | | AST::FunctionType FuncType; |
39 | | std::unique_ptr<WasmEdge::Runtime::Component::HostFunctionBase> Data; |
40 | | }; |
41 | | |
42 | | } // namespace Component |
43 | | } // namespace Instance |
44 | | } // namespace Runtime |
45 | | } // namespace WasmEdge |