Load binary to construct SubType node. See "include/loader/loader.h".
| 303 | |
| 304 | // Load binary to construct SubType node. See "include/loader/loader.h". |
| 305 | Expect<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". |
| 342 | Expect<void> Loader::loadType(AST::FunctionType &FuncType) { |
nothing calls this directly
no test coverage detected