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 8e9651a..e2181e2 100644 --- a/src/main/java/me/topchetoeu/jscript/compilation/control/ForNode.java +++ b/src/main/java/me/topchetoeu/jscript/compilation/control/ForNode.java @@ -25,6 +25,7 @@ public class ForNode extends Node { } @Override public void compile(CompileResult target, boolean pollute) { var subtarget = target.subtarget(); + subtarget.scope.singleEntry = false; subtarget.add(i -> Instruction.stackAlloc(subtarget.scope.allocCount())); declaration.compile(subtarget, false, BreakpointType.STEP_OVER); @@ -39,8 +40,11 @@ public class ForNode extends Node { CompoundNode.compileMultiEntry(body, subtarget, false, BreakpointType.STEP_OVER); LabelContext.popLoop(subtarget.env, label); + subtarget.add(_i -> Instruction.stackRealloc(subtarget.scope.allocCount())); + CompoundNode.compileMultiEntry(assignment, subtarget, false, BreakpointType.STEP_OVER); int endI = subtarget.size(); + end.set(endI); subtarget.add(Instruction.jmp(start - endI));