Commit ea8f1c63
ea8f1c634d34Merged
Ryan Seys <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
feat(codegen): support redo in the each-family blocks
Wraps every loop-body emit site in the each family with the redo-label helpers — covering Array#each (across all 13 typed-array branches: int_array / str_array / float_array / sym_array / ptr_array / range / poly_array, plus the 7 hash-keys-each branches and the hash.keys.each fusion fast path), Array#each_with_index, Array#each_slice, Array#each_cons, Array#each_with_object, and the orthogonal String#each_byte (whose 4-line body-emit pattern matched the canonical shape and got swept up by the same replace).
Each typed-array branch in compile_each_block emits its own C label via push_redo_label — emitting the same name twice in one function would fail to compile, so the counter-driven sp_redo_ uniqueness is load-bearing here.
Block-param assignments (lv_ = sp__get(...)) stay outside
the redo label so redo re-runs the body with the same value
without re-fetching from the iterator.
🤖 Generated with Claude Code
Details
- Commit
- ea8f1c634d34
- Parent
- ecd8b347e965
spinel_codegen.rbmodifiedView file
@indent = @indent + 1 push_scope declare_var(bp, "int") redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }") @indent = @indent + 1 push_scope declare_var(bp1, rt) redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }") @indent = @indent + 1 push_scope declare_var(bp1, rt) redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }") push_scope declare_var(bp1, elem_type_of_array(rt)) declare_var(bp2, obj_t) redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }") push_scope declare_var(bp1, elem_type_of_array(rt)) declare_var(bp2, "int") redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }") if has_bp == 1 declare_var(bp1, key_type) end redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }") if has_bp == 1 declare_var(bp1, elem_type_of_array(rt)) end redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }") if has_bp == 1 declare_var(bp1, "symbol") end redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }") declare_var(bp1, elem_type) end end redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }") if bp2 != "" declare_var(bp2, "int") end redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }") if bp2 != "" declare_var(bp2, "string") end redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }") if bp2 != "" declare_var(bp2, "string") end redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }") if bp2 != "" declare_var(bp2, "int") end redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }") if bp2 != "" declare_var(bp2, "string") end redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }") if bp2 != "" declare_var(bp2, "poly") end redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }") if bp2 != "" declare_var(bp2, "poly") end redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }") if has_bp == 1 declare_var(bp1, "int") end redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }") if has_bp == 1 declare_var(bp1, "poly") end redo_label = push_redo_label emit_redo_label(redo_label) compile_stmts_body(@nd_body[@nd_block[nid]]) pop_redo_label pop_scope @indent = @indent - 1 emit(" }")