#349 AS3 - better handling of declarations

This commit is contained in:
Jindra Petřík
2021-02-04 21:36:09 +01:00
parent 041decaab1
commit 9c6b46ba79
28 changed files with 397 additions and 105 deletions

View File

@@ -16,6 +16,17 @@ public class ActionScript3AssembledDecompileTest extends ActionScript3DecompileT
addSwf("assembled", "testdata/as3_assembled/bin/as3_assembled.swf");
}
@Test
public void testDeclareReg() {
decompileMethod("assembled", "testDeclareReg", "var _loc3_:*;\r\n"
+ "with(_loc3_ = other)\r\n"
+ "{\r\n"
+ "\r\n"
+ "trace(\"hey\");\r\n"
+ "}\r\n",
false);
}
@Test
public void testDoubleDup() {
decompileMethod("assembled", "testDoubleDup", "var _loc10_:Rectangle = myprop(_loc5_);\r\n"
@@ -25,7 +36,8 @@ public class ActionScript3AssembledDecompileTest extends ActionScript3DecompileT
@Test
public void testDup() {
decompileMethod("assembled", "testDup", "return 1 - (var _loc1_:Number = 1 - _loc1_ / _loc4_) * _loc1_;\r\n",
decompileMethod("assembled", "testDup", "var _loc1_:Number;\r\n"
+ "return 1 - (_loc1_ = 1 - _loc1_ / _loc4_) * _loc1_;\r\n",
false);
}
@@ -90,6 +102,7 @@ public class ActionScript3AssembledDecompileTest extends ActionScript3DecompileT
@Test
public void testSetSlotDup() {
decompileMethod("assembled", "testSetSlotDup", "var _loc5_:int = 5;\r\n"
+ "var myslot:int;\r\n"
+ "myname.somemethod(\"okay\",myslot = _loc5_);\r\n"
+ "myname.start();\r\n",
false);
@@ -97,7 +110,8 @@ public class ActionScript3AssembledDecompileTest extends ActionScript3DecompileT
@Test
public void testSetSlotFindProperty() {
decompileMethod("assembled", "testSetSlotFindProperty", "return var myprop:int = 50;\r\n",
decompileMethod("assembled", "testSetSlotFindProperty", "var myprop:int;\r\n"
+ "return myprop = 50;\r\n",
false);
}

View File

@@ -743,7 +743,6 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
@Test
public void testInc2() {
decompileMethod("classic_air", "testInc2", "var a:* = [1];\r\n"
+ "a[this.getInt()]++;\r\n"
+ "var d:* = a[this.getInt()]++;\r\n"
+ "var e:* = ++a[this.getInt()];\r\n"
+ "a[this.getInt()]++;\r\n"
@@ -942,7 +941,8 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile
public void testNamedAnonFunctions() {
decompileMethod("classic_air", "testNamedAnonFunctions", "var test:* = new function():*\r\n"
+ "{\r\n"
+ "return var testFunc:Function = function(param1:*, param2:int, param3:Array):Boolean\r\n"
+ "var testFunc:Function;\r\n"
+ "return testFunc = function(param1:*, param2:int, param3:Array):Boolean\r\n"
+ "{\r\n"
+ "return (param1 as TestClass2).attrib1 == 5;\r\n"
+ "};\r\n"

View File

@@ -734,7 +734,6 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes
@Test
public void testInc2() {
decompileMethod("classic", "testInc2", "var a:* = [1];\r\n"
+ "++a[this.getInt()];\r\n"
+ "var d:* = a[this.getInt()]++;\r\n"
+ "var e:* = ++a[this.getInt()];\r\n"
+ "++a[this.getInt()];\r\n"