aboutsummaryrefslogtreecommitdiffstats
path: root/ExpressionCompiler.cpp
diff options
context:
space:
mode:
authorGav Wood <i@gavwood.com>2015-02-04 03:57:36 +0800
committerGav Wood <i@gavwood.com>2015-02-04 03:57:36 +0800
commit04164b612c61ea2ea5c18f56600f95f03ded7235 (patch)
tree7cb9ae18f9bea6ec2a244e9de69d7c1814b788b9 /ExpressionCompiler.cpp
parente321b956a1381e569fad2e1ee7d9b23c1baff321 (diff)
parent5c828dc8b25f223f45d85359dbbb5d9e275167c2 (diff)
downloaddexon-solidity-04164b612c61ea2ea5c18f56600f95f03ded7235.tar.gz
dexon-solidity-04164b612c61ea2ea5c18f56600f95f03ded7235.tar.zst
dexon-solidity-04164b612c61ea2ea5c18f56600f95f03ded7235.zip
Merge branch 'named-args' of https://github.com/guanqun/cpp-ethereum into guanqun-named-args
Diffstat (limited to 'ExpressionCompiler.cpp')
-rw-r--r--ExpressionCompiler.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp
index 45e0e80b..13d8ccf1 100644
--- a/ExpressionCompiler.cpp
+++ b/ExpressionCompiler.cpp
@@ -195,6 +195,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
{
//@todo struct construction
solAssert(_functionCall.getArguments().size() == 1, "");
+ solAssert(_functionCall.getNames().empty(), "");
Expression const& firstArgument = *_functionCall.getArguments().front();
firstArgument.accept(*this);
appendTypeConversion(*firstArgument.getType(), *_functionCall.getType());
@@ -202,8 +203,35 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
else
{
FunctionType const& function = dynamic_cast<FunctionType const&>(*_functionCall.getExpression().getType());
- vector<ASTPointer<Expression const>> arguments = _functionCall.getArguments();
- solAssert(arguments.size() == function.getParameterTypes().size(), "");
+ TypePointers const& parameterTypes = function.getParameterTypes();
+ vector<string> const& parameterNames = function.getParameterNames();
+ vector<ASTPointer<Expression const>> const& callArguments = _functionCall.getArguments();
+ vector<string> const& callArgumentNames = _functionCall.getNames();
+ solAssert(callArguments.size() == parameterTypes.size(), "");
+
+ vector<ASTPointer<Expression const>> arguments;
+ if (callArgumentNames.empty())
+ {
+ // normal arguments
+ arguments = {callArguments.begin(), callArguments.end()};
+ }
+ else
+ {
+ // named arguments
+ for (size_t i = 0; i < parameterNames.size(); i++) {
+ bool found = false;
+ for (size_t j = 0; j < callArgumentNames.size(); j++) {
+ if (parameterNames[i] == callArgumentNames[j]) {
+ // we found the actual parameter position
+ arguments.push_back(callArguments[j]);
+
+ found = true;
+ break;
+ }
+ }
+ solAssert(found, "");
+ }
+ }
switch (function.getLocation())
{