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

Method loadOption

include/loader/loader.h:487–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

485 Expect<void> loadType(AST::Component::LabelValType &Ty);
486 template <typename ASTType, typename T>
487 Expect<std::optional<T>> loadOption(std::function<Expect<void>(T &)> F) {
488 EXPECTED_TRY(uint8_t Flag, FMgr.readByte().map_error([this](auto E) {
489 return logLoadError(E, FMgr.getLastOffset(), NodeAttrFromAST<ASTType>());
490 }));
491 switch (Flag) {
492 case 0x01: {
493 T V;
494 EXPECTED_TRY(F(V).map_error([](auto E) {
495 spdlog::error(ErrInfo::InfoAST(NodeAttrFromAST<ASTType>()));
496 return E;
497 }));
498 return std::optional<T>(V);
499 }
500 case 0x00:
501 return std::nullopt;
502 default:
503 return logLoadError(ErrCode::Value::MalformedDefType,
504 FMgr.getLastOffset(), NodeAttrFromAST<ASTType>());
505 }
506 }
507 /// @}
508
509 /// \name Loader members

Callers

nothing calls this directly

Calls 5

FClass · 0.85
InfoASTClass · 0.85
getLastOffsetMethod · 0.80
EXPECTED_TRYFunction · 0.50
errorFunction · 0.50

Tested by

no test coverage detected