Commit ecd8b347

ecd8b347e965Merged

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

Description

feat(codegen): support redo in Kernel#loop, upto, and downto

Wraps three more counted/method-form loops with the redo-label helpers: Kernel#loop's while (1) {} body, compile_upto_block's ascending counter, and compile_downto_block's descending counter.

The Kernel#loop branch lives inside compile_block_iteration_stmt; the upto/downto branches are dedicated emitters. All three follow the canonical wrapping (push/emit after @indent += 1 and after the block-param assignment, pop before @indent -= 1).

🤖 Generated with Claude Code

Details

Commit
ecd8b347e965
Parent
069ce8aabe5b

spinel_codegen.rbmodifiedView file

@@ -27390,7 +27390,10 @@
2739027390 @in_loop = 1
2739127391 emit(" while (1) {")
2739227392 @indent = @indent + 1
27393+ redo_label = push_redo_label
27394+ emit_redo_label(redo_label)
2739327395 compile_stmts_body(@nd_body[@nd_block[nid]])
27396+ pop_redo_label
2739427397 @indent = @indent - 1
2739527398 emit(" }")
2739627399 @in_loop = old
@@ -29887,7 +29890,10 @@
2988729890 if bp1 != ""
2988829891 declare_var(bp1, "int")
2988929892 end
29893+ redo_label = push_redo_label
29894+ emit_redo_label(redo_label)
2989029895 compile_stmts_body(@nd_body[@nd_block[nid]])
29896+ pop_redo_label
2989129897 pop_scope
2989229898 @indent = @indent - 1
2989329899 emit(" }")
@@ -29910,7 +29916,10 @@
2991029916 if bp1 != ""
2991129917 declare_var(bp1, "int")
2991229918 end
29919+ redo_label = push_redo_label
29920+ emit_redo_label(redo_label)
2991329921 compile_stmts_body(@nd_body[@nd_block[nid]])
29922+ pop_redo_label
2991429923 pop_scope
2991529924 @indent = @indent - 1
2991629925 emit(" }")