| 385 | } |
| 386 | |
| 387 | std::set<FunctionDefinition const*, ASTNode::CompareByID> Type::operatorDefinitions( |
| 388 | Token _token, |
| 389 | ASTNode const& _scope, |
| 390 | bool _unary |
| 391 | ) const |
| 392 | { |
| 393 | if (!typeDefinition()) |
| 394 | return {}; |
| 395 | |
| 396 | std::set<FunctionDefinition const*, ASTNode::CompareByID> matchingDefinitions; |
| 397 | for (UsingForDirective const* directive: usingForDirectivesForType(*this, _scope)) |
| 398 | for (auto const& [identifierPath, operator_]: directive->functionsAndOperators()) |
| 399 | { |
| 400 | if (operator_ != _token) |
| 401 | continue; |
| 402 | |
| 403 | auto const& functionDefinition = dynamic_cast<FunctionDefinition const&>( |
| 404 | *identifierPath->annotation().referencedDeclaration |
| 405 | ); |
| 406 | auto const* functionType = dynamic_cast<FunctionType const*>( |
| 407 | functionDefinition.libraryFunction() ? functionDefinition.typeViaContractName() : functionDefinition.type() |
| 408 | ); |
| 409 | solAssert(functionType && !functionType->parameterTypes().empty()); |
| 410 | |
| 411 | size_t parameterCount = functionDefinition.parameterList().parameters().size(); |
| 412 | if (*this == *functionType->parameterTypes().front() && (_unary ? parameterCount == 1 : parameterCount == 2)) |
| 413 | matchingDefinitions.insert(&functionDefinition); |
| 414 | } |
| 415 | |
| 416 | return matchingDefinitions; |
| 417 | } |
| 418 | |
| 419 | MemberList::MemberMap Type::attachedFunctions(Type const& _type, ASTNode const& _scope) |
| 420 | { |
no test coverage detected