aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/analysis/DeclarationContainer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsolidity/analysis/DeclarationContainer.cpp')
-rw-r--r--libsolidity/analysis/DeclarationContainer.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp
index 7508ad9e..c7ba78d6 100644
--- a/libsolidity/analysis/DeclarationContainer.cpp
+++ b/libsolidity/analysis/DeclarationContainer.cpp
@@ -79,6 +79,17 @@ Declaration const* DeclarationContainer::conflictingDeclaration(
return nullptr;
}
+void DeclarationContainer::activateVariable(ASTString const& _name)
+{
+ solAssert(
+ m_invisibleDeclarations.count(_name) && m_invisibleDeclarations.at(_name).size() == 1,
+ "Tried to activate a non-inactive variable or multiple inactive variables with the same name."
+ );
+ solAssert(m_declarations.count(_name) == 0 || m_declarations.at(_name).empty(), "");
+ m_declarations[_name].emplace_back(m_invisibleDeclarations.at(_name).front());
+ m_invisibleDeclarations.erase(_name);
+}
+
bool DeclarationContainer::registerDeclaration(
Declaration const& _declaration,
ASTString const* _name,
@@ -106,15 +117,17 @@ bool DeclarationContainer::registerDeclaration(
return true;
}
-vector<Declaration const*> DeclarationContainer::resolveName(ASTString const& _name, bool _recursive) const
+vector<Declaration const*> DeclarationContainer::resolveName(ASTString const& _name, bool _recursive, bool _alsoInvisible) const
{
solAssert(!_name.empty(), "Attempt to resolve empty name.");
- auto result = m_declarations.find(_name);
- if (result != m_declarations.end())
- return result->second;
- if (_recursive && m_enclosingContainer)
- return m_enclosingContainer->resolveName(_name, true);
- return vector<Declaration const*>({});
+ vector<Declaration const*> result;
+ if (m_declarations.count(_name))
+ result = m_declarations.at(_name);
+ if (_alsoInvisible && m_invisibleDeclarations.count(_name))
+ result += m_invisibleDeclarations.at(_name);
+ if (result.empty() && _recursive && m_enclosingContainer)
+ result = m_enclosingContainer->resolveName(_name, true, _alsoInvisible);
+ return result;
}
vector<ASTString> DeclarationContainer::similarNames(ASTString const& _name) const
@@ -129,6 +142,12 @@ vector<ASTString> DeclarationContainer::similarNames(ASTString const& _name) con
if (stringWithinDistance(_name, declarationName, MAXIMUM_EDIT_DISTANCE))
similar.push_back(declarationName);
}
+ for (auto const& declaration: m_invisibleDeclarations)
+ {
+ string const& declarationName = declaration.first;
+ if (stringWithinDistance(_name, declarationName, MAXIMUM_EDIT_DISTANCE))
+ similar.push_back(declarationName);
+ }
if (m_enclosingContainer)
similar += m_enclosingContainer->similarNames(_name);