| 185 | } |
| 186 | |
| 187 | Expect<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". |
| 224 | Expect<void> Loader::loadLimit(AST::Limit &Lim) { |
nothing calls this directly
no test coverage detected