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 + 131793+
redo_label = push_redo_label31794+
emit_redo_label(redo_label)3179331795
body = @nd_body[nid]3179431796
if body >= 03179531797
stmts = get_stmts(body)@@ -31799,6 +31801,7 @@
3179931801
sk = sk + 13180031802
end3180131803
end31804+
pop_redo_label3180231805
@indent = @indent - 13180331806
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 + 132191+
redo_label = push_redo_label32192+
emit_redo_label(redo_label)3218832193
# Compile inner block body, replacing yield with outer block body3218932194
inner_blk = @nd_block[nid]3219032195
if inner_blk >= 0@@ -32224,6 +32229,7 @@
3222432229
end3222532230
end3222632231
end32232+
pop_redo_label3222732233
@indent = @indent - 13222832234
emit(" }")3222932235
end