From a4d49aeaf09884100e1ecefcd020cfb86620755b Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Tue, 14 Jul 2015 20:13:54 +0200 Subject: [PATCH] using DottedChains (almost) everywhere --- .../flash/IdentifiersDeobfuscation.java | 36 +---- .../flash/SourceGeneratorLocalData.java | 3 +- .../com/jpexs/decompiler/flash/abc/ABC.java | 12 +- .../jpexs/decompiler/flash/abc/ClassPath.java | 7 +- .../decompiler/flash/abc/ScriptPack.java | 25 +--- .../flash/abc/avm2/AVM2ConstantPool.java | 29 ++++ .../flash/abc/avm2/AVM2Deobfuscation.java | 7 + .../instructions/alchemy/AlchemyTypeIns.java | 4 +- .../avm2/instructions/types/CoerceSIns.java | 2 +- .../avm2/instructions/types/ConvertBIns.java | 2 +- .../avm2/instructions/types/ConvertDIns.java | 2 +- .../avm2/instructions/types/ConvertIIns.java | 2 +- .../avm2/instructions/types/ConvertOIns.java | 2 +- .../avm2/instructions/types/ConvertSIns.java | 2 +- .../avm2/instructions/types/ConvertUIns.java | 2 +- .../abc/avm2/model/AlchemyLoadAVM2Item.java | 5 +- .../avm2/model/AlchemySignExtendAVM2Item.java | 3 +- .../flash/abc/avm2/model/FindDefAVM2Item.java | 11 +- .../abc/avm2/model/FullMultinameAVM2Item.java | 2 +- .../abc/avm2/model/InitVectorAVM2Item.java | 15 ++- .../abc/avm2/model/IntegerValueAVM2Item.java | 3 +- .../flash/abc/avm2/model/NanAVM2Item.java | 12 +- .../abc/avm2/model/NewFunctionAVM2Item.java | 2 +- .../abc/avm2/model/NewObjectAVM2Item.java | 3 +- .../flash/abc/avm2/model/NullAVM2Item.java | 12 +- .../abc/avm2/model/UndefinedAVM2Item.java | 12 +- .../flash/abc/avm2/model/XMLAVM2Item.java | 12 +- .../model/clauses/DeclarationAVM2Item.java | 4 +- .../abc/avm2/model/clauses/TryAVM2Item.java | 2 +- .../operations/DeletePropertyAVM2Item.java | 3 +- .../abc/avm2/model/operations/EqAVM2Item.java | 3 +- .../abc/avm2/model/operations/GeAVM2Item.java | 3 +- .../abc/avm2/model/operations/GtAVM2Item.java | 3 +- .../abc/avm2/model/operations/InAVM2Item.java | 12 +- .../model/operations/InstanceOfAVM2Item.java | 12 +- .../avm2/model/operations/IsTypeAVM2Item.java | 12 +- .../abc/avm2/model/operations/LeAVM2Item.java | 3 +- .../abc/avm2/model/operations/LtAVM2Item.java | 3 +- .../avm2/model/operations/NeqAVM2Item.java | 3 +- .../model/operations/StrictEqAVM2Item.java | 3 +- .../model/operations/StrictNeqAVM2Item.java | 3 +- .../parser/script/AVM2SourceGenerator.java | 43 +++--- .../parser/script/ActionScript3Parser.java | 62 ++++----- .../abc/avm2/parser/script/CallAVM2Item.java | 21 ++- .../abc/avm2/parser/script/ClassAVM2Item.java | 4 +- .../abc/avm2/parser/script/ConstAVM2Item.java | 5 +- .../avm2/parser/script/FunctionAVM2Item.java | 7 +- .../avm2/parser/script/GetterAVM2Item.java | 3 +- .../avm2/parser/script/InterfaceAVM2Item.java | 4 +- .../avm2/parser/script/MethodAVM2Item.java | 3 +- .../parser/script/NamespacedAVM2Item.java | 21 +-- .../avm2/parser/script/PackageAVM2Item.java | 4 +- .../avm2/parser/script/PropertyAVM2Item.java | 36 ++--- .../avm2/parser/script/SetterAVM2Item.java | 3 +- .../abc/avm2/parser/script/SlotAVM2Item.java | 5 +- .../parser/script/UnresolvedAVM2Item.java | 90 ++++++------- .../abc/avm2/parser/script/XMLAVM2Item.java | 3 +- .../avm2/parser/script/XMLFilterAVM2Item.java | 3 +- .../flash/abc/types/InstanceInfo.java | 4 +- .../flash/abc/types/MethodInfo.java | 2 +- .../decompiler/flash/abc/types/Multiname.java | 19 +-- .../decompiler/flash/abc/types/Namespace.java | 14 +- .../flash/abc/types/ScriptInfo.java | 4 +- .../decompiler/flash/abc/types/ValueKind.java | 2 +- .../flash/abc/types/traits/Trait.java | 8 +- .../flash/abc/types/traits/TraitClass.java | 74 +++++------ .../abc/usages/ClassNameMultinameUsage.java | 8 +- .../abc/usages/InsideClassMultinameUsage.java | 2 +- .../flash/tags/DoInitActionTag.java | 20 +-- .../jpexs/decompiler/graph/DottedChain.java | 124 +++++++++++++----- .../com/jpexs/decompiler/graph/TypeItem.java | 13 +- .../flash/gui/abc/ClassesListTreeModel.java | 11 +- .../flash/gui/abc/DecompiledEditorPane.java | 4 +- .../decompiler/flash/gui/abc/UsageFrame.java | 4 +- .../abc/tablemodels/NamespaceTableModel.java | 9 +- .../flash/gui/debugger/DebuggerTools.java | 4 +- 76 files changed, 505 insertions(+), 436 deletions(-) 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 bd3cf0a9a..6aa174140 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/IdentifiersDeobfuscation.java @@ -317,6 +317,10 @@ public class IdentifiersDeobfuscation { * @return */ public static String printIdentifier(boolean as3, String s, String... validExceptions) { + if (s.isEmpty()) { + return ""; + } + if (s.startsWith("\u00A7") && s.endsWith("\u00A7")) { // Assuming already printed - TODO:detect better return s; } @@ -343,38 +347,6 @@ public class IdentifiersDeobfuscation { return ret; } - public static String printNamespace(boolean as3, String pkg, String... validNameExceptions) { - Cache nameCache = as3 ? as3NameCache : as2NameCache; - if (nameCache.contains(pkg)) { - return nameCache.get(pkg); - } - - if (pkg.isEmpty()) { - nameCache.put(pkg, pkg); - return pkg; - } - - String[] parts; - if (pkg.contains(".")) { - parts = pkg.split("\\."); - } else { - parts = new String[]{pkg}; - } - - StringBuilder ret = new StringBuilder(); - for (int i = 0; i < parts.length; i++) { - if (i > 0) { - ret.append("."); - } - - ret.append(printIdentifier(as3, parts[i], validNameExceptions)); - } - - String retStr = ret.toString(); - nameCache.put(pkg, retStr); - return retStr; - } - public static GraphTextWriter escapeOIdentifier(String s, GraphTextWriter writer) { for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); 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 b999561f1..12d6dfcc0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java @@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash; import com.jpexs.decompiler.flash.abc.types.ABCException; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.ScriptInfo; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import java.io.Serializable; import java.util.ArrayList; @@ -57,7 +58,7 @@ public class SourceGeneratorLocalData implements Serializable { public Map> traitUsages = new HashMap<>(); - public String pkg = ""; + public DottedChain pkg = DottedChain.EMPTY; public List scopeStack = new ArrayList<>(); 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 dba2f2b40..b7abb9d5f 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 @@ -109,7 +109,7 @@ public class ABC { public ABCContainerTag parentTag; /* Map from multiname index of namespace value to namespace name**/ - private Map namespaceMap; + private Map namespaceMap; public ABC(ABCContainerTag tag) { this.parentTag = tag; @@ -814,15 +814,15 @@ public class ABC { } } - private Map getNamespaceMap() { + private Map getNamespaceMap() { if (namespaceMap == null) { - Map map = new HashMap<>(); + Map map = new HashMap<>(); for (ScriptInfo si : script_info) { for (Trait t : si.traits.traits) { if (t instanceof TraitSlotConst) { TraitSlotConst s = ((TraitSlotConst) t); if (s.isNamespace()) { - String key = constants.getNamespace(s.value_index).getName(constants, true); // assume not null + DottedChain key = constants.getNamespace(s.value_index).getName(constants, true); // assume not null DottedChain val = constants.getMultiname(s.name_index).getNameWithNamespace(constants); map.put(key, val); } @@ -857,13 +857,13 @@ public class ABC { return bodyIdxFromMethodIdx; } - public DottedChain nsValueToName(String value) { + public DottedChain nsValueToName(DottedChain value) { if (getNamespaceMap().containsKey(value)) { return getNamespaceMap().get(value); } else { DottedChain ns = getDeobfuscation().builtInNs(value); if (ns == null) { - return new DottedChain(""); + return DottedChain.EMPTY; } else { return ns; } 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 4afffd1ea..467b9ecce 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 @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.abc; +import com.jpexs.decompiler.graph.DottedChain; import java.util.Objects; /** @@ -24,18 +25,18 @@ import java.util.Objects; */ public class ClassPath { - public final String packageStr; + public final DottedChain packageStr; public final String className; - public ClassPath(String packageStr, String className) { + public ClassPath(DottedChain packageStr, String className) { this.packageStr = packageStr; this.className = className; } @Override public String toString() { - return (packageStr == null || packageStr.isEmpty()) ? className : packageStr + "." + className; + return (packageStr == null || packageStr.isEmpty()) ? className : packageStr.toPrintableString(true) + "." + className; } @Override 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 e9e72c944..0db060517 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 @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.helpers.FileTextWriter; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.NulWriter; import com.jpexs.decompiler.flash.treeitems.AS3ClassTreeItem; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.helpers.CancellableWorker; import com.jpexs.helpers.Helper; import com.jpexs.helpers.Path; @@ -82,8 +83,8 @@ public class ScriptPack extends AS3ClassTreeItem { this.allABCs = allAbcs; } - public String getPathPackage() { - String packageName = ""; + public DottedChain getPathPackage() { + DottedChain packageName = DottedChain.EMPTY; for (int t : traitIndices) { Multiname name = abc.script_info.get(scriptIndex).traits.traits.get(t).getName(abc); Namespace ns = name.getNamespace(abc.constants); @@ -108,8 +109,8 @@ public class ScriptPack extends AS3ClassTreeItem { public File getExportFile(String directory, ScriptExportSettings exportSettings) throws IOException { String scriptName = getPathScriptName(); - String packageName = getPathPackage(); - File outDir = new File(directory + File.separatorChar + makeDirPath(packageName)); + DottedChain packageName = getPathPackage(); + File outDir = new File(directory + File.separatorChar + packageName.toFilePath()); Path.createDirectorySafe(outDir); String fileName = outDir.toString() + File.separator + Helper.makeFileName(scriptName) + exportSettings.getFileExtension(); return new File(fileName); @@ -128,22 +129,6 @@ public class ScriptPack extends AS3ClassTreeItem { } return packageName.equals("") ? scriptName : packageName + "." + scriptName; }*/ - private static String makeDirPath(String packageName) { - if (packageName.isEmpty()) { - return ""; - } - String[] pathParts; - if (packageName.contains(".")) { - pathParts = packageName.split("\\."); - } else { - pathParts = new String[]{packageName}; - } - for (int i = 0; i < pathParts.length; i++) { - pathParts[i] = Helper.makeFileName(pathParts[i]); - } - return Helper.joinStrings(pathParts, File.separator); - } - public void convert(final NulWriter writer, final List traits, final ScriptExportMode exportMode, final boolean parallel) throws InterruptedException { for (int t : traitIndices) { Trait trait = traits.get(t); 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 77f344082..642c4b5f2 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 @@ -20,9 +20,12 @@ import com.jpexs.decompiler.flash.abc.types.Decimal; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.Namespace; import com.jpexs.decompiler.flash.abc.types.NamespaceSet; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.helpers.utf8.Utf8PrintWriter; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -47,6 +50,8 @@ public class AVM2ConstantPool { public List constant_multiname = new ArrayList<>(); + public Map dottedChainCache = new HashMap<>(); + public synchronized int addInt(long value) { constant_int.add(value); return constant_int.size() - 1; @@ -340,6 +345,14 @@ public class AVM2ConstantPool { return id; } + public int getStringId(DottedChain val, boolean add) { + if (val == null) { + return 0; + } + + return getStringId(val.toRawString(), add); + } + public int getIntId(long val, boolean add) { int id = getIntId(val); if (add && id == 0) { @@ -404,6 +417,22 @@ public class AVM2ConstantPool { return id; } + public DottedChain getDottedChain(int index) { + String str = getString(index); + DottedChain chain = dottedChainCache.get(str); + if (chain == null) { + if (str.isEmpty()) { + chain = DottedChain.EMPTY; + } else { + chain = new DottedChain(str.split("\\.")); + } + + dottedChainCache.put(str, chain); + } + + return chain; + } + public void dump(Utf8PrintWriter writer) { String s = ""; for (int i = 1; i < constant_int.size(); i++) { 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 004cf9f15..13ba6d063 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 @@ -92,6 +92,13 @@ public class AVM2Deobfuscation { return isValid; } + public DottedChain builtInNs(DottedChain ns) { + if (ns == null || ns.size() != 1) { + return null; + } + return builtInNs(ns.get(0)); + } + public DottedChain builtInNs(String ns) { if (ns == null) { return null; 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 6c0753739..24b4b438e 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 @@ -16,11 +16,13 @@ */ package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; +import com.jpexs.decompiler.graph.DottedChain; + /** * * @author JPEXS */ public interface AlchemyTypeIns { - public static final String ALCHEMY_PACKAGE = "avm2.intrinsics.memory"; + public static final DottedChain ALCHEMY_PACKAGE = new DottedChain("avm2", "intrinsics", "memory"); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java index 72be9784f..bd856cf3d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java @@ -57,6 +57,6 @@ public class CoerceSIns extends InstructionDefinition implements CoerceOrConvert @Override public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return new TypeItem("String"); + return new TypeItem(new DottedChain("String")); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java index 9616a2d64..a328724dd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java @@ -67,6 +67,6 @@ public class ConvertBIns extends InstructionDefinition implements CoerceOrConver @Override public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return new TypeItem("Boolean"); + return new TypeItem(new DottedChain("Boolean")); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java index a88a93fd4..3dfbf2908 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java @@ -75,6 +75,6 @@ public class ConvertDIns extends InstructionDefinition implements CoerceOrConver @Override public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return new TypeItem("Number"); + return new TypeItem(new DottedChain("Number")); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java index 5b852bdda..9d4fe21da 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java @@ -73,6 +73,6 @@ public class ConvertIIns extends InstructionDefinition implements CoerceOrConver @Override public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return new TypeItem("int"); + return new TypeItem(new DottedChain("int")); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java index 9b21931d0..968661991 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java @@ -56,6 +56,6 @@ public class ConvertOIns extends InstructionDefinition implements CoerceOrConver @Override public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return new TypeItem("Object"); + return new TypeItem(new DottedChain("Object")); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java index 3f3459e6c..59a46683c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java @@ -57,6 +57,6 @@ public class ConvertSIns extends InstructionDefinition implements CoerceOrConver @Override public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return new TypeItem("String"); + return new TypeItem(new DottedChain("String")); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java index 4bf1f3c46..a16eb0db8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java @@ -56,6 +56,6 @@ public class ConvertUIns extends InstructionDefinition implements CoerceOrConver @Override public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return new TypeItem("uint"); + return new TypeItem(new DottedChain("uint")); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyLoadAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyLoadAVM2Item.java index 7e746d3ff..a414c99cc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyLoadAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyLoadAVM2Item.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Li32Ins; import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Li8Ins; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -86,9 +87,9 @@ public class AlchemyLoadAVM2Item extends AVM2Item { public GraphTargetItem returnType() { switch (type) { case 'i': - return new TypeItem("int"); + return new TypeItem(new DottedChain("int")); case 'f': - return new TypeItem("Number"); + return new TypeItem(new DottedChain("Number")); } return TypeItem.UNBOUNDED; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemySignExtendAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemySignExtendAVM2Item.java index db2675cb0..991bf68e1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemySignExtendAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemySignExtendAVM2Item.java @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Sxi1Ins; import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Sxi8Ins; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -52,7 +53,7 @@ public class AlchemySignExtendAVM2Item extends AVM2Item { @Override public GraphTargetItem returnType() { - return new TypeItem("int"); + return new TypeItem(new DottedChain("int")); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FindDefAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FindDefAVM2Item.java index d113d6ee1..1600d9270 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FindDefAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/FindDefAVM2Item.java @@ -1,18 +1,19 @@ /* * Copyright (C) 2010-2015 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. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; @@ -33,7 +34,7 @@ public class FindDefAVM2Item extends AVM2Item { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { - return writer.append(propertyName.getNamespace(localData.constantsAvm2).getName(localData.constantsAvm2, false)); //assume not null name + return writer.append(propertyName.getNamespace(localData.constantsAvm2).getName(localData.constantsAvm2, false).toPrintableString(true)); //assume not null name } @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 02e64801d..03d0b4ccb 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 @@ -73,7 +73,7 @@ public class FullMultinameAVM2Item extends AVM2Item { } else { Namespace ns = constants.getMultiname(multinameIndex).getNamespace(constants); if ((ns != null) && (ns.name_index != 0)) { - cns = ns.getName(constants, false); + cns = ns.getName(constants, false).toPrintableString(true); } } return cname.equals("XML") && cns.isEmpty(); 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 30834edd6..335bd63e7 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 @@ -31,6 +31,7 @@ import com.jpexs.decompiler.flash.abc.types.Namespace; import com.jpexs.decompiler.flash.abc.types.NamespaceSet; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -45,6 +46,18 @@ import java.util.List; */ public class InitVectorAVM2Item extends AVM2Item { + public static final DottedChain VECTOR_PACKAGE = new DottedChain("__AS3__", "vec"); + + public static final DottedChain VECTOR_FQN = new DottedChain("__AS3__", "vec", "Vector"); + + public static final DottedChain VECTOR_INT = new DottedChain("__AS3__", "vec", "Vector$int"); + + public static final DottedChain VECTOR_DOUBLE = new DottedChain("__AS3__", "vec", "Vector$double"); + + public static final DottedChain VECTOR_UINT = new DottedChain("__AS3__", "vec", "Vector$uint"); + + public static final DottedChain VECTOR_OBJECT = new DottedChain("__AS3__", "vec", "Vector$object"); + public GraphTargetItem subtype; public List arguments; @@ -97,7 +110,7 @@ public class InitVectorAVM2Item extends AVM2Item { public GraphTargetItem returnType() { List pars = new ArrayList<>(); pars.add(subtype); - return new ApplyTypeAVM2Item(null, new TypeItem("__AS3__.vec.Vector"), pars); + return new ApplyTypeAVM2Item(null, new TypeItem(VECTOR_FQN), pars); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java index 7fe0682dc..03599e588 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java @@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushShortIns; import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -73,7 +74,7 @@ public class IntegerValueAVM2Item extends NumberValueAVM2Item implements Integer @Override public GraphTargetItem returnType() { - return new TypeItem("int"); + return new TypeItem(new DottedChain("int")); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NanAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NanAVM2Item.java index 2bc0ce86f..da5cbe5db 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NanAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NanAVM2Item.java @@ -1,18 +1,19 @@ /* * Copyright (C) 2010-2015 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. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; @@ -20,6 +21,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushNanIns; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -47,7 +49,7 @@ public class NanAVM2Item extends AVM2Item { @Override public GraphTargetItem returnType() { - return new TypeItem("Number"); + return new TypeItem(new DottedChain("Number")); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java index 1346a9ca8..a554381a4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java @@ -98,7 +98,7 @@ public class NewFunctionAVM2Item extends AVM2Item { @Override public GraphTargetItem returnType() { - return new TypeItem("Function"); + return new TypeItem(new DottedChain("Function")); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewObjectAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewObjectAVM2Item.java index 7359809ce..82694d8e8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewObjectAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NewObjectAVM2Item.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewObjectIns; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -63,7 +64,7 @@ public class NewObjectAVM2Item extends AVM2Item { @Override public GraphTargetItem returnType() { - return new TypeItem("Object"); + return new TypeItem(new DottedChain("Object")); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NullAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NullAVM2Item.java index cd0844f94..3c2b441a4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NullAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/NullAVM2Item.java @@ -1,18 +1,19 @@ /* * Copyright (C) 2010-2015 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. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; @@ -21,6 +22,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushNullIns; import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -59,7 +61,7 @@ public class NullAVM2Item extends AVM2Item { @Override public GraphTargetItem returnType() { - return new TypeItem("null"); + return new TypeItem(new DottedChain("null")); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/UndefinedAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/UndefinedAVM2Item.java index eacf63dc7..6505d6ef1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/UndefinedAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/UndefinedAVM2Item.java @@ -1,18 +1,19 @@ /* * Copyright (C) 2010-2015 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. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; @@ -21,6 +22,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushUndefinedIns; import com.jpexs.decompiler.flash.ecma.Undefined; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -52,7 +54,7 @@ public class UndefinedAVM2Item extends AVM2Item { @Override public GraphTargetItem returnType() { - return new TypeItem("Undefined"); + return new TypeItem(new DottedChain("Undefined")); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/XMLAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/XMLAVM2Item.java index d77e20abc..123ff0405 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/XMLAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/XMLAVM2Item.java @@ -1,22 +1,24 @@ /* * Copyright (C) 2010-2015 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. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TypeItem; import com.jpexs.decompiler.graph.model.LocalData; @@ -49,7 +51,7 @@ public class XMLAVM2Item extends AVM2Item { @Override public GraphTargetItem returnType() { - return new TypeItem("XML"); + return new TypeItem(new DottedChain("XML")); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java index 93b117e15..7800ad516 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java @@ -89,7 +89,7 @@ public class DeclarationAVM2Item extends AVM2Item { if (lti.value instanceof ConvertAVM2Item) { coerType = ((ConvertAVM2Item) lti.value).type; } - srcData.declaredType = (coerType instanceof TypeItem) ? ((TypeItem) coerType).fullTypeName.toPrintableString() : "*"; + srcData.declaredType = (coerType instanceof TypeItem) ? ((TypeItem) coerType).fullTypeName.toPrintableString(true) : "*"; writer.append("var "); writer.append(localName); writer.append(":"); @@ -102,7 +102,7 @@ public class DeclarationAVM2Item extends AVM2Item { HighlightData srcData = getSrcData(); srcData.localName = ssti.getNameAsStr(localData); srcData.declaration = true; - srcData.declaredType = (type instanceof TypeItem) ? ((TypeItem) type).fullTypeName.toPrintableString() : "*"; + srcData.declaredType = (type instanceof TypeItem) ? ((TypeItem) type).fullTypeName.toPrintableString(true) : "*"; writer.append("var "); ssti.getName(writer, localData); writer.append(":"); 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 6d7d6b462..877ea7b1a 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 @@ -92,7 +92,7 @@ public class TryAVM2Item extends AVM2Item implements Block { int eti = catchExceptions.get(e).type_index; - data.declaredType = eti <= 0 ? "*" : localData.constantsAvm2.constant_multiname.get(eti).getNameWithNamespace(localData.constantsAvm2).toPrintableString(); + data.declaredType = eti <= 0 ? "*" : localData.constantsAvm2.constant_multiname.get(eti).getNameWithNamespace(localData.constantsAvm2).toPrintableString(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/model/operations/DeletePropertyAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DeletePropertyAVM2Item.java index 4c8a5f772..3a61b1943 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DeletePropertyAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DeletePropertyAVM2Item.java @@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.abc.avm2.parser.script.PropertyAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.parser.script.UnresolvedAVM2Item; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -87,7 +88,7 @@ public class DeletePropertyAVM2Item extends AVM2Item { @Override public GraphTargetItem returnType() { - return new TypeItem("Boolean"); + return new TypeItem(new DottedChain("Boolean")); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/EqAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/EqAVM2Item.java index 9d17d4562..42f364bec 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/EqAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/EqAVM2Item.java @@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfEqIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNeIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.EqualsTypeItem; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -68,6 +69,6 @@ public class EqAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi @Override public GraphTargetItem returnType() { - return new TypeItem("Boolean"); + return new TypeItem(new DottedChain("Boolean")); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GeAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GeAVM2Item.java index 8b34b4cd1..86e31fb50 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GeAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GeAVM2Item.java @@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfGeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNGeIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -74,6 +75,6 @@ public class GeAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi @Override public GraphTargetItem returnType() { - return new TypeItem("Boolean"); + return new TypeItem(new DottedChain("Boolean")); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GtAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GtAVM2Item.java index 864cdfe03..4dc3bec1f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GtAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/GtAVM2Item.java @@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfGtIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNGtIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -67,6 +68,6 @@ public class GtAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi @Override public GraphTargetItem returnType() { - return new TypeItem("Boolean"); + return new TypeItem(new DottedChain("Boolean")); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InAVM2Item.java index 45b33b01f..df7edf1e5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InAVM2Item.java @@ -1,24 +1,26 @@ /* * Copyright (C) 2010-2015 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. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.other.InIns; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -41,6 +43,6 @@ public class InAVM2Item extends BinaryOpItem { @Override public GraphTargetItem returnType() { - return new TypeItem("Boolean"); + return new TypeItem(new DottedChain("Boolean")); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InstanceOfAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InstanceOfAVM2Item.java index 04c34f44d..b472c97d5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InstanceOfAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/InstanceOfAVM2Item.java @@ -1,24 +1,26 @@ /* * Copyright (C) 2010-2015 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. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.types.InstanceOfIns; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -41,6 +43,6 @@ public class InstanceOfAVM2Item extends BinaryOpItem { @Override public GraphTargetItem returnType() { - return new TypeItem("Boolean"); + return new TypeItem(new DottedChain("Boolean")); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/IsTypeAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/IsTypeAVM2Item.java index 5515dfe58..7bf7e70ed 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/IsTypeAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/IsTypeAVM2Item.java @@ -1,24 +1,26 @@ /* * Copyright (C) 2010-2015 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. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.abc.avm2.model.operations; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.types.IsTypeLateIns; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -41,6 +43,6 @@ public class IsTypeAVM2Item extends BinaryOpItem { @Override public GraphTargetItem returnType() { - return new TypeItem("Boolean"); + return new TypeItem(new DottedChain("Boolean")); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LeAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LeAVM2Item.java index 74964cdd1..e65d2482b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LeAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LeAVM2Item.java @@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfLeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNLeIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -74,6 +75,6 @@ public class LeAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi @Override public GraphTargetItem returnType() { - return new TypeItem("Boolean"); + return new TypeItem(new DottedChain("Boolean")); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LtAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LtAVM2Item.java index 472fd1f31..a8b50a278 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LtAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/LtAVM2Item.java @@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfLtIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNLtIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -67,6 +68,6 @@ public class LtAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi @Override public GraphTargetItem returnType() { - return new TypeItem("Boolean"); + return new TypeItem(new DottedChain("Boolean")); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NeqAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NeqAVM2Item.java index e1947b5ab..344c4c8f0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NeqAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/NeqAVM2Item.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfEqIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfNeIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -69,6 +70,6 @@ public class NeqAVM2Item extends BinaryOpItem implements LogicalOpItem, IfCondit @Override public GraphTargetItem returnType() { - return new TypeItem("Boolean"); + return new TypeItem(new DottedChain("Boolean")); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictEqAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictEqAVM2Item.java index bf6ab47df..ac1ddc789 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictEqAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictEqAVM2Item.java @@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictEqIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictNeIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.EqualsTypeItem; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -71,6 +72,6 @@ public class StrictEqAVM2Item extends BinaryOpItem implements LogicalOpItem, IfC @Override public GraphTargetItem returnType() { - return new TypeItem("Boolean"); + return new TypeItem(new DottedChain("Boolean")); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictNeqAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictNeqAVM2Item.java index fba58968d..1024c1150 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictNeqAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/StrictNeqAVM2Item.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictEqIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.IfStrictNeIns; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -72,6 +73,6 @@ public class StrictNeqAVM2Item extends BinaryOpItem implements LogicalOpItem, If @Override public GraphTargetItem returnType() { - return new TypeItem("Boolean"); + return new TypeItem(new DottedChain("Boolean")); } } 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 3191ebfa6..77edde533 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 @@ -138,6 +138,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; @@ -1195,12 +1196,11 @@ public class AVM2SourceGenerator implements SourceGenerator { return abc; } - public void generateClass(List importedClasses, List sinitVariables, boolean staticNeedsActivation, List staticInit, List openedNamespaces, int namespace, int initScope, String pkg, ClassInfo classInfo, InstanceInfo instanceInfo, SourceGeneratorLocalData localData, boolean isInterface, String name, String superName, GraphTargetItem extendsVal, List implementsStr, GraphTargetItem constructor, List traitItems, Reference class_index) throws AVM2ParseException, CompilationException { + public void generateClass(List importedClasses, List sinitVariables, boolean staticNeedsActivation, List staticInit, List openedNamespaces, int namespace, int initScope, DottedChain pkg, ClassInfo classInfo, InstanceInfo instanceInfo, SourceGeneratorLocalData localData, boolean isInterface, String name, String superName, GraphTargetItem extendsVal, List implementsStr, GraphTargetItem constructor, List traitItems, Reference class_index) throws AVM2ParseException, CompilationException { localData.currentClass = name; localData.pkg = pkg; - List ret = new ArrayList<>(); if (extendsVal == null && !isInterface) { - extendsVal = new TypeItem("Object"); + extendsVal = new TypeItem(new DottedChain("Object")); } ParsedSymbol s = null; @@ -1298,7 +1298,7 @@ public class AVM2SourceGenerator implements SourceGenerator { return ret; } - public int generateClass(int namespace, ClassInfo ci, InstanceInfo ii, int initScope, String pkg, SourceGeneratorLocalData localData, AVM2Item cls, Reference class_index) throws AVM2ParseException, CompilationException { + public int generateClass(int namespace, ClassInfo ci, InstanceInfo ii, int initScope, DottedChain pkg, SourceGeneratorLocalData localData, AVM2Item cls, Reference class_index) throws AVM2ParseException, CompilationException { /*ClassInfo ci = new ClassInfo(); InstanceInfo ii = new InstanceInfo(); abc.class_info.add(ci); @@ -1405,7 +1405,7 @@ public class AVM2SourceGenerator implements SourceGenerator { return false; } - public int method(boolean subMethod, boolean isInterface, List callStack, String pkg, boolean needsActivation, List subvariables, int initScope, boolean hasRest, int line, String className, String superType, boolean constructor, SourceGeneratorLocalData localData, List paramTypes, List paramNames, List paramValues, List body, GraphTargetItem retType) throws CompilationException { + public int method(boolean subMethod, boolean isInterface, List callStack, DottedChain pkg, boolean needsActivation, List subvariables, int initScope, boolean hasRest, int line, String className, String superType, boolean constructor, SourceGeneratorLocalData localData, List paramTypes, List paramNames, List paramValues, List body, GraphTargetItem retType) throws CompilationException { //Reference hasArgs = new Reference<>(Boolean.FALSE); //calcRegisters(localData,needsActivation,paramNames,subvariables,body, hasArgs); SourceGeneratorLocalData newlocalData = new SourceGeneratorLocalData(new HashMap<>(), 1, true, 0); @@ -1868,7 +1868,7 @@ public class AVM2SourceGenerator implements SourceGenerator { return null; } - private int genNs(List importedClasses, String pkg, String custom, int namespace, List openedNamespaces, SourceGeneratorLocalData localData, int line) throws CompilationException { + private int genNs(List importedClasses, DottedChain pkg, String custom, int namespace, List openedNamespaces, SourceGeneratorLocalData localData, int line) throws CompilationException { if (custom != null) { PropertyAVM2Item prop = new PropertyAVM2Item(null, custom, abc, allABCs, openedNamespaces, new ArrayList<>()); Reference value = new Reference<>(null); @@ -1913,7 +1913,7 @@ public class AVM2SourceGenerator implements SourceGenerator { return namespace; } - public void generateTraitsPhase2(List importedClasses, String pkg, List items, Trait[] traits, List openedNamespaces, SourceGeneratorLocalData localData) throws CompilationException { + public void generateTraitsPhase2(List importedClasses, DottedChain pkg, List items, Trait[] traits, List openedNamespaces, SourceGeneratorLocalData localData) throws CompilationException { for (int k = 0; k < items.size(); k++) { GraphTargetItem item = items.get(k); if (traits[k] == null) { @@ -2173,12 +2173,12 @@ public class AVM2SourceGenerator implements SourceGenerator { } else { parentNamesAddNames(abc, allABCs, abc.instance_info.get(tc.class_info).name_index, parents, new ArrayList<>(), new ArrayList<>()); - for (int i = parents.size() - 1; i >= 1; i--) { + for (int i = parents.size() - 1; i >= 0; i--) { mbCode.add(ins(new GetLexIns(), parents.get(i))); mbCode.add(ins(new PushScopeIns())); traitScope++; } - mbCode.add(ins(new GetLexIns(), parents.get(1))); + mbCode.add(ins(new GetLexIns(), parents.get(0))); } mbCode.add(ins(new NewClassIns(), tc.class_info)); if (!abc.instance_info.get(tc.class_info).isInterface()) { @@ -2245,25 +2245,12 @@ public class AVM2SourceGenerator implements SourceGenerator { } } if (t instanceof TraitFunction) { - return new TypeItem("Function"); + return new TypeItem(new DottedChain("Function")); } return TypeItem.UNBOUNDED; } - private static boolean eq(Object a, Object b) { - if (a == null && b == null) { - return true; - } - if (a == null) { - return false; - } - if (b == null) { - return false; - } - return a.equals(b); - } - - public static boolean searchPrototypeChain(boolean instanceOnly, List abcs, String pkg, String obj, String propertyName, Reference outName, Reference outNs, Reference outPropNs, Reference outPropNsKind, Reference outPropNsIndex, Reference outPropType, Reference outPropValue) { + public static boolean searchPrototypeChain(boolean instanceOnly, List abcs, DottedChain pkg, String obj, String propertyName, Reference outName, Reference outNs, Reference outPropNs, Reference outPropNsKind, Reference outPropNsIndex, Reference outPropType, Reference outPropValue) { for (ABC abc : abcs) { if (!instanceOnly) { @@ -2272,7 +2259,7 @@ public class AVM2SourceGenerator implements SourceGenerator { continue; } for (Trait t : ii.traits.traits) { - if (eq(pkg, t.getName(abc).getNamespace(abc.constants).getName(abc.constants, true))) { + if (Objects.equals(pkg, t.getName(abc).getNamespace(abc.constants).getName(abc.constants, true))) { if (propertyName.equals(t.getName(abc).getName(abc.constants, null, true))) { outName.setVal(obj); outNs.setVal(pkg); @@ -2297,7 +2284,7 @@ public class AVM2SourceGenerator implements SourceGenerator { } Multiname clsName = ii.getName(abc.constants); if (obj.equals(clsName.getName(abc.constants, null, true))) { - if (eq(pkg, clsName.getNamespace(abc.constants).getName(abc.constants, true))) { + if (Objects.equals(pkg, clsName.getNamespace(abc.constants).getName(abc.constants, true))) { //class found for (Trait t : ii.instance_traits.traits) { @@ -2356,7 +2343,7 @@ public class AVM2SourceGenerator implements SourceGenerator { public static void parentNames(ABC abc, List allABCs, int name_index, List indices, List names, List namespaces, List outABCs) { indices.add(name_index); names.add(abc.constants.constant_multiname.get(name_index).getName(abc.constants, null, true)); - namespaces.add(abc.constants.constant_multiname.get(name_index).getNamespace(abc.constants).getName(abc.constants, true)); + namespaces.add(abc.constants.constant_multiname.get(name_index).getNamespace(abc.constants).getName(abc.constants, true).toRawString()); Multiname mname = abc.constants.constant_multiname.get(name_index); outABCs.add(abc); @@ -2370,7 +2357,7 @@ public class AVM2SourceGenerator implements SourceGenerator { Multiname m = a.constants.constant_multiname.get(a.instance_info.get(i).name_index); if (m.getName(a.constants, null, true).equals(mname.getName(abc.constants, null, true))) { - if (m.getNamespace(a.constants).hasName(mname.getNamespace(abc.constants).getName(abc.constants, true), a.constants)) { + if (m.getNamespace(a.constants).hasName(mname.getNamespace(abc.constants).getName(abc.constants, true).toRawString(), a.constants)) { //Multiname superName = a.constants.constant_multiname.get(a.instance_info.get(i).super_index); abcs.remove(a); if (a.instance_info.get(i).super_index != 0) { 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 42171b0dc..780dc013b 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 @@ -144,7 +144,7 @@ public class ActionScript3Parser { return uniqLast; } - private List commands(TypeItem thisType, String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forinlevel, List variables) throws IOException, AVM2ParseException { + private List commands(TypeItem thisType, DottedChain pkg, Reference needsActivation, List importedClasses, List openedNamespaces, Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forinlevel, List variables) throws IOException, AVM2ParseException { List ret = new ArrayList<>(); if (debugMode) { System.out.println("commands:"); @@ -159,12 +159,12 @@ public class ActionScript3Parser { return ret; } - private GraphTargetItem type(TypeItem thisType, String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem type(TypeItem thisType, DottedChain pkg, Reference needsActivation, List importedClasses, List openedNamespaces, List variables) throws IOException, AVM2ParseException { ParsedSymbol s = lex(); if (s.type == SymbolType.MULTIPLY) { return new UnboundedTypeItem(); } else if (s.type == SymbolType.VOID) { - return new TypeItem("void"); + return new TypeItem(new DottedChain("void")); } else { lexer.pushback(s); } @@ -174,7 +174,7 @@ public class ActionScript3Parser { return t; } - private GraphTargetItem memberOrCall(TypeItem thisType, String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, GraphTargetItem newcmds, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem memberOrCall(TypeItem thisType, DottedChain pkg, Reference needsActivation, List importedClasses, List openedNamespaces, GraphTargetItem newcmds, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { if (debugMode) { System.out.println("memberOrCall:"); } @@ -223,7 +223,7 @@ public class ActionScript3Parser { return ret; } - private GraphTargetItem applyType(TypeItem thisType, String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, GraphTargetItem obj, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem applyType(TypeItem thisType, DottedChain pkg, Reference needsActivation, List importedClasses, List openedNamespaces, GraphTargetItem obj, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { GraphTargetItem ret = obj; ParsedSymbol s = lex(); if (s.type == SymbolType.TYPENAME) { @@ -250,7 +250,7 @@ public class ActionScript3Parser { return ret; } - private GraphTargetItem member(TypeItem thisType, String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, GraphTargetItem obj, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem member(TypeItem thisType, DottedChain pkg, Reference needsActivation, List importedClasses, List openedNamespaces, GraphTargetItem obj, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { if (debugMode) { System.out.println("member:"); } @@ -317,7 +317,7 @@ public class ActionScript3Parser { return ret; } - private GraphTargetItem name(TypeItem thisType, String pkg, Reference needsActivation, boolean typeOnly, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, List variables, List importedClasses) throws IOException, AVM2ParseException { + private GraphTargetItem name(TypeItem thisType, DottedChain 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(); String name2 = ""; @@ -330,7 +330,7 @@ public class ActionScript3Parser { s = lex(); boolean attrBracket = false; - name.parts.add(name2); + name = name.add(name2); while (s.isType(SymbolType.DOT)) { //name += s.value.toString(); //. or :: s = lex(); @@ -353,7 +353,7 @@ public class ActionScript3Parser { expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER, SymbolType.NAMESPACE); name2 += s.value.toString(); } - name.parts.add(name2); + name = name.add(name2); s = lex(); } String nsname = null; @@ -373,7 +373,7 @@ public class ActionScript3Parser { } GraphTargetItem ret = null; - if (!name.parts.isEmpty()) { + if (!name.isEmpty()) { UnresolvedAVM2Item unr = new UnresolvedAVM2Item(new ArrayList<>(), importedClasses, typeOnly, null, lexer.yyline(), name, null, openedNamespaces); //unr.setIndex(index); variables.add(unr); @@ -439,7 +439,7 @@ public class ActionScript3Parser { return ret; } - private List call(TypeItem thisType, String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { + private List call(TypeItem thisType, DottedChain pkg, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { List ret = new ArrayList<>(); //expected(SymbolType.PARENT_OPEN); //MUST BE HANDLED BY CALLER ParsedSymbol s = lex(); @@ -454,12 +454,12 @@ public class ActionScript3Parser { return ret; } - private MethodAVM2Item method(String pkg, boolean isInterface, String customAccess, Reference needsActivation, List importedClasses, boolean override, boolean isFinal, TypeItem thisType, List openedNamespaces, boolean isStatic, int namespace, String functionName, boolean isMethod, List variables) throws IOException, AVM2ParseException { + private MethodAVM2Item method(DottedChain pkg, boolean isInterface, String customAccess, Reference needsActivation, List importedClasses, boolean override, boolean isFinal, TypeItem thisType, List openedNamespaces, boolean isStatic, int namespace, String functionName, boolean isMethod, List variables) throws IOException, AVM2ParseException { FunctionAVM2Item f = function(pkg, isInterface, needsActivation, importedClasses, namespace, thisType, openedNamespaces, functionName, isMethod, variables); return new MethodAVM2Item(f.pkg, f.isInterface, customAccess, f.needsActivation, f.hasRest, f.line, override, isFinal, isStatic, f.namespace, functionName, f.paramTypes, f.paramNames, f.paramValues, f.body, f.subvariables, f.retType); } - private FunctionAVM2Item function(String pkg, boolean isInterface, Reference needsActivation, List importedClasses, int namespace, TypeItem thisType, List openedNamespaces, String functionName, boolean isMethod, List variables) throws IOException, AVM2ParseException { + private FunctionAVM2Item function(DottedChain pkg, boolean isInterface, Reference needsActivation, List importedClasses, int namespace, TypeItem thisType, List openedNamespaces, String functionName, boolean isMethod, List variables) throws IOException, AVM2ParseException { openedNamespaces = new ArrayList<>(openedNamespaces); //local copy int line = lexer.yyline(); ParsedSymbol s; @@ -540,10 +540,10 @@ public class ActionScript3Parser { return new FunctionAVM2Item(pkg, isInterface, needsActivation2.getVal(), namespace, hasRest, line, functionName, paramTypes, paramNames, paramValues, body, subvariables, retType); } - private GraphTargetItem traits(String scriptName, boolean scriptTraits, List sinitVariables, Reference sinitNeedsActivation, List staticInitializer, List importedClasses, int privateNs, int protectedNs, int publicNs, int packageInternalNs, int protectedStaticNs, List openedNamespaces, String pkg, String classNameStr, boolean isInterface, List traits) throws AVM2ParseException, IOException, CompilationException { + private GraphTargetItem traits(String scriptName, boolean scriptTraits, List sinitVariables, Reference sinitNeedsActivation, List staticInitializer, List importedClasses, int privateNs, int protectedNs, int publicNs, int packageInternalNs, int protectedStaticNs, List openedNamespaces, DottedChain pkg, String classNameStr, boolean isInterface, List traits) throws AVM2ParseException, IOException, CompilationException { ParsedSymbol s; GraphTargetItem constr = null; - TypeItem thisType = pkg == null && classNameStr == null ? null : new TypeItem(pkg == null || "".equals(pkg) ? classNameStr : pkg + "." + classNameStr); + TypeItem thisType = pkg == null && classNameStr == null ? null : new TypeItem(pkg == null || pkg.isEmpty() ? new DottedChain(classNameStr) : pkg.add(classNameStr)); List constrVariables = new ArrayList<>(); List originalOpenedNamespaces = openedNamespaces; int originalPrivateNs = privateNs; @@ -824,7 +824,7 @@ public class ActionScript3Parser { lexer.pushback(s); } - ConstAVM2Item ns = new ConstAVM2Item(pkg, customAccess, true, namespace, nname, new TypeItem("Namespace"), new StringAVM2Item(null, nval), lexer.yyline()); + ConstAVM2Item ns = new ConstAVM2Item(pkg, customAccess, true, namespace, nname, new TypeItem(new DottedChain("Namespace")), new StringAVM2Item(null, nval), lexer.yyline()); traits.add(ns); break; case CONST: @@ -888,7 +888,7 @@ public class ActionScript3Parser { return constr; } - private GraphTargetItem classTraits(String scriptName, int gpublicNs, String pkg, List importedClasses, boolean isDynamic, boolean isFinal, List openedNamespaces, String packageName, int namespace, boolean isInterface, String nameStr, GraphTargetItem extendsStr, List implementsStr, List variables) throws IOException, AVM2ParseException, CompilationException { + private GraphTargetItem classTraits(String scriptName, int gpublicNs, DottedChain pkg, List importedClasses, boolean isDynamic, boolean isFinal, List openedNamespaces, DottedChain packageName, int namespace, boolean isInterface, String nameStr, GraphTargetItem extendsStr, List implementsStr, List variables) throws IOException, AVM2ParseException, CompilationException { GraphTargetItem ret = null; @@ -1045,7 +1045,7 @@ public class ActionScript3Parser { } } - private List xmltag(TypeItem thisType, String pkg, Reference usesVars, List openedTags, Reference closedVarTags, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { + private List xmltag(TypeItem thisType, DottedChain pkg, Reference usesVars, List openedTags, Reference closedVarTags, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { ParsedSymbol s = null; List rets = new ArrayList<>(); //GraphTargetItem ret = null; @@ -1174,7 +1174,7 @@ public class ActionScript3Parser { return rets; } - private GraphTargetItem xml(TypeItem thisType, String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem xml(TypeItem thisType, DottedChain pkg, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { List openedTags = new ArrayList<>(); int closedVarTags = 0; @@ -1185,7 +1185,7 @@ public class ActionScript3Parser { return ret; } - private GraphTargetItem command(TypeItem thisType, String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forinlevel, boolean mustBeCommand, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem command(TypeItem thisType, DottedChain pkg, Reference needsActivation, List importedClasses, List openedNamespaces, Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forinlevel, boolean mustBeCommand, List variables) throws IOException, AVM2ParseException { LexBufferer buf = new LexBufferer(); lexer.addListener(buf); GraphTargetItem ret = null; @@ -1668,7 +1668,7 @@ public class ActionScript3Parser { } - private GraphTargetItem expression(TypeItem thisType, String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem expression(TypeItem thisType, DottedChain pkg, Reference needsActivation, List importedClasses, List openedNamespaces, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, AVM2ParseException { return expression(thisType, pkg, needsActivation, importedClasses, openedNamespaces, false, registerVars, inFunction, inMethod, allowRemainder, variables); } @@ -1736,7 +1736,7 @@ public class ActionScript3Parser { return false; } - private int brackets(TypeItem thisType, String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, List ret, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { + private int brackets(TypeItem thisType, DottedChain pkg, Reference needsActivation, List importedClasses, List openedNamespaces, List ret, HashMap registerVars, boolean inFunction, boolean inMethod, List variables) throws IOException, AVM2ParseException { ParsedSymbol s = lex(); int arrCnt = 0; if (s.type == SymbolType.BRACKET_OPEN) { @@ -1760,7 +1760,7 @@ public class ActionScript3Parser { return arrCnt; } - private GraphTargetItem commaExpression(TypeItem thisType, String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forInLevel, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem commaExpression(TypeItem thisType, DottedChain pkg, Reference needsActivation, List importedClasses, List openedNamespaces, Stack loops, Map loopLabels, HashMap registerVars, boolean inFunction, boolean inMethod, int forInLevel, List variables) throws IOException, AVM2ParseException { GraphTargetItem cmd = null; List expr = new ArrayList<>(); ParsedSymbol s; @@ -1782,7 +1782,7 @@ public class ActionScript3Parser { return new CommaExpressionItem(null, expr); } - private GraphTargetItem expression(TypeItem thisType, String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, boolean allowEmpty, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem expression(TypeItem thisType, DottedChain pkg, Reference needsActivation, List importedClasses, List openedNamespaces, boolean allowEmpty, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, AVM2ParseException { GraphTargetItem prim = expressionPrimary(thisType, pkg, needsActivation, importedClasses, openedNamespaces, allowEmpty, registerVars, inFunction, inMethod, allowRemainder, variables); if (prim == null) { return null; @@ -1812,7 +1812,7 @@ public class ActionScript3Parser { return lookahead; } - private GraphTargetItem expression1(GraphTargetItem lhs, int min_precedence, TypeItem thisType, String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, boolean allowEmpty, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem expression1(GraphTargetItem lhs, int min_precedence, TypeItem thisType, DottedChain pkg, Reference needsActivation, List importedClasses, List openedNamespaces, boolean allowEmpty, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, AVM2ParseException { if (debugMode) { System.out.println("expression1:"); } @@ -2025,7 +2025,7 @@ public class ActionScript3Parser { return lhs; } - private GraphTargetItem expressionPrimary(TypeItem thisType, String pkg, Reference needsActivation, List importedClasses, List openedNamespaces, boolean allowEmpty, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, AVM2ParseException { + private GraphTargetItem expressionPrimary(TypeItem thisType, DottedChain pkg, Reference needsActivation, List importedClasses, List openedNamespaces, boolean allowEmpty, HashMap registerVars, boolean inFunction, boolean inMethod, boolean allowRemainder, List variables) throws IOException, AVM2ParseException { if (debugMode) { System.out.println("primary:"); } @@ -2260,18 +2260,18 @@ public class ActionScript3Parser { private PackageAVM2Item parsePackage(List openedNamespaces) throws IOException, AVM2ParseException, CompilationException { List items = new ArrayList<>(); expectedType(SymbolType.PACKAGE); - String name = ""; + DottedChain name = DottedChain.EMPTY; ParsedSymbol s = lex(); if (s.type != SymbolType.CURLY_OPEN) { expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER); - name = s.value.toString(); + name = name.add(s.value.toString()); s = lex(); } while (s.type != SymbolType.CURLY_OPEN) { expected(s, lexer.yyline(), SymbolType.DOT); s = lex(); expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER); - name += "." + s.value.toString(); + name.add(s.value.toString()); s = lex(); } @@ -2283,7 +2283,7 @@ public class ActionScript3Parser { s = lex(); expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER); DottedChain imp = new DottedChain(); - imp.parts.add(s.value.toString()); + imp = imp.add(s.value.toString()); s = lex(); boolean isStar = false; while (s.type == SymbolType.DOT) { @@ -2295,7 +2295,7 @@ public class ActionScript3Parser { break; } expected(s, lexer.yyline(), SymbolGroup.IDENTIFIER); - imp.parts.add(s.value.toString()); + imp = imp.add(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 2f2b05c51..d289bdd02 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 @@ -31,6 +31,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; import com.jpexs.decompiler.flash.abc.types.ValueKind; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -77,14 +78,12 @@ public class CallAVM2Item extends AVM2Item { List allAbcs = new ArrayList<>(); allAbcs.add(g.abc); allAbcs.addAll(g.allABCs); - String cname; - String pkgName = ""; - cname = localData.currentClass; - pkgName = localData.pkg; + String cname = localData.currentClass; + DottedChain pkgName = localData.pkg; GraphTargetItem obj = null; Reference outName = new Reference<>(""); - Reference outNs = new Reference<>(""); - Reference outPropNs = new Reference<>(""); + Reference outNs = new Reference<>(DottedChain.EMPTY); + Reference outPropNs = new Reference<>(DottedChain.EMPTY); Reference outPropNsKind = new Reference<>(1); Reference outPropNsIndex = new Reference<>(0); Reference outPropType = new Reference<>(null); @@ -114,13 +113,11 @@ public class CallAVM2Item extends AVM2Item { List allAbcs = new ArrayList<>(); allAbcs.add(g.abc); allAbcs.addAll(g.allABCs); - String cname; - String pkgName = ""; - cname = localData.currentClass; - pkgName = localData.pkg; + String cname = localData.currentClass; + DottedChain pkgName = localData.pkg; Reference outName = new Reference<>(""); - Reference outNs = new Reference<>(""); - Reference outPropNs = new Reference<>(""); + Reference outNs = new Reference<>(DottedChain.EMPTY); + Reference outPropNs = new Reference<>(DottedChain.EMPTY); Reference outPropNsKind = new Reference<>(1); Reference outPropNsIndex = new Reference<>(0); Reference outPropType = new Reference<>(null); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ClassAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ClassAVM2Item.java index cd49a855d..a8efef843 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ClassAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ClassAVM2Item.java @@ -57,7 +57,7 @@ public class ClassAVM2Item extends AVM2Item implements Block { public List importedClasses; - public String pkg; + public DottedChain pkg; @Override public List> getSubs() { @@ -68,7 +68,7 @@ public class ClassAVM2Item extends AVM2Item implements Block { return ret; } - public ClassAVM2Item(List importedClasses, String pkg, List openedNamespaces, int protectedNs, boolean isDynamic, boolean isFinal, int namespace, String className, GraphTargetItem extendsOp, List implementsOp, List staticInit, boolean staticInitActivation, List sinitVariables, GraphTargetItem constructor, List traits) { + public ClassAVM2Item(List importedClasses, DottedChain pkg, List openedNamespaces, int protectedNs, boolean isDynamic, boolean isFinal, int namespace, String className, GraphTargetItem extendsOp, List implementsOp, List staticInit, boolean staticInitActivation, List sinitVariables, GraphTargetItem constructor, List traits) { super(null, NOPRECEDENCE); this.importedClasses = importedClasses; this.pkg = pkg; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstAVM2Item.java index cb646c105..6e231f9fd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ConstAVM2Item.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script; import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.model.LocalData; @@ -39,7 +40,7 @@ public class ConstAVM2Item extends AVM2Item { public int line; - public String pkg; + public DottedChain pkg; public int getNamespace() { return namespace; @@ -49,7 +50,7 @@ public class ConstAVM2Item extends AVM2Item { return isStatic; } - public ConstAVM2Item(String pkg, String customNamespace, boolean isStatic, int namespace, String var, GraphTargetItem type, GraphTargetItem value, int line) { + public ConstAVM2Item(DottedChain pkg, String customNamespace, boolean isStatic, int namespace, String var, GraphTargetItem type, GraphTargetItem value, int line) { super(null, NOPRECEDENCE, value); this.pkg = pkg; this.line = line; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/FunctionAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/FunctionAVM2Item.java index 6b201fb5b..d6df407d8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/FunctionAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/FunctionAVM2Item.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -59,9 +60,9 @@ public class FunctionAVM2Item extends AVM2Item { public boolean isInterface; - public String pkg; + public DottedChain pkg; - public FunctionAVM2Item(String pkg, boolean isInterface, boolean needsActivation, int namespace, boolean hasRest, int line, String functionName, List paramTypes, List paramNames, List paramValues, List body, List subvariables, GraphTargetItem retType) { + public FunctionAVM2Item(DottedChain pkg, boolean isInterface, boolean needsActivation, int namespace, boolean hasRest, int line, String functionName, List paramTypes, List paramNames, List paramValues, List body, List subvariables, GraphTargetItem retType) { super(null, NOPRECEDENCE); this.pkg = pkg; this.needsActivation = needsActivation; @@ -85,7 +86,7 @@ public class FunctionAVM2Item extends AVM2Item { @Override public GraphTargetItem returnType() { - return new TypeItem("Function"); + return new TypeItem(new DottedChain("Function")); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/GetterAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/GetterAVM2Item.java index 425f84ddb..5740ab150 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/GetterAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/GetterAVM2Item.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.abc.avm2.parser.script; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import java.util.List; @@ -25,7 +26,7 @@ import java.util.List; */ public class GetterAVM2Item extends MethodAVM2Item { - public GetterAVM2Item(String pkg, boolean isInterface, String customNamespace, boolean needsActivation, boolean hasRest, int line, boolean override, boolean isFinal, boolean isStatic, int namespace, String methodName, List paramTypes, List paramNames, List paramValues, List body, List subvariables, GraphTargetItem retType) { + public GetterAVM2Item(DottedChain pkg, boolean isInterface, String customNamespace, boolean needsActivation, boolean hasRest, int line, boolean override, boolean isFinal, boolean isStatic, int namespace, String methodName, List paramTypes, List paramNames, List paramValues, List body, List subvariables, GraphTargetItem retType) { super(pkg, isInterface, customNamespace, needsActivation, hasRest, line, override, isFinal, isStatic, namespace, methodName, paramTypes, paramNames, paramValues, body, subvariables, retType); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/InterfaceAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/InterfaceAVM2Item.java index 70d5625e4..d4fb23155 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/InterfaceAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/InterfaceAVM2Item.java @@ -42,11 +42,11 @@ public class InterfaceAVM2Item extends AVM2Item { public List openedNamespaces; - public String pkg; + public DottedChain pkg; public List importedClasses; - public InterfaceAVM2Item(List importedClasses, String pkg, List openedNamespaces, boolean isFinal, int namespace, String name, List superInterfaces, List traits) { + public InterfaceAVM2Item(List importedClasses, DottedChain pkg, List openedNamespaces, boolean isFinal, int namespace, String name, List superInterfaces, List traits) { super(null, NOPRECEDENCE); this.importedClasses = importedClasses; this.pkg = pkg; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/MethodAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/MethodAVM2Item.java index bdb836735..80ad71974 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/MethodAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/MethodAVM2Item.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.model.LocalData; import java.util.List; @@ -37,7 +38,7 @@ public class MethodAVM2Item extends FunctionAVM2Item { public boolean isInterface; - public MethodAVM2Item(String pkg, boolean isInterface, String customNamespace, boolean needsActivation, boolean hasRest, int line, boolean override, boolean isFinal, boolean isStatic, int namespace, String methodName, List paramTypes, List paramNames, List paramValues, List body, List subvariables, GraphTargetItem retType) { + public MethodAVM2Item(DottedChain pkg, boolean isInterface, String customNamespace, boolean needsActivation, boolean hasRest, int line, boolean override, boolean isFinal, boolean isStatic, int namespace, String methodName, List paramTypes, List paramNames, List paramValues, List body, List subvariables, GraphTargetItem retType) { super(pkg, isInterface, needsActivation, namespace, hasRest, line, methodName, paramTypes, paramNames, paramValues, body, subvariables, retType); this.isStatic = isStatic; this.override = override; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespacedAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespacedAVM2Item.java index 166cc1ab6..85fc5bb56 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespacedAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/NamespacedAVM2Item.java @@ -36,6 +36,7 @@ import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.NamespaceSet; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -116,10 +117,10 @@ public class NamespacedAVM2Item extends AssignableAVM2Item { */ if (name != null) { return toSourceMerge(localData, generator, - ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem("Namespace")), + ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(new DottedChain("Namespace"))), ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)), dupSetTemp(localData, generator, name_temp), - ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem("Namespace")), + ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(new DottedChain("Namespace"))), dupSetTemp(localData, generator, ns_temp), //Start get original //getTemp(localData, generator, ns_temp), generateCoerce(generator, "Namespace"), ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAME, g.abc.constants.getStringId(variableName, true), 0, 0, 0, new ArrayList()), true)), @@ -168,8 +169,8 @@ public class NamespacedAVM2Item extends AssignableAVM2Item { if (name == null) { if (assignedValue != null) { return toSourceMerge(localData, generator, - obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem("Namespace")) : null, nameItem, ins(new ConvertSIns()), obj != null ? obj : ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true)), - ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem("Namespace")), nameItem, ins(new ConvertSIns()), assignedValue, + obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(new DottedChain("Namespace"))) : null, nameItem, ins(new ConvertSIns()), obj != null ? obj : ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true)), + ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(new DottedChain("Namespace"))), nameItem, ins(new ConvertSIns()), assignedValue, needsReturn ? dupSetTemp(localData, generator, ret_temp) : null, ins(new SetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true)), needsReturn ? getTemp(localData, generator, ret_temp) : null, @@ -177,9 +178,9 @@ public class NamespacedAVM2Item extends AssignableAVM2Item { ); } else { return toSourceMerge(localData, generator, - obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem("Namespace")) : null, nameItem, ins(new ConvertSIns()), obj != null ? obj : ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true)), + obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(new DottedChain("Namespace"))) : null, nameItem, ins(new ConvertSIns()), obj != null ? obj : ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true)), call ? dupSetTemp(localData, generator, obj_temp) : null, - ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem("Namespace")), nameItem, ins(new ConvertSIns()), + ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(new DottedChain("Namespace"))), nameItem, ins(new ConvertSIns()), construct ? callargs : null, ins(construct ? new ConstructPropIns() : delete ? new DeletePropertyIns() : new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.RTQNAMEL, 0, 0, 0, 0, new ArrayList<>()), true), construct ? callargs.size() : null), call ? getTemp(localData, generator, obj_temp) : null, @@ -192,8 +193,8 @@ public class NamespacedAVM2Item extends AssignableAVM2Item { } else { if (assignedValue != null) { return toSourceMerge(localData, generator, - obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem("Namespace")) : null, obj != null ? obj : ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)), - ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem("Namespace")), assignedValue, + obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(new DottedChain("Namespace"))) : null, obj != null ? obj : ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)), + ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(new DottedChain("Namespace"))), assignedValue, needsReturn ? dupSetTemp(localData, generator, ret_temp) : null, ins(new SetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)), needsReturn ? getTemp(localData, generator, ret_temp) : null, @@ -201,9 +202,9 @@ public class NamespacedAVM2Item extends AssignableAVM2Item { ); } else { return toSourceMerge(localData, generator, - obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem("Namespace")) : null, obj != null ? obj : ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)), + obj == null ? ns : null, obj == null ? NameAVM2Item.generateCoerce(localData, generator, new TypeItem(new DottedChain("Namespace"))) : null, obj != null ? obj : ins(new FindPropertyStrictIns(), g.abc.constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true)), call ? dupSetTemp(localData, generator, obj_temp) : null, - ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem("Namespace")), + ns, NameAVM2Item.generateCoerce(localData, generator, new TypeItem(new DottedChain("Namespace"))), construct ? callargs : null, ins(construct ? new ConstructPropIns() : delete ? new DeletePropertyIns() : new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(attr ? Multiname.RTQNAMEA : Multiname.RTQNAME, g.abc.constants.getStringId(name, true), 0, 0, 0, new ArrayList<>()), true), construct ? callargs.size() : null), call ? getTemp(localData, generator, obj_temp) : null, diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PackageAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PackageAVM2Item.java index 65e16378d..7f43c043a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PackageAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PackageAVM2Item.java @@ -33,13 +33,13 @@ public class PackageAVM2Item extends AVM2Item { public List items; - public String packageName; + public DottedChain packageName; public List importedClasses = new ArrayList<>(); public int publicNs = 0; - public PackageAVM2Item(int publicNs, List importedClasses, String packageName, List items) { + public PackageAVM2Item(int publicNs, List importedClasses, DottedChain packageName, List items) { super(null, NOPRECEDENCE); this.publicNs = publicNs; this.importedClasses = importedClasses; 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 99274526a..fe6df1767 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 @@ -33,6 +33,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertDIns; import com.jpexs.decompiler.flash.abc.avm2.model.ApplyTypeAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.InitVectorAVM2Item; import com.jpexs.decompiler.flash.abc.types.InstanceInfo; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.Multiname; @@ -44,6 +45,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -195,19 +197,19 @@ public class PropertyAVM2Item extends AssignableAVM2Item { List abcs = new ArrayList<>(); abcs.add(abc); abcs.addAll(otherABCs); - if (ttype.equals(new TypeItem("__AS3__.vec.Vector"))) { + if (ttype.equals(new TypeItem(InitVectorAVM2Item.VECTOR_FQN))) { switch ("" + objSubType) { case "int": - ttype = new TypeItem("__AS3__.vec.Vector$int"); + ttype = new TypeItem(InitVectorAVM2Item.VECTOR_INT); break; case "Number": - ttype = new TypeItem("__AS3__.vec.Vector$double"); + ttype = new TypeItem(InitVectorAVM2Item.VECTOR_DOUBLE); break; case "uint": - ttype = new TypeItem("__AS3__.vec.Vector$uint"); + ttype = new TypeItem(InitVectorAVM2Item.VECTOR_UINT); break; default: - ttype = new TypeItem("__AS3__.vec.Vector$object"); + ttype = new TypeItem(InitVectorAVM2Item.VECTOR_OBJECT); } } loopa: @@ -219,8 +221,8 @@ public class PropertyAVM2Item extends AssignableAVM2Item { Multiname m = ii.getName(a.constants); if (multinameToType(ii.name_index, a.constants).equals(ttype)) { Reference outName = new Reference<>(""); - Reference outNs = new Reference<>(""); - Reference outPropNs = new Reference<>(""); + Reference outNs = new Reference<>(DottedChain.EMPTY); + Reference outPropNs = new Reference<>(DottedChain.EMPTY); Reference outPropNsKind = new Reference<>(1); Reference outPropNsIndex = new Reference<>(0); Reference outPropType = new Reference<>(null); @@ -248,7 +250,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { if (t.getName(abc).getName(abc.constants, null, true).equals(propertyName)) { if (t instanceof TraitSlotConst) { TraitSlotConst tsc = (TraitSlotConst) t; - objType = new TypeItem("Function"); + objType = new TypeItem(new DottedChain("Function")); propType = multinameToType(tsc.type_index, abc.constants); propIndex = tsc.name_index; if (!localData.traitUsages.containsKey(b)) { @@ -264,7 +266,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { for (int i = 0; i < openedNamespaces.size(); i++) { int nsindex = openedNamespaces.get(i); int nsKind = abc.constants.constant_namespace.get(openedNamespaces.get(i)).kind; - String nsname = abc.constants.constant_namespace.get(openedNamespaces.get(i)).getName(abc.constants, true); + DottedChain nsname = abc.constants.constant_namespace.get(openedNamespaces.get(i)).getName(abc.constants, true); int name_index = 0; for (int m = 1; m < abc.constants.constant_multiname.size(); m++) { Multiname mname = abc.constants.constant_multiname.get(m); @@ -310,7 +312,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { } for (Trait t : si.traits.traits) { if (t.name_index == name_index) { - objType = new TypeItem("Object"); + objType = new TypeItem(new DottedChain("Object")); propType = AVM2SourceGenerator.getTraitReturnType(abc, t); propIndex = t.name_index; if (t instanceof TraitSlotConst) { @@ -336,8 +338,8 @@ public class PropertyAVM2Item extends AssignableAVM2Item { Multiname n = a.constants.constant_multiname.get(ii.name_index); if (n.getNamespace(a.constants).kind == Namespace.KIND_PACKAGE && n.getNamespace(a.constants).getName(a.constants, true).equals(nsname)) { Reference outName = new Reference<>(""); - Reference outNs = new Reference<>(""); - Reference outPropNs = new Reference<>(""); + Reference outNs = new Reference<>(DottedChain.EMPTY); + Reference outPropNs = new Reference<>(DottedChain.EMPTY); Reference outPropNsKind = new Reference<>(1); Reference outPropNsIndex = new Reference<>(0); Reference outPropType = new Reference<>(null); @@ -622,13 +624,11 @@ public class PropertyAVM2Item extends AssignableAVM2Item { Object obj = object; if (obj == null) { - String cname; - String pkgName = ""; - cname = localData.currentClass; - pkgName = localData.pkg; + String cname = localData.currentClass; + DottedChain pkgName = localData.pkg; Reference outName = new Reference<>(""); - Reference outNs = new Reference<>(""); - Reference outPropNs = new Reference<>(""); + Reference outNs = new Reference<>(DottedChain.EMPTY); + Reference outPropNs = new Reference<>(DottedChain.EMPTY); Reference outPropNsKind = new Reference<>(1); Reference outPropNsIndex = new Reference<>(0); Reference outPropType = new Reference<>(null); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/SetterAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/SetterAVM2Item.java index 4f7b33ab3..3b57def5d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/SetterAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/SetterAVM2Item.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.abc.avm2.parser.script; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import java.util.List; @@ -25,7 +26,7 @@ import java.util.List; */ public class SetterAVM2Item extends MethodAVM2Item { - public SetterAVM2Item(String pkg, boolean isInterface, String customNamespace, boolean needsActivation, boolean hasRest, int line, boolean override, boolean isFinal, boolean isStatic, int namespace, String methodName, List paramTypes, List paramNames, List paramValues, List body, List subvariables, GraphTargetItem retType) { + public SetterAVM2Item(DottedChain pkg, boolean isInterface, String customNamespace, boolean needsActivation, boolean hasRest, int line, boolean override, boolean isFinal, boolean isStatic, int namespace, String methodName, List paramTypes, List paramNames, List paramValues, List body, List subvariables, GraphTargetItem retType) { super(pkg, isInterface, customNamespace, needsActivation, hasRest, line, override, isFinal, isStatic, namespace, methodName, paramTypes, paramNames, paramValues, body, subvariables, retType); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/SlotAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/SlotAVM2Item.java index 287d4648e..6acb087ad 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/SlotAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/SlotAVM2Item.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script; import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.model.LocalData; @@ -39,7 +40,7 @@ public class SlotAVM2Item extends AVM2Item { public int line; - public String pkg; + public DottedChain pkg; public int getNamespace() { return namespace; @@ -49,7 +50,7 @@ public class SlotAVM2Item extends AVM2Item { return isStatic; } - public SlotAVM2Item(String pkg, String customNamespace, boolean isStatic, int namespace, String var, GraphTargetItem type, GraphTargetItem value, int line) { + public SlotAVM2Item(DottedChain pkg, String customNamespace, boolean isStatic, int namespace, String var, GraphTargetItem type, GraphTargetItem value, int line) { super(null, NOPRECEDENCE, value); this.pkg = pkg; this.line = line; 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 9673872b4..4d3014aa1 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 @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceAIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceSIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.types.ConvertIIns; +import com.jpexs.decompiler.flash.abc.avm2.model.InitVectorAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.NanAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item; @@ -127,7 +128,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { */ public void appendName(String name) { - this.name.parts.add(name); + this.name = this.name.add(name); } public void setDefinition(boolean definition) { @@ -289,26 +290,25 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { } public GraphTargetItem resolve(GraphTargetItem thisType, List paramTypes, List paramNames, ABC abc, List otherAbcs, List callStack, List variables) throws CompilationException { - List parts = name.parts; if (scopeStack.isEmpty()) { //Everything is multiname property in with command //search for variable for (AssignableAVM2Item a : variables) { if (a instanceof NameAVM2Item) { NameAVM2Item n = (NameAVM2Item) a; - if (n.isDefinition() && parts.get(0).equals(n.getVariableName())) { - NameAVM2Item ret = new NameAVM2Item(n.type, n.line, parts.get(0), null, false, openedNamespaces); + if (n.isDefinition() && name.get(0).equals(n.getVariableName())) { + NameAVM2Item ret = new NameAVM2Item(n.type, n.line, name.get(0), null, false, openedNamespaces); ret.setSlotScope(n.getSlotScope()); ret.setSlotNumber(n.getSlotNumber()); ret.setRegNumber(n.getRegNumber()); resolved = ret; - for (int i = 1; i < parts.size(); i++) { - resolved = new PropertyAVM2Item(resolved, parts.get(i), abc, otherAbcs, openedNamespaces, new ArrayList<>()); - if (i == parts.size() - 1) { + for (int i = 1; i < name.size(); i++) { + resolved = new PropertyAVM2Item(resolved, name.get(i), abc, otherAbcs, openedNamespaces, new ArrayList<>()); + if (i == name.size() - 1) { ((PropertyAVM2Item) resolved).assignedValue = assignedValue; } } - if (parts.size() == 1) { + if (name.size() == 1) { ret.setAssignedValue(assignedValue); } ret.setNs(n.getNs()); @@ -321,16 +321,16 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { for (DottedChain imp : importedClasses) { String impName = imp.getLast(); - if (impName.equals(parts.get(0))) { + if (impName.equals(name.get(0))) { TypeItem ret = new TypeItem(imp); resolved = ret; - for (int i = 1; i < parts.size(); i++) { - resolved = new PropertyAVM2Item(resolved, parts.get(i), abc, otherAbcs, openedNamespaces, new ArrayList<>()); - if (i == parts.size() - 1) { + for (int i = 1; i < name.size(); i++) { + resolved = new PropertyAVM2Item(resolved, name.get(i), abc, otherAbcs, openedNamespaces, new ArrayList<>()); + if (i == name.size() - 1) { ((PropertyAVM2Item) resolved).assignedValue = assignedValue; } } - if (parts.size() == 1 && assignedValue != null) { + if (name.size() == 1 && assignedValue != null) { throw new CompilationException("Cannot assign type", line); } return resolvedRoot = ret; @@ -341,26 +341,26 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { List allAbcs = new ArrayList<>(); allAbcs.add(abc); allAbcs.addAll(otherAbcs); - for (int i = 0; i < parts.size(); i++) { - DottedChain fname = new DottedChain(parts.subList(0, i + 1)); //Helper.joinStrings(parts.subList(0, i + 1), "."); + for (int i = 0; i < name.size(); i++) { + DottedChain fname = name.subChain(i + 1); for (ABC a : allAbcs) { for (int c = 0; c < a.instance_info.size(); c++) { if (a.instance_info.get(c).deleted) { continue; } if (a.instance_info.get(c).name_index > 0 && fname.equals(a.instance_info.get(c).getName(a.constants).getNameWithNamespace(a.constants))) { - if (!subtypes.isEmpty() && parts.size() > i + 1) { + if (!subtypes.isEmpty() && name.size() > i + 1) { continue; } TypeItem ret = new TypeItem(fname); resolved = ret; - for (int j = i + 1; j < parts.size(); j++) { - resolved = new PropertyAVM2Item(resolved, parts.get(j), abc, otherAbcs, openedNamespaces, new ArrayList<>()); - if (j == parts.size() - 1) { + for (int j = i + 1; j < name.size(); j++) { + resolved = new PropertyAVM2Item(resolved, name.get(j), abc, otherAbcs, openedNamespaces, new ArrayList<>()); + if (j == name.size() - 1) { ((PropertyAVM2Item) resolved).assignedValue = assignedValue; } } - if (parts.size() == i + 1 && assignedValue != null) { + if (name.size() == i + 1 && assignedValue != null) { throw new CompilationException("Cannot assign type", line); } @@ -382,10 +382,10 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { continue; } if ((a.instance_info.get(c).getName(a.constants) != null && a == abc && a.instance_info.get(c).getName(a.constants).namespace_index == ni) - || (ons.kind != Namespace.KIND_PRIVATE && a.instance_info.get(c).getName(a.constants) != null && a.instance_info.get(c).getName(a.constants).getNamespace(a.constants) != null && a.instance_info.get(c).getName(a.constants).getNamespace(a.constants).hasName(ons.getName(abc.constants, true), a.constants))) { + || (ons.kind != Namespace.KIND_PRIVATE && a.instance_info.get(c).getName(a.constants) != null && a.instance_info.get(c).getName(a.constants).getNamespace(a.constants) != null && a.instance_info.get(c).getName(a.constants).getNamespace(a.constants).hasName(ons.getName(abc.constants, true).toRawString(), a.constants))) { String cname = a.instance_info.get(c).getName(a.constants).getName(a.constants, null, true); - if (parts.get(0).equals(cname)) { - if (!subtypes.isEmpty() && parts.size() > 1) { + if (name.get(0).equals(cname)) { + if (!subtypes.isEmpty() && name.size() > 1) { continue; } TypeItem ret = new TypeItem(a.instance_info.get(c).getName(a.constants).getNameWithNamespace(a.constants)); @@ -399,13 +399,13 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { ret.subtypes.add(st.fullTypeName); }*/ resolved = ret; - for (int i = 1; i < parts.size(); i++) { - resolved = new PropertyAVM2Item(resolved, parts.get(i), abc, otherAbcs, openedNamespaces, new ArrayList<>()); - if (i == parts.size() - 1) { + for (int i = 1; i < name.size(); i++) { + resolved = new PropertyAVM2Item(resolved, name.get(i), abc, otherAbcs, openedNamespaces, new ArrayList<>()); + if (i == name.size() - 1) { ((PropertyAVM2Item) resolved).assignedValue = assignedValue; } } - if (parts.size() == 1 && assignedValue != null) { + if (name.size() == 1 && assignedValue != null) { throw new CompilationException("Cannot assign type", line); } @@ -416,26 +416,26 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { } } - if (parts.get(0).equals("this") || parts.get(0).equals("super")) { + if (name.get(0).equals("this") || name.get(0).equals("super")) { if (thisType == null) { throw new CompilationException("Cannot use this in that context", line); } - NameAVM2Item ret = new NameAVM2Item(thisType, line, parts.get(0), null, false, openedNamespaces); + NameAVM2Item ret = new NameAVM2Item(thisType, line, name.get(0), null, false, openedNamespaces); resolved = ret; - for (int i = 1; i < parts.size(); i++) { - resolved = new PropertyAVM2Item(resolved, parts.get(i), abc, otherAbcs, openedNamespaces, new ArrayList<>()); - if (i == parts.size() - 1) { + for (int i = 1; i < name.size(); i++) { + resolved = new PropertyAVM2Item(resolved, name.get(i), abc, otherAbcs, openedNamespaces, new ArrayList<>()); + if (i == name.size() - 1) { ((PropertyAVM2Item) resolved).assignedValue = assignedValue; } } - if (parts.size() == 1) { + if (name.size() == 1) { ret.setAssignedValue(assignedValue); } return resolvedRoot = ret; } - if (paramNames.contains(parts.get(0)) || parts.get(0).equals("arguments")) { - int ind = paramNames.indexOf(parts.get(0)); + if (paramNames.contains(name.get(0)) || name.get(0).equals("arguments")) { + int ind = paramNames.indexOf(name.get(0)); GraphTargetItem t = TypeItem.UNBOUNDED; if (ind == -1) { @@ -443,22 +443,22 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { t = paramTypes.get(ind); } //else rest parameter - GraphTargetItem ret = new NameAVM2Item(t, line, parts.get(0), null, false, openedNamespaces); + GraphTargetItem ret = new NameAVM2Item(t, line, name.get(0), null, false, openedNamespaces); resolved = ret; - for (int i = 1; i < parts.size(); i++) { - resolved = new PropertyAVM2Item(resolved, parts.get(i), abc, otherAbcs, openedNamespaces, new ArrayList<>()); - if (i == parts.size() - 1) { + for (int i = 1; i < name.size(); i++) { + resolved = new PropertyAVM2Item(resolved, name.get(i), abc, otherAbcs, openedNamespaces, new ArrayList<>()); + if (i == name.size() - 1) { ((PropertyAVM2Item) resolved).assignedValue = assignedValue; } } - if (parts.size() == 1) { + if (name.size() == 1) { ((NameAVM2Item) ret).setAssignedValue(assignedValue); } return resolvedRoot = ret; } - if (/*!subtypes.isEmpty() && */parts.size() == 1 && parts.get(0).equals("Vector")) { - TypeItem ret = new TypeItem("__AS3__.vec.Vector"); + if (/*!subtypes.isEmpty() && */name.size() == 1 && name.get(0).equals("Vector")) { + TypeItem ret = new TypeItem(InitVectorAVM2Item.VECTOR_FQN); /*for (String s : subtypes) { UnresolvedAVM2Item su = new UnresolvedAVM2Item(new ArrayList<>(), importedClasses, true, null, line, s, null, openedNamespaces); su.resolve(thisType, paramTypes, paramNames, abc, otherAbcs, callStack, variables); @@ -477,13 +477,13 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { } resolved = null; GraphTargetItem ret = null; - for (int i = 0; i < parts.size(); i++) { - resolved = new PropertyAVM2Item(resolved, parts.get(i), abc, otherAbcs, openedNamespaces, callStack); + for (int i = 0; i < name.size(); i++) { + resolved = new PropertyAVM2Item(resolved, name.get(i), abc, otherAbcs, openedNamespaces, callStack); if (ret == null) { ((PropertyAVM2Item) resolved).scopeStack = scopeStack; ret = resolved; } - if (i == parts.size() - 1) { + if (i == name.size() - 1) { ((PropertyAVM2Item) resolved).setAssignedValue(assignedValue); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/XMLAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/XMLAVM2Item.java index c881a6a72..169dda052 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/XMLAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/XMLAVM2Item.java @@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.Namespace; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -54,7 +55,7 @@ public class XMLAVM2Item extends AVM2Item { @Override public GraphTargetItem returnType() { - return new TypeItem("XML"); + return new TypeItem(new DottedChain("XML")); } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/XMLFilterAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/XMLFilterAVM2Item.java index 7f18cf4f2..b0b3eec3b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/XMLFilterAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/XMLFilterAVM2Item.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData; import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -55,7 +56,7 @@ public class XMLFilterAVM2Item extends AVM2Item { @Override public GraphTargetItem returnType() { - return new TypeItem("String"); + return new TypeItem(new DottedChain("String")); } @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 f6925af4e..5e1298dfa 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 @@ -100,7 +100,7 @@ public class InstanceInfo { writer.hilightSpecial(abc.constants.getMultiname(name_index).getName(abc.constants, null/* No full names here*/, false), HighlightSpecialType.CLASS_NAME); if (super_index > 0) { - String typeName = abc.constants.getMultiname(super_index).getNameWithNamespace(abc.constants).toPrintableString(); + String typeName = abc.constants.getMultiname(super_index).getNameWithNamespace(abc.constants).toPrintableString(true); writer.appendNoHilight(" extends "); writer.hilightSpecial(abc.constants.getMultiname(super_index).getName(abc.constants, fullyQualifiedNames, false), HighlightSpecialType.TYPE_NAME, typeName); } @@ -114,7 +114,7 @@ public class InstanceInfo { if (i > 0) { writer.append(", "); } - String typeName = abc.constants.getMultiname(interfaces[i]).getNameWithNamespace(abc.constants).toPrintableString(); + String typeName = abc.constants.getMultiname(interfaces[i]).getNameWithNamespace(abc.constants).toPrintableString(true); writer.hilightSpecial(abc.constants.getMultiname(interfaces[i]).getName(abc.constants, fullyQualifiedNames, false), 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 5e32ff6c0..dda32b07e 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 @@ -311,7 +311,7 @@ public class MethodInfo { } String ptype = "*"; if (param_types[i] > 0) { - ptype = constants.getMultiname(param_types[i]).getNameWithNamespace(constants).toPrintableString(); + ptype = constants.getMultiname(param_types[i]).getNameWithNamespace(constants).toPrintableString(true); } HighlightData pdata = new HighlightData(); 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 2189a7a49..477451686 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 @@ -21,7 +21,6 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.types.annotations.Internal; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.helpers.Helper; -import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -189,7 +188,7 @@ public class Multiname { } int type = constants.getNamespace(index).kind; int name_index = constants.getNamespace(index).name_index; - String name = name_index == 0 ? null : constants.getNamespace(index).getName(constants, true); + String name = name_index == 0 ? null : constants.getNamespace(index).getName(constants, true).toRawString(); int sub = -1; for (int n = 1; n < constants.getNamespaceCount(); n++) { if (constants.getNamespace(n).kind == type && constants.getNamespace(n).name_index == name_index) { @@ -296,27 +295,19 @@ public class Multiname { String name = constants.getString(name_index); if (fullyQualifiedNames != null && fullyQualifiedNames.contains(name)) { DottedChain dc = getNameWithNamespace(constants); - return raw ? dc.toString() : dc.toPrintableString(); + return raw ? dc.toString() : dc.toPrintableString(true); } return (isAttribute() ? "@" : "") + (raw ? name : IdentifiersDeobfuscation.printIdentifier(true, name)); } } public DottedChain getNameWithNamespace(AVM2ConstantPool constants) { - StringBuilder ret = new StringBuilder(); Namespace ns = getNamespace(constants); - List chain = new ArrayList<>(); + String name = getName(constants, null, true); if (ns != null) { - String nsname = ns.getName(constants, true); - if (nsname != null && !nsname.isEmpty()) { - String parts[] = nsname.split("\\."); - for (String p : parts) { - chain.add(p); - } - } + return ns.getName(constants, true).add(name); } - chain.add(getName(constants, null, true)); - return new DottedChain(chain); + return new DottedChain(name); } public Namespace getNamespace(AVM2ConstantPool constants) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Namespace.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Namespace.java index 37bdb280b..3c9556e68 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Namespace.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/Namespace.java @@ -16,10 +16,10 @@ */ package com.jpexs.decompiler.flash.abc.types; -import com.jpexs.decompiler.flash.IdentifiersDeobfuscation; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.types.annotations.Internal; +import com.jpexs.decompiler.graph.DottedChain; public class Namespace { @@ -94,7 +94,7 @@ public class Namespace { } public String toString(AVM2ConstantPool constants) { - return getName(constants, false); + return getName(constants, false).toPrintableString(true); } public String getNameWithKind(AVM2ConstantPool constants) { @@ -114,14 +114,12 @@ public class Namespace { return kindStr; } - public String getName(AVM2ConstantPool constants, boolean raw) { + public DottedChain getName(AVM2ConstantPool constants, boolean raw) { if (name_index == 0) { - return null; + return DottedChain.EMPTY; } - if (raw) { - return constants.getString(name_index); - } - return IdentifiersDeobfuscation.printNamespace(true, constants.getString(name_index)); + + return constants.getDottedChain(name_index); } public boolean hasName(String name, AVM2ConstantPool constants) { 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 a11dc73e5..b1c95340a 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 @@ -73,7 +73,7 @@ public class ScriptInfo { Namespace ns = name.getNamespace(abc.constants); if ((ns.kind == Namespace.KIND_PACKAGE_INTERNAL) || (ns.kind == Namespace.KIND_PACKAGE)) { - String packageName = ns.getName(abc.constants, false); // assume not null package + DottedChain packageName = ns.getName(abc.constants, false); // assume not null package String objectName = name.getName(abc.constants, null, false); List traitIndices = new ArrayList<>(); @@ -83,7 +83,7 @@ public class ScriptInfo { otherTraits.clear(); } - if (packagePrefix == null || packageName.startsWith(packagePrefix)) { + if (packagePrefix == null || packageName.toPrintableString(true).startsWith(packagePrefix)) { ClassPath cp = new ClassPath(packageName, objectName); ret.add(new ScriptPack(cp, abc, allAbcs, scriptIndex, traitIndices)); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ValueKind.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ValueKind.java index 097adcda7..9993a2bb6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ValueKind.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/ValueKind.java @@ -157,7 +157,7 @@ public class ValueKind { case CONSTANT_ExplicitNamespace: case CONSTANT_StaticProtectedNs: case CONSTANT_PrivateNs: - ret = "\"" + constants.getNamespace(value_index).getName(constants, true) + "\""; //assume not null name + ret = "\"" + constants.getNamespace(value_index).getName(constants, true).toRawString() + "\""; //assume not null name break; } 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 c7a68e6a4..23c90a3ec 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 @@ -140,7 +140,7 @@ public abstract class Trait implements Cloneable, Serializable { public GraphTextWriter toStringPackaged(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { Namespace ns = abc.constants.getMultiname(name_index).getNamespace(abc.constants); if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) { - String nsname = ns.getName(abc.constants, false); + String nsname = ns.getName(abc.constants, false).toPrintableString(true); writer.appendNoHilight("package"); if (!nsname.isEmpty()) { writer.appendNoHilight(" " + nsname); //assume not null name @@ -156,7 +156,7 @@ public abstract class Trait implements Cloneable, Serializable { public void convertPackaged(Trait parent, String path, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, NulWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { Namespace ns = abc.constants.getMultiname(name_index).getNamespace(abc.constants); if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) { - String nsname = ns.getName(abc.constants, false); + String nsname = ns.getName(abc.constants, false).toPrintableString(true); convert(parent, path + nsname, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); } } @@ -183,8 +183,8 @@ public abstract class Trait implements Cloneable, Serializable { public ClassPath getPath(ABC abc) { Multiname name = getName(abc); Namespace ns = name.getNamespace(abc.constants); - String packageName = ns.getName(abc.constants, false); - String objectName = name.getName(abc.constants, null, false); + DottedChain packageName = ns.getName(abc.constants, false); + String objectName = name.getName(abc.constants, null, true); return new ClassPath(packageName, objectName); //assume not null name } 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 7eb4e710c..6d38d1080 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 @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.other.FindPropertyStrict import com.jpexs.decompiler.flash.abc.avm2.instructions.other.GetLexIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.types.AsTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceIns; +import com.jpexs.decompiler.flash.abc.avm2.model.InitVectorAVM2Item; import com.jpexs.decompiler.flash.abc.types.ABCException; import com.jpexs.decompiler.flash.abc.types.ClassInfo; import com.jpexs.decompiler.flash.abc.types.InstanceInfo; @@ -95,13 +96,13 @@ public class TraitClass extends Trait implements TraitWithSlot { return "Class " + abc.constants.getMultiname(name_index).toString(abc.constants, fullyQualifiedNames) + " slot=" + slot_id + " class_info=" + class_info + " metadata=" + Helper.intArrToString(metadata); } - private boolean parseUsagesFromNS(ABC abc, List imports, List uses, int namespace_index, String ignorePackage, String name) { + private boolean parseUsagesFromNS(ABC abc, List imports, List uses, int namespace_index, DottedChain ignorePackage, String name) { Namespace ns = abc.constants.getNamespace(namespace_index); if (name.isEmpty()) { name = "*"; } - String nsname = ns.getName(abc.constants, ns.kind == Namespace.KIND_NAMESPACE); - DottedChain newimport = nsname == null ? new DottedChain() : new DottedChain(nsname.split("\\.")); + boolean raw = ns.kind == Namespace.KIND_NAMESPACE; + DottedChain newimport = ns.getName(abc.constants, raw); /*if ((ns.kind != Namespace.KIND_PACKAGE) && (ns.kind != Namespace.KIND_NAMESPACE) && (ns.kind != Namespace.KIND_STATIC_PROTECTED)) { @@ -111,23 +112,21 @@ public class TraitClass extends Trait implements TraitWithSlot { DottedChain oldimport = newimport; newimport = new DottedChain(); for (ABCContainerTag abcTag : abc.getAbcTags()) { - DottedChain newname = abcTag.getABC().nsValueToName(oldimport == null ? null : oldimport.toString()); - if (newname.toString().equals("-")) { + DottedChain newname = abcTag.getABC().nsValueToName(oldimport); + if (newname.size() == 1 && newname.get(0).equals("-")) { return true; } - if (!newname.toString().isEmpty()) { + + if (!newname.isEmpty()) { newimport = newname; break; } } - if (newimport.parts.isEmpty()) { - newimport = oldimport; - newimport.parts.add(name); + if (newimport.isEmpty()) { + newimport = oldimport.add(name); } - if (!newimport.parts.isEmpty() && newimport.toString().isEmpty()) { - newimport.parts.clear(); - } - if (newimport.parts.isEmpty()) { + + if (newimport.isEmpty()) { /* if(ns.kind==Namespace.KIND_PACKAGE){ newimport+=".*"; }*/ @@ -141,7 +140,7 @@ public class TraitClass extends Trait implements TraitWithSlot { String usname = newimport.getLast(); if (ns.kind == Namespace.KIND_PACKAGE) { if (!pkg.equals(ignorePackage)) { - if (!pkg.toString().equals("__AS3__.vec")) { //Automatic import + if (!pkg.equals(InitVectorAVM2Item.VECTOR_PACKAGE)) { //Automatic import imports.add(newimport); } } @@ -163,39 +162,35 @@ public class TraitClass extends Trait implements TraitWithSlot { return false; } - private void parseImportsUsagesFromNS(ABC abc, List imports, List uses, int namespace_index, String ignorePackage, String name) { + private void parseImportsUsagesFromNS(ABC abc, List imports, List uses, int namespace_index, DottedChain ignorePackage, String name) { Namespace ns = abc.constants.getNamespace(namespace_index); if (name.isEmpty()) { name = "*"; } - String niS = ns.getName(abc.constants, false); - DottedChain newimport = niS == null ? new DottedChain() : new DottedChain(niS.split("\\.")); + DottedChain newimport = ns.getName(abc.constants, false); if (parseUsagesFromNS(abc, imports, uses, namespace_index, ignorePackage, name)) { return; } else if ((ns.kind != Namespace.KIND_PACKAGE) && (ns.kind != Namespace.KIND_PACKAGE_INTERNAL)) { return; } - if (newimport.parts.isEmpty()) { - newimport = new DottedChain(""); - } - newimport.parts.add(name); + newimport = newimport.add(name); //WUT? /*if (newimport.contains(":")) { return; }*/ if (!imports.contains(newimport)) { DottedChain pkg = newimport.getWithoutLast(); //.substring(0, newimport.lastIndexOf('.')); - if (pkg.toString().equals("__AS3__.vec")) { //special case - is imported always + if (pkg.equals(InitVectorAVM2Item.VECTOR_PACKAGE)) { //special case - is imported always return; } - if (!pkg.toString().equals(ignorePackage)) { + if (!pkg.equals(ignorePackage)) { imports.add(newimport); } } //} } - private void parseUsagesFromMultiname(ABC abc, List imports, List uses, Multiname m, String ignorePackage, List fullyQualifiedNames) { + private void parseUsagesFromMultiname(ABC abc, List imports, List uses, Multiname m, DottedChain ignorePackage, List fullyQualifiedNames) { if (m != null) { if (m.kind == Multiname.TYPENAME) { if (m.qname_index != 0) { @@ -226,7 +221,7 @@ public class TraitClass extends Trait implements TraitWithSlot { } } - private void parseImportsUsagesFromMultiname(ABC abc, List imports, List uses, Multiname m, String ignorePackage, List fullyQualifiedNames) { + private void parseImportsUsagesFromMultiname(ABC abc, List imports, List uses, Multiname m, DottedChain ignorePackage, List fullyQualifiedNames) { if (m != null) { if (m.kind == Multiname.TYPENAME) { if (m.qname_index != 0) { @@ -240,7 +235,7 @@ public class TraitClass extends Trait implements TraitWithSlot { return; } Namespace ns = m.getNamespace(abc.constants); - String name = m.getName(abc.constants, fullyQualifiedNames, false); + String name = m.getName(abc.constants, fullyQualifiedNames, true); NamespaceSet nss = m.getNamespaceSet(abc.constants); if (ns != null) { parseImportsUsagesFromNS(abc, imports, uses, m.namespace_index, ignorePackage, name); @@ -253,7 +248,7 @@ public class TraitClass extends Trait implements TraitWithSlot { } } - private void parseImportsUsagesFromMethodInfo(ABC abc, int method_index, List imports, List uses, String ignorePackage, List fullyQualifiedNames, List visitedMethods) { + private void parseImportsUsagesFromMethodInfo(ABC abc, int method_index, List imports, List uses, DottedChain ignorePackage, List fullyQualifiedNames, List visitedMethods) { if ((method_index < 0) || (method_index >= abc.method_info.size())) { return; } @@ -274,7 +269,7 @@ public class TraitClass extends Trait implements TraitWithSlot { } for (AVM2Instruction ins : body.getCode().code) { if (ins.definition instanceof AlchemyTypeIns) { - DottedChain nimport = new DottedChain((AlchemyTypeIns.ALCHEMY_PACKAGE + "." + ins.definition.instructionName).split("\\.")); + DottedChain nimport = AlchemyTypeIns.ALCHEMY_PACKAGE.add(ins.definition.instructionName); if (!imports.contains(nimport)) { imports.add(nimport); } @@ -312,13 +307,13 @@ public class TraitClass extends Trait implements TraitWithSlot { } } - private void parseImportsUsagesFromTraits(ABC abc, Traits ts, List imports, List uses, String ignorePackage, List fullyQualifiedNames) { + private void parseImportsUsagesFromTraits(ABC abc, Traits ts, List imports, List uses, DottedChain ignorePackage, List fullyQualifiedNames) { for (Trait t : ts.traits) { parseImportsUsagesFromTrait(abc, t, imports, uses, ignorePackage, fullyQualifiedNames); } } - private void parseImportsUsagesFromTrait(ABC abc, Trait t, List imports, List uses, String ignorePackage, List fullyQualifiedNames) { + private void parseImportsUsagesFromTrait(ABC abc, Trait t, List imports, List uses, DottedChain ignorePackage, List fullyQualifiedNames) { if (t instanceof TraitMethodGetterSetter) { TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t; parseImportsUsagesFromMultiname(abc, imports, uses, abc.constants.getMultiname(tm.name_index), ignorePackage, fullyQualifiedNames); @@ -339,7 +334,7 @@ public class TraitClass extends Trait implements TraitWithSlot { ClassInfo classInfo = abc.class_info.get(class_info); InstanceInfo instanceInfo = abc.instance_info.get(class_info); - String packageName = instanceInfo.getName(abc.constants).getNamespace(abc.constants).getName(abc.constants, false); //assume not null name + DottedChain packageName = instanceInfo.getName(abc.constants).getNamespace(abc.constants).getName(abc.constants, false); //assume not null name parseImportsUsagesFromMultiname(abc, imports, uses, abc.constants.getMultiname(instanceInfo.name_index), packageName, fullyQualifiedNames); @@ -380,13 +375,13 @@ public class TraitClass extends Trait implements TraitWithSlot { InstanceInfo instanceInfo = abc.instance_info.get(class_info); Multiname instanceInfoMultiname = instanceInfo.getName(abc.constants); String instanceInfoName = instanceInfoMultiname.getName(abc.constants, fullyQualifiedNames, false); - String packageName = instanceInfoMultiname.getNamespace(abc.constants).getName(abc.constants, false); //assume not null name + DottedChain packageName = instanceInfoMultiname.getNamespace(abc.constants).getName(abc.constants, false); //assume not null name List namesInThisPackage = new ArrayList<>(); for (ABCContainerTag tag : abc.getAbcTags()) { for (ScriptInfo si : tag.getABC().script_info) { for (Trait t : si.traits.traits) { ClassPath classPath = t.getPath(tag.getABC()); - String pkg = classPath.packageStr == null ? "" : classPath.packageStr; + DottedChain pkg = classPath.packageStr == null ? DottedChain.EMPTY : classPath.packageStr; if (pkg.equals(packageName)) { namesInThisPackage.add(classPath.className); } @@ -406,7 +401,7 @@ public class TraitClass extends Trait implements TraitWithSlot { for (DottedChain ipath : imports) { String name = ipath.getLast(); DottedChain pkg = ipath.getWithoutLast(); - if (importnames.contains(name) || ((!pkg.parts.isEmpty()) && isBuiltInClass(name))) { + if (importnames.contains(name) || isBuiltInClass(name)) { fullyQualifiedNames.add(new DottedChain(name)); } else { importnames.add(name); @@ -429,13 +424,12 @@ public class TraitClass extends Trait implements TraitWithSlot { for (int i = 0; i < imports.size(); i++) { DottedChain imp = imports.get(i); - DottedChain pkg = imp.getWithoutLast(); //imp.substring(0, imp.lastIndexOf('.')); - String name = imp.getLast();//imp.substring(imp.lastIndexOf('.') + 1); + DottedChain pkg = imp.getWithoutLast(); + String name = imp.getLast(); if (name.equals("*")) { continue; } - DottedChain dAll = new DottedChain(pkg.parts); - dAll.parts.add("*"); + DottedChain dAll = pkg.add("*"); if (imports.contains(dAll)) { imports.remove(i); i--; @@ -444,8 +438,8 @@ public class TraitClass extends Trait implements TraitWithSlot { boolean hasImport = false; for (DottedChain imp : imports) { - if (!imp.parts.get(0).isEmpty()) { //No imports from root package - writer.appendNoHilight("import " + imp + ";").newLine(); + if (imp.size() > 1) { //No imports from root package + writer.appendNoHilight("import " + imp.toPrintableString(true) + ";").newLine(); hasImport = true; } } 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 56f98f9a9..db6d24aac 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 @@ -1,16 +1,16 @@ /* * Copyright (C) 2010-2015 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. */ @@ -30,6 +30,6 @@ public class ClassNameMultinameUsage extends InsideClassMultinameUsage implement @Override public String toString() { - return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants).toPrintableString(); + return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants).toPrintableString(true); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/InsideClassMultinameUsage.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/InsideClassMultinameUsage.java index 6244374aa..6baa8bef7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/InsideClassMultinameUsage.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/usages/InsideClassMultinameUsage.java @@ -36,7 +36,7 @@ public abstract class InsideClassMultinameUsage extends MultinameUsage { @Override public String toString() { - return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants).toPrintableString(); + return "class " + abc.constants.getMultiname(abc.instance_info.get(classIndex).name_index).getNameWithNamespace(abc.constants).toPrintableString(true); } public int getMultinameIndex() { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java index 96d4067ad..53c4bafe9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -201,31 +201,21 @@ public class DoInitActionTag extends Tag implements CharacterIdTag, ASMSource { @Override public String getExportFileName() { - String expName = swf.getExportName(spriteId); - if ((expName == null) || expName.isEmpty()) { + String expName = swf == null ? "" : swf.getExportName(spriteId); + if (expName == null || expName.isEmpty()) { return super.getExportFileName(); } - String[] pathParts; - if (expName.contains(".")) { - pathParts = expName.split("\\."); - } else { - pathParts = new String[]{expName}; - } + String[] pathParts = expName.contains(".") ? expName.split("\\.") : new String[]{expName}; return pathParts[pathParts.length - 1]; } @Override public String getName() { String expName = swf == null ? "" : swf.getExportName(spriteId); - if ((expName == null) || expName.isEmpty()) { + if (expName == null || expName.isEmpty()) { return super.getName(); } - String[] pathParts; - if (expName.contains(".")) { - pathParts = expName.split("\\."); - } else { - pathParts = new String[]{expName}; - } + String[] pathParts = expName.contains(".") ? expName.split("\\.") : new String[]{expName}; return pathParts[pathParts.length - 1]; } 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 9c8bcca86..adc809f6d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/DottedChain.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/DottedChain.java @@ -17,80 +17,144 @@ package com.jpexs.decompiler.graph; import com.jpexs.decompiler.flash.IdentifiersDeobfuscation; +import com.jpexs.helpers.Helper; +import java.io.File; +import java.io.Serializable; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; -import java.util.Objects; /** * * @author JPEXS */ -public class DottedChain { +public class DottedChain implements Serializable { - public final List parts; + public static final DottedChain EMPTY = new DottedChain(); + + private final String[] parts; + + private final int hash; public DottedChain(List parts) { - this.parts = new ArrayList<>(parts); + this.parts = parts.toArray(new String[parts.size()]); + hash = calcHash(); } public DottedChain(String... parts) { - this.parts = new ArrayList<>(); - for (int i = 0; i < parts.length; i++) { - this.parts.add(parts[i]); - } + this.parts = parts; + hash = calcHash(); + } + + public boolean isEmpty() { + return parts.length == 0; + } + + public int size() { + return parts.length; + } + + public String get(int index) { + return parts[index]; + } + + public DottedChain subChain(int count) { + String[] nparts = Arrays.copyOfRange(parts, 0, count); + return new DottedChain(nparts); } public String getLast() { - if (parts.isEmpty()) { + if (parts.length == 0) { return ""; } else { - return parts.get(parts.size() - 1); + return parts[parts.length - 1]; } } public DottedChain getWithoutLast() { - List nparts = new ArrayList<>(parts); - if (!nparts.isEmpty()) { - nparts.remove(nparts.size() - 1); + if (parts.length < 2) { + return EMPTY; } + + String[] nparts = Arrays.copyOfRange(parts, 0, parts.length - 1); return new DottedChain(nparts); } - public String toPrintableString() { + public DottedChain add(String name) { + String[] nparts = new String[parts.length + 1]; + if (parts.length > 0) { + System.arraycopy(parts, 0, nparts, 0, parts.length); + } + + nparts[nparts.length - 1] = name; + return new DottedChain(nparts); + } + + private String toString(boolean as3, boolean raw) { + if (parts.length == 0 || (parts.length == 1 && parts[0].isEmpty())) { + return ""; + } + StringBuilder ret = new StringBuilder(); - for (int i = 0; i < parts.size(); i++) { + for (int i = 0; i < parts.length; i++) { if (i > 0) { ret.append("."); } - ret.append(IdentifiersDeobfuscation.printIdentifier(true, parts.get(0))); + + String part = parts[i]; + boolean lastStar = i == parts.length - 1 && "*".equals(part); + ret.append((raw || lastStar) ? part : IdentifiersDeobfuscation.printIdentifier(as3, part)); } return ret.toString(); } + public String toFilePath() { + if (parts.length == 0 || (parts.length == 1 && parts[0].isEmpty())) { + return ""; + } + + StringBuilder ret = new StringBuilder(); + for (int i = 0; i < parts.length; i++) { + if (i > 0) { + ret.append(File.separator); + } + + ret.append(Helper.makeFileName(IdentifiersDeobfuscation.printIdentifier(true, parts[i]))); + } + return ret.toString(); + } + + public List toList() { + return new ArrayList<>(Arrays.asList(parts)); + } + + public String toPrintableString(boolean as3) { + return toString(as3, false); + } + + public String toRawString() { + return toString(false/*ignored*/, true); + } + @Override public String toString() { - StringBuilder ret = new StringBuilder(); - for (int i = 0; i < parts.size(); i++) { - if (i > 0) { - ret.append("."); - } - ret.append(parts.get(i)); - } - return ret.toString(); + return toRawString(); } @Override public int hashCode() { - int hash = 3; - hash = 89 * hash + Objects.hashCode(parts); return hash; } + private int calcHash() { + if (parts.length > 0 && parts[0].equals("ยงยง")) { + int a = 1; + } + return Arrays.hashCode(parts); + } + @Override public boolean equals(Object obj) { - if (obj instanceof String) { - obj = new DottedChain(((String) obj).split("\\.")); - } if (obj == null) { return false; } @@ -98,7 +162,7 @@ public class DottedChain { return false; } final DottedChain other = (DottedChain) obj; - if (!Objects.equals(parts, other.parts)) { + if (!Arrays.equals(parts, other.parts)) { return false; } return true; 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 4f18a478f..880eb0ede 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TypeItem.java @@ -32,11 +32,11 @@ import java.util.Objects; */ public class TypeItem extends GraphTargetItem { - public static TypeItem BOOLEAN = new TypeItem("Boolean"); + public static TypeItem BOOLEAN = new TypeItem(new DottedChain("Boolean")); - public static TypeItem STRING = new TypeItem("String"); + public static TypeItem STRING = new TypeItem(new DottedChain("String")); - public static TypeItem ARRAY = new TypeItem("Array"); + public static TypeItem ARRAY = new TypeItem(new DottedChain("Array")); public static UnboundedTypeItem UNBOUNDED = new UnboundedTypeItem(); @@ -79,10 +79,11 @@ public class TypeItem extends GraphTargetItem { @Override public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { + boolean as3 = localData.constantsAvm2 != null; if (localData.fullyQualifiedNames.contains(fullTypeName)) { - writer.hilightSpecial(IdentifiersDeobfuscation.printNamespace(localData.constantsAvm2 != null, fullTypeName.toPrintableString()), HighlightSpecialType.TYPE_NAME, fullTypeName.toPrintableString()); + writer.hilightSpecial(fullTypeName.toPrintableString(as3), HighlightSpecialType.TYPE_NAME, fullTypeName.toPrintableString(as3)); } else { - writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(localData.constantsAvm2 != null, fullTypeName.getLast()), HighlightSpecialType.TYPE_NAME, fullTypeName.toPrintableString()); + writer.hilightSpecial(IdentifiersDeobfuscation.printIdentifier(as3, fullTypeName.getLast()), HighlightSpecialType.TYPE_NAME, fullTypeName.toPrintableString(as3)); } return writer; @@ -100,7 +101,7 @@ public class TypeItem extends GraphTargetItem { @Override public String toString() { - return fullTypeName.toString(); + return fullTypeName.toRawString(); } @Override diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java b/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java index c7d2855a0..2fb6b3a46 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java @@ -24,9 +24,9 @@ import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.gui.AppStrings; import com.jpexs.decompiler.flash.timeline.AS3Package; import com.jpexs.decompiler.flash.treeitems.AS3ClassTreeItem; +import com.jpexs.decompiler.graph.DottedChain; import java.util.ArrayList; import java.util.List; -import java.util.StringTokenizer; import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; import javax.swing.tree.TreeModel; @@ -81,17 +81,16 @@ public class ClassesListTreeModel extends AS3ClassTreeItem implements TreeModel continue; } - String packageStr = item.getClassPath().packageStr; + DottedChain packageStr = item.getClassPath().packageStr; AS3Package pkg = ensurePackage(packageStr); pkg.addScriptPack(item); } } - private AS3Package ensurePackage(String packageStr) { - StringTokenizer st = new StringTokenizer(packageStr, "."); + private AS3Package ensurePackage(DottedChain packageStr) { AS3Package parent = root; - while (st.hasMoreTokens()) { - String pathElement = st.nextToken(); + for (int i = 0; i < packageStr.size(); i++) { + String pathElement = packageStr.get(i); AS3Package pkg = parent.getSubPackage(pathElement); if (pkg == null) { pkg = new AS3Package(pathElement, swf); diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java index 0d60adc6b..06085ee73 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java @@ -520,7 +520,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL if (tm != null) { String name = ""; if (classIndex > -1) { - name = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants).toPrintableString(); + name = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants).toPrintableString(true); } Trait currentTrait = null; @@ -571,7 +571,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL } currentMethodHighlight = null; currentTrait = null; - String name = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants).toPrintableString(); + String name = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants).toPrintableString(true); currentTrait = getCurrentTrait(); isStatic = abc.isStaticTraitId(classIndex, lastTraitIndex); if (currentTrait != null) { diff --git a/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java b/src/com/jpexs/decompiler/flash/gui/abc/UsageFrame.java index 21a398abd..94253c59b 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()); + setTitle((definitions ? translate("dialog.title.declaration") : translate("dialog.title")) + abc.constants.getMultiname(multinameIndex).getNameWithNamespace(abc.constants).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(), abcPanel.abc.instance_info.get(icu.classIndex).getName(abcPanel.abc.constants).getNameWithNamespace(abcPanel.abc.constants).toPrintableString()); + abcPanel.hilightScript(abcPanel.getSwf(), abcPanel.abc.instance_info.get(icu.classIndex).getName(abcPanel.abc.constants).getNameWithNamespace(abcPanel.abc.constants).toPrintableString(true)); } } } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/NamespaceTableModel.java b/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/NamespaceTableModel.java index ac0d16d04..21496b776 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/NamespaceTableModel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/NamespaceTableModel.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.gui.abc.tablemodels; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.graph.DottedChain; import javax.swing.event.TableModelListener; import javax.swing.table.TableModel; @@ -124,11 +125,11 @@ public class NamespaceTableModel implements TableModel { if (rowIndex == 0) { return "-"; } - String val = abc.constants.getNamespace(rowIndex).getName(abc.constants, true); - if (val == null) { - val = "-"; + DottedChain chain = abc.constants.getNamespace(rowIndex).getName(abc.constants, true); + if (chain == null) { + return "-"; } - return val; + return chain.toRawString(); default: return null; } diff --git a/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java b/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java index 6a6abcf3f..179f51838 100644 --- a/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java +++ b/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java @@ -54,7 +54,7 @@ public class DebuggerTools { for (ABCContainerTag ac : swf.getAbcList()) { ABC a = ac.getABC(); for (ScriptPack m : a.getScriptPacks(DEBUGGER_PACKAGE, allAbcList)) { - if (isDebuggerClass(m.getClassPath().packageStr, null)) { + if (isDebuggerClass(m.getClassPath().packageStr.toRawString(), null)) { return m; } } @@ -87,7 +87,7 @@ public class DebuggerTools { public static void replaceTraceCalls(SWF swf, String fname) { if (hasDebugger(swf)) { - String debuggerPkg = getDebuggerScriptPack(swf).getClassPath().packageStr; + String debuggerPkg = getDebuggerScriptPack(swf).getClassPath().packageStr.toRawString(); //change trace to fname for (ABCContainerTag ct : swf.getAbcList()) { ABC a = ct.getABC();