Coverage Report

Created: 2025-12-31 06:34

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/WasmEdge/include/runtime/instance/component/function.h
Line
Count
Source
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: 2019-2024 Second State INC
3
#pragma once
4
5
#include "ast/component/type.h"
6
#include "runtime/instance/function.h"
7
#include "runtime/instance/memory.h"
8
9
#include <memory>
10
11
namespace WasmEdge {
12
namespace Runtime {
13
namespace Instance {
14
namespace Component {
15
16
class FunctionInstance {
17
  // The component function instance currently can only be instantiated by the
18
  // `canon lift` operation. For the component host functions, the extension may
19
  // be implemented in the future.
20
public:
21
  FunctionInstance() = delete;
22
  /// Move constructor.
23
  FunctionInstance(FunctionInstance &&Inst) noexcept
24
      : FuncType(Inst.FuncType), LowerFunc(Inst.LowerFunc),
25
0
        MemInst(Inst.MemInst), ReallocFunc(Inst.ReallocFunc) {}
26
  /// Constructor for component native function.
27
  FunctionInstance(const AST::Component::FuncType &Type,
28
                   Runtime::Instance::FunctionInstance *F,
29
                   Runtime::Instance::MemoryInstance *M,
30
                   Runtime::Instance::FunctionInstance *R) noexcept
31
0
      : FuncType(Type), LowerFunc(F), MemInst(M), ReallocFunc(R) {}
32
33
  /// Getter of component function type.
34
0
  const AST::Component::FuncType &getFuncType() const noexcept {
35
0
    return FuncType;
36
0
  }
37
38
  /// Getter of lower core function instance.
39
0
  Runtime::Instance::FunctionInstance *getLowerFunction() const noexcept {
40
0
    return LowerFunc;
41
0
  }
42
43
  /// Getter of memory instance to value conversion.
44
0
  Runtime::Instance::MemoryInstance *getMemoryInstance() const noexcept {
45
0
    return MemInst;
46
0
  }
47
48
  /// Getter of allocation core function instance.
49
0
  Runtime::Instance::FunctionInstance *getAllocFunction() const noexcept {
50
0
    return ReallocFunc;
51
0
  }
52
53
protected:
54
  const AST::Component::FuncType &FuncType;
55
  Runtime::Instance::FunctionInstance *LowerFunc;
56
  Runtime::Instance::MemoryInstance *MemInst;
57
  Runtime::Instance::FunctionInstance *ReallocFunc;
58
};
59
60
} // namespace Component
61
} // namespace Instance
62
} // namespace Runtime
63
} // namespace WasmEdge