| 981 | } |
| 982 | |
| 983 | std::vector<ASTPointer<Expression const>> FunctionCall::sortedArguments() const |
| 984 | { |
| 985 | // normal arguments |
| 986 | if (m_names.empty()) |
| 987 | return arguments(); |
| 988 | |
| 989 | // named arguments |
| 990 | FunctionTypePointer functionType; |
| 991 | if (*annotation().kind == FunctionCallKind::StructConstructorCall) |
| 992 | { |
| 993 | auto const& type = dynamic_cast<TypeType const&>(*m_expression->annotation().type); |
| 994 | auto const& structType = dynamic_cast<StructType const&>(*type.actualType()); |
| 995 | functionType = structType.constructorType(); |
| 996 | } |
| 997 | else |
| 998 | functionType = dynamic_cast<FunctionType const*>(m_expression->annotation().type); |
| 999 | |
| 1000 | std::vector<ASTPointer<Expression const>> sorted; |
| 1001 | for (auto const& parameterName: functionType->parameterNames()) |
| 1002 | { |
| 1003 | bool found = false; |
| 1004 | for (size_t j = 0; j < m_names.size() && !found; j++) |
| 1005 | if ((found = (parameterName == *m_names.at(j)))) |
| 1006 | // we found the actual parameter position |
| 1007 | sorted.push_back(m_arguments.at(j)); |
| 1008 | solAssert(found, ""); |
| 1009 | } |
| 1010 | |
| 1011 | if (!functionType->takesArbitraryParameters()) |
| 1012 | { |
| 1013 | solAssert(m_arguments.size() == functionType->parameterTypes().size(), ""); |
| 1014 | solAssert(m_arguments.size() == m_names.size(), ""); |
| 1015 | solAssert(m_arguments.size() == sorted.size(), ""); |
| 1016 | } |
| 1017 | |
| 1018 | return sorted; |
| 1019 | } |
| 1020 | |
| 1021 | IdentifierAnnotation& Identifier::annotation() const |
| 1022 | { |
no test coverage detected