| 1370 | } |
| 1371 | |
| 1372 | Expect<void> Validator::validateCanonResourceRep( |
| 1373 | const AST::Component::Canonical &Canon) noexcept { |
| 1374 | const uint32_t Idx = Canon.getIndex(); |
| 1375 | const uint32_t TypeSpaceSize = |
| 1376 | CompCtx.getSortIndexSize(AST::Component::Sort::SortType::Type); |
| 1377 | // 1. Type index bounds. |
| 1378 | if (Idx >= TypeSpaceSize) { |
| 1379 | spdlog::error(ErrCode::Value::InvalidIndex); |
| 1380 | spdlog::error( |
| 1381 | " canon resource.rep: type index {} exceeds type index space size {}"sv, |
| 1382 | Idx, TypeSpaceSize); |
| 1383 | spdlog::error(ErrInfo::InfoAST(ASTNodeAttr::Comp_Canonical)); |
| 1384 | return Unexpect(ErrCode::Value::InvalidIndex); |
| 1385 | } |
| 1386 | // 2. Type must be a resource type. |
| 1387 | if (!CompCtx.isResourceType(Idx)) { |
| 1388 | spdlog::error(ErrCode::Value::InvalidTypeReference); |
| 1389 | spdlog::error( |
| 1390 | " canon resource.rep: type index {} does not reference a resource"sv, |
| 1391 | Idx); |
| 1392 | spdlog::error(ErrInfo::InfoAST(ASTNodeAttr::Comp_Canonical)); |
| 1393 | return Unexpect(ErrCode::Value::InvalidTypeReference); |
| 1394 | } |
| 1395 | // 3. Resource must be locally defined. |
| 1396 | if (!CompCtx.isLocalResource(Idx)) { |
| 1397 | spdlog::error(ErrCode::Value::InvalidTypeReference); |
| 1398 | spdlog::error( |
| 1399 | " canon resource.rep: type index {} is not locally defined (imported or outer-aliased resources are not allowed)"sv, |
| 1400 | Idx); |
| 1401 | spdlog::error(ErrInfo::InfoAST(ASTNodeAttr::Comp_Canonical)); |
| 1402 | return Unexpect(ErrCode::Value::InvalidTypeReference); |
| 1403 | } |
| 1404 | // 4. Validate canonical options. |
| 1405 | EXPECTED_TRY(validateCanonOptions(Canon.getOpCode(), Canon.getOptions())); |
| 1406 | // 5. Allocate the resulting core func. Full signature tracking deferred. |
| 1407 | CompCtx.addCoreFunc(); |
| 1408 | return {}; |
| 1409 | } |
| 1410 | |
| 1411 | Expect<void> Validator::validateCanonResourceDrop( |
| 1412 | const AST::Component::Canonical &Canon) noexcept { |
nothing calls this directly
no test coverage detected