Removing scope rules for pre block in 'For Loops'

This commit is contained in:
fnatic
2019-04-17 05:58:40 +05:30
parent 94053c9a52
commit 5b6ed7a97c
24 changed files with 60 additions and 111 deletions
+3 -10
View File
@@ -118,12 +118,9 @@ void RedundantAssignEliminator::operator()(ForLoop const& _forLoop)
ForLoopInfo outerForLoopInfo;
swap(outerForLoopInfo, m_forLoopInfo);
set<YulString> outerDeclaredVariables;
swap(m_declaredVariables, outerDeclaredVariables);
// We need to visit the statements directly because of the
// scoping rules.
walkVector(_forLoop.pre.statements);
// If the pre block was not empty,
// we would have to deal with more complicated scoping rules.
assertThrow(_forLoop.pre.statements.empty(), OptimizerException, "");
// We just run the loop twice to account for the
// back edge.
@@ -156,10 +153,6 @@ void RedundantAssignEliminator::operator()(ForLoop const& _forLoop)
merge(m_assignments, move(m_forLoopInfo.pendingBreakStmts));
m_forLoopInfo.pendingBreakStmts.clear();
for (auto const& var: m_declaredVariables)
finalize(var, State::Unused);
swap(m_declaredVariables, outerDeclaredVariables);
// Restore potential outer for-loop states.
swap(m_forLoopInfo, outerForLoopInfo);
}