diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/DupIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/DupIns.java index 979ea1ad6..efd023a71 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/DupIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/DupIns.java @@ -30,6 +30,7 @@ import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.model.DuplicateItem; import com.jpexs.decompiler.graph.model.DuplicateSourceItem; import com.jpexs.decompiler.graph.model.HasTempIndex; +import com.jpexs.decompiler.graph.model.SetTemporaryItem; import java.util.List; /** @@ -69,6 +70,12 @@ public class DupIns extends InstructionDefinition { } else { temp = localData.maxTempIndex.getVal() + 1; localData.maxTempIndex.setVal(temp); + /* + //TODO: somehow implement this. Currently it fails many tests:-( + stack.finishBlock(output); + stack.addToOutput(new SetTemporaryItem(AVM2GraphTargetDialect.INSTANCE, ins, localData.lineStartInstruction, v, temp, "dup")); + stack.finishBlock(output); + */ stack.push(new DuplicateSourceItem(AVM2GraphTargetDialect.INSTANCE, ins, localData.lineStartInstruction, v, temp)); } } diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3AssembledDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3AssembledDecompileTest.java index a3bff01be..4b22ab482 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3AssembledDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3AssembledDecompileTest.java @@ -340,28 +340,23 @@ public class ActionScript3AssembledDecompileTest extends ActionScript3DecompileT @Test public void testPushWhile() { decompileMethod("assembled", "testPushWhile", "var _loc3_:int = 5;\r\n" - + "§§push(§§dupsrc(new (getDefinitionByName(\"flash.utils\"+\".\"+§§dupsrc(\"ByteArray\")))()));\r\n" - + "§§push(§§dup(new (getDefinitionByName(\"flash.utils\"+\".\"+§§dupsrc(\"ByteArray\")))()));\r\n" - + "§§push(obfuscated);\r\n" - + "§§swap();\r\n" - + "§§push(\"xxx\");\r\n" - + "§§swap();\r\n" - + "§§pop()[§§pop()] = §§pop();\r\n" + + "var _temp_1:*;\r\n" + + "§§push(obfuscated[\"xxx\"] = new (getDefinitionByName(\"flash.utils\"+\".\"+_temp_1))());\r\n" + "§§push(50);\r\n" + "while(true)\r\n" + "{\r\n" - + "§§push(§§dupsrc(§§pop()));\r\n" - + "if(!§§dup(§§pop()))\r\n" + + "var _temp_4:*;\r\n" + + "§§push(_temp_4);\r\n" + + "if(!_temp_4)\r\n" + "{\r\n" + "break;\r\n" + "}\r\n" - + "§§push(§§pop() - 1);\r\n" - + "§§swap();\r\n" - + "§§push(§§dupsrc(§§pop()));\r\n" - + "§§dupsrc(§§dup(§§pop()))[§§dup(§§dup(§§pop())).length] = 0x29 ^ 0x6F;\r\n" - + "§§push(§§dupsrc(§§pop()));\r\n" - + "§§dupsrc(§§dup(§§pop()))[§§dup(§§dup(§§pop())).length] = 9 ^ 0x54;\r\n" - + "§§swap();\r\n" + + "var _temp_5:* = §§pop();\r\n" + + "var _temp_6:* = §§pop() - 1;\r\n" + + "_temp_5[_temp_5.length] = 0x29 ^ 0x6F;\r\n" + + "_temp_5[_temp_5.length] = 9 ^ 0x54;\r\n" + + "§§push(_temp_5);\r\n" + + "§§push(_temp_6);\r\n" + "}\r\n" + "§§pop();\r\n" + "§§pop();\r\n", diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3CrossCompileSwfToolsDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3CrossCompileSwfToolsDecompileTest.java index 118995957..91ba4b162 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3CrossCompileSwfToolsDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3CrossCompileSwfToolsDecompileTest.java @@ -713,16 +713,16 @@ public class ActionScript3CrossCompileSwfToolsDecompileTest extends ActionScript + "var _loc1_:int = 5;\r\n" + "if(_loc1_ > 4)\r\n" + "{\r\n" - + "§§push(\"RET\");\r\n" + + "var _temp_1:* = \"RET\";\r\n" + "trace(\"in finally\");\r\n" - + "return §§pop();\r\n" + + "return _temp_1;\r\n" + "}\r\n" + "trace(\"between\");\r\n" + "if(_loc1_ < 3)\r\n" + "{\r\n" - + "§§push(\"RE2\");\r\n" + + "var _temp_2:* = \"RE2\";\r\n" + "trace(\"in finally\");\r\n" - + "return §§pop();\r\n" + + "return _temp_2;\r\n" + "}\r\n" + "trace(\"in try2\");\r\n" + "}\r\n" @@ -790,10 +790,10 @@ public class ActionScript3CrossCompileSwfToolsDecompileTest extends ActionScript + "trace(\"in try2\");\r\n" + "if(_loc1_ > 4)\r\n" + "{\r\n" - + "§§push(\"RET\");\r\n" + + "var _temp_1:* = \"RET\";\r\n" + "trace(\"in finally2\");\r\n" + "trace(\"in finally1\");\r\n" - + "return §§pop();\r\n" + + "return _temp_1;\r\n" + "}\r\n" + "}\r\n" + "catch(e:Error)\r\n" @@ -835,11 +835,11 @@ public class ActionScript3CrossCompileSwfToolsDecompileTest extends ActionScript + "trace(\"in try2\");\r\n" + "if(_loc1_ > 4)\r\n" + "{\r\n" - + "§§push(\"RET\");\r\n" + + "var _temp_1:* = \"RET\";\r\n" + "trace(\"in finally2\");\r\n" + "trace(\"in finally1\");\r\n" + "trace(\"in finally0\");\r\n" - + "return §§pop();\r\n" + + "return _temp_1;\r\n" + "}\r\n" + "}\r\n" + "catch(e2:Error)\r\n"