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

Method serializeSegment

lib/loader/serialize/serial_segment.cpp:10–30  ·  view source on GitHub ↗

Serialize table segment. See "include/loader/serialize.h".

Source from the content-addressed store, hash-verified

8
9// Serialize table segment. See "include/loader/serialize.h".
10Expect<void>
11Serializer::serializeSegment(const AST::TableSegment &Seg,
12 std::vector<uint8_t> &OutVec) const noexcept {
13 // Table segment: tabletype + expr.
14 if (Seg.getExpr().getInstrs().size() > 0) {
15 if (!Conf.hasProposal(Proposal::FunctionReferences)) {
16 return logNeedProposal(ErrCode::Value::MalformedTable,
17 Proposal::FunctionReferences,
18 ASTNodeAttr::Seg_Table);
19 }
20 OutVec.push_back(0x40);
21 OutVec.push_back(0x00);
22 }
23 return Expect<void>{}
24 .and_then([&]() { return serializeType(Seg.getTableType(), OutVec); })
25 .and_then([&]() { return serializeExpression(Seg.getExpr(), OutVec); })
26 .map_error([](auto E) {
27 spdlog::error(ErrInfo::InfoAST(ASTNodeAttr::Seg_Table));
28 return E;
29 });
30}
31
32// Serialize global segment. See "include/loader/serialize.h".
33Expect<void>

Callers

nothing calls this directly

Calls 15

InfoASTClass · 0.85
hasProposalMethod · 0.80
getInitExprsMethod · 0.80
insertMethod · 0.80
errorFunction · 0.50
EXPECTED_TRYFunction · 0.50
sizeMethod · 0.45
getInstrsMethod · 0.45
getModeMethod · 0.45
getIdxMethod · 0.45
getOpCodeMethod · 0.45
getTargetIndexMethod · 0.45

Tested by

no test coverage detected