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

Method loadCompositeType

lib/loader/ast/type.cpp:187–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187Expect<void> Loader::loadCompositeType(AST::CompositeType &CType) {
188 // Read the composite type flag.
189 EXPECTED_TRY(uint8_t B, FMgr.readByte().map_error([this](auto E) {
190 return logLoadError(E, FMgr.getLastOffset(), ASTNodeAttr::Type_Rec);
191 }));
192
193 // Read the compiste type by cases.
194 switch (static_cast<TypeCode>(B)) {
195 case TypeCode::Array: {
196 AST::FieldType FType;
197 EXPECTED_TRY(loadFieldType(FType));
198 CType.setArrayType(std::move(FType));
199 return {};
200 }
201 case TypeCode::Struct: {
202 std::vector<AST::FieldType> FList;
203 EXPECTED_TRY(loadVec<AST::SubType>(
204 FList, [this](AST::FieldType &FType) -> Expect<void> {
205 // The error code logging is handled.
206 return loadFieldType(FType);
207 }));
208 CType.setStructType(std::move(FList));
209 return {};
210 }
211 case TypeCode::Func: {
212 AST::FunctionType FuncType;
213 EXPECTED_TRY(loadType(FuncType));
214 CType.setFunctionType(std::move(FuncType));
215 return {};
216 }
217 default:
218 return logLoadError(ErrCode::Value::IntegerTooLong, FMgr.getLastOffset(),
219 ASTNodeAttr::Type_Rec);
220 }
221}
222
223// Load binary to construct Limit node. See "include/loader/loader.h".
224Expect<void> Loader::loadLimit(AST::Limit &Lim) {

Callers

nothing calls this directly

Calls 5

setArrayTypeMethod · 0.80
setStructTypeMethod · 0.80
setFunctionTypeMethod · 0.80
getLastOffsetMethod · 0.80
EXPECTED_TRYFunction · 0.70

Tested by

no test coverage detected