diff --git a/CHANGELOG.md b/CHANGELOG.md index ab562bfe9..1e179e451 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. - AS3 break loop in catch clause - AS3 inner functions scope (setslot/getslot) - AS3 p-code traits of bodys of inner methods +- AS3 getslot/setslot, getglobalscope instruction ## [13.0.0] - 2021-02-08 ### Added 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 92e47aeeb..e814ce9aa 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 @@ -254,6 +254,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.InitPropertyAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.NewFunctionAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.ReturnVoidAVM2Item; @@ -1875,32 +1876,34 @@ public class AVM2Code implements Cloneable { } if (subItem instanceof SetSlotAVM2Item) { SetSlotAVM2Item ssti = (SetSlotAVM2Item) subItem; - Slot sl = new Slot(ssti.scope, ssti.slotName); - if (!declaredSlots.contains(sl)) { - GraphTargetItem type = TypeItem.UNBOUNDED; - for (int t = 0; t < body.traits.traits.size(); t++) { - if (body.traits.traits.get(t).getName(abc) == sl.multiname) { - if (body.traits.traits.get(t) instanceof TraitSlotConst) { - type = PropertyAVM2Item.multinameToType(((TraitSlotConst) body.traits.traits.get(t)).type_index, abc.constants); + if (ssti.scope instanceof NewActivationAVM2Item) { + Slot sl = new Slot(ssti.scope, ssti.slotName); + if (!declaredSlots.contains(sl)) { + GraphTargetItem type = TypeItem.UNBOUNDED; + for (int t = 0; t < body.traits.traits.size(); t++) { + if (body.traits.traits.get(t).getName(abc) == sl.multiname) { + if (body.traits.traits.get(t) instanceof TraitSlotConst) { + type = PropertyAVM2Item.multinameToType(((TraitSlotConst) body.traits.traits.get(t)).type_index, abc.constants); + } } } - } - DeclarationAVM2Item d = new DeclarationAVM2Item(subItem, type); - ssti.setDeclaration(d); - declaredSlotsDec.add(d); - declaredSlots.add(sl); + DeclarationAVM2Item d = new DeclarationAVM2Item(subItem, type); + ssti.setDeclaration(d); + declaredSlotsDec.add(d); + declaredSlots.add(sl); + + if (subItem == currentItem) { + items.set(i, d); + } else { + d.showValue = false; + items.add(i, d); + i++; + } - if (subItem == currentItem) { - items.set(i, d); } else { - d.showValue = false; - items.add(i, d); - i++; + int idx = declaredSlots.indexOf(sl); + ssti.setDeclaration(declaredSlotsDec.get(idx)); } - - } else { - int idx = declaredSlots.indexOf(sl); - ssti.setDeclaration(declaredSlotsDec.get(idx)); } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java index 6f3752d68..64ec3cd53 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java @@ -32,6 +32,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.ClassAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.GlobalAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item; @@ -40,6 +41,7 @@ import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitWithSlot; +import com.jpexs.decompiler.flash.abc.types.traits.Traits; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -325,49 +327,51 @@ public abstract class InstructionDefinition implements Serializable { return localData.code.adr2pos(src.getAddress()); } - protected Multiname searchSlotName(int slotIndex, AVM2LocalData localData, GraphTargetItem obj) { - return searchSlotName(slotIndex, localData, obj, -1); + protected static Multiname searchSlotName(int slotIndex, AVM2LocalData localData, GraphTargetItem obj, Reference realObj) { + return searchSlotName(slotIndex, localData, obj, -1, realObj); } - private Multiname searchSlotName(int slotIndex, AVM2LocalData localData, GraphTargetItem obj, int multiNameIndex) { + private static Multiname searchSlotName(int slotIndex, AVM2LocalData localData, GraphTargetItem obj, int multiNameIndex, Reference realObj) { if ((obj instanceof ExceptionAVM2Item) && (multiNameIndex == -1 || ((ExceptionAVM2Item) obj).exception.name_index == multiNameIndex)) { return localData.getConstants().getMultiname(((ExceptionAVM2Item) obj).exception.name_index); - } else if ((obj instanceof ThisAVM2Item) || (obj instanceof ClassAVM2Item)) { - List traits = localData.getScriptInfo().get(localData.scriptIndex).traits.traits; - for (int t = 0; t < traits.size(); t++) { - Trait trait = traits.get(t); - if (trait instanceof TraitWithSlot) { - if (multiNameIndex == -1 || trait.name_index == multiNameIndex) { - if (((TraitWithSlot) trait).getSlotIndex() == slotIndex) { - return trait.getName(localData.abc); - } - } - } - } - } else if (obj instanceof NewActivationAVM2Item) { - MethodBody body = localData.methodBody; - List traits = body.traits.traits; - for (int t = 0; t < traits.size(); t++) { - Trait trait = traits.get(t); - if (trait instanceof TraitWithSlot) { - if (multiNameIndex == -1 || trait.name_index == multiNameIndex) { - if (((TraitWithSlot) trait).getSlotIndex() == slotIndex) { - return trait.getName(localData.abc); - } - } - } - } - } else if (obj instanceof FindPropertyAVM2Item) { + } + + if (obj instanceof FindPropertyAVM2Item) { FindPropertyAVM2Item findProp = (FindPropertyAVM2Item) obj; for (GraphTargetItem item : localData.scopeStack) { - Multiname ret = searchSlotName(slotIndex, localData, item, ((FullMultinameAVM2Item) findProp.propertyName).multinameIndex); + Multiname ret = searchSlotName(slotIndex, localData, item, ((FullMultinameAVM2Item) findProp.propertyName).multinameIndex, realObj); if (ret != null) { return ret; } } - + return null; } + + Traits traits = null; + if (obj instanceof NewActivationAVM2Item) { + traits = localData.methodBody.traits; + } else if (obj instanceof ThisAVM2Item) { + traits = localData.abc.instance_info.get(localData.classIndex).instance_traits; + } else if (obj instanceof ClassAVM2Item) { + traits = localData.abc.class_info.get(localData.classIndex).static_traits; + } else if (obj instanceof GlobalAVM2Item) { + traits = localData.abc.script_info.get(localData.scriptIndex).traits; + } + if (traits != null) { + for (int t = 0; t < traits.traits.size(); t++) { + Trait trait = traits.traits.get(t); + if (trait instanceof TraitWithSlot) { + if (multiNameIndex == -1 || trait.name_index == multiNameIndex) { + if (((TraitWithSlot) trait).getSlotIndex() == slotIndex) { + realObj.setVal(obj); + return trait.getName(localData.abc); + } + } + } + } + } + return null; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/SetTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/SetTypeIns.java index 67b220339..8afd571af 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/SetTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/SetTypeIns.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; import com.jpexs.decompiler.flash.abc.ABC; @@ -36,8 +37,6 @@ import java.util.Stack; */ public interface SetTypeIns { - public abstract String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, MethodBody body, HashMap localRegNames, List fullyQualifiedNames) throws InterruptedException; - public static void handleResult(GraphTargetItem value, TranslateStack stack, List output, AVM2LocalData localData, GraphTargetItem result, int regId) { GraphTargetItem notCoercedValue = value; if ((value instanceof CoerceAVM2Item) || (value instanceof ConvertAVM2Item)) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java index 81dc010f2..2d3f7b8da 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java @@ -23,6 +23,7 @@ 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.NewFunctionAVM2Item; import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.ScopeStack; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -39,7 +40,7 @@ public class NewFunctionIns extends InstructionDefinition { @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int methodIndex = ins.operands[0]; - NewFunctionAVM2Item function = new NewFunctionAVM2Item(ins, localData.lineStartInstruction, "", path, false, localData.scriptIndex, localData.classIndex, localData.abc, localData.fullyQualifiedNames, methodIndex, localData.scopeStack); + NewFunctionAVM2Item function = new NewFunctionAVM2Item(ins, localData.lineStartInstruction, "", path, false, localData.scriptIndex, localData.classIndex, localData.abc, localData.fullyQualifiedNames, methodIndex, (ScopeStack) localData.scopeStack.clone()); stack.push(function); } 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 c5fa37546..1717c958a 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 @@ -141,14 +141,5 @@ public abstract class SetLocalTypeIns extends InstructionDefinition implements S return 1; } - @Override - public String getObject(Stack stack, ABC abc, - AVM2Instruction ins, List output, - MethodBody body, HashMap localRegNames, - List fullyQualifiedNames - ) { - return AVM2Item.localRegName(localRegNames, getRegisterId(ins)); - } - public abstract int getRegisterId(AVM2Instruction ins); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java index c7c55249c..517d97bd4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.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.GlobalAVM2Item; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -43,7 +44,9 @@ public class GetGlobalScopeIns extends InstructionDefinition { @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { - stack.push(localData.scopeStack.get(0)); + //Note: it is not true that "The global scope object is the object at the bottom of the scope stack.", + //It is special scope which is not present at standard scope stack. + stack.push(new GlobalAVM2Item(ins, localData.lineStartInstruction)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java index 0e29edc3c..640c3cba3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.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; @@ -21,6 +22,7 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; 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.GetSlotAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.GlobalAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.Multiname; @@ -28,6 +30,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; +import com.jpexs.helpers.Reference; import java.util.List; /** @@ -43,23 +46,9 @@ public class GetGlobalSlotIns extends InstructionDefinition { @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int slotIndex = ins.operands[0]; - GraphTargetItem obj = localData.scopeStack.get(0); //scope - Multiname slotname = null; - if (obj instanceof ExceptionAVM2Item) { - slotname = localData.getConstants().getMultiname(((ExceptionAVM2Item) obj).exception.name_index); - } else { - MethodBody body = localData.methodBody; - List traits = body.traits.traits; - for (int t = 0; t < traits.size(); t++) { - Trait trait = traits.get(t); - if (trait instanceof TraitSlotConst) { - if (((TraitSlotConst) trait).slot_id == slotIndex) { - slotname = trait.getName(localData.abc); - } - } - - } - } + GraphTargetItem obj = new GlobalAVM2Item(ins, localData.lineStartInstruction); + Reference realObj = new Reference<>(null); + Multiname slotname = InstructionDefinition.searchSlotName(slotIndex, localData, obj, realObj); stack.push(new GetSlotAVM2Item(ins, localData.lineStartInstruction, obj, obj, slotIndex, slotname)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java index 885bcdeb8..e8a295338 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.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.model.GetSlotAVM2Item; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; +import com.jpexs.helpers.Reference; import java.util.List; /** @@ -41,7 +43,9 @@ public class GetSlotIns extends InstructionDefinition { int slotIndex = ins.operands[0]; GraphTargetItem objinreg = stack.pop(); //scope GraphTargetItem obj = objinreg.getThroughRegister(); - Multiname slotname = searchSlotName(slotIndex, localData, obj); + Reference realObj = new Reference<>(null); + Multiname slotname = InstructionDefinition.searchSlotName(slotIndex, localData, obj, realObj); + obj = realObj.getVal(); stack.push(new GetSlotAVM2Item(ins, localData.lineStartInstruction, obj, objinreg, slotIndex, slotname)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetGlobalSlotIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetGlobalSlotIns.java index c492b5082..80cae9613 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetGlobalSlotIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetGlobalSlotIns.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; @@ -22,8 +23,10 @@ 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.instructions.SetTypeIns; import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.SetGlobalSlotAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.GlobalAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.SetSlotAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; @@ -43,18 +46,14 @@ public class SetGlobalSlotIns extends InstructionDefinition implements SetTypeIn @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { + int slotIndex = ins.operands[0]; GraphTargetItem value = stack.pop(); - GraphTargetItem result = new SetGlobalSlotAVM2Item(ins, localData.lineStartInstruction, ins.operands[0], value); - SetTypeIns.handleResult(value, stack, output, localData, result, -1); + GraphTargetItem obj = new GlobalAVM2Item(ins, localData.lineStartInstruction); + SetSlotIns.handleSetSlot(localData, stack, ins, output, slotIndex, obj, value); } @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { return 1; } - - @Override - public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { - return "globalslot" + ins.operands[0]; - } } 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 047c821c4..4cc2cca66 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 @@ -279,15 +279,4 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns int multinameIndex = ins.operands[0]; return 2 + getMultinameRequiredStackSize(abc.constants, multinameIndex); } - - @Override - public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - String multiname = resolveMultinameNoPop(0, stack, abc.constants, multinameIndex, ins, fullyQualifiedNames); - GraphTargetItem obj = stack.get(1 + resolvedCount(abc.constants, multinameIndex)); //pod vrcholem - if ((!obj.toString().isEmpty())) { - multiname = "." + multiname; - } - return obj + multiname; - } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java index 00d88b640..402eb921d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.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; @@ -38,6 +39,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; +import com.jpexs.helpers.Reference; import java.util.HashMap; import java.util.List; import java.util.Stack; @@ -57,12 +59,21 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns { int slotIndex = ins.operands[0]; GraphTargetItem value = stack.pop(); GraphTargetItem obj = stack.pop(); //scopeId + if (obj.getThroughRegister() instanceof NewActivationAVM2Item) { + ((NewActivationAVM2Item) obj.getThroughRegister()).slots.put(slotIndex, value); + } + handleSetSlot(localData, stack, ins, output, slotIndex, obj, value); + } + + public static void handleSetSlot(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, int slotIndex, GraphTargetItem obj, GraphTargetItem value) { + GraphTargetItem objnoreg = obj; obj = obj.getThroughRegister(); - if (obj instanceof NewActivationAVM2Item) { - ((NewActivationAVM2Item) obj).slots.put(slotIndex, value); - } - Multiname slotname = searchSlotName(slotIndex, localData, obj); + + Reference realObj = new Reference<>(null); + Multiname slotname = InstructionDefinition.searchSlotName(slotIndex, localData, obj, realObj); + + obj = realObj.getVal(); if (slotname != null) { if (value instanceof LocalRegAVM2Item) { @@ -134,20 +145,4 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns { public int getStackPopCount(AVM2Instruction ins, ABC abc) { return 2; } - - @Override - public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { - int slotIndex = ins.operands[0]; - ////String obj = stack.get(1); - String slotname = ""; - for (int t = 0; t < body.traits.traits.size(); t++) { - if (body.traits.traits.get(t) instanceof TraitSlotConst) { - if (((TraitSlotConst) body.traits.traits.get(t)).slot_id == slotIndex) { - slotname = body.traits.traits.get(t).getName(abc).getName(abc.constants, fullyQualifiedNames, true, true); - } - } - - } - return slotname; - } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java index fe523cbb9..80afe1ba2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java @@ -64,13 +64,4 @@ public class SetSuperIns extends InstructionDefinition implements SetTypeIns { return 2 + getMultinameRequiredStackSize(abc.constants, multinameIndex); } - @Override - public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, MethodBody body, HashMap localRegNames, List fullyQualifiedNames) throws InterruptedException { - int multinameIndex = ins.operands[0]; - String multiname = resolveMultinameNoPop(1, stack, abc.constants, multinameIndex, ins, fullyQualifiedNames); - HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), false); - stack.get(1 + resolvedCount(abc.constants, multinameIndex)).toString(writer, LocalData.create(abc, localRegNames, fullyQualifiedNames)); - String obj = writer.toString(); - return obj + ".super." + multiname; - } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetGlobalSlotAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GlobalAVM2Item.java similarity index 61% rename from libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetGlobalSlotAVM2Item.java rename to libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GlobalAVM2Item.java index 457c0c1e9..a4ef69cb5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetGlobalSlotAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GlobalAVM2Item.java @@ -12,56 +12,51 @@ * 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.model; +import com.jpexs.decompiler.flash.ecma.ObjectType; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; -import com.jpexs.decompiler.graph.GraphPart; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TypeItem; import com.jpexs.decompiler.graph.model.LocalData; +import java.util.HashMap; /** * * @author JPEXS */ -public class SetGlobalSlotAVM2Item extends AVM2Item { +public class GlobalAVM2Item extends AVM2Item { - public int slotId; - - @Override - public GraphPart getFirstPart() { - return value.getFirstPart(); - } - - public SetGlobalSlotAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, int slotId, GraphTargetItem value) { - super(instruction, lineStartIns, PRECEDENCE_ASSIGMENT, value); - this.slotId = slotId; + public GlobalAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns) { + super(instruction, lineStartIns, PRECEDENCE_PRIMARY); } @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { - writer.append("§§setglobalslot"); - writer.spaceBeforeCallParenthesies(2); - writer.append("("); - writer.append(slotId).append(","); - value.toString(writer, localData); - return writer.append(")"); + return writer.append("global"); } @Override - public boolean hasSideEffect() { + public Object getResult() { + return new ObjectType(new HashMap<>()) { + @Override + public String toString() { + return "global"; + } + }; + } + + @Override + public boolean hasReturnValue() { return true; } @Override public GraphTargetItem returnType() { - return TypeItem.UNBOUNDED; + return new TypeItem("global"); } - @Override - public boolean hasReturnValue() { - return false; - } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java index 7d411ad2c..efd7454fa 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java @@ -87,7 +87,7 @@ public class NewFunctionAVM2Item extends AVM2Item { abc.method_info.get(methodIndex).getReturnTypeStr(writer, abc.constants, fullyQualifiedNames); writer.startBlock(); if (body != null) { - body.convert(new ConvertData(), path + "/inner", ScriptExportMode.AS, isStatic, methodIndex, scriptIndex, classIndex, abc, null, (ScopeStack) this.scopeStack.clone(), 0, new NulWriter(), fullyQualifiedNames, null, false); + body.convert(new ConvertData(), path + "/inner", ScriptExportMode.AS, isStatic, methodIndex, scriptIndex, classIndex, abc, null, new ScopeStack(), 0, new NulWriter(), fullyQualifiedNames, null, false); body.toString(path + "/inner", ScriptExportMode.AS, abc, null, writer, fullyQualifiedNames); } writer.endBlock(); diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DecompileTestBase.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DecompileTestBase.java index 859ce5d8f..cef4bb645 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DecompileTestBase.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DecompileTestBase.java @@ -93,7 +93,7 @@ public abstract class ActionScript3DecompileTestBase extends ActionScriptTestBas Configuration.autoDeobfuscate.set(methodName.toLowerCase().contains("obfus")); - abc.bodies.get(bodyIndex).convert(new ConvertData(), "run", ScriptExportMode.AS, isStatic, abc.bodies.get(bodyIndex).method_info, scriptIndex, clsIndex, abc, null, new ScopeStack(scriptIndex), 0, new NulWriter(), new ArrayList<>(), ts, true); + abc.bodies.get(bodyIndex).convert(new ConvertData(), "run", ScriptExportMode.AS, isStatic, abc.bodies.get(bodyIndex).method_info, scriptIndex, clsIndex, abc, null, new ScopeStack(), 0, new NulWriter(), new ArrayList<>(), ts, true); writer = new HighlightedTextWriter(new CodeFormatting(), false); abc.bodies.get(bodyIndex).toString("run", ScriptExportMode.AS, abc, null, writer, new ArrayList<>()); } catch (InterruptedException ex) { diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassTest.java index 7fa0d264a..a53c75a05 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3ClassTest.java @@ -26,14 +26,15 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase { @BeforeClass public void init() throws IOException, InterruptedException { addSwf("standard", "testdata/as3_new/bin/as3_new.flex.swf"); + addSwf("assembled", "testdata/as3_assembled/bin/as3_assembled.swf"); } - private void decompileScriptPack(String path, String expectedResult) { + private void decompileScriptPack(String swfId, String path, String expectedResult) { DoABC2Tag tag = null; ABC abc = null; ScriptPack scriptPack = null; - for (Tag t : getSwf("standard").getTags()) { + for (Tag t : getSwf(swfId).getTags()) { if (t instanceof DoABC2Tag) { tag = (DoABC2Tag) t; abc = tag.getABC(); @@ -59,7 +60,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase { @Test public void testMyPackage1TestClass() { - decompileScriptPack("tests_classes.mypackage1.TestClass", "package tests_classes.mypackage1\n" + decompileScriptPack("standard", "tests_classes.mypackage1.TestClass", "package tests_classes.mypackage1\n" + "{\n" + " public class TestClass implements tests_classes.mypackage1.TestInterface\n" + " {\n" @@ -96,7 +97,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase { @Test public void testMyPackage1TestClass2() { - decompileScriptPack("tests_classes.mypackage1.TestClass2", "package tests_classes.mypackage1\n" + decompileScriptPack("standard", "tests_classes.mypackage1.TestClass2", "package tests_classes.mypackage1\n" + "{\n" + " public class TestClass2\n" + " {\n" @@ -139,7 +140,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase { @Test public void testMyPackage1TestInterface() { - decompileScriptPack("tests_classes.mypackage1.TestInterface", "package tests_classes.mypackage1\n" + decompileScriptPack("standard", "tests_classes.mypackage1.TestInterface", "package tests_classes.mypackage1\n" + "{\n" + " public interface TestInterface extends tests_classes.mypackage2.TestInterface\n" + " {\n" @@ -151,7 +152,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase { @Test public void testMyPackage1MyNamespace() { - decompileScriptPack("tests_classes.mypackage1.myNamespace", "package tests_classes.mypackage1\n" + decompileScriptPack("standard", "tests_classes.mypackage1.myNamespace", "package tests_classes.mypackage1\n" + "{\n" + " public namespace myNamespace = \"https://www.free-decompiler.com/flash/test/namespace\";\n" + "}"); @@ -159,7 +160,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase { @Test public void testMyPackage2TestClass() { - decompileScriptPack("tests_classes.mypackage2.TestClass", "package tests_classes.mypackage2\n" + decompileScriptPack("standard", "tests_classes.mypackage2.TestClass", "package tests_classes.mypackage2\n" + "{\n" + " public class TestClass implements TestInterface\n" + " {\n" @@ -184,7 +185,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase { @Test public void testMyPackage2TestInterface() { - decompileScriptPack("tests_classes.mypackage2.TestInterface", "package tests_classes.mypackage2\n" + decompileScriptPack("standard", "tests_classes.mypackage2.TestInterface", "package tests_classes.mypackage2\n" + "{\n" + " public interface TestInterface\n" + " {\n" @@ -196,7 +197,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase { @Test public void testMyPackage3TestClass() { - decompileScriptPack("tests_classes.mypackage3.TestClass", "package tests_classes.mypackage3\n" + decompileScriptPack("standard", "tests_classes.mypackage3.TestClass", "package tests_classes.mypackage3\n" + "{\n" + " public class TestClass\n" + " {\n" @@ -217,7 +218,7 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase { @Test public void testThisOutsideClass() { - decompileScriptPack("tests_classes.TestThisOutsideClass", "package tests_classes\n" + decompileScriptPack("standard", "tests_classes.TestThisOutsideClass", "package tests_classes\n" + "{\n" + " public class TestThisOutsideClass\n" + " {\n" @@ -243,4 +244,54 @@ public class ActionScript3ClassTest extends ActionScript3DecompileTestBase { + " this.attrib++;\n" + "}"); } + + @Test + public void testSlots() { + decompileScriptPack("assembled", "tests.TestSlots", "package tests\n" + + "{\n" + + " public class TestSlots\n" + + " {\n" + + " \n" + + " public static var classVar1:String = \"cls1\";\n" + + " \n" + + " public static var classVar2:String = \"cls2\";\n" + + " \n" + + " \n" + + " public var instanceVar1:String = \"ins1\";\n" + + " \n" + + " public var instanceVar2:String = \"ins2\";\n" + + " \n" + + " public function TestSlots()\n" + + " {\n" + + " super();\n" + + " }\n" + + " \n" + + " public static function classMethod() : void\n" + + " {\n" + + " trace(classVar1);\n" + + " trace(classVar2);\n" + + " trace(globalVar1);\n" + + " trace(globalVar2);\n" + + " }\n" + + " \n" + + " public function instanceMethod() : void\n" + + " {\n" + + " trace(instanceVar1);\n" + + " trace(instanceVar2);\n" + + " trace(globalVar1);\n" + + " trace(globalVar2);\n" + + " }\n" + + " }\n" + + "}\n" + + "\n" + + "var globalVar1:String = \"glb1\";\n" + + "\n" + + "var globalVar2:String = \"glb2\";\n" + + "\n" + + "function globalFunction():void\n" + + "{\n" + + " trace(globalVar1);\n" + + " trace(globalVar2);\n" + + "}"); + } } 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 2bda0bbe2..702e35db2 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 @@ -880,6 +880,18 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile false); } + @Test + public void testInnerFunctionScope() { + decompileMethod("classic_air", "testInnerFunctionScope", "a = a;\r\n" + + "var innerFunc:Function = function(b:String):*\r\n" + + "{\r\n" + + "testProm = 4;\r\n" + + "trace(testProm);\r\n" + + "};\r\n" + + "innerFunc(a);\r\n", + false); + } + @Test public void testInnerFunctions() { decompileMethod("classic_air", "testInnerFunctions", "a = a;\r\n" 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 aed9a9565..6aa8afd73 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 @@ -874,6 +874,17 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes false); } + @Test + public void testInnerFunctionScope() { + decompileMethod("classic", "testInnerFunctionScope", "var innerFunc:Function = function(b:String):*\r\n" + + "{\r\n" + + "testProm = 4;\r\n" + + "trace(testProm);\r\n" + + "};\r\n" + + "innerFunc(a);\r\n", + false); + } + @Test public void testInnerFunctions() { decompileMethod("classic", "testInnerFunctions", "var s:int = 0;\r\n" diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3CrossCompileDecompileTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3CrossCompileDecompileTest.java index 0e45c83c7..015a30a73 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3CrossCompileDecompileTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/as3decompile/ActionScript3CrossCompileDecompileTest.java @@ -417,15 +417,16 @@ public class ActionScript3CrossCompileDecompileTest extends ActionScript3Decompi + "trace(\"in catch1\");\r\n" + "while(true)\r\n" + "{\r\n" + + "trace(\"xx\");\r\n" + "if(a > 5)\r\n" + "{\r\n" + "break;\r\n" + "}\r\n" + + "trace(\"yy\");\r\n" + "}\r\n" + "trace(\"in catch1c\");\r\n" + "}\r\n" - + "}\r\n" - + "trace(\"after\");\r\n", + + "}\r\n", false); } 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 2f8ef49e0..ea00cada0 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 @@ -408,15 +408,16 @@ public class ActionScript3CrossCompileSwfToolsDecompileTest extends ActionScript + "trace(\"in catch1\");\r\n" + "while(true)\r\n" + "{\r\n" + + "trace(\"xx\");\r\n" + "if(_loc1_ > 5)\r\n" + "{\r\n" + "break;\r\n" + "}\r\n" + + "trace(\"yy\");\r\n" + "}\r\n" + "trace(\"in catch1c\");\r\n" + "}\r\n" - + "}\r\n" - + "trace(\"after\");\r\n", + + "}\r\n", false); } diff --git a/libsrc/ffdec_lib/testdata/as3_assembled/abc/as3_assembled-0/as3_assembled-0.main.abc b/libsrc/ffdec_lib/testdata/as3_assembled/abc/as3_assembled-0/as3_assembled-0.main.abc index f6d2e4bc8..452721813 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_assembled/abc/as3_assembled-0/as3_assembled-0.main.abc and b/libsrc/ffdec_lib/testdata/as3_assembled/abc/as3_assembled-0/as3_assembled-0.main.abc differ diff --git a/libsrc/ffdec_lib/testdata/as3_assembled/abc/as3_assembled-0/as3_assembled-0.main.asasm b/libsrc/ffdec_lib/testdata/as3_assembled/abc/as3_assembled-0/as3_assembled-0.main.asasm index 18c2a11f1..bf7085e30 100644 --- a/libsrc/ffdec_lib/testdata/as3_assembled/abc/as3_assembled-0/as3_assembled-0.main.asasm +++ b/libsrc/ffdec_lib/testdata/as3_assembled/abc/as3_assembled-0/as3_assembled-0.main.asasm @@ -23,5 +23,7 @@ program #include "tests/TestDeobfuscatorJumpsExceptionStart.script.asasm" #include "tests/TestUnnamedException.script.asasm" #include "tests/TestTryCatchLoopBreakLevel2.script.asasm" + #include "tests/TestSlots.script.asasm" + #include "tests/TestSlots.init/inline_method.method.asasm" ; place to add next end ; program diff --git a/libsrc/ffdec_lib/testdata/as3_assembled/abc/as3_assembled-0/tests/TestSlots.class.asasm b/libsrc/ffdec_lib/testdata/as3_assembled/abc/as3_assembled-0/tests/TestSlots.class.asasm new file mode 100644 index 000000000..1c710a7d2 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/as3_assembled/abc/as3_assembled-0/tests/TestSlots.class.asasm @@ -0,0 +1,163 @@ +class + refid "tests:TestSlots" + instance QName(PackageNamespace("tests"), "TestSlots") + extends QName(PackageNamespace(""), "Object") + flag SEALED + iinit + refid "tests:TestSlots/instance/init" + body + maxstack 1 + localcount 1 + initscopedepth 0 + maxscopedepth 1 + code + getlocal0 + pushscope + + getlocal0 + constructsuper 0 + + returnvoid + end ; code + end ; body + end ; method + trait slot QName(PackageNamespace(""), "instanceVar1") flag METADATA type QName(PackageNamespace(""), "String") value Utf8("ins1") + slotid 1 + metadata "__go_to_definition_help" + item "pos" "106" + end ; metadata + end ; trait + trait slot QName(PackageNamespace(""), "instanceVar2") flag METADATA type QName(PackageNamespace(""), "String") value Utf8("ins2") + slotid 2 + metadata "__go_to_definition_help" + item "pos" "150" + end ; metadata + end ; trait + trait method QName(PackageNamespace(""), "instanceMethod") flag METADATA + method + name "instanceMethod" + refid "tests:TestSlots/instance/instanceMethod" + returns QName(PackageNamespace(""), "void") + body + maxstack 3 + localcount 1 + initscopedepth 0 + maxscopedepth 1 + code + getlocal0 + pushscope + + debugfile "C:\\Dropbox\\Programovani\\JavaSE\\FFDec\\libsrc\\ffdec_lib\\testdata\\testslots\\src;tests;TestSlots.as" + findpropstrict QName(PackageNamespace(""), "trace") + debugline 18 + getscopeobject 0 + getslot 1 ;instanceVar1 + callpropvoid QName(PackageNamespace(""), "trace"), 1 + findpropstrict QName(PackageNamespace(""), "trace") + debugline 19 + getscopeobject 0 + getslot 2 ;instanceVar2 + callpropvoid QName(PackageNamespace(""), "trace"), 1 + + ;these are nested, I think this won't happen in real files + ;findpropstrict QName(PackageNamespace(""), "trace") + ;debugline 20 + ;getglobalscope + ;getslot 3 ;TestSlots + ;getslot 1 ;classVar1 + ;callpropvoid QName(PackageNamespace(""), "trace"), 1 + + ;findpropstrict QName(PackageNamespace(""), "trace") + ;debugline 21 + ;getglobalscope + ;getslot 3 ;TestSlots + ;getslot 2 ;classVar2 + ;callpropvoid QName(PackageNamespace(""), "trace"), 1 + + findpropstrict QName(PackageNamespace(""), "trace") + debugline 22 + getglobalscope + getslot 1 ;globalVar1 + callpropvoid QName(PackageNamespace(""), "trace"), 1 + findpropstrict QName(PackageNamespace(""), "trace") + debugline 23 + getglobalscope + getslot 2 ;globalVar2 + callpropvoid QName(PackageNamespace(""), "trace"), 1 + returnvoid + end ; code + end ; body + end ; method + metadata "__go_to_definition_help" + item "pos" "309" + end ; metadata + end ; trait + end ; instance + cinit + refid "tests:TestSlots/class/init" + body + maxstack 0 + localcount 1 + initscopedepth 0 + maxscopedepth 0 + code + returnvoid + end ; code + end ; body + end ; method + trait slot QName(PackageNamespace(""), "classVar1") flag METADATA type QName(PackageNamespace(""), "String") value Utf8("cls1") + slotid 1 + metadata "__go_to_definition_help" + item "pos" "205" + end ; metadata + end ; trait + trait slot QName(PackageNamespace(""), "classVar2") flag METADATA type QName(PackageNamespace(""), "String") value Utf8("cls2") + slotid 2 + metadata "__go_to_definition_help" + item "pos" "254" + end ; metadata + end ; trait + trait method QName(PackageNamespace(""), "classMethod") flag METADATA + method + name "classMethod" + refid "tests:TestSlots/class/classMethod" + returns QName(PackageNamespace(""), "void") + body + maxstack 3 + localcount 1 + initscopedepth 0 + maxscopedepth 1 + code + getlocal0 + pushscope + + debugfile "C:\\Dropbox\\Programovani\\JavaSE\\FFDec\\libsrc\\ffdec_lib\\testdata\\testslots\\src;tests;TestSlots.as" + findpropstrict QName(PackageNamespace(""), "trace") + debugline 28 + getscopeobject 0 + getslot 1 ;classVar1 + callpropvoid QName(PackageNamespace(""), "trace"), 1 + findpropstrict QName(PackageNamespace(""), "trace") + debugline 29 + getscopeobject 0 + getslot 2 ;classVar2 + callpropvoid QName(PackageNamespace(""), "trace"), 1 + findpropstrict QName(PackageNamespace(""), "trace") + debugline 30 + getglobalscope + getslot 1 ;globalVar1 + callpropvoid QName(PackageNamespace(""), "trace"), 1 + findpropstrict QName(PackageNamespace(""), "trace") + debugline 31 + getglobalscope + getslot 2 ;globalVar2 + callpropvoid QName(PackageNamespace(""), "trace"), 1 + returnvoid + end ; code + end ; body + end ; method + metadata "__go_to_definition_help" + item "pos" "512" + end ; metadata + end ; trait +end ; class diff --git a/libsrc/ffdec_lib/testdata/as3_assembled/abc/as3_assembled-0/tests/TestSlots.init/inline_method.method.asasm b/libsrc/ffdec_lib/testdata/as3_assembled/abc/as3_assembled-0/tests/TestSlots.init/inline_method.method.asasm new file mode 100644 index 000000000..573430f7a --- /dev/null +++ b/libsrc/ffdec_lib/testdata/as3_assembled/abc/as3_assembled-0/tests/TestSlots.init/inline_method.method.asasm @@ -0,0 +1,29 @@ +method + name "globalFunction" + refid "tests:TestSlots/init/inline_method" + returns QName(PackageNamespace(""), "void") + body + maxstack 3 + localcount 1 + initscopedepth 0 + maxscopedepth 1 + code + getlocal0 + pushscope + + debugfile "C:\\Dropbox\\Programovani\\JavaSE\\FFDec\\libsrc\\ffdec_lib\\testdata\\testslots\\src;tests;TestSlots.as" + getlex QName(PackageNamespace(""), "trace") + debugline 43 + getglobalscope + getlex QName(PrivateNamespace("FilePrivateNS:TestSlots"), "globalVar1") + call 1 + pop + getlex QName(PackageNamespace(""), "trace") + debugline 44 + getglobalscope + getlex QName(PrivateNamespace("FilePrivateNS:TestSlots"), "globalVar2") + call 1 + returnvoid + end ; code + end ; body +end ; method diff --git a/libsrc/ffdec_lib/testdata/as3_assembled/abc/as3_assembled-0/tests/TestSlots.script.asasm b/libsrc/ffdec_lib/testdata/as3_assembled/abc/as3_assembled-0/tests/TestSlots.script.asasm new file mode 100644 index 000000000..2bef64709 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/as3_assembled/abc/as3_assembled-0/tests/TestSlots.script.asasm @@ -0,0 +1,57 @@ +script + sinit + refid "tests:TestSlots/init" + body + maxstack 3 + localcount 1 + initscopedepth 0 + maxscopedepth 2 + code + getlocal0 + pushscope + + getscopeobject 0 + getlex QName(PackageNamespace(""), "Object") + dup + pushscope + + newclass "tests:TestSlots" + popscope + initproperty QName(PackageNamespace("tests"), "TestSlots") + + getglobalscope + newfunction "tests:TestSlots/init/inline_method" + setproperty QName(PrivateNamespace("FilePrivateNS:TestSlots"), "globalFunction") + + debugfile "C:\\Dropbox\\Programovani\\JavaSE\\FFDec\\libsrc\\ffdec_lib\\testdata\\testslots\\src;tests;TestSlots.as" + debugline 38 + pushstring "glb1" + findproperty QName(PrivateNamespace("FilePrivateNS:TestSlots"), "globalVar1") + swap + setproperty QName(PrivateNamespace("FilePrivateNS:TestSlots"), "globalVar1") + + debugline 39 + pushstring "glb2" + findproperty QName(PrivateNamespace("FilePrivateNS:TestSlots"), "globalVar2") + swap + setproperty QName(PrivateNamespace("FilePrivateNS:TestSlots"), "globalVar2") + + returnvoid + end ; code + end ; body + end ; method + trait class QName(PackageNamespace("tests"), "TestSlots") flag METADATA + slotid 3 + #include "TestSlots.class.asasm" + metadata "__go_to_definition_help" + item "pos" "73" + end ; metadata + end ; trait + trait slot QName(PrivateNamespace("FilePrivateNS:TestSlots"), "globalVar1") type QName(PackageNamespace(""), "String") + slotid 1 + end + trait slot QName(PrivateNamespace("FilePrivateNS:TestSlots"), "globalVar2") type QName(PackageNamespace(""), "String") + slotid 2 + end + trait slot QName(PrivateNamespace("FilePrivateNS:TestSlots"), "globalFunction") end +end ; script diff --git a/libsrc/ffdec_lib/testdata/as3_assembled/bin/as3_assembled.swf b/libsrc/ffdec_lib/testdata/as3_assembled/bin/as3_assembled.swf index 37e48f0b2..7ba011d84 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_assembled/bin/as3_assembled.swf and b/libsrc/ffdec_lib/testdata/as3_assembled/bin/as3_assembled.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.air.swf b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.air.swf index 4cd8e972c..bcc074905 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.air.swf and b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.air.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex.swf b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex.swf index 68b0b74c8..e1f77262b 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex.swf and b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex_apache.swf b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex_apache.swf index e52eecae3..55b2038ee 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex_apache.swf and b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.flex_apache.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.swftools.swf b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.swftools.swf index ec2d88478..e8e46f686 100644 Binary files a/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.swftools.swf and b/libsrc/ffdec_lib/testdata/as3_cross_compile/bin/as3_cross_compile.swftools.swf differ diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/obj/as3_cross_compileConfig.old b/libsrc/ffdec_lib/testdata/as3_cross_compile/obj/as3_cross_compileConfig.old index 6d522439f..8bd4a91f5 100644 --- a/libsrc/ffdec_lib/testdata/as3_cross_compile/obj/as3_cross_compileConfig.old +++ b/libsrc/ffdec_lib/testdata/as3_cross_compile/obj/as3_cross_compileConfig.old @@ -3,6 +3,8 @@ 25.0 + false + true CONFIG::debug diff --git a/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchLoopBreak5.as b/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchLoopBreak5.as index 14e6cdd33..9e8a0b268 100644 --- a/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchLoopBreak5.as +++ b/libsrc/ffdec_lib/testdata/as3_cross_compile/src/tests/TestTryCatchLoopBreak5.as @@ -23,14 +23,16 @@ package tests { trace("in catch1"); while (true){ + trace("xx"); if (a > 5){ break; } + trace("yy"); } trace("in catch1c"); } } - trace("after"); + //trace("after"); } 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 baddf3880..7a1fd3e0c 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