try in if fix

This commit is contained in:
Jindra Petřík
2021-02-07 22:28:50 +01:00
parent ebc8e86323
commit 16c2ec01ea
12 changed files with 108 additions and 5 deletions

View File

@@ -1067,7 +1067,7 @@ public class AVM2Graph extends Graph {
}
}
if (afterPart == null && localData.pushDefaultPart.containsKey(finallyIndex)) {
if (localData.pushDefaultPart.containsKey(finallyIndex)) {
exAfterPart = localData.pushDefaultPart.get(finallyIndex);
tryStopPart.add(exAfterPart);
}

View File

@@ -238,15 +238,14 @@ public class Graph {
GraphPartQueue newParts = new GraphPartQueue();
List<GraphPart> nextParts = new ArrayList<>(getNextParts(localData, part));
/*
!!THROW
for (ThrowState ts : throwStates) {
if (ts.state != 1) {
if (ts.throwingParts.contains(part)) {
newParts.add(ts.targetPart);
}
}
}*/
}
loopnext:
for (GraphPart nextRaw : nextParts) {

View File

@@ -94,6 +94,36 @@ public class ActionScript3CrossCompileDecompileTest extends ActionScript3Decompi
false);
}
@Test(dataProvider = "swfNamesProvider")
public void testTryCatchInIf2(String swfUsed) {
decompileMethod(swfUsed, "testTryCatchInIf2", "var a:int = Math.random();\r\n"
+ "if(a > 10)\r\n"
+ "{\r\n"
+ "try\r\n"
+ "{\r\n"
+ "trace(\"a\");\r\n"
+ "return;\r\n"
+ "}\r\n"
+ "catch(e:Error)\r\n"
+ "{\r\n"
+ "trace(\"in catch 1\");\r\n"
+ "}\r\n"
+ "}\r\n"
+ "else\r\n"
+ "{\r\n"
+ "try\r\n"
+ "{\r\n"
+ "trace(\"b\");\r\n"
+ "}\r\n"
+ "catch(e:Error)\r\n"
+ "{\r\n"
+ "trace(\"in catch 2\");\r\n"
+ "}\r\n"
+ "}\r\n"
+ "trace(\"after\");\r\n",
false);
}
@Test(dataProvider = "swfNamesProvider")
public void testTryCatchInWhile(String swfUsed) {
decompileMethod(swfUsed, "testTryCatchInWhile", "trace(\"before loop\");\r\n"

View File

@@ -85,6 +85,36 @@ public class ActionScript3CrossCompileSwfToolsDecompileTest extends ActionScript
false);
}
@Test
public void testTryCatchInIf2() {
decompileMethod("swftools", "testTryCatchInIf2", "var _loc1_:int = Math.random();\r\n"
+ "if(_loc1_ > 10)\r\n"
+ "{\r\n"
+ "try\r\n"
+ "{\r\n"
+ "trace(\"a\");\r\n"
+ "return;\r\n"
+ "}\r\n"
+ "catch(e:Error)\r\n"
+ "{\r\n"
+ "trace(\"in catch 1\");\r\n"
+ "}\r\n"
+ "}\r\n"
+ "else\r\n"
+ "{\r\n"
+ "try\r\n"
+ "{\r\n"
+ "trace(\"b\");\r\n"
+ "}\r\n"
+ "catch(e:Error)\r\n"
+ "{\r\n"
+ "trace(\"in catch 2\");\r\n"
+ "}\r\n"
+ "}\r\n"
+ "trace(\"after\");\r\n",
false);
}
@Test
public void testTryCatchInWhile() {
decompileMethod("swftools", "testTryCatchInWhile", "trace(\"before loop\");\r\n"

View File

@@ -13,6 +13,7 @@ package
TestTryCatch;
TestTryCatchIfInTry;
TestTryCatchInIf;
TestTryCatchInIf2;
TestTryCatchInWhile;
TestTryCatchInWhile2;
TestTryCatchInWhile3;

View File

@@ -0,0 +1,43 @@
package tests
{
/**
* ...
* @author JPEXS
*/
public class TestTryCatchInIf2
{
public function run():void
{
var a:int = Math.random();
if (a > 10)
{
try
{
trace("a");
return;
}
catch (e:Error)
{
trace("in catch 1");
}
}
else
{
try
{
trace("b");
}
catch (e:Error)
{
trace("in catch 2");
}
}
trace("after");
}
}
}

View File

@@ -5,7 +5,7 @@ package tests
{
public function run():*
{
trace("hello");
trace("hello");
}
}
}