diff options
author | Lefteris Karapetsas <lefteris@refu.co> | 2015-02-27 18:35:25 +0800 |
---|---|---|
committer | Lefteris Karapetsas <lefteris@refu.co> | 2015-03-02 18:51:13 +0800 |
commit | efe8f9f8a054a7a7489db44e236e5424becf9db7 (patch) | |
tree | 5cb75003f96c654f6ff6eb81a5376da3bda44f58 /AST.cpp | |
parent | 7db2b6fbdb7188596fbb05bea32d686c32e26c7f (diff) | |
download | dexon-solidity-efe8f9f8a054a7a7489db44e236e5424becf9db7.tar.gz dexon-solidity-efe8f9f8a054a7a7489db44e236e5424becf9db7.tar.zst dexon-solidity-efe8f9f8a054a7a7489db44e236e5424becf9db7.zip |
Use lambda to avoid code duplication in inheritableMembers
Diffstat (limited to 'AST.cpp')
-rw-r--r-- | AST.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
@@ -217,26 +217,23 @@ vector<ASTPointer<Declaration>> const& ContractDefinition::getInheritableMembers m_inheritableMembers.reset(new vector<ASTPointer<Declaration>>()); for (ContractDefinition const* contract: getLinearizedBaseContracts()) { - for (ASTPointer<FunctionDefinition> const& f: contract->getDefinedFunctions()) - if (memberSeen.count(f->getName()) == 0 && f->isVisibleInDerivedContracts()) + auto addInheritableMember = [&](ASTPointer<Declaration> const& _decl) + { + if (memberSeen.count(_decl->getName()) == 0 && _decl->isVisibleInDerivedContracts()) { - memberSeen.insert(f->getName()); - m_inheritableMembers->push_back(f); + memberSeen.insert(_decl->getName()); + m_inheritableMembers->push_back(_decl); } + }; + + for (ASTPointer<FunctionDefinition> const& f: contract->getDefinedFunctions()) + addInheritableMember(f); for (ASTPointer<VariableDeclaration> const& v: contract->getStateVariables()) - if (memberSeen.count(v->getName()) == 0 && v->isVisibleInDerivedContracts()) - { - memberSeen.insert(v->getName()); - m_inheritableMembers->push_back(v); - } + addInheritableMember(v); for (ASTPointer<StructDefinition> const& s: contract->getDefinedStructs()) - if (memberSeen.count(s->getName()) == 0 && s->isVisibleInDerivedContracts()) - { - memberSeen.insert(s->getName()); - m_inheritableMembers->push_back(s); - } + addInheritableMember(s); } } return *m_inheritableMembers; |