diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java index 622c6520b..943468d12 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java @@ -209,7 +209,7 @@ public class IdentifiersDeobfuscation { } public String deobfuscateNameWithPackage(boolean as3, String n, HashMap namesMap, RenameType renameType, Map selected) { - DottedChain nChain = DottedChain.parse(n); + DottedChain nChain = DottedChain.parseWithSuffix(n); DottedChain pkg = nChain.getWithoutLast(); String name = nChain.getLast(); @@ -288,7 +288,7 @@ public class IdentifiersDeobfuscation { usageType = "name"; } - DottedChain sChain = DottedChain.parse(s); + DottedChain sChain = DottedChain.parseWithSuffix(s); if (selected != null) { if (selected.containsKey(sChain)) { return selected.get(sChain).toRawString(); @@ -314,14 +314,14 @@ public class IdentifiersDeobfuscation { ret = fooString(firstUppercase, rndSize); if (allVariableNamesStr.contains(ret) || isReservedWord(ret, as3) - || namesMap.containsValue(DottedChain.parse(ret))) { + || namesMap.containsValue(DottedChain.parseWithSuffix(ret))) { found = true; rndSize++; } } } while (found); - namesMap.put(DottedChain.parse(s), DottedChain.parse(ret)); + namesMap.put(DottedChain.parseWithSuffix(s), DottedChain.parseWithSuffix(ret)); return ret; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index 1c4880084..7dafe48e1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -2204,7 +2204,7 @@ public final class SWF implements SWFContainerItem, Timelined { public void renameAS2Identifier(String identifier, String newname) throws InterruptedException { Map selected = new HashMap<>(); - selected.put(DottedChain.parse(identifier), DottedChain.parse(newname)); + selected.put(DottedChain.parseWithSuffix(identifier), DottedChain.parseWithSuffix(newname)); renameAS2Identifiers(null, selected); } @@ -2276,7 +2276,7 @@ public final class SWF implements SWFContainerItem, Timelined { String fname = dvf.toStringNoH(null); String changed = deobfuscation.deobfuscateName(false, fname, false, "method", deobfuscated, renameType, selected); if (changed != null) { - deobfuscated.put(DottedChain.parse(fname), DottedChain.parse(changed)); + deobfuscated.put(DottedChain.parseWithSuffix(fname), DottedChain.parseWithSuffix(changed)); } } } @@ -2295,7 +2295,7 @@ public final class SWF implements SWFContainerItem, Timelined { String vname = dvf.toStringNoH(null); String changed = deobfuscation.deobfuscateName(false, vname, false, "attribute", deobfuscated, renameType, selected); if (changed != null) { - deobfuscated.put(DottedChain.parse(vname), DottedChain.parse(changed)); + deobfuscated.put(DottedChain.parseWithSuffix(vname), DottedChain.parseWithSuffix(changed)); } } } @@ -2331,7 +2331,7 @@ public final class SWF implements SWFContainerItem, Timelined { changedNameStr = changedNameStr2; } ret++; - deobfuscated.put(DottedChain.parse(nameStr), DottedChain.parse(changedNameStr)); + deobfuscated.put(DottedChain.parseWithSuffix(nameStr), DottedChain.parseWithSuffix(changedNameStr)); pos++; } name = mem.object; @@ -2355,7 +2355,7 @@ public final class SWF implements SWFContainerItem, Timelined { changedNameStr = changedNameStr2; } ret++; - deobfuscated.put(DottedChain.parse(nameStr), DottedChain.parse(changedNameStr)); + deobfuscated.put(DottedChain.parseWithSuffix(nameStr), DottedChain.parseWithSuffix(changedNameStr)); pos++; } } @@ -2899,7 +2899,8 @@ public final class SWF implements SWFContainerItem, Timelined { timelined.setModified(true); timelined.resetTimeline(); } else // timeline should be always the swf here - if (removeDependencies) { + { + if (removeDependencies) { removeTagWithDependenciesFromTimeline(tag, timelined.getTimeline()); timelined.setModified(true); } else { @@ -2908,6 +2909,7 @@ public final class SWF implements SWFContainerItem, Timelined { timelined.setModified(true); } } + } } @Override @@ -3538,10 +3540,10 @@ public final class SWF implements SWFContainerItem, Timelined { if (firstTrait instanceof TraitClass) { int cindex = ((TraitClass) firstTrait).class_info; Multiname superName = documentPack.abc.constants.getMultiname(documentPack.abc.instance_info.get(cindex).super_index); - String parentClass = superName.getNameWithNamespace(documentPack.abc.constants).toRawString(); + String parentClass = superName.getNameWithNamespace(documentPack.abc.constants, true).toRawString(); if ("mx.managers.SystemManager".equals(parentClass)) { for (Trait t : documentPack.abc.instance_info.get(cindex).instance_traits.traits) { - if ((t instanceof TraitMethodGetterSetter) && "info".equals(t.getName(documentPack.abc).getName(documentPack.abc.constants, new ArrayList<>(), true))) { + if ((t instanceof TraitMethodGetterSetter) && "info".equals(t.getName(documentPack.abc).getName(documentPack.abc.constants, new ArrayList<>(), true, true))) { int mi = ((TraitMethodGetterSetter) t).method_info; try { @@ -3627,7 +3629,7 @@ public final class SWF implements SWFContainerItem, Timelined { if (cit instanceof SetPropertyAVM2Item) { if (cit.value instanceof GetLexAVM2Item) { GetLexAVM2Item gl = (GetLexAVM2Item) cit.value; - ignoredClasses.add(gl.propertyName.getNameWithNamespace(p.abc.constants).toRawString()); + ignoredClasses.add(gl.propertyName.getNameWithNamespace(p.abc.constants, true).toRawString()); } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java index 75d13f0ad..422905d25 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java @@ -50,7 +50,7 @@ public class SourceGeneratorLocalData implements Serializable { public int finallyRegister = -1; - public String currentClass; + public String currentClass; //FIXME! Suffixed or not? public String superClass = null; @@ -79,7 +79,7 @@ public class SourceGeneratorLocalData implements Serializable { public boolean isStatic = false; public String getFullClass() { - return pkg == null ? currentClass : pkg.add(currentClass).toRawString(); + return pkg == null ? currentClass : pkg.addWithSuffix(currentClass).toRawString(); } public SourceGeneratorLocalData(HashMap registerVars, Integer inFunction, Boolean inMethod, Integer forInLevel) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java index 516127195..ab1f30808 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -42,6 +42,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitFunction; import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.abc.types.traits.Traits; +import com.jpexs.decompiler.flash.abc.usages.ClassNameInTraitMultinameUsage; import com.jpexs.decompiler.flash.abc.usages.ClassNameMultinameUsage; import com.jpexs.decompiler.flash.abc.usages.ConstVarNameMultinameUsage; import com.jpexs.decompiler.flash.abc.usages.ConstVarTypeMultinameUsage; @@ -392,7 +393,7 @@ public class ABC { int mIndex = body.getCode().code.get(ip).operands[0]; if (mIndex > 0) { Multiname m = constants.getMultiname(mIndex); - if (m.getNameWithNamespace(constants).toRawString().equals("flash.utils.getDefinitionByName")) { + if (m.getNameWithNamespace(constants, true).toRawString().equals("flash.utils.getDefinitionByName")) { if (ip > 0) { if (body.getCode().code.get(ip - 1).definition instanceof PushStringIns) { int strIndex = body.getCode().code.get(ip - 1).operands[0]; @@ -827,9 +828,9 @@ public class ABC { return getMethodIndexing().findMethodBodyIndex(methodInfo); } - public MethodBody findBodyClassInitializerByClass(String className) { + public MethodBody findBodyClassInitializerByClass(String classNameWithSuffix) { for (int i = 0; i < instance_info.size(); i++) { - if (className.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, null, true))) { + if (classNameWithSuffix.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, null, true, true))) { MethodBody body = findBody(class_info.get(i).cinit_index); if (body != null) { return body; @@ -840,9 +841,9 @@ public class ABC { return null; } - public MethodBody findBodyInstanceInitializerByClass(String className) { + public MethodBody findBodyInstanceInitializerByClass(String classNameWithSuffix) { for (int i = 0; i < instance_info.size(); i++) { - if (className.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, null, true))) { + if (classNameWithSuffix.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, null, true, true))) { MethodBody body = findBody(instance_info.get(i).iinit_index); if (body != null) { return body; @@ -853,13 +854,13 @@ public class ABC { return null; } - public MethodBody findBodyByClassAndName(String className, String methodName) { + public MethodBody findBodyByClassAndName(String classNameWithSuffix, String methodNameWithSuffix) { for (int i = 0; i < instance_info.size(); i++) { - if (className.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, null, true))) { + if (classNameWithSuffix.equals(constants.getMultiname(instance_info.get(i).name_index).getName(constants, null, true, true))) { for (Trait t : instance_info.get(i).instance_traits.traits) { if (t instanceof TraitMethodGetterSetter) { TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t; - if (methodName.equals(t2.getName(this).getName(constants, null, true))) { + if (methodNameWithSuffix.equals(t2.getName(this).getName(constants, null, true, true))) { MethodBody body = findBody(t2.method_info); if (body != null) { return body; @@ -871,7 +872,7 @@ public class ABC { for (Trait t : class_info.get(i).static_traits.traits) { if (t instanceof TraitMethodGetterSetter) { TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t; - if (methodName.equals(t2.getName(this).getName(constants, null, true))) { + if (methodNameWithSuffix.equals(t2.getName(this).getName(constants, null, true, true))) { MethodBody body = findBody(t2.method_info); if (body != null) { return body; @@ -956,7 +957,7 @@ public class ABC { TraitSlotConst s = ((TraitSlotConst) t); if (s.isNamespace()) { String key = constants.getNamespace(s.value_index).getName(constants).toRawString(); // assume not null - DottedChain val = constants.getMultiname(s.name_index).getNameWithNamespace(constants); + DottedChain val = constants.getMultiname(s.name_index).getNameWithNamespace(constants, true); map.put(key, val); } } @@ -1069,6 +1070,13 @@ public class ABC { private void findMultinameUsageInTraits(Traits traits, int multinameIndex, int traitsType, int scriptIndex, int classIndex, List ret, int parentTraitIndex) { for (int t = 0; t < traits.traits.size(); t++) { + //Assuming instance_info.name_index has same multiname as in the class trait + /*if (traits.traits.get(t) instanceof TraitClass) { + TraitClass tc = (TraitClass) traits.traits.get(t); + if (tc.name_index == multinameIndex) { + ret.add(new ClassNameInTraitMultinameUsage(this, multinameIndex, tc.class_info)); + } + }*/ if (traits.traits.get(t) instanceof TraitSlotConst) { TraitSlotConst tsc = (TraitSlotConst) traits.traits.get(t); if (tsc.name_index == multinameIndex) { @@ -1121,7 +1129,7 @@ public class ABC { for (int multinameIndex = 1; multinameIndex < constants.getMultinameCount(); multinameIndex++) { Multiname m = constants.getMultiname(multinameIndex); if (m.kind == Multiname.QNAME || m.kind == Multiname.QNAMEA) { - String name = m.getName(constants, new ArrayList<>(), true); + String name = m.getName(constants, new ArrayList<>(), true, false); if (!nameToQNameIndices.containsKey(name)) { nameToQNameIndices.put(name, new ArrayList<>()); } @@ -1155,6 +1163,7 @@ public class ABC { Set collidingMultinameIndices = new HashSet<>(); for (MultinameUsage col : collidingUsages) { + //System.err.println("collides " + col); collidingMultinameIndices.add(col.multinameIndex); } @@ -1168,6 +1177,9 @@ public class ABC { if (multinameIndex == 0) { return ret; } + for (int s = 0; s < script_info.size(); s++) { + findMultinameUsageInTraits(script_info.get(s).traits, multinameIndex, TraitMultinameUsage.TRAITS_TYPE_SCRIPT, s, -1, ret, -1); + } for (int c = 0; c < instance_info.size(); c++) { if (instance_info.get(c).name_index == multinameIndex) { ret.add(new ClassNameMultinameUsage(this, multinameIndex, c)); @@ -1203,11 +1215,11 @@ public class ABC { return ret; } - public int findMethodInfoByName(int classId, String methodName) { + public int findMethodInfoByName(int classId, String methodNameWithSuffix) { if (classId > -1) { for (Trait t : instance_info.get(classId).instance_traits.traits) { if (t instanceof TraitMethodGetterSetter) { - if (t.getName(this).getName(constants, null, true).equals(methodName)) { + if (t.getName(this).getName(constants, null, true, true).equals(methodNameWithSuffix)) { return ((TraitMethodGetterSetter) t).method_info; } } @@ -1216,11 +1228,11 @@ public class ABC { return -1; } - public int findMethodBodyByName(int classId, String methodName) { + public int findMethodBodyByName(int classId, String methodNameWithSuffix) { if (classId > -1) { for (Trait t : instance_info.get(classId).instance_traits.traits) { if (t instanceof TraitMethodGetterSetter) { - if (t.getName(this).getName(constants, null, true).equals(methodName)) { + if (t.getName(this).getName(constants, null, true, true).equals(methodNameWithSuffix)) { return findBodyIndex(((TraitMethodGetterSetter) t).method_info); } } @@ -1239,10 +1251,10 @@ public class ABC { return findClassByName(str); } - public int findClassByName(String name) { + public int findClassByName(String nameWithSuffix) { for (int c = 0; c < instance_info.size(); c++) { - DottedChain s = constants.getMultiname(instance_info.get(c).name_index).getNameWithNamespace(constants); - if (name.equals(s.toRawString())) { + DottedChain s = constants.getMultiname(instance_info.get(c).name_index).getNameWithNamespace(constants, true); + if (nameWithSuffix.equals(s.toRawString())) { return c; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java index 4ad52a171..7c0bc9e22 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ClassPath.java @@ -29,30 +29,37 @@ public class ClassPath { public final String className; - public ClassPath(DottedChain packageStr, String className) { + public final String namespaceSuffix; + + public ClassPath(DottedChain packageStr, String className, String namespaceSuffix) { this.packageStr = packageStr == null ? DottedChain.TOPLEVEL : packageStr; this.className = className; + this.namespaceSuffix = namespaceSuffix; } @Override public String toString() { - return packageStr.add(className).toPrintableString(true); + return packageStr.add(className, namespaceSuffix).toPrintableString(true); } public String toRawString() { - return packageStr.add(className).toRawString(); + return packageStr.add(className, namespaceSuffix).toRawString(); } @Override public int hashCode() { - int hash = 7; - hash = 37 * hash + Objects.hashCode(packageStr); - hash = 37 * hash + Objects.hashCode(className); + int hash = 3; + hash = 31 * hash + Objects.hashCode(this.packageStr); + hash = 31 * hash + Objects.hashCode(this.className); + hash = 31 * hash + Objects.hashCode(this.namespaceSuffix); return hash; } @Override public boolean equals(Object obj) { + if (this == obj) { + return true; + } if (obj == null) { return false; } @@ -60,9 +67,16 @@ public class ClassPath { return false; } final ClassPath other = (ClassPath) obj; - if (!Objects.equals(packageStr, other.packageStr)) { + if (!Objects.equals(this.className, other.className)) { return false; } - return Objects.equals(className, other.className); + if (!Objects.equals(this.namespaceSuffix, other.namespaceSuffix)) { + return false; + } + if (!Objects.equals(this.packageStr, other.packageStr)) { + return false; + } + return true; } + } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java index 55317afe1..cb19d825a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/ScriptPack.java @@ -98,7 +98,7 @@ public class ScriptPack extends AS3ClassTreeItem { } public ScriptPack(ClassPath path, ABC abc, List allAbcs, int scriptIndex, List traitIndices) { - super(path.className, path); + super(path.className, path.namespaceSuffix, path); this.abc = abc; this.scriptIndex = scriptIndex; this.traitIndices = traitIndices; @@ -124,7 +124,7 @@ public class ScriptPack extends AS3ClassTreeItem { Multiname name = abc.script_info.get(scriptIndex).traits.traits.get(t).getName(abc); Namespace ns = name.getNamespace(abc.constants); if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) { - scriptName = name.getName(abc.constants, null, false); + scriptName = name.getName(abc.constants, null, false, true); } } return scriptName; 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 23bda7014..911626f6f 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 @@ -1754,7 +1754,7 @@ public class AVM2Code implements Cloneable { if (code.get(ip + plus + 2).definition instanceof SwapIns) { if (code.get(ip + plus + 4).definition instanceof PopScopeIns) { if (code.get(ip + plus + 3).definition instanceof SetPropertyIns) { - functionName = abc.constants.getMultiname(code.get(ip + plus + 3).operands[0]).getName(abc.constants, fullyQualifiedNames, true); + functionName = abc.constants.getMultiname(code.get(ip + plus + 3).operands[0]).getName(abc.constants, fullyQualifiedNames, true, true); scopeStack.pop();// with output.remove(output.size() - 1); // with ip = ip + plus + 4; // +1 below @@ -2040,7 +2040,7 @@ public class AVM2Code implements Cloneable { if (value instanceof NewFunctionAVM2Item) { NewFunctionAVM2Item f = (NewFunctionAVM2Item) value; - f.functionName = tsc.getName(abc).getName(abc.constants, fullyQualifiedNames, true); + f.functionName = tsc.getName(abc).getName(abc.constants, fullyQualifiedNames, true, true); } AssignedValue av = new AssignedValue(value, initializerType, methodIndex); convertData.assignedValues.put(tsc, av); @@ -2085,7 +2085,7 @@ public class AVM2Code implements Cloneable { if (param_types[i] == 0) { type = TypeItem.UNBOUNDED; } else { - type = new TypeItem(abc.constants.getMultiname(param_types[i]).getNameWithNamespace(abc.constants)); + type = new TypeItem(abc.constants.getMultiname(param_types[i]).getNameWithNamespace(abc.constants, true)); } if (d.length > r) { d[r] = new DeclarationAVM2Item(new SetLocalAVM2Item(null, null, r, new NullAVM2Item(null, null)), type); @@ -2174,8 +2174,7 @@ public class AVM2Code implements Cloneable { ins.operands[j] = updater.updateOperandOffset(target, ins.operands[j]); } }*/ //Faster, but not so universal - { - if (ins.definition instanceof IfTypeIns) { + if (ins.definition instanceof IfTypeIns) { long target = ins.getTargetAddress(); try { ins.operands[0] = updater.updateOperandOffset(ins.getAddress(), target, ins.operands[0]); @@ -2183,7 +2182,6 @@ public class AVM2Code implements Cloneable { throw new ConvertException("Invalid offset (" + ins + ")", i); } } - } ins.setAddress(updater.updateInstructionOffset(ins.getAddress())); //Note: changing operands here does not change instruction byte length as offsets are always S24 (not variable length) } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ConstantPool.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ConstantPool.java index 26ab7fd0a..b492487d2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ConstantPool.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ConstantPool.java @@ -664,7 +664,7 @@ public class AVM2ConstantPool implements Cloneable { String str = getString(index); DottedChain chain = dottedChainCache.get(str); if (chain == null) { - chain = DottedChain.parse(str); + chain = DottedChain.parseWithSuffix(str); dottedChainCache.put(str, chain); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Deobfuscation.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Deobfuscation.java index e51616a1f..0bd79b685 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Deobfuscation.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Deobfuscation.java @@ -48,9 +48,9 @@ public class AVM2Deobfuscation { private final Map usageTypesCount = new HashMap<>(); - public static final DottedChain FLASH_PROXY = new DottedChain("flash", "utils", "flash_proxy"); + public static final DottedChain FLASH_PROXY = new DottedChain(new String[]{"flash", "utils", "flash_proxy"}, ""); - public static final DottedChain BUILTIN = new DottedChain("-"); + public static final DottedChain BUILTIN = new DottedChain(new String[]{"-"}, ""); public AVM2Deobfuscation(SWF swf, AVM2ConstantPool constants) { this.swf = swf; @@ -111,12 +111,12 @@ public class AVM2Deobfuscation { } if (swf.as3StringConstantExists(ret) || IdentifiersDeobfuscation.isReservedWord2(ret) - || deobfuscated.containsValue(DottedChain.parse(ret))) { + || deobfuscated.containsValue(DottedChain.parseWithSuffix(ret))) { found = true; rndSize++; } } while (found); - deobfuscated.put(DottedChain.parse(orig), DottedChain.parse(ret)); + deobfuscated.put(DottedChain.parseWithSuffix(orig), DottedChain.parseWithSuffix(ret)); return ret; } @@ -130,7 +130,7 @@ public class AVM2Deobfuscation { } boolean isValid = isValidNSPart(s); if (!isValid) { - DottedChain sChain = DottedChain.parse(s); + DottedChain sChain = DottedChain.parseWithSuffix(s); DottedChain newName; if (namesMap.containsKey(sChain)) { newName = namesMap.get(sChain); @@ -186,19 +186,19 @@ public class AVM2Deobfuscation { if (!isValid) { DottedChain newname; - DottedChain sChain = DottedChain.parse(s); + DottedChain sChain = DottedChain.parseWithSuffix(s); if (namesMap.containsKey(sChain)) { newname = namesMap.get(sChain); } else { String str = fooString(namesMap, constants.getString(strIndex), firstUppercase, stringUsageTypes.get(strIndex), renameType); - newname = DottedChain.parse(str); + newname = DottedChain.parseWithSuffix(str); } if (stringUsages.contains(strIndex) || namespaceUsages.contains(strIndex)) { // this name is already referenced as String strIndex = constants.addString(s); // add new index } constants.setString(strIndex, newname.toRawString()); if (!namesMap.containsKey(sChain)) { - namesMap.put(sChain, DottedChain.parse(constants.getString(strIndex))); + namesMap.put(sChain, DottedChain.parseWithSuffix(constants.getString(strIndex))); } } return strIndex; 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 3db5c3f90..566490ee4 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 @@ -214,7 +214,7 @@ public abstract class InstructionDefinition implements Serializable { } } - return new FullMultinameAVM2Item(property, ins, localData.lineStartInstruction, multinameIndex, localData.abc.constants.getMultiname(multinameIndex).getName(localData.getConstants(), new ArrayList<>(), true), name, ns); + return new FullMultinameAVM2Item(property, ins, localData.lineStartInstruction, multinameIndex, localData.abc.constants.getMultiname(multinameIndex).getName(localData.getConstants(), new ArrayList<>(), true, true), name, ns); } protected int getMultinameRequiredStackSize(AVM2ConstantPool constants, int multinameIndex) { @@ -258,7 +258,7 @@ public abstract class InstructionDefinition implements Serializable { if (constants.getMultiname(multinameIndex).needsName()) { name = stack.get(pos).toString(); } else { - name = GraphTextWriter.hilighOffset(constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames, false), ins.getAddress()); + name = GraphTextWriter.hilighOffset(constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames, false, true), ins.getAddress()); } return name + ns; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/AlchemyTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/AlchemyTypeIns.java index 9d31839da..eef64361b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/AlchemyTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/AlchemyTypeIns.java @@ -24,5 +24,5 @@ import com.jpexs.decompiler.graph.DottedChain; */ public interface AlchemyTypeIns { - public static final DottedChain ALCHEMY_PACKAGE = new DottedChain("avm2", "intrinsics", "memory"); + public static final DottedChain ALCHEMY_PACKAGE = new DottedChain(new String[]{"avm2", "intrinsics", "memory"}, DottedChain.NO_SUFFIX); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java index 16af04d1e..5d83071e0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java @@ -101,7 +101,7 @@ public class ConstructIns extends InstructionDefinition { } if (obj instanceof GetLexAVM2Item) { GetLexAVM2Item glt = (GetLexAVM2Item) obj; - isXML = glt.propertyName.getName(localData.getConstants(), localData.fullyQualifiedNames, true).equals("XML"); + isXML = glt.propertyName.getName(localData.getConstants(), localData.fullyQualifiedNames, true, true).equals("XML"); } if (isXML) { @@ -129,7 +129,7 @@ public class ConstructIns extends InstructionDefinition { } if (obj instanceof GetLexAVM2Item) { GetLexAVM2Item glt = (GetLexAVM2Item) obj; - isRegExp = glt.propertyName.getName(localData.getConstants(), localData.fullyQualifiedNames, true).equals("RegExp"); + isRegExp = glt.propertyName.getName(localData.getConstants(), localData.fullyQualifiedNames, true, true).equals("RegExp"); } if (isRegExp && (args.size() >= 1) && (args.get(0) instanceof StringAVM2Item) && (args.size() == 1 || (args.size() == 2 && args.get(1) instanceof StringAVM2Item))) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java index bab047939..785309f82 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java @@ -46,7 +46,7 @@ public class NewClassIns extends InstructionDefinition { stack.pop().toString(writer, LocalData.create(localData.getConstants(), localData.localRegNames, localData.fullyQualifiedNames)); String baseType = writer.toString(); ABC abc = localData.abc; - stack.push(new UnparsedAVM2Item(ins, localData.lineStartInstruction, "new " + abc.constants.getMultiname(abc.instance_info.get(clsIndex).name_index).getName(localData.getConstants(), localData.fullyQualifiedNames, false) + ".class extends " + baseType)); + stack.push(new UnparsedAVM2Item(ins, localData.lineStartInstruction, "new " + abc.constants.getMultiname(abc.instance_info.get(clsIndex).name_index).getName(localData.getConstants(), localData.fullyQualifiedNames, false, true) + ".class extends " + baseType)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java index a9ca920cc..56b4df551 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java @@ -68,7 +68,7 @@ public abstract class GetLocalTypeIns extends InstructionDefinition { List ts = localData.getInstanceInfo().get(localData.classIndex).instance_traits.traits; boolean isBasicObject = localData.thisHasDefaultToPrimitive; Multiname m = localData.getInstanceInfo().get(localData.classIndex).getName(localData.getConstants()); - stack.push(new ThisAVM2Item(ins, localData.lineStartInstruction, m, m.getNameWithNamespace(localData.getConstants()), isBasicObject)); + stack.push(new ThisAVM2Item(ins, localData.lineStartInstruction, m, m.getNameWithNamespace(localData.getConstants(), true), isBasicObject)); } return; } 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 6dfa5870a..37c4f75c5 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 @@ -104,7 +104,7 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns { if (slotname != null) { if (value instanceof LocalRegAVM2Item) { LocalRegAVM2Item lr = (LocalRegAVM2Item) value; - String slotNameStr = slotname.getName(localData.getConstants(), localData.fullyQualifiedNames, true); + String slotNameStr = slotname.getName(localData.getConstants(), localData.fullyQualifiedNames, true, true); if (localData.localRegNames.containsKey(lr.regIndex)) { if (localData.localRegNames.get(lr.regIndex).equals(slotNameStr)) { return; //Register with same name to slot @@ -179,7 +179,7 @@ public class SetSlotIns extends InstructionDefinition implements SetTypeIns { 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); + slotname = body.traits.traits.get(t).getName(abc).getName(abc.constants, fullyQualifiedNames, true, true); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java index 97a85c446..4d2ebec49 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java @@ -56,7 +56,7 @@ public class AsTypeIns extends InstructionDefinition { public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem val = stack.pop(); - stack.push(new AsTypeAVM2Item(ins, localData.lineStartInstruction, val, new FullMultinameAVM2Item(false, ins, localData.lineStartInstruction, ins.operands[0], localData.abc.constants.getMultiname(ins.operands[0]).getName(localData.getConstants(), new ArrayList<>(), true)))); + stack.push(new AsTypeAVM2Item(ins, localData.lineStartInstruction, val, new FullMultinameAVM2Item(false, ins, localData.lineStartInstruction, ins.operands[0], localData.abc.constants.getMultiname(ins.operands[0]).getName(localData.getConstants(), new ArrayList<>(), true, true)))); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java index b50019d7a..299425165 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java @@ -42,7 +42,7 @@ public class IsTypeIns extends InstructionDefinition { public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int multinameIndex = ins.operands[0]; GraphTargetItem value = stack.pop(); - stack.push(new IsTypeAVM2Item(ins, localData.lineStartInstruction, value, new FullMultinameAVM2Item(false, ins, localData.lineStartInstruction, multinameIndex, localData.abc.constants.getMultiname(multinameIndex).getName(localData.getConstants(), new ArrayList<>(), true)))); + stack.push(new IsTypeAVM2Item(ins, localData.lineStartInstruction, value, new FullMultinameAVM2Item(false, ins, localData.lineStartInstruction, multinameIndex, localData.abc.constants.getMultiname(multinameIndex).getName(localData.getConstants(), new ArrayList<>(), true, true)))); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ClassAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ClassAVM2Item.java index ab762c49b..d0e781b37 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ClassAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ClassAVM2Item.java @@ -37,7 +37,7 @@ public class ClassAVM2Item extends AVM2Item { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { - return writer.append(className.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false)); + return writer.append(className.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java index c0e12d4dc..2020ccfac 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java @@ -80,7 +80,7 @@ public class FullMultinameAVM2Item extends AVM2Item { if (name != null) { cname = name.toString(LocalData.create(constants, localRegNames, fullyQualifiedNames)); } else { - cname = (constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames, true)); + cname = (constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames, true, true)); } String cns = ""; if (namespace != null) { @@ -121,7 +121,7 @@ public class FullMultinameAVM2Item extends AVM2Item { AVM2ConstantPool constants = localData.constantsAvm2; List fullyQualifiedNames = property ? new ArrayList<>() : localData.fullyQualifiedNames; if (multinameIndex > 0 && multinameIndex < constants.getMultinameCount()) { - writer.append(constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames, false)); + writer.append(constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames, false, true)); } else { writer.append("§§multiname(").append(multinameIndex).append(")"); } 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 00c7516e6..dc49bdbf8 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 @@ -38,7 +38,7 @@ public class GetLexAVM2Item extends AVM2Item { public GetLexAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Multiname propertyName, AVM2ConstantPool constants) { super(instruction, lineStartIns, PRECEDENCE_PRIMARY); this.propertyName = propertyName; - this.fullPropertyName = propertyName.getNameWithNamespace(constants); + this.fullPropertyName = propertyName.getNameWithNamespace(constants, true); } public String getRawPropertyName() { @@ -47,9 +47,9 @@ public class GetLexAVM2Item extends AVM2Item { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { - String localName = propertyName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false); + String localName = propertyName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true); getSrcData().localName = localName; - return writer.append(propertyName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false)); + return writer.append(propertyName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java index e7fa4b1f2..801bbec63 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java @@ -46,18 +46,18 @@ public class GetSlotAVM2Item extends AVM2Item { } getSrcData().localName = getNameAsStr(localData); - return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false)); + return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true)); } public String getNameAsStr(LocalData localData) { - return slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false); + return slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true); } public GraphTextWriter getName(GraphTextWriter writer, LocalData localData) { if (slotName == null) { return writer.append("/*UnknownSlot*/"); } - return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false)); + return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/InitVectorAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/InitVectorAVM2Item.java index 6e77a22dd..3b0e065d5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/InitVectorAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/InitVectorAVM2Item.java @@ -42,17 +42,17 @@ import java.util.List; */ public class InitVectorAVM2Item extends AVM2Item { - public static final DottedChain VECTOR_PACKAGE = new DottedChain("__AS3__", "vec"); + public static final DottedChain VECTOR_PACKAGE = new DottedChain(new String[]{"__AS3__", "vec"}, ""); - public static final DottedChain VECTOR_FQN = new DottedChain("__AS3__", "vec", "Vector"); + public static final DottedChain VECTOR_FQN = new DottedChain(new String[]{"__AS3__", "vec", "Vector"}, ""); - public static final DottedChain VECTOR_INT = new DottedChain("__AS3__", "vec", "Vector$int"); + public static final DottedChain VECTOR_INT = new DottedChain(new String[]{"__AS3__", "vec", "Vector$int"}, ""); - public static final DottedChain VECTOR_DOUBLE = new DottedChain("__AS3__", "vec", "Vector$double"); + public static final DottedChain VECTOR_DOUBLE = new DottedChain(new String[]{"__AS3__", "vec", "Vector$double"}, ""); - public static final DottedChain VECTOR_UINT = new DottedChain("__AS3__", "vec", "Vector$uint"); + public static final DottedChain VECTOR_UINT = new DottedChain(new String[]{"__AS3__", "vec", "Vector$uint"}, ""); - public static final DottedChain VECTOR_OBJECT = new DottedChain("__AS3__", "vec", "Vector$object"); + public static final DottedChain VECTOR_OBJECT = new DottedChain(new String[]{"__AS3__", "vec", "Vector$object"}, ""); public GraphTargetItem subtype; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java index da45cc47c..006395145 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java @@ -61,7 +61,7 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { - getSrcData().localName = slotName == null ? "/*UnknownSlot*/" : slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false); + getSrcData().localName = slotName == null ? "/*UnknownSlot*/" : slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true); if (getSrcData().localName.equals(value.toString(localData))) { //assigning parameters to activation reg return writer; @@ -75,14 +75,14 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign } public String getNameAsStr(LocalData localData) { - return slotName == null ? "/*UnknownSlot*/" : slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false); + return slotName == null ? "/*UnknownSlot*/" : slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true); } public GraphTextWriter getName(GraphTextWriter writer, LocalData localData) { if (slotName == null) { return writer.append("/*UnknownSlot*/"); } - return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false)); + return writer.append(slotName.getName(localData.constantsAvm2, localData.fullyQualifiedNames, false, true)); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java index 89bff8a6f..8136f0e18 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java @@ -97,7 +97,7 @@ public class TryAVM2Item extends AVM2Item implements Block { int eti = catchExceptions.get(e).type_index; - data.declaredType = eti <= 0 ? DottedChain.ALL : localData.constantsAvm2.getMultiname(eti).getNameWithNamespace(localData.constantsAvm2); + data.declaredType = eti <= 0 ? DottedChain.ALL : localData.constantsAvm2.getMultiname(eti).getNameWithNamespace(localData.constantsAvm2, true); writer.hilightSpecial(localName, HighlightSpecialType.TRY_NAME, e, data); writer.append(":"); writer.hilightSpecial(catchExceptions.get(e).getTypeName(localData.constantsAvm2, localData.fullyQualifiedNames), HighlightSpecialType.TRY_TYPE, e); 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 3afe103d9..5e700b90f 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 @@ -1244,7 +1244,7 @@ public class AVM2SourceGenerator implements SourceGenerator { if (t instanceof TraitSlotConst) { TraitSlotConst tsc = (TraitSlotConst) t; if (tsc.kindType == Trait.TRAIT_SLOT) { - if ("_skinParts".equals(tsc.getName(ci.abc).getName(ci.abc.constants, new ArrayList<>(), true))) { + if ("_skinParts".equals(tsc.getName(ci.abc).getName(ci.abc.constants, new ArrayList<>(), true, true))) { if (d.assignedValues.containsKey(tsc)) { if (d.assignedValues.get(tsc).value instanceof NewObjectAVM2Item) { NewObjectAVM2Item no = (NewObjectAVM2Item) d.assignedValues.get(tsc).value; @@ -1270,7 +1270,7 @@ public class AVM2SourceGenerator implements SourceGenerator { } */ List getterBody = new ArrayList<>(); - UnresolvedAVM2Item sp = new UnresolvedAVM2Item(new ArrayList<>(), importedClasses, false, TypeItem.UNBOUNDED, 0, new DottedChain("_skinParts"), + UnresolvedAVM2Item sp = new UnresolvedAVM2Item(new ArrayList<>(), importedClasses, false, TypeItem.UNBOUNDED, 0, new DottedChain(new String[]{"_skinParts"}, ""), null, openedNamespaces); getterBody.add(new ReturnValueAVM2Item(null, null, sp)); List subvars = new ArrayList<>(); @@ -1577,7 +1577,7 @@ public class AVM2SourceGenerator implements SourceGenerator { List registerLines = new ArrayList<>(); List registerTypes = new ArrayList<>(); if (className != null) { - String fullClassName = pkg.add(className).toRawString(); + String fullClassName = pkg.addWithSuffix(className).toRawString(); registerTypes.add(fullClassName); localData.scopeStack.add(new LocalRegAVM2Item(null, null, registerNames.size(), null)); registerNames.add("this"); @@ -1831,9 +1831,9 @@ public class AVM2SourceGenerator implements SourceGenerator { TraitSlotConst tsc = (TraitSlotConst) mbody.traits.traits.get(i); GraphTargetItem type = TypeItem.UNBOUNDED; if (tsc.type_index > 0) { - type = new TypeItem(abcIndex.getSelectedAbc().constants.getMultiname(tsc.type_index).getNameWithNamespace(abcIndex.getSelectedAbc().constants)); + type = new TypeItem(abcIndex.getSelectedAbc().constants.getMultiname(tsc.type_index).getNameWithNamespace(abcIndex.getSelectedAbc().constants, true)); } - NameAVM2Item d = new NameAVM2Item(type, 0, tsc.getName(abcIndex.getSelectedAbc()).getName(abcIndex.getSelectedAbc().constants, null, true), NameAVM2Item.getDefaultValue("" + type), true, new ArrayList<>()); + NameAVM2Item d = new NameAVM2Item(type, 0, tsc.getName(abcIndex.getSelectedAbc()).getName(abcIndex.getSelectedAbc().constants, null, true, true), NameAVM2Item.getDefaultValue("" + type), true, new ArrayList<>()); d.setSlotNumber(tsc.slot_id); d.setSlotScope(slotScope); mbodyCode.addAll(0, toInsList(d.toSourceIgnoreReturnValue(localData, this))); @@ -2452,7 +2452,7 @@ public class AVM2SourceGenerator implements SourceGenerator { indices.add( abc.getSelectedAbc().constants.getMultinameId( Multiname.createQName(false, - abc.getSelectedAbc().constants.getStringId(superName.getName(a.constants, null, true), true), + abc.getSelectedAbc().constants.getStringId(superName.getName(a.constants, null, true, true /*FIXME!!! ???*/), true), abc.getSelectedAbc().constants.getNamespaceId(superName.getNamespace(a.constants).kind, superName.getNamespace(a.constants).getName(a.constants), 0, true)), true) ); } @@ -2503,9 +2503,9 @@ public class AVM2SourceGenerator implements SourceGenerator { 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) { - AbcIndexing.TraitIndex sp = abc.findScriptProperty(pkg.add(propertyName)); + AbcIndexing.TraitIndex sp = abc.findScriptProperty(pkg.addWithSuffix(propertyName)); if (sp == null) { - sp = abc.findProperty(new AbcIndexing.PropertyDef(propertyName, new TypeItem(pkg.add(obj)), abc.getSelectedAbc(), selectedNs), !instanceOnly, true); + sp = abc.findProperty(new AbcIndexing.PropertyDef(propertyName, new TypeItem(pkg.addWithSuffix(obj)), abc.getSelectedAbc(), selectedNs), !instanceOnly, true); } if (sp != null) { if (sp.objType instanceof TypeItem) { @@ -2527,12 +2527,12 @@ public class AVM2SourceGenerator implements SourceGenerator { } public static void parentNames(AbcIndexing abc, int name_index, List indices, List names, List namespaces, List outABCs) { - AbcIndexing.ClassIndex ci = abc.findClass(new TypeItem(abc.getSelectedAbc().constants.getMultiname(name_index).getNameWithNamespace(abc.getSelectedAbc().constants))); + AbcIndexing.ClassIndex ci = abc.findClass(new TypeItem(abc.getSelectedAbc().constants.getMultiname(name_index).getNameWithNamespace(abc.getSelectedAbc().constants, true /*FIXME!!*/))); while (ci != null) { int ni = ci.abc.instance_info.get(ci.index).name_index; indices.add(ni); outABCs.add(ci.abc); - names.add(ci.abc.constants.getMultiname(ni).getName(ci.abc.constants, null, true)); + names.add(ci.abc.constants.getMultiname(ni).getName(ci.abc.constants, null, true, true/*FIXME!!*/)); namespaces.add(ci.abc.constants.getMultiname(ni).getNamespace(ci.abc.constants).getName(ci.abc.constants).toRawString()); ci = ci.parent; } @@ -2627,7 +2627,7 @@ public class AVM2SourceGenerator implements SourceGenerator { Multiname m = ci.abc.instance_info.get(ci.index).getName(ci.abc.constants); if (m != null) { Namespace ns = ci.abc.instance_info.get(ci.index).getName(ci.abc.constants).getNamespace(ci.abc.constants); - String n = m.getName(ci.abc.constants, new ArrayList<>(), true); + String n = m.getName(ci.abc.constants, new ArrayList<>(), true, true /*FIXME!!*/); String nsn = ns == null ? null : ns.getName(ci.abc.constants).toRawString(); name_index = constants.getQnameId( n, @@ -2638,7 +2638,7 @@ public class AVM2SourceGenerator implements SourceGenerator { for (int i = 1; i < constants.getMultinameCount(); i++) { Multiname mname = constants.getMultiname(i); - if (mname != null && name.equals(mname.getName(constants, null, true))) { + if (mname != null && name.equals(mname.getName(constants, null, true, true /*FIXME!!*/))) { if (mname.getNamespace(constants) != null && pkg.equals(mname.getNamespace(constants).getName(constants))) { name_index = i; break; @@ -2648,7 +2648,7 @@ public class AVM2SourceGenerator implements SourceGenerator { if (name_index == 0) { if (pkg.isEmpty() && localData.currentScript != null /*FIXME!*/) { for (Trait t : localData.currentScript.traits.traits) { - if (t.getName(abc).getName(constants, null, true).equals(name)) { + if (t.getName(abc).getName(constants, null, true, true /*FIXME!!*/).equals(name)) { name_index = t.name_index; break; } 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 d691e4cf4..e039e9a17 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 @@ -278,7 +278,7 @@ public final class AbcIndexing { @Override public String toString() { - return abc.constants.getMultiname(abc.instance_info.get(index).name_index).getNameWithNamespace(abc.constants).toPrintableString(true); + return abc.constants.getMultiname(abc.instance_info.get(index).name_index).getNameWithNamespace(abc.constants, true).toPrintableString(true); } public ClassIndex(int index, ABC abc, ClassIndex parent) { @@ -389,7 +389,7 @@ public final class AbcIndexing { if (ci != null && ci.parent != null && (prop.abc == null || prop.propNsIndex == 0)) { ci = ci.parent; //parent protected - DottedChain parentClass = ci.abc.instance_info.get(ci.index).getName(ci.abc.constants).getNameWithNamespace(ci.abc.constants); + DottedChain parentClass = ci.abc.instance_info.get(ci.index).getName(ci.abc.constants).getNameWithNamespace(ci.abc.constants, true); TraitIndex pti = findProperty(new PropertyDef(prop.propName, new TypeItem(parentClass), ci.abc, ci.abc.instance_info.get(ci.index).protectedNS), findStatic, findInstance); if (pti != null) { return pti; @@ -414,7 +414,7 @@ public final class AbcIndexing { } return new ApplyTypeAVM2Item(null, null, obj, params); } else { - return new TypeItem(m.getNameWithNamespace(constants)); + return new TypeItem(m.getNameWithNamespace(constants, true)); } } @@ -453,12 +453,12 @@ 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), 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, true /*FIXME ???*/), 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) { Multiname m = abc.constants.getMultiname(t.name_index); - PropertyNsDef ndp = new PropertyNsDef(t.getName(abc).getName(abc.constants, new ArrayList<>() /*?*/, true), m == null || m.namespace_index == 0 ? DottedChain.EMPTY : m.getNamespace(abc.constants).getName(abc.constants), abc, m == null ? 0 : m.namespace_index); + PropertyNsDef ndp = new PropertyNsDef(t.getName(abc).getName(abc.constants, new ArrayList<>() /*?*/, true, true/*FIXME ???*/), m == null || m.namespace_index == 0 ? DottedChain.EMPTY : m.getNamespace(abc.constants).getName(abc.constants), abc, m == null ? 0 : m.namespace_index); TraitIndex ti = new TraitIndex(t, abc, getTraitReturnType(abc, t), propValue, multinameToType(name_index, abc.constants)); if (!mapNs.containsKey(ndp)) { mapNs.put(ndp, ti); @@ -552,7 +552,7 @@ public final class AbcIndexing { for (ClassIndex cindex : addedClasses) { int parentClassName = abc.instance_info.get(cindex.index).super_index; if (parentClassName > 0) { - TypeItem parentClass = new TypeItem(abc.constants.getMultiname(parentClassName).getNameWithNamespace(abc.constants)); + TypeItem parentClass = new TypeItem(abc.constants.getMultiname(parentClassName).getNameWithNamespace(abc.constants, true)); ClassIndex parentClassIndex = findClass(parentClass); if (parentClassIndex == null) { //Parent class can be deleted, do not check. TODO: handle this better 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 4001a5606..d3d4d237c 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 @@ -304,7 +304,7 @@ public class ActionScript3Parser { s = lex(); GraphTargetItem ns = null; if (s.type == SymbolType.NAMESPACE_OP) { - ns = new UnresolvedAVM2Item(new ArrayList<>(), importedClasses, false, null, lexer.yyline(), new DottedChain(propName), null, openedNamespaces); + ns = new UnresolvedAVM2Item(new ArrayList<>(), importedClasses, false, null, lexer.yyline(), new DottedChain(new String[]{propName}, "" /*FIXME ???*/), null, openedNamespaces); variables.add((UnresolvedAVM2Item) ns); s = lex(); if (s.type == SymbolType.BRACKET_OPEN) { @@ -337,7 +337,7 @@ public class ActionScript3Parser { private GraphTargetItem name(List> allOpenedNamespaces, TypeItem thisType, NamespaceItem pkg, Reference needsActivation, boolean typeOnly, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, List variables, List importedClasses) throws IOException, AVM2ParseException { ParsedSymbol s = lex(); - DottedChain name = new DottedChain(); + DottedChain name = new DottedChain(new String[]{}, ""); String name2 = ""; if (s.type == SymbolType.ATTRIBUTE) { name2 += "@"; @@ -348,7 +348,7 @@ public class ActionScript3Parser { s = lex(); boolean attrBracket = false; - name = name.add(name2); + name = name.addWithSuffix(name2); while (s.isType(SymbolType.DOT)) { //name += s.value.toString(); //. or :: s = lex(); @@ -371,7 +371,7 @@ public class ActionScript3Parser { expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.NAMESPACE, SymbolType.MULTIPLY); name2 += s.value.toString(); } - name = name.add(name2); + name = name.addWithSuffix(name2); s = lex(); } String nsname = null; @@ -402,7 +402,7 @@ public class ActionScript3Parser { if (attr) { nsname = nsname.substring(1); } - UnresolvedAVM2Item ns = new UnresolvedAVM2Item(new ArrayList<>(), importedClasses, typeOnly, null, lexer.yyline(), new DottedChain(nsname), null, openedNamespaces); + UnresolvedAVM2Item ns = new UnresolvedAVM2Item(new ArrayList<>(), importedClasses, typeOnly, null, lexer.yyline(), new DottedChain(new String[]{nsname}, ""), null, openedNamespaces); variables.add(ns); ret = new NamespacedAVM2Item(ns, nsprop, nspropItem, ret, attr, openedNamespaces, null); } @@ -618,7 +618,7 @@ public class ActionScript3Parser { looptraits: while (true) { - TypeItem thisType = new TypeItem(pkg.name.add(classNameStr)); + TypeItem thisType = new TypeItem(pkg.name.addWithSuffix(classNameStr)); boolean isGetter = false; boolean isSetter = false; boolean isOverride = false; @@ -884,13 +884,13 @@ public class ActionScript3Parser { s = lex(); if (s.type != SymbolType.CURLY_OPEN) { expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER); - pkgName = pkgName.add(s.value.toString()); + pkgName = pkgName.addWithSuffix(s.value.toString()); s = lex(); } while (s.type == SymbolType.DOT) { s = lex(); expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER); - pkgName = pkgName.add(s.value.toString()); + pkgName = pkgName.addWithSuffix(s.value.toString()); s = lex(); } expected(s, lexer.yyline(), SymbolType.CURLY_OPEN); @@ -1744,7 +1744,7 @@ public class ActionScript3Parser { for (AssignableAVM2Item a : catchVars) { if (a instanceof UnresolvedAVM2Item) { UnresolvedAVM2Item ui = (UnresolvedAVM2Item) a; - if (ui.getVariableName().equals(DottedChain.parse(e.getVariableName()))) { + if (ui.getVariableName().equals(DottedChain.parseWithSuffix(e.getVariableName()))) { try { ui.resolve(null, new ArrayList<>(), new ArrayList<>(), abcIndex, new ArrayList<>(), variables); } catch (CompilationException ex) { @@ -1767,7 +1767,7 @@ public class ActionScript3Parser { if (av instanceof UnresolvedAVM2Item) { UnresolvedAVM2Item ui = (UnresolvedAVM2Item) av; for (NameAVM2Item e : catchExceptions) { - if (ui.getVariableName().equals(DottedChain.parse(e.getVariableName()))) { + if (ui.getVariableName().equals(DottedChain.parseWithSuffix(e.getVariableName()))) { try { ui.resolve(null, new ArrayList<>(), new ArrayList<>(), abcIndex, new ArrayList<>(), variables); } catch (CompilationException ex) { @@ -2486,8 +2486,8 @@ public class ActionScript3Parser { } s = lex(); expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER); - DottedChain fullName = new DottedChain(); - fullName = fullName.add(s.value.toString()); + DottedChain fullName = new DottedChain(new String[]{}, ""); + fullName = fullName.addWithSuffix(s.value.toString()); s = lex(); boolean isStar = false; while (s.type == SymbolType.DOT) { @@ -2499,7 +2499,7 @@ public class ActionScript3Parser { break; } expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER); - fullName = fullName.add(s.value.toString()); + fullName = fullName.addWithSuffix(s.value.toString()); s = lex(); } 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 b9c215802..c7fac0d57 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 @@ -134,7 +134,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().add(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) && (localData.getFullClass().equals(outNs.getVal().addWithSuffix(outName.getVal()).toRawString()))) { NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.getFullClass()), 0, "this", null, false, new ArrayList<>()); nobj.setRegNumber(0); obj = nobj; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstructSomethingAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstructSomethingAVM2Item.java index 7a731466e..7573154ef 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstructSomethingAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstructSomethingAVM2Item.java @@ -65,7 +65,7 @@ public class ConstructSomethingAVM2Item extends CallAVM2Item { if (resname instanceof TypeItem) { TypeItem prop = (TypeItem) resname; - if (localData.isStatic && localData.pkg.add(localData.currentClass).equals(prop.fullTypeName)) { + if (localData.isStatic && localData.pkg.addWithSuffix(localData.currentClass).equals(prop.fullTypeName)) { return toSourceMerge(localData, generator, new AVM2Instruction(0, AVM2Instructions.GetLocal0, new int[]{}), arguments, new AVM2Instruction(0, AVM2Instructions.Construct, new int[]{arguments.size()})); 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 67f19c014..c4f320a4c 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 @@ -49,7 +49,7 @@ public class NamespaceItem { } public NamespaceItem(String name, int kind) { - this.name = DottedChain.parse(name); + this.name = DottedChain.parseWithSuffix(name); this.kind = kind; } 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 0bbd9bd49..22755433a 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 @@ -119,7 +119,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { } return new ApplyTypeAVM2Item(null, null, obj, params); } else { - return new TypeItem(m.getNameWithNamespace(constants)); + return new TypeItem(m.getNameWithNamespace(constants, true)); } } @@ -245,7 +245,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { } } if (AVM2SourceGenerator.searchPrototypeChain(otherNs, localData.privateNs, localData.protectedNs, false, abcIndex, ftn.getWithoutLast(), ftn.getLast(), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue, outPropValueAbc)) { - objType = new TypeItem(outNs.getVal().add(outName.getVal())); + objType = new TypeItem(outNs.getVal().addWithSuffix(outName.getVal())); propType = outPropType.getVal(); propIndex = constants.getMultinameId(Multiname.createQName(false, constants.getStringId(propertyName, true), @@ -260,7 +260,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { for (MethodBody b : callStack) { for (int i = 0; i < b.traits.traits.size(); i++) { Trait t = b.traits.traits.get(i); - if (t.getName(abc).getName(constants, null, true).equals(propertyName)) { + if (t.getName(abc).getName(constants, null, true, true).equals(propertyName)) { if (t instanceof TraitSlotConst) { TraitSlotConst tsc = (TraitSlotConst) t; objType = new TypeItem(DottedChain.FUNCTION); @@ -287,7 +287,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { int name_index = 0; for (int m = 1; m < constants.getMultinameCount(); m++) { Multiname mname = constants.getMultiname(m); - if (mname.kind == Multiname.QNAME && mname.getName(constants, null, true).equals(propertyName) && mname.namespace_index == nsindex) { + if (mname.kind == Multiname.QNAME && mname.getName(constants, null, true, true).equals(propertyName) && mname.namespace_index == nsindex) { name_index = m; break; } @@ -363,7 +363,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { } } 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)) { - objType = new TypeItem(outNs.getVal().add(outName.getVal())); + objType = new TypeItem(outNs.getVal().addWithSuffix(outName.getVal())); propType = p.returnType; propIndex = constants.getMultinameId(Multiname.createQName(false, constants.getStringId(propertyName, true), @@ -683,7 +683,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().add(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) && (localData.getFullClass().equals(outNs.getVal().addWithSuffix(outName.getVal()).toRawString()))) { NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.getFullClass()), 0, "this", null, false, openedNamespaces); nobj.setRegNumber(0); obj = nobj; 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 83ee345a5..3c83c9879 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 @@ -123,7 +123,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { } */ public void appendName(String name) { - this.name = this.name.add(name); + this.name = this.name.addWithSuffix(name); } public void setDefinition(boolean definition) { @@ -354,7 +354,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { //Search for types in opened namespaces for (NamespaceItem n : openedNamespaces) { Namespace ons = abc.getSelectedAbc().constants.getNamespace(n.getCpoolIndex(abc)); - TypeItem ti = new TypeItem(ons.getName(abc.getSelectedAbc().constants).add(name.get(0))); + TypeItem ti = new TypeItem(ons.getName(abc.getSelectedAbc().constants).addWithSuffix(name.get(0))); AbcIndexing.ClassIndex ci = abc.findClass(ti); if (ci != null) { if (!subtypes.isEmpty() && name.size() > 1) { @@ -393,7 +393,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { if (ci == null) { ntype = new TypeItem("Object"); } else { - ntype = new TypeItem(ci.abc.instance_info.get(ci.index).getName(ci.abc.constants).getNameWithNamespace(ci.abc.constants)); + ntype = new TypeItem(ci.abc.instance_info.get(ci.index).getName(ci.abc.constants).getNameWithNamespace(ci.abc.constants, true)); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ABCException.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ABCException.java index 4d83a14eb..5d21b1ecf 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ABCException.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ABCException.java @@ -65,14 +65,14 @@ public class ABCException implements Serializable, Cloneable { if (name_index == 0) { return ""; } - return constants.getMultiname(name_index).getName(constants, fullyQualifiedNames, false); + return constants.getMultiname(name_index).getName(constants, fullyQualifiedNames, false, true); } public String getTypeName(AVM2ConstantPool constants, List fullyQualifiedNames) { if (type_index == 0) { return "*"; } - return constants.getMultiname(type_index).getName(constants, fullyQualifiedNames, false); + return constants.getMultiname(type_index).getName(constants, fullyQualifiedNames, false, true); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java index 4a637b1a5..7f151cf0e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java @@ -103,11 +103,11 @@ public class InstanceInfo { } writer.appendNoHilight(modifiers + objType); - writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, null/* No full names here*/, false), HighlightSpecialType.CLASS_NAME); + writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, null/* No full names here*/, false, true), HighlightSpecialType.CLASS_NAME); if (super_index > 0) { - String typeName = abc.constants.getMultiname(super_index).getNameWithNamespace(abc.constants).toRawString(); - String parentName = abc.constants.getMultiname(super_index).getName(abc.constants, fullyQualifiedNames, false); + String typeName = abc.constants.getMultiname(super_index).getNameWithNamespace(abc.constants, true).toRawString(); + String parentName = abc.constants.getMultiname(super_index).getName(abc.constants, fullyQualifiedNames, false, true); if (!parentName.equals("Object")) { writer.appendNoHilight(" extends "); writer.hilightSpecial(parentName, HighlightSpecialType.TYPE_NAME, typeName); @@ -123,8 +123,8 @@ public class InstanceInfo { if (i > 0) { writer.append(", "); } - String typeName = abc.constants.getMultiname(interfaces[i]).getNameWithNamespace(abc.constants).toRawString(); - writer.hilightSpecial(abc.constants.getMultiname(interfaces[i]).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TYPE_NAME, typeName); + String typeName = abc.constants.getMultiname(interfaces[i]).getNameWithNamespace(abc.constants, true).toRawString(); + writer.hilightSpecial(abc.constants.getMultiname(interfaces[i]).getName(abc.constants, fullyQualifiedNames, false, true), HighlightSpecialType.TYPE_NAME, typeName); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java index 20f504f49..ef5c195ef 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java @@ -319,7 +319,7 @@ public class MethodInfo { } DottedChain ptype = DottedChain.ALL; if (param_types[i] > 0) { - ptype = constants.getMultiname(param_types[i]).getNameWithNamespace(constants); + ptype = constants.getMultiname(param_types[i]).getNameWithNamespace(constants, true); } HighlightData pdata = new HighlightData(); @@ -340,7 +340,7 @@ public class MethodInfo { if (param_types[i] == 0) { writer.hilightSpecial("*", HighlightSpecialType.PARAM, i); } else { - writer.hilightSpecial(constants.getMultiname(param_types[i]).getName(constants, fullyQualifiedNames, false), HighlightSpecialType.PARAM, i); + writer.hilightSpecial(constants.getMultiname(param_types[i]).getName(constants, fullyQualifiedNames, false, true), HighlightSpecialType.PARAM, i); } if (optional != null) { if (i >= param_types.length - optional.length) { @@ -381,7 +381,7 @@ public class MethodInfo { if (multiname.kind != Multiname.TYPENAME && multiname.name_index > 0 && constants.getString(multiname.name_index).equals("void")) { rname = "void"; } else { - rname = multiname.getName(constants, fullyQualifiedNames, false); + rname = multiname.getName(constants, fullyQualifiedNames, false, true); } } return writer.hilightSpecial(rname, HighlightSpecialType.RETURNS); @@ -394,7 +394,7 @@ public class MethodInfo { if (multiname.kind != Multiname.TYPENAME && multiname.name_index > 0 && constants.getString(multiname.name_index).equals("void")) { rname = "void"; } else { - rname = multiname.getName(constants, fullyQualifiedNames, false); + rname = multiname.getName(constants, fullyQualifiedNames, false, true); } } return rname; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Multiname.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Multiname.java index af4a6bd0c..ff8f261ec 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Multiname.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Multiname.java @@ -76,6 +76,13 @@ public class Multiname { @Internal private boolean displayNamespace = false; + public String getNamespaceSuffix() { + if (displayNamespace) { + return "#" + namespace_index; + } + return ""; + } + public void setDisplayNamespace(boolean displayNamespace) { this.displayNamespace = displayNamespace; } @@ -307,12 +314,12 @@ public class Multiname { return null; } - private String typeNameToStr(AVM2ConstantPool constants, List fullyQualifiedNames, boolean raw) { + private String typeNameToStr(AVM2ConstantPool constants, List fullyQualifiedNames, boolean dontDeobfuscate, boolean withSuffix) { if (constants.getMultiname(qname_index).name_index == name_index) { return "ambiguousTypeName"; } StringBuilder typeNameStr = new StringBuilder(); - typeNameStr.append(constants.getMultiname(qname_index).getName(constants, fullyQualifiedNames, raw)); + typeNameStr.append(constants.getMultiname(qname_index).getName(constants, fullyQualifiedNames, dontDeobfuscate, withSuffix)); if (params != null && params.length > 0) { typeNameStr.append(".<"); for (int i = 0; i < params.length; i++) { @@ -323,7 +330,7 @@ public class Multiname { if (param == 0) { typeNameStr.append("*"); } else { - typeNameStr.append(constants.getMultiname(param).getName(constants, fullyQualifiedNames, raw)); + typeNameStr.append(constants.getMultiname(param).getName(constants, fullyQualifiedNames, dontDeobfuscate, withSuffix)); } } typeNameStr.append(">"); @@ -331,9 +338,9 @@ public class Multiname { return typeNameStr.toString(); } - public String getName(AVM2ConstantPool constants, List fullyQualifiedNames, boolean raw) { + public String getName(AVM2ConstantPool constants, List fullyQualifiedNames, boolean dontDeobfuscate, boolean withSuffix) { if (kind == TYPENAME) { - return typeNameToStr(constants, fullyQualifiedNames, raw); + return typeNameToStr(constants, fullyQualifiedNames, dontDeobfuscate, withSuffix); } if (name_index == -1) { return ""; @@ -342,19 +349,15 @@ public class Multiname { return isAttribute() ? "@*" : "*"; } else { String name = constants.getString(name_index); - String nssuffix = ""; - if (displayNamespace) { - nssuffix += "#" + namespace_index; + if (fullyQualifiedNames != null && fullyQualifiedNames.contains(DottedChain.parseWithSuffix(name))) { + DottedChain dc = getNameWithNamespace(constants, withSuffix); + return dontDeobfuscate ? dc.toRawString() : dc.toPrintableString(true); } - if (fullyQualifiedNames != null && fullyQualifiedNames.contains(DottedChain.parse(name))) { - DottedChain dc = getNameWithNamespace(constants); - return raw ? dc.toRawString() : dc.toPrintableString(true); - } - return (isAttribute() ? "@" : "") + (raw ? name : IdentifiersDeobfuscation.printIdentifier(true, name) + nssuffix); + return (isAttribute() ? "@" : "") + (dontDeobfuscate ? name : IdentifiersDeobfuscation.printIdentifier(true, name)) + (withSuffix ? getNamespaceSuffix() : ""); } } - public DottedChain getNameWithNamespace(AVM2ConstantPool constants) { + public DottedChain getNameWithNamespace(AVM2ConstantPool constants, boolean withSuffix) { Namespace ns = getNamespace(constants); if (ns == null) { NamespaceSet nss = getNamespaceSet(constants); @@ -364,11 +367,11 @@ public class Multiname { } } } - String name = getName(constants, null, true); + String name = getName(constants, null, false, false); if (ns != null) { - return ns.getName(constants).add(name); + return ns.getName(constants).add(name, withSuffix ? getNamespaceSuffix() : ""); } - return new DottedChain(name); + return new DottedChain(new String[]{name}, withSuffix ? getNamespaceSuffix() : ""); } public Namespace getNamespace(AVM2ConstantPool constants) { @@ -492,7 +495,7 @@ public class Multiname { return false; } - if (!Objects.equals(other.getName(otherCpool, new ArrayList<>(), true), getName(thisCpool, new ArrayList<>(), true))) { + if (!Objects.equals(other.getName(otherCpool, new ArrayList<>(), true, true), getName(thisCpool, new ArrayList<>(), true, true))) { return false; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java index 7bacebf5d..0f06dd6d8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java @@ -78,7 +78,8 @@ public class ScriptInfo { if ((ns.kind == Namespace.KIND_PACKAGE_INTERNAL) || (ns.kind == Namespace.KIND_PACKAGE)) { DottedChain packageName = ns.getName(abc.constants); // assume not null package - String objectName = name.getName(abc.constants, null, true); + String objectName = name.getName(abc.constants, null, true, false); + String namespaceSuffix = name.getNamespaceSuffix(); List traitIndices = new ArrayList<>(); traitIndices.add(j); @@ -88,7 +89,7 @@ public class ScriptInfo { } if (packagePrefix == null || packageName.toPrintableString(true).startsWith(packagePrefix)) { - ClassPath cp = new ClassPath(packageName, objectName); + ClassPath cp = new ClassPath(packageName, objectName, namespaceSuffix); ret.add(new ScriptPack(cp, abc, allAbcs, scriptIndex, traitIndices)); } } @@ -96,6 +97,24 @@ public class ScriptInfo { if (ret.size() == 1) { ret.get(0).isSimple = true; } + if (ret.isEmpty() && !otherTraits.isEmpty()) { //no public/package internal traits to determine common pack name + //make each trait separate pack + for (int traitIndex : otherTraits) { + Trait t = traits.traits.get(traitIndex); + Multiname name = t.getName(abc); + Namespace ns = name.getNamespace(abc.constants); + + DottedChain packageName = ns.getName(abc.constants); + String objectName = name.getName(abc.constants, null, true, false); + String namespaceSuffix = name.getNamespaceSuffix(); + + List traitIndices = new ArrayList<>(); + + traitIndices.add(traitIndex); + ClassPath cp = new ClassPath(packageName, objectName, namespaceSuffix); + ret.add(new ScriptPack(cp, abc, allAbcs, scriptIndex, traitIndices)); + } + } return ret; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java index 0406b3c87..93b5d6876 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java @@ -118,11 +118,11 @@ public abstract class Trait implements Cloneable, Serializable { public var attr2; */ if (parent instanceof TraitClass) { - String thisName = getName(abc).getName(abc.constants, new ArrayList<>(), true); + String thisName = getName(abc).getName(abc.constants, new ArrayList<>(), true, true); List classTraits = abc.class_info.get(((TraitClass) parent).class_info).static_traits.traits; for (Trait t : classTraits) { if (t.kindType == Trait.TRAIT_SLOT) { - if ("_skinParts".equals(t.getName(abc).getName(abc.constants, new ArrayList<>(), true))) { + if ("_skinParts".equals(t.getName(abc).getName(abc.constants, new ArrayList<>(), true, true))) { if (t.getName(abc).getNamespace(abc.constants).kind == Namespace.KIND_PRIVATE) { if (convertData.assignedValues.containsKey(t)) { if (convertData.assignedValues.get(t).value instanceof NewObjectAVM2Item) { @@ -233,7 +233,7 @@ public abstract class Trait implements Cloneable, Serializable { if (importnames.contains(name)) { imports.remove(i); i--; - fullyQualifiedNames.add(new DottedChain(name)); + fullyQualifiedNames.add(DottedChain.parseWithSuffix(name)); } else { importnames.add(name); } @@ -246,7 +246,7 @@ public abstract class Trait implements Cloneable, Serializable { if (name.equals("*")) { continue; } - DottedChain dAll = pkg.add("*"); + DottedChain dAll = pkg.addWithSuffix("*"); if (imports.contains(dAll)) { imports.remove(i); i--; @@ -491,8 +491,9 @@ public abstract class Trait implements Cloneable, Serializable { Multiname name = getName(abc); Namespace ns = name.getNamespace(abc.constants); DottedChain packageName = ns == null ? DottedChain.EMPTY : ns.getName(abc.constants); - String objectName = name.getName(abc.constants, null, true); - return new ClassPath(packageName, objectName); //assume not null name + String objectName = name.getName(abc.constants, null, true, false); + String namespaceSuffix = name.getNamespaceSuffix(); + return new ClassPath(packageName, objectName, namespaceSuffix); //assume not null name } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index 1dfcd5649..5d9afa2bb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -114,7 +114,7 @@ public class TraitClass extends Trait implements TraitWithSlot { fullyQualifiedNames = new ArrayList<>(); writeImportsUsages(abc, writer, packageName, fullyQualifiedNames); - String instanceInfoName = instanceInfoMultiname.getName(abc.constants, fullyQualifiedNames, false); + String instanceInfoName = instanceInfoMultiname.getName(abc.constants, fullyQualifiedNames, false, true); writer.startClass(class_info); @@ -175,7 +175,7 @@ public class TraitClass extends Trait implements TraitWithSlot { writer.startMethod(instanceInfo.iinit_index); writer.appendNoHilight(modifier); writer.appendNoHilight("function "); - writer.appendNoHilight(m.getName(abc.constants, null/*do not want full names here*/, false)); + writer.appendNoHilight(m.getName(abc.constants, null/*do not want full names here*/, false, true)); writer.appendNoHilight("("); bodyIndex = abc.findBodyIndex(instanceInfo.iinit_index); MethodBody body = bodyIndex == -1 ? null : abc.bodies.get(bodyIndex); @@ -210,12 +210,12 @@ public class TraitClass extends Trait implements TraitWithSlot { fullyQualifiedNames = new ArrayList<>(); InstanceInfo instanceInfo = abc.instance_info.get(class_info); - String instanceInfoName = instanceInfo.getName(abc.constants).getName(abc.constants, fullyQualifiedNames, false); + String instanceInfoName = instanceInfo.getName(abc.constants).getName(abc.constants, fullyQualifiedNames, false, true); ClassInfo classInfo = abc.class_info.get(class_info); AbcIndexing index = new AbcIndexing(abc.getSwf()); //for simplification of String(this) - convertData.thisHasDefaultToPrimitive = null == index.findProperty(new AbcIndexing.PropertyDef("toString", new TypeItem(instanceInfo.getName(abc.constants).getNameWithNamespace(abc.constants)), abc, abc.constants.getNamespaceId(Namespace.KIND_PACKAGE, DottedChain.TOPLEVEL, abc.constants.getStringId("", true), true)), false, true); + convertData.thisHasDefaultToPrimitive = null == index.findProperty(new AbcIndexing.PropertyDef("toString", new TypeItem(instanceInfo.getName(abc.constants).getNameWithNamespace(abc.constants, true)), abc, abc.constants.getNamespaceId(Namespace.KIND_PACKAGE, DottedChain.TOPLEVEL, abc.constants.getStringId("", true), true)), false, true); //class initializer int bodyIndex = abc.findBodyIndex(classInfo.cinit_index); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java index 41b0b73f4..dcb80e1e1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java @@ -65,7 +65,7 @@ public class TraitFunction extends Trait implements TraitWithSlot { } getModifiers(abc, isStatic, writer); writer.hilightSpecial("function ", HighlightSpecialType.TRAIT_TYPE); - writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TRAIT_NAME); + writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false, true), HighlightSpecialType.TRAIT_NAME); writer.appendNoHilight("("); abc.method_info.get(method_info).getParamStr(writer, abc.constants, body, abc, fullyQualifiedNames); writer.appendNoHilight(") : "); @@ -87,7 +87,7 @@ public class TraitFunction extends Trait implements TraitWithSlot { writer.startBlock(); int bodyIndex = abc.findBodyIndex(method_info); if (bodyIndex != -1) { - abc.bodies.get(bodyIndex).toString(path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false), exportMode, abc, this, writer, fullyQualifiedNames); + abc.bodies.get(bodyIndex).toString(path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false, true), exportMode, abc, this, writer, fullyQualifiedNames); } writer.endBlock(); @@ -104,7 +104,7 @@ public class TraitFunction extends Trait implements TraitWithSlot { convertHeader(parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); int bodyIndex = abc.findBodyIndex(method_info); if (bodyIndex != -1) { - abc.bodies.get(bodyIndex).convert(convertData, path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false), exportMode, isStatic, method_info, scriptIndex, classIndex, abc, this, new ScopeStack(), 0, writer, fullyQualifiedNames, null, true); + abc.bodies.get(bodyIndex).convert(convertData, path + "." + abc.constants.getMultiname(name_index).getName(abc.constants, fullyQualifiedNames, false, true), exportMode, isStatic, method_info, scriptIndex, classIndex, abc, this, new ScopeStack(), 0, writer, fullyQualifiedNames, null, true); } writer.endMethod(); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java index 7a1565329..64d139ffe 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java @@ -95,7 +95,7 @@ public class TraitMethodGetterSetter extends Trait { getModifiers(abc, isStatic, writer); writer.hilightSpecial("function " + addKind, HighlightSpecialType.TRAIT_TYPE); - writer.hilightSpecial(getName(abc).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TRAIT_NAME); + writer.hilightSpecial(getName(abc).getName(abc.constants, fullyQualifiedNames, false, true), HighlightSpecialType.TRAIT_NAME); writer.appendNoHilight("("); abc.method_info.get(method_info).getParamStr(writer, abc.constants, body, abc, fullyQualifiedNames); writer.appendNoHilight(") : "); @@ -109,7 +109,7 @@ public class TraitMethodGetterSetter extends Trait { writeImportsUsages(abc, writer, getPackage(abc), fullyQualifiedNames); } writer.startMethod(method_info); - path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames, false); + path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames, false, true); convertHeader(parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); int bodyIndex = abc.findBodyIndex(method_info); if (exportMode != ScriptExportMode.AS_METHOD_STUBS) { @@ -130,7 +130,7 @@ public class TraitMethodGetterSetter extends Trait { } getMetaData(parent, convertData, abc, writer); writer.startMethod(method_info); - path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames, false); + path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames, false, true); toStringHeader(parent, convertData, path, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); int bodyIndex = abc.findBodyIndex(method_info); if (classIndex != -1 && abc.instance_info.get(classIndex).isInterface() || bodyIndex == -1) { @@ -190,10 +190,10 @@ public class TraitMethodGetterSetter extends Trait { @Override public boolean isVisible(boolean isStatic, ABC abc) { if (Configuration.handleSkinPartsAutomatically.get()) { - if ("skinParts".equals(getName(abc).getName(abc.constants, new ArrayList<>(), true))) { + if ("skinParts".equals(getName(abc).getName(abc.constants, new ArrayList<>(), true, true))) { if (kindType == TRAIT_GETTER) { MethodInfo mi = abc.method_info.get(method_info); - if (mi.param_types.length == 0 && "Object".equals(abc.constants.getMultiname(mi.ret_type).getNameWithNamespace(abc.constants).toRawString())) { + if (mi.param_types.length == 0 && "Object".equals(abc.constants.getMultiname(mi.ret_type).getNameWithNamespace(abc.constants, true).toRawString())) { if (abc.constants.getNamespace(abc.constants.getMultiname(name_index).namespace_index).kind == Namespace.KIND_PROTECTED) { return false; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java index 0da163cc9..6e401f904 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java @@ -76,7 +76,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot { public String getType(AVM2ConstantPool constants, List fullyQualifiedNames) { String typeStr = "*"; if (type_index > 0) { - typeStr = constants.getMultiname(type_index).getName(constants, fullyQualifiedNames, false); + typeStr = constants.getMultiname(type_index).getName(constants, fullyQualifiedNames, false, true); } return typeStr; } @@ -101,7 +101,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot { slotconst = "namespace"; } writer.hilightSpecial(slotconst + " ", HighlightSpecialType.TRAIT_TYPE); - writer.hilightSpecial(getName(abc).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TRAIT_NAME); + writer.hilightSpecial(getName(abc).getName(abc.constants, fullyQualifiedNames, false, true), HighlightSpecialType.TRAIT_NAME); writer.hilightSpecial(typeStr, HighlightSpecialType.TRAIT_TYPE_NAME); return writer; } @@ -216,9 +216,9 @@ public class TraitSlotConst extends Trait implements TraitWithSlot { Hide: private static var _skinParts (part of [SkinPart] compilations) */ - if (isStatic && "_skinParts".equals(getName(abc).getName(abc.constants, new ArrayList<>(), true))) { + if (isStatic && "_skinParts".equals(getName(abc).getName(abc.constants, new ArrayList<>(), true, true))) { if (kindType == Trait.TRAIT_SLOT) { - if ("_skinParts".equals(getName(abc).getName(abc.constants, new ArrayList<>(), true))) { + if ("_skinParts".equals(getName(abc).getName(abc.constants, new ArrayList<>(), true, true))) { if (getName(abc).getNamespace(abc.constants).kind == Namespace.KIND_PRIVATE) { return false; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/ClassNameInTraitMultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/ClassNameInTraitMultinameUsage.java new file mode 100644 index 000000000..3a70f81c6 --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/ClassNameInTraitMultinameUsage.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2010-2016 JPEXS, All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. + */ +package com.jpexs.decompiler.flash.abc.usages; + +import com.jpexs.decompiler.flash.abc.ABC; + +/** + * + * @author JPEXS + */ +public class ClassNameInTraitMultinameUsage extends MultinameUsage implements DefinitionUsage, InsideClassMultinameUsageInterface { + + private int classIndex; + + public ClassNameInTraitMultinameUsage(ABC abc, int multinameIndex, int classIndex) { + super(abc, multinameIndex); + this.classIndex = classIndex; + } + + @Override + public int getClassIndex() { + return classIndex; + } + + @Override + public String toString() { + return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants, true).toPrintableString(true) + " trait name"; + } + + @Override + public boolean collides(MultinameUsage other) { + if (other instanceof InsideClassMultinameUsageInterface) { + if (((InsideClassMultinameUsageInterface) other).getClassIndex() == getClassIndex()) { + return false; + } + } + if ((other instanceof ClassNameInTraitMultinameUsage) || (other instanceof ClassNameMultinameUsage)) { + return sameMultinameName(other); + } + return false; + } + +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/ClassNameMultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/ClassNameMultinameUsage.java index b31583cae..1a0af3da6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/ClassNameMultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/ClassNameMultinameUsage.java @@ -38,12 +38,17 @@ public class ClassNameMultinameUsage extends MultinameUsage implements Definitio @Override public String toString() { - return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants).toPrintableString(true); + return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants, true).toPrintableString(true); } @Override public boolean collides(MultinameUsage other) { - if (other instanceof ClassNameMultinameUsage) { + if (other instanceof InsideClassMultinameUsageInterface) { + if (((InsideClassMultinameUsageInterface) other).getClassIndex() == getClassIndex()) { + return false; + } + } + if ((other instanceof ClassNameInTraitMultinameUsage) || (other instanceof ClassNameMultinameUsage)) { return sameMultinameName(other); } return false; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/MultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/MultinameUsage.java index 54470d592..ae6b0000b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/MultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/MultinameUsage.java @@ -54,12 +54,11 @@ public abstract class MultinameUsage { return false; } if ((thisM.kind == Multiname.QNAME || thisM.kind == Multiname.QNAMEA) && otherM.kind == thisM.kind) { - String thisName = thisM.getName(abc.constants, new ArrayList<>(), true); - String otherName = otherM.getName(other.abc.constants, new ArrayList<>(), true); + String thisName = thisM.getName(abc.constants, new ArrayList<>(), true, true); + String otherName = otherM.getName(other.abc.constants, new ArrayList<>(), true, true); Namespace thisNs = thisM.getNamespace(abc.constants); Namespace otherNs = otherM.getNamespace(other.abc.constants); if (!Objects.equals(thisName, otherName)) { - System.err.println("not equal name: " + thisName + ", " + otherName); return false; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/TraitMultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/TraitMultinameUsage.java index 54b4ec186..778360f54 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/TraitMultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/TraitMultinameUsage.java @@ -51,7 +51,7 @@ public abstract class TraitMultinameUsage extends MultinameUsage implements Insi @Override public String toString() { - return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants).toPrintableString(true); + return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants, true).toPrintableString(true); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java index 099e63d3f..a6a0f0c66 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/AS3ScriptExporter.java @@ -128,7 +128,7 @@ public class AS3ScriptExporter { if (((SetLocalAVM2Item) asg).regIndex == ((LocalRegAVM2Item) sp.object).regIndex) { GraphTargetItem val = sp.value; if (sp.propertyName instanceof FullMultinameAVM2Item) { - String propName = pack.abc.constants.getMultiname(((FullMultinameAVM2Item) sp.propertyName).multinameIndex).getName(pack.abc.constants, new ArrayList<>(), true); + String propName = pack.abc.constants.getMultiname(((FullMultinameAVM2Item) sp.propertyName).multinameIndex).getName(pack.abc.constants, new ArrayList<>(), true, true); if (val instanceof CallPropertyAVM2Item) { CallPropertyAVM2Item cap = (CallPropertyAVM2Item) val; if (cp.propertyName instanceof FullMultinameAVM2Item) { @@ -216,7 +216,7 @@ public class AS3ScriptExporter { private String getTagName(ScriptPack pack, int classMIndex, int nameMindex, Map namespaces) { Multiname m = pack.abc.constants.getMultiname(classMIndex); Multiname mn = pack.abc.constants.getMultiname(nameMindex); - String parentName = mn.getName(pack.abc.constants, new ArrayList<>(), true); + String parentName = mn.getName(pack.abc.constants, new ArrayList<>(), true, true); String pkg = m.getNamespace(pack.abc.constants).getName(pack.abc.constants).toRawString(); pkg += ".*"; String ns = null; @@ -276,7 +276,7 @@ public class AS3ScriptExporter { if (it instanceof InitPropertyAVM2Item) { InitPropertyAVM2Item ip = (InitPropertyAVM2Item) it; if (ip.object instanceof ThisAVM2Item) { - String propName = pack.abc.constants.getMultiname(ip.propertyName.multinameIndex).getName(pack.abc.constants, new ArrayList<>(), true); + String propName = pack.abc.constants.getMultiname(ip.propertyName.multinameIndex).getName(pack.abc.constants, new ArrayList<>(), true, true); GraphTargetItem val = ((InitPropertyAVM2Item) it).value; if (val instanceof CallPropertyAVM2Item) { CallPropertyAVM2Item cp = (CallPropertyAVM2Item) val; @@ -296,7 +296,7 @@ public class AS3ScriptExporter { ConstructPropAVM2Item cp = (ConstructPropAVM2Item) val; if (cp.propertyName instanceof FullMultinameAVM2Item) { Multiname m = pack.abc.constants.getMultiname(((FullMultinameAVM2Item) cp.propertyName).multinameIndex); - if ("mx.core.DeferredInstanceFromFunction".equals("" + m.getNameWithNamespace(pack.abc.constants))) { + if ("mx.core.DeferredInstanceFromFunction".equals("" + m.getNameWithNamespace(pack.abc.constants, true))) { if (!cp.args.isEmpty()) { if (cp.args.get(0) instanceof GetPropertyAVM2Item) { GetPropertyAVM2Item gp = (GetPropertyAVM2Item) cp.args.get(0); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/DependencyParser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/DependencyParser.java index a779c35d2..2479fcb21 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/DependencyParser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/DependencyParser.java @@ -51,7 +51,7 @@ public class DependencyParser { } else if ((ns.kind != Namespace.KIND_PACKAGE) && (ns.kind != Namespace.KIND_PACKAGE_INTERNAL)) { return; } - newimport = newimport.add(name); + newimport = newimport.addWithSuffix(name); Dependency dep = new Dependency(newimport, dependencyType); if (!dependencies.contains(dep)) { @@ -80,7 +80,7 @@ public class DependencyParser { return; } Namespace ns = m.getNamespace(abc.constants); - String name = m.getName(abc.constants, fullyQualifiedNames, true); + String name = m.getName(abc.constants, fullyQualifiedNames, true, true); NamespaceSet nss = m.getNamespaceSet(abc.constants); if (ns != null) { parseDependenciesFromNS(ignoredCustom, abc, dependencies, uses, m.namespace_index, ignorePackage, name, dependencyType); @@ -114,7 +114,7 @@ public class DependencyParser { } for (AVM2Instruction ins : body.getCode().code) { if (ins.definition instanceof AlchemyTypeIns) { - DottedChain nimport = AlchemyTypeIns.ALCHEMY_PACKAGE.add(ins.definition.instructionName); + DottedChain nimport = AlchemyTypeIns.ALCHEMY_PACKAGE.addWithSuffix(ins.definition.instructionName); Dependency depExp = new Dependency(nimport, DependencyType.EXPRESSION); if (!dependencies.contains(depExp)) { dependencies.add(depExp); @@ -166,7 +166,7 @@ public class DependencyParser { return; } Namespace ns = m.getNamespace(abc.constants); - String name = m.getName(abc.constants, fullyQualifiedNames, false); + String name = m.getName(abc.constants, fullyQualifiedNames, false, true); NamespaceSet nss = m.getNamespaceSet(abc.constants); if (ns != null) { parseUsagesFromNS(ignoredCustom, abc, dependencies, uses, m.namespace_index, ignorePackage, name); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/LinkReportExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/LinkReportExporter.java index 222a8fd0d..652ae0cbf 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/LinkReportExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/script/LinkReportExporter.java @@ -92,7 +92,7 @@ public class LinkReportExporter { List existingObjects = new ArrayList<>(); for (ScriptPack sp : as3scripts) { - existingObjects.add(sp.getClassPath().packageStr.add(sp.getClassPath().className)); + existingObjects.add(sp.getClassPath().packageStr.add(sp.getClassPath().className, sp.getClassPath().namespaceSuffix)); } for (ScriptPack sp : revList) { @@ -119,7 +119,7 @@ public class LinkReportExporter { ns = abc.constants.getNamespace(nss.namespaces[0]); } String pkgName = ns == null ? "" : ns.getName(abc.constants).toRawString(); - String clsName = multiName.getName(abc.constants, new ArrayList<>(), true); + String clsName = multiName.getName(abc.constants, new ArrayList<>(), true, true); return pkgName.isEmpty() ? clsName : pkgName + ":" + clsName; } @@ -167,7 +167,7 @@ public class LinkReportExporter { sb.append(indent(3)).append("").append(newLineChar); //Automatic - tc.getDependencies(null, abc, dependencies, uses, new DottedChain("FAKE!PACKAGE"), new ArrayList<>()); + tc.getDependencies(null, abc, dependencies, uses, new DottedChain(new String[]{"FAKE!PACKAGE"}, ""), new ArrayList<>()); for (Dependency dependency : dependencies) { DottedChain dc = dependency.getId(); if (!"*".equals(dc.getLast())) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfToSwcExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfToSwcExporter.java index 5dc306aea..3e6862e91 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfToSwcExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/swf/SwfToSwcExporter.java @@ -104,7 +104,7 @@ public class SwfToSwcExporter { for (ScriptPack pack : packs) { ClassPath cp = pack.getClassPath(); - definedObjects.add(cp.packageStr.add(cp.className)); + definedObjects.add(cp.packageStr.add(cp.className, "" /*strip*/)); } List allAbcList = new ArrayList<>(); @@ -123,17 +123,17 @@ public class SwfToSwcExporter { for (ScriptPack pack : tagPacks) { ClassPath cp = pack.getClassPath(); - String defId = dottedChainToId(cp.packageStr.add(cp.className)); + String defId = dottedChainToId(cp.packageStr.add(cp.className, "" /*strip*/)); sb.append(" \n"); Set allDeps = new HashSet<>(); - allDeps.add(new DottedChain("AS3")); + allDeps.add(new DottedChain(new String[]{"AS3"}, "")); sb.append(" \n"); if (!skipDependencies) { List dependencies = new ArrayList<>(); List uses = new ArrayList<>(); - pack.abc.script_info.get(pack.scriptIndex).traits.getDependencies(null, pack.abc, dependencies, uses, new DottedChain("NO:PACKAGE"), new ArrayList<>()); + pack.abc.script_info.get(pack.scriptIndex).traits.getDependencies(null, pack.abc, dependencies, uses, new DottedChain(new String[]{"NO:PACKAGE"}, ""), new ArrayList<>()); for (Dependency d : dependencies) { if ("*".equals(d.getId().getLast())) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/flexsdk/MxmlcAs3ScriptReplacer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/flexsdk/MxmlcAs3ScriptReplacer.java index 578802cba..0762c24ed 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/flexsdk/MxmlcAs3ScriptReplacer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/flexsdk/MxmlcAs3ScriptReplacer.java @@ -86,11 +86,11 @@ public class MxmlcAs3ScriptReplacer extends MxmlcRunner implements As3ScriptRepl if (ii.deleted) { return true; } - if (ii.super_index != 0 && isParentDeleted(abc, allAbcs, abc.constants.getMultiname(ii.super_index).getNameWithNamespace(abc.constants))) { + if (ii.super_index != 0 && isParentDeleted(abc, allAbcs, abc.constants.getMultiname(ii.super_index).getNameWithNamespace(abc.constants, false))) { return true; } for (int iface : ii.interfaces) { - if (isParentDeleted(abc, allAbcs, abc.constants.getMultiname(iface).getNameWithNamespace(abc.constants))) { + if (isParentDeleted(abc, allAbcs, abc.constants.getMultiname(iface).getNameWithNamespace(abc.constants, false))) { return true; } } @@ -265,7 +265,7 @@ public class MxmlcAs3ScriptReplacer extends MxmlcRunner implements As3ScriptRepl //remove all subclasses from the SWC for (ScriptPack sp : copyPacks) { - DottedChain dc = sp.getPathPackage().add(sp.getPathScriptName()); + DottedChain dc = sp.getPathPackage().add(sp.getPathScriptName(), ""); if (isParentDeleted(sp.abc, sp.allABCs, dc)) { sp.abc.script_info.get(sp.scriptIndex).delete(sp.abc, true); modAbcs.add(sp.abc); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS3Package.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS3Package.java index 3013f4e73..c3f129204 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS3Package.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/AS3Package.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.timeline; import com.jpexs.decompiler.flash.IdentifiersDeobfuscation; import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.abc.ClassPath; import com.jpexs.decompiler.flash.abc.ScriptPack; import com.jpexs.decompiler.flash.treeitems.AS3ClassTreeItem; import java.util.ArrayList; @@ -44,7 +45,7 @@ public class AS3Package extends AS3ClassTreeItem { private List sortedScripts; public AS3Package(String packageName, SWF swf) { - super(packageName, null); + super(packageName, "", null); this.swf = swf; this.packageName = packageName; } @@ -81,12 +82,13 @@ public class AS3Package extends AS3ClassTreeItem { } public void addScriptPack(ScriptPack script) { - scripts.put(script.getClassPath().className, script); + ClassPath cp = script.getClassPath(); + scripts.put(cp.className + cp.namespaceSuffix, script); sortedScripts = null; } public void addSubPackage(AS3Package subPackage) { - subPackages.put(subPackage.getName(), subPackage); + subPackages.put(subPackage.getNameWithNamespaceSuffix(), subPackage); sortedPackages = null; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/AS3ClassTreeItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/AS3ClassTreeItem.java index 6bb91b1da..1d1653216 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/AS3ClassTreeItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/treeitems/AS3ClassTreeItem.java @@ -29,13 +29,20 @@ public abstract class AS3ClassTreeItem implements TreeItem { private final ClassPath path; - public AS3ClassTreeItem(String name, ClassPath path) { + private final String namespaceSuffix; + + public AS3ClassTreeItem(String name, String namespaceSuffix, ClassPath path) { this.name = name; this.path = path; + this.namespaceSuffix = namespaceSuffix; } - public String getName() { - return name; + public String getNameWithNamespaceSuffix() { + String ret = name; + if (namespaceSuffix != null) { + ret += namespaceSuffix; + } + return ret; } public String getPath() { @@ -44,6 +51,10 @@ public abstract class AS3ClassTreeItem implements TreeItem { @Override public String toString() { - return IdentifiersDeobfuscation.printIdentifier(true, name); + String ret = IdentifiersDeobfuscation.printIdentifier(true, name); + if (namespaceSuffix != null) { + ret += namespaceSuffix; + } + return ret; } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/DottedChain.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/DottedChain.java index 83831c68a..bf4e53e00 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/DottedChain.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/DottedChain.java @@ -30,37 +30,39 @@ import java.util.List; */ public class DottedChain implements Serializable, Comparable { + public static final String NO_SUFFIX = ""; + public static final DottedChain EMPTY = new DottedChain(true); - public static final DottedChain TOPLEVEL = new DottedChain(); + public static final DottedChain TOPLEVEL = new DottedChain(new String[]{}, NO_SUFFIX); - public static final DottedChain BOOLEAN = new DottedChain("Boolean"); + public static final DottedChain BOOLEAN = new DottedChain(new String[]{"Boolean"}, NO_SUFFIX); - public static final DottedChain STRING = new DottedChain("String"); + public static final DottedChain STRING = new DottedChain(new String[]{"String"}, NO_SUFFIX); - public static final DottedChain ARRAY = new DottedChain("Array"); + public static final DottedChain ARRAY = new DottedChain(new String[]{"Array"}, NO_SUFFIX); - public static final DottedChain NUMBER = new DottedChain("Number"); + public static final DottedChain NUMBER = new DottedChain(new String[]{"Number"}, NO_SUFFIX); - public static final DottedChain OBJECT = new DottedChain("Object"); + public static final DottedChain OBJECT = new DottedChain(new String[]{"Object"}, NO_SUFFIX); - public static final DottedChain INT = new DottedChain("int"); + public static final DottedChain INT = new DottedChain(new String[]{"int"}, NO_SUFFIX); - public static final DottedChain UINT = new DottedChain("uint"); + public static final DottedChain UINT = new DottedChain(new String[]{"uint"}, NO_SUFFIX); - public static final DottedChain UNDEFINED = new DottedChain("Undefined"); + public static final DottedChain UNDEFINED = new DottedChain(new String[]{"Undefined"}, NO_SUFFIX); - public static final DottedChain XML = new DottedChain("XML"); + public static final DottedChain XML = new DottedChain(new String[]{"XML"}, NO_SUFFIX); - public static final DottedChain NULL = new DottedChain("null"); + public static final DottedChain NULL = new DottedChain(new String[]{"null"}, NO_SUFFIX); - public static final DottedChain FUNCTION = new DottedChain("Function"); + public static final DottedChain FUNCTION = new DottedChain(new String[]{"Function"}, NO_SUFFIX); - public static final DottedChain VOID = new DottedChain("void"); + public static final DottedChain VOID = new DottedChain(new String[]{"void"}, NO_SUFFIX); - public static final DottedChain NAMESPACE = new DottedChain("Namespace"); + public static final DottedChain NAMESPACE = new DottedChain(new String[]{"Namespace"}, NO_SUFFIX); - public static final DottedChain ALL = new DottedChain("*"); + public static final DottedChain ALL = new DottedChain(new String[]{"*"}, NO_SUFFIX); private final String[] parts; @@ -70,13 +72,25 @@ public class DottedChain implements Serializable, Comparable { private boolean isNull = false; - public static final DottedChain parse(String name) { + private String namespaceSuffix = ""; + + public String getNamespaceSuffix() { + return namespaceSuffix; + } + + public static final DottedChain parseWithSuffix(String name) { if (name == null) { return DottedChain.EMPTY; } else if (name.isEmpty()) { return DottedChain.TOPLEVEL; } else { - return new DottedChain(name.split("\\.")); + String nameNoSuffix = name; + String namespaceSuffix = ""; + if (name.matches(".*#[0-9]+$")) { + nameNoSuffix = name.substring(0, name.lastIndexOf("#")); + namespaceSuffix = name.substring(name.lastIndexOf("#")); + } + return new DottedChain(nameNoSuffix.split("\\."), namespaceSuffix); } } @@ -88,7 +102,7 @@ public class DottedChain implements Serializable, Comparable { } public DottedChain(DottedChain src) { - this(src.parts); + this(src.parts, src.namespaceSuffix); this.isNull = src.isNull; } @@ -98,7 +112,10 @@ public class DottedChain implements Serializable, Comparable { hash = calcHash(); } - public DottedChain(String... parts) { + /*public DottedChain(String onePart, String namespaceSuffix) { + this(new String[]{onePart}, namespaceSuffix); + }*/ + public DottedChain(String[] parts, String namespaceSuffix) { if (parts.length == 1 && parts[0].isEmpty()) { length = 0; this.parts = new String[0]; @@ -107,6 +124,7 @@ public class DottedChain implements Serializable, Comparable { this.parts = parts; } hash = calcHash(); + this.namespaceSuffix = namespaceSuffix; } private DottedChain(String[] parts, int length) { @@ -165,7 +183,17 @@ public class DottedChain implements Serializable, Comparable { return new DottedChain(parts, length - 1); } - public DottedChain add(String name) { + public DottedChain addWithSuffix(String name) { + String addedNameNoSuffix = name; + String addedNamespaceSuffix = ""; + if (name != null && name.matches(".*#[0-9]+$")) { + addedNameNoSuffix = name.substring(0, name.lastIndexOf("#")); + addedNamespaceSuffix = name.substring(name.lastIndexOf("#")); + } + return add(addedNameNoSuffix, addedNamespaceSuffix); + } + + public DottedChain add(String name, String namespaceSuffix) { if (name == null) { return new DottedChain(this); } @@ -175,10 +203,10 @@ public class DottedChain implements Serializable, Comparable { } nparts[nparts.length - 1] = name; - return new DottedChain(nparts); + return new DottedChain(nparts, namespaceSuffix); } - protected String toString(boolean as3, boolean raw) { + protected String toString(boolean as3, boolean raw, boolean withSuffix) { if (isNull) { return ""; } @@ -196,6 +224,9 @@ public class DottedChain implements Serializable, Comparable { boolean lastStar = i == length - 1 && "*".equals(part); ret.append((raw || lastStar) ? part : IdentifiersDeobfuscation.printIdentifier(as3, part)); } + if (withSuffix) { + ret.append(namespaceSuffix); + } return ret.toString(); } @@ -223,11 +254,11 @@ public class DottedChain implements Serializable, Comparable { } public String toPrintableString(boolean as3) { - return toString(as3, false); + return toString(as3, false, true); } - public String toRawString() { - return toString(false/*ignored*/, true); + public String toRawString() { //Is SUFFIX correctly handled? + return toString(false/*ignored*/, true, true); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java index ed6a06085..238f9a30e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java @@ -43,7 +43,7 @@ public class TypeItem extends GraphTargetItem { public final DottedChain fullTypeName; public TypeItem(String s) { - this(s == null ? new DottedChain() : new DottedChain(s.split("\\."))); + this(s == null ? new DottedChain(new String[]{}, "") : DottedChain.parseWithSuffix(s)); } public TypeItem(DottedChain fullTypeName) { @@ -78,7 +78,7 @@ public class TypeItem extends GraphTargetItem { public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { boolean as3 = localData.constantsAvm2 != null; - if (localData.fullyQualifiedNames.contains(new DottedChain(fullTypeName.getLast()))) { + if (localData.fullyQualifiedNames.contains(DottedChain.parseWithSuffix(fullTypeName.getLast()))) { writer.hilightSpecial(fullTypeName.toPrintableString(as3), HighlightSpecialType.TYPE_NAME, fullTypeName.toRawString()); } else { writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(as3, fullTypeName.getLast()), HighlightSpecialType.TYPE_NAME, fullTypeName.toRawString()); diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java index c1e77c76a..b405470a6 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3Test.java @@ -66,7 +66,7 @@ public class ActionScript3Test extends ActionScriptTestBase { } } assertNotNull(tag); - clsIndex = tag.getABC().findClassByName(new DottedChain("classes", "Test")); + clsIndex = tag.getABC().findClassByName(new DottedChain(new String[]{"classes", "Test"}, "")); assertTrue(clsIndex > -1); this.abc = tag.getABC(); Configuration.autoDeobfuscate.set(false); diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS3Generator.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS3Generator.java index 52b2cf491..8d6477cc5 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS3Generator.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/generators/AS3Generator.java @@ -55,12 +55,16 @@ public class AS3Generator { break; } } + if (tag == null) { + System.err.println("No ABC found"); + return; + } ABC abc = tag.getABC(); int classId = abc.findClassByName("classes.Test"); StringBuilder s = new StringBuilder(); for (Trait t : abc.instance_info.get(classId).instance_traits.traits) { if (t instanceof TraitMethodGetterSetter) { - String name = t.getName(abc).getName(abc.constants, null, true); + String name = t.getName(abc).getName(abc.constants, null, true, true); if (name.startsWith("test")) { s.append("@Test\r\npublic void "); s.append(name); diff --git a/libsrc/ffdec_lib/testdata/namespaces/EmptyDocument.as b/libsrc/ffdec_lib/testdata/namespaces/EmptyDocument.as index c499a2242..45c06dde5 100644 --- a/libsrc/ffdec_lib/testdata/namespaces/EmptyDocument.as +++ b/libsrc/ffdec_lib/testdata/namespaces/EmptyDocument.as @@ -8,11 +8,17 @@ public var attr:int = 5; public function EmptyDocument() { + var mc:MyClass = new MyClass(); + var mc2:MyClass2 = new MyClass2() + var r = mc.getResult() + mc2.getResult(); + + var expected = 561; + var display_txt:TextField = new TextField(); - display_txt.text = "Hello World!"; + display_txt.text = "Actual = "+r+", expected = "+expected+", "+(r==expected?"OKAY":"FAIL"); display_txt.width = 300; addChild(display_txt); - var mc = new MyClass(); + } } diff --git a/libsrc/ffdec_lib/testdata/namespaces/MyClass.as b/libsrc/ffdec_lib/testdata/namespaces/MyClass.as index c20cf59db..a9cb4f569 100644 --- a/libsrc/ffdec_lib/testdata/namespaces/MyClass.as +++ b/libsrc/ffdec_lib/testdata/namespaces/MyClass.as @@ -30,69 +30,85 @@ public function f1():int { - return 1; + return 17; } public function f2():int { - return 2; + return 18; } protected function f1x():int { - return 3; + return 19; } protected function f2x():int { - return 4; + return 20; } private function f1y():int { - return 5; + return 21; } private function f2y():int { - return 6; + return 22; } public static function f1():int { - return 7; + return 23; } public static function f2():int { - return 8; + return 24; } protected static function f1x():int { - return 9; + return 25; } protected static function f2x():int { - return 10; + return 26; } private static function f1y():int { - return 11; + return 27; } private static function f2y():int { - return 12; + return 28; } myns function f1():int { - return 13; + return 29; } myns function f2():int { - return 14; + return 30; } myns2 function f1():int { - return 15; + return 31; } myns2 function f2():int { - return 16; + return 32; } + + public function getResult():int { + var inst_a = this.a1 + this.a2 + this.a1x + this.a2x + this.a1y + this.a2y; + var inst_f = this.f1() + this.f2() + this.f1x() + this.f2x() + this.f1y() + this.f2y(); + var inst = inst_a + inst_f; + + var stat_a = MyClass.a1 + MyClass.a2 + MyClass.a1x + MyClass.a2x + MyClass.a1y + MyClass.a2y; + var stat_f = MyClass.f1() + MyClass.f2() + MyClass.f1x() + MyClass.f2x() + MyClass.f1y() + MyClass.f2y(); + var stat = stat_a + stat_f; + + var ns_a = myns::a1 + myns::a2 + myns2::a1 + myns2::a2; + var ns_f = myns::f1() + myns::f2() + myns2::f1() + myns2::f2(); + var ns = ns_a + ns_f; + + return inst+stat+ns; //528 + } } } diff --git a/libsrc/ffdec_lib/testdata/namespaces/MyClass2.as b/libsrc/ffdec_lib/testdata/namespaces/MyClass2.as new file mode 100644 index 000000000..a26be3277 --- /dev/null +++ b/libsrc/ffdec_lib/testdata/namespaces/MyClass2.as @@ -0,0 +1,15 @@ +package { + + public class MyClass2 { + + public function MyClass2() { + + } + + public function getResult():int{ + return 33; + } + + } + +} diff --git a/libsrc/ffdec_lib/testdata/namespaces/namespaces.swf b/libsrc/ffdec_lib/testdata/namespaces/namespaces.swf index ee0a803f2..a2dce8280 100644 Binary files a/libsrc/ffdec_lib/testdata/namespaces/namespaces.swf and b/libsrc/ffdec_lib/testdata/namespaces/namespaces.swf differ diff --git a/libsrc/ffdec_lib/testdata/namespaces/same_classes.swf b/libsrc/ffdec_lib/testdata/namespaces/same_classes.swf new file mode 100644 index 000000000..356130bbe Binary files /dev/null and b/libsrc/ffdec_lib/testdata/namespaces/same_classes.swf differ diff --git a/libsrc/ffdec_lib/testdata/namespaces/same_traits.swf b/libsrc/ffdec_lib/testdata/namespaces/same_traits.swf new file mode 100644 index 000000000..6a2fdd624 Binary files /dev/null and b/libsrc/ffdec_lib/testdata/namespaces/same_traits.swf differ diff --git a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java index 805575b4a..629d0cb4c 100644 --- a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java +++ b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java @@ -3749,7 +3749,7 @@ public class CommandLineArgumentParser { String dcs = swf.getDocumentClass(); if (dcs != null) { if (dcs.contains(".")) { - DottedChain dc = new DottedChain(dcs.split("\\.")); + DottedChain dc = DottedChain.parseWithSuffix(dcs); pw.println("documentClass=" + dc.toPrintableString(true)); } else { pw.println("documentClass=" + IdentifiersDeobfuscation.printIdentifier(true, dcs)); diff --git a/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java b/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java index 64c9c3251..509c37db3 100644 --- a/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java +++ b/src/com/jpexs/decompiler/flash/gui/DebuggerHandler.java @@ -571,7 +571,7 @@ public class DebuggerHandler implements DebugConnectionListener { Matcher m; if ((m = patAS3.matcher(name)).matches()) { - String clsName = m.group(3); + String clsNameWithSuffix = m.group(3); String pkg = m.group(2).replace("\\", "."); m = patAS3PCode.matcher(name); @@ -579,10 +579,10 @@ public class DebuggerHandler implements DebugConnectionListener { moduleToClassIndex.put(file, Integer.parseInt(m.group(3))); moduleToTraitIndex.put(file, Integer.parseInt(m.group(4))); moduleToMethodIndex.put(file, Integer.parseInt(m.group(5))); - name = DottedChain.parse(pkg).add(clsName).toString(); + name = DottedChain.parseWithSuffix(pkg).addWithSuffix(clsNameWithSuffix).toString(); name = "#PCODE abc:" + m.group(1) + ",body:" + m.group(6) + ";" + name; } else { - name = DottedChain.parse(pkg).add(clsName).toString(); + name = DottedChain.parseWithSuffix(pkg).addWithSuffix(clsNameWithSuffix).toString(); } } modulePaths.put(file, name); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index 625807aaa..a71e0b336 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -213,7 +213,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener locTypeRef = new Reference<>(DottedChain.EMPTY); @@ -343,9 +343,8 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL return false; } boolean found; - t = sd.getNextToken(t); - while (t != lastToken && !currentType.equals(DottedChain.ALL)) { - t = sd.getNextToken(t); + + while (!currentType.equals(DottedChain.ALL)) { String ident = t.getString(sd); found = false; List abcList = getABC().getSwf().getAbcList(); @@ -357,13 +356,13 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL InstanceInfo ii = a.instance_info.get(cindex); for (int j = 0; j < ii.instance_traits.traits.size(); j++) { Trait tr = ii.instance_traits.traits.get(j); - if (ident.equals(tr.getName(a).getName(a.constants, null, false /*NOT RAW!*/))) { + if (ident.equals(tr.getName(a).getName(a.constants, null, false /*NOT RAW!*/, true))) { classIndex.setVal(cindex); abcIndex.setVal(i); traitIndex.setVal(j); classTrait.setVal(false); multinameIndex.setVal(tr.name_index); - currentType = ii.getName(a.constants).getNameWithNamespace(a.constants); + currentType = ii.getName(a.constants).getNameWithNamespace(a.constants, true); found = true; break loopi; } @@ -372,13 +371,13 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL ClassInfo ci = a.class_info.get(cindex); for (int j = 0; j < ci.static_traits.traits.size(); j++) { Trait tr = ci.static_traits.traits.get(j); - if (ident.equals(tr.getName(a).getName(a.constants, null, false /*NOT RAW!*/))) { + if (ident.equals(tr.getName(a).getName(a.constants, null, false /*NOT RAW!*/, true))) { classIndex.setVal(cindex); abcIndex.setVal(i); traitIndex.setVal(j); classTrait.setVal(true); multinameIndex.setVal(tr.name_index); - currentType = ii.getName(a.constants).getNameWithNamespace(a.constants); + currentType = ii.getName(a.constants).getNameWithNamespace(a.constants, true); found = true; break loopi; } @@ -389,10 +388,14 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL return false; } + if (t == lastToken) { + break; + } t = sd.getNextToken(t); if (!".".equals(t.getString(sd))) { break; } + t = sd.getNextToken(t); } return true; } @@ -481,7 +484,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL for (int i = 1; i < abc.constants.getMultinameCount(); i++) { Multiname m = abc.constants.getMultiname(i); if (m != null) { - if (typeName.equals(m.getNameWithNamespace(abc.constants).toRawString())) { + if (typeName.equals(m.getNameWithNamespace(abc.constants, true).toRawString())) { return i; } } @@ -536,7 +539,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL if (tm != null) { String name = ""; if (classIndex > -1) { - name = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants).toPrintableString(true); + name = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants, true).toPrintableString(true); } Trait currentTrait = null; @@ -547,7 +550,7 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL currentTrait = getCurrentTrait(); isStatic = abc.isStaticTraitId(classIndex, lastTraitIndex); if (currentTrait != null) { - name += ":" + currentTrait.getName(abc).getName(abc.constants, null, false); + name += ":" + currentTrait.getName(abc).getName(abc.constants, null, false, true); } } } @@ -588,11 +591,11 @@ public class DecompiledEditorPane extends DebuggableEditorPane implements CaretL } currentMethodHighlight = null; //currentTrait = null; - String name = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants).toPrintableString(true); + String name = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants, true).toPrintableString(true); currentTrait = getCurrentTrait(); isStatic = abc.isStaticTraitId(classIndex, lastTraitIndex); if (currentTrait != null) { - name += ":" + currentTrait.getName(abc).getName(abc.constants, null, false); + name += ":" + currentTrait.getName(abc).getName(abc.constants, null, false, true); } displayMethod(pos, abc.findMethodIdByTraitId(classIndex, lastTraitIndex), name, currentTrait, lastTraitIndex, isStatic); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java index 7a310a243..e25f83b76 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java @@ -286,7 +286,7 @@ public class DetailPanel extends JPanel implements TagEditorPanel { if (trait == null) { traitNameLabel.setText("-"); } else if (abcPanel != null) { - traitNameLabel.setText(trait.getName(abcPanel.abc).getName(abcPanel.abc.constants, null, false)); + traitNameLabel.setText(trait.getName(abcPanel.abc).getName(abcPanel.abc.constants, null, false, true)); } }); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java b/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java index 15a034584..ddce8551a 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java @@ -97,9 +97,9 @@ public class TraitsListItem { return "__" + STR_SCRIPT_INITIALIZER; } if (isStatic) { - return abc.class_info.get(classIndex).static_traits.traits.get(index).getName(abc).getName(abc.constants, null, false); + return abc.class_info.get(classIndex).static_traits.traits.get(index).getName(abc).getName(abc.constants, null, false, true); } else { - return abc.instance_info.get(classIndex).instance_traits.traits.get(index).getName(abc).getName(abc.constants, null, false); + return abc.instance_info.get(classIndex).instance_traits.traits.get(index).getName(abc).getName(abc.constants, null, false, true); } } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java b/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java index 4cc2d8c93..1fde1de45 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java @@ -92,7 +92,7 @@ public class UsageFrame extends AppDialog implements MouseListener { cont.add(new JScrollPane(usageList), BorderLayout.CENTER); cont.add(buttonsPanel, BorderLayout.SOUTH); setSize(400, 300); - setTitle((definitions ? translate("dialog.title.declaration") : translate("dialog.title")) + abc.constants.getMultiname(multinameIndex).getNameWithNamespace(abc.constants).toPrintableString(true)); + setTitle((definitions ? translate("dialog.title.declaration") : translate("dialog.title")) + abc.constants.getMultiname(multinameIndex).getNameWithNamespace(abc.constants, true).toPrintableString(true)); View.centerScreen(this); View.setWindowIcon(this); } @@ -133,7 +133,7 @@ public class UsageFrame extends AppDialog implements MouseListener { settrait.run(); } else { abcPanel.decompiledTextArea.addScriptListener(settrait); - abcPanel.hilightScript(abcPanel.getSwf(), icu.getAbc().instance_info.get(icu.getClassIndex()).getName(icu.getAbc().constants).getNameWithNamespace(icu.getAbc().constants).toRawString()); + abcPanel.hilightScript(abcPanel.getSwf(), icu.getAbc().instance_info.get(icu.getClassIndex()).getName(icu.getAbc().constants).getNameWithNamespace(icu.getAbc().constants, true).toRawString()); } } } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/MultinameTableModel.java b/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/MultinameTableModel.java index dea183418..2192e629e 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/MultinameTableModel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/MultinameTableModel.java @@ -131,7 +131,7 @@ public class MultinameTableModel implements TableModel { if (abc.constants.getMultiname(rowIndex).name_index == -1) { return ""; } - return abc.constants.getMultiname(rowIndex).getName(abc.constants, null, true); + return abc.constants.getMultiname(rowIndex).getName(abc.constants, null, true, true); case 3: if (rowIndex == 0) { return ""; diff --git a/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java b/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java index e06f83a3d..13b3d51a9 100644 --- a/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java +++ b/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java @@ -97,23 +97,23 @@ public class DebuggerTools { } for (int i = 1; i < a.constants.getMultinameCount(); i++) { Multiname m = a.constants.getMultiname(i); - if ("flash.display.Loader".equals(m.getNameWithNamespace(a.constants).toRawString())) { + if ("flash.display.Loader".equals(m.getNameWithNamespace(a.constants, true).toRawString())) { m.namespace_index = a.constants.getNamespaceId(Namespace.KIND_PACKAGE, debuggerPkg, 0, true); m.name_index = a.constants.getStringId("DebugLoader", true); ((Tag) ct).setModified(true); - } else if ("flash.utils.getDefinitionByName".equals(m.getNameWithNamespace(a.constants).toRawString())) { + } else if ("flash.utils.getDefinitionByName".equals(m.getNameWithNamespace(a.constants, true).toRawString())) { m.namespace_index = a.constants.getNamespaceId(Namespace.KIND_PACKAGE, debuggerPkg, 0, true); m.name_index = a.constants.getStringId("debugGetDefinitionByName", true); ((Tag) ct).setModified(true); - } else if ("flash.utils.getQualifiedClassName".equals(m.getNameWithNamespace(a.constants).toRawString())) { + } else if ("flash.utils.getQualifiedClassName".equals(m.getNameWithNamespace(a.constants, true).toRawString())) { m.namespace_index = a.constants.getNamespaceId(Namespace.KIND_PACKAGE, debuggerPkg, 0, true); m.name_index = a.constants.getStringId("debugGetQualifiedClassName", true); ((Tag) ct).setModified(true); - } else if ("flash.utils.getQualifiedSuperclassName".equals(m.getNameWithNamespace(a.constants).toRawString())) { + } else if ("flash.utils.getQualifiedSuperclassName".equals(m.getNameWithNamespace(a.constants, true).toRawString())) { m.namespace_index = a.constants.getNamespaceId(Namespace.KIND_PACKAGE, debuggerPkg, 0, true); m.name_index = a.constants.getStringId("debugGetQualifiedSuperclassName", true); ((Tag) ct).setModified(true); - } else if ("flash.utils.describeType".equals(m.getNameWithNamespace(a.constants).toRawString())) { + } else if ("flash.utils.describeType".equals(m.getNameWithNamespace(a.constants, true).toRawString())) { m.namespace_index = a.constants.getNamespaceId(Namespace.KIND_PACKAGE, debuggerPkg, 0, true); m.name_index = a.constants.getStringId("debugDescribeType", true); ((Tag) ct).setModified(true); @@ -131,7 +131,7 @@ public class DebuggerTools { ABC a = ct.getABC(); for (int i = 1; i < a.constants.getMultinameCount(); i++) { Multiname m = a.constants.getMultiname(i); - if ("trace".equals(m.getNameWithNamespace(a.constants).toRawString())) { + if ("trace".equals(m.getNameWithNamespace(a.constants, true).toRawString())) { m.namespace_index = a.constants.getNamespaceId(Namespace.KIND_PACKAGE, debuggerPkg, 0, true); m.name_index = a.constants.getStringId(fname, true); ((Tag) ct).setModified(true); @@ -154,7 +154,7 @@ public class DebuggerTools { ABC a = ct.getABC(); for (int i = 1; i < a.constants.getMultinameCount(); i++) { Multiname m = a.constants.getMultiname(i); - String packageStr = m.getNameWithNamespace(a.constants).toString(); + String packageStr = m.getNameWithNamespace(a.constants, true).toString(); if (isDebuggerClass(packageStr, "debugTrace") || isDebuggerClass(packageStr, "debugAlert") || isDebuggerClass(packageStr, "debugSocket")