From f1997e458425d740c7e9d2e4d7647c9a343cb698 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Wed, 25 Dec 2024 03:01:49 +0200 Subject: [PATCH] fix: incorrect continue jump location in for loops --- .../me/topchetoeu/jscript/compilation/control/ForNode.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/topchetoeu/jscript/compilation/control/ForNode.java b/src/main/java/me/topchetoeu/jscript/compilation/control/ForNode.java index 25837ef..8449c5f 100644 --- a/src/main/java/me/topchetoeu/jscript/compilation/control/ForNode.java +++ b/src/main/java/me/topchetoeu/jscript/compilation/control/ForNode.java @@ -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();