Fixed: AS3 with statement decompilation

This commit is contained in:
Jindra Petřík
2021-02-20 22:01:46 +01:00
parent b9749678f9
commit 8a6c4cf35c
14 changed files with 160 additions and 14 deletions

View File

@@ -18,10 +18,8 @@ public class ActionScript3AssembledDecompileTest extends ActionScript3DecompileT
@Test
public void testDeclareReg() {
decompileMethod("assembled", "testDeclareReg", "var _loc3_:*;\r\n"
+ "with(_loc3_ = other)\r\n"
decompileMethod("assembled", "testDeclareReg", "with(other)\r\n"
+ "{\r\n"
+ "\r\n"
+ "trace(\"hey\");\r\n"
+ "}\r\n",
false);

View File

@@ -513,6 +513,28 @@ public class ActionScript3CrossCompileDecompileTest extends ActionScript3Decompi
false);
}
@Test(dataProvider = "swfNamesProvider")
public void testTryCatchWith(String swfUsed) {
decompileMethod(swfUsed, "testTryCatchWith", "var a:MyTest = new MyTest();\r\n"
+ "trace(\"before with\");\r\n"
+ "with(a)\r\n"
+ "{\r\n"
+ "trace(\"before try\");\r\n"
+ "try\r\n"
+ "{\r\n"
+ "trace(\"in try\");\r\n"
+ "}\r\n"
+ "catch(e:Error)\r\n"
+ "{\r\n"
+ "attrib = attrib + 1;\r\n"
+ "trace(\"in catch\");\r\n"
+ "}\r\n"
+ "trace(\"after try\");\r\n"
+ "}\r\n"
+ "trace(\"after\");\r\n",
false);
}
@Test(dataProvider = "swfNamesProvider")
public void testTryFinally(String swfUsed) {
decompileMethod(swfUsed, "testTryFinally", "trace(\"before try\");\r\n"

View File

@@ -504,6 +504,32 @@ public class ActionScript3CrossCompileSwfToolsDecompileTest extends ActionScript
false);
}
@Test
public void testTryCatchWith() {
decompileMethod("swftools", "testTryCatchWith", "var _loc1_:* = new MyTest();\r\n"
+ "trace(\"before with\");\r\n"
+ "var _loc2_:*;\r\n"
+ "with(_loc2_ = _loc1_)\r\n"
+ "{\r\n"
+ "trace(\"before try\");\r\n"
+ "try\r\n"
+ "{\r\n"
+ "trace(\"in try\");\r\n"
+ "}\r\n"
+ "catch(e:Error)\r\n"
+ "{\r\n"
+ "with(_loc2_)\r\n"
+ "{\r\n"
+ "\r\n"
+ "attrib = attrib + 1;\r\n"
+ "trace(\"in catch\");\r\n"
+ "}\r\n"
+ "trace(\"after try\");\r\n"
+ "}\r\n"
+ "trace(\"after\");\r\n",
false);
}
@Test
public void testTryFinally() {
decompileMethod("swftools", "testTryFinally", "trace(\"before try\");\r\n"