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

Method validateCanonResourceDrop

lib/validator/component_validator.cpp:1411–1441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1409}
1410
1411Expect<void> Validator::validateCanonResourceDrop(
1412 const AST::Component::Canonical &Canon) noexcept {
1413 const uint32_t Idx = Canon.getIndex();
1414 const uint32_t TypeSpaceSize =
1415 CompCtx.getSortIndexSize(AST::Component::Sort::SortType::Type);
1416 // 1. Type index bounds.
1417 if (Idx >= TypeSpaceSize) {
1418 spdlog::error(ErrCode::Value::InvalidIndex);
1419 spdlog::error(
1420 " canon resource.drop: type index {} exceeds type index space size {}"sv,
1421 Idx, TypeSpaceSize);
1422 spdlog::error(ErrInfo::InfoAST(ASTNodeAttr::Comp_Canonical));
1423 return Unexpect(ErrCode::Value::InvalidIndex);
1424 }
1425 // 2. Type must be a resource type.
1426 if (!CompCtx.isResourceType(Idx)) {
1427 spdlog::error(ErrCode::Value::InvalidTypeReference);
1428 spdlog::error(
1429 " canon resource.drop: type index {} does not reference a resource"sv,
1430 Idx);
1431 spdlog::error(ErrInfo::InfoAST(ASTNodeAttr::Comp_Canonical));
1432 return Unexpect(ErrCode::Value::InvalidTypeReference);
1433 }
1434 // 3. resource.drop accepts both local and imported resources — no locality
1435 // check.
1436 // 4. Validate canonical options.
1437 EXPECTED_TRY(validateCanonOptions(Canon.getOpCode(), Canon.getOptions()));
1438 // 5. Allocate the resulting core func. Full signature tracking deferred.
1439 CompCtx.addCoreFunc();
1440 return {};
1441}
1442
1443Expect<void> Validator::validate(const AST::Component::Import &Im) noexcept {
1444 // Validation steps:

Callers

nothing calls this directly

Calls 10

InfoASTClass · 0.85
UnexpectFunction · 0.85
getOptionsMethod · 0.80
addCoreFuncMethod · 0.80
errorFunction · 0.50
EXPECTED_TRYFunction · 0.50
getIndexMethod · 0.45
getSortIndexSizeMethod · 0.45
isResourceTypeMethod · 0.45
getOpCodeMethod · 0.45

Tested by

no test coverage detected