mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-21 10:25:43 +00:00
AS3: "All" option in ABC list to merge scripts into 1 tree
AS3: Better decompiling namespaces
This commit is contained in:
@@ -297,13 +297,18 @@ public class SWF {
|
||||
}
|
||||
}
|
||||
};
|
||||
List<DoABCTag> abcTags=new ArrayList<DoABCTag>();
|
||||
for (Tag t : tags) {
|
||||
if (t instanceof DoABCTag) {
|
||||
((DoABCTag) t).abc.addEventListener(evl);
|
||||
((DoABCTag) t).abc.export(outdir, isPcode);
|
||||
abcTags.add((DoABCTag)t);
|
||||
asV3Found = true;
|
||||
}
|
||||
}
|
||||
for(DoABCTag t:abcTags){
|
||||
t.abc.addEventListener(evl);
|
||||
t.abc.export(outdir, isPcode,abcTags);
|
||||
}
|
||||
|
||||
if (!asV3Found) {
|
||||
List<Object> list2 = new ArrayList<Object>();
|
||||
list2.addAll(tags);
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.jpexs.asdec.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.asdec.abc.types.traits.Traits;
|
||||
import com.jpexs.asdec.abc.usages.*;
|
||||
import com.jpexs.asdec.helpers.Helper;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -474,52 +475,48 @@ public class ABC {
|
||||
}
|
||||
}
|
||||
/* Map from multiname index of namespace value to namespace name**/
|
||||
private HashMap<Integer, Integer> namespaceMap;
|
||||
private HashMap<String, String> namespaceMap;
|
||||
|
||||
private void loadNamespaceMap() {
|
||||
namespaceMap = new HashMap<Integer, Integer>();
|
||||
namespaceMap = new HashMap<String, String>();
|
||||
for (ScriptInfo si : script_info) {
|
||||
for (Trait t : si.traits.traits) {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst s = ((TraitSlotConst) t);
|
||||
if (s.value_kind == ValueKind.CONSTANT_Namespace) {
|
||||
namespaceMap.put(s.value_index, s.name_index);
|
||||
if (s.isNamespace()) {
|
||||
String key=constants.constant_namespace[s.value_index].getName(constants);
|
||||
String val=constants.constant_multiname[s.name_index].getNameWithNamespace(constants);
|
||||
namespaceMap.put(key, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int nsValueToName(int value_index) {
|
||||
if (namespaceMap.containsKey(value_index)) {
|
||||
return namespaceMap.get(value_index);
|
||||
public String builtInNs(String ns) {
|
||||
if (ns.equals("http://www.adobe.com/2006/actionscript/flash/proxy")) {
|
||||
return "flash.utils.flash_proxy";
|
||||
}
|
||||
if(ns.equals("http://adobe.com/AS3/2006/builtin")){
|
||||
return "-";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String nsValueToName(String value) {
|
||||
if (namespaceMap.containsKey(value)) {
|
||||
return namespaceMap.get(value);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<String, String> namespacesToString() {
|
||||
HashMap<String, String> ret = new HashMap<String, String>();
|
||||
for (Integer value_index : namespaceMap.keySet()) {
|
||||
int name_index = namespaceMap.get(value_index);
|
||||
String n = "";
|
||||
String packageName = constants.constant_multiname[name_index].getNamespace(constants).getName(constants);
|
||||
n += ("package " + packageName + "\r\n");
|
||||
n += ("{\r\n");
|
||||
Namespace ns = constants.constant_multiname[name_index].getNamespace(constants);
|
||||
String modifiers = ns.getPrefix(this);
|
||||
if (!modifiers.equals("")) {
|
||||
modifiers += " ";
|
||||
String ns=builtInNs(value);
|
||||
if(ns==null){
|
||||
return "";
|
||||
}else{
|
||||
return ns;
|
||||
}
|
||||
String nsname = constants.constant_multiname[name_index].getName(constants);
|
||||
n += IDENT_STRING + modifiers + "namespace " + nsname + " = \"" + Helper.escapeString(constants.constant_namespace[value_index].getName(constants)) + "\";\r\n";
|
||||
n += ("}\r\n");
|
||||
ret.put(packageName + "." + nsname, n);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void export(String directory, boolean pcode) throws IOException {
|
||||
public void export(String directory, boolean pcode,List<DoABCTag> abcList) 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("."));
|
||||
@@ -536,7 +533,7 @@ public class ABC {
|
||||
}
|
||||
String fileName = outDir.toString() + File.separator + className + ".as";
|
||||
FileOutputStream fos = new FileOutputStream(fileName);
|
||||
fos.write(script_info[i].convert(this, pcode, false).getBytes());
|
||||
fos.write(script_info[i].convert(abcList,this, pcode, false).getBytes());
|
||||
fos.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class FullMultinameTreeItem extends TreeItem {
|
||||
|
||||
@Override
|
||||
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames) {
|
||||
String ret;
|
||||
String ret = "";
|
||||
if (name != null) {
|
||||
ret = "[" + name.toString(constants, localRegNames) + "]";
|
||||
} else {
|
||||
|
||||
@@ -91,19 +91,25 @@ public abstract class TreeItem {
|
||||
return propertyName.toString(constants, localRegNames);
|
||||
}
|
||||
if (propertyName instanceof FullMultinameTreeItem) {
|
||||
|
||||
if (((FullMultinameTreeItem) propertyName).isRuntime()) {
|
||||
return obStr + propertyName.toString(constants, localRegNames);
|
||||
return joinProperty(obStr ,propertyName.toString(constants, localRegNames));
|
||||
} else {
|
||||
if (!obStr.equals("")) {
|
||||
obStr += ".";
|
||||
}
|
||||
return obStr + ((FullMultinameTreeItem) propertyName).toString(constants, localRegNames);
|
||||
return joinProperty(obStr,((FullMultinameTreeItem) propertyName).toString(constants, localRegNames));
|
||||
}
|
||||
} else {
|
||||
return obStr + "[" + propertyName.toString(constants, localRegNames) + "]";
|
||||
}
|
||||
}
|
||||
|
||||
private String joinProperty(String prefix,String name){
|
||||
if(prefix.endsWith(".")){
|
||||
prefix=prefix.substring(0,prefix.length()-1);
|
||||
}
|
||||
if(!name.startsWith("[")){
|
||||
return prefix+"."+name;
|
||||
}
|
||||
return prefix+name;
|
||||
}
|
||||
|
||||
public TreeItem getNotCoerced() {
|
||||
return this;
|
||||
|
||||
@@ -26,6 +26,7 @@ public class ABCComboBoxModel implements ComboBoxModel {
|
||||
|
||||
public List<DoABCTag> list;
|
||||
public int itemIndex = 0;
|
||||
public static final String ROOT=" - all - ";
|
||||
|
||||
public ABCComboBoxModel(List<DoABCTag> list) {
|
||||
this.list = list;
|
||||
@@ -33,11 +34,14 @@ public class ABCComboBoxModel implements ComboBoxModel {
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return list.size();
|
||||
return 1+list.size();
|
||||
}
|
||||
|
||||
public Object getElementAt(int index) {
|
||||
return list.get(index);
|
||||
if(index==0){
|
||||
return ROOT;
|
||||
}
|
||||
return list.get(index-1);
|
||||
}
|
||||
|
||||
public void addListDataListener(ListDataListener l) {
|
||||
@@ -47,7 +51,11 @@ public class ABCComboBoxModel implements ComboBoxModel {
|
||||
}
|
||||
|
||||
public void setSelectedItem(Object anItem) {
|
||||
itemIndex = list.indexOf(anItem);
|
||||
if(anItem==ROOT){
|
||||
itemIndex=0;
|
||||
}else{
|
||||
itemIndex = 1+list.indexOf(anItem);
|
||||
}
|
||||
}
|
||||
|
||||
public Object getSelectedItem() {
|
||||
|
||||
@@ -21,6 +21,8 @@ import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.types.ScriptInfo;
|
||||
import com.jpexs.asdec.abc.types.traits.Trait;
|
||||
import com.jpexs.asdec.abc.types.traits.TraitClass;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
@@ -30,8 +32,7 @@ import javax.swing.tree.TreePath;
|
||||
|
||||
public class ClassesListTree extends JTree implements TreeSelectionListener {
|
||||
|
||||
public ABC abc;
|
||||
|
||||
private List<DoABCTag> abcList;
|
||||
public void selectClass(int classIndex) {
|
||||
ClassesListTreeModel model = (ClassesListTreeModel) getModel();
|
||||
TreeElement selectedElement = model.getElementByClassIndex(classIndex);
|
||||
@@ -40,9 +41,9 @@ public class ClassesListTree extends JTree implements TreeSelectionListener {
|
||||
scrollPathToVisible(treePath);
|
||||
}
|
||||
|
||||
public ClassesListTree(ABC abc) {
|
||||
this.abc = abc;
|
||||
setModel(new ClassesListTreeModel(abc));
|
||||
public ClassesListTree(List<DoABCTag> list) {
|
||||
this.abcList=list;
|
||||
setModel(new ClassesListTreeModel(list));
|
||||
addTreeSelectionListener(this);
|
||||
DefaultTreeCellRenderer treeRenderer = new DefaultTreeCellRenderer();
|
||||
ClassLoader cldr = this.getClass().getClassLoader();
|
||||
@@ -52,9 +53,9 @@ public class ClassesListTree extends JTree implements TreeSelectionListener {
|
||||
setCellRenderer(treeRenderer);
|
||||
}
|
||||
|
||||
public void setABC(ABC abc) {
|
||||
setModel(new ClassesListTreeModel(abc));
|
||||
this.abc = abc;
|
||||
public void setDoABCTags(List<DoABCTag> list) {
|
||||
this.abcList=list;
|
||||
setModel(new ClassesListTreeModel(list));
|
||||
}
|
||||
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
@@ -66,23 +67,25 @@ public class ClassesListTree extends JTree implements TreeSelectionListener {
|
||||
return;
|
||||
}
|
||||
Object item = tp.getItem();
|
||||
if (item instanceof ScriptInfo) {
|
||||
final ScriptInfo script = (ScriptInfo) item;
|
||||
if (item instanceof TreeLeafScript) {
|
||||
final TreeLeafScript scriptLeaf = (TreeLeafScript) item;
|
||||
|
||||
if (!Main.isWorking()) {
|
||||
Main.startWork("Decompiling class...");
|
||||
Main.startWork("Decompiling...");
|
||||
(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
int classIndex = -1;
|
||||
for (Trait t : script.traits.traits) {
|
||||
for (Trait t : scriptLeaf.abc.script_info[scriptLeaf.scriptIndex].traits.traits) {
|
||||
if (t instanceof TraitClass) {
|
||||
classIndex = ((TraitClass) t).class_info;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Main.abcMainFrame.navigator.setClassIndex(classIndex);
|
||||
Main.abcMainFrame.decompiledTextArea.setScript(script, abc);
|
||||
Main.abcMainFrame.navigator.setABC(abcList,scriptLeaf.abc);
|
||||
Main.abcMainFrame.setAbc(scriptLeaf.abc);
|
||||
Main.abcMainFrame.decompiledTextArea.setScript(scriptLeaf.abc.script_info[scriptLeaf.scriptIndex], scriptLeaf.abc,abcList);
|
||||
Main.abcMainFrame.detailPanel.methodTraitPanel.methodCodePanel.sourceTextArea.setText("");
|
||||
Main.stopWork();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.jpexs.asdec.abc.gui;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.types.ScriptInfo;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
import javax.swing.event.TreeModelListener;
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
@@ -50,16 +52,18 @@ class ClassIndexVisitor implements TreeVisitor {
|
||||
|
||||
public class ClassesListTreeModel implements TreeModel {
|
||||
|
||||
private ABC abc;
|
||||
private Tree classTree = new Tree();
|
||||
private List<DoABCTag> list;
|
||||
|
||||
public ClassesListTreeModel(ABC abc) {
|
||||
this.abc = abc;
|
||||
for (ScriptInfo si : abc.script_info) {
|
||||
String path = si.getPath(abc);
|
||||
String nsName = path.substring(path.lastIndexOf(".") + 1);
|
||||
String packageName = path.substring(0, path.lastIndexOf("."));
|
||||
classTree.add(nsName, packageName, si);
|
||||
public ClassesListTreeModel(List<DoABCTag> list) {
|
||||
this.list = list;
|
||||
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);
|
||||
String nsName = path.substring(path.lastIndexOf(".") + 1);
|
||||
String packageName = path.substring(0, path.lastIndexOf("."));
|
||||
classTree.add(nsName, packageName, new TreeLeafScript(tag.abc, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.jpexs.asdec.abc.types.ScriptInfo;
|
||||
import com.jpexs.asdec.abc.types.traits.Trait;
|
||||
import com.jpexs.asdec.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.asdec.helpers.Highlighting;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.ArrayList;
|
||||
@@ -177,7 +178,9 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseL
|
||||
addCaretListener(this);
|
||||
}
|
||||
|
||||
public void setScript(ScriptInfo script, ABC abc) {
|
||||
private List<DoABCTag> abcList;
|
||||
|
||||
public void setScript(ScriptInfo script, ABC abc,List<DoABCTag> abcList) {
|
||||
setText("//Please wait...");
|
||||
if (script == null) {
|
||||
highlights = new ArrayList<Highlighting>();
|
||||
@@ -189,7 +192,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseL
|
||||
|
||||
String hilightedCode;
|
||||
if (!bufferedClasses.containsKey(script)) {
|
||||
hilightedCode = script.convert(abc, false, true);
|
||||
hilightedCode = script.convert(abcList,abc, false, true);
|
||||
highlights = Highlighting.getInstrHighlights(hilightedCode);
|
||||
traitHighlights = Highlighting.getTraitHighlights(hilightedCode);
|
||||
methodHighlights = Highlighting.getMethodHighlights(hilightedCode);
|
||||
@@ -205,6 +208,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseL
|
||||
}
|
||||
setText(hilightedCode);
|
||||
this.abc = abc;
|
||||
this.abcList = abcList;
|
||||
this.script = script;
|
||||
}
|
||||
|
||||
@@ -212,7 +216,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseL
|
||||
if (bufferedClasses.containsKey(script)) {
|
||||
bufferedClasses.remove(script);
|
||||
}
|
||||
setScript(script, abc);
|
||||
setScript(script, abc,abcList);
|
||||
setNoTrait();
|
||||
}
|
||||
|
||||
|
||||
@@ -52,14 +52,13 @@ public class IconListRenderer
|
||||
// Get icon to use for the list item value
|
||||
|
||||
String modifiersRegex = "(public |static |final |override |private |protected |package )*";
|
||||
|
||||
if (value.toString().matches(modifiersRegex + "const .*")) {
|
||||
if((" "+value.toString()).contains(" const ")){
|
||||
label.setIcon(constIcon);
|
||||
}
|
||||
if (value.toString().matches(modifiersRegex + "var .*")) {
|
||||
if((" "+value.toString()).contains(" var ")){
|
||||
label.setIcon(variableIcon);
|
||||
}
|
||||
if (value.toString().matches(modifiersRegex + "function .*")) {
|
||||
if((" "+value.toString()).contains(" function ")){
|
||||
label.setIcon(functionIcon);
|
||||
}
|
||||
if (value.toString().equals(TraitsListModel.STR_CLASS_INITIALIZER)) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.*;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -116,6 +117,13 @@ public class MainFrame extends JFrame implements ActionListener, ItemListener {
|
||||
return table;
|
||||
}
|
||||
|
||||
public void setAbc(ABC abc) {
|
||||
this.abc = abc;
|
||||
updateConstList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void updateConstList() {
|
||||
switch (constantTypeList.getSelectedIndex()) {
|
||||
case 0:
|
||||
@@ -148,14 +156,19 @@ public class MainFrame extends JFrame implements ActionListener, ItemListener {
|
||||
}
|
||||
|
||||
public void switchAbc(int index) {
|
||||
listIndex = index;
|
||||
this.abc = list.get(listIndex).abc;
|
||||
classTree.setABC(abc);
|
||||
decompiledTextArea.setABC(abc);
|
||||
navigator.setABC(abc);
|
||||
listIndex = index;
|
||||
if (index == -1) {
|
||||
classTree.setDoABCTags(list);
|
||||
} else {
|
||||
List<DoABCTag> oneList = new ArrayList<DoABCTag>();
|
||||
oneList.add(list.get(index));
|
||||
this.abc=list.get(index).abc;
|
||||
classTree.setDoABCTags(oneList);
|
||||
}
|
||||
//decompiledTextArea.setABC(abc);
|
||||
//navigator.setABC(abc);
|
||||
//constantTypeList = new JComboBox(new String[]{"UINT", "INT", "DOUBLE", "STRING", "NAMESPACE", "NAMESPACESET", "MULTINAME"});
|
||||
updateConstList();
|
||||
|
||||
}
|
||||
|
||||
public MainFrame(List<DoABCTag> list) {
|
||||
@@ -195,7 +208,7 @@ public class MainFrame extends JFrame implements ActionListener, ItemListener {
|
||||
pan2.add((abcComboBox = new JComboBox(new ABCComboBoxModel(list))), BorderLayout.NORTH);
|
||||
|
||||
navigator = new TraitsList();
|
||||
navigator.setABC(abc);
|
||||
navigator.setABC(list,abc);
|
||||
|
||||
|
||||
JPanel navPanel = new JPanel(new BorderLayout());
|
||||
@@ -206,7 +219,7 @@ public class MainFrame extends JFrame implements ActionListener, ItemListener {
|
||||
navPanel.add(new JScrollPane(navigator), BorderLayout.CENTER);
|
||||
|
||||
splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
|
||||
new JScrollPane(classTree = new ClassesListTree(abc)),
|
||||
new JScrollPane(classTree = new ClassesListTree(list)),
|
||||
navPanel);
|
||||
|
||||
JTabbedPane tabbedPane = new JTabbedPane();
|
||||
@@ -332,6 +345,9 @@ public class MainFrame extends JFrame implements ActionListener, ItemListener {
|
||||
constantTable = new JTable();
|
||||
autoResizeColWidth(constantTable, new UIntTableModel(abc));
|
||||
constantTable.setAutoCreateRowSorter(true);
|
||||
|
||||
final List<DoABCTag> inlist=list;
|
||||
|
||||
constantTable.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
@@ -343,7 +359,7 @@ public class MainFrame extends JFrame implements ActionListener, ItemListener {
|
||||
}
|
||||
int multinameIndex = constantTable.convertRowIndexToModel(rowIndex);
|
||||
if (multinameIndex > 0) {
|
||||
UsageFrame usageFrame = new UsageFrame(abc, multinameIndex);
|
||||
UsageFrame usageFrame = new UsageFrame(inlist,abc, multinameIndex);
|
||||
usageFrame.setVisible(true);
|
||||
}
|
||||
}
|
||||
@@ -452,7 +468,7 @@ public class MainFrame extends JFrame implements ActionListener, ItemListener {
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
switchAbc(listIndex);
|
||||
switchAbc(listIndex-1);
|
||||
}
|
||||
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
@@ -461,7 +477,7 @@ public class MainFrame extends JFrame implements ActionListener, ItemListener {
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
switchAbc(index);
|
||||
switchAbc(index-1);
|
||||
}
|
||||
if (e.getSource() == constantTypeList) {
|
||||
int index = ((JComboBox) e.getSource()).getSelectedIndex();
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.jpexs.asdec.abc.gui;
|
||||
|
||||
import com.jpexs.asdec.Main;
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
@@ -26,6 +28,7 @@ import javax.swing.event.ListSelectionListener;
|
||||
public class TraitsList extends JList implements ListSelectionListener {
|
||||
|
||||
ABC abc;
|
||||
List<DoABCTag> abcTags;
|
||||
int classIndex = -1;
|
||||
|
||||
public int getClassIndex() {
|
||||
@@ -37,8 +40,9 @@ public class TraitsList extends JList implements ListSelectionListener {
|
||||
setCellRenderer(new IconListRenderer());
|
||||
}
|
||||
|
||||
public void setABC(ABC abc) {
|
||||
public void setABC(List<DoABCTag> abcTags,ABC abc) {
|
||||
this.abc = abc;
|
||||
this.abcTags=abcTags;
|
||||
setModel(new DefaultListModel());
|
||||
setClassIndex(-1);
|
||||
}
|
||||
@@ -49,7 +53,7 @@ public class TraitsList extends JList implements ListSelectionListener {
|
||||
setModel(new DefaultListModel());
|
||||
} else {
|
||||
if (abc != null) {
|
||||
setModel(new TraitsListModel(abc, classIndex));
|
||||
setModel(new TraitsListModel(abcTags,abc, classIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package com.jpexs.asdec.abc.gui;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
import javax.swing.ListModel;
|
||||
import javax.swing.event.ListDataListener;
|
||||
|
||||
@@ -26,9 +28,11 @@ public class TraitsListModel implements ListModel {
|
||||
int classIndex;
|
||||
public static final String STR_INSTANCE_INITIALIZER = "instance initializer";
|
||||
public static final String STR_CLASS_INITIALIZER = "class initializer";
|
||||
private List<DoABCTag> abcTags;
|
||||
|
||||
public TraitsListModel(ABC abc, int classIndex) {
|
||||
public TraitsListModel(List<DoABCTag> abcTags,ABC abc, int classIndex) {
|
||||
this.abc = abc;
|
||||
this.abcTags=abcTags;
|
||||
this.classIndex = classIndex;
|
||||
}
|
||||
|
||||
@@ -41,9 +45,9 @@ public class TraitsListModel implements ListModel {
|
||||
|
||||
public Object getElementAt(int index) {
|
||||
if (index < abc.class_info[classIndex].static_traits.traits.length) {
|
||||
return abc.class_info[classIndex].static_traits.traits[index].convertHeader(abc, true, false, classIndex, false);
|
||||
return abc.class_info[classIndex].static_traits.traits[index].convertHeader(abcTags,abc, true, false, classIndex, false);
|
||||
} else if (index < abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length) {
|
||||
return abc.instance_info[classIndex].instance_traits.traits[index - abc.class_info[classIndex].static_traits.traits.length].convertHeader(abc, false, false, classIndex, false);
|
||||
return abc.instance_info[classIndex].instance_traits.traits[index - abc.class_info[classIndex].static_traits.traits.length].convertHeader(abcTags,abc, false, false, classIndex, false);
|
||||
} else if (index == abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length) {
|
||||
return STR_INSTANCE_INITIALIZER;
|
||||
} else {
|
||||
|
||||
@@ -16,15 +16,21 @@
|
||||
*/
|
||||
package com.jpexs.asdec.abc.gui;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TreeLeafClass {
|
||||
public class TreeLeafScript {
|
||||
|
||||
public int classIndex;
|
||||
public ABC abc;
|
||||
public int scriptIndex;
|
||||
|
||||
public TreeLeafClass(int classIndex) {
|
||||
this.classIndex = classIndex;
|
||||
public TreeLeafScript(ABC abc, int scriptIndex) {
|
||||
this.abc = abc;
|
||||
this.scriptIndex = scriptIndex;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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.asdec.abc.gui;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TreeLeafString {
|
||||
|
||||
public String str;
|
||||
|
||||
public TreeLeafString(String str) {
|
||||
this.str = str;
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import com.jpexs.asdec.abc.usages.MethodMultinameUsage;
|
||||
import com.jpexs.asdec.abc.usages.MultinameUsage;
|
||||
import com.jpexs.asdec.abc.usages.TraitMultinameUsage;
|
||||
import com.jpexs.asdec.gui.View;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Container;
|
||||
import java.awt.FlowLayout;
|
||||
@@ -45,10 +46,10 @@ public class UsageFrame extends JFrame implements ActionListener, MouseListener
|
||||
private UsageListModel usageListModel;
|
||||
private ABC abc;
|
||||
|
||||
public UsageFrame(ABC abc, int multinameIndex) {
|
||||
public UsageFrame(List<DoABCTag> abcTags,ABC abc, int multinameIndex) {
|
||||
List<MultinameUsage> usages = abc.findMultinameUsage(multinameIndex);
|
||||
this.abc = abc;
|
||||
usageListModel = new UsageListModel(abc);
|
||||
usageListModel = new UsageListModel(abcTags,abc);
|
||||
for (MultinameUsage u : usages) {
|
||||
usageListModel.addElement(u);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.jpexs.asdec.abc.gui;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.usages.MultinameUsage;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
import javax.swing.DefaultListModel;
|
||||
|
||||
/**
|
||||
@@ -27,19 +29,21 @@ import javax.swing.DefaultListModel;
|
||||
public class UsageListModel extends DefaultListModel {
|
||||
|
||||
private ABC abc;
|
||||
private List<DoABCTag> abcTags;
|
||||
|
||||
public UsageListModel(ABC abc) {
|
||||
public UsageListModel(List<DoABCTag> abcTags,ABC abc) {
|
||||
this.abc = abc;
|
||||
this.abcTags=abcTags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(int index) {
|
||||
return ((MultinameUsage) super.get(index)).toString(abc);
|
||||
return ((MultinameUsage) super.get(index)).toString(abcTags,abc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int index) {
|
||||
return ((MultinameUsage) super.getElementAt(index)).toString(abc);
|
||||
return ((MultinameUsage) super.getElementAt(index)).toString(abcTags,abc);
|
||||
}
|
||||
|
||||
public MultinameUsage getUsage(int index) {
|
||||
|
||||
@@ -75,7 +75,7 @@ public class InstanceInfo {
|
||||
}
|
||||
|
||||
if (isFinal()) {
|
||||
modifiers = "final ";
|
||||
modifiers += "final ";
|
||||
}
|
||||
if (isDynamic()) {
|
||||
modifiers = modifiers + "dynamic ";
|
||||
|
||||
@@ -19,6 +19,8 @@ package com.jpexs.asdec.abc.types;
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.types.traits.Trait;
|
||||
import com.jpexs.asdec.abc.types.traits.Traits;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
|
||||
public class ScriptInfo {
|
||||
|
||||
@@ -45,7 +47,7 @@ public class ScriptInfo {
|
||||
return "";
|
||||
}
|
||||
|
||||
public String convert(ABC abc, boolean pcode, boolean highlighting) {
|
||||
return traits.convert(abc, false, pcode, true, -1, highlighting);
|
||||
public String convert(List<DoABCTag> abcTags,ABC abc, boolean pcode, boolean highlighting) {
|
||||
return traits.convert(abcTags,abc, false, pcode, true, -1, highlighting);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.types.Multiname;
|
||||
import com.jpexs.asdec.abc.types.Namespace;
|
||||
import com.jpexs.asdec.helpers.Helper;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Trait {
|
||||
|
||||
@@ -40,18 +42,47 @@ public abstract class Trait {
|
||||
public static final int TRAIT_FUNCTION = 5;
|
||||
public static final int TRAIT_CONST = 6;
|
||||
|
||||
public String getModifiers(ABC abc, boolean isStatic) {
|
||||
public String getModifiers(List<DoABCTag> abcTags, ABC abc, boolean isStatic) {
|
||||
String ret = "";
|
||||
if ((kindFlags & ATTR_Override) > 0) {
|
||||
ret += "override";
|
||||
}
|
||||
Multiname m = getName(abc);
|
||||
if (m != null) {
|
||||
int v = abc.nsValueToName(m.namespace_index);
|
||||
if (v > -1) {
|
||||
ret += " " + abc.constants.constant_multiname[v].getName(abc.constants);
|
||||
String nsname = "";
|
||||
if (abc.constants.constant_namespace[m.namespace_index].kind == Namespace.KIND_NAMESPACE) {
|
||||
for (DoABCTag abcTag : abcTags) {
|
||||
nsname = abcTag.abc.nsValueToName(abc.constants.constant_namespace[m.namespace_index].getName(abc.constants));
|
||||
if (nsname.equals("-")) {
|
||||
break;
|
||||
}
|
||||
if (nsname.contains(".")) {
|
||||
nsname = nsname.substring(nsname.lastIndexOf(".") + 1);
|
||||
}
|
||||
if (!nsname.equals("")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Namespace ns = m.getNamespace(abc.constants);
|
||||
|
||||
if (nsname.contains(":")) {
|
||||
nsname = "";
|
||||
}
|
||||
|
||||
|
||||
if ((!nsname.equals("")) && (!nsname.equals("-"))) {
|
||||
} else {
|
||||
if (ns != null) {
|
||||
if (ns.kind == Namespace.KIND_NAMESPACE) {
|
||||
nsname = ns.getName(abc.constants);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!nsname.contains(":")) {
|
||||
ret += " " + nsname;
|
||||
}
|
||||
if (ns != null) {
|
||||
ret += " " + ns.getPrefix(abc);
|
||||
}
|
||||
@@ -76,16 +107,16 @@ public abstract class Trait {
|
||||
return abc.constants.constant_multiname[name_index].toString(abc.constants) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata);
|
||||
}
|
||||
|
||||
public String convert(ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight) {
|
||||
public String convert(List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight) {
|
||||
return abc.constants.constant_multiname[name_index].toString(abc.constants) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata);
|
||||
}
|
||||
|
||||
public String convertPackaged(ABC abc, boolean isStatic, boolean pcod, int classIndex, boolean highlight) {
|
||||
return makePackageFromIndex(abc, name_index, convert(abc, isStatic, pcod, classIndex, highlight));
|
||||
public String convertPackaged(List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcod, int classIndex, boolean highlight) {
|
||||
return makePackageFromIndex(abc, name_index, convert(abcTags, abc, isStatic, pcod, classIndex, highlight));
|
||||
}
|
||||
|
||||
public String convertHeader(ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight) {
|
||||
return convert(abc, isStatic, pcode, classIndex, highlight).trim();
|
||||
public String convertHeader(List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight) {
|
||||
return convert(abcTags, abc, isStatic, pcode, classIndex, highlight).trim();
|
||||
}
|
||||
|
||||
protected String makePackageFromIndex(ABC abc, int name_index, String value) {
|
||||
|
||||
@@ -23,12 +23,14 @@ import com.jpexs.asdec.abc.avm2.instructions.construction.NewFunctionIns;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.InitPropertyTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.SetPropertyTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.ABCException;
|
||||
import com.jpexs.asdec.abc.types.MethodBody;
|
||||
import com.jpexs.asdec.abc.types.Multiname;
|
||||
import com.jpexs.asdec.abc.types.Namespace;
|
||||
import com.jpexs.asdec.abc.types.NamespaceSet;
|
||||
import com.jpexs.asdec.helpers.Helper;
|
||||
import com.jpexs.asdec.helpers.Highlighting;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
@@ -46,14 +48,48 @@ public class TraitClass extends Trait {
|
||||
return "Class " + abc.constants.constant_multiname[name_index].toString(abc.constants) + " slot=" + slot_id + " class_info=" + class_info + " metadata=" + Helper.intArrToString(metadata);
|
||||
}
|
||||
|
||||
private void parseImportFromNS(ABC abc, List imports, Namespace ns, String ignorePackage, String name) {
|
||||
private void parseImportFromNS(List<DoABCTag> abcTags, ABC abc, List imports, List<String> uses, int namespace_index, String ignorePackage, String name) {
|
||||
Namespace ns = abc.constants.constant_namespace[namespace_index];
|
||||
if (name.equals("")) {
|
||||
name = "*";
|
||||
}
|
||||
if (ns.kind != Namespace.KIND_PACKAGE) {
|
||||
String newimport = ns.getName(abc.constants);
|
||||
if (ns.kind == Namespace.KIND_NAMESPACE) {
|
||||
String oldimport = newimport;
|
||||
newimport = null;
|
||||
for (DoABCTag abcTag : abcTags) {
|
||||
String newname = abcTag.abc.nsValueToName(oldimport);
|
||||
if (newname.equals("-")) {
|
||||
return;
|
||||
}
|
||||
if (!newname.equals("")) {
|
||||
newimport = newname;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newimport != null) {
|
||||
if (!imports.contains(newimport)) {
|
||||
if (newimport.contains(":")) {
|
||||
return;
|
||||
}
|
||||
String pkg = "";
|
||||
if (newimport.contains(".")) {
|
||||
pkg = newimport.substring(0, newimport.lastIndexOf("."));
|
||||
}
|
||||
String usname=newimport;
|
||||
if(usname.contains(".")){
|
||||
usname=usname.substring(usname.lastIndexOf(".")+1);
|
||||
}
|
||||
if (!pkg.equals(ignorePackage)) {
|
||||
imports.add(newimport);
|
||||
}
|
||||
uses.add(usname);
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else if (ns.kind != Namespace.KIND_PACKAGE) {
|
||||
return;
|
||||
}
|
||||
String newimport = ns.getName(abc.constants);
|
||||
if (newimport.equals("-")) {
|
||||
newimport = "";
|
||||
}
|
||||
@@ -71,50 +107,65 @@ public class TraitClass extends Trait {
|
||||
}
|
||||
}
|
||||
|
||||
private void parseImportFromMultiname(ABC abc, List imports, Multiname m, String ignorePackage) {
|
||||
private void parseImportFromMultiname(List<DoABCTag> abcTags, ABC abc, List<String> imports, List<String> uses, Multiname m, String ignorePackage) {
|
||||
if (m != null) {
|
||||
Namespace ns = m.getNamespace(abc.constants);
|
||||
String name = m.getName(abc.constants);
|
||||
NamespaceSet nss = m.getNamespaceSet(abc.constants);
|
||||
if (ns != null) {
|
||||
parseImportFromNS(abc, imports, ns, ignorePackage, name);
|
||||
parseImportFromNS(abcTags, abc, imports,uses, m.namespace_index, ignorePackage, name);
|
||||
}
|
||||
if (nss != null) {
|
||||
for (int ni : nss.namespaces) {
|
||||
parseImportFromNS(abc, imports, abc.constants.constant_namespace[ni], ignorePackage, name);
|
||||
parseImportFromNS(abcTags, abc, imports,uses, ni, ignorePackage, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void parseImportsFromMethodInfo(ABC abc, int method_index, List imports, String ignorePackage) {
|
||||
private void parseImportsFromMethodInfo(List<DoABCTag> abcTags, ABC abc, int method_index, List<String> imports, List<String> uses, String ignorePackage) {
|
||||
if (abc.method_info[method_index].ret_type != 0) {
|
||||
parseImportFromMultiname(abc, imports, abc.constants.constant_multiname[abc.method_info[method_index].ret_type], ignorePackage);
|
||||
parseImportFromMultiname(abcTags, abc, imports,uses, abc.constants.constant_multiname[abc.method_info[method_index].ret_type], ignorePackage);
|
||||
}
|
||||
for (int t : abc.method_info[method_index].param_types) {
|
||||
if (t != 0) {
|
||||
parseImportFromMultiname(abc, imports, abc.constants.constant_multiname[t], ignorePackage);
|
||||
parseImportFromMultiname(abcTags, abc, imports,uses, abc.constants.constant_multiname[t], ignorePackage);
|
||||
}
|
||||
}
|
||||
MethodBody body = abc.findBody(method_index);
|
||||
if (body != null) {
|
||||
for (ABCException ex : body.exceptions) {
|
||||
parseImportFromMultiname(abcTags, abc, imports,uses, abc.constants.constant_multiname[ex.type_index], ignorePackage);
|
||||
}
|
||||
for (AVM2Instruction ins : body.code.code) {
|
||||
if (ins.definition instanceof NewFunctionIns) {
|
||||
parseImportsFromMethodInfo(abc, ins.operands[0], imports, ignorePackage);
|
||||
parseImportsFromMethodInfo(abcTags, abc, ins.operands[0], imports,uses, ignorePackage);
|
||||
}
|
||||
for (int k = 0; k < ins.definition.operands.length; k++) {
|
||||
if (ins.definition.operands[k] == AVM2Code.DAT_MULTINAME_INDEX) {
|
||||
int multinameIndex = ins.operands[k];
|
||||
parseImportFromMultiname(abc, imports, abc.constants.constant_multiname[multinameIndex], ignorePackage);
|
||||
parseImportFromMultiname(abcTags, abc, imports,uses, abc.constants.constant_multiname[multinameIndex], ignorePackage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List getImports(ABC abc) {
|
||||
List<String> imports = new ArrayList<String>();
|
||||
private void parseImportsFromTrait(List<DoABCTag> abcTags, ABC abc, Trait t, List<String> imports, List<String> uses, String ignorePackage) {
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t;
|
||||
if (tm.method_info != 0) {
|
||||
parseImportsFromMethodInfo(abcTags, abc, tm.method_info, imports,uses, ignorePackage);
|
||||
}
|
||||
}
|
||||
parseImportFromMultiname(abcTags, abc, imports,uses, t.getName(abc), ignorePackage);
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst ts = (TraitSlotConst) t;
|
||||
parseImportFromMultiname(abcTags, abc, imports,uses, abc.constants.constant_multiname[ts.type_index], ignorePackage);
|
||||
}
|
||||
}
|
||||
|
||||
private List getImports(List<DoABCTag> abcTags, ABC abc,List<String> imports,List<String> uses) {
|
||||
//constructor
|
||||
|
||||
//parseImportFromMultiname(imports, constants.constant_multiname[instance_info[instanceIndex].name_index]);
|
||||
@@ -122,45 +173,32 @@ public class TraitClass extends Trait {
|
||||
String packageName = abc.instance_info[class_info].getName(abc.constants).getNamespace(abc.constants).getName(abc.constants);
|
||||
|
||||
if (abc.instance_info[class_info].super_index > 0) {
|
||||
parseImportFromMultiname(abc, imports, abc.constants.constant_multiname[abc.instance_info[class_info].super_index], packageName);
|
||||
parseImportFromMultiname(abcTags, abc, imports,uses, abc.constants.constant_multiname[abc.instance_info[class_info].super_index], packageName);
|
||||
}
|
||||
for (int i : abc.instance_info[class_info].interfaces) {
|
||||
parseImportFromMultiname(abc, imports, abc.constants.constant_multiname[i], packageName);
|
||||
parseImportFromMultiname(abcTags, abc, imports,uses, abc.constants.constant_multiname[i], packageName);
|
||||
}
|
||||
|
||||
//static
|
||||
for (Trait t : abc.class_info[class_info].static_traits.traits) {
|
||||
//parseImportFromMultiname(imports, t.getMultiName(constants));
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t;
|
||||
if (tm.method_info != 0) {
|
||||
parseImportsFromMethodInfo(abc, tm.method_info, imports, packageName);
|
||||
}
|
||||
}
|
||||
|
||||
parseImportsFromTrait(abcTags, abc, t, imports, uses, packageName);
|
||||
}
|
||||
|
||||
//static initializer
|
||||
parseImportsFromMethodInfo(abc, abc.class_info[class_info].cinit_index, imports, packageName);
|
||||
parseImportsFromMethodInfo(abcTags, abc, abc.class_info[class_info].cinit_index, imports, uses, packageName);
|
||||
|
||||
//instance
|
||||
for (Trait t : abc.instance_info[class_info].instance_traits.traits) {
|
||||
//parseImportFromMultiname(imports, t.getMultiName(constants));
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t;
|
||||
if (tm.method_info != 0) {
|
||||
parseImportsFromMethodInfo(abc, tm.method_info, imports, packageName);
|
||||
}
|
||||
}
|
||||
parseImportsFromTrait(abcTags, abc, t, imports, uses, packageName);
|
||||
}
|
||||
|
||||
//instance initializer
|
||||
parseImportsFromMethodInfo(abc, abc.instance_info[class_info].iinit_index, imports, packageName);
|
||||
parseImportsFromMethodInfo(abcTags, abc, abc.instance_info[class_info].iinit_index, imports, uses, packageName);
|
||||
return imports;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convert(ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight) {
|
||||
public String convert(List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight) {
|
||||
if (!highlight) {
|
||||
Highlighting.doHighlight = false;
|
||||
}
|
||||
@@ -168,12 +206,18 @@ public class TraitClass extends Trait {
|
||||
PrintStream out = new PrintStream(baos);
|
||||
|
||||
//imports
|
||||
List<String> imports = getImports(abc);
|
||||
List<String> imports = new ArrayList<String>();
|
||||
List<String> uses = new ArrayList<String>();
|
||||
getImports(abcTags, abc,imports,uses);
|
||||
for (String imp : imports) {
|
||||
out.println(ABC.IDENT_STRING + "import " + imp + ";");
|
||||
}
|
||||
out.println();
|
||||
|
||||
for (String us : uses) {
|
||||
out.println(ABC.IDENT_STRING + "use namespace " + us + ";");
|
||||
}
|
||||
out.println();
|
||||
|
||||
//class header
|
||||
String classHeader = abc.instance_info[class_info].getClassHeaderStr(abc);
|
||||
if (classHeader.startsWith("private ")) {
|
||||
@@ -266,9 +310,9 @@ public class TraitClass extends Trait {
|
||||
//}
|
||||
|
||||
//static variables,constants & methods
|
||||
outTraits.add(abc.class_info[class_info].static_traits.convert(abc, true, pcode, false, class_info, highlight));
|
||||
outTraits.add(abc.class_info[class_info].static_traits.convert(abcTags, abc, true, pcode, false, class_info, highlight));
|
||||
|
||||
outTraits.add(abc.instance_info[class_info].instance_traits.convert(abc, false, pcode, false, class_info, highlight));
|
||||
outTraits.add(abc.instance_info[class_info].instance_traits.convert(abcTags, abc, false, pcode, false, class_info, highlight));
|
||||
|
||||
out.println(Helper.joinStrings(outTraits, "\r\n\r\n"));
|
||||
out.println(ABC.IDENT_STRING + "}");//class
|
||||
|
||||
@@ -20,6 +20,8 @@ import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodBody;
|
||||
import com.jpexs.asdec.helpers.Helper;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
public class TraitFunction extends Trait {
|
||||
@@ -33,8 +35,8 @@ public class TraitFunction extends Trait {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertHeader(ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight) {
|
||||
String modifier = getModifiers(abc, isStatic) + " ";
|
||||
public String convertHeader(List<DoABCTag> abcTags,ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight) {
|
||||
String modifier = getModifiers(abcTags,abc, isStatic) + " ";
|
||||
if (modifier.equals(" ")) {
|
||||
modifier = "";
|
||||
}
|
||||
@@ -43,8 +45,8 @@ public class TraitFunction extends Trait {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convert(ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight) {
|
||||
String header = convertHeader(abc, isStatic, pcode, classIndex, highlight);
|
||||
public String convert(List<DoABCTag> abcTags,ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight) {
|
||||
String header = convertHeader(abcTags,abc, isStatic, pcode, classIndex, highlight);
|
||||
String bodyStr = "";
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (bodyIndex != -1) {
|
||||
|
||||
@@ -20,6 +20,8 @@ import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodBody;
|
||||
import com.jpexs.asdec.helpers.Helper;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
public class TraitMethodGetterSetter extends Trait {
|
||||
@@ -32,8 +34,9 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
return "0x" + Helper.formatAddress(fileOffset) + " " + Helper.byteArrToString(bytes) + " MethodGetterSetter " + abc.constants.constant_multiname[name_index].toString(abc.constants) + " disp_id=" + disp_id + " method_info=" + method_info + " metadata=" + Helper.intArrToString(metadata);
|
||||
}
|
||||
|
||||
public String convertHeader(ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight) {
|
||||
String modifier = getModifiers(abc, isStatic) + " ";
|
||||
@Override
|
||||
public String convertHeader(List<DoABCTag> abcTags,ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight) {
|
||||
String modifier = getModifiers(abcTags,abc, isStatic) + " ";
|
||||
if (modifier.equals(" ")) {
|
||||
modifier = "";
|
||||
}
|
||||
@@ -50,8 +53,8 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convert(ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight) {
|
||||
String header = convertHeader(abc, isStatic, pcode, classIndex, highlight);
|
||||
public String convert(List<DoABCTag> abcTags,ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight) {
|
||||
String header = convertHeader(abcTags,abc, isStatic, pcode, classIndex, highlight);
|
||||
|
||||
String bodyStr = "";
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
|
||||
@@ -22,7 +22,9 @@ import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.ValueKind;
|
||||
import com.jpexs.asdec.helpers.Helper;
|
||||
import com.jpexs.asdec.helpers.Highlighting;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class TraitSlotConst extends Trait {
|
||||
|
||||
@@ -77,9 +79,17 @@ public class TraitSlotConst extends Trait {
|
||||
return slotconst + " " + getName(abc).getName(abc.constants) + typeStr + valueStr + ";";
|
||||
}
|
||||
|
||||
public boolean isNamespace(){
|
||||
if (value_kind != 0) {
|
||||
ValueKind val = new ValueKind(value_index, value_kind);
|
||||
return val.isNamespace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convert(ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight) {
|
||||
String modifier = getModifiers(abc, isStatic) + " ";
|
||||
public String convert(List<DoABCTag> abcTags,ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight) {
|
||||
String modifier = getModifiers(abcTags,abc, isStatic) + " ";
|
||||
if (modifier.equals(" ")) {
|
||||
modifier = "";
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.jpexs.asdec.abc.types.traits;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.helpers.Highlighting;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
|
||||
public class Traits {
|
||||
|
||||
@@ -46,7 +48,7 @@ public class Traits {
|
||||
return s;
|
||||
}
|
||||
|
||||
public String convert(ABC abc, boolean isStatic, boolean pcode, boolean makePackages, int classIndex, boolean highlighting) {
|
||||
public String convert(List<DoABCTag> abcTags,ABC abc, boolean isStatic, boolean pcode, boolean makePackages, int classIndex, boolean highlighting) {
|
||||
String s = "";
|
||||
for (int t = 0; t < traits.length; t++) {
|
||||
if (t > 0) {
|
||||
@@ -54,9 +56,9 @@ public class Traits {
|
||||
}
|
||||
String plus;
|
||||
if (makePackages) {
|
||||
plus = traits[t].convertPackaged(abc, isStatic, pcode, classIndex, highlighting);
|
||||
plus = traits[t].convertPackaged(abcTags,abc, isStatic, pcode, classIndex, highlighting);
|
||||
} else {
|
||||
plus = traits[t].convert(abc, isStatic, pcode, classIndex, highlighting);
|
||||
plus = traits[t].convert(abcTags,abc, isStatic, pcode, classIndex, highlighting);
|
||||
}
|
||||
if (highlighting) {
|
||||
int h = t;
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package com.jpexs.asdec.abc.usages;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -29,7 +31,7 @@ public class ClassNameMultinameUsage extends InsideClassMultinameUsage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ABC abc) {
|
||||
public String toString(List<DoABCTag> abcTags,ABC abc) {
|
||||
return "class " + abc.constants.constant_multiname[abc.instance_info[classIndex].name_index].getNameWithNamespace(abc.constants);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.types.traits.TraitMethodGetterSetter;
|
||||
import com.jpexs.asdec.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.asdec.abc.types.traits.Traits;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -32,14 +34,14 @@ public abstract class ConstVarMultinameUsage extends TraitMultinameUsage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ABC abc) {
|
||||
return super.toString(abc) + " "
|
||||
public String toString(List<DoABCTag> abcTags,ABC abc) {
|
||||
return super.toString(abcTags,abc) + " "
|
||||
+ (parentTraitIndex > -1
|
||||
? (isStatic
|
||||
? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader(abc, isStatic, false, classIndex, false))
|
||||
: (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(abc, isStatic, false, classIndex, false)))
|
||||
? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader(abcTags,abc, isStatic, false, classIndex, false))
|
||||
: (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(abcTags,abc, isStatic, false, classIndex, false)))
|
||||
: "")
|
||||
+ ((TraitSlotConst) traits.traits[traitIndex]).convertHeader(abc, isStatic, false, classIndex, false);
|
||||
+ ((TraitSlotConst) traits.traits[traitIndex]).convertHeader(abcTags,abc, isStatic, false, classIndex, false);
|
||||
}
|
||||
|
||||
public int getTraitIndex() {
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.jpexs.asdec.abc.usages;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.types.traits.Traits;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -30,7 +32,7 @@ public class ConstVarNameMultinameUsage extends ConstVarMultinameUsage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ABC abc) {
|
||||
return super.toString(abc) + " name";
|
||||
public String toString(List<DoABCTag> abcTags,ABC abc) {
|
||||
return super.toString(abcTags,abc) + " name";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.jpexs.asdec.abc.usages;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.types.traits.Traits;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -30,7 +32,7 @@ public class ConstVarTypeMultinameUsage extends ConstVarMultinameUsage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ABC abc) {
|
||||
return super.toString(abc) + " type";
|
||||
public String toString(List<DoABCTag> abcTags,ABC abc) {
|
||||
return super.toString(abcTags,abc) + " type";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package com.jpexs.asdec.abc.usages;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -29,7 +31,7 @@ public class ExtendsMultinameUsage extends InsideClassMultinameUsage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ABC abc) {
|
||||
return super.toString(abc) + " extends";
|
||||
public String toString(List<DoABCTag> abcTags,ABC abc) {
|
||||
return super.toString(abcTags,abc) + " extends";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package com.jpexs.asdec.abc.usages;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -29,7 +31,7 @@ public class ImplementsMultinameUsage extends InsideClassMultinameUsage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ABC abc) {
|
||||
return super.toString(abc) + " implements";
|
||||
public String toString(List<DoABCTag> abcTags,ABC abc) {
|
||||
return super.toString(abcTags,abc) + " implements";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package com.jpexs.asdec.abc.usages;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -32,7 +34,7 @@ public abstract class InsideClassMultinameUsage extends MultinameUsage {
|
||||
this.classIndex = classIndex;
|
||||
}
|
||||
|
||||
public String toString(ABC abc) {
|
||||
public String toString(List<DoABCTag> abcTags,ABC abc) {
|
||||
return "class " + abc.constants.constant_multiname[abc.instance_info[classIndex].name_index].getNameWithNamespace(abc.constants);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.jpexs.asdec.abc.usages;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.types.traits.Traits;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -30,7 +32,7 @@ public class MethodBodyMultinameUsage extends MethodMultinameUsage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ABC abc) {
|
||||
return super.toString(abc) + " body";
|
||||
public String toString(List<DoABCTag> abcTags,ABC abc) {
|
||||
return super.toString(abcTags,abc) + " body";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ package com.jpexs.asdec.abc.usages;
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.types.traits.TraitMethodGetterSetter;
|
||||
import com.jpexs.asdec.abc.types.traits.Traits;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -38,17 +40,17 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ABC abc) {
|
||||
return super.toString(abc) + " " + (isInitializer
|
||||
public String toString(List<DoABCTag> abcTags,ABC abc) {
|
||||
return super.toString(abcTags,abc) + " " + (isInitializer
|
||||
? (isStatic
|
||||
? "class initializer"
|
||||
: "instance initializer")
|
||||
: ((parentTraitIndex > -1
|
||||
? (isStatic
|
||||
? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader(abc, isStatic, false, classIndex, false))
|
||||
: (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(abc, isStatic, false, classIndex, false))) + " "
|
||||
? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader(abcTags,abc, isStatic, false, classIndex, false))
|
||||
: (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(abcTags,abc, isStatic, false, classIndex, false))) + " "
|
||||
: "")
|
||||
+ (((TraitMethodGetterSetter) traits.traits[traitIndex]).convertHeader(abc, isStatic, false, classIndex, false))));
|
||||
+ (((TraitMethodGetterSetter) traits.traits[traitIndex]).convertHeader(abcTags,abc, isStatic, false, classIndex, false))));
|
||||
}
|
||||
|
||||
public int getTraitIndex() {
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.jpexs.asdec.abc.usages;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.types.traits.Traits;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -30,7 +32,7 @@ public class MethodNameMultinameUsage extends MethodMultinameUsage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ABC abc) {
|
||||
return super.toString(abc) + " name";
|
||||
public String toString(List<DoABCTag> abcTags,ABC abc) {
|
||||
return super.toString(abcTags,abc) + " name";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.jpexs.asdec.abc.usages;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.types.traits.Traits;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -30,7 +32,7 @@ public class MethodParamsMultinameUsage extends MethodMultinameUsage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ABC abc) {
|
||||
return super.toString(abc) + " params";
|
||||
public String toString(List<DoABCTag> abcTags,ABC abc) {
|
||||
return super.toString(abcTags,abc) + " params";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.jpexs.asdec.abc.usages;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.types.traits.Traits;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -30,7 +32,7 @@ public class MethodReturnTypeMultinameUsage extends MethodMultinameUsage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ABC abc) {
|
||||
return super.toString(abc) + " return type";
|
||||
public String toString(List<DoABCTag> abcTags,ABC abc) {
|
||||
return super.toString(abcTags,abc) + " return type";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package com.jpexs.asdec.abc.usages;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -24,5 +26,5 @@ import com.jpexs.asdec.abc.ABC;
|
||||
*/
|
||||
public abstract class MultinameUsage {
|
||||
|
||||
public abstract String toString(ABC abc);
|
||||
public abstract String toString(List<DoABCTag> abcTags,ABC abc);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package com.jpexs.asdec.abc.usages;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -31,7 +33,7 @@ public class TypeNameMultinameUsage extends MultinameUsage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ABC abc) {
|
||||
public String toString(List<DoABCTag> abcTags,ABC abc) {
|
||||
return "TypeName " + abc.constants.constant_multiname[typename_index].toString(abc.constants);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user