From c86be8aac5f042863ee6e7095acbee61631f6027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Fri, 12 Apr 2013 20:22:21 +0200 Subject: [PATCH] DoABC(82) renamed to DoABCDefine, DoABC(72) tag created --- trunk/src/com/jpexs/decompiler/flash/SWF.java | 15 +-- .../decompiler/flash/SWFInputStream.java | 6 +- .../com/jpexs/decompiler/flash/abc/ABC.java | 7 +- .../flash/abc/gui/ABCComboBoxModel.java | 7 +- .../decompiler/flash/abc/gui/ABCPanel.java | 15 +-- .../flash/abc/gui/ClassesListTree.java | 19 +-- .../flash/abc/gui/DecompiledEditorPane.java | 7 +- .../decompiler/flash/abc/gui/TraitsList.java | 7 +- .../flash/abc/gui/TraitsListItem.java | 7 +- .../flash/abc/gui/TraitsListModel.java | 7 +- .../decompiler/flash/abc/gui/UsageFrame.java | 5 +- .../flash/abc/gui/UsageListModel.java | 7 +- .../flash/abc/types/ScriptInfo.java | 7 +- .../abc/usages/ClassNameMultinameUsage.java | 4 +- .../abc/usages/ConstVarMultinameUsage.java | 4 +- .../usages/ConstVarNameMultinameUsage.java | 4 +- .../usages/ConstVarTypeMultinameUsage.java | 4 +- .../abc/usages/ExtendsMultinameUsage.java | 4 +- .../abc/usages/ImplementsMultinameUsage.java | 4 +- .../abc/usages/InsideClassMultinameUsage.java | 5 +- .../abc/usages/MethodBodyMultinameUsage.java | 4 +- .../abc/usages/MethodMultinameUsage.java | 4 +- .../abc/usages/MethodNameMultinameUsage.java | 4 +- .../usages/MethodParamsMultinameUsage.java | 4 +- .../MethodReturnTypeMultinameUsage.java | 4 +- .../flash/abc/usages/MultinameUsage.java | 5 +- .../abc/usages/TypeNameMultinameUsage.java | 4 +- .../jpexs/decompiler/flash/gui/MainFrame.java | 38 +++--- .../flash/tags/ABCContainerTag.java | 27 +++++ .../decompiler/flash/tags/DoABCDefineTag.java | 108 ++++++++++++++++++ .../jpexs/decompiler/flash/tags/DoABCTag.java | 37 +++--- .../decompiler/flash/ActionScript3Test.java | 12 +- .../com/jpexs/decompiler/flash/Generator.java | 10 +- .../jpexs/decompiler/flash/RecompileTest.java | 1 + 34 files changed, 274 insertions(+), 133 deletions(-) create mode 100644 trunk/src/com/jpexs/decompiler/flash/tags/ABCContainerTag.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index f366e4bbc..e50a0d9d5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -49,6 +49,7 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; import com.jpexs.decompiler.flash.gui.FrameNode; import com.jpexs.decompiler.flash.gui.TagNode; import com.jpexs.decompiler.flash.helpers.Helper; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag; import com.jpexs.decompiler.flash.tags.DefineBitsJPEG3Tag; import com.jpexs.decompiler.flash.tags.DefineBitsJPEG4Tag; @@ -60,7 +61,7 @@ import com.jpexs.decompiler.flash.tags.DefineButtonTag; import com.jpexs.decompiler.flash.tags.DefineSoundTag; import com.jpexs.decompiler.flash.tags.DefineSpriteTag; import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import com.jpexs.decompiler.flash.tags.DoInitActionTag; import com.jpexs.decompiler.flash.tags.ExportAssetsTag; import com.jpexs.decompiler.flash.tags.JPEGTablesTag; @@ -413,17 +414,17 @@ public class SWF { } } }; - List abcTags = new ArrayList(); + List abcTags = new ArrayList(); for (Tag t : tags) { - if (t instanceof DoABCTag) { - abcTags.add((DoABCTag) t); + if (t instanceof ABCContainerTag) { + abcTags.add((ABCContainerTag) t); asV3Found = true; } } for (int i = 0; i < abcTags.size(); i++) { - DoABCTag t = abcTags.get(i); - t.abc.addEventListener(evl); - t.abc.export(outdir, isPcode, abcTags, "tag " + (i + 1) + "/" + abcTags.size() + " "); + ABCContainerTag t = abcTags.get(i); + t.getABC().addEventListener(evl); + t.getABC().export(outdir, isPcode, abcTags, "tag " + (i + 1) + "/" + abcTags.size() + " "); } if (!asV3Found) { diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java index 1546f3755..e3a446070 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -1286,7 +1286,9 @@ public class SWFInputStream extends InputStream { case 71: ret = new ImportAssets2Tag(data, version, pos); break; - //case 72: + case 72: + ret = new DoABCTag(data, version, pos); + break; case 73: ret = new DefineFontAlignZonesTag(data, version, pos); break; @@ -1307,7 +1309,7 @@ public class SWFInputStream extends InputStream { break; //case 79-81: case 82: - ret = new DoABCTag(data, version, pos); + ret = new DoABCDefineTag(data, version, pos); break; case 83: ret = new DefineShape4Tag(data, version, pos); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java index ceaa21535..c742a789a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -27,7 +27,8 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.abc.types.traits.Traits; import com.jpexs.decompiler.flash.abc.usages.*; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import java.io.*; import java.util.ArrayList; import java.util.HashMap; @@ -543,11 +544,11 @@ public class ABC { } } - public void export(String directory, boolean pcode, List abcList) throws IOException { + public void export(String directory, boolean pcode, List abcList) throws IOException { export(directory, pcode, abcList, ""); } - public void export(String directory, boolean pcode, List abcList, String abcStr) throws IOException { + public void export(String directory, boolean pcode, List abcList, String abcStr) throws IOException { for (int i = 0; i < script_info.length; i++) { String path = script_info[i].getPath(this); String packageName = path.substring(0, path.lastIndexOf(".")); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCComboBoxModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCComboBoxModel.java index 6bece613b..5fc717115 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCComboBoxModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCComboBoxModel.java @@ -16,7 +16,8 @@ */ package com.jpexs.decompiler.flash.abc.gui; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import java.util.Collections; import java.util.List; import javax.swing.ComboBoxModel; @@ -24,11 +25,11 @@ import javax.swing.event.ListDataListener; public class ABCComboBoxModel implements ComboBoxModel { - public List list; + public List list; public int itemIndex = 0; public static final String ROOT = " - all - "; - public ABCComboBoxModel(List list) { + public ABCComboBoxModel(List list) { this.list = list; Collections.sort(this.list); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java index 6250788e1..863481c95 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java @@ -20,7 +20,8 @@ import com.jpexs.decompiler.flash.Main; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.gui.tablemodels.*; import com.jpexs.decompiler.flash.gui.View; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Font; @@ -42,7 +43,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener { public TraitsList navigator; public ClassesListTree classTree; public ABC abc; - public List list; + public List list; public JComboBox abcComboBox; public int listIndex = -1; public DecompiledEditorPane decompiledTextArea; @@ -147,9 +148,9 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener { if (index == -1) { classTree.setDoABCTags(list); } else { - List oneList = new ArrayList(); + List oneList = new ArrayList(); oneList.add(list.get(index)); - this.abc = list.get(index).abc; + this.abc = list.get(index).getABC(); classTree.setDoABCTags(oneList); } updateConstList(); @@ -172,14 +173,14 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener { } - public ABCPanel(List list) { + public ABCPanel(List list) { DefaultSyntaxKit.initKit(); this.list = list; if (list.size() > 0) { - this.abc = list.get(0).abc; + this.abc = list.get(0).getABC(); } setLayout(new BorderLayout()); @@ -302,7 +303,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener { } constantTable.setAutoCreateRowSorter(true); - final List inlist = list; + final List inlist = list; final ABCPanel t = this; constantTable.addMouseListener(new MouseAdapter() { @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTree.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTree.java index 60f027b5c..c9d43956a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTree.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTree.java @@ -20,7 +20,8 @@ import com.jpexs.decompiler.flash.Main; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitClass; import com.jpexs.decompiler.flash.gui.View; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -33,7 +34,7 @@ import javax.swing.tree.TreeSelectionModel; public class ClassesListTree extends JTree implements TreeSelectionListener { - private List abcList; + private List abcList; public HashMap treeList; private ABCPanel abcPanel; @@ -45,7 +46,7 @@ public class ClassesListTree extends JTree implements TreeSelectionListener { scrollPathToVisible(treePath); } - public ClassesListTree(List list, ABCPanel abcPanel) { + public ClassesListTree(List list, ABCPanel abcPanel) { this.abcList = list; this.treeList = getTreeList(list); this.abcPanel = abcPanel; @@ -92,18 +93,18 @@ public class ClassesListTree extends JTree implements TreeSelectionListener { return selectedScripts; } - public HashMap getTreeList(List list) { + public HashMap getTreeList(List list) { HashMap ret = new HashMap(); - for (DoABCTag tag : list) { - for (int i = 0; i < tag.abc.script_info.length; i++) { - String path = tag.abc.script_info[i].getPath(tag.abc); - ret.put(path, new TreeLeafScript(tag.abc, i)); + for (ABCContainerTag tag : list) { + for (int i = 0; i < tag.getABC().script_info.length; i++) { + String path = tag.getABC().script_info[i].getPath(tag.getABC()); + ret.put(path, new TreeLeafScript(tag.getABC(), i)); } } return ret; } - public void setDoABCTags(List list) { + public void setDoABCTags(List list) { this.abcList = list; this.treeList = getTreeList(list); setModel(new ClassesListTreeModel(this.treeList)); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java index 2a944d0d5..c25a19e4b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java @@ -21,7 +21,8 @@ import com.jpexs.decompiler.flash.abc.types.ScriptInfo; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.helpers.Highlighting; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -263,13 +264,13 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL addCaretListener(this); this.abcPanel = abcPanel; } - private List abcList; + private List abcList; public void clearScriptCache() { bufferedClasses.clear(); } - public void setScript(ScriptInfo script, ABC abc, List abcList) { + public void setScript(ScriptInfo script, ABC abc, List abcList) { if (script == null) { highlights = new ArrayList(); traitHighlights = new ArrayList(); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsList.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsList.java index 42a1b6a2f..3f3dfb5da 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsList.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsList.java @@ -17,7 +17,8 @@ package com.jpexs.decompiler.flash.abc.gui; import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import java.util.List; import javax.swing.DefaultListModel; import javax.swing.JList; @@ -27,7 +28,7 @@ import javax.swing.event.ListSelectionListener; public class TraitsList extends JList implements ListSelectionListener { ABC abc; - List abcTags; + List abcTags; int classIndex = -1; private ABCPanel abcPanel; private boolean sorted = false; @@ -49,7 +50,7 @@ public class TraitsList extends JList implements ListSelectionListener { setCellRenderer(new IconListRenderer()); } - public void setABC(List abcTags, ABC abc) { + public void setABC(List abcTags, ABC abc) { this.abc = abc; this.abcTags = abcTags; setModel(new DefaultListModel()); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListItem.java index 53ff71380..26cf51eaa 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListItem.java @@ -4,7 +4,8 @@ import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import java.util.ArrayList; import java.util.List; @@ -16,14 +17,14 @@ public class TraitsListItem { private Type type; private boolean isStatic; - private List abcTags; + private List abcTags; private ABC abc; private int classIndex; private int index; public static final String STR_INSTANCE_INITIALIZER = "instance initializer"; public static final String STR_CLASS_INITIALIZER = "class initializer"; - public TraitsListItem(Type type, int index, boolean isStatic, List abcTags, ABC abc, int classIndex) { + public TraitsListItem(Type type, int index, boolean isStatic, List abcTags, ABC abc, int classIndex) { this.type = type; this.index = index; this.isStatic = isStatic; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListModel.java index b95e78383..012529a65 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListModel.java @@ -17,7 +17,8 @@ package com.jpexs.decompiler.flash.abc.gui; import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -28,7 +29,7 @@ import javax.swing.event.ListDataListener; public class TraitsListModel implements ListModel { private List items; - private List abcTags; + private List abcTags; private ABC abc; private int classIndex; @@ -57,7 +58,7 @@ public class TraitsListModel implements ListModel { items.add(new TraitsListItem(TraitsListItem.Type.INITIALIZER, 0, true, abcTags, abc, classIndex)); } - public TraitsListModel(List abcTags, ABC abc, int classIndex, boolean sorted) { + public TraitsListModel(List abcTags, ABC abc, int classIndex, boolean sorted) { this.abcTags = abcTags; this.abc = abc; this.classIndex = classIndex; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/UsageFrame.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/UsageFrame.java index 744bb2ff2..dddef2527 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/UsageFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/UsageFrame.java @@ -22,7 +22,8 @@ import com.jpexs.decompiler.flash.abc.usages.MethodMultinameUsage; import com.jpexs.decompiler.flash.abc.usages.MultinameUsage; import com.jpexs.decompiler.flash.abc.usages.TraitMultinameUsage; import com.jpexs.decompiler.flash.gui.View; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import java.awt.BorderLayout; import java.awt.Container; import java.awt.FlowLayout; @@ -46,7 +47,7 @@ public class UsageFrame extends JFrame implements ActionListener, MouseListener private ABC abc; private ABCPanel abcPanel; - public UsageFrame(List abcTags, ABC abc, int multinameIndex, ABCPanel abcPanel) { + public UsageFrame(List abcTags, ABC abc, int multinameIndex, ABCPanel abcPanel) { this.abcPanel = abcPanel; List usages = abc.findMultinameUsage(multinameIndex); this.abc = abc; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/UsageListModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/UsageListModel.java index 825a87bc7..d4ec060eb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/UsageListModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/UsageListModel.java @@ -18,7 +18,8 @@ package com.jpexs.decompiler.flash.abc.gui; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.usages.MultinameUsage; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import java.util.List; import javax.swing.DefaultListModel; @@ -29,9 +30,9 @@ import javax.swing.DefaultListModel; public class UsageListModel extends DefaultListModel { private ABC abc; - private List abcTags; + private List abcTags; - public UsageListModel(List abcTags, ABC abc) { + public UsageListModel(List abcTags, ABC abc) { this.abc = abc; this.abcTags = abcTags; } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java index 064cac5be..5bcba6255 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java @@ -20,7 +20,8 @@ import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitClass; import com.jpexs.decompiler.flash.abc.types.traits.Traits; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -62,11 +63,11 @@ public class ScriptInfo { return packageName + "." + scriptName; } - public String convert(List abcTags, ABC abc, boolean pcode, boolean highlighting) { + public String convert(List abcTags, ABC abc, boolean pcode, boolean highlighting) { return traits.convert("", abcTags, abc, false, pcode, true, -1, highlighting, new ArrayList()); } - public void export(ABC abc, List abcList, String directory, boolean pcode) throws IOException { + public void export(ABC abc, List abcList, String directory, boolean pcode) throws IOException { String path = getPath(abc); String packageName = path.substring(0, path.lastIndexOf(".")); String className = path.substring(path.lastIndexOf(".") + 1); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ClassNameMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ClassNameMultinameUsage.java index 4d7e17cb2..61c2403ff 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ClassNameMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ClassNameMultinameUsage.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.abc.usages; import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.util.List; /** @@ -31,7 +31,7 @@ public class ClassNameMultinameUsage extends InsideClassMultinameUsage { } @Override - public String toString(List abcTags, ABC abc) { + public String toString(List abcTags, ABC abc) { return "class " + abc.constants.constant_multiname[abc.instance_info[classIndex].name_index].getNameWithNamespace(abc.constants); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java index b39c29961..1f994f132 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java @@ -20,7 +20,7 @@ import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import com.jpexs.decompiler.flash.abc.types.traits.Traits; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.util.ArrayList; import java.util.List; @@ -35,7 +35,7 @@ public abstract class ConstVarMultinameUsage extends TraitMultinameUsage { } @Override - public String toString(List abcTags, ABC abc) { + public String toString(List abcTags, ABC abc) { return super.toString(abcTags, abc) + " " + (parentTraitIndex > -1 ? (isStatic diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarNameMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarNameMultinameUsage.java index 0f255a4cf..06f638759 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarNameMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarNameMultinameUsage.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.usages; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.traits.Traits; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.util.List; /** @@ -32,7 +32,7 @@ public class ConstVarNameMultinameUsage extends ConstVarMultinameUsage { } @Override - public String toString(List abcTags, ABC abc) { + public String toString(List abcTags, ABC abc) { return super.toString(abcTags, abc) + " name"; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarTypeMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarTypeMultinameUsage.java index 6ca4a24d1..6aa6fe264 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarTypeMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarTypeMultinameUsage.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.usages; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.traits.Traits; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.util.List; /** @@ -32,7 +32,7 @@ public class ConstVarTypeMultinameUsage extends ConstVarMultinameUsage { } @Override - public String toString(List abcTags, ABC abc) { + public String toString(List abcTags, ABC abc) { return super.toString(abcTags, abc) + " type"; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ExtendsMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ExtendsMultinameUsage.java index 8571deefe..d499af18e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ExtendsMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ExtendsMultinameUsage.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.abc.usages; import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.util.List; /** @@ -31,7 +31,7 @@ public class ExtendsMultinameUsage extends InsideClassMultinameUsage { } @Override - public String toString(List abcTags, ABC abc) { + public String toString(List abcTags, ABC abc) { return super.toString(abcTags, abc) + " extends"; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ImplementsMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ImplementsMultinameUsage.java index e03f75427..8224393e2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ImplementsMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ImplementsMultinameUsage.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.abc.usages; import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.util.List; /** @@ -31,7 +31,7 @@ public class ImplementsMultinameUsage extends InsideClassMultinameUsage { } @Override - public String toString(List abcTags, ABC abc) { + public String toString(List abcTags, ABC abc) { return super.toString(abcTags, abc) + " implements"; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/InsideClassMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/InsideClassMultinameUsage.java index 757efc80e..88b32568e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/InsideClassMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/InsideClassMultinameUsage.java @@ -17,7 +17,8 @@ package com.jpexs.decompiler.flash.abc.usages; import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.util.List; /** @@ -35,7 +36,7 @@ public abstract class InsideClassMultinameUsage extends MultinameUsage { } @Override - public String toString(List abcTags, ABC abc) { + public String toString(List abcTags, ABC abc) { return "class " + abc.constants.constant_multiname[abc.instance_info[classIndex].name_index].getNameWithNamespace(abc.constants); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodBodyMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodBodyMultinameUsage.java index 8b64b1400..f7365a3e3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodBodyMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodBodyMultinameUsage.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.usages; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.traits.Traits; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.util.List; /** @@ -32,7 +32,7 @@ public class MethodBodyMultinameUsage extends MethodMultinameUsage { } @Override - public String toString(List abcTags, ABC abc) { + public String toString(List abcTags, ABC abc) { return super.toString(abcTags, abc) + " body"; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java index 395acca6f..10a8324e5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java @@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.abc.usages; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.abc.types.traits.Traits; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.util.ArrayList; import java.util.List; @@ -41,7 +41,7 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage { } @Override - public String toString(List abcTags, ABC abc) { + public String toString(List abcTags, ABC abc) { return super.toString(abcTags, abc) + " " + (isInitializer ? (isStatic ? "class initializer" diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodNameMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodNameMultinameUsage.java index 33fb876b4..4bf50f0a2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodNameMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodNameMultinameUsage.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.usages; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.traits.Traits; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.util.List; /** @@ -32,7 +32,7 @@ public class MethodNameMultinameUsage extends MethodMultinameUsage { } @Override - public String toString(List abcTags, ABC abc) { + public String toString(List abcTags, ABC abc) { return super.toString(abcTags, abc) + " name"; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodParamsMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodParamsMultinameUsage.java index 567ec9d9a..fe5f10fa3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodParamsMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodParamsMultinameUsage.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.usages; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.traits.Traits; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.util.List; /** @@ -32,7 +32,7 @@ public class MethodParamsMultinameUsage extends MethodMultinameUsage { } @Override - public String toString(List abcTags, ABC abc) { + public String toString(List abcTags, ABC abc) { return super.toString(abcTags, abc) + " params"; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodReturnTypeMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodReturnTypeMultinameUsage.java index 87a80a717..8d015c0ab 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodReturnTypeMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodReturnTypeMultinameUsage.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.usages; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.traits.Traits; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.util.List; /** @@ -32,7 +32,7 @@ public class MethodReturnTypeMultinameUsage extends MethodMultinameUsage { } @Override - public String toString(List abcTags, ABC abc) { + public String toString(List abcTags, ABC abc) { return super.toString(abcTags, abc) + " return type"; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MultinameUsage.java index 4f8103f77..c81e371d6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MultinameUsage.java @@ -17,7 +17,8 @@ package com.jpexs.decompiler.flash.abc.usages; import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.util.List; /** @@ -26,5 +27,5 @@ import java.util.List; */ public abstract class MultinameUsage { - public abstract String toString(List abcTags, ABC abc); + public abstract String toString(List abcTags, ABC abc); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/TypeNameMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/TypeNameMultinameUsage.java index 6c2d8ec13..a00a54737 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/TypeNameMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/TypeNameMultinameUsage.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.abc.usages; import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; import java.util.ArrayList; import java.util.List; @@ -34,7 +34,7 @@ public class TypeNameMultinameUsage extends MultinameUsage { } @Override - public String toString(List abcTags, ABC abc) { + public String toString(List abcTags, ABC abc) { return "TypeName " + abc.constants.constant_multiname[typename_index].toString(abc.constants, new ArrayList()); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java index 12a3afda1..34fffa586 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainFrame.java @@ -54,7 +54,7 @@ import com.jpexs.decompiler.flash.tags.DefineSpriteTag; import com.jpexs.decompiler.flash.tags.DefineText2Tag; import com.jpexs.decompiler.flash.tags.DefineTextTag; import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.flash.tags.EndTag; import com.jpexs.decompiler.flash.tags.ExportAssetsTag; import com.jpexs.decompiler.flash.tags.JPEGTablesTag; @@ -157,7 +157,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi final static String DETAILCARDEMPTYPANEL = "Empty card"; private JPEGTablesTag jtt; private HashMap characters; - private List abcList; + private List abcList; JSplitPane splitPane1; JSplitPane splitPane2; private JPanel detailPanel; @@ -372,7 +372,7 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi cl2.show(detailPanel, DETAILCARDEMPTYPANEL); - abcList = new ArrayList(); + abcList = new ArrayList(); getActionScript3(objs, abcList); if (!abcList.isEmpty()) { addTab(tabPane, abcPanel = new ABCPanel(abcList), "ActionScript3", View.getIcon("as16")); @@ -597,13 +597,13 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi } } - public static void getActionScript3(List list, List actionScripts) { + public static void getActionScript3(List list, List actionScripts) { for (Object t : list) { if (t instanceof Container) { getActionScript3(((Container) t).getSubItems(), actionScripts); } - if (t instanceof DoABCTag) { - actionScripts.add((DoABCTag) t); + if (t instanceof ABCContainerTag) { + actionScripts.add((ABCContainerTag) t); } } } @@ -1160,8 +1160,8 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi protected Object doInBackground() throws Exception { int cnt = 0; if (all) { - for (DoABCTag tag : abcPanel.list) { - tag.abc.restoreControlFlow(); + for (ABCContainerTag tag : abcPanel.list) { + tag.getABC().restoreControlFlow(); } } else { int bi = abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex(); @@ -1188,8 +1188,8 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi protected Object doInBackground() throws Exception { int cnt = 0; if (all) { - for (DoABCTag tag : abcPanel.list) { - cnt += tag.abc.removeTraps(); + for (ABCContainerTag tag : abcPanel.list) { + cnt += tag.getABC().removeTraps(); } } else { int bi = abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex(); @@ -1216,8 +1216,8 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi protected Object doInBackground() throws Exception { int cnt = 0; if (all) { - for (DoABCTag tag : abcPanel.list) { - cnt += tag.abc.removeDeadCode(); + for (ABCContainerTag tag : abcPanel.list) { + cnt += tag.getABC().removeDeadCode(); } } else { int bi = abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex(); @@ -1246,8 +1246,8 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi if (abcPanel != null) { HashMap namesMap = new HashMap(); - for (DoABCTag tag : abcPanel.list) { - cnt += tag.abc.deobfuscateIdentifiers(namesMap); + for (ABCContainerTag tag : abcPanel.list) { + cnt += tag.getABC().deobfuscateIdentifiers(namesMap); } } else { cnt = swf.deobfuscateAS2Identifiers(); @@ -1278,14 +1278,14 @@ public class MainFrame extends JFrame implements ActionListener, TreeSelectionLi @Override protected Object doInBackground() throws Exception { if (deobfuscationDialog.processAllCheckbox.isSelected()) { - for (DoABCTag tag : abcPanel.list) { + for (ABCContainerTag tag : abcPanel.list) { if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_DEAD_CODE) { - tag.abc.removeDeadCode(); + tag.getABC().removeDeadCode(); } else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_REMOVE_TRAPS) { - tag.abc.removeTraps(); + tag.getABC().removeTraps(); } else if (deobfuscationDialog.codeProcessingLevel.getValue() == DeobfuscationDialog.LEVEL_RESTORE_CONTROL_FLOW) { - tag.abc.removeTraps(); - tag.abc.restoreControlFlow(); + tag.getABC().removeTraps(); + tag.getABC().restoreControlFlow(); } } } else { diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/ABCContainerTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/ABCContainerTag.java new file mode 100644 index 000000000..978e976f0 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/tags/ABCContainerTag.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2013 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.tags; + +import com.jpexs.decompiler.flash.abc.ABC; + +/** + * + * @author JPEXS + */ +public interface ABCContainerTag extends Comparable{ + public ABC getABC(); +} diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java new file mode 100644 index 000000000..55c68cd76 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoABCDefineTag.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2010-2013 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.tags; + +import com.jpexs.decompiler.flash.Main; +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.CopyOutputStream; +import java.io.*; + +/** + * Defines a series of ActionScript 3 bytecodes to be executed + */ +public class DoABCDefineTag extends Tag implements ABCContainerTag { + + public ABC getABC() { + return abc; + } + + + /** + * ActionScript 3 bytecodes + */ + private ABC abc; + /** + * A 32-bit flags value, which may contain the following bits set: + * kDoAbcLazyInitializeFlag = 1: Indicates that the ABC block should not be + * executed immediately, but only parsed. A later finddef may cause its + * scripts to execute. + */ + public long flags; + /** + * The name assigned to the bytecode. + */ + public String name; + + @Override + public String getName() { + return "DoABCDefine (" + name + ")"; + } + + /** + * Constructor + * + * @param data Data bytes + * @param version SWF version + * @throws IOException + */ + public DoABCDefineTag(byte[] data, int version, long pos) throws IOException { + super(82, "DoABCDefine", data, pos); + InputStream is = new ByteArrayInputStream(data); + SWFInputStream sis = new SWFInputStream(is, version); + flags = sis.readUI32(); + name = sis.readString(); + abc = new ABC(is); + } + + /** + * Gets data bytes + * + * @param version SWF version + * @return Bytes of data + */ + @Override + public byte[] getData(int version) { + try { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + OutputStream os = bos; + if (Main.DEBUG_COPY) { + os = new CopyOutputStream(os, new ByteArrayInputStream(super.data)); + } + SWFOutputStream sos = new SWFOutputStream(os, version); + sos.writeUI32(flags); + sos.writeString(name); + abc.saveToStream(sos); + sos.close(); + return bos.toByteArray(); + } catch (IOException e) { + } + return new byte[0]; + } + + @Override + public int compareTo(ABCContainerTag o) { + if(o instanceof DoABCDefineTag){ + DoABCDefineTag n=(DoABCDefineTag)o; + int lastCmp = name.compareTo(n.name); + return (lastCmp != 0 ? lastCmp + : name.compareTo(n.name)); + } + return 0; + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoABCTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoABCTag.java index 6d7b0d5f0..dc9d75f3b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoABCTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoABCTag.java @@ -26,27 +26,22 @@ import java.io.*; /** * Defines a series of ActionScript 3 bytecodes to be executed */ -public class DoABCTag extends Tag implements Comparable { +public class DoABCTag extends Tag implements ABCContainerTag { /** * ActionScript 3 bytecodes */ - public ABC abc; - /** - * A 32-bit flags value, which may contain the following bits set: - * kDoAbcLazyInitializeFlag = 1: Indicates that the ABC block should not be - * executed immediately, but only parsed. A later finddef may cause its - * scripts to execute. - */ - public long flags; - /** - * The name assigned to the bytecode. - */ - public String name; + private ABC abc; + @Override + public ABC getABC() { + return abc; + } + + @Override public String getName() { - return "DoABC (" + name + ")"; + return "DoABC"; } /** @@ -57,11 +52,8 @@ public class DoABCTag extends Tag implements Comparable { * @throws IOException */ public DoABCTag(byte[] data, int version, long pos) throws IOException { - super(82, "DoABC", data, pos); + super(72, "DoABC", data, pos); InputStream is = new ByteArrayInputStream(data); - SWFInputStream sis = new SWFInputStream(is, version); - flags = sis.readUI32(); - name = sis.readString(); abc = new ABC(is); } @@ -80,8 +72,6 @@ public class DoABCTag extends Tag implements Comparable { os = new CopyOutputStream(os, new ByteArrayInputStream(super.data)); } SWFOutputStream sos = new SWFOutputStream(os, version); - sos.writeUI32(flags); - sos.writeString(name); abc.saveToStream(sos); sos.close(); return bos.toByteArray(); @@ -90,10 +80,9 @@ public class DoABCTag extends Tag implements Comparable { return new byte[0]; } + @Override - public int compareTo(DoABCTag n) { - int lastCmp = name.compareTo(n.name); - return (lastCmp != 0 ? lastCmp - : name.compareTo(n.name)); + public int compareTo(ABCContainerTag o) { + return 0; } } diff --git a/trunk/test/com/jpexs/decompiler/flash/ActionScript3Test.java b/trunk/test/com/jpexs/decompiler/flash/ActionScript3Test.java index 5f7a342ce..01a470a58 100644 --- a/trunk/test/com/jpexs/decompiler/flash/ActionScript3Test.java +++ b/trunk/test/com/jpexs/decompiler/flash/ActionScript3Test.java @@ -2,7 +2,7 @@ package com.jpexs.decompiler.flash; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import com.jpexs.decompiler.flash.tags.Tag; import java.io.FileInputStream; import java.io.IOException; @@ -25,17 +25,17 @@ public class ActionScript3Test { @BeforeClass public void init() throws IOException { swf = new SWF(new FileInputStream("testdata/as3/TestMovie.swf")); - DoABCTag tag = null; + DoABCDefineTag tag = null; for (Tag t : swf.tags) { - if (t instanceof DoABCTag) { - tag = (DoABCTag) t; + if (t instanceof DoABCDefineTag) { + tag = (DoABCDefineTag) t; break; } } assertNotNull(tag); - clsIndex = tag.abc.findClassByName("classes.Test"); + clsIndex = tag.getABC().findClassByName("classes.Test"); assertTrue(clsIndex > -1); - this.abc = tag.abc; + this.abc = tag.getABC(); } private void decompileMethod(String methodName, String expectedResult, boolean isStatic) { diff --git a/trunk/test/com/jpexs/decompiler/flash/Generator.java b/trunk/test/com/jpexs/decompiler/flash/Generator.java index 184072e26..310b219ff 100644 --- a/trunk/test/com/jpexs/decompiler/flash/Generator.java +++ b/trunk/test/com/jpexs/decompiler/flash/Generator.java @@ -4,7 +4,7 @@ import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.graph.GraphTargetItem; -import com.jpexs.decompiler.flash.tags.DoABCTag; +import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import com.jpexs.decompiler.flash.tags.Tag; import java.io.FileInputStream; import java.io.PrintWriter; @@ -20,14 +20,14 @@ import java.util.Stack; public class Generator { public static void main(String[] args) throws Exception { SWF swf=new SWF(new FileInputStream("testdata/as3/TestMovie.swf")); - DoABCTag tag = null; + DoABCDefineTag tag = null; for (Tag t : swf.tags) { - if (t instanceof DoABCTag) { - tag = (DoABCTag) t; + if (t instanceof DoABCDefineTag) { + tag = (DoABCDefineTag) t; break; } } - ABC abc=tag.abc; + ABC abc=tag.getABC(); int classId=abc.findClassByName("classes.Test"); StringBuilder s=new StringBuilder(); for(Trait t:abc.instance_info[classId].instance_traits.traits){ diff --git a/trunk/test/com/jpexs/decompiler/flash/RecompileTest.java b/trunk/test/com/jpexs/decompiler/flash/RecompileTest.java index e9d15f887..c327560fc 100644 --- a/trunk/test/com/jpexs/decompiler/flash/RecompileTest.java +++ b/trunk/test/com/jpexs/decompiler/flash/RecompileTest.java @@ -29,6 +29,7 @@ public class RecompileTest { public void testRecompile() { File dir=new File(TESTDATADIR); File files[]=dir.listFiles(new FilenameFilter(){ + @Override public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(".swf"); }