class Opal::Rewriters::ForRewriter
def on_for(node)
def on_for(node) loop_variable, loop_range, loop_body = *node # Declare local variables used in the loop and the loop body at the outer scope outer_assignments = generate_outer_assignments(loop_variable, loop_body) # Generate temporary loop variable tmp_loop_variable = self.class.next_tmp get_tmp_loop_variable = s(:js_tmp, tmp_loop_variable) # Assign the loop variables in the loop body loop_body = prepend_to_body(loop_body, assign_loop_variable(loop_variable, get_tmp_loop_variable)) # Transform the for-loop into each-loop with updated loop body node = transform_for_to_each_loop(node, loop_range, tmp_loop_variable, loop_body) node.updated(:begin, [*outer_assignments, node]) end