diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java index 596d9d9fa..bc1b84fbe 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java @@ -2612,31 +2612,34 @@ public class AVM2SourceGenerator implements SourceGenerator { return TypeItem.UNBOUNDED; } - public static boolean searchPrototypeChain(List otherNs, int privateNs, int protectedNs, boolean instanceOnly, AbcIndexing abc, DottedChain pkg, String obj, String propertyName, Reference outName, Reference outNs, Reference outPropNs, Reference outPropNsKind, Reference outPropNsIndex, Reference outPropType, Reference outPropValue, Reference outPropValueAbc) { + public static boolean searchPrototypeChain(List otherNs, int privateNs, int protectedNs, boolean instanceOnly, AbcIndexing abc, DottedChain pkg, String obj, String propertyName, Reference outName, Reference outNs, Reference outPropNs, Reference outPropNsKind, Reference outPropNsIndex, Reference outPropType, Reference outPropValue, Reference outPropValueAbc, Reference isType) { // private and protected namespaces first so we find overriding functions before overridden functions - if (searchPrototypeChain(privateNs, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc)) { + if (searchPrototypeChain(privateNs, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType)) { return true; } - if (searchPrototypeChain(protectedNs, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc)) { + if (searchPrototypeChain(protectedNs, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType)) { return true; } for (int ns : otherNs) { - if (searchPrototypeChain(ns, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc)) { + if (searchPrototypeChain(ns, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType)) { return true; } } - return searchPrototypeChain(0, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc); + return searchPrototypeChain(0, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType); } - private static boolean searchPrototypeChain(int selectedNs, boolean instanceOnly, AbcIndexing abc, DottedChain pkg, String obj, String propertyName, Reference outName, Reference outNs, Reference outPropNs, Reference outPropNsKind, Reference outPropNsIndex, Reference outPropType, Reference outPropValue, Reference outPropValueAbc) { - + private static boolean searchPrototypeChain(int selectedNs, boolean instanceOnly, AbcIndexing abc, DottedChain pkg, String obj, String propertyName, Reference outName, Reference outNs, Reference outPropNs, Reference outPropNsKind, Reference outPropNsIndex, Reference outPropType, Reference outPropValue, Reference outPropValueAbc, Reference isType) { + isType.setVal(false); AbcIndexing.TraitIndex sp = abc.findScriptProperty(pkg.addWithSuffix(propertyName)); if (sp == null) { sp = abc.findProperty(new AbcIndexing.PropertyDef(propertyName, new TypeItem(pkg.addWithSuffix(obj)), abc.getSelectedAbc(), selectedNs), !instanceOnly, true); } if (sp != null) { + if (sp.trait instanceof TraitClass) { + isType.setVal(true); + } if (sp.objType instanceof TypeItem) { outName.setVal(((TypeItem) sp.objType).fullTypeName.getLast()); outNs.setVal(((TypeItem) sp.objType).fullTypeName.getWithoutLast()); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java index 16a0fcce8..1e29309cb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/CallAVM2Item.java @@ -91,12 +91,13 @@ public class CallAVM2Item extends AVM2Item { Reference outPropValue = new Reference<>(null); Reference outPropValueABC = new Reference<>(null); List otherNs = new ArrayList<>(); + Reference isType = new Reference<>(false); for (NamespaceItem on : openedNamespaces) { if (on.isResolved()) { otherNs.add(on.getCpoolIndex(g.abcIndex)); } } - if (cname != null && AVM2SourceGenerator.searchPrototypeChain(otherNs, localData.privateNs, localData.protectedNs, true, g.abcIndex, pkgName, cname, n.getVariableName(), outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueABC)) { + if (cname != null && AVM2SourceGenerator.searchPrototypeChain(otherNs, localData.privateNs, localData.protectedNs, true, g.abcIndex, pkgName, cname, n.getVariableName(), outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueABC, isType)) { NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.getFullClass()), n.line, "this", null, false, n.openedNamespaces, abcIndex); nobj.setRegNumber(0); obj = nobj; @@ -132,6 +133,7 @@ public class CallAVM2Item extends AVM2Item { Reference outPropType = new Reference<>(null); Reference outPropValue = new Reference<>(null); Reference outPropValueAbc = new Reference<>(null); + Reference isType = new Reference<>(false); List otherNs = new ArrayList<>(); for (NamespaceItem n : openedNamespaces) { @@ -140,7 +142,7 @@ public class CallAVM2Item extends AVM2Item { } } - if (cname != null && AVM2SourceGenerator.searchPrototypeChain(otherNs, localData.privateNs, localData.protectedNs, true, g.abcIndex, pkgName, cname, prop.propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc) && (localData.getFullClass().equals(outNs.getVal().addWithSuffix(outName.getVal()).toRawString()))) { + if (cname != null && AVM2SourceGenerator.searchPrototypeChain(otherNs, localData.privateNs, localData.protectedNs, true, g.abcIndex, pkgName, cname, prop.propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType) && (localData.getFullClass().equals(outNs.getVal().addWithSuffix(outName.getVal()).toRawString()))) { NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.getFullClass()), 0, "this", null, false, new ArrayList<>(), abcIndex); nobj.setRegNumber(0); obj = nobj; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespaceItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespaceItem.java index f546b9c09..4a2c93a97 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespaceItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespaceItem.java @@ -89,8 +89,9 @@ public class NamespaceItem { PropertyAVM2Item prop = new PropertyAVM2Item(null, custom, abcIndex, openedNamespaces, new ArrayList<>()); Reference value = new Reference<>(null); Reference outAbc = new Reference<>(null); + Reference isType = new Reference<>(false); - prop.resolve(true, localData, new Reference<>(null), new Reference<>(null), new Reference<>(0), value, outAbc); + prop.resolve(true, localData, isType, new Reference<>(null), new Reference<>(null), new Reference<>(0), value, outAbc); boolean resolved = true; if (value.getVal() == null) { resolved = false; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java index 2655afc99..02b231b57 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java @@ -31,6 +31,7 @@ import com.jpexs.decompiler.flash.abc.types.Namespace; import com.jpexs.decompiler.flash.abc.types.ScriptInfo; import com.jpexs.decompiler.flash.abc.types.ValueKind; import com.jpexs.decompiler.flash.abc.types.traits.Trait; +import com.jpexs.decompiler.flash.abc.types.traits.TraitClass; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; @@ -132,7 +133,8 @@ public class PropertyAVM2Item extends AssignableAVM2Item { return multinameToType(new HashSet<>(), m_index, constants); } - public void resolve(boolean mustExist, SourceGeneratorLocalData localData, Reference objectType, Reference propertyType, Reference propertyIndex, Reference propertyValue, Reference propertyValueABC) throws CompilationException { + public void resolve(boolean mustExist, SourceGeneratorLocalData localData, Reference isType, Reference objectType, Reference propertyType, Reference propertyIndex, Reference propertyValue, Reference propertyValueABC) throws CompilationException { + isType.setVal(false); GraphTargetItem thisType = new TypeItem(localData.getFullClass()); GraphTargetItem objType = null; GraphTargetItem objSubType = null; @@ -269,7 +271,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { propValueAbc = sp.abc; } } - if (propType == null && AVM2SourceGenerator.searchPrototypeChain(otherNs, localData.privateNs, localData.protectedNs, false, abcIndex, ftn.getWithoutLast(), ftn.getLast(), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc)) { + if (propType == null && AVM2SourceGenerator.searchPrototypeChain(otherNs, localData.privateNs, localData.protectedNs, false, abcIndex, ftn.getWithoutLast(), ftn.getLast(), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType)) { objType = new TypeItem(outNs.getVal().addWithSuffix(outName.getVal())); propType = outPropType.getVal(); propIndex = constants.getMultinameId(Multiname.createQName(false, @@ -356,6 +358,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { } for (Trait t : si.traits.traits) { if (t.name_index == name_index) { + isType.setVal(t instanceof TraitClass); objType = new TypeItem(DottedChain.OBJECT); propType = AVM2SourceGenerator.getTraitReturnType(abcIndex, t); propIndex = t.name_index; @@ -387,7 +390,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { otherns.add(n.getCpoolIndex(abcIndex)); } } - if (AVM2SourceGenerator.searchPrototypeChain(otherns, localData.privateNs, localData.protectedNs, false, abcIndex, nsname, (((TypeItem) p.objType).fullTypeName.getLast()), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc)) { + if (AVM2SourceGenerator.searchPrototypeChain(otherns, localData.privateNs, localData.protectedNs, false, abcIndex, nsname, (((TypeItem) p.objType).fullTypeName.getLast()), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType)) { objType = new TypeItem(outNs.getVal().addWithSuffix(outName.getVal())); propType = p.returnType; propIndex = constants.getMultinameId(Multiname.createQName(false, @@ -446,7 +449,8 @@ public class PropertyAVM2Item extends AssignableAVM2Item { Reference propIndex = new Reference<>(0); Reference outPropValue = new Reference<>(null); Reference outPropValueAbc = new Reference<>(null); - resolve(false, localData, objType, propType, propIndex, outPropValue, outPropValueAbc); + Reference isType = new Reference<>(false); + resolve(false, localData, isType, objType, propType, propIndex, outPropValue, outPropValueAbc); return propIndex.getVal(); } @@ -458,8 +462,9 @@ public class PropertyAVM2Item extends AssignableAVM2Item { Reference propIndex = new Reference<>(0); Reference outPropValue = new Reference<>(null); Reference outPropValueAbc = new Reference<>(null); + Reference isType = new Reference<>(false); try { - resolve(false, new SourceGeneratorLocalData(new HashMap<>(), 0, false, 0)/*???*/, objType, propType, propIndex, outPropValue, outPropValueAbc); + resolve(false, new SourceGeneratorLocalData(new HashMap<>(), 0, false, 0)/*???*/, isType, objType, propType, propIndex, outPropValue, outPropValueAbc); return propType.getVal(); } catch (CompilationException ex) { @@ -475,8 +480,9 @@ public class PropertyAVM2Item extends AssignableAVM2Item { Reference propIndex = new Reference<>(0); Reference outPropValue = new Reference<>(null); Reference outPropValueAbc = new Reference<>(null); + Reference isType = new Reference<>(false); - resolve(false, localData, objType, propType, propIndex, outPropValue, outPropValueAbc); + resolve(false, localData, isType, objType, propType, propIndex, outPropValue, outPropValueAbc); int propertyId = propIndex.getVal(); Object obj = resolveObject(localData, generator); @@ -539,6 +545,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { Reference outPropType = new Reference<>(null); Reference outPropValue = new Reference<>(null); Reference outPropValueAbc = new Reference<>(null); + Reference isType = new Reference<>(false); /*List abcs = new ArrayList<>(); abcs.add(abc); @@ -549,7 +556,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { otherNs.add(n.getCpoolIndex(abcIndex)); } } - if (!localData.subMethod && cname != null && AVM2SourceGenerator.searchPrototypeChain(otherNs, localData.privateNs, localData.protectedNs, true, abcIndex, pkgName, cname, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc) && (localData.getFullClass().equals(outNs.getVal().addWithSuffix(outName.getVal()).toRawString()))) { + if (!localData.subMethod && cname != null && AVM2SourceGenerator.searchPrototypeChain(otherNs, localData.privateNs, localData.protectedNs, true, abcIndex, pkgName, cname, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType) && (localData.getFullClass().equals(outNs.getVal().addWithSuffix(outName.getVal()).toRawString()))) { NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.getFullClass()), 0, "this", null, false, openedNamespaces, abcIndex); nobj.setRegNumber(0); obj = nobj; @@ -560,7 +567,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { Reference propValue = new Reference<>(null); Reference propValueAbc = new Reference<>(null); - resolve(false, localData, objType, propType, propIndex, outPropValue, propValueAbc); + resolve(false, localData, isType, objType, propType, propIndex, outPropValue, propValueAbc); obj = ins(AVM2Instructions.FindPropertyStrict, propIndex.getVal()); } } @@ -575,8 +582,9 @@ public class PropertyAVM2Item extends AssignableAVM2Item { Reference propIndex = new Reference<>(0); Reference outPropValue = new Reference<>(null); Reference outPropValueAbc = new Reference<>(null); + Reference isType = new Reference<>(false); - resolve(false, localData, objType, propType, propIndex, outPropValue, outPropValueAbc); + resolve(false, localData, isType, objType, propType, propIndex, outPropValue, outPropValueAbc); int propertyId = propIndex.getVal(); Object obj = resolveObject(localData, generator); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java index 34dd19027..fd2e223d0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java @@ -349,10 +349,11 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { Reference propertyIndex = new Reference<>(null); Reference propertyValue = new Reference<>(null); Reference propertyValueABC = new Reference<>(null); + Reference isType = new Reference<>(false); - resolvedx.resolve(true, localData, objectType, propertyType, propertyIndex, propertyValue, propertyValueABC); + resolvedx.resolve(true, localData, isType, objectType, propertyType, propertyIndex, propertyValue, propertyValueABC); - if (objectType.getVal() != null && !((objectType.getVal() instanceof TypeItem) && ("".equals(((TypeItem) objectType.getVal()).fullTypeName.toRawString())))) { + if (objectType.getVal() != null && !isType.getVal()) { isProperty = true; } } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index 226b035a9..fcab78552 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -1516,8 +1516,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener