| 3537 | } |
| 3538 | |
| 3539 | bool FunctionType::canTakeArguments( |
| 3540 | FuncCallArguments const& _arguments, |
| 3541 | Type const* _selfType |
| 3542 | ) const |
| 3543 | { |
| 3544 | solAssert(!hasBoundFirstArgument() || _selfType, ""); |
| 3545 | if (hasBoundFirstArgument() && !_selfType->isImplicitlyConvertibleTo(*selfType())) |
| 3546 | return false; |
| 3547 | TypePointers paramTypes = parameterTypes(); |
| 3548 | std::vector<std::string> const paramNames = parameterNames(); |
| 3549 | |
| 3550 | if (takesArbitraryParameters()) |
| 3551 | return true; |
| 3552 | else if (_arguments.numArguments() != paramTypes.size()) |
| 3553 | return false; |
| 3554 | else if (!_arguments.hasNamedArguments()) |
| 3555 | return equal( |
| 3556 | _arguments.types.cbegin(), |
| 3557 | _arguments.types.cend(), |
| 3558 | paramTypes.cbegin(), |
| 3559 | [](Type const* argumentType, Type const* parameterType) |
| 3560 | { |
| 3561 | return argumentType->isImplicitlyConvertibleTo(*parameterType); |
| 3562 | } |
| 3563 | ); |
| 3564 | else if (paramNames.size() != _arguments.numNames()) |
| 3565 | return false; |
| 3566 | else |
| 3567 | { |
| 3568 | solAssert(_arguments.numArguments() == _arguments.numNames(), "Expected equal sized type & name vectors"); |
| 3569 | |
| 3570 | size_t matchedNames = 0; |
| 3571 | |
| 3572 | for (size_t a = 0; a < _arguments.names.size(); a++) |
| 3573 | for (size_t p = 0; p < paramNames.size(); p++) |
| 3574 | if (*_arguments.names[a] == paramNames[p]) |
| 3575 | { |
| 3576 | matchedNames++; |
| 3577 | if (!_arguments.types[a]->isImplicitlyConvertibleTo(*paramTypes[p])) |
| 3578 | return false; |
| 3579 | } |
| 3580 | |
| 3581 | if (matchedNames == _arguments.numNames()) |
| 3582 | return true; |
| 3583 | |
| 3584 | return false; |
| 3585 | } |
| 3586 | } |
| 3587 | |
| 3588 | bool FunctionType::hasEqualParameterTypes(FunctionType const& _other) const |
| 3589 | { |
no test coverage detected