MCPcopy Create free account
hub / github.com/argotorg/solidity / sortedArguments

Method sortedArguments

libsolidity/ast/AST.cpp:983–1019  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

981}
982
983std::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
1021IdentifierAnnotation& Identifier::annotation() const
1022{

Callers 12

visitDeploymentMethod · 0.80
internalFunctionCallMethod · 0.80
buildABIFunctionsMethod · 0.80
inlineFunctionCallMethod · 0.80
visitBytesConcatMethod · 0.80
visitABIFunctionMethod · 0.80
visitMethod · 0.80
endVisitMethod · 0.80

Calls 8

actualTypeMethod · 0.80
constructorTypeMethod · 0.80
parameterNamesMethod · 0.80
atMethod · 0.80
parameterTypesMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected