mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Only active variables at the point of their declaration.
This commit is contained in:
1 parent
6b9dda06f3
commit
88a5c66f4a
8 files changed
+176
-33
No files matched your search
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user