| 1331 | } |
| 1332 | |
| 1333 | Expect<void> Validator::validateCanonResourceNew( |
| 1334 | const AST::Component::Canonical &Canon) noexcept { |
| 1335 | const uint32_t Idx = Canon.getIndex(); |
| 1336 | const uint32_t TypeSpaceSize = |
| 1337 | CompCtx.getSortIndexSize(AST::Component::Sort::SortType::Type); |
| 1338 | // 1. Type index bounds. |
| 1339 | if (Idx >= TypeSpaceSize) { |
| 1340 | spdlog::error(ErrCode::Value::InvalidIndex); |
| 1341 | spdlog::error( |
| 1342 | " canon resource.new: type index {} exceeds type index space size {}"sv, |
| 1343 | Idx, TypeSpaceSize); |
| 1344 | spdlog::error(ErrInfo::InfoAST(ASTNodeAttr::Comp_Canonical)); |
| 1345 | return Unexpect(ErrCode::Value::InvalidIndex); |
| 1346 | } |
| 1347 | // 2. Type must be a resource type. |
| 1348 | if (!CompCtx.isResourceType(Idx)) { |
| 1349 | spdlog::error(ErrCode::Value::InvalidTypeReference); |
| 1350 | spdlog::error( |
| 1351 | " canon resource.new: type index {} does not reference a resource"sv, |
| 1352 | Idx); |
| 1353 | spdlog::error(ErrInfo::InfoAST(ASTNodeAttr::Comp_Canonical)); |
| 1354 | return Unexpect(ErrCode::Value::InvalidTypeReference); |
| 1355 | } |
| 1356 | // 3. Resource must be locally defined. |
| 1357 | if (!CompCtx.isLocalResource(Idx)) { |
| 1358 | spdlog::error(ErrCode::Value::InvalidTypeReference); |
| 1359 | spdlog::error( |
| 1360 | " canon resource.new: type index {} is not locally defined (imported or outer-aliased resources are not allowed)"sv, |
| 1361 | Idx); |
| 1362 | spdlog::error(ErrInfo::InfoAST(ASTNodeAttr::Comp_Canonical)); |
| 1363 | return Unexpect(ErrCode::Value::InvalidTypeReference); |
| 1364 | } |
| 1365 | // 4. Validate canonical options. |
| 1366 | EXPECTED_TRY(validateCanonOptions(Canon.getOpCode(), Canon.getOptions())); |
| 1367 | // 5. Allocate the resulting core func. Full signature tracking deferred. |
| 1368 | CompCtx.addCoreFunc(); |
| 1369 | return {}; |
| 1370 | } |
| 1371 | |
| 1372 | Expect<void> Validator::validateCanonResourceRep( |
| 1373 | const AST::Component::Canonical &Canon) noexcept { |
nothing calls this directly
no test coverage detected