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 1a3943c0c..3623fbf11 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 @@ -1977,7 +1977,7 @@ public class AVM2Code implements Cloneable { Slot sl = new Slot(new NewActivationAVM2Item(null, null), abc.constants.getMultiname(traits.get(traitName).name_index)); TraitSlotConst tsc = (TraitSlotConst) traits.get(traitName); GraphTargetItem type = PropertyAVM2Item.multinameToType(tsc.type_index, abc.constants); - DeclarationAVM2Item d = new DeclarationAVM2Item(new GetLexAVM2Item(null, null, sl.multiname, abc.constants, type, false), type); + DeclarationAVM2Item d = new DeclarationAVM2Item(new GetLexAVM2Item(null, null, sl.multiname, abc.constants, type, TypeItem.UNBOUNDED /*?*/, false), type); declaredSlotsDec.add(d); declaredSlots.add(sl); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallIns.java index 736e3b83f..192512671 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallIns.java @@ -23,6 +23,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.instructions.other.GetPropertyIns; import com.jpexs.decompiler.flash.abc.avm2.model.CallAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java index 6c70455fb..ff53fece1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java @@ -81,12 +81,14 @@ public class CallPropLexIns extends CallPropertyIns { } FullMultinameAVM2Item multiname = resolveMultiname(localData, true, stack, localData.getConstants(), multinameIndex, ins); - GraphTargetItem receiver = stack.pop(); + GraphTargetItem obj = stack.pop(); Reference isStatic = new Reference<>(false); - GraphTargetItem type = GetPropertyIns.resolvePropertyType(localData, receiver, multiname, isStatic, true); + Reference type = new Reference<>(null); + Reference callType = new Reference<>(null); + GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, type, callType); - stack.push(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, false, receiver, multiname, args, type, isStatic.getVal())); + stack.push(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, false, obj, multiname, args, callType.getVal(), isStatic.getVal())); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java index b5e624124..6bc06b3e2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java @@ -82,10 +82,12 @@ public class CallPropVoidIns extends InstructionDefinition { } FullMultinameAVM2Item multiname = resolveMultiname(localData, true, stack, localData.getConstants(), multinameIndex, ins); - GraphTargetItem receiver = stack.pop(); + GraphTargetItem obj = stack.pop(); Reference isStatic = new Reference<>(false); - GraphTargetItem type = GetPropertyIns.resolvePropertyType(localData, receiver, multiname, isStatic, true); - output.add(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, true, receiver, multiname, args, type, isStatic.getVal())); + Reference type = new Reference<>(null); + Reference callType = new Reference<>(null); + GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, type, callType); + output.add(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, true, obj, multiname, args, callType.getVal(), isStatic.getVal())); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java index 4319dcfa0..4c12a7142 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java @@ -82,11 +82,13 @@ public class CallPropertyIns extends InstructionDefinition { } FullMultinameAVM2Item multiname = resolveMultiname(localData, true, stack, localData.getConstants(), multinameIndex, ins); - GraphTargetItem receiver = stack.pop(); + GraphTargetItem obj = stack.pop(); Reference isStatic = new Reference<>(false); - GraphTargetItem type = GetPropertyIns.resolvePropertyType(localData, receiver, multiname, isStatic, true); + Reference type = new Reference<>(null); + Reference callType = new Reference<>(null); + GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, type, callType); - stack.push(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, false, receiver, multiname, args, type, isStatic.getVal())); + stack.push(new CallPropertyAVM2Item(ins, localData.lineStartInstruction, false, obj, multiname, args, callType.getVal(), isStatic.getVal())); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java index f79ea55c6..5a012d02d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java @@ -57,7 +57,9 @@ public class DeletePropertyIns extends InstructionDefinition { FullMultinameAVM2Item multiname = resolveMultiname(localData, true, stack, localData.getConstants(), multinameIndex, ins); GraphTargetItem obj = stack.pop(); Reference isStatic = new Reference<>(false); - GraphTargetItem type = GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, true); + Reference type = new Reference<>(null); + Reference callType = new Reference<>(null); + GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, type, callType); stack.add(new DeletePropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname, isStatic.getVal())); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java index 74ea5c78b..c3405f71e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java @@ -24,10 +24,13 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing; import com.jpexs.decompiler.flash.abc.avm2.parser.script.PropertyAVM2Item; import com.jpexs.decompiler.flash.abc.types.Multiname; +import com.jpexs.decompiler.flash.abc.types.Namespace; import com.jpexs.decompiler.flash.abc.types.traits.Trait; 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.decompiler.graph.TypeItem; @@ -46,12 +49,13 @@ public class GetLexIns extends InstructionDefinition { super(0x60, "getlex", new int[]{AVM2Code.DAT_MULTINAME_INDEX}, true); } - public static GraphTargetItem resolveLexType( + public static void resolveLexType( AVM2LocalData localData, GraphTargetItem obj, int multinameIndex, - Reference isStatic, boolean call) { - GraphTargetItem type = null; + Reference isStatic, Reference type, Reference callType) { + type.setVal(TypeItem.UNBOUNDED); + callType.setVal(TypeItem.UNBOUNDED); String multinameStr = localData.abc.constants.getMultiname(multinameIndex).getName(localData.abc.constants, new ArrayList<>(), true, true); for (Trait t : localData.methodBody.traits.traits) { if (t instanceof TraitSlotConst) { @@ -60,41 +64,41 @@ public class GetLexIns extends InstructionDefinition { tsc.getName(localData.abc).getName(localData.abc.constants, new ArrayList<>(), true, true), multinameStr )) { - type = PropertyAVM2Item.multinameToType(tsc.type_index, localData.abc.constants); - break; + GraphTargetItem ty = PropertyAVM2Item.multinameToType(tsc.type_index, localData.abc.constants); + type.setVal(ty); + callType.setVal(ty); + return; } } } - if (type == null) { - if (localData.abcIndex != null) { - String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc.constants, true).toRawString(); - GraphTargetItem thisPropType = TypeItem.UNBOUNDED; - if (currentClassName != null) { - if (call) { - thisPropType = localData.abcIndex.findPropertyCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multinameIndex).namespace_index, true, true, true); - } else { - thisPropType = localData.abcIndex.findPropertyType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multinameIndex).namespace_index, true, true, true); - } - } - if (!thisPropType.equals(TypeItem.UNBOUNDED)) { - type = thisPropType; - } + if (localData.abcIndex != null) { + String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc.constants, true).toRawString(); + if (currentClassName != null) { + localData.abcIndex.findPropertyTypeOrCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multinameIndex).namespace_index, true, true, true, type, callType); + } - if (type == null) { - TypeItem ti = new TypeItem(localData.abc.constants.getMultiname(multinameIndex).getNameWithNamespace(localData.abc.constants, true)); - if (localData.abcIndex.findClass(ti) != null) { - type = ti; + if (type.getVal().equals(TypeItem.UNBOUNDED)) { + TypeItem ti = new TypeItem(localData.abc.constants.getMultiname(multinameIndex).getNameWithNamespace(localData.abc.constants, true)); + if (localData.abcIndex.findClass(ti) != null) { + type.setVal(ti); + callType.setVal(TypeItem.UNBOUNDED); + isStatic.setVal(true); + return; + } + Namespace ns = localData.abc.constants.getMultiname(multinameIndex).getNamespace(localData.abc.constants); + if (ns != null) { + String rawNs = ns.getRawName(localData.abc.constants); + AbcIndexing.TraitIndex traitIndex = localData.abcIndex.findScriptProperty(multinameStr, DottedChain.parseWithSuffix(rawNs)); + if (traitIndex != null) { + type.setVal(traitIndex.returnType); + callType.setVal(traitIndex.callReturnType); isStatic.setVal(true); + return; } } } } - - if (type == null) { - type = TypeItem.UNBOUNDED; - } - return type; } @Override @@ -102,8 +106,10 @@ public class GetLexIns extends InstructionDefinition { int multinameIndex = ins.operands[0]; Multiname multiname = localData.getConstants().getMultiname(multinameIndex); Reference isStatic = new Reference<>(false); - GraphTargetItem type = GetLexIns.resolveLexType(localData, null, multinameIndex, isStatic, false); - stack.push(new GetLexAVM2Item(ins, localData.lineStartInstruction, multiname, localData.getConstants(), type, isStatic.getVal())); + Reference type = new Reference<>(null); + Reference callType = new Reference<>(null); + GetLexIns.resolveLexType(localData, null, multinameIndex, isStatic, type, callType); + stack.push(new GetLexAVM2Item(ins, localData.lineStartInstruction, multiname, localData.getConstants(), type.getVal(), callType.getVal(), isStatic.getVal())); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java index b0cbe5d3f..446f52abc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java @@ -31,14 +31,17 @@ import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.SetLocalAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.AbcIndexing; import com.jpexs.decompiler.flash.abc.avm2.parser.script.PropertyAVM2Item; import com.jpexs.decompiler.flash.abc.types.Multiname; +import com.jpexs.decompiler.flash.abc.types.Namespace; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.ecma.ArrayType; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.ecma.ObjectType; import com.jpexs.decompiler.flash.ecma.Undefined; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import com.jpexs.decompiler.graph.TypeItem; @@ -131,17 +134,20 @@ public class GetPropertyIns extends InstructionDefinition { } } Reference isStatic = new Reference<>(false); - GraphTargetItem type = resolvePropertyType(localData, obj, multiname, isStatic, false); + Reference type = new Reference<>(null); + Reference callType = new Reference<>(null); + resolvePropertyType(localData, obj, multiname, isStatic, type, callType); - stack.push(new GetPropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname, type, isStatic.getVal())); + stack.push(new GetPropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname, type.getVal(), callType.getVal(), isStatic.getVal())); } - public static GraphTargetItem resolvePropertyType( + public static void resolvePropertyType( AVM2LocalData localData, GraphTargetItem obj, FullMultinameAVM2Item multiname, - Reference isStatic, boolean call) { - GraphTargetItem type = null; + Reference isStatic, Reference type, Reference callType) { + type.setVal(TypeItem.UNBOUNDED); + callType.setVal(TypeItem.UNBOUNDED); String multinameStr = localData.abc.constants.getMultiname(multiname.multinameIndex).getName(localData.abc.constants, new ArrayList<>(), true, true); if (obj instanceof FindPropertyAVM2Item) { FindPropertyAVM2Item fprop = (FindPropertyAVM2Item) obj; @@ -153,32 +159,40 @@ public class GetPropertyIns extends InstructionDefinition { tsc.getName(localData.abc).getName(localData.abc.constants, new ArrayList<>(), true, true), multinameStr )) { - type = PropertyAVM2Item.multinameToType(tsc.type_index, localData.abc.constants); - break; + GraphTargetItem ty = PropertyAVM2Item.multinameToType(tsc.type_index, localData.abc.constants); + type.setVal(ty); + callType.setVal(ty); + return; } } } - if (type == null) { + if (type.getVal().equals(TypeItem.UNBOUNDED)) { if (localData.abcIndex != null) { String currentClassName = localData.classIndex == -1 ? null : localData.abc.instance_info.get(localData.classIndex).getName(localData.abc.constants).getNameWithNamespace(localData.abc.constants, true).toRawString(); GraphTargetItem thisPropType = TypeItem.UNBOUNDED; if (currentClassName != null) { - if (call) { - thisPropType = localData.abcIndex.findPropertyCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, true, true, true); - } else { - thisPropType = localData.abcIndex.findPropertyType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, true, true, true); - } + localData.abcIndex.findPropertyTypeOrCallType(localData.abc, new TypeItem(currentClassName), multinameStr, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, true, true, true, type, callType); } - if (!thisPropType.equals(TypeItem.UNBOUNDED)) { - type = thisPropType; - } - - if (type == null) { + if (type.getVal().equals(TypeItem.UNBOUNDED)) { TypeItem ti = new TypeItem(localData.abc.constants.getMultiname(multiname.multinameIndex).getNameWithNamespace(localData.abc.constants, true)); if (localData.abcIndex.findClass(ti) != null) { - type = ti; + type.setVal(ti); + callType.setVal(TypeItem.UNBOUNDED); isStatic.setVal(true); + return; + } + + Namespace ns = localData.abc.constants.getMultiname(multiname.multinameIndex).getNamespace(localData.abc.constants); + if (ns != null) { + String rawNs = ns.getRawName(localData.abc.constants); + AbcIndexing.TraitIndex traitIndex = localData.abcIndex.findScriptProperty(multinameStr, DottedChain.parseWithSuffix(rawNs)); + if (traitIndex != null) { + type.setVal(traitIndex.returnType); + callType.setVal(traitIndex.callReturnType); + isStatic.setVal(true); //? + return; + } } } } @@ -198,22 +212,21 @@ public class GetPropertyIns extends InstructionDefinition { if (obj instanceof GetPropertyAVM2Item) { if (((GetPropertyAVM2Item) obj).isStatic) { parentStatic = true; - } + } } if (receiverType instanceof ApplyTypeAVM2Item) { - ApplyTypeAVM2Item ati = (ApplyTypeAVM2Item) receiverType; + ApplyTypeAVM2Item ati = (ApplyTypeAVM2Item) receiverType; if (localData.abc.constants.getMultiname(multiname.multinameIndex).needsName()) { - if (call) { - type = TypeItem.UNBOUNDED; /*?*/ - } else { - type = ati.params.get(0); - } + callType.setVal(TypeItem.UNBOUNDED); + /*?*/ + type.setVal(ati.params.get(0)); + return; } else { receiverType = ati.object; - + if (receiverType.equals(new TypeItem("__AS3__.vec.Vector"))) { String paramStr = ati.params.get(0).toString(); - switch(paramStr) { + switch (paramStr) { case "double": case "int": case "uint": @@ -223,26 +236,14 @@ public class GetPropertyIns extends InstructionDefinition { receiverType = new TypeItem("__AS3__.vec.Vector$object"); } } - + //TODO: handle method calls to return proper param type results } - } - if (type == null) - { - if (call) { - type = localData.abcIndex.findPropertyCallType(localData.abc, receiverType, multiname.resolvedMultinameName, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, parentStatic, !parentStatic, false); - } else { - type = localData.abcIndex.findPropertyType(localData.abc, receiverType, multiname.resolvedMultinameName, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, parentStatic, !parentStatic, false); - } } + localData.abcIndex.findPropertyTypeOrCallType(localData.abc, receiverType, multiname.resolvedMultinameName, localData.abc.constants.getMultiname(multiname.multinameIndex).namespace_index, parentStatic, !parentStatic, false, type, callType); } } } - - if (type == null) { - type = TypeItem.UNBOUNDED; - } - return type; } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java index bdc440a08..c8a91c8b0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java @@ -69,9 +69,11 @@ public class InitPropertyIns extends InstructionDefinition { }*/ Reference isStatic = new Reference<>(false); - GraphTargetItem type = GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, false); + Reference type = new Reference<>(null); + Reference callType = new Reference<>(null); + GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, type, callType); - InitPropertyAVM2Item result = new InitPropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname, val, type, isStatic.getVal()); + InitPropertyAVM2Item result = new InitPropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname, val, type.getVal(), callType.getVal(), isStatic.getVal()); SetPropertyIns.handleCompound(localData, obj, multiname, val, output, result); output.add(result); } 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 2c0166f39..76686c104 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 @@ -361,9 +361,11 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns } */ Reference isStatic = new Reference<>(false); - GraphTargetItem type = GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, false); + Reference type = new Reference<>(null); + Reference callType = new Reference<>(null); + GetPropertyIns.resolvePropertyType(localData, obj, multiname, isStatic, type, callType); - SetPropertyAVM2Item result = new SetPropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname, value, type, isStatic.getVal()); + SetPropertyAVM2Item result = new SetPropertyAVM2Item(ins, localData.lineStartInstruction, obj, multiname, value, type.getVal(), callType.getVal(), isStatic.getVal()); handleCompound(localData, obj, multiname, value, output, result); SetTypeIns.handleResult(value, stack, output, localData, result, -1); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallAVM2Item.java index 726a0fd67..a56fc716f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/CallAVM2Item.java @@ -226,6 +226,12 @@ public class CallAVM2Item extends AVM2Item { @Override public GraphTargetItem returnType() { + if (function instanceof GetPropertyAVM2Item) { + return ((GetPropertyAVM2Item)function).callType; + } + if (function instanceof GetLexAVM2Item) { + return ((GetLexAVM2Item)function).callType; + } return TypeItem.UNBOUNDED; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java index 013fd4769..fb141868f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java @@ -37,14 +37,17 @@ public class GetLexAVM2Item extends AVM2Item implements SimpleValue { public GraphTargetItem type; - public boolean isStatic; + public GraphTargetItem callType; + + public boolean isStatic; private final DottedChain fullPropertyName; - public GetLexAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Multiname propertyName, AVM2ConstantPool constants, GraphTargetItem type, boolean isStatic) { + public GetLexAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Multiname propertyName, AVM2ConstantPool constants, GraphTargetItem type, GraphTargetItem callType, boolean isStatic) { super(instruction, lineStartIns, PRECEDENCE_PRIMARY); this.propertyName = propertyName; this.type = type; + this.callType = callType; this.fullPropertyName = propertyName.getNameWithNamespace(constants, true); this.isStatic = isStatic; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetPropertyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetPropertyAVM2Item.java index e8b3d2435..97f1156af 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetPropertyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetPropertyAVM2Item.java @@ -49,6 +49,8 @@ public class GetPropertyAVM2Item extends AVM2Item { public GraphTargetItem type; + public GraphTargetItem callType; + public boolean isStatic; @Override @@ -131,11 +133,12 @@ public class GetPropertyAVM2Item extends AVM2Item { return null; } - public GetPropertyAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem object, GraphTargetItem propertyName, GraphTargetItem type, boolean isStatic) { + public GetPropertyAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem object, GraphTargetItem propertyName, GraphTargetItem type, GraphTargetItem callType, boolean isStatic) { super(instruction, lineStartIns, PRECEDENCE_PRIMARY); this.object = object; this.propertyName = propertyName; this.type = type; + this.callType = callType; this.isStatic = isStatic; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/InitPropertyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/InitPropertyAVM2Item.java index 1af7f9554..6ae0c72b7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/InitPropertyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/InitPropertyAVM2Item.java @@ -44,6 +44,8 @@ public class InitPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, A public GraphTargetItem type; + public GraphTargetItem callType; + public boolean isStatic; @Override @@ -63,11 +65,12 @@ public class InitPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, A this.declaration = declaration; } - public InitPropertyAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem object, FullMultinameAVM2Item propertyName, GraphTargetItem value, GraphTargetItem type, boolean isStatic) { + public InitPropertyAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem object, FullMultinameAVM2Item propertyName, GraphTargetItem value, GraphTargetItem type, GraphTargetItem callType, boolean isStatic) { super(instruction, lineStartIns, PRECEDENCE_ASSIGMENT, value); this.object = object; this.propertyName = propertyName; this.type = type; + this.callType = callType; this.isStatic = isStatic; } @@ -87,7 +90,7 @@ public class InitPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, A @Override public GraphTargetItem getObject() { - return new GetPropertyAVM2Item(getInstruction(), getLineStartIns(), object, propertyName, type, isStatic); + return new GetPropertyAVM2Item(getInstruction(), getLineStartIns(), object, propertyName, type, callType, isStatic); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetPropertyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetPropertyAVM2Item.java index 43fd1e875..cbd272d4e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetPropertyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetPropertyAVM2Item.java @@ -51,6 +51,8 @@ public class SetPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, As public GraphTargetItem type; + public GraphTargetItem callType; + public boolean isStatic; @Override @@ -77,12 +79,13 @@ public class SetPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, As } } - public SetPropertyAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem object, GraphTargetItem propertyName, GraphTargetItem value, GraphTargetItem type, boolean isStatic) { + public SetPropertyAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, GraphTargetItem object, GraphTargetItem propertyName, GraphTargetItem value, GraphTargetItem type, GraphTargetItem callType, boolean isStatic) { super(instruction, lineStartIns, PRECEDENCE_ASSIGMENT); this.object = object; this.propertyName = propertyName; this.value = value; this.type = type; + this.callType = callType; this.isStatic = isStatic; } @@ -106,7 +109,7 @@ public class SetPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, As @Override public GraphTargetItem getObject() { - return new GetPropertyAVM2Item(getInstruction(), getLineStartIns(), object, propertyName, type, isStatic); + return new GetPropertyAVM2Item(getInstruction(), getLineStartIns(), object, propertyName, type, callType, isStatic); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AbcIndexing.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AbcIndexing.java index 7e1135aa8..6e9f172eb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AbcIndexing.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AbcIndexing.java @@ -34,6 +34,7 @@ import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TypeItem; +import com.jpexs.helpers.Reference; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -354,6 +355,18 @@ public final class AbcIndexing { return classes.get(cls); } + public void findPropertyTypeOrCallType(ABC abc, GraphTargetItem cls, String propName, int ns, boolean findStatic, boolean findInstance, boolean findProtected, Reference type, Reference callType) { + TraitIndex traitIndex = findProperty(new PropertyDef(propName, cls, abc, ns), findStatic, findInstance, findProtected); + if (traitIndex == null) { + type.setVal(TypeItem.UNBOUNDED); + callType.setVal(TypeItem.UNBOUNDED); + } else { + type.setVal(traitIndex.returnType); + callType.setVal(traitIndex.callReturnType); + } + } + + public GraphTargetItem findPropertyType(ABC abc, GraphTargetItem cls, String propName, int ns, boolean findStatic, boolean findInstance, boolean findProtected) { TraitIndex traitIndex = findProperty(new PropertyDef(propName, cls, abc, ns), findStatic, findInstance, findProtected); if (traitIndex == null) { 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 72dc0c94b..7c2b51ade 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 @@ -251,7 +251,8 @@ public class ActionScript3ClassicAirDecompileTest extends ActionScript3Decompile + "s = v.join(\"x\");\r\n" + "i = int(v.join(\"x\"));\r\n" + "i = int(prot);\r\n" - + "s = prot;\r\n", + + "s = prot;\r\n" + + "s = String(getTimer());\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 7393a461b..6dc84b8a5 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 @@ -250,7 +250,8 @@ public class ActionScript3ClassicDecompileTest extends ActionScript3DecompileTes + "s = v.join(\"x\");\r\n" + "i = int(v.join(\"x\"));\r\n" + "i = int(prot);\r\n" - + "s = prot;\r\n", + + "s = prot;\r\n" + + "s = String(getTimer());\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 88d8ed447..c7f8e86dc 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 837392d73..598b1864a 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/TestConvert.as b/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestConvert.as index e3c983303..9709b079c 100644 --- a/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestConvert.as +++ b/libsrc/ffdec_lib/testdata/as3_new/src/tests/TestConvert.as @@ -1,6 +1,7 @@ package tests { import tests_classes.TestConvertParent; + import flash.utils.getTimer; public class TestConvert extends TestConvertParent { @@ -50,6 +51,8 @@ package tests i = int(prot); s = prot; + + s = String(getTimer()); } } }