MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / HostFunctionBase

Class HostFunctionBase

include/runtime/hostfunc.h:30–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28class CallingFrame;
29
30class HostFunctionBase {
31public:
32 HostFunctionBase() = delete;
33 HostFunctionBase(const uint64_t FuncCost)
34 : DefType(AST::FunctionType()), Cost(FuncCost) {}
35 virtual ~HostFunctionBase() = default;
36
37 /// Run host function body.
38 virtual Expect<void> run(const CallingFrame &CallFrame,
39 Span<const ValVariant> Args,
40 Span<ValVariant> Rets) = 0;
41
42 /// Getter for function type.
43 const AST::FunctionType &getFuncType() const noexcept {
44 return DefType.getCompositeType().getFuncType();
45 }
46
47 /// Getter for host function cost.
48 uint64_t getCost() const { return Cost; }
49
50 /// Getter for defined type.
51 const AST::SubType &getDefinedType() const noexcept { return DefType; }
52
53protected:
54 AST::SubType DefType;
55 const uint64_t Cost;
56};
57
58template <typename T> class HostFunction : public HostFunctionBase {
59public:

Callers 1

wasmedge.cppFile · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected