Fixed: #2297 AS1/2/3 direct editation - if..else clause broken when using continue/break

This commit is contained in:
Jindra Petřík
2024-09-23 21:52:25 +02:00
parent b90eeaa7d0
commit 2976829642
3 changed files with 10 additions and 7 deletions
@@ -359,9 +359,10 @@ public class AVM2SourceGenerator implements SourceGenerator {
}
AVM2Instruction ajmp = null;
if (onFalse != null) {
if (!((!nonempty(onTrue).isEmpty())
&& ((onTrue.get(onTrue.size() - 1).definition instanceof ContinueJumpIns)
|| ((onTrue.get(onTrue.size() - 1).definition instanceof BreakJumpIns))))) {
if (onTrueCmds.isEmpty() ||
!((onTrueCmds.get(onTrueCmds.size() - 1) instanceof ContinueItem)
|| (onTrueCmds.get(onTrueCmds.size() - 1) instanceof BreakItem))
) {
ajmp = ins(AVM2Instructions.Jump, 0);
onTrue.add(ajmp);
}
@@ -183,10 +183,10 @@ public class ActionSourceGenerator implements SourceGenerator {
ifaif.setJumpOffset(onTrueLen);
ActionJump ajmp = null;
if (onFalse != null) {
if (!((!nonempty(onTrue).isEmpty())
&& (onTrue.get(onTrue.size() - 1) instanceof ActionJump)
&& ((((ActionJump) onTrue.get(onTrue.size() - 1)).isContinue)
|| (((ActionJump) onTrue.get(onTrue.size() - 1)).isBreak)))) {
if (onTrueCmds.isEmpty() ||
!((onTrueCmds.get(onTrueCmds.size() - 1) instanceof ContinueItem)
|| (onTrueCmds.get(onTrueCmds.size() - 1) instanceof BreakItem))
) {
ajmp = new ActionJump(0, charset);
ret.add(ajmp);
onTrueLen += ajmp.getTotalActionLength();