mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10234 from ethereum/smt_named_arguments
[SMTChecker] Support named arguments in function calls
This commit is contained in:
@@ -757,6 +757,44 @@ FunctionCallAnnotation& FunctionCall::annotation() const
|
||||
return initAnnotation<FunctionCallAnnotation>();
|
||||
}
|
||||
|
||||
vector<ASTPointer<Expression const>> FunctionCall::sortedArguments() const
|
||||
{
|
||||
// normal arguments
|
||||
if (m_names.empty())
|
||||
return arguments();
|
||||
|
||||
// named arguments
|
||||
FunctionTypePointer functionType;
|
||||
if (*annotation().kind == FunctionCallKind::StructConstructorCall)
|
||||
{
|
||||
auto const& type = dynamic_cast<TypeType const&>(*m_expression->annotation().type);
|
||||
auto const& structType = dynamic_cast<StructType const&>(*type.actualType());
|
||||
functionType = structType.constructorType();
|
||||
}
|
||||
else
|
||||
functionType = dynamic_cast<FunctionType const*>(m_expression->annotation().type);
|
||||
|
||||
vector<ASTPointer<Expression const>> sorted;
|
||||
for (auto const& parameterName: functionType->parameterNames())
|
||||
{
|
||||
bool found = false;
|
||||
for (size_t j = 0; j < m_names.size() && !found; j++)
|
||||
if ((found = (parameterName == *m_names.at(j))))
|
||||
// we found the actual parameter position
|
||||
sorted.push_back(m_arguments.at(j));
|
||||
solAssert(found, "");
|
||||
}
|
||||
|
||||
if (!functionType->takesArbitraryParameters())
|
||||
{
|
||||
solAssert(m_arguments.size() == functionType->parameterTypes().size(), "");
|
||||
solAssert(m_arguments.size() == m_names.size(), "");
|
||||
solAssert(m_arguments.size() == sorted.size(), "");
|
||||
}
|
||||
|
||||
return sorted;
|
||||
}
|
||||
|
||||
IdentifierAnnotation& Identifier::annotation() const
|
||||
{
|
||||
return initAnnotation<IdentifierAnnotation>();
|
||||
|
||||
Reference in New Issue
Block a user