diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java index e2f45dcb8..3304fe011 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java @@ -1152,6 +1152,7 @@ public class Graph { } if (stopPart.contains(part)) { + //System.err.println("/stopped part " + part); return; } for (Loop el : loops) { @@ -1174,9 +1175,11 @@ public class Graph { if (visited.contains(part)) { part.level = 0; + //System.err.println("set level " + part + " to zero"); } else { visited.add(part); part.level = level; + //System.err.println("set level " + part + " to " + level); } boolean isLoop = false; @@ -1194,9 +1197,18 @@ public class Graph { if (nextParts == null) { nextParts = part.nextParts; } + nextParts = new ArrayList<>(nextParts); + + if (nextParts.size() == 2 && stopPart.contains(nextParts.get(1))) { + nextParts.remove(1); + } + if (nextParts.size() >= 1 && stopPart.contains(nextParts.get(0))) { + nextParts.remove(0); + } if (nextParts.size() == 2) { GraphPart next = getCommonPart(localData, nextParts, loops);//part.getNextPartPath(new ArrayList()); + //System.err.println("- common part of " + nextParts.get(0) + " and " + nextParts.get(1) + " is " + next); List stopParts2 = new ArrayList<>(); //stopPart); if (next != null) { stopParts2.add(next); @@ -1204,12 +1216,20 @@ public class Graph { stopParts2.add(stopPart.get(stopPart.size() - 1)); } if (next != nextParts.get(0)) { + // System.err.println("- going to branch 0 nextpart from " + part + " to " + nextParts.get(0)); markLevels(path, localData, nextParts.get(0), allParts, loops, next == null ? stopPart : stopParts2, level + 1, visited, recursionLevel + 1); + } else { + //System.err.println("- branch 0 of " + part + " is skipped (=next)"); } + if (next != nextParts.get(1)) { + //System.err.println("- going to branch 1 nextpart from " + part + " to " + nextParts.get(1)); markLevels(path, localData, nextParts.get(1), allParts, loops, next == null ? stopPart : stopParts2, level + 1, visited, recursionLevel + 1); + } else { + //System.err.println("- branch 1 of " + part + " is skipped (=next)"); } if (next != null) { + //System.err.println("- going to next from " + part + " to " + next); markLevels(path, localData, next, allParts, loops, stopPart, level, visited, recursionLevel + 1); } } @@ -1246,6 +1266,7 @@ public class Graph { } if (nextParts.size() == 1) { + //System.err.println("going to one nexpart from " + part + " to " + nextParts.get(0)); markLevels(path, localData, nextParts.get(0), allParts, loops, stopPart, level, visited, recursionLevel + 1); } @@ -1269,6 +1290,7 @@ public class Graph { if (isLoop) { if (currentLoop != null && currentLoop.loopBreak != null) { currentLoop.phase = 2; + //System.err.println("- going to break of loop " + currentLoop.loopBreak); markLevels(path, localData, currentLoop.loopBreak, allParts, loops, stopPart, level, visited, recursionLevel + 1); } } @@ -2190,13 +2212,6 @@ public class Graph { if (!bodyBranch.isEmpty()) { ret.add(index, loopItem); - /* - loopItem.commands.remove(loopItem.commands.size() - 1); - exprList.addAll(loopItem.commands); - commands.addAll(bodyBranch); - exprList.add(expr); - checkContinueAtTheEnd(commands, currentLoop); - ret.add(index, li = new WhileItem(null, currentLoop, exprList, commands));*/ } else { loopItem.commands.remove(loopItem.commands.size() - 1); commands.addAll(loopItem.commands); diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java index 700e78f3f..89273b64a 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java @@ -1948,4 +1948,29 @@ public class ActionScript2Test extends ActionScript2TestBase { + "trace(\"after\");\r\n" ); } + + @Test + public void frame70_forWithContinue2Test() { + compareSrc(70, "trace(\"forWithContinue2Test\");\r\n" + + "var s = \"A\";\r\n" + + "var i = 0;\r\n" + + "for(; i < 10; i++)\r\n" + + "{\r\n" + + "if(s == \"B\")\r\n" + + "{\r\n" + + "if(s == \"C\")\r\n" + + "{\r\n" + + "continue;\r\n" + + "}\r\n" + + "}\r\n" + + "trace(\"D\");\r\n" + + "var j = 0;\r\n" + + "while(j < 29)\r\n" + + "{\r\n" + + "trace(\"E\");\r\n" + + "j++;\r\n" + + "}\r\n" + + "}\r\n" + ); + } } diff --git a/libsrc/ffdec_lib/testdata/as2/as2.fla b/libsrc/ffdec_lib/testdata/as2/as2.fla index 4b38fcd38..47ee76926 100644 Binary files a/libsrc/ffdec_lib/testdata/as2/as2.fla and b/libsrc/ffdec_lib/testdata/as2/as2.fla differ diff --git a/libsrc/ffdec_lib/testdata/as2/as2.swf b/libsrc/ffdec_lib/testdata/as2/as2.swf index 3b1088827..6630bec7e 100644 Binary files a/libsrc/ffdec_lib/testdata/as2/as2.swf and b/libsrc/ffdec_lib/testdata/as2/as2.swf differ