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

Method loadSection

lib/loader/ast/component/component_section.cpp:10–39  ·  view source on GitHub ↗

Load component core:module section. See "include/loader/loader.h".

Source from the content-addressed store, hash-verified

8
9// Load component core:module section. See "include/loader/loader.h".
10Expect<void> Loader::loadSection(AST::Component::CoreModuleSection &Sec) {
11 return loadSectionContent(Sec, [this, &Sec]() -> Expect<void> {
12 auto ReportError = [](auto E) {
13 spdlog::error(ErrInfo::InfoAST(ASTNodeAttr::Comp_Sec_CoreMod));
14 return E;
15 };
16 auto ExpectedSize = Sec.getContentSize();
17 auto StartOffset = FMgr.getOffset();
18
19 EXPECTED_TRY(auto Preamble, Loader::loadPreamble().map_error(ReportError));
20 auto &[WasmMagic, Ver] = Preamble;
21 if (unlikely(Ver != ModuleVersion)) {
22 return logLoadError(ErrCode::Value::MalformedVersion,
23 FMgr.getLastOffset(), ASTNodeAttr::Comp_Sec_CoreMod);
24 }
25 AST::Module &CoreMod = Sec.getContent();
26 CoreMod.getMagic() = WasmMagic;
27 CoreMod.getVersion() = Ver;
28
29 auto Offset = FMgr.getOffset();
30 if (unlikely(ExpectedSize < Offset - StartOffset)) {
31 return logLoadError(ErrCode::Value::UnexpectedEnd, FMgr.getLastOffset(),
32 ASTNodeAttr::Comp_Sec_CoreMod);
33 }
34
35 EXPECTED_TRY(loadModule(CoreMod, ExpectedSize - (Offset - StartOffset))
36 .map_error(ReportError));
37 return {};
38 });
39}
40
41// Load component core:instance section. See "include/loader/loader.h".
42Expect<void> Loader::loadSection(AST::Component::CoreInstanceSection &Sec) {

Callers

nothing calls this directly

Calls 10

InfoASTClass · 0.85
unlikelyFunction · 0.85
loadModuleFunction · 0.85
getContentSizeMethod · 0.80
getLastOffsetMethod · 0.80
EXPECTED_TRYFunction · 0.70
errorFunction · 0.50
getOffsetMethod · 0.45
getContentMethod · 0.45
getVersionMethod · 0.45

Tested by

no test coverage detected