mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #4094 from ethereum/disambiguator-cleanup
Use NameDispenser in Disambiguator
This commit is contained in:
commit
58c63dcc9c
@ -38,17 +38,7 @@ string Disambiguator::translateIdentifier(string const& _originalName)
|
|||||||
Scope::Identifier const* id = m_scopes.back()->lookup(_originalName);
|
Scope::Identifier const* id = m_scopes.back()->lookup(_originalName);
|
||||||
solAssert(id, "");
|
solAssert(id, "");
|
||||||
if (!m_translations.count(id))
|
if (!m_translations.count(id))
|
||||||
{
|
m_translations[id] = m_nameDispenser.newName(_originalName);
|
||||||
string translated = _originalName;
|
|
||||||
size_t suffix = 0;
|
|
||||||
while (m_usedNames.count(translated))
|
|
||||||
{
|
|
||||||
suffix++;
|
|
||||||
translated = _originalName + "_" + std::to_string(suffix);
|
|
||||||
}
|
|
||||||
m_usedNames.insert(translated);
|
|
||||||
m_translations[id] = translated;
|
|
||||||
}
|
|
||||||
return m_translations.at(id);
|
return m_translations.at(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <libjulia/ASTDataForward.h>
|
#include <libjulia/ASTDataForward.h>
|
||||||
|
|
||||||
#include <libjulia/optimiser/ASTCopier.h>
|
#include <libjulia/optimiser/ASTCopier.h>
|
||||||
|
#include <libjulia/optimiser/NameDispenser.h>
|
||||||
|
|
||||||
#include <libsolidity/inlineasm/AsmAnalysisInfo.h>
|
#include <libsolidity/inlineasm/AsmAnalysisInfo.h>
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ protected:
|
|||||||
|
|
||||||
std::vector<solidity::assembly::Scope*> m_scopes;
|
std::vector<solidity::assembly::Scope*> m_scopes;
|
||||||
std::map<void const*, std::string> m_translations;
|
std::map<void const*, std::string> m_translations;
|
||||||
std::set<std::string> m_usedNames;
|
NameDispenser m_nameDispenser;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user