From 07e43b5bcec6f27d8cf26a89ecabac60bbac8943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Sun, 13 Apr 2014 20:00:22 +0200 Subject: [PATCH] AS3 parser: get/set property stats fix. List of differences from official compiler. --- .../abc/avm2/instructions/other/GetPropertyIns.java | 13 +++++++------ .../abc/avm2/instructions/other/SetPropertyIns.java | 9 +++++---- .../flash/abc/avm2/parser/script/diff.txt | 5 +++++ .../flash/abc/avm2/parser/script/todo.txt | 3 +-- 4 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/diff.txt diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java index d8ee104b0..0a3f58763 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java @@ -25,7 +25,6 @@ import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.graph.GraphTargetItem; import java.util.HashMap; import java.util.List; @@ -49,11 +48,13 @@ public class GetPropertyIns extends InstructionDefinition { public int getStackDelta(AVM2Instruction ins, ABC abc) { int ret = -1 + 1; int multinameIndex = ins.operands[0]; - int kind = abc.constants.getMultiname(multinameIndex).kind; - if (kind != Multiname.MULTINAMEL && kind != Multiname.MULTINAMELA) { //FIXME!!! - if (abc.constants.getMultiname(multinameIndex).needsName()) { - ret--; - } + //Note: In official compiler, the stack can be wrong(greater) for some MULTINAMEL/A, e.g. increments + /* + var arr=[1,2,3]; + return arr[2]++; + */ + if (abc.constants.getMultiname(multinameIndex).needsName()) { + ret--; } if (abc.constants.getMultiname(multinameIndex).needsNs()) { ret--; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java index 6fd593c7f..ca83f9004 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java @@ -134,10 +134,11 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns public int getStackDelta(AVM2Instruction ins, ABC abc) { int ret = -2; int multinameIndex = ins.operands[0]; - int multinameKind = abc.constants.getMultiname(multinameIndex).kind; - if (multinameKind == Multiname.MULTINAMEL || multinameKind == Multiname.MULTINAMELA) { //FIXME!!! - return 0; - } + //Note: In official compiler, the stack can be wrong(greater) for some MULTINAMEL/A, e.g. increments + /* + var arr=[1,2,3]; + trace(arr[2]++); + */ if (abc.constants.getMultiname(multinameIndex).needsName()) { ret--; } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/diff.txt b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/diff.txt new file mode 100644 index 000000000..5f34f4339 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/diff.txt @@ -0,0 +1,5 @@ +List of differences between FFDec and official compiler +-------------------------------------------------------- +- Maximal stack count in method body can be lower in FFDec as official compiler in some cases calculates it wrong (e.g. increments and set/get property). +- In names of type Multiname(L/LA), namespaceset can have namespaces in different order, this is because official compiler generates + this based on constructor position inside class \ No newline at end of file diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/todo.txt b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/todo.txt index 84adb6748..8e38be43f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/todo.txt +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/todo.txt @@ -2,5 +2,4 @@ TODO List for AS3 parser/compiler: ------------------------------ - E4X (XML) - default xml namespace -- custom namespace modifiers -- fix setproperty, getproperty stats calculation (stack pos) \ No newline at end of file +- custom namespace modifiers \ No newline at end of file