diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java index bb3e384da..454adb864 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWF.java @@ -1162,7 +1162,7 @@ public final class SWF implements SWFContainerItem, Timelined { public List getAS3Packs() { List packs = new ArrayList<>(); for (ABCContainerTag abcTag : getAbcList()) { - packs.addAll(abcTag.getABC().getScriptPacks()); + packs.addAll(abcTag.getABC().getScriptPacks(null)); } return uniqueAS3Packs(packs); } 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 393bc7440..218b463fb 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 @@ -866,10 +866,10 @@ public class ABC { } } - public List getScriptPacks() { + public List getScriptPacks(String packagePrefix) { List ret = new ArrayList<>(); for (int i = 0; i < script_info.size(); i++) { - ret.addAll(script_info.get(i).getPacks(this, i)); + ret.addAll(script_info.get(i).getPacks(this, i, packagePrefix)); } return ret; } @@ -1045,7 +1045,7 @@ public class ABC { public List findScriptPacksByPath(String name) { List ret = new ArrayList<>(); - List allPacks = getScriptPacks(); + List allPacks = getScriptPacks(null); // todo: honfika: use filter parameter if (name.endsWith(".**") || name.equals("**") || name.endsWith(".++") || name.equals("++")) { name = name.substring(0, name.length() - 2); @@ -1076,7 +1076,7 @@ public class ABC { } public ScriptPack findScriptPackByPath(String name) { - List packs = getScriptPacks(); + List packs = getScriptPacks(null); for (ScriptPack en : packs) { if (en.getClassPath().toString().equals(name)) { return en; 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 f7b9929a2..415017877 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 @@ -40,7 +40,7 @@ public class ScriptInfo { this.traits = traits; } - public List getPacks(ABC abc, int scriptIndex) { + public List getPacks(ABC abc, int scriptIndex, String packagePrefix) { List ret = new ArrayList<>(); List otherTraits = new ArrayList<>(); @@ -66,10 +66,13 @@ public class ScriptInfo { traitIndices.add(j); if (!otherTraits.isEmpty()) { traitIndices.addAll(otherTraits); + otherTraits.clear(); + } + + if (packagePrefix == null || packageName.startsWith(packagePrefix)) { + ClassPath cp = new ClassPath(packageName, objectName); + ret.add(new ScriptPack(cp, abc, scriptIndex, traitIndices)); } - otherTraits = new ArrayList<>(); - ClassPath cp = new ClassPath(packageName, objectName); - ret.add(new ScriptPack(cp, abc, scriptIndex, traitIndices)); } } return ret; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java index 03a6658a0..b23070422 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 @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.abc.types.traits; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.ClassPath; import com.jpexs.decompiler.flash.abc.types.Multiname; import com.jpexs.decompiler.flash.abc.types.Namespace; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; @@ -189,11 +190,11 @@ public abstract class Trait implements Serializable { public abstract int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc, String path) throws InterruptedException; - public String getPath(ABC abc) { + public ClassPath getPath(ABC abc) { Multiname name = getName(abc); Namespace ns = name.getNamespace(abc.constants); String packageName = ns.getName(abc.constants, false); String objectName = name.getName(abc.constants, new ArrayList(), false); - return packageName + "." + objectName; //assume not null name + return new ClassPath(packageName, objectName); //assume not null name } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index 049312d13..2e2014557 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 @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash.abc.types.traits; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.ClassPath; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewFunctionIns; @@ -366,18 +367,12 @@ public class TraitClass extends Trait implements TraitWithSlot { for (ABCContainerTag tag : abc.getAbcTags()) { for (ScriptInfo si : tag.getABC().script_info) { for (Trait t : si.traits.traits) { - String spath = t.getPath(tag.getABC()); - String pkg = ""; - String name = spath; - if (spath.contains(".")) { - pkg = spath.substring(0, spath.lastIndexOf('.')); - name = spath.substring(spath.lastIndexOf('.') + 1); - } + ClassPath classPath = t.getPath(tag.getABC()); + String pkg = classPath.packageStr == null ? "" : classPath.packageStr; if (pkg.equals(packageName)) { - namesInThisPackage.add(name); + namesInThisPackage.add(classPath.className); } } - } } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index 1b6c782b2..f8738395d 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -804,7 +804,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se try { String oldSp = null; - List packs = abc.script_info.get(oldIndex).getPacks(abc, oldIndex); + List packs = abc.script_info.get(oldIndex).getPacks(abc, oldIndex, null); if (!packs.isEmpty()) { oldSp = packs.get(0).getClassPath().toString(); } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java b/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java index fc8401188..de57feb98 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ClassesListTreeModel.java @@ -81,7 +81,8 @@ public class ClassesListTreeModel extends AS3ClassTreeItem implements TreeModel } } - AS3Package pkg = ensurePackage(item.getClassPath().packageStr); + String packageStr = item.getClassPath().packageStr; + AS3Package pkg = ensurePackage(packageStr); pkg.addScriptPack(item); } } diff --git a/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java b/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java index 3d87544ca..0bf9c798d 100644 --- a/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java +++ b/src/com/jpexs/decompiler/flash/gui/debugger/DebuggerTools.java @@ -47,7 +47,7 @@ public class DebuggerTools { private static ScriptPack getDebuggerScriptPack(SWF swf) { for (ABCContainerTag ac : swf.getAbcList()) { ABC a = ac.getABC(); - for (ScriptPack m : a.getScriptPacks()) { + for (ScriptPack m : a.getScriptPacks(DEBUGGER_PACKAGE)) { if (isDebuggerClass(m.getClassPath().packageStr, null)) { return m; } @@ -64,11 +64,18 @@ public class DebuggerTools { if (tested == null) { return false; } + + // fast check, because dynamic regex compile and match is expensive + if (!tested.startsWith(DEBUGGER_PACKAGE)) { + return false; + } + if (cls == null) { cls = ""; } else { cls = "\\." + Pattern.quote(cls); } + return tested.matches(Pattern.quote(DEBUGGER_PACKAGE) + "(\\.pkg[a-f0-9]+)?" + cls); }