diff --git a/.gitignore b/.gitignore index ce3dadfa5..8436190bb 100644 --- a/.gitignore +++ b/.gitignore @@ -33,8 +33,9 @@ hs_err_pid*.log /libsrc/ffdec_lib/dist/ /libsrc/ffdec_lib/testdata/decompile/ /libsrc/ffdec_lib/testdata/recompile/ +/libsrc/ffdec_lib/coverage.ec /libsrc/ffdec_lib/revision.txt /libsrc/jpproxy/nbproject/private/ /libsrc/jpproxy/dist/ /libsrc/jpproxy/build/ -/libsrc/LZMA/nbproject/private/ \ No newline at end of file +/libsrc/LZMA/nbproject/private/ 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 f58adba05..5dc3f80ef 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,true); //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 2997589fe..4f48a317a 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,false); //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/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index b8c9b4e29..3b0999aec 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -1209,17 +1209,18 @@ public class AVM2Code implements Cloneable { /** * Test for killed register. CalcKilledStats must be called before + * * @param regName * @param start * @param end - * @return + * @return */ - public boolean isKilled(int regName, int start, int end) { - if(!killedRegs.containsKey(regName)){ + public boolean isKilled(int regName, int start, int end) { + if (!killedRegs.containsKey(regName)) { return false; } - for(int ip:killedRegs.get(regName)){ - if(ip>=start && ip<=end){ + for (int ip : killedRegs.get(regName)) { + if (ip >= start && ip <= end) { return true; } } @@ -1239,32 +1240,32 @@ public class AVM2Code implements Cloneable { return localRegNames; } - private Map> killedRegs=new HashMap>(); - - public void calcKilledStats(MethodBody body){ + private Map> killedRegs = new HashMap<>(); + + public void calcKilledStats(MethodBody body) { killedRegs.clear(); try { - HashMap> vis=visitCode(body); - for(int k=0;k> vis = visitCode(body); + for (int k = 0; k < code.size(); k++) { + if (vis.get(k).isEmpty()) { continue; } if (code.get(k).definition instanceof KillIns) { int regid = code.get(k).operands[0]; - if(!killedRegs.containsKey(regid)){ + if (!killedRegs.containsKey(regid)) { killedRegs.put(regid, new HashSet()); } killedRegs.get(regid).add(k); } } - + } catch (InterruptedException ex) { //ignored } } - + public List clearTemporaryRegisters(List output) { - for (int i = 0; i < output.size(); i++) { + for (int i = 0; i < output.size(); i++) { if (output.get(i) instanceof SetLocalAVM2Item) { if (isKilled(((SetLocalAVM2Item) output.get(i)).regIndex, 0, code.size() - 1)) { SetLocalAVM2Item lsi = (SetLocalAVM2Item) output.get(i); 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 c6f75213e..a1bf9a7e2 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 @@ -34,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)); //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 0e7eadb76..9c4c91aef 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,false); + 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 1b8ef3e0b..c8ce42296 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), 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,true))) { + 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,true)); + 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,true))) { + 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,true)); + 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,true)); + 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,true), 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,true)); + 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(mname.getNamespace(abc.constants).getName(abc.constants,true),a.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,true))) { + 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 638869155..6070b0576 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,true), 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,true); + 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,true).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 d0b2ba6d9..2d69192c1 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,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), 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 449c31ef4..ba5643519 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,true); + 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,raw); + 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 ed83aee72..c1d6b75b6 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,false); + return getName(constants, false); } public String getNameWithKind(AVM2ConstantPool constants) { @@ -101,7 +101,7 @@ public class Namespace { if (name_index == 0) { return null; } - if(raw){ + if (raw) { return constants.getString(name_index); } return Deobfuscation.printNamespace(constants.getString(name_index)); 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 e702bc720..c3a9fd376 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,false); //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 3217a39e4..3b24e58f3 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,true) + "\""; //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,true) + "\")"; //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 a20059986..6f20eb453 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,true)); + 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,true); + 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,false); + 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,false); + 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 94044adcb..c3c609a22 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,false); + 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,false); + 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,false); //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,false); //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 c88995114..faa19d1bf 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 @@ -403,14 +403,14 @@ public class Action implements GraphSourceItem { * @param version SWF version * @param exportMode PCode or hex? * @return source ASM - * + * */ public static String actionsToString(List listeners, long address, ActionList list, int version, ScriptExportMode exportMode) { HilightedTextWriter writer = new HilightedTextWriter(new CodeFormatting(), false); actionsToString(listeners, address, list, version, exportMode, writer); return writer.toString(); } - + /** * Converts list of actions to ASM source * diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionList.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionList.java index b29c116a2..14f4cb009 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionList.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/ActionList.java @@ -190,7 +190,7 @@ public class ActionList extends ArrayList { public String toString() { return Action.actionsToString(new ArrayList(), 0, this, SWF.DEFAULT_VERSION, ScriptExportMode.PCODE); } - + public String toSource() { try { return Action.actionsToSource(null, this, ""); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java index 540d28be0..bc857eaad 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java @@ -28,12 +28,12 @@ import com.jpexs.decompiler.flash.action.ActionLocalData; import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; import com.jpexs.decompiler.flash.action.model.ReturnActionItem; import com.jpexs.decompiler.flash.action.special.ActionEnd; -import com.jpexs.decompiler.flash.action.special.ActionStore; import com.jpexs.decompiler.flash.action.swf4.ActionAdd; import com.jpexs.decompiler.flash.action.swf4.ActionEquals; import com.jpexs.decompiler.flash.action.swf4.ActionGetVariable; import com.jpexs.decompiler.flash.action.swf4.ActionIf; import com.jpexs.decompiler.flash.action.swf4.ActionJump; +import com.jpexs.decompiler.flash.action.swf4.ActionLess; import com.jpexs.decompiler.flash.action.swf4.ActionMultiply; import com.jpexs.decompiler.flash.action.swf4.ActionNot; import com.jpexs.decompiler.flash.action.swf4.ActionPush; @@ -54,14 +54,13 @@ import com.jpexs.decompiler.flash.action.swf5.ActionDefineFunction; import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal; import com.jpexs.decompiler.flash.action.swf5.ActionEquals2; import com.jpexs.decompiler.flash.action.swf5.ActionIncrement; +import com.jpexs.decompiler.flash.action.swf5.ActionLess2; import com.jpexs.decompiler.flash.action.swf5.ActionModulo; import com.jpexs.decompiler.flash.action.swf5.ActionPushDuplicate; import com.jpexs.decompiler.flash.action.swf5.ActionReturn; import com.jpexs.decompiler.flash.action.swf6.ActionGreater; import com.jpexs.decompiler.flash.ecma.EcmaScript; -import com.jpexs.decompiler.flash.helpers.SWFDecompilerListener; import com.jpexs.decompiler.graph.Graph; -import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateException; import com.jpexs.decompiler.graph.TranslateStack; @@ -80,7 +79,7 @@ import java.util.logging.Logger; * * @author JPEXS */ -public class ActionDeobfuscator implements SWFDecompilerListener { +public class ActionDeobfuscator extends ActionDeobfuscatorSimple { private final int executionLimit = 30000; @@ -131,89 +130,6 @@ public class ActionDeobfuscator implements SWFDecompilerListener { return true; } - private boolean removeUnreachableActions(ActionList actions) { - Set reachableActions = new HashSet<>(); - Set processedActions = new HashSet<>(); - reachableActions.add(actions.get(0)); - boolean modified = true; - while (modified) { - modified = false; - for (int i = 0; i < actions.size(); i++) { - Action action = actions.get(i); - if (reachableActions.contains(action) && !processedActions.contains(action)) { - if (!action.isExit() && !(action instanceof ActionJump) && i != actions.size() - 1) { - Action next = actions.get(i + 1); - if (!reachableActions.contains(next)) { - reachableActions.add(next); - } - } - - if (action instanceof ActionJump) { - ActionJump aJump = (ActionJump) action; - long ref = aJump.getAddress() + aJump.getTotalActionLength() + aJump.getJumpOffset(); - Action target = actions.getByAddress(ref); - if (target != null && !reachableActions.contains(target)) { - reachableActions.add(target); - } - } else if (action instanceof ActionIf) { - ActionIf aIf = (ActionIf) action; - long ref = aIf.getAddress() + aIf.getTotalActionLength() + aIf.getJumpOffset(); - Action target = actions.getByAddress(ref); - if (target != null && !reachableActions.contains(target)) { - reachableActions.add(target); - } - } else if (action instanceof ActionStore) { - ActionStore aStore = (ActionStore) action; - int storeSize = aStore.getStoreSize(); - if (actions.size() > i + storeSize) { - Action target = actions.get(i + storeSize); - if (!reachableActions.contains(target)) { - reachableActions.add(target); - } - } - } else if (action instanceof GraphSourceItemContainer) { - GraphSourceItemContainer container = (GraphSourceItemContainer) action; - long ref = action.getAddress() + action.getTotalActionLength(); - for (Long size : container.getContainerSizes()) { - ref += size; - Action target = actions.getByAddress(ref); - if (target != null && !reachableActions.contains(target)) { - reachableActions.add(target); - } - } - } - - processedActions.add(action); - modified = true; - } - } - } - - boolean result = false; - for (int i = 0; i < actions.size(); i++) { - if (!reachableActions.contains(actions.get(i))) { - actions.removeAction(i); - i--; - result = true; - } - } - - return result; - } - - private boolean removeZeroJumps(ActionList actions) { - boolean result = false; - for (int i = 0; i < actions.size(); i++) { - Action action = actions.get(i); - if (action instanceof ActionJump && ((ActionJump) action).getJumpOffset() == 0) { - actions.removeAction(i); - i--; - result = true; - } - } - return result; - } - private boolean removeObfuscationIfs(ActionList actions, Map fakeFunctions) { if (actions.size() == 0) { return false; @@ -303,7 +219,7 @@ public class ActionDeobfuscator implements SWFDecompilerListener { } return cPool; } - + private void executeActions(ActionList actions, int idx, int endIdx, ActionConstantPool constantPool, ExecutionResult result, Map fakeFunctions) { List output = new ArrayList<>(); ActionLocalData localData = new ActionLocalData(); @@ -383,6 +299,8 @@ public class ActionDeobfuscator implements SWFDecompilerListener { || action instanceof ActionSetVariable || action instanceof ActionEquals || action instanceof ActionEquals2 + || action instanceof ActionLess + || action instanceof ActionLess2 || action instanceof ActionGreater || action instanceof ActionNot || action instanceof ActionIf diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimple.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimple.java index 28dff82aa..55f2fd848 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimple.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimple.java @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionList; import com.jpexs.decompiler.flash.action.ActionLocalData; import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.flash.action.special.ActionStore; import com.jpexs.decompiler.flash.action.swf4.ActionAdd; import com.jpexs.decompiler.flash.action.swf4.ActionEquals; import com.jpexs.decompiler.flash.action.swf4.ActionIf; @@ -44,12 +45,15 @@ import com.jpexs.decompiler.flash.action.swf5.ActionPushDuplicate; import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.helpers.SWFDecompilerListener; import com.jpexs.decompiler.graph.Graph; +import com.jpexs.decompiler.graph.GraphSourceItemContainer; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateException; import com.jpexs.decompiler.graph.TranslateStack; import java.util.ArrayList; import java.util.EmptyStackException; +import java.util.HashSet; import java.util.List; +import java.util.Set; /** * @@ -69,6 +73,9 @@ public class ActionDeobfuscatorSimple implements SWFDecompilerListener { return false; } + removeUnreachableActions(actions); + removeZeroJumps(actions); + for (int i = 0; i < actions.size(); i++) { ExecutionResult result = new ExecutionResult(); executeActions(actions, i, actions.size() - 1, result); @@ -79,7 +86,7 @@ public class ActionDeobfuscatorSimple implements SWFDecompilerListener { newIstructionCount++; } - if (newIstructionCount * 2 < result.instructionsProcessed) { + if (newIstructionCount + 1 < result.instructionsProcessed) { Action target = actions.get(result.idx); Action prevAction = actions.get(i); @@ -99,6 +106,18 @@ public class ActionDeobfuscatorSimple implements SWFDecompilerListener { jump.setAddress(prevAction.getAddress()); jump.setJumpOffset((int) (target.getAddress() - jump.getAddress() - jump.getTotalActionLength())); actions.addAction(i++, jump); + + Action nextAction = actions.size() > i ? actions.get(i) : null; + + removeUnreachableActions(actions); + removeZeroJumps(actions); + + if (nextAction != null) { + int nextIdx = actions.indexOf(nextAction); + if (nextIdx < i) { + i = nextIdx; + } + } } } } @@ -106,6 +125,89 @@ public class ActionDeobfuscatorSimple implements SWFDecompilerListener { return false; } + protected boolean removeUnreachableActions(ActionList actions) { + Set reachableActions = new HashSet<>(); + Set processedActions = new HashSet<>(); + reachableActions.add(actions.get(0)); + boolean modified = true; + while (modified) { + modified = false; + for (int i = 0; i < actions.size(); i++) { + Action action = actions.get(i); + if (reachableActions.contains(action) && !processedActions.contains(action)) { + if (!action.isExit() && !(action instanceof ActionJump) && i != actions.size() - 1) { + Action next = actions.get(i + 1); + if (!reachableActions.contains(next)) { + reachableActions.add(next); + } + } + + if (action instanceof ActionJump) { + ActionJump aJump = (ActionJump) action; + long ref = aJump.getAddress() + aJump.getTotalActionLength() + aJump.getJumpOffset(); + Action target = actions.getByAddress(ref); + if (target != null && !reachableActions.contains(target)) { + reachableActions.add(target); + } + } else if (action instanceof ActionIf) { + ActionIf aIf = (ActionIf) action; + long ref = aIf.getAddress() + aIf.getTotalActionLength() + aIf.getJumpOffset(); + Action target = actions.getByAddress(ref); + if (target != null && !reachableActions.contains(target)) { + reachableActions.add(target); + } + } else if (action instanceof ActionStore) { + ActionStore aStore = (ActionStore) action; + int storeSize = aStore.getStoreSize(); + if (actions.size() > i + storeSize) { + Action target = actions.get(i + storeSize); + if (!reachableActions.contains(target)) { + reachableActions.add(target); + } + } + } else if (action instanceof GraphSourceItemContainer) { + GraphSourceItemContainer container = (GraphSourceItemContainer) action; + long ref = action.getAddress() + action.getTotalActionLength(); + for (Long size : container.getContainerSizes()) { + ref += size; + Action target = actions.getByAddress(ref); + if (target != null && !reachableActions.contains(target)) { + reachableActions.add(target); + } + } + } + + processedActions.add(action); + modified = true; + } + } + } + + boolean result = false; + for (int i = 0; i < actions.size(); i++) { + if (!reachableActions.contains(actions.get(i))) { + actions.removeAction(i); + i--; + result = true; + } + } + + return result; + } + + protected boolean removeZeroJumps(ActionList actions) { + boolean result = false; + for (int i = 0; i < actions.size(); i++) { + Action action = actions.get(i); + if (action instanceof ActionJump && ((ActionJump) action).getJumpOffset() == 0) { + actions.removeAction(i); + i--; + result = true; + } + } + return result; + } + private void executeActions(ActionList actions, int idx, int endIdx, ExecutionResult result) { List output = new ArrayList<>(); ActionLocalData localData = new ActionLocalData(); @@ -146,7 +248,8 @@ public class ActionDeobfuscatorSimple implements SWFDecompilerListener { || action instanceof ActionBitRShift || action instanceof ActionEquals || action instanceof ActionNot - || action instanceof ActionIf)) { + || action instanceof ActionIf + || action instanceof ActionJump)) { break; } @@ -166,6 +269,15 @@ public class ActionDeobfuscatorSimple implements SWFDecompilerListener { idx++; + if (action instanceof ActionJump) { + ActionJump jump = (ActionJump) action; + long address = jump.getAddress() + jump.getTotalActionLength() + jump.getJumpOffset(); + idx = actions.indexOf(actions.getByAddress(address)); + if (idx == -1) { + throw new TranslateException("Jump target not found: " + address); + } + } + if (action instanceof ActionIf) { ActionIf aif = (ActionIf) action; if (EcmaScript.toBoolean(stack.pop().getResult())) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java index e8f2385ee..b494859ea 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/parser/script/ActionSourceGenerator.java @@ -181,8 +181,8 @@ public class ActionSourceGenerator implements SourceGenerator { private void fixLoop(List code, int breakOffset, int continueOffset) { int pos = 0; - for (Action a : code) { - pos += a.getBytes(SWF.DEFAULT_VERSION).length; + for (Action a : code) { + pos += a.getTotalActionLength(); if (a instanceof ActionJump) { ActionJump aj = (ActionJump) a; if (aj.isContinue && (continueOffset != Integer.MAX_VALUE)) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java index e27702c9a..10c0118f3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.action.swf4; import com.jpexs.decompiler.flash.EndOfStreamException; +import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; @@ -185,6 +186,7 @@ public class ActionPush extends Action { super(0x96, 0); this.values = new ArrayList<>(); this.values.add(value); + updateLength(SWF.DEFAULT_VERSION); } public ActionPush(FlasmLexer lexer, List constantPool) throws IOException, ActionParseException { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java index 6bc70f02d..cbc4e8728 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/exporters/SoundExporter.java @@ -119,16 +119,16 @@ public class SoundExporter { int nativeFormat = fmt.getNativeExportFormat(); if (nativeFormat == SoundFormat.EXPORT_MP3 && mode.hasMP3()) { - List datas=st.getRawSoundData(); - for(byte[] data:datas){ + List datas = st.getRawSoundData(); + for (byte[] data : datas) { fos.write(data); } } else if ((nativeFormat == SoundFormat.EXPORT_FLV && mode.hasFlv()) || mode == SoundExportMode.FLV) { if (st instanceof DefineSoundTag) { FLVOutputStream flv = new FLVOutputStream(fos); flv.writeHeader(true, false); - List datas=st.getRawSoundData(); - for(byte[] data:datas){ + List datas = st.getRawSoundData(); + for (byte[] data : datas) { flv.writeTag(new FLVTAG(0, new AUDIODATA(st.getSoundFormatId(), st.getSoundRate(), st.getSoundSize(), st.getSoundType(), data))); } } else if (st instanceof SoundStreamHeadTypeTag) { @@ -149,8 +149,8 @@ public class SoundExporter { } else { List soundData = st.getRawSoundData(); SWF swf = ((Tag) st).getSwf(); - List siss=new ArrayList<>(); - for(byte[] data:soundData){ + List siss = new ArrayList<>(); + for (byte[] data : soundData) { siss.add(new SWFInputStream(swf, data)); } fmt.createWav(siss, fos); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java index e8fd8fb2a..e02ce4db2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFontTag.java @@ -37,7 +37,7 @@ import java.util.List; * @author JPEXS */ public class DefineFontTag extends FontTag { - + @SWFType(BasicType.UI16) public int fontId; public List glyphShapeTable; @@ -46,22 +46,22 @@ public class DefineFontTag extends FontTag { @Internal private DefineFontInfo2Tag fontInfo2Tag = null; public static final int ID = 10; - + @Override public boolean isSmall() { return false; } - + @Override public double getGlyphAdvance(int glyphIndex) { return -1; } - + @Override public int getGlyphWidth(int glyphIndex) { return glyphShapeTable.get(glyphIndex).getBounds().getWidth(); } - + private void ensureFontInfo() { if (fontInfoTag == null) { for (Tag t : swf.tags) { @@ -80,7 +80,7 @@ public class DefineFontTag extends FontTag { } } } - + @Override public char glyphToChar(int glyphIndex) { ensureFontInfo(); @@ -92,7 +92,7 @@ public class DefineFontTag extends FontTag { return '?'; } } - + @Override public int charToGlyph(char c) { ensureFontInfo(); @@ -102,7 +102,7 @@ public class DefineFontTag extends FontTag { return fontInfoTag.codeTable.indexOf((int) c); } return -1; - + } /** @@ -147,7 +147,7 @@ public class DefineFontTag extends FontTag { int firstOffset = sis.readUI16("firstOffset"); int nGlyphs = firstOffset / 2; glyphShapeTable = new ArrayList<>(); - + for (int i = 1; i < nGlyphs; i++) { sis.readUI16("offset"); //offset } @@ -155,22 +155,22 @@ public class DefineFontTag extends FontTag { glyphShapeTable.add(sis.readSHAPE(1, false, "shape")); } } - + @Override public int getFontId() { return fontId; } - + @Override public List getGlyphShapeTable() { return glyphShapeTable; } - + @Override public int getCharacterId() { return fontId; } - + @Override public String getFontName() { ensureFontInfo(); @@ -182,7 +182,7 @@ public class DefineFontTag extends FontTag { } return null; } - + @Override public boolean isBold() { if (fontInfo2Tag != null) { @@ -193,7 +193,7 @@ public class DefineFontTag extends FontTag { } return false; } - + @Override public boolean isItalic() { if (fontInfo2Tag != null) { @@ -204,26 +204,26 @@ public class DefineFontTag extends FontTag { } return false; } - + @Override public boolean isSmallEditable() { return false; } - + @Override public boolean isBoldEditable() { return fontInfo2Tag != null || fontInfoTag != null; } - + @Override public boolean isItalicEditable() { return fontInfo2Tag != null || fontInfoTag != null; } - + @Override public void setSmall(boolean value) { } - + @Override public void setBold(boolean value) { if (fontInfo2Tag != null) { @@ -233,7 +233,7 @@ public class DefineFontTag extends FontTag { fontInfoTag.fontFlagsBold = value; } } - + @Override public void setItalic(boolean value) { if (fontInfo2Tag != null) { @@ -243,27 +243,27 @@ public class DefineFontTag extends FontTag { fontInfoTag.fontFlagsItalic = value; } } - + @Override public int getAscent() { return -1; } - + @Override public int getDescent() { return -1; } - + @Override public int getLeading() { return -1; } - + @Override public int getDivider() { return 1; } - + @Override public void addCharacter(char character, String fontName) { SHAPE shp = SHAPERECORD.systemFontCharacterToSHAPE(fontName, getFontStyle(), getDivider() * 1024, character); @@ -297,10 +297,10 @@ public class DefineFontTag extends FontTag { } else { glyphShapeTable.set(pos, shp); } - + setModified(true); } - + @Override public String getCharacters(List tags) { String ret = ""; @@ -317,7 +317,7 @@ public class DefineFontTag extends FontTag { } return ret; } - + @Override public int getGlyphKerningAdjustment(int glyphIndex, int nextGlyphIndex) { return 0; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java index ccd8f575b..287bd2b4b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineSoundTag.java @@ -307,7 +307,7 @@ public class DefineSoundTag extends CharacterTag implements SoundTag { @Override public List getRawSoundData() { - List ret=new ArrayList(); + List ret = new ArrayList<>(); if (soundFormat == SoundFormat.FORMAT_MP3) { ret.add(Arrays.copyOfRange(soundData, 2, soundData.length)); return ret; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java index bac13d946..7f79351dd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHead2Tag.java @@ -182,7 +182,7 @@ public class SoundStreamHead2Tag extends CharacterIdTag implements SoundStreamHe @Override public List getBlocks() { List ret = new ArrayList<>(); - SoundStreamHeadTag.populateSoundStreamBlocks(0,swf.tags, this, ret); + SoundStreamHeadTag.populateSoundStreamBlocks(0, swf.tags, this, ret); return ret; } @@ -199,7 +199,7 @@ public class SoundStreamHead2Tag extends CharacterIdTag implements SoundStreamHe @Override public List getRawSoundData() { - List ret = new ArrayList(); + List ret = new ArrayList<>(); List blocks = getBlocks(); for (SoundStreamBlockTag block : blocks) { if (streamSoundCompression == SoundFormat.FORMAT_MP3) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java index 0032b10de..be9fc7bca 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/SoundStreamHeadTag.java @@ -172,16 +172,16 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea return streamSoundType; } - public static void populateSoundStreamBlocks(int containerId,List tags, Tag head, List output) { + public static void populateSoundStreamBlocks(int containerId, List tags, Tag head, List output) { boolean found = false; for (ContainerItem t : tags) { if (t == head) { found = true; - ((SoundStreamHeadTypeTag)head).setVirtualCharacterId(containerId); + ((SoundStreamHeadTypeTag) head).setVirtualCharacterId(containerId); continue; } if (t instanceof Container) { - populateSoundStreamBlocks(((CharacterIdTag)t).getCharacterId(),((Container) t).getSubItems(), head, output); + populateSoundStreamBlocks(((CharacterIdTag) t).getCharacterId(), ((Container) t).getSubItems(), head, output); } if (!found) { continue; @@ -198,7 +198,7 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea @Override public List getBlocks() { List ret = new ArrayList<>(); - populateSoundStreamBlocks(0,swf.tags, this, ret); + populateSoundStreamBlocks(0, swf.tags, this, ret); return ret; } @@ -215,7 +215,7 @@ public class SoundStreamHeadTag extends CharacterIdTag implements SoundStreamHea @Override public List getRawSoundData() { - List ret = new ArrayList(); + List ret = new ArrayList<>(); List blocks = getBlocks(); for (SoundStreamBlockTag block : blocks) { if (streamSoundCompression == SoundFormat.FORMAT_MP3) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java index 86ec24769..2a9863c5c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/base/FontTag.java @@ -43,7 +43,6 @@ import java.awt.font.FontRenderContext; import java.awt.font.GlyphMetrics; import java.awt.font.GlyphVector; import java.awt.geom.Area; -import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -174,7 +173,7 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable } else if (t instanceof DefineText2Tag) { textRecords = ((DefineText2Tag) t).textRecords; } - + if (textRecords != null) { int curFontId = 0; for (TEXTRECORD tr : textRecords) { @@ -192,7 +191,7 @@ public abstract class FontTag extends CharacterTag implements AloneTag, Drawable en.glyphIndex++; } } - + t.setModified(true); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java index 3a4091d7e..951f81591 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/types/sound/SoundFormat.java @@ -166,7 +166,7 @@ public class SoundFormat { public boolean createWav(List siss, OutputStream os) { ensureFormat(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); - for(SWFInputStream sis:siss){ + for (SWFInputStream sis : siss) { decode(sis, baos); } try { diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java index e3b2db041..342abfd7f 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java @@ -80,7 +80,7 @@ public class ActionScript2DeobfuscatorTest extends ActionStript2TestBase { }; } - // todo: honfika @Test(dataProvider = "provideBasicTrueExpressions") + @Test(dataProvider = "provideBasicTrueExpressions") public void testRemoveBasicTrueExpressions(String expression) throws ActionParseException, IOException, CompilationException, InterruptedException, TimeoutException{ String res = recompile("if("+expression+"){"+ "trace(\"OK\");"+ @@ -88,14 +88,14 @@ public class ActionScript2DeobfuscatorTest extends ActionStript2TestBase { "trace(\"FAIL\");"+ "}"); if(res.contains("\"FAIL\"")){ - fail("OnFalse clause was not removed:"+res); + fail("OnFalse clause was not removed: " + res); } if(!res.contains("\"OK\"")){ - fail("OnTrue clause was removed:"+res); + fail("OnTrue clause was removed: " + res); } } - // todo: honfika @Test(dataProvider = "provideBasicFalseExpressions") + @Test(dataProvider = "provideBasicFalseExpressions") public void testRemoveBasicFalseExpressions(String expression) throws Exception { String res = recompile("if("+expression+"){"+ "trace(\"FAIL\");"+ diff --git a/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java b/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java index e11dabe95..3c5acc243 100644 --- a/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/BinaryPanel.java @@ -16,12 +16,7 @@ */ package com.jpexs.decompiler.flash.gui; -import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.gui.hexview.HexView; -import com.jpexs.decompiler.flash.gui.treenodes.SWFNode; -import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; -import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.treenodes.TagNode; import com.jpexs.helpers.utf8.Utf8Helper; import java.awt.BorderLayout; @@ -32,8 +27,6 @@ import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.io.ByteArrayInputStream; -import java.io.IOException; import java.util.Arrays; import javax.swing.BorderFactory; import javax.swing.JLabel; @@ -51,7 +44,7 @@ public final class BinaryPanel extends JPanel implements ComponentListener { private byte[] data; private JPanel swfInsidePanel; private TagNode node = null; - private MainPanel mainPanel; + private final MainPanel mainPanel; public BinaryPanel(final MainPanel mainPanel) { super(new BorderLayout()); @@ -65,7 +58,7 @@ public final class BinaryPanel extends JPanel implements ComponentListener { add(bottomPanel, BorderLayout.SOUTH); addComponentListener(this); swfInsidePanel = new JPanel(); - swfInsidePanel.setBackground(new Color(253,205,137)); + swfInsidePanel.setBackground(new Color(253, 205, 137)); swfInsidePanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); swfInsidePanel.add(new JLabel(AppStrings.translate("binarydata.swfInside"))); swfInsidePanel.setFocusable(true); @@ -90,7 +83,7 @@ public final class BinaryPanel extends JPanel implements ComponentListener { hexEditor.setData(data, null, null); if (node != null) { - if(node.subNodes.isEmpty() && data.length>8){ + if (node.subNodes.isEmpty() && data.length > 8) { try { String signature = new String(data, 0, 3, Utf8Helper.charset); if (Arrays.asList( @@ -101,11 +94,11 @@ public final class BinaryPanel extends JPanel implements ComponentListener { "CFX" //Compressed ScaleForm GFx ).contains(signature)) { swfInsidePanel.setVisible(true); - } + } } catch (Exception ex) { swfInsidePanel.setVisible(false); } - }else{ + } else { swfInsidePanel.setVisible(false); } } else { diff --git a/src/com/jpexs/decompiler/flash/gui/LoadingDialog.java b/src/com/jpexs/decompiler/flash/gui/LoadingDialog.java index 3648c331c..ab67ee1ca 100644 --- a/src/com/jpexs/decompiler/flash/gui/LoadingDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/LoadingDialog.java @@ -64,6 +64,8 @@ public class LoadingDialog extends AppDialog implements ImageObserver { /** * Constructor + * + * @param owner */ public LoadingDialog(Window owner) { super(owner); diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index fe6f39d69..01a8cab83 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -78,7 +78,6 @@ import java.util.logging.Logger; import java.util.logging.SimpleFormatter; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.swing.JDialog; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JOptionPane; @@ -184,7 +183,7 @@ public class Main { } public static void startWork(final String name, final int percent, final CancellableWorker worker) { - working = true; + working = true; View.execInEventDispatchLater(new Runnable() { @Override public void run() { @@ -508,8 +507,8 @@ public class Main { View.execInEventDispatch(new Runnable() { @Override public void run() { - if (Main.loadingDialog == null || Main.loadingDialog.getOwner() == null) { - Main.loadingDialog = new LoadingDialog(mainFrame==null?null:mainFrame.getWindow()); + if (Main.loadingDialog == null || Main.loadingDialog.getOwner() == null) { + Main.loadingDialog = new LoadingDialog(mainFrame == null ? null : mainFrame.getWindow()); } } }); diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index e2a1c1dbc..01f0e40dd 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -2224,37 +2224,37 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec } public void loadFromBinaryTag(final TagNode node) { - - if (Main.loadingDialog == null || Main.loadingDialog.getOwner() == null) { - Main.loadingDialog = new LoadingDialog(mainFrame==null?null:mainFrame.getWindow()); + + if (Main.loadingDialog == null || Main.loadingDialog.getOwner() == null) { + Main.loadingDialog = new LoadingDialog(mainFrame == null ? null : mainFrame.getWindow()); } Main.loadingDialog.setVisible(true); - Main.startWork(AppStrings.translate("work.reading.swf") + "..."); - new Thread(){ + Main.startWork(AppStrings.translate("work.reading.swf") + "..."); + new Thread() { @Override - public void run() { - try { - SWF bswf = new SWF(new ByteArrayInputStream(((DefineBinaryDataTag)node.getItem()).binaryData),new ProgressListener() { + public void run() { + try { + SWF bswf = new SWF(new ByteArrayInputStream(((DefineBinaryDataTag) node.getItem()).binaryData), new ProgressListener() { @Override public void progress(int p) { - Main.loadingDialog.setPercent(p); + Main.loadingDialog.setPercent(p); } }, Configuration.parallelSpeedUp.get()); bswf.fileTitle = "(SWF Data)"; SWFNode snode = ((TagTreeModel) tagTree.getModel()).createSwfNode(bswf); snode.binaryData = (DefineBinaryDataTag) node.getItem(); - node.subNodes.add(snode); + node.subNodes.add(snode); } catch (IOException | InterruptedException ex) { //ignore } Main.loadingDialog.setVisible(false); Main.stopWork(); } - + }.start(); - + } public void reload(boolean forceReload) { diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java index 202c39b65..1d4bc8649 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java @@ -425,14 +425,14 @@ public class PreviewPanel extends JSplitPane implements ActionListener { public void clear() { imagePanel.stop(); - binaryPanel.setBinaryData(null,null); + binaryPanel.setBinaryData(null, null); genericTagPanel.clear(); fontPanel.clear(); } - public void showBinaryPanel(byte[] data,TagNode node) { + public void showBinaryPanel(byte[] data, TagNode node) { showCardLeft(BINARY_TAG_CARD); - binaryPanel.setBinaryData(data,node); + binaryPanel.setBinaryData(data, node); parametersPanel.setVisible(false); } diff --git a/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java b/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java index 077802114..491e7ef54 100644 --- a/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java +++ b/src/com/jpexs/decompiler/flash/gui/SoundTagPlayer.java @@ -72,9 +72,9 @@ public class SoundTagPlayer implements MediaDisplay { ByteArrayOutputStream baos = new ByteArrayOutputStream(); List soundData = tag.getRawSoundData(); SWF swf = ((Tag) tag).getSwf(); - List siss=new ArrayList<>(); - for(byte[] data:soundData){ - siss.add(new SWFInputStream(swf,data)); + List siss = new ArrayList<>(); + for (byte[] data : soundData) { + siss.add(new SWFInputStream(swf, data)); } tag.getSoundFormat().createWav(siss, baos); player = new SoundPlayer(new ByteArrayInputStream(baos.toByteArray())); diff --git a/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java b/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java index 1aef80bd3..7086890f2 100644 --- a/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java +++ b/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java @@ -17,7 +17,6 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.gui.abc.ClassesListTreeModel; import com.jpexs.decompiler.flash.gui.abc.treenodes.ClassesListNode; import com.jpexs.decompiler.flash.gui.abc.treenodes.TreeElement; @@ -26,7 +25,6 @@ import com.jpexs.decompiler.flash.gui.treenodes.SWFContainerNode; import com.jpexs.decompiler.flash.gui.treenodes.SWFNode; import com.jpexs.decompiler.flash.gui.treenodes.StringNode; import com.jpexs.decompiler.flash.gui.treenodes.TagTreeRoot; -import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag; import com.jpexs.decompiler.flash.tags.DefineSpriteTag; import com.jpexs.decompiler.flash.tags.ShowFrameTag; import com.jpexs.decompiler.flash.tags.SoundStreamBlockTag; @@ -44,14 +42,10 @@ import com.jpexs.decompiler.flash.treenodes.FrameNode; import com.jpexs.decompiler.flash.treenodes.HeaderNode; import com.jpexs.decompiler.flash.treenodes.TagNode; import com.jpexs.decompiler.flash.treenodes.TreeNode; -import java.io.ByteArrayInputStream; -import java.io.IOException; 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; import javax.swing.event.TreeModelListener; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; @@ -106,17 +100,16 @@ public class TagTreeModel implements TreeModel { return mainFrame.translate(key); } - - private List getSoundStreams(DefineSpriteTag sprite){ - List ret=new ArrayList<>(); - for(Tag t:sprite.subTags){ - if(t instanceof SoundStreamHeadTypeTag){ + private List getSoundStreams(DefineSpriteTag sprite) { + List ret = new ArrayList<>(); + for (Tag t : sprite.subTags) { + if (t instanceof SoundStreamHeadTypeTag) { ret.add(new TagNode(t)); } } return ret; } - + private List createTagList(List list, SWF swf, SWFNode swfNode, ClassesListTreeModel classTreeModel) { boolean hasAbc = swf.abcList != null && !swf.abcList.isEmpty(); @@ -149,7 +142,7 @@ public class TagTreeModel implements TreeModel { break; case SPRITE: sprites.add(new TagNode(t)); - sounds.addAll(getSoundStreams((DefineSpriteTag)t)); + sounds.addAll(getSoundStreams((DefineSpriteTag) t)); break; case BUTTON: buttons.add(new TagNode(t)); @@ -171,7 +164,7 @@ public class TagTreeModel implements TreeModel { break; case BINARY_DATA: TagNode bt; - binaryData.add(bt = new TagNode(t)); + binaryData.add(bt = new TagNode(t)); break; default: if (!actionScriptTags.contains(t) && t.getId() != ShowFrameTag.ID && !ShowFrameTag.isNestedTagType(t.getId())) { diff --git a/src/com/jpexs/decompiler/flash/gui/TextPanel.java b/src/com/jpexs/decompiler/flash/gui/TextPanel.java index d03ac2bc9..6ac9f02ef 100644 --- a/src/com/jpexs/decompiler/flash/gui/TextPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/TextPanel.java @@ -51,7 +51,7 @@ public class TextPanel extends JPanel implements ActionListener { super(new BorderLayout()); DefaultSyntaxKit.initKit(); - + this.mainPanel = mainPanel; textSearchPanel = new SearchPanel<>(new FlowLayout(), mainPanel); add(textSearchPanel, BorderLayout.NORTH); 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 3e78d8e9a..11bd58702 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/NamespaceTableModel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/tablemodels/NamespaceTableModel.java @@ -122,7 +122,7 @@ public class NamespaceTableModel implements TableModel { if (rowIndex == 0) { return "-"; } - String val = abc.constants.getNamespace(rowIndex).getName(abc.constants,true); + String val = abc.constants.getNamespace(rowIndex).getName(abc.constants, true); if (val == null) { val = "-"; } diff --git a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index 30f0a5b38..df0d6b7c1 100644 --- a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -153,25 +153,25 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene SyntaxDocument sDoc = ActionUtils.getSyntaxDocument(decompiledEditor); if (sDoc != null) { Token t = sDoc.getTokenAt(pos); - String ident=null; + String ident = null; //It should be identifier or obfuscated identifier - if (t != null && (t.type == TokenType.IDENTIFIER || t.type == TokenType.REGEX)) { + if (t != null && (t.type == TokenType.IDENTIFIER || t.type == TokenType.REGEX)) { CharSequence tData = t.getText(sDoc); - ident=tData.toString(); + ident = tData.toString(); //We need to get unescaped identifier, so we use our Lexer - ActionScriptLexer lex=new ActionScriptLexer(new StringReader(ident)); + ActionScriptLexer lex = new ActionScriptLexer(new StringReader(ident)); try { - ParsedSymbol symb=lex.lex(); - if(symb.type==SymbolType.IDENTIFIER){ - ident = (String)symb.value; - }else{ + ParsedSymbol symb = lex.lex(); + if (symb.type == SymbolType.IDENTIFIER) { + ident = (String) symb.value; + } else { ident = null; } } catch (IOException | ActionParseException ex) { - ident=null; - } - } - if(ident==null){ + ident = null; + } + } + if (ident == null) { Highlighting h = Highlighting.search(decompiledHilights, pos); if (h != null) { List list = lastCode; @@ -206,11 +206,11 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene } } - }else{ + } else { return ident; } } - return null; + return null; } private CachedScript getCached(ASMSource pack) { diff --git a/src/com/jpexs/decompiler/flash/gui/generictageditors/ColorEditor.java b/src/com/jpexs/decompiler/flash/gui/generictageditors/ColorEditor.java index 72b4f2fb6..b0b20432a 100644 --- a/src/com/jpexs/decompiler/flash/gui/generictageditors/ColorEditor.java +++ b/src/com/jpexs/decompiler/flash/gui/generictageditors/ColorEditor.java @@ -32,8 +32,6 @@ import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.lang.reflect.Array; import java.lang.reflect.Field; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JColorChooser;