diff options
author | Liana Husikyan <liana@ethdev.com> | 2015-05-01 00:06:04 +0800 |
---|---|---|
committer | Liana Husikyan <liana@ethdev.com> | 2015-05-04 20:47:38 +0800 |
commit | 8b5fa857d7ce68573a763c03a1d064c30cbf9153 (patch) | |
tree | 47dd0f6a17c035bdc0d0f3a39da2033cd1b5ee9c /DeclarationContainer.cpp | |
parent | ef26d9611120c5d3c36263a87e907a007e24c8d2 (diff) | |
download | dexon-solidity-8b5fa857d7ce68573a763c03a1d064c30cbf9153.tar.gz dexon-solidity-8b5fa857d7ce68573a763c03a1d064c30cbf9153.tar.zst dexon-solidity-8b5fa857d7ce68573a763c03a1d064c30cbf9153.zip |
created secondarySoureLocation error type
added additional information to error msgs
Diffstat (limited to 'DeclarationContainer.cpp')
-rw-r--r-- | DeclarationContainer.cpp | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/DeclarationContainer.cpp b/DeclarationContainer.cpp index 2130f3a0..c836663c 100644 --- a/DeclarationContainer.cpp +++ b/DeclarationContainer.cpp @@ -28,6 +28,28 @@ using namespace std; using namespace dev; using namespace dev::solidity; +Declaration const* DeclarationContainer::conflictingDeclaration(Declaration const& _declaration) const +{ + ASTString const& name(_declaration.getName()); + solAssert(!name.empty(), ""); + vector<Declaration const*> declarations; + if (m_declarations.count(name)) + declarations += m_declarations.at(name); + if (m_invisibleDeclarations.count(name)) + declarations += m_invisibleDeclarations.at(name); + if (dynamic_cast<FunctionDefinition const*>(&_declaration)) + { + // check that all other declarations with the same name are functions + for (Declaration const* declaration: declarations) + if (!dynamic_cast<FunctionDefinition const*>(declaration)) + return declaration; + } + else if (!declarations.empty()) + return declarations.front(); + + return nullptr; +} + bool DeclarationContainer::registerDeclaration(Declaration const& _declaration, bool _invisible, bool _update) { ASTString const& name(_declaration.getName()); @@ -40,24 +62,8 @@ bool DeclarationContainer::registerDeclaration(Declaration const& _declaration, m_declarations.erase(name); m_invisibleDeclarations.erase(name); } - else - { - vector<Declaration const*> declarations; - if (m_declarations.count(name)) - declarations += m_declarations.at(name); - if (m_invisibleDeclarations.count(name)) - declarations += m_invisibleDeclarations.at(name); - if (dynamic_cast<FunctionDefinition const*>(&_declaration)) - { - // check that all other declarations with the same name are functions - - for (Declaration const* declaration: declarations) - if (!dynamic_cast<FunctionDefinition const*>(declaration)) - return false; - } - else if (!declarations.empty()) - return false; - } + else if (conflictingDeclaration(_declaration)) + return false; if (_invisible) m_invisibleDeclarations[name].insert(&_declaration); |