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