diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 76c02e764..5adcfa062 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -2031,7 +2031,9 @@ public class AVM2Code implements Cloneable { if (code.get(ip + plus + 3).definition instanceof SetPropertyIns) { functionName = abc.constants.getMultiname(code.get(ip + plus + 3).operands[0]).getName(usedDeobfuscations, abc, abc.constants, fullyQualifiedNames, true, true); localScopeStack.pop(); // with - output.remove(output.size() - 1); // with + stack.finishBlock(output); + stack.moveToStack(output); + output.remove(output.size() - 1); // with ip = ip + plus + 4; // +1 below } } diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicAirDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicAirDecompileTest.java index f7e9863db..81ce3180d 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicAirDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicAirDecompileTest.java @@ -1834,7 +1834,15 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile + "{\r\n" + "return (param1 as TestClass2).attrib1 == 5;\r\n" + "};\r\n" - + "})();\r\n", + + "})();\r\n" + + "f(5,(function():*\r\n" + + "{\r\n" + + "var g:Function;\r\n" + + "return g = function():int\r\n" + + "{\r\n" + + "return 42;\r\n" + + "};\r\n" + + "})());\r\n", false); } diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java index 52ac41aca..3eb47d3f4 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassicDecompileTest.java @@ -1831,7 +1831,11 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes decompileMethod("classic", "testNamedAnonFunctions", "var test:* = function testFunc(param1:*, param2:int, param3:Array):Boolean\r\n" + "{\r\n" + "return (param1 as TestClass2).attrib1 == 5;\r\n" - + "};\r\n", + + "};\r\n" + + "this.f(5,function g():int\r\n" + + "{\r\n" + + "return 42;\r\n" + + "});\r\n", false); } diff --git a/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.air.swf b/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.air.swf index c7c10d4a4..b61f62f03 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.air.swf and b/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.air.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.flex.swf b/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.flex.swf index 1aaa3549f..4b5f60fc9 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.flex.swf and b/libsrc/ffdec_lib/testdata/as3_new/bin/as3_new.flex.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestNamedAnonFunctions.as b/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestNamedAnonFunctions.as index 6e7cb644b..b8b570c5d 100644 --- a/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestNamedAnonFunctions.as +++ b/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestNamedAnonFunctions.as @@ -8,7 +8,14 @@ package tests { return (param1 as TestClass2).attrib1 == 5; }; - } + f(5, function g():int { + return 42; + }); + } + + private function f(a:int,b:Function) + { + } } } diff --git a/libsrc/ffdec_lib/testexpected/as3_new/tests/TestNamedAnonFunctions.as b/libsrc/ffdec_lib/testexpected/as3_new/tests/TestNamedAnonFunctions.as index 5a24f0f4c..32e7888cf 100644 --- a/libsrc/ffdec_lib/testexpected/as3_new/tests/TestNamedAnonFunctions.as +++ b/libsrc/ffdec_lib/testexpected/as3_new/tests/TestNamedAnonFunctions.as @@ -54,7 +54,7 @@ package tests returns null body - maxstack 4 + maxstack 5 localcount 2 initscopedepth 5 maxscopedepth 8 @@ -74,7 +74,7 @@ package tests getscopeobject 1 newobject 0 pushwith - newfunction 2 + newfunction 3 dup getscopeobject 2 swap @@ -82,90 +82,128 @@ package tests popscope coerce_a setslot 1 + getlocal0 + pushbyte 5 + newobject 0 + pushwith + newfunction 4 + dup + getscopeobject 2 + swap + setproperty QName(PackageNamespace("tests"),"g") + popscope + callpropvoid QName(PrivateNamespace("tests:TestNamedAnonFunctions"),"f"), 2 + returnvoid + end ; code + end ; body + end ; method + } + + private function f(a:int, b:Function) : * + { + trait method QName(PrivateNamespace("tests:TestNamedAnonFunctions"),"f") + dispid 0 + method + name "tests:TestNamedAnonFunctions/private/f" + param QName(PackageNamespace(""),"int") + param QName(PackageNamespace(""),"Function") + returns null + + body + maxstack 1 + localcount 3 + initscopedepth 4 + maxscopedepth 5 + + code + getlocal0 + pushscope + debug 1, "a", 0, 0 + debug 1, "b", 1, 0 + returnvoid + end ; code + end ; body + end ; method + } + } + } + + class TestClass2 + { + + method + name "" + returns null + + body + maxstack 1 + localcount 1 + initscopedepth 3 + maxscopedepth 4 + + code + getlocal0 + pushscope + returnvoid + end ; code + end ; body + end ; method + + public var attrib1:int; + + public function TestClass2() + { + method + name "TestNamedAnonFunctions.as$0:TestClass2/TestClass2" + returns null + + body + maxstack 1 + localcount 1 + initscopedepth 4 + maxscopedepth 5 + + code + getlocal0 + pushscope + getlocal0 + constructsuper 0 returnvoid end ; code end ; body end ; method } } - } - - class TestClass2 - { method name "" returns null body - maxstack 1 + maxstack 2 localcount 1 - initscopedepth 3 - maxscopedepth 4 + initscopedepth 1 + maxscopedepth 3 code getlocal0 pushscope + findpropstrict Multiname("TestNamedAnonFunctions",[PackageNamespace("tests")]) + getlex QName(PackageNamespace(""),"Object") + pushscope + getlex QName(PackageNamespace(""),"Object") + newclass 0 + popscope + initproperty QName(PackageNamespace("tests"),"TestNamedAnonFunctions") + findpropstrict Multiname("TestClass2",[PrivateNamespace("TestNamedAnonFunctions.as$0")]) + getlex QName(PackageNamespace(""),"Object") + pushscope + getlex QName(PackageNamespace(""),"Object") + newclass 1 + popscope + initproperty QName(PrivateNamespace("TestNamedAnonFunctions.as$0"),"TestClass2") returnvoid end ; code end ; body end ; method - public var attrib1:int; - - public function TestClass2() - { - method - name "TestNamedAnonFunctions.as$0:TestClass2/TestClass2" - returns null - - body - maxstack 1 - localcount 1 - initscopedepth 4 - maxscopedepth 5 - - code - getlocal0 - pushscope - getlocal0 - constructsuper 0 - returnvoid - end ; code - end ; body - end ; method - } - } - - method - name "" - returns null - - body - maxstack 2 - localcount 1 - initscopedepth 1 - maxscopedepth 3 - - code - getlocal0 - pushscope - findpropstrict Multiname("TestNamedAnonFunctions",[PackageNamespace("tests")]) - getlex QName(PackageNamespace(""),"Object") - pushscope - getlex QName(PackageNamespace(""),"Object") - newclass 0 - popscope - initproperty QName(PackageNamespace("tests"),"TestNamedAnonFunctions") - findpropstrict Multiname("TestClass2",[PrivateNamespace("TestNamedAnonFunctions.as$0")]) - getlex QName(PackageNamespace(""),"Object") - pushscope - getlex QName(PackageNamespace(""),"Object") - newclass 1 - popscope - initproperty QName(PrivateNamespace("TestNamedAnonFunctions.as$0"),"TestClass2") - returnvoid - end ; code - end ; body - end ; method -