aboutsummaryrefslogtreecommitdiffstats
path: root/libyul/optimiser/NameDispenser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libyul/optimiser/NameDispenser.cpp')
-rw-r--r--libyul/optimiser/NameDispenser.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/libyul/optimiser/NameDispenser.cpp b/libyul/optimiser/NameDispenser.cpp
index e7cdc60f..172e6907 100644
--- a/libyul/optimiser/NameDispenser.cpp
+++ b/libyul/optimiser/NameDispenser.cpp
@@ -22,17 +22,19 @@
#include <libyul/optimiser/NameCollector.h>
#include <libyul/AsmData.h>
+#include <libyul/Dialect.h>
using namespace std;
using namespace dev;
using namespace yul;
-NameDispenser::NameDispenser(Block const& _ast):
- NameDispenser(NameCollector(_ast).names())
+NameDispenser::NameDispenser(Dialect const& _dialect, Block const& _ast):
+ NameDispenser(_dialect, NameCollector(_ast).names())
{
}
-NameDispenser::NameDispenser(set<YulString> _usedNames):
+NameDispenser::NameDispenser(Dialect const& _dialect, set<YulString> _usedNames):
+ m_dialect(_dialect),
m_usedNames(std::move(_usedNames))
{
}
@@ -51,7 +53,7 @@ YulString NameDispenser::newName(YulString _nameHint, YulString _context)
YulString NameDispenser::newNameInternal(YulString _nameHint)
{
YulString name = _nameHint;
- while (name.empty() || m_usedNames.count(name))
+ while (name.empty() || m_usedNames.count(name) || m_dialect.builtin(name))
{
m_counter++;
name = YulString(_nameHint.str() + "_" + to_string(m_counter));