void FunctionInliner::visit(Iteration &iter)
{
- SetForScope<Block *> set_block(current_block, &iter.body);
+ /* Visit the initialization statement before entering the loop body so the
+ inlined statements get inserted outside. */
if(iter.init_statement)
iter.init_statement->visit(*this);
- /* Skip the condition and loop expression parts because they're executed on
- every iteration of the loop */
+
+ SetForScope<Block *> set_block(current_block, &iter.body);
+ /* Skip the condition and loop expression parts because they're not properly
+ inside the body block. Inlining anything into them will require a more
+ comprehensive transformation. */
iter.body.visit(*this);
}