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

Method loadType

lib/loader/ast/type.cpp:305–339  ·  view source on GitHub ↗

Load binary to construct SubType node. See "include/loader/loader.h".

Source from the content-addressed store, hash-verified

303
304// Load binary to construct SubType node. See "include/loader/loader.h".
305Expect<void> Loader::loadType(AST::SubType &SType) {
306 // Pick the first byte for sub type.
307 EXPECTED_TRY(uint8_t B, FMgr.peekByte().map_error([this](auto E) {
308 return logLoadError(E, FMgr.getLastOffset(), ASTNodeAttr::Type_Rec);
309 }));
310
311 switch (static_cast<TypeCode>(B)) {
312 default:
313 // Case: comptype.
314 SType.setFinal(true);
315 return loadCompositeType(SType.getCompositeType());
316 case TypeCode::Sub:
317 // Case: 0x50 vec(typeidx) comptype.
318 SType.setFinal(false);
319 break;
320 case TypeCode::SubFinal:
321 // Case: 0x4F vec(typeidx) comptype.
322 SType.setFinal(true);
323 break;
324 }
325 FMgr.readByte();
326
327 // Read the super type indices.
328 auto LoadNum = [this](uint32_t &Idx) -> Expect<void> {
329 EXPECTED_TRY(uint32_t Num, FMgr.readU32().map_error([this](auto E) {
330 return logLoadError(E, FMgr.getLastOffset(), ASTNodeAttr::Type_Rec);
331 }));
332 Idx = Num;
333 return {};
334 };
335 EXPECTED_TRY(loadVec<AST::SubType>(SType.getSuperTypeIndices(), LoadNum));
336
337 // Read the composite type.
338 return loadCompositeType(SType.getCompositeType());
339}
340
341// Load binary to construct FunctionType node. See "include/loader/loader.h".
342Expect<void> Loader::loadType(AST::FunctionType &FuncType) {

Callers

nothing calls this directly

Calls 13

InfoASTClass · 0.85
unlikelyFunction · 0.85
setFinalMethod · 0.80
readByteMethod · 0.80
getSuperTypeIndicesMethod · 0.80
getParamTypesMethod · 0.80
getLastOffsetMethod · 0.80
setTypeIdxMethod · 0.80
EXPECTED_TRYFunction · 0.70
errorFunction · 0.50
setRefTypeMethod · 0.45
setValTypeMethod · 0.45

Tested by

no test coverage detected