From 7193119f11afc66526a337da948de828f676a3f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 14 Sep 2014 18:50:36 +0200 Subject: [PATCH] AS3 namespaces deobfuscation fix --- .../com/jpexs/decompiler/flash/abc/ABC.java | 2 +- .../decompiler/flash/abc/ScriptPack.java | 2 +- .../flash/abc/avm2/model/FindDefAVM2Item.java | 5 +- .../abc/avm2/model/FullMultinameAVM2Item.java | 2 +- .../parser/script/AVM2SourceGenerator.java | 20 +- .../avm2/parser/script/PropertyAVM2Item.java | 6 +- .../parser/script/UnresolvedAVM2Item.java | 2 +- .../decompiler/flash/abc/types/Multiname.java | 4 +- .../decompiler/flash/abc/types/Namespace.java | 14 +- .../flash/abc/types/ScriptInfo.java | 2 +- .../decompiler/flash/abc/types/ValueKind.java | 4 +- .../flash/abc/types/traits/Trait.java | 8 +- .../flash/abc/types/traits/TraitClass.java | 8 +- .../jpexs/decompiler/flash/action/Action.java | 12 +- .../abc/tablemodels/NamespaceTableModel.java | 336 +++++++++--------- 15 files changed, 213 insertions(+), 214 deletions(-) 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 eb70251d7..f58adba05 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 @@ -801,7 +801,7 @@ public class ABC { if (t instanceof TraitSlotConst) { TraitSlotConst s = ((TraitSlotConst) t); if (s.isNamespace()) { - String key = constants.getNamespace(s.value_index).getName(constants); //assume not null + String key = constants.getNamespace(s.value_index).getName(constants,true); //assume not null String val = constants.getMultiname(s.name_index).getNameWithNamespace(constants, true); namespaceMap.put(key, val); } 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 64f4bdc11..2997589fe 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 @@ -74,7 +74,7 @@ public class ScriptPack implements TreeElementItem { Multiname name = abc.script_info.get(scriptIndex).traits.traits.get(t).getName(abc); Namespace ns = name.getNamespace(abc.constants); if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) { - packageName = ns.getName(abc.constants); //assume not null + packageName = ns.getName(abc.constants,false); //assume not null } } return packageName; 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 0a71cc6c1..c6f75213e 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 @@ -12,7 +12,8 @@ * 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)); //assume not null name + return writer.append(propertyName.getNamespace(localData.constantsAvm2).getName(localData.constantsAvm2,false)); //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 87473a416..0e7eadb76 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 @@ -70,7 +70,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); + cns = ns.getName(constants,false); } } return cname.equals("XML") && cns.isEmpty(); 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 64dc0a09c..1b8ef3e0b 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 @@ -2136,7 +2136,7 @@ public class AVM2SourceGenerator implements SourceGenerator { abc.constants.getMultinameId( new Multiname(Multiname.QNAME, abc.constants.getStringId(superName.getName(a.constants, new ArrayList(), true), true), - abc.constants.getNamespaceId(new Namespace(superName.getNamespace(a.constants).kind, abc.constants.getStringId(superName.getNamespace(a.constants).getName(a.constants), true)), 0, true), 0, 0, new ArrayList()), true) + abc.constants.getNamespaceId(new Namespace(superName.getNamespace(a.constants).kind, abc.constants.getStringId(superName.getNamespace(a.constants).getName(a.constants,true), true)), 0, true), 0, 0, new ArrayList()), true) ); } } @@ -2190,11 +2190,11 @@ public class AVM2SourceGenerator implements SourceGenerator { continue; } for (Trait t : ii.traits.traits) { - if (eq(pkg, t.getName(abc).getNamespace(abc.constants).getName(abc.constants))) { + if (eq(pkg, t.getName(abc).getNamespace(abc.constants).getName(abc.constants,true))) { if (propertyName.equals(t.getName(abc).getName(abc.constants, new ArrayList(), true))) { outName.setVal(obj); outNs.setVal(pkg); - outPropNs.setVal(t.getName(abc).getNamespace(abc.constants).getName(abc.constants)); + outPropNs.setVal(t.getName(abc).getNamespace(abc.constants).getName(abc.constants,true)); outPropNsKind.setVal(t.getName(abc).getNamespace(abc.constants).kind); outPropNsIndex.setVal(abc.constants.getNamespaceSubIndex(t.getName(abc).namespace_index)); outPropType.setVal(getTraitReturnType(abc, t)); @@ -2215,7 +2215,7 @@ public class AVM2SourceGenerator implements SourceGenerator { } Multiname clsName = ii.getName(abc.constants); if (obj.equals(clsName.getName(abc.constants, new ArrayList(), true))) { - if (eq(pkg, clsName.getNamespace(abc.constants).getName(abc.constants))) { + if (eq(pkg, clsName.getNamespace(abc.constants).getName(abc.constants,true))) { //class found for (Trait t : ii.instance_traits.traits) { @@ -2225,7 +2225,7 @@ public class AVM2SourceGenerator implements SourceGenerator { if (propertyName.equals(t.getName(abc).getName(abc.constants, new ArrayList(), true))) { outName.setVal(obj); outNs.setVal(pkg); - outPropNs.setVal(t.getName(abc).getNamespace(abc.constants).getName(abc.constants)); + outPropNs.setVal(t.getName(abc).getNamespace(abc.constants).getName(abc.constants,true)); outPropNsKind.setVal(t.getName(abc).getNamespace(abc.constants).kind); outPropNsIndex.setVal(abc.constants.getNamespaceSubIndex(t.getName(abc).namespace_index)); outPropType.setVal(getTraitReturnType(abc, t)); @@ -2245,7 +2245,7 @@ public class AVM2SourceGenerator implements SourceGenerator { if (propertyName.equals(t.getName(abc).getName(abc.constants, new ArrayList(), true))) { outName.setVal(obj); outNs.setVal(pkg); - outPropNs.setVal(t.getName(abc).getNamespace(abc.constants).getName(abc.constants)); + outPropNs.setVal(t.getName(abc).getNamespace(abc.constants).getName(abc.constants,true)); outPropNsKind.setVal(t.getName(abc).getNamespace(abc.constants).kind); outPropNsIndex.setVal(abc.constants.getNamespaceSubIndex(t.getName(abc).namespace_index)); outPropType.setVal(getTraitReturnType(abc, t)); @@ -2260,7 +2260,7 @@ public class AVM2SourceGenerator implements SourceGenerator { Multiname superName = abc.constants.constant_multiname.get(ii.super_index); if (superName != null) { - return searchPrototypeChain(instanceOnly, abcs, superName.getNamespace(abc.constants).getName(abc.constants), superName.getName(abc.constants, new ArrayList(), true), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue); + return searchPrototypeChain(instanceOnly, abcs, superName.getNamespace(abc.constants).getName(abc.constants,true), superName.getName(abc.constants, new ArrayList(), true), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue); } else { return false; } @@ -2274,7 +2274,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, new ArrayList(), true)); - namespaces.add(abc.constants.constant_multiname.get(name_index).getNamespace(abc.constants).getName(abc.constants)); + namespaces.add(abc.constants.constant_multiname.get(name_index).getNamespace(abc.constants).getName(abc.constants,true)); Multiname mname = abc.constants.constant_multiname.get(name_index); outABCs.add(abc); @@ -2288,7 +2288,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, new ArrayList(), true).equals(mname.getName(abc.constants, new ArrayList(), true))) { - if (m.getNamespace(a.constants).hasName(a.constants, mname.getNamespace(abc.constants).getName(abc.constants))) { + if (m.getNamespace(a.constants).hasName(mname.getNamespace(abc.constants).getName(abc.constants,true),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) { @@ -2392,7 +2392,7 @@ public class AVM2SourceGenerator implements SourceGenerator { for (int i = 1; i < abc.constants.constant_multiname.size(); i++) { Multiname mname = abc.constants.constant_multiname.get(i); if (mname != null && name.equals(mname.getName(abc.constants, new ArrayList(), true))) { - if (mname.getNamespace(abc.constants) != null && pkg.equals(mname.getNamespace(abc.constants).getName(abc.constants))) { + if (mname.getNamespace(abc.constants) != null && pkg.equals(mname.getNamespace(abc.constants).getName(abc.constants,true))) { name_index = i; break; } 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 20d6ef272..638869155 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 @@ -219,7 +219,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { Reference outPropNsIndex = new Reference<>(0); Reference outPropType = new Reference<>(null); Reference outPropValue = new Reference<>(null); - if (AVM2SourceGenerator.searchPrototypeChain(false, abcs, m.getNamespace(a.constants).getName(a.constants), m.getName(a.constants, new ArrayList(), true), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue)) { + if (AVM2SourceGenerator.searchPrototypeChain(false, abcs, m.getNamespace(a.constants).getName(a.constants,true), m.getName(a.constants, new ArrayList(), true), propertyName, outName, outNs, outPropNs, outPropNsKind, outPropNsIndex, outPropType, outPropValue)) { objType = new TypeItem("".equals(outNs.getVal()) ? outName.getVal() : outNs.getVal() + "." + outName.getVal()); propType = outPropType.getVal(); propIndex = abc.constants.getMultinameId(new Multiname(Multiname.QNAME, @@ -258,7 +258,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); + String 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); @@ -328,7 +328,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { continue; } 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).equals(nsname)) { + 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<>(""); 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 acb0b349f..d0b2ba6d9 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 @@ -407,7 +407,7 @@ 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), 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), a.constants))) { String cname = a.instance_info.get(c).getName(a.constants).getName(a.constants, new ArrayList(), true); if (parts.get(0).equals(cname)) { if (!subtypes.isEmpty() && parts.size() > 1) { 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 a4cd464d0..449c31ef4 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 @@ -157,7 +157,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); + String name = name_index == 0 ? null : constants.getNamespace(index).getName(constants,true); int sub = -1; for (int n = 1; n < constants.getNamespaceCount(); n++) { if (constants.getNamespace(n).kind == type && constants.getNamespace(n).name_index == name_index) { @@ -272,7 +272,7 @@ public class Multiname { String ret = ""; Namespace ns = getNamespace(constants); if (ns != null) { - String nsname = ns.getName(constants); + String nsname = ns.getName(constants,raw); if (nsname != null && !nsname.isEmpty()) { ret += nsname + "."; } 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 e166bf3bb..ed83aee72 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 @@ -77,7 +77,7 @@ public class Namespace { } public String toString(AVM2ConstantPool constants) { - return getName(constants); //getPrefix(constants)+" "+getName(constants); + return getName(constants,false); } public String getNameWithKind(AVM2ConstantPool constants) { @@ -97,18 +97,14 @@ public class Namespace { return kindStr; } - public String getName(AVM2ConstantPool constants) { + public String getName(AVM2ConstantPool constants, boolean raw) { if (name_index == 0) { return null; } - return Deobfuscation.printNamespace(constants.getString(name_index)); - } - - public boolean hasName(AVM2ConstantPool constants, String name) { - if (name == null) { - return name_index == 0; + if(raw){ + return constants.getString(name_index); } - return name.equals(getName(constants)); + return Deobfuscation.printNamespace(constants.getString(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 403ebf610..e702bc720 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 @@ -50,7 +50,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); //assume not null package + String packageName = ns.getName(abc.constants,false); //assume not null package String objectName = name.getName(abc.constants, new ArrayList(), false); List traitIndices = new ArrayList<>(); 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 63f06b3b7..3217a39e4 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 @@ -134,7 +134,7 @@ public class ValueKind { case CONSTANT_ExplicitNamespace: case CONSTANT_StaticProtectedNs: case CONSTANT_PrivateNs: - ret = "\"" + constants.getNamespace(value_index).getName(constants) + "\""; //assume not null name + ret = "\"" + constants.getNamespace(value_index).getName(constants,true) + "\""; //assume not null name break; } return ret; @@ -176,7 +176,7 @@ public class ValueKind { case CONSTANT_ExplicitNamespace: case CONSTANT_StaticProtectedNs: case CONSTANT_PrivateNs: - ret = constants.getNamespace(value_index).getKindStr() + "(\"" + constants.getNamespace(value_index).getName(constants) + "\")"; //assume not null name + ret = constants.getNamespace(value_index).getKindStr() + "(\"" + constants.getNamespace(value_index).getName(constants,true) + "\")"; //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 f4b82c2dd..a20059986 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 @@ -63,7 +63,7 @@ public abstract class Trait implements Serializable { if (m.namespace_index == -1) { break; } - nsname = abcTag.getABC().nsValueToName(abc.constants.getNamespace(m.namespace_index).getName(abc.constants)); + nsname = abcTag.getABC().nsValueToName(abc.constants.getNamespace(m.namespace_index).getName(abc.constants,true)); if (nsname == null) { break; } @@ -85,7 +85,7 @@ public abstract class Trait implements Serializable { } else { if (ns != null) { if (ns.kind == Namespace.KIND_NAMESPACE) { - nsname = ns.getName(abc.constants); + nsname = ns.getName(abc.constants,true); } } } @@ -132,7 +132,7 @@ public abstract class Trait implements Serializable { public GraphTextWriter toStringPackaged(Trait parent, String path, List abcTags, 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); + String nsname = ns.getName(abc.constants,false); writer.appendNoHilight("package"); if (!nsname.isEmpty()) { writer.appendNoHilight(" " + nsname); //assume not null name @@ -174,7 +174,7 @@ public abstract class Trait implements Serializable { public String getPath(ABC abc) { Multiname name = getName(abc); Namespace ns = name.getNamespace(abc.constants); - String packageName = ns.getName(abc.constants); + String packageName = ns.getName(abc.constants,false); String objectName = name.getName(abc.constants, new ArrayList(), false); return 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 87443c380..94044adcb 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 @@ -91,7 +91,7 @@ public class TraitClass extends Trait implements TraitWithSlot { if (name.isEmpty()) { name = "*"; } - String newimport = ns.getName(abc.constants); + String newimport = ns.getName(abc.constants,false); /*if ((ns.kind != Namespace.KIND_PACKAGE) && (ns.kind != Namespace.KIND_NAMESPACE) && (ns.kind != Namespace.KIND_STATIC_PROTECTED)) { @@ -163,7 +163,7 @@ public class TraitClass extends Trait implements TraitWithSlot { if (name.isEmpty()) { name = "*"; } - String newimport = ns.getName(abc.constants); + String newimport = ns.getName(abc.constants,false); if (parseUsagesFromNS(abcTags, abc, imports, uses, namespace_index, ignorePackage, name)) { return; } else if ((ns.kind != Namespace.KIND_PACKAGE) && (ns.kind != Namespace.KIND_PACKAGE_INTERNAL)) { @@ -321,7 +321,7 @@ public class TraitClass extends Trait implements TraitWithSlot { private List getImportsUsages(List abcTags, ABC abc, List imports, List uses, List fullyQualifiedNames) { //constructor - String packageName = abc.instance_info.get(class_info).getName(abc.constants).getNamespace(abc.constants).getName(abc.constants); //assume not null name + String packageName = abc.instance_info.get(class_info).getName(abc.constants).getNamespace(abc.constants).getName(abc.constants,false); //assume not null name parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.getMultiname(abc.instance_info.get(class_info).name_index), packageName, fullyQualifiedNames); @@ -360,7 +360,7 @@ public class TraitClass extends Trait implements TraitWithSlot { public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ScriptExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List fullyQualifiedNames, boolean parallel) throws InterruptedException { writer.startClass(class_info); - String packageName = abc.instance_info.get(class_info).getName(abc.constants).getNamespace(abc.constants).getName(abc.constants); //assume not null name + String packageName = abc.instance_info.get(class_info).getName(abc.constants).getNamespace(abc.constants).getName(abc.constants,false); //assume not null name List namesInThisPackage = new ArrayList<>(); for (ABCContainerTag tag : abcTags) { for (ScriptInfo si : tag.getABC().script_info) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java index 088278585..9e8e63995 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java @@ -103,11 +103,13 @@ public class Action implements GraphSourceItem { private long address; public static final String[] reservedWords = { - "as", "break", "case", "catch", "class", "const", "continue", "default", "delete", "do", "each", "else", - "extends", "false", "finally", "for", "function", "get", "if", "implements", "import", "in", "instanceof", - "interface", "internal", "is", "native", "new", "null", "override", "package", "private", "protected", "public", - "return", "set", "super", "switch", "this", "throw", "true", "try", "typeof", "use", "var", /*"void",*/ "while", - "with", "dynamic", "default", "final", "in"}; + "as", "break", "case", "catch", "class", "const", "continue", "default", "delete", "do", "else", + "extends", "false", "finally", "for", "function", "if", "implements", "import", "in", "instanceof", + "interface", "internal", "is", "native", "new", "null", "package", "private", "protected", "public", + "return", "super", "switch", "this", "throw",/*to*/ "true", "try", "typeof", "use", "var", /*"void",*/ "while", + "with", + //syntactic keywords - can be used as identifiers, but that have special meaning in certain contexts + "each", "get", "set", "namespace", "#include", "include", "dynamic", "final", "native", "override", "static", "in"}; public static boolean isReservedWord(String s) { if (s == null) { 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 37831aef7..3e78d8e9a 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/NamespaceTableModel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/NamespaceTableModel.java @@ -1,168 +1,168 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.gui.abc.tablemodels; - -import com.jpexs.decompiler.flash.abc.ABC; -import javax.swing.event.TableModelListener; -import javax.swing.table.TableModel; - -public class NamespaceTableModel implements TableModel { - - private final ABC abc; - private static final String[] columnNames = new String[]{"Index", "Kind", "Name"}; - private static final Class[] classes = new Class[]{Long.class, String.class, String.class}; - - public NamespaceTableModel(ABC abc) { - this.abc = abc; - } - - /** - * Returns the number of rows in the model. A JTable uses this - * method to determine how many rows it should display. This method should - * be quick, as it is called frequently during rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - @Override - public int getRowCount() { - if (abc == null) { - return 0; - } - return abc.constants.getNamespaceCount(); - } - - /** - * Returns the number of columns in the model. A JTable uses - * this method to determine how many columns it should create and display by - * default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - @Override - public int getColumnCount() { - return 3; - } - - /** - * Returns the name of the column at columnIndex. This is used - * to initialize the table's column header name. Note: this name does not - * need to be unique; two columns in a table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - @Override - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } - - /** - * Returns the most specific superclass for all the cell values in the - * column. This is used by the JTable to set up a default - * renderer and editor for the column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - @Override - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } - - /** - * Returns true if the cell at rowIndex and - * columnIndex is editable. Otherwise, setValueAt - * on the cell will not change the value of that cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } - - /** - * Returns the value for the cell at columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - switch (columnIndex) { - case 0: - return rowIndex; - case 1: - if (rowIndex == 0) { - return "-"; - } - return abc.constants.getNamespace(rowIndex).getKindStr(); - case 2: - if (rowIndex == 0) { - return "-"; - } - String val = abc.constants.getNamespace(rowIndex).getName(abc.constants); - if (val == null) { - val = "-"; - } - return val; - default: - return null; - } - } - - /** - * Sets the value in the cell at columnIndex and - * rowIndex to aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - @Override - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - } - - /** - * Adds a listener to the list that is notified each time a change to the - * data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void addTableModelListener(TableModelListener l) { - } - - /** - * Removes a listener from the list that is notified each time a change to - * the data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void removeTableModelListener(TableModelListener l) { - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui.abc.tablemodels; + +import com.jpexs.decompiler.flash.abc.ABC; +import javax.swing.event.TableModelListener; +import javax.swing.table.TableModel; + +public class NamespaceTableModel implements TableModel { + + private final ABC abc; + private static final String[] columnNames = new String[]{"Index", "Kind", "Name"}; + private static final Class[] classes = new Class[]{Long.class, String.class, String.class}; + + public NamespaceTableModel(ABC abc) { + this.abc = abc; + } + + /** + * Returns the number of rows in the model. A JTable uses this + * method to determine how many rows it should display. This method should + * be quick, as it is called frequently during rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + @Override + public int getRowCount() { + if (abc == null) { + return 0; + } + return abc.constants.getNamespaceCount(); + } + + /** + * Returns the number of columns in the model. A JTable uses + * this method to determine how many columns it should create and display by + * default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + @Override + public int getColumnCount() { + return 3; + } + + /** + * Returns the name of the column at columnIndex. This is used + * to initialize the table's column header name. Note: this name does not + * need to be unique; two columns in a table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + @Override + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } + + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the JTable to set up a default + * renderer and editor for the column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + @Override + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } + + /** + * Returns true if the cell at rowIndex and + * columnIndex is editable. Otherwise, setValueAt + * on the cell will not change the value of that cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } + + /** + * Returns the value for the cell at columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + switch (columnIndex) { + case 0: + return rowIndex; + case 1: + if (rowIndex == 0) { + return "-"; + } + return abc.constants.getNamespace(rowIndex).getKindStr(); + case 2: + if (rowIndex == 0) { + return "-"; + } + String val = abc.constants.getNamespace(rowIndex).getName(abc.constants,true); + if (val == null) { + val = "-"; + } + return val; + default: + return null; + } + } + + /** + * Sets the value in the cell at columnIndex and + * rowIndex to aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + @Override + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } + + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void addTableModelListener(TableModelListener l) { + } + + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void removeTableModelListener(TableModelListener l) { + } +}