diff options
author | Liana Husikyan <liana@ethdev.com> | 2015-05-07 22:52:06 +0800 |
---|---|---|
committer | Liana Husikyan <liana@ethdev.com> | 2015-05-08 23:51:52 +0800 |
commit | 495d827eceb2f8160421d0f7ce86d1183b54b3de (patch) | |
tree | 774b97de98757e679eb960c05ee669fdd5dfc359 /NameAndTypeResolver.cpp | |
parent | 115c22c0e001fd0f9c440c45b33009bfe99697f8 (diff) | |
download | dexon-solidity-495d827eceb2f8160421d0f7ce86d1183b54b3de.tar dexon-solidity-495d827eceb2f8160421d0f7ce86d1183b54b3de.tar.gz dexon-solidity-495d827eceb2f8160421d0f7ce86d1183b54b3de.tar.bz2 dexon-solidity-495d827eceb2f8160421d0f7ce86d1183b54b3de.tar.lz dexon-solidity-495d827eceb2f8160421d0f7ce86d1183b54b3de.tar.xz dexon-solidity-495d827eceb2f8160421d0f7ce86d1183b54b3de.tar.zst dexon-solidity-495d827eceb2f8160421d0f7ce86d1183b54b3de.zip |
implemented cleanup of duplication in resolver
Diffstat (limited to 'NameAndTypeResolver.cpp')
-rw-r--r-- | NameAndTypeResolver.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/NameAndTypeResolver.cpp b/NameAndTypeResolver.cpp index 4d33048d..ac841fcc 100644 --- a/NameAndTypeResolver.cpp +++ b/NameAndTypeResolver.cpp @@ -132,12 +132,14 @@ vector<Declaration const*> NameAndTypeResolver::getNameFromCurrentScope(ASTStrin vector<Declaration const*> NameAndTypeResolver::cleanupedDeclarations(Identifier const& _identifier) { - vector<Declaration const*> result; - for (auto declaration : m_currentScope->resolveName(_identifier.getName())) + vector<Declaration const*> uniqueFunctions; + + auto declarations = m_currentScope->resolveName(_identifier.getName()); + for (auto it = declarations.begin(); it != declarations.end(); ++it) { - solAssert(declaration, ""); + solAssert(*it, ""); // the declaration is functionDefinition while declarations > 1 - FunctionDefinition const& functionDefinition = dynamic_cast<FunctionDefinition const&>(*declaration); + FunctionDefinition const& functionDefinition = dynamic_cast<FunctionDefinition const&>(**it); FunctionType functionType(functionDefinition); for(auto parameter: functionType.getParameterTypes() + functionType.getReturnParameterTypes()) if (!parameter) @@ -146,9 +148,20 @@ vector<Declaration const*> NameAndTypeResolver::cleanupedDeclarations(Identifier errinfo_sourceLocation(_identifier.getLocation()) << errinfo_comment("Function type can not be used in this context") ); - //////////delete repitations. check by hasequalparameter types of function type + if (uniqueFunctions.end() == find_if( + uniqueFunctions.begin(), + uniqueFunctions.end(), + [&](Declaration const* d) + { + FunctionDefinition const& newFunctionDefinition = dynamic_cast<FunctionDefinition const&>(*d); + FunctionType newFunctionType(newFunctionDefinition); + + return functionType.hasEqualArgumentTypes(newFunctionType); + } + )) + uniqueFunctions.push_back(*it); } - return result; + return uniqueFunctions; } void NameAndTypeResolver::importInheritedScope(ContractDefinition const& _base) |