diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bc0dccfc..4d6b17377 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. - [#1870] AS3 Adding new class - Target DoABC tag or position can be selected to prevent Error 1014 - [#1871] Toogle buttons for disabling subsprite animation, display preview of sprites/frames - [#1875] Remove no longer accessed items from cache after certain amount of time +- [#1280] AS3 Direct editation of traits with the same name ### Fixed - [#1869] Replace references now replaces all references, not just PlaceObject 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 eb5474986..d9cad1222 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 @@ -746,7 +746,7 @@ public class AVM2SourceGenerator implements SourceGenerator { ret.add(ins(AVM2Instructions.NewObject, 0)); ret.add(ins(AVM2Instructions.PushWith)); scope = localData.scopeStack.size(); - localData.scopeStack.add(new PropertyAVM2Item(null, false, item.functionName, abcIndex, new ArrayList<>(), localData.callStack)); + localData.scopeStack.add(new PropertyAVM2Item(null, false, item.functionName, "" /*??*/, abcIndex, new ArrayList<>(), localData.callStack)); } AVM2ConstantPool constants = abcIndex.getSelectedAbc().constants; ret.add(ins(AVM2Instructions.NewFunction, method(false, constants.getStringId(item.functionName, true), true, false, localData.callStack, localData.pkg, item.needsActivation, item.subvariables, 0 /*Set later*/, item.hasRest, item.line, localData.currentClass, null, false, localData, item.paramTypes, item.paramNames, item.paramValues, item.body, item.retType))); @@ -1850,7 +1850,7 @@ public class AVM2SourceGenerator implements SourceGenerator { continue; } - NameAVM2Item d = new NameAVM2Item(n.type, n.line, n.isAttribute(), n.getVariableName(), NameAVM2Item.getDefaultValue("" + n.type), true, n.openedNamespaces, abcIndex); + NameAVM2Item d = new NameAVM2Item(n.type, n.line, n.isAttribute(), n.getVariableName(), n.getNamespaceSuffix(), NameAVM2Item.getDefaultValue("" + n.type), true, n.openedNamespaces, abcIndex); //no index if (needsActivation) { if (d.getSlotNumber() <= 0) { @@ -1909,9 +1909,9 @@ public class AVM2SourceGenerator implements SourceGenerator { mbody.traits.traits.add(tsc); } for (int i = 1; i < paramRegCount; i++) { - NameAVM2Item param = new NameAVM2Item(registerTypes.get(i), 0, false, registerNames.get(i), null, false, new ArrayList<>(), abcIndex); + NameAVM2Item param = new NameAVM2Item(registerTypes.get(i), 0, false, registerNames.get(i), "", null, false, new ArrayList<>(), abcIndex); param.setRegNumber(i); - NameAVM2Item d = new NameAVM2Item(registerTypes.get(i), 0, false, registerNames.get(i), param, true, new ArrayList<>(), abcIndex); + NameAVM2Item d = new NameAVM2Item(registerTypes.get(i), 0, false, registerNames.get(i), "", param, true, new ArrayList<>(), abcIndex); d.setSlotScope(slotScope); d.setSlotNumber(slotNames.indexOf(registerNames.get(i))); declarations.add(d); @@ -2609,8 +2609,13 @@ 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, Reference isType) { + public static boolean searchPrototypeChain(Integer namespaceSuffix, 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 (namespaceSuffix != null) { + if (searchPrototypeChain(namespaceSuffix, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType)) { + return true; + } + } if (searchPrototypeChain(privateNs, instanceOnly, abc, pkg, obj, propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc, isType)) { return true; } 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 58af260fc..b62ec7bdc 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 @@ -453,7 +453,7 @@ public final class AbcIndexing { propValue = new ValueKind(tsc.value_index, tsc.value_kind); } if (map != null) { - PropertyDef dp = new PropertyDef(t.getName(abc).getName(abc.constants, new ArrayList<>() /*?*/, true, true /*FIXME ???*/), multinameToType(name_index, abc.constants), abc, abc.constants.getMultiname(t.name_index).namespace_index); + PropertyDef dp = new PropertyDef(t.getName(abc).getName(abc.constants, new ArrayList<>() /*?*/, true, false), multinameToType(name_index, abc.constants), abc, abc.constants.getMultiname(t.name_index).namespace_index); map.put(dp, new TraitIndex(t, abc, getTraitReturnType(abc, t), propValue, multinameToType(name_index, abc.constants))); } if (mapNs != null) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java index 45fea332d..d78bb0d64 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScript3Parser.java @@ -306,6 +306,7 @@ public class ActionScript3Parser { String propName = s.value.toString(); //Can be * GraphTargetItem propItem = null; s = lex(); + String nsSuffix = ""; GraphTargetItem ns = null; if (s.type == SymbolType.NAMESPACE_OP) { ns = new UnresolvedAVM2Item(new ArrayList<>(), importedClasses, false, null, lexer.yyline(), new DottedChain(new String[]{propName}, new String[]{""} /*FIXME ???*/), null, openedNamespaces, abcIndex); @@ -321,12 +322,17 @@ public class ActionScript3Parser { propItem = null; } } else { - lexer.pushback(s); + if (s.type == SymbolType.NAMESPACESUFFIX) { + nsSuffix = "#" + s.value; + } else { + lexer.pushback(s); + } } + if (ns != null) { ret = new NamespacedAVM2Item(ns, propName, propItem, ret, attr, openedNamespaces, null); } else { - ret = new PropertyAVM2Item(ret, attr, propName, abcIndex, openedNamespaces, new ArrayList<>()); + ret = new PropertyAVM2Item(ret, attr, propName, nsSuffix, abcIndex, openedNamespaces, new ArrayList<>()); } s = lex(); } @@ -553,14 +559,14 @@ public class ActionScript3Parser { } List body = null; List subvariables = new ArrayList<>(); - subvariables.add(new NameAVM2Item(thisType, lexer.yyline(), false, "this", null, true, openedNamespaces, abcIndex)); + subvariables.add(new NameAVM2Item(thisType, lexer.yyline(), false, "this", "", null, true, openedNamespaces, abcIndex)); for (int i = 0; i < paramNames.size() - (hasRest ? 1 : 0); i++) { - subvariables.add(new NameAVM2Item(paramTypes.get(i), lexer.yyline(), false, paramNames.get(i), null, true, openedNamespaces, abcIndex)); + subvariables.add(new NameAVM2Item(paramTypes.get(i), lexer.yyline(), false, paramNames.get(i), "", null, true, openedNamespaces, abcIndex)); } if (hasRest) { - subvariables.add(new NameAVM2Item(TypeItem.UNBOUNDED, lexer.yyline(), false, paramNames.get(paramNames.size() - 1), null, true, openedNamespaces, abcIndex)); + subvariables.add(new NameAVM2Item(TypeItem.UNBOUNDED, lexer.yyline(), false, paramNames.get(paramNames.size() - 1), "", null, true, openedNamespaces, abcIndex)); } - subvariables.add(new NameAVM2Item(thisType, lexer.yyline(), false, "arguments", null, true, openedNamespaces, abcIndex)); + subvariables.add(new NameAVM2Item(thisType, lexer.yyline(), false, "arguments", "", null, true, openedNamespaces, abcIndex)); int parCnt = subvariables.size(); Reference needsActivation2 = new Reference<>(false); if (!isInterface) { @@ -750,7 +756,7 @@ public class ActionScript3Parser { } } else { fname = s.value.toString(); - } + } if (fname.equals(classNameStr)) { //constructor if (isStatic) { throw new AVM2ParseException("Constructor cannot be static", lexer.yyline()); @@ -771,6 +777,14 @@ public class ActionScript3Parser { isStatic = true; } { + + s = lex(); + if (s.type == SymbolType.NAMESPACESUFFIX) { + namespace = new NamespaceItem((Integer) s.value); + } else { + lexer.pushback(s); + } + MethodAVM2Item ft = method(allOpenedNamespaces, outsidePackage, isPrivate, metadata, namespace, isInterface, customNs, new Reference<>(false), importedClasses, isOverride, isFinal, thisType, openedNamespaces, isStatic, fname, true, new ArrayList<>()); if (isGetter) { @@ -852,6 +866,12 @@ public class ActionScript3Parser { expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER); String vcname = s.value.toString(); s = lex(); + + if (s.type == SymbolType.NAMESPACESUFFIX) { + namespace = new NamespaceItem((Integer) s.value); + s = lex(); + } + GraphTargetItem type; if (s.type == SymbolType.COLON) { type = type(allOpenedNamespaces, thisType, pkg, new Reference<>(false), importedClasses, openedNamespaces, new ArrayList<>()); @@ -1477,10 +1497,10 @@ public class ActionScript3Parser { if (s.type == SymbolType.ASSIGN) { GraphTargetItem varval = (expression(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, true, variables, false)); - ret = new NameAVM2Item(type, lexer.yyline(), false, varIdentifier, varval, true, openedNamespaces, abcIndex); + ret = new NameAVM2Item(type, lexer.yyline(), false, varIdentifier, "", varval, true, openedNamespaces, abcIndex); variables.add((NameAVM2Item) ret); } else { - ret = new NameAVM2Item(type, lexer.yyline(), false, varIdentifier, null, true, openedNamespaces, abcIndex); + ret = new NameAVM2Item(type, lexer.yyline(), false, varIdentifier, "", null, true, openedNamespaces, abcIndex); variables.add((NameAVM2Item) ret); lexer.pushback(s); } @@ -1748,7 +1768,7 @@ public class ActionScript3Parser { String enamestr = s.value.toString(); expectedType(SymbolType.COLON); GraphTargetItem etype = type(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, variables); - NameAVM2Item e = new NameAVM2Item(etype, lexer.yyline(), false, enamestr, new ExceptionAVM2Item(null)/*?*/, true/*?*/, openedNamespaces, abcIndex); + NameAVM2Item e = new NameAVM2Item(etype, lexer.yyline(), false, enamestr, "", new ExceptionAVM2Item(null)/*?*/, true/*?*/, openedNamespaces, abcIndex); variables.add(e); catchExceptions.add(e); e.setSlotNumber(1); 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 466af4516..fe0131753 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 @@ -48,11 +48,11 @@ public class CallAVM2Item extends AVM2Item { public int line; public List openedNamespaces; - + private AbcIndexing abcIndex; public CallAVM2Item(List openedNamespaces, int line, GraphTargetItem name, List arguments, AbcIndexing abcIndex) { - super(null, null, NOPRECEDENCE); + super(null, null, NOPRECEDENCE); this.openedNamespaces = openedNamespaces; this.name = name; this.arguments = arguments; @@ -97,12 +97,12 @@ public class CallAVM2Item extends AVM2Item { 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, isType)) { - NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.getFullClass()), n.line, false, "this", null, false, n.openedNamespaces, abcIndex); + if (cname != null && AVM2SourceGenerator.searchPrototypeChain(null, 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, false, "this", "", null, false, n.openedNamespaces, abcIndex); nobj.setRegNumber(0); obj = nobj; } - PropertyAVM2Item p = new PropertyAVM2Item(obj, n.isAttribute(), n.getVariableName(), g.abcIndex, n.openedNamespaces, new ArrayList<>()); + PropertyAVM2Item p = new PropertyAVM2Item(obj, n.isAttribute(), n.getVariableName(), n.getNamespaceSuffix(), g.abcIndex, n.openedNamespaces, new ArrayList<>()); p.setAssignedValue(n.getAssignedValue()); callable = p; } @@ -142,8 +142,8 @@ 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, isType) && (localData.getFullClass().equals(outNs.getVal().addWithSuffix(outName.getVal()).toRawString()))) { - NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.getFullClass()), 0, false, "this", null, false, new ArrayList<>(), abcIndex); + if (cname != null && AVM2SourceGenerator.searchPrototypeChain(null, 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, false, "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/NameAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java index 0e4965165..1893c6bc1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NameAVM2Item.java @@ -76,10 +76,12 @@ public class NameAVM2Item extends AssignableAVM2Item { public GraphTargetItem redirect; private AbcIndexing abcIndex; + + private String namespaceSuffix; @Override public AssignableAVM2Item copy() { - NameAVM2Item c = new NameAVM2Item(type, line, attribute, variableName, assignedValue, definition, openedNamespaces, abcIndex); + NameAVM2Item c = new NameAVM2Item(type, line, attribute, variableName, namespaceSuffix, assignedValue, definition, openedNamespaces, abcIndex); c.setNs(ns); c.regNumber = regNumber; c.unresolved = unresolved; @@ -145,10 +147,17 @@ public class NameAVM2Item extends AssignableAVM2Item { return variableName; } - public NameAVM2Item(GraphTargetItem type, int line, boolean attribute, String variableName, GraphTargetItem storeValue, boolean definition, List openedNamespaces, AbcIndexing abcIndex) { + public String getNamespaceSuffix() { + return namespaceSuffix; + } + + + + public NameAVM2Item(GraphTargetItem type, int line, boolean attribute, String variableName, String namespaceSuffix, GraphTargetItem storeValue, boolean definition, List openedNamespaces, AbcIndexing abcIndex) { super(storeValue); this.attribute = attribute; this.variableName = variableName; + this.namespaceSuffix = namespaceSuffix; this.assignedValue = storeValue; this.definition = definition; this.line = line; 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 72bab0b26..9ce427749 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 @@ -53,6 +53,10 @@ public class NamespaceItem { this.name = DottedChain.parseWithSuffix(name); this.kind = kind; } + + public NamespaceItem(int nsIndex) { + this.nsIndex = nsIndex; + } @Override public String toString() { @@ -86,7 +90,7 @@ public class NamespaceItem { } if (kind == Namespace.KIND_NAMESPACE) { String custom = name.toRawString(); - PropertyAVM2Item prop = new PropertyAVM2Item(null, false, custom, abcIndex, openedNamespaces, new ArrayList<>()); + PropertyAVM2Item prop = new PropertyAVM2Item(null, false, custom, "", abcIndex, openedNamespaces, new ArrayList<>()); Reference value = new Reference<>(null); Reference outAbc = new Reference<>(null); Reference isType = new Reference<>(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 e0ec46080..9d6d22847 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 @@ -64,6 +64,8 @@ public class PropertyAVM2Item extends AssignableAVM2Item { public GraphTargetItem object; public AbcIndexing abcIndex; + + public String namespaceSuffix; private final List openedNamespaces; @@ -73,13 +75,14 @@ public class PropertyAVM2Item extends AssignableAVM2Item { @Override public AssignableAVM2Item copy() { - PropertyAVM2Item p = new PropertyAVM2Item(object, attribute, propertyName, abcIndex, openedNamespaces, callStack); + PropertyAVM2Item p = new PropertyAVM2Item(object, attribute, propertyName, namespaceSuffix, abcIndex, openedNamespaces, callStack); return p; } - public PropertyAVM2Item(GraphTargetItem object, boolean attribute, String propertyName, AbcIndexing abcIndex, List openedNamespaces, List callStack) { - this.attribute = attribute; + public PropertyAVM2Item(GraphTargetItem object, boolean attribute, String propertyName, String namespaceSuffix, AbcIndexing abcIndex, List openedNamespaces, List callStack) { + this.attribute = attribute; this.propertyName = propertyName; + this.namespaceSuffix = namespaceSuffix; this.object = object; this.abcIndex = abcIndex; this.openedNamespaces = openedNamespaces; @@ -137,6 +140,11 @@ public class PropertyAVM2Item extends AssignableAVM2Item { } public void resolve(boolean mustExist, SourceGeneratorLocalData localData, Reference isType, Reference objectType, Reference propertyType, Reference propertyIndex, Reference propertyValue, Reference propertyValueABC) throws CompilationException { + + Integer namespaceSuffixInt = null; + if (!"".equals(namespaceSuffix)) { + namespaceSuffixInt = Integer.parseInt(namespaceSuffix.substring(1)); + } isType.setVal(false); GraphTargetItem thisType = new TypeItem(localData.getFullClass()); GraphTargetItem objType = null; @@ -274,12 +282,12 @@ 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, isType)) { + if (propType == null && AVM2SourceGenerator.searchPrototypeChain(namespaceSuffixInt, 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, constants.getStringId(propertyName, true), - constants.getNamespaceId(outPropNsKind.getVal(), outPropNs.getVal(), outPropNsIndex.getVal(), true)), true + namespaceSuffixInt != null ? namespaceSuffixInt : constants.getNamespaceId(outPropNsKind.getVal(), outPropNs.getVal(), outPropNsIndex.getVal(), true)), true ); propValue = outPropValue.getVal(); propValueAbc = outPropValueAbc.getVal(); @@ -393,12 +401,12 @@ 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, isType)) { + if (AVM2SourceGenerator.searchPrototypeChain(namespaceSuffixInt, 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, constants.getStringId(propertyName, true), - constants.getNamespaceId(outPropNsKind.getVal(), outPropNs.getVal(), outPropNsIndex.getVal(), true)), true + namespaceSuffixInt != null ? namespaceSuffixInt : constants.getNamespaceId(outPropNsKind.getVal(), outPropNs.getVal(), outPropNsIndex.getVal(), true)), true ); propValue = p.value; propValueAbc = outPropValueAbc.getVal(); @@ -558,8 +566,14 @@ 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, isType) && (localData.getFullClass().equals(outNs.getVal().addWithSuffix(outName.getVal()).toRawString()))) { - NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.getFullClass()), 0, false, "this", null, false, openedNamespaces, abcIndex); + + Integer namespaceSuffixInt = null; + if (!"".equals(namespaceSuffix)) { + namespaceSuffixInt = Integer.parseInt(namespaceSuffix.substring(1)); + } + + if (!localData.subMethod && cname != null && AVM2SourceGenerator.searchPrototypeChain(namespaceSuffixInt, 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, false, "this", "", null, false, openedNamespaces, abcIndex); nobj.setRegNumber(0); obj = nobj; } else { 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 2b72d7d60..93d35520e 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 @@ -295,13 +295,13 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { if (a instanceof NameAVM2Item) { NameAVM2Item n = (NameAVM2Item) a; if (n.isDefinition() && name.get(0).equals(n.getVariableName())) { - NameAVM2Item ret = new NameAVM2Item(n.type, n.line, name.isAttribute(0), name.get(0), null, false, openedNamespaces, abcIndex); + NameAVM2Item ret = new NameAVM2Item(n.type, n.line, name.isAttribute(0), name.get(0), name.getNamespaceSuffix(0), null, false, openedNamespaces, abcIndex); ret.setSlotScope(n.getSlotScope()); ret.setSlotNumber(n.getSlotNumber()); ret.setRegNumber(n.getRegNumber()); resolved = ret; for (int i = 1; i < name.size(); i++) { - resolved = new PropertyAVM2Item(resolved, name.isAttribute(i), name.get(i), abc, openedNamespaces, new ArrayList<>()); + resolved = new PropertyAVM2Item(resolved, name.isAttribute(i), name.get(i), name.getNamespaceSuffix(i), abc, openedNamespaces, new ArrayList<>()); if (i == name.size() - 1) { ((PropertyAVM2Item) resolved).assignedValue = assignedValue; } @@ -325,10 +325,10 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { t = paramTypes.get(ind); } //else rest parameter - GraphTargetItem ret = new NameAVM2Item(t, line, name.isAttribute(0), name.get(0), null, false, openedNamespaces, abcIndex); + GraphTargetItem ret = new NameAVM2Item(t, line, name.isAttribute(0), name.get(0), name.getNamespaceSuffix(0), null, false, openedNamespaces, abcIndex); resolved = ret; for (int i = 1; i < name.size(); i++) { - resolved = new PropertyAVM2Item(resolved, name.isAttribute(i), name.get(i), abc, openedNamespaces, new ArrayList<>()); + resolved = new PropertyAVM2Item(resolved, name.isAttribute(i), name.get(i), name.getNamespaceSuffix(i), abc, openedNamespaces, new ArrayList<>()); if (i == name.size() - 1) { ((PropertyAVM2Item) resolved).assignedValue = assignedValue; } @@ -341,7 +341,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { boolean isProperty = false; if (localData != null) { //resolve can be called without localData - PropertyAVM2Item resolvedx = new PropertyAVM2Item(null, name.isAttribute(0), name.get(0), abc, openedNamespaces, callStack); + PropertyAVM2Item resolvedx = new PropertyAVM2Item(null, name.isAttribute(0), name.get(0), name.getNamespaceSuffix(0), abc, openedNamespaces, callStack); ((PropertyAVM2Item) resolvedx).scopeStack = scopeStack; ((PropertyAVM2Item) resolvedx).setAssignedValue(assignedValue); Reference objectType = new Reference<>(null); @@ -368,7 +368,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { if (ci != null) { resolved = ti; for (int i = 1; i < name.size(); i++) { - resolved = new PropertyAVM2Item(resolved, name.isAttribute(i), name.get(i), abc, openedNamespaces, new ArrayList<>()); + resolved = new PropertyAVM2Item(resolved, name.isAttribute(i), name.get(i), name.getNamespaceSuffix(i), abc, openedNamespaces, new ArrayList<>()); if (i == name.size() - 1) { ((PropertyAVM2Item) resolved).assignedValue = assignedValue; } @@ -387,7 +387,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { TypeItem ret = new TypeItem(imp); resolved = ret; for (int i = 1; i < name.size(); i++) { - resolved = new PropertyAVM2Item(resolved, name.isAttribute(i), name.get(i), abc, openedNamespaces, new ArrayList<>()); + resolved = new PropertyAVM2Item(resolved, name.isAttribute(i), name.get(i), name.getNamespaceSuffix(i), abc, openedNamespaces, new ArrayList<>()); if (i == name.size() - 1) { ((PropertyAVM2Item) resolved).assignedValue = assignedValue; } @@ -420,7 +420,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { TypeItem ret = new TypeItem(fname); resolved = ret; for (int j = i + 1; j < name.size(); j++) { - resolved = new PropertyAVM2Item(resolved, name.isAttribute(j), name.get(j), abc, openedNamespaces, new ArrayList<>()); + resolved = new PropertyAVM2Item(resolved, name.isAttribute(j), name.get(j), name.getNamespaceSuffix(j), abc, openedNamespaces, new ArrayList<>()); if (j == name.size() - 1) { ((PropertyAVM2Item) resolved).assignedValue = assignedValue; } @@ -449,7 +449,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { TypeItem ret = ti; resolved = ret; for (int i = 1; i < name.size(); i++) { - resolved = new PropertyAVM2Item(resolved, name.isAttribute(i), name.get(i), abc, openedNamespaces, new ArrayList<>()); + resolved = new PropertyAVM2Item(resolved, name.isAttribute(i), name.get(i), name.getNamespaceSuffix(i), abc, openedNamespaces, new ArrayList<>()); if (i == name.size() - 1) { ((PropertyAVM2Item) resolved).assignedValue = assignedValue; } @@ -483,10 +483,10 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { } } - NameAVM2Item ret = new NameAVM2Item(ntype, line, name.isAttribute(0), name.get(0), null, false, openedNamespaces, abcIndex); + NameAVM2Item ret = new NameAVM2Item(ntype, line, name.isAttribute(0), name.get(0), name.getNamespaceSuffix(0), null, false, openedNamespaces, abcIndex); resolved = ret; for (int i = 1; i < name.size(); i++) { - resolved = new PropertyAVM2Item(resolved, name.isAttribute(i), name.get(i), abc, openedNamespaces, new ArrayList<>()); + resolved = new PropertyAVM2Item(resolved, name.isAttribute(i), name.get(i), name.getNamespaceSuffix(i), abc, openedNamespaces, new ArrayList<>()); if (i == name.size() - 1) { ((PropertyAVM2Item) resolved).assignedValue = assignedValue; } @@ -509,7 +509,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { resolved = null; GraphTargetItem ret = null; for (int i = 0; i < name.size(); i++) { - resolved = new PropertyAVM2Item(resolved, name.isAttribute(i), name.get(i), abc, openedNamespaces, callStack); + resolved = new PropertyAVM2Item(resolved, name.isAttribute(i), name.get(i), name.getNamespaceSuffix(i), abc, openedNamespaces, callStack); if (ret == null) { ((PropertyAVM2Item) resolved).scopeStack = scopeStack; ret = resolved;