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

Method loadSectionContent

include/loader/loader.h:330–357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328
329 template <typename T, typename ElemLoader>
330 Expect<void> loadSectionContent(T &Sec, ElemLoader &&Func) {
331 Sec.setStartOffset(FMgr.getOffset());
332 // Load the section size first.
333 EXPECTED_TRY(uint32_t SecSize, FMgr.readU32().map_error([this](auto E) {
334 return logLoadError(E, FMgr.getLastOffset(), NodeAttrFromAST<T>());
335 }));
336
337 // Check the remain file/buffer size.
338 if (unlikely(FMgr.getRemainSize() < SecSize)) {
339 return logLoadError(ErrCode::Value::LengthOutOfBounds,
340 FMgr.getLastOffset(), NodeAttrFromAST<T>());
341 }
342
343 // Set the section size.
344 Sec.setContentSize(SecSize);
345 auto StartOffset = FMgr.getOffset();
346
347 // Invoke the callback function.
348 EXPECTED_TRY(Func());
349
350 // Check the read size matches the section size.
351 auto EndOffset = FMgr.getOffset();
352 if (EndOffset - StartOffset != Sec.getContentSize()) {
353 return logLoadError(ErrCode::Value::SectionSizeMismatch, EndOffset,
354 NodeAttrFromAST<T>());
355 }
356 return {};
357 }
358
359 template <typename T, typename ElemLoader>
360 Expect<void> loadSectionContentVec(T &Sec, ElemLoader &&Func) {

Callers

nothing calls this directly

Calls 9

unlikelyFunction · 0.85
setStartOffsetMethod · 0.80
getRemainSizeMethod · 0.80
getLastOffsetMethod · 0.80
setContentSizeMethod · 0.80
getContentSizeMethod · 0.80
EXPECTED_TRYFunction · 0.50
FuncClass · 0.50
getOffsetMethod · 0.45

Tested by

no test coverage detected