diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/AVM2LocalData.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/AVM2LocalData.java index cebcb41b9..7bc9b5506 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/AVM2LocalData.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/AVM2LocalData.java @@ -89,6 +89,8 @@ public class AVM2LocalData extends BaseLocalData { */ public Map finallyThrowParts = new HashMap<>(); + public Map finallyTargetParts = new HashMap<>(); + //switchedPart -> index of nextpart public Map defaultWays = new HashMap<>(); @@ -156,6 +158,7 @@ public class AVM2LocalData extends BaseLocalData { finallyThrowParts = localData.finallyThrowParts; inGetLoops = localData.inGetLoops; parsedExceptionIds = localData.parsedExceptionIds; + finallyTargetParts = localData.finallyTargetParts; } public AVM2ConstantPool getConstants() { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java index 1a704594c..ae3ec91f4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java @@ -160,9 +160,27 @@ public class AVM2Graph extends Graph { } + @Override + protected boolean canBeBreakCandidate(BaseLocalData localData, GraphPart part) { + AVM2LocalData aLocalData = (AVM2LocalData) localData; + if (aLocalData.finallyTargetParts.containsValue(part)) { + return false; + } + return true; + } + + @Override protected void beforeGetLoops(BaseLocalData localData, String path, Set allParts, List throwStates) throws InterruptedException { AVM2LocalData avm2LocalData = ((AVM2LocalData) localData); + + for (int e = 0; e < body.exceptions.length; e++) { + ABCException ex = body.exceptions[e]; + if (ex.isFinally()) { + avm2LocalData.finallyTargetParts.put(e, searchPart(code.adr2pos(ex.target), allParts)); + } + } + avm2LocalData.codeStats = avm2LocalData.code.getStats(avm2LocalData.abc, avm2LocalData.methodBody, avm2LocalData.methodBody.init_scope_depth, false); getIgnoredSwitches((AVM2LocalData) localData, allParts); Set integerSwitchesIps = new HashSet<>(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionGraph.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionGraph.java index a1f3124db..9c60ca11b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionGraph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionGraph.java @@ -143,7 +143,7 @@ public class ActionGraph extends Graph { } @Override - protected boolean canBeBreakCandidate(GraphPart part) { + protected boolean canBeBreakCandidate(BaseLocalData localData, GraphPart part) { if (part.refs.size() <= 1) { return true; } 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 54112ccf2..647d71475 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Graph.java @@ -517,7 +517,6 @@ public class Graph { beforeGetLoops(localData, path, allParts, throwStates); List loops = new ArrayList<>(); - getLoops(localData, heads.get(0), loops, throwStates, null); afterGetLoops(localData, path, allParts); @@ -532,7 +531,7 @@ public class Graph { //TODO: Make getPrecontinues faster getBackEdges(localData, loops, throwStates); - new GraphPrecontinueDetector().detectPrecontinues(heads, allParts, loops); + new GraphPrecontinueDetector().detectPrecontinues(heads, allParts, loops, throwStates); /*System.err.println(""); for (Loop el : loops) { @@ -1155,13 +1154,21 @@ public class Graph { } } - private void getLoops(BaseLocalData localData, GraphPart part, List loops, List throwStates, List stopPart) throws InterruptedException { - clearLoops(loops); - getLoops(localData, part, loops, throwStates, stopPart, true, 1, new ArrayList<>()); - clearLoops(loops); + private void clearThrowStates(List throwStates) { + for (ThrowState ts : throwStates) { + ts.state = 0; + } } - protected boolean canBeBreakCandidate(GraphPart part) { + private void getLoops(BaseLocalData localData, GraphPart part, List loops, List throwStates, List stopPart) throws InterruptedException { + clearLoops(loops); + clearThrowStates(throwStates); + getLoopsWalk(localData, part, loops, throwStates, stopPart, true, new ArrayList<>(), 0); + clearLoops(loops); + clearThrowStates(throwStates); + } + + protected boolean canBeBreakCandidate(BaseLocalData localData, GraphPart part) { return true; } @@ -1169,7 +1176,21 @@ public class Graph { } - private void getLoops(BaseLocalData localData, GraphPart part, List loops, List throwStates, List stopPart, boolean first, int level, List visited) throws InterruptedException { + private void findPartsOutsideTry(ThrowState ts, GraphPart part, List ret, Set visited) { + if (visited.contains(part)) { + return; + } + visited.add(part); + if (!ts.throwingParts.contains(part)) { + ret.add(part); + return; + } + for (GraphPart n : part.nextParts) { + findPartsOutsideTry(ts, n, ret, visited); + } + } + + private void getLoopsWalk(BaseLocalData localData, GraphPart part, List loops, List throwStates, List stopPart, boolean first, List visited, int level) throws InterruptedException { if (part == null) { return; @@ -1184,6 +1205,15 @@ public class Graph { } checkGetLoopsPart(part); + List currentThrowStates = new ArrayList<>(); + + for (ThrowState ts : throwStates) { + if (ts.throwingParts.contains(part) && ts.state != 1) { + currentThrowStates.add(ts); + ts.state = 1; + } + } + if (debugGetLoops) { System.err.println("getloops: " + part); } @@ -1200,8 +1230,11 @@ public class Graph { } } - if (lastP1 != null && canBeBreakCandidate(part)) { + if (lastP1 != null && canBeBreakCandidate(localData, part)) { if (lastP1.breakCandidates.contains(part)) { + if (part.start == 54) { + System.err.println("xxx"); + } lastP1.breakCandidates.add(part); lastP1.breakCandidatesLevels.add(level); return; @@ -1259,16 +1292,16 @@ public class Graph { stopPart2.add(next); } if (next != nps.get(0)) { - getLoops(localData, nps.get(0), loops, throwStates, stopPart2, false, level + 1, visited); + getLoopsWalk(localData, nps.get(0), loops, throwStates, stopPart2, false, visited, level + 1); } if (next != nps.get(1)) { - getLoops(localData, nps.get(1), loops, throwStates, stopPart2, false, level + 1, visited); + getLoopsWalk(localData, nps.get(1), loops, throwStates, stopPart2, false, visited, level + 1); } if (next != null) { - getLoops(localData, next, loops, throwStates, stopPart, false, level, visited); + getLoopsWalk(localData, next, loops, throwStates, stopPart, false, visited, level); } } else if (part.nextParts.size() > 2 || partIsSwitch(part)) { - GraphPart next = getNextCommonPart(localData, part, loops, throwStates); + GraphPart next = getMostCommonPart(localData, part.nextParts, loops, throwStates); for (GraphPart p : part.nextParts) { List stopPart2 = stopPart == null ? new ArrayList<>() : new ArrayList<>(stopPart); @@ -1284,45 +1317,107 @@ public class Graph { } } if (next != p) { - getLoops(localData, p, loops, throwStates, stopPart2, false, level + 1, visited); + getLoopsWalk(localData, p, loops, throwStates, stopPart2, false, visited, level + 1); } } if (next != null) { - getLoops(localData, next, loops, throwStates, stopPart, false, level, visited); + getLoopsWalk(localData, next, loops, throwStates, stopPart, false, visited, level); } } else if (part.nextParts.size() == 1) { - getLoops(localData, part.nextParts.get(0), loops, throwStates, stopPart, false, level, visited); + getLoopsWalk(localData, part.nextParts.get(0), loops, throwStates, stopPart, false, visited, level); } List loops2 = new ArrayList<>(loops); - for (Loop l : loops2) { + /*for (Loop l : loops2) { l.breakCandidatesLocked++; - } + }*/ for (ThrowState ts : throwStates) { - //check state? - if (ts.throwingParts.contains(part)) { + if (ts.throwingParts.contains(part) && (currentThrowStates.contains(ts) || ts.state != 1)) { GraphPart t = ts.targetPart; if (!visited.contains(t)) { - getLoops(localData, t, loops, throwStates, stopPart, false, level, visited); + getLoopsWalk(localData, t, loops, throwStates, stopPart, false, visited, level + 1 /*???*/); } } } - for (Loop l : loops2) { + /*for (Loop l : loops2) { l.breakCandidatesLocked--; - } + }*/ if (isLoop && currentLoop != null) { GraphPart found; + + for (int i = 0; i < currentLoop.breakCandidates.size(); i++) { + GraphPart ch = checkPart(null, localData, null, currentLoop.breakCandidates.get(i), null); + if (ch == null) { + currentLoop.breakCandidates.remove(i); + currentLoop.breakCandidatesLevels.remove(i); + i--; + } + } + if (debugGetLoops) { + System.err.println("loop " + currentLoop + " break candidates:"); + for (GraphPart cand : currentLoop.breakCandidates) { + System.err.println("- " + cand); + } + } + + List contThrowStates = new ArrayList<>(); + + for (ThrowState ts : throwStates) { + if (ts.throwingParts.contains(currentLoop.loopContinue)) { + contThrowStates.add(ts.exceptionId); + } + } + Map removed = new HashMap<>(); - do { - found = null; - for (int i = 0; i < currentLoop.breakCandidates.size(); i++) { - GraphPart ch = checkPart(null, localData, null, currentLoop.breakCandidates.get(i), null); - if (ch == null) { - currentLoop.breakCandidates.remove(i); - i--; + + loopcand: + for (int c = 0; c < currentLoop.breakCandidates.size(); c++) { + GraphPart cand = currentLoop.breakCandidates.get(c); + List candThrowStates = new ArrayList<>(); + for (ThrowState ts : throwStates) { + if (ts.throwingParts.contains(cand)) { + if (contThrowStates.equals(candThrowStates)) { + //adding new ts + //this means breakcandidate is in nested try + if (debugGetLoops) { + System.err.println("candidate " + cand + " is in inner try, getting outside parts"); + } + List outsideTry = new ArrayList<>(); + findPartsOutsideTry(ts, cand, outsideTry, new HashSet<>()); + + for (int j = outsideTry.size() - 1; j >= 0; j--) { + if (!canBeBreakCandidate(localData, outsideTry.get(j))) { + outsideTry.remove(j); + } + } + if (debugGetLoops) { + for (GraphPart op : outsideTry) { + System.err.println("- outsidepart " + op); + } + } + int bcLevel = currentLoop.breakCandidatesLevels.get(c); + currentLoop.breakCandidates.remove(c); + + currentLoop.breakCandidates.addAll(c, outsideTry); + currentLoop.breakCandidatesLevels.remove(c); + + removed.put(cand, bcLevel); + for (int j = 0; j < outsideTry.size(); j++) { + currentLoop.breakCandidatesLevels.add(c, bcLevel); + } + + c--; + continue loopcand; + } + candThrowStates.add(ts.exceptionId); } } + } + + do { + found = null; + loopcand: for (GraphPart cand : currentLoop.breakCandidates) { for (GraphPart cand2 : currentLoop.breakCandidates) { @@ -1372,7 +1467,7 @@ public class Graph { removed.put(found, maxlevel); } } while ((found != null) && (currentLoop.breakCandidates.size() > 1)); - + Map count = new HashMap<>(); GraphPart winner = null; int winnerCount = 0; @@ -1431,7 +1526,7 @@ public class Graph { if (removedVisited.contains(r)) { continue; } - getLoops(localData, r, loops, throwStates, stopPart, false, removed.get(r), visited); + getLoopsWalk(localData, r, loops, throwStates, stopPart, false, visited, removed.get(r)); removedVisited.add(r); } start = false; @@ -1444,7 +1539,7 @@ public class Graph { el.phase = 2; } } - getLoops(localData, currentLoop.loopBreak, loops, throwStates, stopPart, false, level, visited); + getLoopsWalk(localData, currentLoop.loopBreak, loops, throwStates, stopPart, false, visited, level); } } @@ -1638,9 +1733,7 @@ public class Graph { boolean vCanHandleVisited = canHandleVisited(localData, part); - /*if (part.start == 31) { - - FIXME + /*if (part.start == 25) { new RuntimeException().printStackTrace(); }*/ if (vCanHandleVisited) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphPart.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphPart.java index 80b4ccec1..9c1ea15b9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphPart.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphPart.java @@ -175,7 +175,6 @@ public class GraphPart implements Serializable { return true; } } - if (useThrow) for (ThrowState ts : throwStates) { if (ts.state != 1) { if (ts.throwingParts.contains(this)) { @@ -188,15 +187,6 @@ public class GraphPart implements Serializable { } } } - /*if (useThrow) { - for (GraphPart p : throwParts) { - if (p == part) { - return true; - } else if (p.leadsTo(localData, gr, code, this, part, visited, loops, throwStates, useThrow)) { - return true; - } - } - }*/ return false; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Loop.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Loop.java index 106c360ca..cb4b83349 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Loop.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/Loop.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.graph; import java.io.Serializable; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/ThrowState.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/ThrowState.java index d3786c385..b353b2faf 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/ThrowState.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/ThrowState.java @@ -13,4 +13,29 @@ public class ThrowState { public Set throwingParts = new HashSet<>(); public GraphPart targetPart; + + @Override + public int hashCode() { + int hash = 3; + hash = 97 * hash + this.exceptionId; + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ThrowState other = (ThrowState) obj; + if (this.exceptionId != other.exceptionId) { + return false; + } + return true; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/precontinues/GraphPrecontinueDetector.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/precontinues/GraphPrecontinueDetector.java index f92b2373b..5a97d706f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/precontinues/GraphPrecontinueDetector.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/precontinues/GraphPrecontinueDetector.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.graph.precontinues; import com.jpexs.decompiler.graph.GraphPart; import com.jpexs.decompiler.graph.Loop; +import com.jpexs.decompiler.graph.ThrowState; import com.jpexs.helpers.Reference; import java.util.ArrayList; import java.util.HashMap; @@ -40,7 +41,7 @@ import java.util.Set; */ public class GraphPrecontinueDetector { - public void detectPrecontinues(List heads, Set allParts, List loops) { + public void detectPrecontinues(List heads, Set allParts, List loops, List throwStates) { boolean isSomethingTodo = false; for (Loop el : loops) { if (el.backEdges.size() == 1) { @@ -60,6 +61,12 @@ public class GraphPrecontinueDetector { for (GraphPart part : allParts) { Node node = partToNode.get(part); for (GraphPart prev : part.refs) { + /*if (prev.start < 0 && !partToNode.containsKey(prev)) { + Node minusNode = new Node(); + minusNode.graphPart = prev; + partToNode.put(prev, node); + continue; + }*/ if (prev.start < 0) { continue; } @@ -90,6 +97,12 @@ public class GraphPrecontinueDetector { } } + List targetParts = new ArrayList<>(); + + for (ThrowState ts : throwStates) { + targetParts.add(ts.targetPart); + } + for (Loop el : loops) { if (el.backEdges.size() == 1) { //System.err.println("loop " + el.loopContinue); @@ -97,15 +110,26 @@ public class GraphPrecontinueDetector { Node node = partToNode.get(backEdgePart); //System.err.println("backedge:" + backEdgePart); boolean wholeLoop = false; - while (node.parentNode != null) { - node = node.parentNode; - //System.err.println("- parent " + node.graphPart); - if (node.graphPart.equals(el.loopContinue)) { - wholeLoop = true; - break; + boolean inTryTarget = false; + + if (targetParts.contains(node.graphPart)) { + inTryTarget = true; + } + if (!inTryTarget) { + while (node.parentNode != null) { + node = node.parentNode; + //System.err.println("- parent " + node.graphPart); + if (node.graphPart.equals(el.loopContinue)) { + wholeLoop = true; + break; + } + if (targetParts.contains(node.graphPart)) { + inTryTarget = true; + break; + } } } - if (!wholeLoop) { + if (!wholeLoop && !inTryTarget) { el.loopPreContinue = node.graphPart; //System.err.println("found precontinue:" + node.graphPart); } diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.air.swf b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.air.swf index 429b394ed..3cfaf17dd 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.air.swf and b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.air.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex.swf b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex.swf index d4db64948..597cea95d 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex.swf and b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex_apache.swf b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex_apache.swf index 193a266e4..9aec6df3b 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex_apache.swf and b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex_apache.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.swftools.swf b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.swftools.swf index 87853972b..8cec9a9e4 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.swftools.swf and b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.swftools.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/obj/as3_cross_compileConfig.old b/libsrc/ffdec_lib/testdata/as3_cross_compile/obj/as3_cross_compileConfig.old index e4c2ad11e..05ccd9936 100644 --- a/libsrc/ffdec_lib/testdata/as3_cross_compile/obj/as3_cross_compileConfig.old +++ b/libsrc/ffdec_lib/testdata/as3_cross_compile/obj/as3_cross_compileConfig.old @@ -16,7 +16,7 @@ CONFIG::timeStamp - '06.02.2021' + '07.02.2021' CONFIG::air diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/obj/as3_cross_compileConfig.xml b/libsrc/ffdec_lib/testdata/as3_cross_compile/obj/as3_cross_compileConfig.xml index e4c2ad11e..05ccd9936 100644 --- a/libsrc/ffdec_lib/testdata/as3_cross_compile/obj/as3_cross_compileConfig.xml +++ b/libsrc/ffdec_lib/testdata/as3_cross_compile/obj/as3_cross_compileConfig.xml @@ -16,7 +16,7 @@ CONFIG::timeStamp - '06.02.2021' + '07.02.2021' CONFIG::air diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/src/Main.as b/libsrc/ffdec_lib/testdata/as3_cross_compile/src/Main.as index d979aa5f6..eece0b7e7 100644 --- a/libsrc/ffdec_lib/testdata/as3_cross_compile/src/Main.as +++ b/libsrc/ffdec_lib/testdata/as3_cross_compile/src/Main.as @@ -9,13 +9,14 @@ package * @author JPEXS */ public class Main extends MovieClip - { + { TestTryCatch; TestTryCatchIfInTry; TestTryCatchInIf; TestTryCatchInWhile; TestTryCatchInWhile2; TestTryCatchInWhile3; + TestTryCatchInWhile4; TestTryCatchLoop; TestTryCatchLoopBreak; TestTryCatchExceptionUsage diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchInWhile3.as b/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchInWhile3.as index e2ee5c3bd..3710d51dc 100644 --- a/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchInWhile3.as +++ b/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchInWhile3.as @@ -12,20 +12,20 @@ package tests { var a:int; a = 0; - trace("before loop"); - while (a > 5) + trace("before loop"); //1-17 + while (a > 5) //44-47 { try { - return "intry return"; + return "intry return"; //20-23 } catch(e:Error) { - trace("in catch"); + trace("in catch"); //26-43 } - a++; + a++; //26-43 cont. } - return "OK"; + return "OK";//48-50 } } diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchInWhile4.as b/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchInWhile4.as new file mode 100644 index 000000000..eb7f0b5d0 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchInWhile4.as @@ -0,0 +1,37 @@ +package tests +{ + /** + * ... + * @author JPEXS + */ + public class TestTryCatchInWhile4 + { + + public function run() : void + { + var a:int; + a = 0; + + while (true) { + + try + { + trace("try2"); //12-21 + if (a == 10){ + trace("br"); + break; + } + return; + } + catch(e:Error) + { + trace("in catch2"); + } + trace("a=" + a); + } + trace("after"); //61-66 + } + + } + +} \ No newline at end of file diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchLoopBreak.as b/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchLoopBreak.as index 51c64b75a..3fc1a330e 100644 --- a/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchLoopBreak.as +++ b/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchLoopBreak.as @@ -13,59 +13,23 @@ package tests { var a:int; a = 0; - trace("before loop");//1-15 + trace("before loop"); try { - trace("try1a");//16-22 - while (a < 10){ //34-37 loop0 - trace("a=" + a); //23-33 + trace("in try1"); + while (a < 10){ + trace("a=" + a); a++; } - trace("try1b"); //38-44 - //45-45 + trace("in try2"); + } catch(e:Error) { - trace("in catch"); //46-61 + trace("in catch"); } - trace("middle");//62-68 - - - while (a < 20) { //104-107 loop1 - //69-69 - try - { - trace("try2"); //70-77 - return; - } - catch(e:Error) - { - trace("in catch2"); //80-103 - } - trace("a=" + a); //pokračuje 80-103 - } - trace("middle2"); //108-114 - - while (true) { //161-161 loop2 - //115-115 - try - { - trace("try3"); //116-122 - } - catch(e:Error) - { - trace("in catch3"); //124-141 - break; - } - catch(e:EOFError) - { - trace("in catch4"); //141-159 - break; - } - //123-123 - } - trace("exit"); //162-167 + trace("after"); } diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchLoopBreak2.as b/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchLoopBreak2.as new file mode 100644 index 000000000..4d527e002 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchLoopBreak2.as @@ -0,0 +1,36 @@ +package tests +{ + import flash.errors.EOFError; + /** + * ... + * @author JPEXS + */ + public class TestTryCatchLoopBreak2 + { + + + public function run() : void + { + var a:int; + a = 0; + trace("before loop"); + + while (a < 20) { + + try + { + trace("in try"); + return; + } + catch(e:Error) + { + trace("in catch"); + } + trace("a=" + a); + } + trace("after"); + } + + } + +} \ No newline at end of file diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchLoopBreak3.as b/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchLoopBreak3.as new file mode 100644 index 000000000..804ebc38b --- /dev/null +++ b/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchLoopBreak3.as @@ -0,0 +1,41 @@ +package tests +{ + import flash.errors.EOFError; + /** + * ... + * @author JPEXS + */ + public class TestTryCatchLoopBreak3 + { + + + public function run() : void + { + var a:int; + a = 0; + trace("before loop"); + while (true) { + + try + { + trace("in try"); + } + catch(e:Error) + { + trace("in catch1"); + break; + } + catch(e:EOFError) + { + trace("in catch2"); + break; + } + + } + trace("after"); + + } + + } + +} \ No newline at end of file