Commit 4c33b5b5

4c33b5b55325Merged

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

Description

feat(codegen): support redo in zip, step, and cycle blocks

Wraps the three method-iterator branches inside compile_block_iteration_stmt that take a block: Array#zip { |a, b| ... }, Integer#step { |i| ... }, and Array#cycle { |x| ... }. All three follow the canonical pattern (push/emit after @indent += 1 and after the block-param assignments, pop before @indent -= 1).

The cycle branch nests a count-loop around the element-loop in C; the redo label lives inside the inner element-loop body so a redo re-runs only the current element iteration, not the whole cycle.

🤖 Generated with Claude Code

Details

Commit
4c33b5b55325
Parent
ea8f1c634d34

spinel_codegen.rbmodifiedView file

@@ -27220,7 +27220,10 @@
2722027220 push_scope
2722127221 declare_var(bp1, elem_t)
2722227222 declare_var(bp2, elem_t)
27223+ redo_label = push_redo_label
27224+ emit_redo_label(redo_label)
2722327225 compile_stmts_body(@nd_body[@nd_block[nid]])
27226+ pop_redo_label
2722427227 pop_scope
2722527228 @indent = @indent - 1
2722627229 emit(" }")
@@ -27264,7 +27267,10 @@
2726427267 @indent = @indent + 1
2726527268 push_scope
2726627269 declare_var(bp1, "int")
27270+ redo_label = push_redo_label
27271+ emit_redo_label(redo_label)
2726727272 compile_stmts_body(@nd_body[@nd_block[nid]])
27273+ pop_redo_label
2726827274 pop_scope
2726927275 @indent = @indent - 1
2727027276 emit(" }")
@@ -27297,7 +27303,10 @@
2729727303 @indent = @indent + 1
2729827304 push_scope
2729927305 declare_var(bp1, et)
27306+ redo_label = push_redo_label
27307+ emit_redo_label(redo_label)
2730027308 compile_stmts_body(@nd_body[@nd_block[nid]])
27309+ pop_redo_label
2730127310 pop_scope
2730227311 @indent = @indent - 1
2730327312 emit(" }")