Fix redo keyword

Add `OP_NOP` to distinguish `retry` and jump targets while maintaining instruction compatibility.
Ideally, it might be preferable to separate them into `OP_REDO`.

fixed #6439
This commit is contained in:
dearblue
2024-12-01 11:40:17 +09:00
parent 939659e2db
commit 9a67bdb6aa
+2
View File
@@ -1323,6 +1323,7 @@ for_body(codegen_scope *s, node *tree)
/* construct loop */
lp = loop_push(s, LOOP_FOR);
lp->pc1 = new_label(s);
genop_0(s, OP_NOP); /* for redo */
/* loop body */
codegen(s, tree->cdr->cdr->car, VAL);
@@ -2589,6 +2590,7 @@ codegen(codegen_scope *s, node *tree, int val)
pos = genjmp2_0(s, OP_JMPIF, cursp(), NOVAL);
}
lp->pc1 = new_label(s);
genop_0(s, OP_NOP); /* for redo */
codegen(s, tree->cdr, NOVAL);
genjmp(s, OP_JMP, lp->pc0);
dispatch(s, pos);