From 287f7868f07f98a2cb59f049f21126fc09dab26d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Mon, 4 Mar 2013 19:59:14 +0100 Subject: [PATCH] Issue #37 reversed loop conditions in AS3 --- .../com/jpexs/decompiler/flash/graph/Graph.java | 2 +- .../decompiler/flash/ActionScript3Test.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java b/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java index 3246e8b54..8f91c90d9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java +++ b/trunk/src/com/jpexs/decompiler/flash/graph/Graph.java @@ -905,7 +905,7 @@ public class Graph { } GraphPart loopBodyStart = null; GraphPart next = part.getNextPartPath(loopContinues); - if (((!reversed) || loop) && (expr instanceof LogicalOpItem)) { + if ((reversed == loop) && (expr instanceof LogicalOpItem)) { expr = ((LogicalOpItem) expr).invert(); } List retx = ret; diff --git a/trunk/test/com/jpexs/decompiler/flash/ActionScript3Test.java b/trunk/test/com/jpexs/decompiler/flash/ActionScript3Test.java index d6917b7e1..5f7a342ce 100644 --- a/trunk/test/com/jpexs/decompiler/flash/ActionScript3Test.java +++ b/trunk/test/com/jpexs/decompiler/flash/ActionScript3Test.java @@ -98,7 +98,7 @@ public class ActionScript3Test { + "trace(\"a=\"+a);\r\n" + "a++;\r\n" + "}\r\n" - + "while(a>=20);\r\n", false); + + "while(a<20);\r\n", false); } @Test @@ -184,7 +184,7 @@ public class ActionScript3Test { + "case 57*a:\r\n" + "trace(\"fiftyseven multiply a\");\r\n" + "b=0;\r\n" - + "while(b>=50)\r\n" + + "while(b<50)\r\n" + "{\r\n" + "if(b==10)\r\n" + "{\r\n" @@ -216,10 +216,10 @@ public class ActionScript3Test { + "}\r\n" + "c=0;\r\n" + "loop0:\r\n" - + "for(;c>=8;c=c+1)\r\n" + + "for(;c<8;c=c+1)\r\n" + "{\r\n" + "d=0;\r\n" - + "while(d>=25)\r\n" + + "while(d<25)\r\n" + "{\r\n" + "e=0;\r\n" + "if(e>=50)\r\n" @@ -294,7 +294,7 @@ public class ActionScript3Test { @Test public void testForBreak() { decompileMethod("testForBreak", "var a:* = 0;\r\n" - + "while(a>=10)\r\n" + + "while(a<10)\r\n" + "{\r\n" + "if(a==5)\r\n" + "{\r\n" @@ -334,7 +334,7 @@ public class ActionScript3Test { @Test public void testFor() { decompileMethod("testFor", "var a:* = 0;\r\n" - + "while(a>=10)\r\n" + + "while(a<10)\r\n" + "{\r\n" + "trace(\"a=\"+a);\r\n" + "a++;\r\n" @@ -344,7 +344,7 @@ public class ActionScript3Test { @Test public void testForContinue() { decompileMethod("testForContinue", "var a:* = 0;\r\n" - + "for(;a>=10;a=a+1)\r\n" + + "for(;a<10;a=a+1)\r\n" + "{\r\n" + "if(a==9)\r\n" + "{\r\n" @@ -754,7 +754,7 @@ public class ActionScript3Test { + "do\r\n" + "{\r\n" + "k++;\r\n" - + "if(k==7)\r\n" + + "if(k!=7)\r\n" + "{\r\n" + "k=5*k;\r\n" + "}\r\n"