aboutsummaryrefslogtreecommitdiffstats
path: root/libjulia
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-05-09 07:45:50 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-05-09 07:45:50 +0800
commit3b241843a77ed29d10355fc17383da18d979bc5b (patch)
tree64c1ca423862dcea7df7fdd9d3f7a8a15834395f /libjulia
parent10792dbc909bdd2c8ba7c0301ed81ee28b0ae1cc (diff)
downloaddexon-solidity-3b241843a77ed29d10355fc17383da18d979bc5b.tar.gz
dexon-solidity-3b241843a77ed29d10355fc17383da18d979bc5b.tar.zst
dexon-solidity-3b241843a77ed29d10355fc17383da18d979bc5b.zip
Use NameDispenser in Disambiguator
Diffstat (limited to 'libjulia')
-rw-r--r--libjulia/optimiser/Disambiguator.cpp12
-rw-r--r--libjulia/optimiser/Disambiguator.h3
2 files changed, 3 insertions, 12 deletions
diff --git a/libjulia/optimiser/Disambiguator.cpp b/libjulia/optimiser/Disambiguator.cpp
index df2984e5..b988dba7 100644
--- a/libjulia/optimiser/Disambiguator.cpp
+++ b/libjulia/optimiser/Disambiguator.cpp
@@ -38,17 +38,7 @@ string Disambiguator::translateIdentifier(string const& _originalName)
Scope::Identifier const* id = m_scopes.back()->lookup(_originalName);
solAssert(id, "");
if (!m_translations.count(id))
- {
- 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;
- }
+ m_translations[id] = m_nameDispenser.newName(_originalName);
return m_translations.at(id);
}
diff --git a/libjulia/optimiser/Disambiguator.h b/libjulia/optimiser/Disambiguator.h
index 18ffd157..6fc8a615 100644
--- a/libjulia/optimiser/Disambiguator.h
+++ b/libjulia/optimiser/Disambiguator.h
@@ -23,6 +23,7 @@
#include <libjulia/ASTDataForward.h>
#include <libjulia/optimiser/ASTCopier.h>
+#include <libjulia/optimiser/NameDispenser.h>
#include <libsolidity/inlineasm/AsmAnalysisInfo.h>
@@ -60,7 +61,7 @@ protected:
std::vector<solidity::assembly::Scope*> m_scopes;
std::map<void const*, std::string> m_translations;
- std::set<std::string> m_usedNames;
+ NameDispenser m_nameDispenser;
};
}