Commit 4ed92ee6

4ed92ee63631Merged

Ryan Seys <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

feat(codegen): support redo in inline-yield-expanded loops

Wraps two helpers that emit user-block-body loops inside an inlined yield expansion:

  • compile_stmt_with_block's WhileNode arm: when a method body contains `while cond; ...; end` and the method is inlined into a caller's block, the inlined while-body now installs a redo label so a `redo` inside the user block jumps to the inlined loop top.
  • compile_each_with_yield_inline's int_array branch: when an each call inside an inlined yield is itself inlined further, the inner loop body now installs a redo label.

🤖 Generated with Claude Code

Details

Commit
4ed92ee63631
Parent
4c33b5b55325

spinel_codegen.rbmodifiedView file

@@ -31790,6 +31790,8 @@
3179031790 cond = compile_expr_remap(@nd_predicate[nid], map_from, map_to)
3179131791 emit(" while (" + cond + ") {")
3179231792 @indent = @indent + 1
31793+ redo_label = push_redo_label
31794+ emit_redo_label(redo_label)
3179331795 body = @nd_body[nid]
3179431796 if body >= 0
3179531797 stmts = get_stmts(body)
@@ -31799,6 +31801,7 @@
3179931801 sk = sk + 1
3180031802 end
3180131803 end
31804+ pop_redo_label
3180231805 @indent = @indent - 1
3180331806 emit(" }")
3180431807 @in_loop = old
@@ -32185,6 +32188,8 @@
3218532188 emit(" for (mrb_int " + tmp + " = 0; " + tmp + " < sp_IntArray_length(" + recv_expr + "); " + tmp + "++) {")
3218632189 emit(" lv_" + inner_bp_remapped + " = sp_IntArray_get(" + recv_expr + ", " + tmp + ");")
3218732190 @indent = @indent + 1
32191+ redo_label = push_redo_label
32192+ emit_redo_label(redo_label)
3218832193 # Compile inner block body, replacing yield with outer block body
3218932194 inner_blk = @nd_block[nid]
3219032195 if inner_blk >= 0
@@ -32224,6 +32229,7 @@
3222432229 end
3222532230 end
3222632231 end
32232+ pop_redo_label
3222732233 @indent = @indent - 1
3222832234 emit(" }")
3222932235 end