DoABC(82) renamed to DoABCDefine,

DoABC(72) tag created
This commit is contained in:
Jindra Petk
2013-04-12 20:22:21 +02:00
parent 59ff5cb488
commit c86be8aac5
34 changed files with 274 additions and 133 deletions

View File

@@ -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<DoABCTag> abcTags = new ArrayList<DoABCTag>();
List<ABCContainerTag> abcTags = new ArrayList<ABCContainerTag>();
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) {

View File

@@ -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);

View File

@@ -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<DoABCTag> abcList) throws IOException {
public void export(String directory, boolean pcode, List<ABCContainerTag> abcList) throws IOException {
export(directory, pcode, abcList, "");
}
public void export(String directory, boolean pcode, List<DoABCTag> abcList, String abcStr) throws IOException {
public void export(String directory, boolean pcode, List<ABCContainerTag> 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("."));

View File

@@ -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<DoABCTag> list;
public List<ABCContainerTag> list;
public int itemIndex = 0;
public static final String ROOT = " - all - ";
public ABCComboBoxModel(List<DoABCTag> list) {
public ABCComboBoxModel(List<ABCContainerTag> list) {
this.list = list;
Collections.sort(this.list);
}

View File

@@ -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<DoABCTag> list;
public List<ABCContainerTag> 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<DoABCTag> oneList = new ArrayList<DoABCTag>();
List<ABCContainerTag> oneList = new ArrayList<ABCContainerTag>();
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<DoABCTag> list) {
public ABCPanel(List<ABCContainerTag> 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<DoABCTag> inlist = list;
final List<ABCContainerTag> inlist = list;
final ABCPanel t = this;
constantTable.addMouseListener(new MouseAdapter() {
@Override

View File

@@ -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<DoABCTag> abcList;
private List<ABCContainerTag> abcList;
public HashMap<String, TreeLeafScript> treeList;
private ABCPanel abcPanel;
@@ -45,7 +46,7 @@ public class ClassesListTree extends JTree implements TreeSelectionListener {
scrollPathToVisible(treePath);
}
public ClassesListTree(List<DoABCTag> list, ABCPanel abcPanel) {
public ClassesListTree(List<ABCContainerTag> 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<String, TreeLeafScript> getTreeList(List<DoABCTag> list) {
public HashMap<String, TreeLeafScript> getTreeList(List<ABCContainerTag> list) {
HashMap<String, TreeLeafScript> ret = new HashMap<String, TreeLeafScript>();
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<DoABCTag> list) {
public void setDoABCTags(List<ABCContainerTag> list) {
this.abcList = list;
this.treeList = getTreeList(list);
setModel(new ClassesListTreeModel(this.treeList));

View File

@@ -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<DoABCTag> abcList;
private List<ABCContainerTag> abcList;
public void clearScriptCache() {
bufferedClasses.clear();
}
public void setScript(ScriptInfo script, ABC abc, List<DoABCTag> abcList) {
public void setScript(ScriptInfo script, ABC abc, List<ABCContainerTag> abcList) {
if (script == null) {
highlights = new ArrayList<Highlighting>();
traitHighlights = new ArrayList<Highlighting>();

View File

@@ -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<DoABCTag> abcTags;
List<ABCContainerTag> 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<DoABCTag> abcTags, ABC abc) {
public void setABC(List<ABCContainerTag> abcTags, ABC abc) {
this.abc = abc;
this.abcTags = abcTags;
setModel(new DefaultListModel());

View File

@@ -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<DoABCTag> abcTags;
private List<ABCContainerTag> 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<DoABCTag> abcTags, ABC abc, int classIndex) {
public TraitsListItem(Type type, int index, boolean isStatic, List<ABCContainerTag> abcTags, ABC abc, int classIndex) {
this.type = type;
this.index = index;
this.isStatic = isStatic;

View File

@@ -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<TraitsListItem> items;
private List<DoABCTag> abcTags;
private List<ABCContainerTag> 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<DoABCTag> abcTags, ABC abc, int classIndex, boolean sorted) {
public TraitsListModel(List<ABCContainerTag> abcTags, ABC abc, int classIndex, boolean sorted) {
this.abcTags = abcTags;
this.abc = abc;
this.classIndex = classIndex;

View File

@@ -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<DoABCTag> abcTags, ABC abc, int multinameIndex, ABCPanel abcPanel) {
public UsageFrame(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, ABCPanel abcPanel) {
this.abcPanel = abcPanel;
List<MultinameUsage> usages = abc.findMultinameUsage(multinameIndex);
this.abc = abc;

View File

@@ -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<DoABCTag> abcTags;
private List<ABCContainerTag> abcTags;
public UsageListModel(List<DoABCTag> abcTags, ABC abc) {
public UsageListModel(List<ABCContainerTag> abcTags, ABC abc) {
this.abc = abc;
this.abcTags = abcTags;
}

View File

@@ -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<DoABCTag> abcTags, ABC abc, boolean pcode, boolean highlighting) {
public String convert(List<ABCContainerTag> abcTags, ABC abc, boolean pcode, boolean highlighting) {
return traits.convert("", abcTags, abc, false, pcode, true, -1, highlighting, new ArrayList<String>());
}
public void export(ABC abc, List<DoABCTag> abcList, String directory, boolean pcode) throws IOException {
public void export(ABC abc, List<ABCContainerTag> 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);

View File

@@ -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<DoABCTag> abcTags, ABC abc) {
public String toString(List<ABCContainerTag> abcTags, ABC abc) {
return "class " + abc.constants.constant_multiname[abc.instance_info[classIndex].name_index].getNameWithNamespace(abc.constants);
}
}

View File

@@ -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<DoABCTag> abcTags, ABC abc) {
public String toString(List<ABCContainerTag> abcTags, ABC abc) {
return super.toString(abcTags, abc) + " "
+ (parentTraitIndex > -1
? (isStatic

View File

@@ -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<DoABCTag> abcTags, ABC abc) {
public String toString(List<ABCContainerTag> abcTags, ABC abc) {
return super.toString(abcTags, abc) + " name";
}
}

View File

@@ -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<DoABCTag> abcTags, ABC abc) {
public String toString(List<ABCContainerTag> abcTags, ABC abc) {
return super.toString(abcTags, abc) + " type";
}
}

View File

@@ -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<DoABCTag> abcTags, ABC abc) {
public String toString(List<ABCContainerTag> abcTags, ABC abc) {
return super.toString(abcTags, abc) + " extends";
}
}

View File

@@ -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<DoABCTag> abcTags, ABC abc) {
public String toString(List<ABCContainerTag> abcTags, ABC abc) {
return super.toString(abcTags, abc) + " implements";
}
}

View File

@@ -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<DoABCTag> abcTags, ABC abc) {
public String toString(List<ABCContainerTag> abcTags, ABC abc) {
return "class " + abc.constants.constant_multiname[abc.instance_info[classIndex].name_index].getNameWithNamespace(abc.constants);
}

View File

@@ -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<DoABCTag> abcTags, ABC abc) {
public String toString(List<ABCContainerTag> abcTags, ABC abc) {
return super.toString(abcTags, abc) + " body";
}
}

View File

@@ -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<DoABCTag> abcTags, ABC abc) {
public String toString(List<ABCContainerTag> abcTags, ABC abc) {
return super.toString(abcTags, abc) + " " + (isInitializer
? (isStatic
? "class initializer"

View File

@@ -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<DoABCTag> abcTags, ABC abc) {
public String toString(List<ABCContainerTag> abcTags, ABC abc) {
return super.toString(abcTags, abc) + " name";
}
}

View File

@@ -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<DoABCTag> abcTags, ABC abc) {
public String toString(List<ABCContainerTag> abcTags, ABC abc) {
return super.toString(abcTags, abc) + " params";
}
}

View File

@@ -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<DoABCTag> abcTags, ABC abc) {
public String toString(List<ABCContainerTag> abcTags, ABC abc) {
return super.toString(abcTags, abc) + " return type";
}
}

View File

@@ -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<DoABCTag> abcTags, ABC abc);
public abstract String toString(List<ABCContainerTag> abcTags, ABC abc);
}

View File

@@ -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<DoABCTag> abcTags, ABC abc) {
public String toString(List<ABCContainerTag> abcTags, ABC abc) {
return "TypeName " + abc.constants.constant_multiname[typename_index].toString(abc.constants, new ArrayList<String>());
}
}

View File

@@ -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<Integer, CharacterTag> characters;
private List<DoABCTag> abcList;
private List<ABCContainerTag> 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<DoABCTag>();
abcList = new ArrayList<ABCContainerTag>();
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<Object> list, List<DoABCTag> actionScripts) {
public static void getActionScript3(List<Object> list, List<ABCContainerTag> 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<String, String> namesMap = new HashMap<String, String>();
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 {

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package com.jpexs.decompiler.flash.tags;
import com.jpexs.decompiler.flash.abc.ABC;
/**
*
* @author JPEXS
*/
public interface ABCContainerTag extends Comparable<ABCContainerTag>{
public ABC getABC();
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
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;
}
}

View File

@@ -26,27 +26,22 @@ import java.io.*;
/**
* Defines a series of ActionScript 3 bytecodes to be executed
*/
public class DoABCTag extends Tag implements Comparable<DoABCTag> {
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<DoABCTag> {
* @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<DoABCTag> {
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<DoABCTag> {
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;
}
}

View File

@@ -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) {

View File

@@ -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){

View File

@@ -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");
}