mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-24 22:00:55 +00:00
AS3: Basic finding usage of multinames
This commit is contained in:
@@ -26,8 +26,6 @@ import com.jpexs.asdec.gui.proxy.ProxyFrame;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import com.jpexs.asdec.tags.Tag;
|
||||
import com.jpexs.proxy.Replacement;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
@@ -733,5 +733,20 @@ public class ABC {
|
||||
}
|
||||
}
|
||||
|
||||
//public
|
||||
public List<Integer> findMultinameUsage(int multinameIndex){
|
||||
List<Integer> ret=new ArrayList<Integer>();
|
||||
for(int i=0;i<bodies.length;i++){
|
||||
loopbody:for(AVM2Instruction ins:bodies[i].code.code){
|
||||
for(int op=0;op<ins.definition.operands.length;op++){
|
||||
if(ins.definition.operands[op]==AVM2Code.DAT_MULTINAME_INDEX){
|
||||
if(ins.operands[op]==multinameIndex){
|
||||
ret.add(i);
|
||||
break loopbody;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 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 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Usage {
|
||||
|
||||
}
|
||||
@@ -297,6 +297,24 @@ public class MainFrame extends JFrame implements ActionListener, ItemListener {
|
||||
constantTable = new JTable();
|
||||
autoResizeColWidth(constantTable, new UIntTableModel(abc));
|
||||
constantTable.setAutoCreateRowSorter(true);
|
||||
constantTable.addMouseListener(new MouseAdapter(){
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if(e.getClickCount()==2){
|
||||
if(constantTypeList.getSelectedIndex()==6){
|
||||
int rowIndex=constantTable.getSelectedRow();
|
||||
if(rowIndex==-1) return;
|
||||
int multinameIndex=constantTable.convertRowIndexToModel(rowIndex);
|
||||
if(multinameIndex>0){
|
||||
UsageFrame usageFrame=new UsageFrame(abc, multinameIndex);
|
||||
usageFrame.setVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
constantTypeList.addItemListener(this);
|
||||
panConstants.add(constantTypeList, BorderLayout.NORTH);
|
||||
panConstants.add(new JScrollPane(constantTable), BorderLayout.CENTER);
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (C) 2010 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 2
|
||||
* 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.gui;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.types.traits.Trait;
|
||||
import com.jpexs.asdec.abc.types.traits.TraitMethodGetterSetter;
|
||||
import com.jpexs.asdec.gui.View;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Container;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class UsageFrame extends JFrame implements ActionListener {
|
||||
private JButton gotoButton=new JButton("Go to");
|
||||
private JButton cancelButton=new JButton("Cancel");
|
||||
private JList usageList;
|
||||
private DefaultListModel usageListModel=new DefaultListModel();
|
||||
public UsageFrame(ABC abc,int multinameIndex){
|
||||
List<Integer> usages=abc.findMultinameUsage(multinameIndex);
|
||||
for(int bodyIndex:usages){
|
||||
for(int c=0;c<abc.class_info.length;c++){
|
||||
if(abc.class_info[c].cinit_index==bodyIndex) usageListModel.addElement(abc.instance_info[c].getName(abc.constants).getNameWithNamespace(abc.constants)+" (static initializer)");
|
||||
if(abc.instance_info[c].iinit_index==bodyIndex) usageListModel.addElement(abc.instance_info[c].getName(abc.constants).getNameWithNamespace(abc.constants)+" (instance initializer)");
|
||||
for(Trait t:abc.class_info[c].static_traits.traits){
|
||||
if(t instanceof TraitMethodGetterSetter){
|
||||
TraitMethodGetterSetter tmgs=(TraitMethodGetterSetter)t;
|
||||
if(tmgs.method_info==abc.bodies[bodyIndex].method_info){
|
||||
usageListModel.addElement("static "+abc.instance_info[c].getName(abc.constants).getNameWithNamespace(abc.constants)+"."+tmgs.getMethodName(abc.constants));
|
||||
}
|
||||
}
|
||||
}
|
||||
for(Trait t:abc.instance_info[c].instance_traits.traits){
|
||||
if(t instanceof TraitMethodGetterSetter){
|
||||
TraitMethodGetterSetter tmgs=(TraitMethodGetterSetter)t;
|
||||
if(tmgs.method_info==abc.bodies[bodyIndex].method_info){
|
||||
usageListModel.addElement(abc.instance_info[c].getName(abc.constants).getNameWithNamespace(abc.constants)+"."+tmgs.getMethodName(abc.constants));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
usageList=new JList(usageListModel);
|
||||
gotoButton.setActionCommand("GOTO");
|
||||
gotoButton.addActionListener(this);
|
||||
cancelButton.setActionCommand("CANCEL");
|
||||
cancelButton.addActionListener(this);
|
||||
JPanel buttonsPanel=new JPanel();
|
||||
buttonsPanel.setLayout(new FlowLayout());
|
||||
//buttonsPanel.add(gotoButton);
|
||||
buttonsPanel.add(cancelButton);
|
||||
|
||||
Container cont=getContentPane();
|
||||
cont.setLayout(new BorderLayout());
|
||||
cont.add(new JScrollPane(usageList),BorderLayout.CENTER);
|
||||
cont.add(buttonsPanel, BorderLayout.SOUTH);
|
||||
setSize(400,300);
|
||||
setTitle("Usages:"+abc.constants.constant_multiname[multinameIndex].getNameWithNamespace(abc.constants));
|
||||
View.centerScreen(this);
|
||||
View.setWindowIcon(this);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(e.getActionCommand().equals("GOTO")){
|
||||
|
||||
}
|
||||
if(e.getActionCommand().equals("CANCEL")){
|
||||
setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,6 +141,17 @@ public class Multiname {
|
||||
}
|
||||
}
|
||||
|
||||
public String getNameWithNamespace(ConstantPool constants){
|
||||
String ret="";
|
||||
Namespace ns=getNamespace(constants);
|
||||
if(ns!=null){
|
||||
String nsname=ns.getName(constants);
|
||||
if(!nsname.equals("")) ret+=nsname+".";
|
||||
}
|
||||
ret+=getName(constants);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Namespace getNamespace(ConstantPool constants) {
|
||||
if ((namespace_index == 0) || (namespace_index == -1)) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user