fix: incorrect continue jump location in for loops

This commit is contained in:
TopchetoEU 2024-12-25 03:01:49 +02:00
parent e93498fed5
commit f1997e4584
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4

View File

@ -30,6 +30,7 @@ public class ForNode extends Node {
@Override public void compile(CompileResult target, boolean pollute) {
if (declaration != null) declaration.compile(target, false, BreakpointType.STEP_OVER);
var continueTarget = new DeferredIntSupplier();
int start = target.size();
int mid = -1;
if (condition != null) {
@ -39,9 +40,10 @@ public class ForNode extends Node {
var end = new DeferredIntSupplier();
LabelContext.pushLoop(target.env, loc(), label, end, start);
LabelContext.pushLoop(target.env, loc(), label, end, continueTarget);
body.compile(target, false, BreakpointType.STEP_OVER);
continueTarget.set(target.size());
if (assignment != null) assignment.compile(target, false, BreakpointType.STEP_OVER);
int endI = target.size();