diff options
author | chriseth <chris@ethereum.org> | 2018-10-18 04:54:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-18 04:54:38 +0800 |
commit | 7609e2871e77b623d4c6187b7ebed693ce74cd0e (patch) | |
tree | fd94161253697dfb29592b3aea471abe44658653 /libyul/optimiser/FullInliner.cpp | |
parent | c578b21e7c94dbb5ae1eec7bfb9e92e4ffea4ae9 (diff) | |
parent | 732d09cef1548e2111c47b6f5b04a54db10a9d41 (diff) | |
download | dexon-solidity-7609e2871e77b623d4c6187b7ebed693ce74cd0e.tar.gz dexon-solidity-7609e2871e77b623d4c6187b7ebed693ce74cd0e.tar.zst dexon-solidity-7609e2871e77b623d4c6187b7ebed693ce74cd0e.zip |
Merge pull request #5240 from ethereum/limitDispenserSize
[Yul] Limit name length created by dispenser
Diffstat (limited to 'libyul/optimiser/FullInliner.cpp')
-rw-r--r-- | libyul/optimiser/FullInliner.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/libyul/optimiser/FullInliner.cpp b/libyul/optimiser/FullInliner.cpp index aa069506..ce71eda5 100644 --- a/libyul/optimiser/FullInliner.cpp +++ b/libyul/optimiser/FullInliner.cpp @@ -41,11 +41,10 @@ using namespace dev::yul; using namespace dev::solidity; FullInliner::FullInliner(Block& _ast): - m_ast(_ast) + m_ast(_ast), m_nameDispenser(_ast) { assertThrow(m_ast.statements.size() >= 1, OptimizerException, ""); assertThrow(m_ast.statements.front().type() == typeid(Block), OptimizerException, ""); - m_nameDispenser.m_usedNames = NameCollector(m_ast).names(); // Determine constants SSAValueTracker tracker; @@ -157,7 +156,7 @@ vector<Statement> InlineModifier::performInline(Statement& _statement, FunctionC // helper function to create a new variable that is supposed to model // an existing variable. auto newVariable = [&](TypedName const& _existingVariable, Expression* _value) { - string newName = m_nameDispenser.newName(function.name + "_" + _existingVariable.name); + string newName = m_nameDispenser.newName(_existingVariable.name, function.name); variableReplacements[_existingVariable.name] = newName; VariableDeclaration varDecl{_funCall.location, {{_funCall.location, newName, _existingVariable.type}}, {}}; if (_value) @@ -170,7 +169,7 @@ vector<Statement> InlineModifier::performInline(Statement& _statement, FunctionC for (auto const& var: function.returnVariables) newVariable(var, nullptr); - Statement newBody = BodyCopier(m_nameDispenser, function.name + "_", variableReplacements)(function.body); + Statement newBody = BodyCopier(m_nameDispenser, function.name, variableReplacements)(function.body); newStatements += std::move(boost::get<Block>(newBody).statements); boost::apply_visitor(GenericFallbackVisitor<Assignment, VariableDeclaration>{ @@ -203,15 +202,10 @@ vector<Statement> InlineModifier::performInline(Statement& _statement, FunctionC return newStatements; } -string InlineModifier::newName(string const& _prefix) -{ - return m_nameDispenser.newName(_prefix); -} - Statement BodyCopier::operator()(VariableDeclaration const& _varDecl) { for (auto const& var: _varDecl.variables) - m_variableReplacements[var.name] = m_nameDispenser.newName(m_varNamePrefix + var.name); + m_variableReplacements[var.name] = m_nameDispenser.newName(var.name, m_varNamePrefix); return ASTCopier::operator()(_varDecl); } |