diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java index 0a753b27f..fb45aaa61 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -694,6 +694,7 @@ public class ABC { SWFDecompilerPlugin.fireMethodBodyParsed(this, mb, swf); } + //this will read all method body codes. TODO: make this ondemand refreshMultinameNamespaceSuffixes(); getMethodIndexing(); 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 f0cdba7b9..2d94f2ddd 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 @@ -1577,7 +1577,7 @@ public class AVM2Code implements Cloneable { } } } - if ((ins.definition instanceof SetLocalTypeIns) && (ip + 1 <= end)) { // set_local_x,get_local_x.. no other local_x get + /*if ((ins.definition instanceof SetLocalTypeIns) && (ip + 1 <= end)) { // set_local_x,get_local_x.. no other local_x get AVM2Instruction insAfter = code.get(ip + 1); Set usages = setLocalPosToGetLocalPos.containsKey(ip) ? setLocalPosToGetLocalPos.get(ip) : new HashSet<>(); @@ -1590,7 +1590,8 @@ public class AVM2Code implements Cloneable { ip++; continue iploop; } - } else if (ins.definition instanceof DupIns) { + } else*/ + if (ins.definition instanceof DupIns) { int nextPos; do { AVM2Instruction insAfter = ip + 1 < code.size() ? code.get(ip + 1) : null; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java index e9eb2971e..c5fa37546 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; import com.jpexs.decompiler.flash.abc.ABC; @@ -136,8 +137,7 @@ public abstract class SetLocalTypeIns extends InstructionDefinition implements S } @Override - public int getStackPopCount(AVM2Instruction ins, ABC abc - ) { + public int getStackPopCount(AVM2Instruction ins, ABC abc) { return 1; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java index 96144afcb..047c821c4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.instructions.other; import com.jpexs.decompiler.flash.abc.ABC; @@ -24,6 +25,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.SetTypeIns; import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.ApplyTypeAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.ConstructAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.DecrementAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item; @@ -63,8 +65,10 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns SetLocalAVM2Item valueSetLocalReg = (SetLocalAVM2Item) item; if ((valueSetLocalReg.value instanceof IncrementAVM2Item) || (valueSetLocalReg.value instanceof DecrementAVM2Item)) { boolean isIncrement = (valueSetLocalReg.value instanceof IncrementAVM2Item); - if (valueSetLocalReg.value.value instanceof GetPropertyAVM2Item) { - GetPropertyAVM2Item getProperty = (GetPropertyAVM2Item) valueSetLocalReg.value.value; + boolean hasConvert = valueSetLocalReg.value.value instanceof ConvertAVM2Item; //in air there is convert added when postincrement + + if (valueSetLocalReg.value.value.getNotCoercedNoDup() instanceof GetPropertyAVM2Item) { + GetPropertyAVM2Item getProperty = (GetPropertyAVM2Item) valueSetLocalReg.value.value.getNotCoercedNoDup(); FullMultinameAVM2Item propertyName = ((FullMultinameAVM2Item) getProperty.propertyName); SetLocalAVM2Item nameSetLocalReg = null; if (propertyName.name instanceof SetLocalAVM2Item) { @@ -82,18 +86,16 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns } getProperty.object = objSetLocalReg.value; - if (standalone) { - if (isIncrement) { + if (isIncrement) { + if (hasConvert && standalone) { return new PostIncrementAVM2Item(ins, localData.lineStartInstruction, getProperty); - } else { + } + return new PreIncrementAVM2Item(ins, localData.lineStartInstruction, getProperty); + } else { + if (hasConvert && standalone) { return new PostDecrementAVM2Item(ins, localData.lineStartInstruction, getProperty); } - } else { - if (isIncrement) { - return new PreIncrementAVM2Item(ins, localData.lineStartInstruction, getProperty); - } else { - return new PreDecrementAVM2Item(ins, localData.lineStartInstruction, getProperty); - } + return new PreDecrementAVM2Item(ins, localData.lineStartInstruction, getProperty); } } } @@ -169,9 +171,9 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns if (getProp.object.value == obj) { getProp.object = obj; if (isIncrement) { - output.add(new PostIncrementAVM2Item(ins, localData.lineStartInstruction, getProp)); + output.add(new PreIncrementAVM2Item(ins, localData.lineStartInstruction, getProp)); } else { - output.add(new PostDecrementAVM2Item(ins, localData.lineStartInstruction, getProp)); + output.add(new PreDecrementAVM2Item(ins, localData.lineStartInstruction, getProp)); } return; } @@ -188,7 +190,7 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns if (obj instanceof LocalRegAVM2Item) { LocalRegAVM2Item objLocalReg = (LocalRegAVM2Item) obj; - if (!output.isEmpty() && !stack.isEmpty()) { + if (!output.isEmpty()) { if (output.get(output.size() - 1) instanceof SetLocalAVM2Item) { SetLocalAVM2Item valueSetLocalReg = (SetLocalAVM2Item) output.get(output.size() - 1); if ((valueSetLocalReg.value instanceof IncrementAVM2Item) @@ -196,7 +198,7 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns boolean isIncrement = (valueSetLocalReg.value instanceof IncrementAVM2Item); if (valueSetLocalReg.value.value instanceof DuplicateItem) { GraphTargetItem duplicated = valueSetLocalReg.value.value.value; - if (stack.peek() == duplicated) { + if (!stack.isEmpty() && stack.peek() == duplicated) { GraphTargetItem notCoerced = duplicated.getNotCoerced(); if (notCoerced instanceof GetPropertyAVM2Item) { GetPropertyAVM2Item getProperty = (GetPropertyAVM2Item) notCoerced; @@ -249,7 +251,6 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns return; } } - } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopIns.java index c20e803b8..099e87a79 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopIns.java @@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.MarkItem; import com.jpexs.decompiler.graph.TranslateStack; @@ -54,6 +55,10 @@ public class PopIns extends InstructionDefinition { return; } + if (top instanceof FindPropertyAVM2Item) { + return; + } + output.add(top); } diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3AssembledDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3AssembledDecompileTest.java index 18374d1c3..8ba0f1d13 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3AssembledDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3AssembledDecompileTest.java @@ -82,7 +82,7 @@ public class ActionScript3AssembledDecompileTest extends ActionScript3DecompileT @Test public void testIncrement3() { - decompileMethod("assembled", "testIncrement3", "_loc1_.length--;\r\n", + decompileMethod("assembled", "testIncrement3", "--_loc1_.length;\r\n", false); } diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3ClassicDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3ClassicDecompileTest.java index 6dee0742e..83c6eac77 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3ClassicDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3ClassicDecompileTest.java @@ -250,9 +250,9 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes + "var g:* = undefined;\r\n" + "d = new TestClass1();\r\n" + "k = null;\r\n" - + "k.(d.attrib++, 0);\r\n" + + "k.(++d.attrib, 0);\r\n" + "trace(\"between\");\r\n" - + "g = k.(d.attrib++, 0);\r\n" + + "g = k.(++d.attrib, 0);\r\n" + "trace(\"end\");\r\n", false); } @@ -733,9 +733,11 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes @Test public void testInc2() { decompileMethod("classic", "testInc2", "var a:* = [1];\r\n" - + "a[this.getInt()]++;\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" + + "++a[this.getInt()];\r\n" + "var b:* = 1;\r\n" + "b++;\r\n" + "var c:* = 1;\r\n" @@ -776,9 +778,11 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes + "trace(\"arr[e++]\");\r\n" + "var chars:Array = new Array(36);\r\n" + "var index:uint = 0;\r\n" - + "chars[index++] = 5;\r\n" + + "var _loc7_:* = index++;\r\n" + + "chars[_loc7_] = 5;\r\n" + "trace(\"arr[++e]\");\r\n" - + "chars[++index] = 5;\r\n", + + "var _loc8_:* = ++index;\r\n" + + "chars[_loc8_] = 5;\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 eff1649d0..69821c54b 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 1d035dfc1..6ad6c6b53 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/obj/as3_newConfig.old b/libsrc/ffdec_lib/testdata/as3_new/obj/as3_newConfig.old index 60b1928bd..bf76cee95 100644 --- a/libsrc/ffdec_lib/testdata/as3_new/obj/as3_newConfig.old +++ b/libsrc/ffdec_lib/testdata/as3_new/obj/as3_newConfig.old @@ -16,7 +16,7 @@ CONFIG::timeStamp - '03.02.2021' + '04.02.2021' CONFIG::air diff --git a/libsrc/ffdec_lib/testdata/as3_new/obj/as3_newConfig.xml b/libsrc/ffdec_lib/testdata/as3_new/obj/as3_newConfig.xml index 60b1928bd..bf76cee95 100644 --- a/libsrc/ffdec_lib/testdata/as3_new/obj/as3_newConfig.xml +++ b/libsrc/ffdec_lib/testdata/as3_new/obj/as3_newConfig.xml @@ -16,7 +16,7 @@ CONFIG::timeStamp - '03.02.2021' + '04.02.2021' CONFIG::air diff --git a/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestInc2.as b/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestInc2.as index 9a6a08b91..7764a1fba 100644 --- a/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestInc2.as +++ b/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestInc2.as @@ -5,10 +5,13 @@ package tests { public function run():* { - var a:* = [1]; - a[this.getInt()]++; + var a:* = [1]; var d:* = a[this.getInt()]++; var e:* = ++a[this.getInt()]; + + a[this.getInt()]++; + ++a[this.getInt()]; + var b:* = 1; b++; var c:* = 1;