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

Function makeCompWithImportedFunc

test/component/ComponentValidatorTest.cpp:1101–1119  ·  view source on GitHub ↗

Helper: build a Component with an imported component func (func index 0).

Source from the content-addressed store, hash-verified

1099
1100// Helper: build a Component with an imported component func (func index 0).
1101inline AST::Component::Component makeCompWithImportedFunc() {
1102 AST::Component::Component Comp;
1103 // Need a FuncType at type index 0.
1104 Comp.getSections().emplace_back();
1105 Comp.getSections().back().emplace<AST::Component::TypeSection>();
1106 auto &TypeSec =
1107 std::get<AST::Component::TypeSection>(Comp.getSections().back());
1108 TypeSec.getContent().emplace_back();
1109 TypeSec.getContent().back().setFuncType(AST::Component::FuncType());
1110 // Import a func of that type.
1111 Comp.getSections().emplace_back();
1112 Comp.getSections().back().emplace<AST::Component::ImportSection>();
1113 auto &ImpSec =
1114 std::get<AST::Component::ImportSection>(Comp.getSections().back());
1115 ImpSec.getContent().emplace_back();
1116 ImpSec.getContent().back().getName() = "f";
1117 ImpSec.getContent().back().getDesc().setFuncTypeIdx(0);
1118 return Comp;
1119}
1120
1121// Helper: build a Component with a resource (type 0), a FuncType (type 1),
1122// and a core func allocated via resource.new 0 (core func index 0).

Callers 1

TESTFunction · 0.85

Calls 7

FuncTypeClass · 0.85
getSectionsMethod · 0.80
backMethod · 0.80
setFuncTypeMethod · 0.80
setFuncTypeIdxMethod · 0.80
getContentMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected