mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 07:50:47 +00:00
Initial version based on previous work. (Version alpha 7)
This commit is contained in:
@@ -0,0 +1,372 @@
|
||||
package com.jpexs.asdec;
|
||||
|
||||
import com.jpexs.asdec.abc.NotSameException;
|
||||
import com.jpexs.asdec.gui.LoadingDialog;
|
||||
import com.jpexs.asdec.gui.ModeFrame;
|
||||
import com.jpexs.asdec.gui.View;
|
||||
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 javax.swing.*;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Main executable class
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
public static com.jpexs.asdec.abc.gui.MainFrame abcMainFrame;
|
||||
public static com.jpexs.asdec.action.gui.MainFrame actionMainFrame;
|
||||
public static ProxyFrame proxyFrame;
|
||||
public static String file;
|
||||
public static String maskURL;
|
||||
public static SWF swf;
|
||||
public static String version = "alpha7";
|
||||
public static String applicationName = "JP ActionScript Decompiler v." + version;
|
||||
public static LoadingDialog loadingDialog = new LoadingDialog();
|
||||
public static ModeFrame modeFrame;
|
||||
private static boolean working = false;
|
||||
private static TrayIcon trayIcon;
|
||||
private static MenuItem stopMenuItem;
|
||||
public static boolean DEBUG_COPY = false;
|
||||
public static boolean DEBUG_MODE = false;
|
||||
public static boolean DISABLE_DANGEROUS = false;
|
||||
|
||||
public static String getFileTitle() {
|
||||
if (maskURL != null) return maskURL;
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of replacements
|
||||
*/
|
||||
public static java.util.List<Replacement> replacements = new ArrayList<Replacement>();
|
||||
|
||||
|
||||
private static String getASDecHome() {
|
||||
String dir = ".";//System.getProperty("user.home");
|
||||
if (!dir.endsWith(File.separator)) dir += File.separator;
|
||||
dir += "config" + File.separator;
|
||||
return dir;
|
||||
}
|
||||
|
||||
private static String getReplacementsFile() {
|
||||
return getASDecHome() + "replacements.ini";
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves replacements to file for future use
|
||||
*/
|
||||
public static void saveReplacements() {
|
||||
try {
|
||||
File f = new File(getASDecHome());
|
||||
if (!f.exists()) f.mkdir();
|
||||
PrintWriter pw = new PrintWriter(new FileWriter(getReplacementsFile()));
|
||||
for (Replacement r : replacements) {
|
||||
pw.println(r.urlPattern);
|
||||
pw.println(r.targetFile);
|
||||
}
|
||||
pw.close();
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load replacements from file
|
||||
*/
|
||||
public static void loadReplacements() {
|
||||
replacements = new ArrayList<Replacement>();
|
||||
try {
|
||||
BufferedReader br = new BufferedReader(new FileReader(getReplacementsFile()));
|
||||
String s = "";
|
||||
while ((s = br.readLine()) != null) {
|
||||
Replacement r = new Replacement(s, br.readLine());
|
||||
replacements.add(r);
|
||||
}
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isWorking() {
|
||||
return working;
|
||||
}
|
||||
|
||||
public static void showProxy() {
|
||||
if (proxyFrame == null) proxyFrame = new ProxyFrame();
|
||||
proxyFrame.setVisible(true);
|
||||
proxyFrame.setState(Frame.NORMAL);
|
||||
}
|
||||
|
||||
public static void startWork(String name) {
|
||||
working = true;
|
||||
abcMainFrame.setStatus(name);
|
||||
}
|
||||
|
||||
public static void stopWork() {
|
||||
working = false;
|
||||
abcMainFrame.setStatus("");
|
||||
}
|
||||
|
||||
public static SWF parseSWF(String file) throws Exception {
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
SWF locswf = new SWF(fis);
|
||||
return locswf;
|
||||
}
|
||||
|
||||
|
||||
public static void saveFile(String outfile) throws IOException {
|
||||
file = outfile;
|
||||
swf.saveTo(new FileOutputStream(outfile));
|
||||
}
|
||||
|
||||
|
||||
private static class OpenFileWorker extends SwingWorker {
|
||||
@Override
|
||||
protected Object doInBackground() throws Exception {
|
||||
try {
|
||||
swf = parseSWF(Main.file);
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
DEBUG_COPY = true;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
swf.saveTo(baos);
|
||||
} catch (NotSameException nse) {
|
||||
if (DEBUG_MODE) {
|
||||
nse.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
JOptionPane.showMessageDialog(null, "WARNING: The SWF decompiler may have problems saving this file. Recommended usage is READ ONLY.");
|
||||
}
|
||||
DEBUG_COPY = false;
|
||||
//DEBUG_COPY=true;
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
JOptionPane.showMessageDialog(null, "Cannot load SWF file.");
|
||||
loadingDialog.setVisible(false);
|
||||
return false;
|
||||
}
|
||||
List<Tag> listAbc = new ArrayList<Tag>();
|
||||
for (Tag t : swf.tags) {
|
||||
if (t instanceof DoABCTag) listAbc.add(t);
|
||||
}
|
||||
|
||||
|
||||
if (false) {
|
||||
JOptionPane.showMessageDialog(null, "This SWF file does not contain any ActionScript parts");
|
||||
loadingDialog.setVisible(false);
|
||||
if (!openFileDialog()) {
|
||||
System.exit(0);
|
||||
}
|
||||
} else {
|
||||
if (listAbc.size() > 0) {
|
||||
List<DoABCTag> listAbc2 = new ArrayList<DoABCTag>();
|
||||
for (Tag tag : listAbc) {
|
||||
listAbc2.add((DoABCTag) tag);
|
||||
}
|
||||
abcMainFrame = new com.jpexs.asdec.abc.gui.MainFrame(listAbc2);
|
||||
abcMainFrame.display();
|
||||
} else {
|
||||
actionMainFrame = new com.jpexs.asdec.action.gui.MainFrame(swf.tags);
|
||||
actionMainFrame.display();
|
||||
}
|
||||
}
|
||||
loadingDialog.setVisible(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean openFile(String swfFile) {
|
||||
if (abcMainFrame != null)
|
||||
abcMainFrame.setVisible(false);
|
||||
if (actionMainFrame != null)
|
||||
actionMainFrame.setVisible(false);
|
||||
Main.file = swfFile;
|
||||
Main.loadingDialog.setVisible(true);
|
||||
(new OpenFileWorker()).execute();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static boolean saveFileDialog(Frame f) {
|
||||
JFileChooser fc = new JFileChooser();
|
||||
int returnVal = fc.showSaveDialog(f);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File file = fc.getSelectedFile();
|
||||
try {
|
||||
Main.saveFile(file.getAbsolutePath());
|
||||
maskURL = null;
|
||||
return true;
|
||||
} catch (IOException ex) {
|
||||
JOptionPane.showMessageDialog(null, "Cannot write to the file");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean openFileDialog() {
|
||||
maskURL = null;
|
||||
JFileChooser fc = new JFileChooser();
|
||||
fc.setFileFilter(new FileFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File f) {
|
||||
return (f.getName().endsWith(".swf")) || (f.isDirectory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "SWF files (*.swf)";
|
||||
}
|
||||
|
||||
});
|
||||
int returnVal = fc.showOpenDialog(null);
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
File selfile = fc.getSelectedFile();
|
||||
Main.openFile(selfile.getAbsolutePath());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void showModeFrame() {
|
||||
if (modeFrame == null) modeFrame = new ModeFrame();
|
||||
modeFrame.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
View.setWinLookAndFeel();
|
||||
loadReplacements();
|
||||
if (args.length < 1) {
|
||||
showModeFrame();
|
||||
} else {
|
||||
if (args[0].equals("-proxy")) {
|
||||
int port = 55555;
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i].startsWith("-P")) {
|
||||
try {
|
||||
port = Integer.parseInt(args[i].substring(2));
|
||||
} catch (NumberFormatException nex) {
|
||||
System.err.println("Bad port number");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (proxyFrame == null) proxyFrame = new ProxyFrame();
|
||||
proxyFrame.setPort(port);
|
||||
addTrayIcon();
|
||||
switchProxy();
|
||||
} else {
|
||||
openFile(args[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String tempFile(String url) {
|
||||
File f = new File(getASDecHome() + "saved" + File.separator);
|
||||
if (!f.exists()) f.mkdirs();
|
||||
return getASDecHome() + "saved" + File.separator + "asdec_" + Integer.toHexString(url.hashCode()) + ".tmp";
|
||||
|
||||
}
|
||||
|
||||
public static void removeTrayIcon() {
|
||||
if (SystemTray.isSupported()) {
|
||||
SystemTray tray = SystemTray.getSystemTray();
|
||||
if (trayIcon != null) {
|
||||
tray.remove(trayIcon);
|
||||
trayIcon = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void switchProxy() {
|
||||
proxyFrame.switchState();
|
||||
if (stopMenuItem != null) {
|
||||
if (proxyFrame.isRunning()) {
|
||||
stopMenuItem.setLabel("Stop proxy");
|
||||
} else {
|
||||
stopMenuItem.setLabel("Start proxy");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void addTrayIcon() {
|
||||
if (trayIcon != null) return;
|
||||
if (SystemTray.isSupported()) {
|
||||
SystemTray tray = SystemTray.getSystemTray();
|
||||
trayIcon = new TrayIcon(View.loadImage("com/jpexs/asdec/gui/graphics/proxy16.png"), "JP ASDec Proxy");
|
||||
trayIcon.setImageAutoSize(true);
|
||||
PopupMenu trayPopup = new PopupMenu();
|
||||
|
||||
|
||||
ActionListener trayListener = new ActionListener() {
|
||||
/**
|
||||
* Invoked when an action occurs.
|
||||
*/
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getActionCommand().equals("EXIT")) Main.exit();
|
||||
if (e.getActionCommand().equals("SHOW")) Main.showProxy();
|
||||
if (e.getActionCommand().equals("SWITCH")) Main.switchProxy();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
MenuItem showMenuItem = new MenuItem("Show proxy");
|
||||
showMenuItem.setActionCommand("SHOW");
|
||||
showMenuItem.addActionListener(trayListener);
|
||||
trayPopup.add(showMenuItem);
|
||||
stopMenuItem = new MenuItem("Start proxy");
|
||||
stopMenuItem.setActionCommand("SWITCH");
|
||||
stopMenuItem.addActionListener(trayListener);
|
||||
trayPopup.add(stopMenuItem);
|
||||
trayPopup.addSeparator();
|
||||
MenuItem exitMenuItem = new MenuItem("Exit");
|
||||
exitMenuItem.setActionCommand("EXIT");
|
||||
exitMenuItem.addActionListener(trayListener);
|
||||
trayPopup.add(exitMenuItem);
|
||||
|
||||
trayIcon.setPopupMenu(trayPopup);
|
||||
trayIcon.addMouseListener(new MouseAdapter() {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getButton() == MouseEvent.BUTTON1) {
|
||||
Main.showProxy();
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
tray.add(trayIcon);
|
||||
} catch (AWTException ex) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void exit() {
|
||||
saveReplacements();
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
package com.jpexs.asdec;
|
||||
|
||||
import com.jpexs.asdec.tags.Tag;
|
||||
import com.jpexs.asdec.types.RECT;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.zip.DeflaterOutputStream;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
/**
|
||||
* Class representing SWF file
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class SWF {
|
||||
|
||||
/**
|
||||
* Tags inside of file
|
||||
*/
|
||||
public List<Tag> tags = new ArrayList<Tag>();
|
||||
/**
|
||||
* Rectangle for the display
|
||||
*/
|
||||
public RECT displayRect;
|
||||
/**
|
||||
* Movie frame rate
|
||||
*/
|
||||
public int frameRate;
|
||||
/**
|
||||
* Number of frames in movie
|
||||
*/
|
||||
public int frameCount;
|
||||
/**
|
||||
* Version of SWF
|
||||
*/
|
||||
public int version;
|
||||
/**
|
||||
* Size of the file
|
||||
*/
|
||||
public long fileSize;
|
||||
|
||||
/**
|
||||
* Use compression
|
||||
*/
|
||||
public boolean compressed = false;
|
||||
|
||||
/**
|
||||
* Gets all tags with specified id
|
||||
*
|
||||
* @param tagId Identificator of tag type
|
||||
* @return List of tags
|
||||
*/
|
||||
public List<Tag> getTagData(int tagId) {
|
||||
List<Tag> ret = new ArrayList<Tag>();
|
||||
for (Tag tag : tags) {
|
||||
if (tag.getId() == tagId) {
|
||||
ret.add(tag);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves this SWF into new file
|
||||
*
|
||||
* @param os OutputStream to save SWF in
|
||||
* @throws IOException
|
||||
*/
|
||||
public void saveTo(OutputStream os) throws IOException {
|
||||
try {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, version);
|
||||
sos.writeRECT(displayRect);
|
||||
sos.writeUI8(0);
|
||||
sos.writeUI8(frameRate);
|
||||
sos.writeUI16(frameCount);
|
||||
|
||||
sos.writeTags(tags);
|
||||
sos.writeUI16(0);
|
||||
sos.close();
|
||||
if (compressed) {
|
||||
os.write('C');
|
||||
} else {
|
||||
os.write('F');
|
||||
}
|
||||
os.write('W');
|
||||
os.write('S');
|
||||
os.write(version);
|
||||
byte data[] = baos.toByteArray();
|
||||
sos = new SWFOutputStream(os, version);
|
||||
sos.writeUI32(data.length + 8);
|
||||
|
||||
if (compressed) {
|
||||
os = new DeflaterOutputStream(os);
|
||||
}
|
||||
os.write(data);
|
||||
}
|
||||
finally {
|
||||
if (os != null)
|
||||
os.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct SWF from stream
|
||||
*
|
||||
* @param is Stream to read SWF from
|
||||
* @throws IOException
|
||||
*/
|
||||
public SWF(InputStream is) throws IOException {
|
||||
byte hdr[] = new byte[3];
|
||||
is.read(hdr);
|
||||
String shdr = new String(hdr);
|
||||
if ((!shdr.equals("FWS")) && (!shdr.equals("CWS"))) {
|
||||
throw new IOException("Invalid SWF file");
|
||||
}
|
||||
version = is.read();
|
||||
SWFInputStream sis = new SWFInputStream(is, version);
|
||||
fileSize = sis.readUI32();
|
||||
|
||||
if (hdr[0] == 'C') {
|
||||
sis = new SWFInputStream(new InflaterInputStream(is), version);
|
||||
compressed = true;
|
||||
}
|
||||
|
||||
|
||||
displayRect = sis.readRECT();
|
||||
sis.readUI8();
|
||||
frameRate = sis.readUI8();
|
||||
frameCount = sis.readUI16();
|
||||
tags = sis.readTagList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compress SWF file
|
||||
*
|
||||
* @param fis Input stream
|
||||
* @param fos Output stream
|
||||
*/
|
||||
public static void fws2cws(InputStream fis, OutputStream fos) {
|
||||
try {
|
||||
byte swfHead[] = new byte[8];
|
||||
fis.read(swfHead);
|
||||
|
||||
swfHead[0] = 'C';
|
||||
fos.write(swfHead);
|
||||
fos = new DeflaterOutputStream(fos);
|
||||
int i = 0;
|
||||
while ((i = fis.read()) != -1) {
|
||||
fos.write(i);
|
||||
}
|
||||
|
||||
fis.close();
|
||||
fos.close();
|
||||
} catch (FileNotFoundException ex) {
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Decompress SWF file
|
||||
*
|
||||
* @param fis Input stream
|
||||
* @param fos Output stream
|
||||
*/
|
||||
public static void cws2fws(InputStream fis, OutputStream fos) {
|
||||
try {
|
||||
byte swfHead[] = new byte[8];
|
||||
fis.read(swfHead);
|
||||
InflaterInputStream iis = new InflaterInputStream(fis);
|
||||
swfHead[0] = 'F';
|
||||
fos.write(swfHead);
|
||||
int i = 0;
|
||||
while ((i = iis.read()) != -1) {
|
||||
fos.write(i);
|
||||
}
|
||||
|
||||
fis.close();
|
||||
fos.close();
|
||||
} catch (FileNotFoundException ex) {
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,918 @@
|
||||
package com.jpexs.asdec;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.tags.Tag;
|
||||
import com.jpexs.asdec.types.*;
|
||||
import com.jpexs.asdec.types.filters.*;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Class for writing data into SWF file
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class SWFOutputStream extends OutputStream {
|
||||
private OutputStream os;
|
||||
private int version;
|
||||
private long pos = 0;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param os OutputStream for writing data
|
||||
* @param version Version of SWF
|
||||
*/
|
||||
public SWFOutputStream(OutputStream os, int version) {
|
||||
this.version = version;
|
||||
this.os = os;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes byte to the stream
|
||||
*
|
||||
* @param b byte to write
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
alignByte();
|
||||
os.write(b);
|
||||
pos++;
|
||||
}
|
||||
|
||||
private void alignByte() throws IOException {
|
||||
if (bitPos > 0) {
|
||||
bitPos = 0;
|
||||
write(tempByte);
|
||||
tempByte = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes UI8 (Unsigned 8bit integer) value to the stream
|
||||
*
|
||||
* @param val UI8 value to write
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeUI8(int val) throws IOException {
|
||||
write(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes String value to the stream
|
||||
*
|
||||
* @param value String value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeString(String value) throws IOException {
|
||||
write(value.getBytes("utf8"));
|
||||
write(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes UI32 (Unsigned 32bit integer) value to the stream
|
||||
*
|
||||
* @param value UI32 value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeUI32(long value) throws IOException {
|
||||
write((int) (value & 0xff));
|
||||
write((int) ((value >> 8) & 0xff));
|
||||
write((int) ((value >> 16) & 0xff));
|
||||
write((int) ((value >> 24) & 0xff));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes UI16 (Unsigned 16bit integer) value to the stream
|
||||
*
|
||||
* @param value UI16 value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeUI16(int value) throws IOException {
|
||||
write((int) (value & 0xff));
|
||||
write((int) ((value >> 8) & 0xff));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes SI32 (Signed 32bit integer) value to the stream
|
||||
*
|
||||
* @param value SI32 value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeSI32(long value) throws IOException {
|
||||
writeUI32(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes SI16 (Signed 16bit integer) value to the stream
|
||||
*
|
||||
* @param value SI16 value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeSI16(int value) throws IOException {
|
||||
writeUI16(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes SI8 (Signed 8bit integer) value to the stream
|
||||
*
|
||||
* @param value SI8 value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeSI8(int value) throws IOException {
|
||||
writeUI8(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes FIXED (Fixed point 16.16) value to the stream
|
||||
*
|
||||
* @param value FIXED value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeFIXED(double value) throws IOException {
|
||||
long valueLong = (long) (value * (1 << 16));
|
||||
int beforePoint = (int) valueLong >> 16;
|
||||
|
||||
int afterPoint = (int) valueLong % (1 << 16);
|
||||
writeUI16(afterPoint);
|
||||
writeUI16(beforePoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes FIXED8 (Fixed point 8.8) value to the stream
|
||||
*
|
||||
* @param value FIXED8 value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeFIXED8(float value) throws IOException {
|
||||
int beforePoint = (int) getIntPart(value);
|
||||
int afterPoint = (int) getIntPart((value + (value < 0 ? beforePoint : -beforePoint)) * 256);
|
||||
writeUI8(afterPoint);
|
||||
writeUI8(beforePoint);
|
||||
}
|
||||
|
||||
private void writeLong(long value) throws IOException {
|
||||
byte writeBuffer[] = new byte[8];
|
||||
writeBuffer[3] = (byte) (value >>> 56);
|
||||
writeBuffer[2] = (byte) (value >>> 48);
|
||||
writeBuffer[1] = (byte) (value >>> 40);
|
||||
writeBuffer[0] = (byte) (value >>> 32);
|
||||
writeBuffer[7] = (byte) (value >>> 24);
|
||||
writeBuffer[6] = (byte) (value >>> 16);
|
||||
writeBuffer[5] = (byte) (value >>> 8);
|
||||
writeBuffer[4] = (byte) (value >>> 0);
|
||||
write(writeBuffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes DOUBLE (double precision floating point value) value to the stream
|
||||
*
|
||||
* @param value DOUBLE value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeDOUBLE(double value) throws IOException {
|
||||
writeLong(Double.doubleToLongBits(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes FLOAT (single precision floating point value) value to the stream
|
||||
*
|
||||
* @param value FLOAT value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeFLOAT(float value) throws IOException {
|
||||
writeUI32(Float.floatToIntBits(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes FLOAT16 (16bit floating point value) value to the stream
|
||||
*
|
||||
* @param value FLOAT16 value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeFLOAT16(float value) throws IOException {
|
||||
int bits = Float.floatToRawIntBits(value);
|
||||
int sign = bits >> 31;
|
||||
int exponent = (bits >> 22) & 0xff;
|
||||
int mantisa = bits & 0x3FFFFF;
|
||||
mantisa = mantisa >> 13;
|
||||
writeUI16((sign << 15) + (exponent << 10) + mantisa);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes EncodedU32 (Encoded unsigned 32bit value) value to the stream
|
||||
*
|
||||
* @param value U32 value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeEncodedU32(long value) throws IOException {
|
||||
boolean loop = true;
|
||||
value = value & 0xFFFFFFFF;
|
||||
do {
|
||||
int ret = (int) (value & 0x7F);
|
||||
if (value < 0x80) {
|
||||
loop = false;
|
||||
}
|
||||
if (value > 0x7F) {
|
||||
ret += 0x80;
|
||||
}
|
||||
write(ret);
|
||||
value = value >> 7;
|
||||
} while (loop);
|
||||
}
|
||||
|
||||
private int bitPos = 0;
|
||||
private int tempByte = 0;
|
||||
|
||||
/**
|
||||
* Flushes data to underlying stream
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
if (bitPos > 0) {
|
||||
bitPos = 0;
|
||||
write(tempByte);
|
||||
tempByte = 0;
|
||||
}
|
||||
os.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the stream
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
flush();
|
||||
os.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes UB[nBits] (Unsigned-bit value) value to the stream
|
||||
*
|
||||
* @param nBits Number of bits which represent value
|
||||
* @param value Unsigned value to write
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeUB(int nBits, long value) throws IOException {
|
||||
for (int bit = 0; bit < nBits; bit++) {
|
||||
int nb = (int) ((value >> (nBits - 1 - bit)) & 1);
|
||||
tempByte += nb * (1 << (7 - bitPos));
|
||||
bitPos++;
|
||||
if (bitPos == 8) {
|
||||
bitPos = 0;
|
||||
write(tempByte);
|
||||
tempByte = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes SB[nBits] (Signed-bit value) value to the stream
|
||||
*
|
||||
* @param nBits Number of bits which represent value
|
||||
* @param value Signed value to write
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeSB(int nBits, long value) throws IOException {
|
||||
writeUB(nBits, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes FB[nBits] (Signed fixed-point bit value) value to the stream
|
||||
*
|
||||
* @param nBits Number of bits which represent value
|
||||
* @param value Double value to write
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeFB(int nBits, double value) throws IOException {
|
||||
long longVal = (long) (value * (1 << 16));
|
||||
writeSB(nBits, longVal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes RECT value to the stream
|
||||
*
|
||||
* @param value RECT value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeRECT(RECT value) throws IOException {
|
||||
int nBits = 0;
|
||||
nBits = enlargeBitCountS(nBits, value.Xmin);
|
||||
nBits = enlargeBitCountS(nBits, value.Xmax);
|
||||
nBits = enlargeBitCountS(nBits, value.Ymin);
|
||||
nBits = enlargeBitCountS(nBits, value.Ymax);
|
||||
|
||||
writeUB(5, nBits);
|
||||
writeSB(nBits, value.Xmin);
|
||||
writeSB(nBits, value.Xmax);
|
||||
writeSB(nBits, value.Ymin);
|
||||
writeSB(nBits, value.Ymax);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes list of Tag values to the stream
|
||||
*
|
||||
* @param tags List of tag values
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeTags(List<Tag> tags) throws IOException {
|
||||
for (Tag tag : tags) {
|
||||
writeTag(tag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes Tag value to the stream
|
||||
*
|
||||
* @param tag Tag value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeTag(Tag tag) throws IOException {
|
||||
byte data[] = tag.getData(version);
|
||||
int tagLength = data.length;
|
||||
int tagID = tag.getId();
|
||||
int tagIDLength = (tagID << 6);
|
||||
if ((tagLength < 0x3f) && (!tag.forceWriteAsLong)) {
|
||||
tagIDLength += tagLength;
|
||||
writeUI16(tagIDLength);
|
||||
} else {
|
||||
tagIDLength += 0x3f;
|
||||
writeUI16(tagIDLength);
|
||||
writeSI32(tagLength);
|
||||
}
|
||||
write(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates number of bits needed for representing unsigned value
|
||||
*
|
||||
* @param v Unsigned value
|
||||
* @return Number of bits
|
||||
*/
|
||||
public static int getNeededBitsU(long v) {
|
||||
|
||||
int n = 32;
|
||||
long m = 0x80000000;
|
||||
if (v == 0x00000000) n = 0;
|
||||
else
|
||||
while (!((v & m) > 0)) {
|
||||
n--;
|
||||
m >>= 1;
|
||||
}
|
||||
return n;
|
||||
/*if (value == 0) {
|
||||
return 1;
|
||||
}
|
||||
return Long.toBinaryString(value).length();*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates number of bits needed for representing signed value
|
||||
*
|
||||
* @param v Signed value
|
||||
* @return Number of bits
|
||||
*/
|
||||
public static int getNeededBitsS(long v) {
|
||||
int n = 33;
|
||||
long m = 0x80000000;
|
||||
if ((v & m) == m) {
|
||||
if (v == 0xffffffff) n = 1;
|
||||
else
|
||||
while ((v & m) == m) {
|
||||
n--;
|
||||
m >>= 1;
|
||||
}
|
||||
} else {
|
||||
if (v == 0x00000000) n = 1;
|
||||
else
|
||||
while ((v & m) == 0) {
|
||||
n--;
|
||||
m >>= 1;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
/*if (value == 0) {
|
||||
return 1;
|
||||
}
|
||||
if (value == -1) {
|
||||
return 2;
|
||||
}
|
||||
if (value < 0) {
|
||||
String str = Long.toBinaryString(value);
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
if (str.charAt(i) == '0') {
|
||||
return str.length() - 1 - i + 2;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
return Long.toBinaryString(value).length() + 1;
|
||||
} */
|
||||
}
|
||||
|
||||
|
||||
private static long getIntPart(double value) {
|
||||
if (value < 0) return (long) Math.ceil(value);
|
||||
return (long) Math.floor(value);
|
||||
}
|
||||
|
||||
private static double getFloatPart(double value) {
|
||||
if (value < 0) return value - getIntPart(value);
|
||||
return value + getIntPart(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates number of bits needed for representing fixed-point value
|
||||
*
|
||||
* @param value Fixed-point value
|
||||
* @return Number of bits
|
||||
*/
|
||||
public static int getNeededBitsF(double value) {
|
||||
if (value == -1) return 18;
|
||||
long val = (long) (value * (1 << 16));
|
||||
return getNeededBitsS(val);
|
||||
}
|
||||
|
||||
private int enlargeBitCountU(int currentBitCount, long value) {
|
||||
int neededNew = getNeededBitsU(value);
|
||||
if (neededNew > currentBitCount) return neededNew;
|
||||
return currentBitCount;
|
||||
}
|
||||
|
||||
private int enlargeBitCountS(int currentBitCount, long value) {
|
||||
int neededNew = getNeededBitsS(value);
|
||||
if (neededNew > currentBitCount) return neededNew;
|
||||
return currentBitCount;
|
||||
}
|
||||
|
||||
private int enlargeBitCountF(int currentBitCount, double value) {
|
||||
int neededNew = getNeededBitsF(value);
|
||||
if (neededNew > currentBitCount) return neededNew;
|
||||
return currentBitCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes MATRIX value to the stream
|
||||
*
|
||||
* @param value MATRIX value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeMatrix(MATRIX value) throws IOException {
|
||||
writeUB(1, value.hasScale ? 1 : 0);
|
||||
if (value.hasScale) {
|
||||
int nBits = 0;
|
||||
nBits = enlargeBitCountF(nBits, value.scaleX);
|
||||
nBits = enlargeBitCountF(nBits, value.scaleY);
|
||||
nBits = value.scaleNBits; //FFFUUU
|
||||
writeUB(5, nBits);
|
||||
writeFB(nBits, value.scaleX);
|
||||
writeFB(nBits, value.scaleY);
|
||||
}
|
||||
writeUB(1, value.hasRotate ? 1 : 0);
|
||||
if (value.hasRotate) {
|
||||
int nBits = 0;
|
||||
nBits = enlargeBitCountF(nBits, value.rotateSkew0);
|
||||
nBits = enlargeBitCountF(nBits, value.rotateSkew1);
|
||||
nBits = value.rotateNBits; //FFFUUU
|
||||
writeUB(5, nBits);
|
||||
writeFB(nBits, value.rotateSkew0);
|
||||
writeFB(nBits, value.rotateSkew1);
|
||||
}
|
||||
int NTranslateBits = 0;
|
||||
NTranslateBits = enlargeBitCountS(NTranslateBits, value.translateX);
|
||||
NTranslateBits = enlargeBitCountS(NTranslateBits, value.translateY);
|
||||
NTranslateBits = value.translateNBits; //FFFUUU
|
||||
writeUB(5, NTranslateBits);
|
||||
|
||||
|
||||
writeSB(NTranslateBits, value.translateX);
|
||||
writeSB(NTranslateBits, value.translateY);
|
||||
alignByte();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes CXFORMWITHALPHA value to the stream
|
||||
*
|
||||
* @param value CXFORMWITHALPHA value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeCXFORMWITHALPHA(CXFORMWITHALPHA value) throws IOException {
|
||||
writeUB(1, value.hasAddTerms ? 1 : 0);
|
||||
writeUB(1, value.hasMultTerms ? 1 : 0);
|
||||
int Nbits = 1;
|
||||
if (value.hasMultTerms) {
|
||||
Nbits = enlargeBitCountS(Nbits, value.redMultTerm);
|
||||
Nbits = enlargeBitCountS(Nbits, value.greenMultTerm);
|
||||
Nbits = enlargeBitCountS(Nbits, value.blueMultTerm);
|
||||
Nbits = enlargeBitCountS(Nbits, value.alphaMultTerm);
|
||||
}
|
||||
if (value.hasAddTerms) {
|
||||
Nbits = enlargeBitCountS(Nbits, value.redAddTerm);
|
||||
Nbits = enlargeBitCountS(Nbits, value.greenAddTerm);
|
||||
Nbits = enlargeBitCountS(Nbits, value.blueAddTerm);
|
||||
Nbits = enlargeBitCountS(Nbits, value.alphaAddTerm);
|
||||
}
|
||||
writeUB(4, Nbits);
|
||||
if (value.hasMultTerms) {
|
||||
writeSB(Nbits, value.redMultTerm);
|
||||
writeSB(Nbits, value.greenMultTerm);
|
||||
writeSB(Nbits, value.blueMultTerm);
|
||||
writeSB(Nbits, value.alphaMultTerm);
|
||||
}
|
||||
if (value.hasAddTerms) {
|
||||
writeSB(Nbits, value.redAddTerm);
|
||||
writeSB(Nbits, value.greenAddTerm);
|
||||
writeSB(Nbits, value.blueAddTerm);
|
||||
writeSB(Nbits, value.alphaAddTerm);
|
||||
}
|
||||
alignByte();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes CLIPEVENTFLAGS value to the stream
|
||||
*
|
||||
* @param value CLIPEVENTFLAGS value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeCLIPEVENTFLAGS(CLIPEVENTFLAGS value) throws IOException {
|
||||
writeUB(1, value.clipEventKeyUp ? 1 : 0);
|
||||
writeUB(1, value.clipEventKeyDown ? 1 : 0);
|
||||
writeUB(1, value.clipEventMouseUp ? 1 : 0);
|
||||
writeUB(1, value.clipEventMouseDown ? 1 : 0);
|
||||
writeUB(1, value.clipEventMouseMove ? 1 : 0);
|
||||
writeUB(1, value.clipEventUnload ? 1 : 0);
|
||||
writeUB(1, value.clipEventEnterFrame ? 1 : 0);
|
||||
writeUB(1, value.clipEventLoad ? 1 : 0);
|
||||
writeUB(1, value.clipEventDragOver ? 1 : 0);
|
||||
writeUB(1, value.clipEventRollOut ? 1 : 0);
|
||||
writeUB(1, value.clipEventRollOver ? 1 : 0);
|
||||
writeUB(1, value.clipEventReleaseOutside ? 1 : 0);
|
||||
writeUB(1, value.clipEventRelease ? 1 : 0);
|
||||
writeUB(1, value.clipEventPress ? 1 : 0);
|
||||
writeUB(1, value.clipEventInitialize ? 1 : 0);
|
||||
writeUB(1, value.clipEventData ? 1 : 0);
|
||||
if (version >= 6) {
|
||||
writeUB(5, 0);
|
||||
writeUB(1, value.clipEventConstruct ? 1 : 0);
|
||||
writeUB(1, value.clipEventKeyPress ? 1 : 0);
|
||||
writeUB(1, value.clipEventDragOut ? 1 : 0);
|
||||
writeUB(8, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes CLIPACTIONRECORD value to the stream
|
||||
*
|
||||
* @param value CLIPACTIONRECORD value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeCLIPACTIONRECORD(CLIPACTIONRECORD value) throws IOException {
|
||||
writeCLIPEVENTFLAGS(value.eventFlags);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, version);
|
||||
|
||||
if (value.eventFlags.clipEventKeyPress) {
|
||||
sos.writeUI8(value.keyCode);
|
||||
}
|
||||
sos.write(Action.actionsToBytes(value.actions, true, version));
|
||||
sos.close();
|
||||
byte data[] = baos.toByteArray();
|
||||
writeUI32(data.length); //actionRecordSize
|
||||
write(data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Writes CLIPACTIONS value to the stream
|
||||
*
|
||||
* @param value CLIPACTIONS value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeCLIPACTIONS(CLIPACTIONS value) throws IOException {
|
||||
writeUI16(0);//reserved
|
||||
writeCLIPEVENTFLAGS(value.allEventFlags);
|
||||
for (CLIPACTIONRECORD car : value.clipActionRecords) {
|
||||
writeCLIPACTIONRECORD(car);
|
||||
}
|
||||
if (version <= 5) {
|
||||
writeUI16(0);
|
||||
} else {
|
||||
writeUI32(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes COLORMATRIXFILTER value to the stream
|
||||
*
|
||||
* @param value COLORMATRIXFILTER value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeCOLORMATRIXFILTER(COLORMATRIXFILTER value) throws IOException {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
writeFLOAT(value.matrix[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes RGBA value to the stream
|
||||
*
|
||||
* @param value RGBA value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeRGBA(RGBA value) throws IOException {
|
||||
writeUI8(value.red);
|
||||
writeUI8(value.green);
|
||||
writeUI8(value.blue);
|
||||
writeUI8(value.alpha);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes CONVOLUTIONFILTER value to the stream
|
||||
*
|
||||
* @param value CONVOLUTIONFILTER value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeCONVOLUTIONFILTER(CONVOLUTIONFILTER value) throws IOException {
|
||||
writeUI8(value.matrixX);
|
||||
writeUI8(value.matrixY);
|
||||
writeFLOAT(value.divisor);
|
||||
writeFLOAT(value.bias);
|
||||
for (int x = 0; x < value.matrixX; x++) {
|
||||
for (int y = 0; y < value.matrixY; y++) {
|
||||
writeFLOAT(value.matrix[x][y]);
|
||||
}
|
||||
}
|
||||
writeRGBA(value.defaultColor);
|
||||
writeUB(6, 0); //reserved
|
||||
writeUB(1, value.clamp ? 1 : 0);
|
||||
writeUB(1, value.preserveAlpha ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes BLURFILTER value to the stream
|
||||
*
|
||||
* @param value BLURFILTER value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeBLURFILTER(BLURFILTER value) throws IOException {
|
||||
writeFIXED(value.blurX);
|
||||
writeFIXED(value.blurY);
|
||||
writeUB(5, value.passes);
|
||||
writeUB(3, 0);//reserved
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes DROPSHADOWFILTER value to the stream
|
||||
*
|
||||
* @param value DROPSHADOWFILTER value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeDROPSHADOWFILTER(DROPSHADOWFILTER value) throws IOException {
|
||||
writeRGBA(value.dropShadowColor);
|
||||
writeFIXED(value.blurX);
|
||||
writeFIXED(value.blurY);
|
||||
writeFIXED(value.angle);
|
||||
writeFIXED(value.distance);
|
||||
writeFIXED8(value.strength);
|
||||
writeUB(1, value.innerShadow ? 1 : 0);
|
||||
writeUB(1, value.knockout ? 1 : 0);
|
||||
writeUB(1, value.compositeSource ? 1 : 0);
|
||||
writeUB(5, value.passes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes GLOWFILTER value to the stream
|
||||
*
|
||||
* @param value GLOWFILTER value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeGLOWFILTER(GLOWFILTER value) throws IOException {
|
||||
writeRGBA(value.glowColor);
|
||||
writeFIXED(value.blurX);
|
||||
writeFIXED(value.blurY);
|
||||
writeFIXED8(value.strength);
|
||||
writeUB(1, value.innerGlow ? 1 : 0);
|
||||
writeUB(1, value.knockout ? 1 : 0);
|
||||
writeUB(1, value.compositeSource ? 1 : 0);
|
||||
writeUB(5, value.passes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes BEVELFILTER value to the stream
|
||||
*
|
||||
* @param value BEVELFILTER value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeBEVELFILTER(BEVELFILTER value) throws IOException {
|
||||
writeRGBA(value.shadowColor);
|
||||
writeRGBA(value.highlightColor);
|
||||
writeFIXED(value.blurX);
|
||||
writeFIXED(value.blurY);
|
||||
writeFIXED(value.angle);
|
||||
writeFIXED(value.distance);
|
||||
writeFIXED8(value.strength);
|
||||
writeUB(1, value.innerShadow ? 1 : 0);
|
||||
writeUB(1, value.knockout ? 1 : 0);
|
||||
writeUB(1, value.compositeSource ? 1 : 0);
|
||||
writeUB(1, value.onTop ? 1 : 0);
|
||||
writeUB(4, value.passes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes GRADIENTGLOWFILTER value to the stream
|
||||
*
|
||||
* @param value GRADIENTGLOWFILTER value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeGRADIENTGLOWFILTER(GRADIENTGLOWFILTER value) throws IOException {
|
||||
writeUI8(value.gradientColors.length);
|
||||
for (int i = 0; i < value.gradientColors.length; i++) {
|
||||
writeRGBA(value.gradientColors[i]);
|
||||
}
|
||||
for (int i = 0; i < value.gradientColors.length; i++) {
|
||||
writeUI8(value.gradientRatio[i]);
|
||||
}
|
||||
writeFIXED(value.blurX);
|
||||
writeFIXED(value.blurY);
|
||||
writeFIXED(value.angle);
|
||||
writeFIXED(value.distance);
|
||||
writeFIXED8(value.strength);
|
||||
writeUB(1, value.innerShadow ? 1 : 0);
|
||||
writeUB(1, value.knockout ? 1 : 0);
|
||||
writeUB(1, value.compositeSource ? 1 : 0);
|
||||
writeUB(1, value.onTop ? 1 : 0);
|
||||
writeUB(4, value.passes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes GRADIENTBEVELFILTER value to the stream
|
||||
*
|
||||
* @param value GRADIENTBEVELFILTER value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeGRADIENTBEVELFILTER(GRADIENTBEVELFILTER value) throws IOException {
|
||||
writeUI8(value.gradientColors.length);
|
||||
for (int i = 0; i < value.gradientColors.length; i++) {
|
||||
writeRGBA(value.gradientColors[i]);
|
||||
}
|
||||
for (int i = 0; i < value.gradientColors.length; i++) {
|
||||
writeUI8(value.gradientRatio[i]);
|
||||
}
|
||||
writeFIXED(value.blurX);
|
||||
writeFIXED(value.blurY);
|
||||
writeFIXED(value.angle);
|
||||
writeFIXED(value.distance);
|
||||
writeFIXED8(value.strength);
|
||||
writeUB(1, value.innerShadow ? 1 : 0);
|
||||
writeUB(1, value.knockout ? 1 : 0);
|
||||
writeUB(1, value.compositeSource ? 1 : 0);
|
||||
writeUB(1, value.onTop ? 1 : 0);
|
||||
writeUB(4, value.passes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes list of FILTER values to the stream
|
||||
*
|
||||
* @param list List of FILTER values
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeFILTERLIST(List<FILTER> list) throws IOException {
|
||||
writeUI8(list.size());
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
writeFILTER(list.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes FILTER value to the stream
|
||||
*
|
||||
* @param value FILTER value
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeFILTER(FILTER value) throws IOException {
|
||||
writeUI8(value.id);
|
||||
switch (value.id) {
|
||||
case 0:
|
||||
writeDROPSHADOWFILTER((DROPSHADOWFILTER) value);
|
||||
break;
|
||||
case 1:
|
||||
writeBLURFILTER((BLURFILTER) value);
|
||||
break;
|
||||
case 2:
|
||||
writeGLOWFILTER((GLOWFILTER) value);
|
||||
break;
|
||||
case 3:
|
||||
writeBEVELFILTER((BEVELFILTER) value);
|
||||
break;
|
||||
case 4:
|
||||
writeGRADIENTGLOWFILTER((GRADIENTGLOWFILTER) value);
|
||||
break;
|
||||
case 5:
|
||||
writeCONVOLUTIONFILTER((CONVOLUTIONFILTER) value);
|
||||
break;
|
||||
case 6:
|
||||
writeCOLORMATRIXFILTER((COLORMATRIXFILTER) value);
|
||||
break;
|
||||
case 7:
|
||||
writeGRADIENTBEVELFILTER((GRADIENTBEVELFILTER) value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes list of BUTTONRECORD values to the stream
|
||||
*
|
||||
* @param list List of BUTTONRECORD values
|
||||
* @param inDefineButton2 Whether write inside of DefineButton2Tag or not
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeBUTTONRECORDList(List<BUTTONRECORD> list, boolean inDefineButton2) throws IOException {
|
||||
for (BUTTONRECORD brec : list) {
|
||||
writeBUTTONRECORD(brec, inDefineButton2);
|
||||
}
|
||||
writeUI8(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes BUTTONRECORD value to the stream
|
||||
*
|
||||
* @param value BUTTONRECORD value
|
||||
* @param inDefineButton2 Whether write inside of DefineButton2Tag or not
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeBUTTONRECORD(BUTTONRECORD value, boolean inDefineButton2) throws IOException {
|
||||
writeUB(2, 0);//reserved
|
||||
writeUB(1, value.buttonHasBlendMode ? 1 : 0);
|
||||
writeUB(1, value.buttonHasFilterList ? 1 : 0);
|
||||
writeUB(1, value.buttonStateHitTest ? 1 : 0);
|
||||
writeUB(1, value.buttonStateDown ? 1 : 0);
|
||||
writeUB(1, value.buttonStateOver ? 1 : 0);
|
||||
writeUB(1, value.buttonStateUp ? 1 : 0);
|
||||
writeUI16(value.characterId);
|
||||
writeUI16(value.placeDepth);
|
||||
writeMatrix(value.placeMatrix);
|
||||
if (inDefineButton2) {
|
||||
writeCXFORMWITHALPHA(value.colorTransform);
|
||||
if (value.buttonHasFilterList) {
|
||||
writeFILTERLIST(value.filterList);
|
||||
}
|
||||
if (value.buttonHasBlendMode) {
|
||||
writeUI8(value.blendMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes list of BUTTONCONDACTION values to the stream
|
||||
*
|
||||
* @param list List of BUTTONCONDACTION values
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeBUTTONCONDACTIONList(List<BUTTONCONDACTION> list) throws IOException {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
writeBUTTONCONDACTION(list.get(i), i == list.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes BUTTONCONDACTION value to the stream
|
||||
*
|
||||
* @param value BUTTONCONDACTION value
|
||||
* @param isLast True if it is last on the list
|
||||
* @throws IOException
|
||||
*/
|
||||
public void writeBUTTONCONDACTION(BUTTONCONDACTION value, boolean isLast) throws IOException {
|
||||
BUTTONCONDACTION ret = new BUTTONCONDACTION();
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWFOutputStream sos = new SWFOutputStream(baos, version);
|
||||
sos.writeUB(1, value.condIdleToOverDown ? 1 : 0);
|
||||
sos.writeUB(1, value.condOutDownToIdle ? 1 : 0);
|
||||
sos.writeUB(1, value.condOutDownToOverDown ? 1 : 0);
|
||||
sos.writeUB(1, value.condOverDownToOutDown ? 1 : 0);
|
||||
sos.writeUB(1, value.condOverDownToOverUp ? 1 : 0);
|
||||
sos.writeUB(1, value.condOverUpToOverDown ? 1 : 0);
|
||||
sos.writeUB(1, value.condOverUpToIddle ? 1 : 0);
|
||||
sos.writeUB(1, value.condIdleToOverUp ? 1 : 0);
|
||||
sos.writeUB(7, value.condKeyPress);
|
||||
sos.writeUB(1, value.condOverDownToIddle ? 1 : 0);
|
||||
sos.write(Action.actionsToBytes(value.actions, true, version));
|
||||
sos.close();
|
||||
byte data[] = baos.toByteArray();
|
||||
if (isLast) {
|
||||
writeUI16(0);
|
||||
} else {
|
||||
writeUI16(data.length + 2);
|
||||
}
|
||||
write(data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,728 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc;
|
||||
|
||||
import com.jpexs.asdec.Main;
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.UnknownInstructionCode;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
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.*;
|
||||
import com.jpexs.asdec.abc.types.traits.Trait;
|
||||
import com.jpexs.asdec.abc.types.traits.TraitMethodGetterSetter;
|
||||
import com.jpexs.asdec.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.asdec.helpers.Highlighting;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ABC {
|
||||
|
||||
public int major_version = 0;
|
||||
public int minor_version = 0;
|
||||
public ConstantPool constants;
|
||||
public MethodInfo method_info[];
|
||||
public MetadataInfo metadata_info[];
|
||||
public InstanceInfo instance_info[];
|
||||
public ClassInfo class_info[];
|
||||
public ScriptInfo script_info[];
|
||||
public MethodBody bodies[];
|
||||
public long stringOffsets[];
|
||||
public static String IDENT_STRING = " ";
|
||||
|
||||
public ABC(InputStream is) throws IOException {
|
||||
|
||||
ABCInputStream ais = new ABCInputStream(is);
|
||||
major_version = ais.readU16();
|
||||
minor_version = ais.readU16();
|
||||
constants = new ConstantPool();
|
||||
//constant integers
|
||||
int constant_int_pool_count = ais.readU30();
|
||||
constants.constant_int = new long[constant_int_pool_count];
|
||||
for (int i = 1; i < constant_int_pool_count; i++) { //index 0 not used. Values 1..n-1
|
||||
constants.constant_int[i] = ais.readS32();
|
||||
}
|
||||
|
||||
//constant unsigned integers
|
||||
int constant_uint_pool_count = ais.readU30();
|
||||
constants.constant_uint = new long[constant_uint_pool_count];
|
||||
for (int i = 1; i < constant_uint_pool_count; i++) { //index 0 not used. Values 1..n-1
|
||||
constants.constant_uint[i] = ais.readU32();
|
||||
}
|
||||
|
||||
//constant double
|
||||
int constant_double_pool_count = ais.readU30();
|
||||
constants.constant_double = new double[constant_double_pool_count];
|
||||
for (int i = 1; i < constant_double_pool_count; i++) { //index 0 not used. Values 1..n-1
|
||||
constants.constant_double[i] = ais.readDouble();
|
||||
}
|
||||
|
||||
//constant string
|
||||
int constant_string_pool_count = ais.readU30();
|
||||
constants.constant_string = new String[constant_string_pool_count];
|
||||
stringOffsets = new long[constant_string_pool_count];
|
||||
constants.constant_string[0] = "";
|
||||
for (int i = 1; i < constant_string_pool_count; i++) { //index 0 not used. Values 1..n-1
|
||||
long pos = ais.getPosition();
|
||||
constants.constant_string[i] = ais.readString();
|
||||
stringOffsets[i] = pos;
|
||||
/*
|
||||
INVALID STRINGS
|
||||
|
||||
String invalidStr=",,if,else,finally,while,int,switch,return,case,do,";
|
||||
if(invalidStr.contains(","+constants.constant_string[i]+",")){
|
||||
//constants.constant_string[i]="s"+i+"/"+constants.constant_string[i];
|
||||
}*/
|
||||
}
|
||||
|
||||
//constant namespace
|
||||
int constant_namespace_pool_count = ais.readU30();
|
||||
constants.constant_namespace = new Namespace[constant_namespace_pool_count];
|
||||
for (int i = 1; i < constant_namespace_pool_count; i++) { //index 0 not used. Values 1..n-1
|
||||
constants.constant_namespace[i] = ais.readNamespace();
|
||||
cleanOneName(constants.constant_namespace[i].name_index);
|
||||
}
|
||||
|
||||
//constant namespace set
|
||||
int constant_namespace_set_pool_count = ais.readU30();
|
||||
constants.constant_namespace_set = new NamespaceSet[constant_namespace_set_pool_count];
|
||||
for (int i = 1; i < constant_namespace_set_pool_count; i++) { //index 0 not used. Values 1..n-1
|
||||
constants.constant_namespace_set[i] = new NamespaceSet();
|
||||
int namespace_count = ais.readU30();
|
||||
constants.constant_namespace_set[i].namespaces = new int[namespace_count];
|
||||
for (int j = 0; j < namespace_count; j++) {
|
||||
constants.constant_namespace_set[i].namespaces[j] = ais.readU30();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//constant multiname
|
||||
int constant_multiname_pool_count = ais.readU30();
|
||||
constants.constant_multiname = new Multiname[constant_multiname_pool_count];
|
||||
for (int i = 1; i < constant_multiname_pool_count; i++) { //index 0 not used. Values 1..n-1
|
||||
constants.constant_multiname[i] = ais.readMultiname();
|
||||
cleanNamespace(constants.constant_multiname[i].name_index);
|
||||
}
|
||||
|
||||
|
||||
//method info
|
||||
int methods_count = ais.readU30();
|
||||
method_info = new MethodInfo[methods_count];
|
||||
for (int i = 0; i < methods_count; i++) { //index 0 not used. Values 1..n-1
|
||||
method_info[i] = ais.readMethodInfo();
|
||||
}
|
||||
|
||||
//metadata info
|
||||
int metadata_count = ais.readU30();
|
||||
metadata_info = new MetadataInfo[metadata_count];
|
||||
for (int i = 0; i < metadata_count; i++) { //index 0 not used. Values 1..n-1
|
||||
int name_index = ais.readU30();
|
||||
int values_count = ais.readU30();
|
||||
int keys[] = new int[values_count];
|
||||
for (int v = 0; v < values_count; v++) {
|
||||
keys[v] = ais.readU30();
|
||||
}
|
||||
int values[] = new int[values_count];
|
||||
for (int v = 0; v < values_count; v++) {
|
||||
values[v] = ais.readU30();
|
||||
}
|
||||
metadata_info[i] = new MetadataInfo(name_index, keys, values);
|
||||
}
|
||||
|
||||
int class_count = ais.readU30();
|
||||
instance_info = new InstanceInfo[class_count];
|
||||
for (int i = 0; i < class_count; i++) {
|
||||
instance_info[i] = ais.readInstanceInfo();
|
||||
}
|
||||
class_info = new ClassInfo[class_count];
|
||||
for (int i = 0; i < class_count; i++) {
|
||||
class_info[i] = new ClassInfo();
|
||||
class_info[i].cinit_index = ais.readU30();
|
||||
class_info[i].static_traits = ais.readTraits();
|
||||
}
|
||||
int script_count = ais.readU30();
|
||||
script_info = new ScriptInfo[script_count];
|
||||
for (int i = 0; i < script_count; i++) {
|
||||
script_info[i] = new ScriptInfo();
|
||||
script_info[i].init_index = ais.readU30();
|
||||
script_info[i].traits = ais.readTraits();
|
||||
}
|
||||
|
||||
int bodies_count = ais.readU30();
|
||||
bodies = new MethodBody[bodies_count];
|
||||
for (int i = 0; i < bodies_count; i++) {
|
||||
bodies[i] = new MethodBody();
|
||||
bodies[i].method_info = ais.readU30();
|
||||
bodies[i].max_stack = ais.readU30();
|
||||
bodies[i].max_regs = ais.readU30();
|
||||
bodies[i].scope_depth = ais.readU30();
|
||||
bodies[i].max_scope = ais.readU30();
|
||||
int code_length = ais.readU30();
|
||||
bodies[i].codeBytes = new byte[code_length];
|
||||
for (int j = 0; j < code_length; j++) {
|
||||
bodies[i].codeBytes[j] = (byte) ais.read();
|
||||
}
|
||||
try {
|
||||
bodies[i].code = new AVM2Code(new ByteArrayInputStream(bodies[i].codeBytes));
|
||||
} catch (UnknownInstructionCode re) {
|
||||
bodies[i].code = new AVM2Code();
|
||||
System.err.println(re.toString());
|
||||
}
|
||||
int ex_count = ais.readU30();
|
||||
bodies[i].exceptions = new ABCException[ex_count];
|
||||
for (int j = 0; j < ex_count; j++) {
|
||||
bodies[i].exceptions[j] = new ABCException();
|
||||
bodies[i].exceptions[j].start = ais.readU30();
|
||||
bodies[i].exceptions[j].end = ais.readU30();
|
||||
bodies[i].exceptions[j].target = ais.readU30();
|
||||
bodies[i].exceptions[j].type_index = ais.readU30();
|
||||
bodies[i].exceptions[j].name_index = ais.readU30();
|
||||
}
|
||||
bodies[i].traits = ais.readTraits();
|
||||
/*try {
|
||||
bodies[i].code.clearCode(constants, bodies[i]);
|
||||
} catch (ConvertException ignored) {
|
||||
} */
|
||||
}
|
||||
}
|
||||
|
||||
public void saveToStream(OutputStream os) throws IOException {
|
||||
ABCOutputStream aos = new ABCOutputStream(os);
|
||||
aos.writeU16(major_version);
|
||||
aos.writeU16(minor_version);
|
||||
|
||||
aos.writeU30(constants.constant_int.length);
|
||||
for (int i = 1; i < constants.constant_int.length; i++) {
|
||||
try {
|
||||
aos.writeS32(constants.constant_int[i]);
|
||||
} catch (NotSameException nex) {
|
||||
System.out.println("written:" + constants.constant_int[i]);
|
||||
throw nex;
|
||||
}
|
||||
}
|
||||
aos.writeU30(constants.constant_uint.length);
|
||||
for (int i = 1; i < constants.constant_uint.length; i++) {
|
||||
aos.writeU32(constants.constant_uint[i]);
|
||||
}
|
||||
|
||||
aos.writeU30(constants.constant_double.length);
|
||||
for (int i = 1; i < constants.constant_double.length; i++) {
|
||||
aos.writeDouble(constants.constant_double[i]);
|
||||
}
|
||||
|
||||
aos.writeU30(constants.constant_string.length);
|
||||
for (int i = 1; i < constants.constant_string.length; i++) {
|
||||
aos.writeString(constants.constant_string[i]);
|
||||
}
|
||||
|
||||
aos.writeU30(constants.constant_namespace.length);
|
||||
for (int i = 1; i < constants.constant_namespace.length; i++) {
|
||||
aos.writeNamespace(constants.constant_namespace[i]);
|
||||
}
|
||||
|
||||
aos.writeU30(constants.constant_namespace_set.length);
|
||||
for (int i = 1; i < constants.constant_namespace_set.length; i++) {
|
||||
aos.writeU30(constants.constant_namespace_set[i].namespaces.length);
|
||||
for (int j = 0; j < constants.constant_namespace_set[i].namespaces.length; j++) {
|
||||
aos.writeU30(constants.constant_namespace_set[i].namespaces[j]);
|
||||
}
|
||||
}
|
||||
|
||||
aos.writeU30(constants.constant_multiname.length);
|
||||
for (int i = 1; i < constants.constant_multiname.length; i++) {
|
||||
aos.writeMultiname(constants.constant_multiname[i]);
|
||||
}
|
||||
|
||||
aos.writeU30(method_info.length);
|
||||
for (int i = 0; i < method_info.length; i++) {
|
||||
aos.writeMethodInfo(method_info[i]);
|
||||
}
|
||||
|
||||
aos.writeU30(metadata_info.length);
|
||||
for (int i = 0; i < metadata_info.length; i++) {
|
||||
aos.writeU30(metadata_info[i].name_index);
|
||||
aos.writeU30(metadata_info[i].values.length);
|
||||
for (int j = 0; j < metadata_info[i].values.length; j++) {
|
||||
aos.writeU30(metadata_info[i].keys[j]);
|
||||
}
|
||||
for (int j = 0; j < metadata_info[i].values.length; j++) {
|
||||
aos.writeU30(metadata_info[i].values[j]);
|
||||
}
|
||||
}
|
||||
|
||||
aos.writeU30(class_info.length);
|
||||
for (int i = 0; i < instance_info.length; i++) {
|
||||
aos.writeInstanceInfo(instance_info[i]);
|
||||
}
|
||||
for (int i = 0; i < class_info.length; i++) {
|
||||
aos.writeU30(class_info[i].cinit_index);
|
||||
aos.writeTraits(class_info[i].static_traits);
|
||||
}
|
||||
aos.writeU30(script_info.length);
|
||||
for (int i = 0; i < script_info.length; i++) {
|
||||
aos.writeU30(script_info[i].init_index);
|
||||
aos.writeTraits(script_info[i].traits);
|
||||
}
|
||||
|
||||
aos.writeU30(bodies.length);
|
||||
for (int i = 0; i < bodies.length; i++) {
|
||||
aos.writeU30(bodies[i].method_info);
|
||||
aos.writeU30(bodies[i].max_stack);
|
||||
aos.writeU30(bodies[i].max_regs);
|
||||
aos.writeU30(bodies[i].scope_depth);
|
||||
aos.writeU30(bodies[i].max_scope);
|
||||
byte codeBytes[] = bodies[i].code.getBytes();
|
||||
aos.writeU30(codeBytes.length);
|
||||
try {
|
||||
aos.write(codeBytes);
|
||||
} catch (NotSameException ex) {
|
||||
System.out.println(bodies[i].code.toString(constants));
|
||||
System.exit(0);
|
||||
return;
|
||||
}
|
||||
aos.writeU30(bodies[i].exceptions.length);
|
||||
for (int j = 0; j < bodies[i].exceptions.length; j++) {
|
||||
aos.writeU30(bodies[i].exceptions[j].start);
|
||||
aos.writeU30(bodies[i].exceptions[j].end);
|
||||
aos.writeU30(bodies[i].exceptions[j].target);
|
||||
aos.writeU30(bodies[i].exceptions[j].type_index);
|
||||
aos.writeU30(bodies[i].exceptions[j].name_index);
|
||||
}
|
||||
aos.writeTraits(bodies[i].traits);
|
||||
}
|
||||
}
|
||||
|
||||
private void parseImportFromMultiname(List imports, Multiname m) {
|
||||
if (m != null) {
|
||||
Namespace ns = m.getNamespace(constants);
|
||||
String name = m.getName(constants);
|
||||
if (ns != null) {
|
||||
String newimport = ns.getName(constants);
|
||||
if (!newimport.equals("")) {
|
||||
newimport += "." + name;
|
||||
if (newimport.contains(":")) {
|
||||
return;
|
||||
}
|
||||
if (!imports.contains(newimport)) {
|
||||
imports.add(newimport);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List getImports(int instanceIndex) {
|
||||
List<String> imports = new ArrayList<String>();
|
||||
|
||||
//constructor
|
||||
|
||||
//parseImportFromMultiname(imports, constants.constant_multiname[instance_info[instanceIndex].name_index]);
|
||||
|
||||
if (instance_info[instanceIndex].super_index > 0) {
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[instance_info[instanceIndex].super_index]);
|
||||
}
|
||||
for (int i : instance_info[instanceIndex].interfaces) {
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[i]);
|
||||
}
|
||||
//static
|
||||
for (Trait t : class_info[instanceIndex].static_traits.traits) {
|
||||
//parseImportFromMultiname(imports, t.getMultiName(constants));
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t;
|
||||
if (tm.method_info != 0) {
|
||||
MethodBody body = findBody(tm.method_info);
|
||||
if (body != null) {
|
||||
for (AVM2Instruction ins : body.code.code) {
|
||||
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(imports, constants.constant_multiname[multinameIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int p = 0; p < method_info[tm.method_info].param_types.length; p++) {
|
||||
if (method_info[tm.method_info].param_types[p] != 0) {
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[method_info[tm.method_info].param_types[p]]);
|
||||
}
|
||||
if (method_info[tm.method_info].ret_type != 0) {
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[method_info[tm.method_info].ret_type]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//instance
|
||||
for (Trait t : instance_info[instanceIndex].instance_traits.traits) {
|
||||
//parseImportFromMultiname(imports, t.getMultiName(constants));
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t;
|
||||
if (tm.method_info != 0) {
|
||||
MethodBody body = findBody(tm.method_info);
|
||||
if (body != null) {
|
||||
for (AVM2Instruction ins : body.code.code) {
|
||||
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(imports, constants.constant_multiname[multinameIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int p = 0; p < method_info[tm.method_info].param_types.length; p++) {
|
||||
if (method_info[tm.method_info].param_types[p] != 0) {
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[method_info[tm.method_info].param_types[p]]);
|
||||
}
|
||||
if (method_info[tm.method_info].ret_type != 0) {
|
||||
parseImportFromMultiname(imports, constants.constant_multiname[method_info[tm.method_info].ret_type]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return imports;
|
||||
}
|
||||
|
||||
public MethodBody findBody(int methodInfo) {
|
||||
int pos = findBodyIndex(methodInfo);
|
||||
if (pos == -1) {
|
||||
return null;
|
||||
} else {
|
||||
return bodies[pos];
|
||||
}
|
||||
}
|
||||
|
||||
public int findBodyIndex(int methodInfo) {
|
||||
if (methodInfo == -1) {
|
||||
return -1;
|
||||
}
|
||||
for (int b = 0; b < bodies.length; b++) {
|
||||
if (bodies[b].method_info == methodInfo) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public MethodBody findBodyByClassAndName(String className, String methodName) {
|
||||
for (int i = 0; i < instance_info.length; i++) {
|
||||
if (className.equals(constants.constant_multiname[instance_info[i].name_index].getName(constants))) {
|
||||
for (Trait t : instance_info[i].instance_traits.traits) {
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t;
|
||||
if (methodName.equals(t2.getMethodName(constants))) {
|
||||
for (MethodBody body : bodies) {
|
||||
if (body.method_info == t2.method_info) {
|
||||
return body;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < class_info.length; i++) {
|
||||
if (className.equals(constants.constant_multiname[instance_info[i].name_index].getName(constants))) {
|
||||
for (Trait t : class_info[i].static_traits.traits) {
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t;
|
||||
if (methodName.equals(t2.getMethodName(constants))) {
|
||||
for (MethodBody body : bodies) {
|
||||
if (body.method_info == t2.method_info) {
|
||||
return body;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private String addTabs(String s, int tabs) {
|
||||
String parts[] = s.split("\r\n");
|
||||
String ret = "";
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
for (int t = 0; t < tabs; t++) {
|
||||
ret += IDENT_STRING;
|
||||
}
|
||||
ret += parts[i];
|
||||
if (i < parts.length - 1) {
|
||||
ret += "\r\n";
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int findMethodIdByTraitId(int classIndex, int traitId) {
|
||||
if (traitId < class_info[classIndex].static_traits.traits.length) {
|
||||
if (class_info[classIndex].static_traits.traits[traitId] instanceof TraitMethodGetterSetter) {
|
||||
return ((TraitMethodGetterSetter) class_info[classIndex].static_traits.traits[traitId]).method_info;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} else if (traitId < class_info[classIndex].static_traits.traits.length + instance_info[classIndex].instance_traits.traits.length) {
|
||||
traitId -= class_info[classIndex].static_traits.traits.length;
|
||||
if (instance_info[classIndex].instance_traits.traits[traitId] instanceof TraitMethodGetterSetter) {
|
||||
return ((TraitMethodGetterSetter) instance_info[classIndex].instance_traits.traits[traitId]).method_info;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
traitId -= class_info[classIndex].static_traits.traits.length + instance_info[classIndex].instance_traits.traits.length;
|
||||
if (traitId == 0) {
|
||||
return instance_info[classIndex].iinit_index;
|
||||
} else if (traitId == 1) {
|
||||
return class_info[classIndex].cinit_index;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String classToString(int i, boolean highlight) {
|
||||
String ret = "";
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
PrintStream out = new PrintStream(baos);
|
||||
String packageName = instance_info[i].getName(constants).getNamespace(constants).getName(constants);
|
||||
out.println("package " + packageName);
|
||||
out.println("{");
|
||||
|
||||
//imports
|
||||
List<String> imports = getImports(i);
|
||||
for (String imp : imports) {
|
||||
out.println(IDENT_STRING + "import " + imp + ";");
|
||||
}
|
||||
out.println();
|
||||
|
||||
//class header
|
||||
String classHeader = instance_info[i].getClassHeaderStr(constants);
|
||||
if (classHeader.startsWith("private "))
|
||||
classHeader = "public " + classHeader.substring("private ".length());
|
||||
out.println(IDENT_STRING + classHeader);
|
||||
out.println(IDENT_STRING + "{");
|
||||
|
||||
|
||||
if (class_info[i].cinit_index != 0) {
|
||||
int bodyIndex = findBodyIndex(class_info[i].cinit_index);
|
||||
List<TreeItem> initializer = bodies[bodyIndex].code.toTree(true, i, this, constants, method_info, bodies[bodyIndex]);
|
||||
for (TreeItem ti : initializer) {
|
||||
if (ti instanceof SetPropertyTreeItem) {
|
||||
int multinameIndex = ((SetPropertyTreeItem) ti).propertyName.multinameIndex;
|
||||
TreeItem value = ((SetPropertyTreeItem) ti).value;
|
||||
for (Trait t : class_info[i].static_traits.traits) {
|
||||
if (t.name_index == multinameIndex) {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
((TraitSlotConst) t).assignedValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ti instanceof InitPropertyTreeItem) {
|
||||
int multinameIndex = ((InitPropertyTreeItem) ti).propertyName.multinameIndex;
|
||||
TreeItem value = ((InitPropertyTreeItem) ti).value;
|
||||
for (Trait t : class_info[i].static_traits.traits) {
|
||||
if (t.name_index == multinameIndex) {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
((TraitSlotConst) t).assignedValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*String bodyStr = "";
|
||||
int bodyIndex = findBodyIndex(class_info[i].cinit_index);
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = addTabs(bodies[bodyIndex].toString(this, constants, method_info, hilight), 3);
|
||||
}
|
||||
if (!bodyStr.equals("")) {
|
||||
String toPrint = IDENT_STRING + IDENT_STRING + "static {\r\n" + bodyStr + "\r\n" + IDENT_STRING + IDENT_STRING + "}";
|
||||
if (hilight) {
|
||||
toPrint = Highlighting.hilighTrait(toPrint, class_info[i].static_traits.traits.length + instance_info[i].instance_traits.traits.length + 1);
|
||||
}
|
||||
out.println(toPrint);
|
||||
}*/
|
||||
}
|
||||
|
||||
//constructor
|
||||
if (instance_info[i].iinit_index != 0) {
|
||||
String modifier = "";
|
||||
Multiname m = constants.constant_multiname[instance_info[i].name_index];
|
||||
if (m != null) {
|
||||
Namespace ns = m.getNamespace(constants);
|
||||
if (ns != null) {
|
||||
modifier = ns.getPrefix(constants) + " ";
|
||||
if (modifier.equals(" ")) {
|
||||
modifier = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
String constructorParams = method_info[instance_info[i].iinit_index].getParamStr(constants);
|
||||
String bodyStr = "";
|
||||
int bodyIndex = findBodyIndex(instance_info[i].iinit_index);
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = addTabs(bodies[bodyIndex].toString(false, i, this, constants, method_info, highlight), 3);
|
||||
}
|
||||
String toPrint = IDENT_STRING + IDENT_STRING + modifier + "function " + constants.constant_multiname[instance_info[i].name_index].getName(constants) + "(" + constructorParams + ") {\r\n" + bodyStr + "\r\n" + IDENT_STRING + IDENT_STRING + "}";
|
||||
if (highlight) {
|
||||
toPrint = Highlighting.hilighTrait(toPrint, class_info[i].static_traits.traits.length + instance_info[i].instance_traits.traits.length);
|
||||
}
|
||||
out.println(toPrint);
|
||||
}
|
||||
|
||||
//static variables,constants & methods
|
||||
for (int ti = 0; ti < class_info[i].static_traits.traits.length; ti++) {
|
||||
Trait t = class_info[i].static_traits.traits[ti];
|
||||
String toPrint = "";
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t;
|
||||
String bodyStr = "";
|
||||
int bodyIndex = findBodyIndex(tm.method_info);
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = addTabs(bodies[bodyIndex].toString(true, i, this, constants, method_info, highlight), 3);
|
||||
}
|
||||
toPrint = IDENT_STRING + IDENT_STRING + tm.convert(constants, method_info, true) + " {\r\n" + bodyStr + "\r\n" + IDENT_STRING + IDENT_STRING + "}";
|
||||
}
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst ts = (TraitSlotConst) t;
|
||||
|
||||
toPrint = IDENT_STRING + IDENT_STRING + ts.convert(constants, method_info, true) + ";";
|
||||
}
|
||||
if (highlight) {
|
||||
toPrint = Highlighting.hilighTrait(toPrint, ti);
|
||||
} else {
|
||||
toPrint = Highlighting.stripHilights(toPrint);
|
||||
}
|
||||
out.println(toPrint);
|
||||
}
|
||||
for (int ti = 0; ti < instance_info[i].instance_traits.traits.length; ti++) {
|
||||
Trait t = instance_info[i].instance_traits.traits[ti];
|
||||
String toPrint = "";
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst ts = (TraitSlotConst) t;
|
||||
toPrint = IDENT_STRING + IDENT_STRING + ts.convert(constants, method_info, false) + ";";
|
||||
}
|
||||
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t;
|
||||
String bodyStr = "";
|
||||
int bodyIndex = findBodyIndex(tm.method_info);
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = addTabs(bodies[bodyIndex].toString(false, i, this, constants, method_info, highlight), 3);
|
||||
}
|
||||
toPrint = IDENT_STRING + IDENT_STRING + tm.convert(constants, method_info, false) + " {\r\n" + bodyStr + "\r\n" + IDENT_STRING + IDENT_STRING + "}";
|
||||
}
|
||||
if (highlight) {
|
||||
toPrint = Highlighting.hilighTrait(toPrint, class_info[i].static_traits.traits.length + ti);
|
||||
} else {
|
||||
toPrint = Highlighting.stripHilights(toPrint);
|
||||
}
|
||||
out.println(toPrint);
|
||||
}
|
||||
|
||||
|
||||
out.println(IDENT_STRING + "}");//class
|
||||
out.println("}");//package
|
||||
out.flush();
|
||||
|
||||
return baos.toString();
|
||||
}
|
||||
|
||||
public void export(String directory) throws IOException {
|
||||
for (int i = 0; i < instance_info.length; i++) {
|
||||
String packageName = instance_info[i].getName(constants).getNamespace(constants).getName(constants);
|
||||
String className = instance_info[i].getName(constants).getName(constants);
|
||||
Main.startWork("Exporting " + (i + 1) + "/" + instance_info.length + " " + packageName + "." + className + "...");
|
||||
File outDir = new File(directory + File.separatorChar + packageName.replace('.', File.separatorChar));
|
||||
if (!outDir.exists()) {
|
||||
outDir.mkdirs();
|
||||
}
|
||||
String fileName = outDir.toString() + File.separator + className + ".as";
|
||||
FileOutputStream fos = new FileOutputStream(fileName);
|
||||
fos.write(classToString(i, false).getBytes());
|
||||
fos.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void dump(OutputStream os) {
|
||||
PrintStream output = new PrintStream(os);
|
||||
constants.dump(output);
|
||||
for (int i = 0; i < method_info.length; i++) {
|
||||
output.println("MethodInfo[" + i + "]:" + method_info[i].toString(constants));
|
||||
}
|
||||
for (int i = 0; i < metadata_info.length; i++) {
|
||||
output.println("MetadataInfo[" + i + "]:" + metadata_info[i].toString(constants));
|
||||
}
|
||||
for (int i = 0; i < instance_info.length; i++) {
|
||||
output.println("InstanceInfo[" + i + "]:" + instance_info[i].toString(constants));
|
||||
}
|
||||
for (int i = 0; i < class_info.length; i++) {
|
||||
output.println("ClassInfo[" + i + "]:" + class_info[i].toString(constants));
|
||||
}
|
||||
for (int i = 0; i < script_info.length; i++) {
|
||||
output.println("ScriptInfo[" + i + "]:" + script_info[i].toString(constants));
|
||||
}
|
||||
for (int i = 0; i < bodies.length; i++) {
|
||||
output.println("MethodBody[" + i + "]:"); //+ bodies[i].toString(this, constants, method_info));
|
||||
}
|
||||
}
|
||||
|
||||
public static final String[] reservedWords = {
|
||||
"as", "break", "case", "catch", "class", "const", "continue", /*"default",*/ "delete", "do", "each", "else",
|
||||
"extends", "false", "finally", "for", "function", "if", "implements", "import", "in", "instanceof",
|
||||
"interface", "internal", "is", "native", "new", "null", "package", "private", "protected", "public",
|
||||
"return", "super", "switch", "this", "throw", "true", "try", "typeof", "use", "var", /*"void",*/ "while",
|
||||
"with"};
|
||||
public int unknownCount = 0;
|
||||
|
||||
public void cleanOneName(int index) {
|
||||
cleanNamespace(index);
|
||||
}
|
||||
|
||||
public void cleanNamespace(int index) {
|
||||
if (index <= 0) {
|
||||
return;
|
||||
}
|
||||
String s = constants.constant_string[index];
|
||||
boolean isValid = true;
|
||||
boolean isReserved = false;
|
||||
for (String rw : reservedWords) {
|
||||
if (rw.equals(s.trim())) {
|
||||
isValid = false;
|
||||
isReserved = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isValid) {
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (s.charAt(i) > 127) {
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
if (isReserved) {
|
||||
constants.constant_string[index] = "name_" + s.replace(" ", "_");
|
||||
} else {
|
||||
unknownCount++;
|
||||
constants.constant_string[index] = "_name" + unknownCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc;
|
||||
|
||||
import com.jpexs.asdec.abc.types.*;
|
||||
import com.jpexs.asdec.abc.types.traits.*;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
|
||||
public class ABCInputStream extends InputStream {
|
||||
|
||||
private InputStream is;
|
||||
private long bytesRead = 0;
|
||||
private ByteArrayOutputStream bufferOs = null;
|
||||
|
||||
public void startBuffer() {
|
||||
bufferOs = new ByteArrayOutputStream();
|
||||
}
|
||||
|
||||
public byte[] stopBuffer() {
|
||||
if (bufferOs == null) return new byte[0];
|
||||
byte ret[] = bufferOs.toByteArray();
|
||||
bufferOs = null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public ABCInputStream(InputStream is) {
|
||||
this.is = is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
bytesRead++;
|
||||
int i = is.read();
|
||||
if (bufferOs != null) {
|
||||
if (i != -1)
|
||||
bufferOs.write(i);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public int readU8() throws IOException {
|
||||
return read();
|
||||
}
|
||||
|
||||
public int readU32() throws IOException {
|
||||
int i = 0;
|
||||
int ret = 0;
|
||||
int bytePos = 0;
|
||||
int byteCount = 0;
|
||||
boolean nextByte = false;
|
||||
do {
|
||||
i = read();
|
||||
nextByte = (i >> 7) == 1;
|
||||
i = i & 0x7f;
|
||||
ret = ret + (i << bytePos);
|
||||
byteCount++;
|
||||
bytePos += 7;
|
||||
} while (nextByte);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int readU30() throws IOException {
|
||||
return readU32();
|
||||
}
|
||||
|
||||
public int readS24() throws IOException {
|
||||
int ret = (read()) + (read() << 8) + (read() << 16);
|
||||
|
||||
if ((ret >> 23) == 1) {
|
||||
ret = ret | 0xff000000;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int readU16() throws IOException {
|
||||
return (read()) + (read() << 8);
|
||||
}
|
||||
|
||||
public long readS32() throws IOException {
|
||||
int i = 0;
|
||||
long ret = 0;
|
||||
int bytePos = 0;
|
||||
int byteCount = 0;
|
||||
boolean nextByte = false;
|
||||
do {
|
||||
i = read();
|
||||
nextByte = (i >> 7) == 1;
|
||||
i = i & 0x7f;
|
||||
ret = ret + (i << bytePos);
|
||||
byteCount++;
|
||||
bytePos += 7;
|
||||
if (bytePos == 35) {
|
||||
if ((ret >> 31) == 1)
|
||||
ret = -(ret & 0x7fffffff);
|
||||
break;
|
||||
}
|
||||
} while (nextByte);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
return is.available();
|
||||
}
|
||||
|
||||
|
||||
public final long readLong() throws IOException {
|
||||
byte readBuffer[] = safeRead(8);
|
||||
return (((long) readBuffer[7] << 56) +
|
||||
((long) (readBuffer[6] & 255) << 48) +
|
||||
((long) (readBuffer[5] & 255) << 40) +
|
||||
((long) (readBuffer[4] & 255) << 32) +
|
||||
((long) (readBuffer[3] & 255) << 24) +
|
||||
((readBuffer[2] & 255) << 16) +
|
||||
((readBuffer[1] & 255) << 8) +
|
||||
((readBuffer[0] & 255) << 0));
|
||||
}
|
||||
|
||||
public double readDouble() throws IOException {
|
||||
long el = readLong();
|
||||
double ret = Double.longBitsToDouble(el);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
private byte[] safeRead(int count) throws IOException {
|
||||
byte ret[] = new byte[count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
ret[i] = (byte) read();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Namespace readNamespace() throws IOException {
|
||||
int kind = read();
|
||||
int name_index = 0;
|
||||
for (int k = 0; k < Namespace.nameSpaceKinds.length; k++) {
|
||||
if (Namespace.nameSpaceKinds[k] == kind) {
|
||||
name_index = readU30();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return new Namespace(kind, name_index);
|
||||
}
|
||||
|
||||
public Multiname readMultiname() throws IOException {
|
||||
int kind = read();
|
||||
int namespace_index = -1;
|
||||
int name_index = -1;
|
||||
int namespace_set_index = -1;
|
||||
|
||||
if ((kind == 7) || (kind == 0xd)) { // CONSTANT_QName and CONSTANT_QNameA.
|
||||
namespace_index = readU30();
|
||||
name_index = readU30();
|
||||
}
|
||||
if ((kind == 9) || (kind == 0xe)) { // CONSTANT_Multiname and CONSTANT_MultinameA.
|
||||
name_index = readU30();
|
||||
namespace_set_index = readU30();
|
||||
}
|
||||
if ((kind == 0xf) || (kind == 0x10)) { //CONSTANT_RTQName and CONSTANT_RTQNameA
|
||||
name_index = readU30();
|
||||
}
|
||||
if ((kind == 0x1B) || (kind == 0x1C)) { //CONSTANT_MultinameL and CONSTANT_MultinameLA
|
||||
namespace_set_index = readU30();
|
||||
}
|
||||
//kind==0x11,0x12 nothing CONSTANT_RTQNameL and CONSTANT_RTQNameLA.
|
||||
return new Multiname(kind, name_index, namespace_index, namespace_set_index);
|
||||
}
|
||||
|
||||
public MethodInfo readMethodInfo() throws IOException {
|
||||
int param_count = readU30();
|
||||
int ret_type = readU30();
|
||||
int param_types[] = new int[param_count];
|
||||
for (int i = 0; i < param_count; i++) {
|
||||
param_types[i] = readU30();
|
||||
}
|
||||
int name_index = readU30();
|
||||
int flags = read();
|
||||
|
||||
//// 1=need_arguments, 2=need_activation, 4=need_rest 8=has_optional (16=ignore_rest, 32=explicit,) 64=setsdxns, 128=has_paramnames
|
||||
|
||||
ValueKind optional[] = new ValueKind[0];
|
||||
if ((flags & 8) == 8) { //if has_optional
|
||||
int optional_count = readU30();
|
||||
optional = new ValueKind[optional_count];
|
||||
for (int i = 0; i < optional_count; i++) {
|
||||
optional[i] = new ValueKind(readU30(), read());
|
||||
}
|
||||
}
|
||||
|
||||
int param_names[] = new int[param_count];
|
||||
if ((flags & 128) == 128) { //if has_paramnames
|
||||
for (int i = 0; i < param_count; i++) {
|
||||
param_names[i] = readU30();
|
||||
}
|
||||
}
|
||||
return new MethodInfo(param_types, ret_type, name_index, flags, optional, param_names);
|
||||
}
|
||||
|
||||
public Trait readTrait() throws IOException {
|
||||
long pos = getPosition();
|
||||
startBuffer();
|
||||
int name_index = readU30();
|
||||
int kind = read();
|
||||
int kindType = 0xf & kind;
|
||||
int kindFlags = kind >> 4;
|
||||
Trait trait = new Trait();
|
||||
|
||||
switch (kindType) {
|
||||
case 0: //slot
|
||||
case 6: //const
|
||||
TraitSlotConst t1 = new TraitSlotConst();
|
||||
t1.slot_id = readU30();
|
||||
t1.type_index = readU30();
|
||||
t1.value_index = readU30();
|
||||
if (t1.value_index != 0)
|
||||
t1.value_kind = read();
|
||||
trait = t1;
|
||||
break;
|
||||
case 1: //method
|
||||
case 2: //getter
|
||||
case 3: //setter
|
||||
TraitMethodGetterSetter t2 = new TraitMethodGetterSetter();
|
||||
t2.disp_id = readU30();
|
||||
t2.method_info = readU30();
|
||||
trait = t2;
|
||||
break;
|
||||
case 4: //class
|
||||
TraitClass t3 = new TraitClass();
|
||||
t3.slot_id = readU30();
|
||||
t3.class_info = readU30();
|
||||
trait = t3;
|
||||
break;
|
||||
case 5: //function
|
||||
TraitFunction t4 = new TraitFunction();
|
||||
t4.slot_index = readU30();
|
||||
t4.method_info = readU30();
|
||||
trait = t4;
|
||||
break;
|
||||
}
|
||||
trait.fileOffset = pos;
|
||||
trait.kindType = kindType;
|
||||
trait.kindFlags = kindFlags;
|
||||
trait.name_index = name_index;
|
||||
if ((kindFlags & 4) == 4) {
|
||||
int metadata_count = readU30();
|
||||
trait.metadata = new int[metadata_count];
|
||||
for (int i = 0; i < metadata_count; i++) {
|
||||
trait.metadata[i] = readU30();
|
||||
}
|
||||
}
|
||||
trait.bytes = stopBuffer();
|
||||
return trait;
|
||||
}
|
||||
|
||||
public Traits readTraits() throws IOException {
|
||||
int count = readU30();
|
||||
Traits traits = new Traits();
|
||||
traits.traits = new Trait[count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
traits.traits[i] = readTrait();
|
||||
}
|
||||
return traits;
|
||||
}
|
||||
|
||||
public InstanceInfo readInstanceInfo() throws IOException {
|
||||
InstanceInfo ret = new InstanceInfo();
|
||||
ret.name_index = readU30();
|
||||
ret.super_index = readU30();
|
||||
ret.flags = read();
|
||||
if ((ret.flags & 8) == 8) {
|
||||
ret.protectedNS = readU30();
|
||||
}
|
||||
int interfaces_count = readU30();
|
||||
ret.interfaces = new int[interfaces_count];
|
||||
for (int i = 0; i < interfaces_count; i++) {
|
||||
ret.interfaces[i] = readU30();
|
||||
}
|
||||
ret.iinit_index = readU30();
|
||||
ret.instance_traits = readTraits();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String readString() throws IOException {
|
||||
int length = readU30();
|
||||
return new String(safeRead(length), "utf8");
|
||||
}
|
||||
|
||||
|
||||
/*public void markStart(){
|
||||
bytesRead=0;
|
||||
}*/
|
||||
|
||||
public long getPosition() {
|
||||
return bytesRead;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc;
|
||||
|
||||
import com.jpexs.asdec.abc.types.InstanceInfo;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
import com.jpexs.asdec.abc.types.Multiname;
|
||||
import com.jpexs.asdec.abc.types.Namespace;
|
||||
import com.jpexs.asdec.abc.types.traits.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class ABCOutputStream extends OutputStream {
|
||||
|
||||
private OutputStream os;
|
||||
|
||||
public ABCOutputStream(OutputStream os) {
|
||||
this.os = os;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
os.write(b);
|
||||
}
|
||||
|
||||
public void writeU30(long value) throws IOException {
|
||||
writeS32(value);
|
||||
/*boolean loop = true;
|
||||
boolean underZero=value<0;
|
||||
|
||||
if(underZero){
|
||||
value = value & 0xFFFFFFFF;
|
||||
}else{
|
||||
value = value & 0x7FFFFFFF;
|
||||
}
|
||||
do {
|
||||
int ret = (int) (value & 0x7F);
|
||||
if (value < 0x80) {
|
||||
loop = false;
|
||||
}
|
||||
if (value > 0x7F) {
|
||||
ret += 0x80;
|
||||
}
|
||||
write(ret);
|
||||
value = value >> 7;
|
||||
} while (loop);
|
||||
*/
|
||||
}
|
||||
|
||||
public void writeU32(long value) throws IOException {
|
||||
boolean loop = true;
|
||||
value = value & 0xFFFFFFFF;
|
||||
do {
|
||||
int ret = (int) (value & 0x7F);
|
||||
if (value < 0x80) {
|
||||
loop = false;
|
||||
}
|
||||
if (value > 0x7F) {
|
||||
ret += 0x80;
|
||||
}
|
||||
write(ret);
|
||||
value = value >> 7;
|
||||
} while (loop);
|
||||
}
|
||||
|
||||
public void writeS24(long value) throws IOException {
|
||||
int ret = (int) (value & 0xff);
|
||||
write(ret);
|
||||
value = value >> 8;
|
||||
ret = (int) (value & 0xff);
|
||||
write(ret);
|
||||
value = value >> 8;
|
||||
ret = (int) (value & 0xff);
|
||||
write(ret);
|
||||
value = value >> 8;
|
||||
}
|
||||
|
||||
public void writeS32(long value) throws IOException {
|
||||
boolean belowZero = value < 0;
|
||||
/*if (belowZero) {
|
||||
value = -value;
|
||||
}*/
|
||||
int bitcount = 0;
|
||||
boolean loop = true;
|
||||
//value = value & 0xFFFFFFFF;
|
||||
do {
|
||||
bitcount += 7;
|
||||
int ret = (int) (value & 0x7F);
|
||||
if (value < 0x80) {
|
||||
if (belowZero) { //&& bitcount < 35
|
||||
ret += 0x80;
|
||||
} else {
|
||||
loop = false;
|
||||
}
|
||||
} else {
|
||||
ret += 0x80;
|
||||
}
|
||||
|
||||
if (bitcount == 35) {
|
||||
ret = ret & 0xf;
|
||||
}
|
||||
write(ret);
|
||||
if (bitcount == 35) {
|
||||
break;
|
||||
}
|
||||
value = value >> 7;
|
||||
} while (loop);
|
||||
}
|
||||
|
||||
public void writeLong(long value) throws IOException {
|
||||
byte writeBuffer[] = new byte[8];
|
||||
writeBuffer[7] = (byte) (value >>> 56);
|
||||
writeBuffer[6] = (byte) (value >>> 48);
|
||||
writeBuffer[5] = (byte) (value >>> 40);
|
||||
writeBuffer[4] = (byte) (value >>> 32);
|
||||
writeBuffer[3] = (byte) (value >>> 24);
|
||||
writeBuffer[2] = (byte) (value >>> 16);
|
||||
writeBuffer[1] = (byte) (value >>> 8);
|
||||
writeBuffer[0] = (byte) (value >>> 0);
|
||||
write(writeBuffer);
|
||||
}
|
||||
|
||||
public void writeDouble(double value) throws IOException {
|
||||
writeLong(Double.doubleToLongBits(value));
|
||||
}
|
||||
|
||||
public void writeU8(int value) throws IOException {
|
||||
write(value);
|
||||
}
|
||||
|
||||
public void writeU16(int value) throws IOException {
|
||||
write(value & 0xff);
|
||||
write((value >> 8) & 0xff);
|
||||
}
|
||||
|
||||
public void writeString(String s) throws IOException {
|
||||
byte sbytes[] = s.getBytes("utf8");
|
||||
writeU30(sbytes.length);
|
||||
write(sbytes);
|
||||
}
|
||||
|
||||
public void writeNamespace(Namespace ns) throws IOException {
|
||||
write(ns.kind);
|
||||
for (int k = 0; k < Namespace.nameSpaceKinds.length; k++) {
|
||||
if (Namespace.nameSpaceKinds[k] == ns.kind) {
|
||||
writeU30(ns.name_index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeMultiname(Multiname m) throws IOException {
|
||||
write(m.kind);
|
||||
if ((m.kind == 7) || (m.kind == 0xd)) { // CONSTANT_QName and CONSTANT_QNameA.
|
||||
writeU30(m.namespace_index);
|
||||
writeU30(m.name_index);
|
||||
}
|
||||
if ((m.kind == 9) || (m.kind == 0xe)) { // CONSTANT_Multiname and CONSTANT_MultinameA.
|
||||
writeU30(m.name_index);
|
||||
writeU30(m.namespace_set_index);
|
||||
}
|
||||
if ((m.kind == 0xf) || (m.kind == 0x10)) { //CONSTANT_RTQName and CONSTANT_RTQNameA
|
||||
writeU30(m.name_index);
|
||||
}
|
||||
if ((m.kind == 0x1B) || (m.kind == 0x1C)) { //CONSTANT_MultinameL and CONSTANT_MultinameLA
|
||||
writeU30(m.namespace_set_index);
|
||||
}
|
||||
//kind==0x11,0x12 nothing CONSTANT_RTQNameL and CONSTANT_RTQNameLA.
|
||||
}
|
||||
|
||||
public void writeMethodInfo(MethodInfo mi) throws IOException {
|
||||
writeU30(mi.param_types.length);
|
||||
writeU30(mi.ret_type);
|
||||
for (int i = 0; i < mi.param_types.length; i++) {
|
||||
writeU30(mi.param_types[i]);
|
||||
}
|
||||
writeU30(mi.name_index);
|
||||
write(mi.flags);
|
||||
if ((mi.flags & 8) == 8) {
|
||||
writeU30(mi.optional.length);
|
||||
for (int i = 0; i < mi.optional.length; i++) {
|
||||
writeU30(mi.optional[i].value_index);
|
||||
write(mi.optional[i].value_kind);
|
||||
}
|
||||
}
|
||||
|
||||
if ((mi.flags & 128) == 128) { //if has_paramnames
|
||||
for (int i = 0; i < mi.paramNames.length; i++) {
|
||||
writeU30(mi.paramNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeTrait(Trait t) throws IOException {
|
||||
writeU30(t.name_index);
|
||||
write((t.kindFlags << 4) + t.kindType);
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst t1 = (TraitSlotConst) t;
|
||||
writeU30(t1.slot_id);
|
||||
writeU30(t1.type_index);
|
||||
writeU30(t1.value_index);
|
||||
if (t1.value_index != 0) {
|
||||
write(t1.value_kind);
|
||||
}
|
||||
}
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t;
|
||||
writeU30(t2.disp_id);
|
||||
writeU30(t2.method_info);
|
||||
}
|
||||
if (t instanceof TraitClass) {
|
||||
TraitClass t3 = (TraitClass) t;
|
||||
writeU30(t3.slot_id);
|
||||
writeU30(t3.class_info);
|
||||
}
|
||||
if (t instanceof TraitFunction) {
|
||||
TraitFunction t4 = (TraitFunction) t;
|
||||
writeU30(t4.slot_index);
|
||||
writeU30(t4.method_info);
|
||||
}
|
||||
if ((t.kindFlags & 4) == 4) {
|
||||
writeU30(t.metadata.length);
|
||||
for (int i = 0; i < t.metadata.length; i++) {
|
||||
writeU30(t.metadata[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeTraits(Traits t) throws IOException {
|
||||
writeU30(t.traits.length);
|
||||
for (int i = 0; i < t.traits.length; i++) {
|
||||
writeTrait(t.traits[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeInstanceInfo(InstanceInfo ii) throws IOException {
|
||||
writeU30(ii.name_index);
|
||||
writeU30(ii.super_index);
|
||||
write(ii.flags);
|
||||
if ((ii.flags & 8) == 8) {
|
||||
writeU30(ii.protectedNS);
|
||||
}
|
||||
writeU30(ii.interfaces.length);
|
||||
for (int i = 0; i < ii.interfaces.length; i++) {
|
||||
writeU30(ii.interfaces[i]);
|
||||
}
|
||||
writeU30(ii.iinit_index);
|
||||
writeTraits(ii.instance_traits);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class CopyOutputStream extends OutputStream {
|
||||
private OutputStream os;
|
||||
private InputStream is;
|
||||
private long pos = 0;
|
||||
private int TEMPSIZE = 5;
|
||||
private int temp[] = new int[TEMPSIZE];
|
||||
private int tempPos = 0;
|
||||
|
||||
public CopyOutputStream(OutputStream os, InputStream is) {
|
||||
this.os = os;
|
||||
this.is = is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
temp[tempPos] = b;
|
||||
tempPos = (tempPos + 1) % TEMPSIZE;
|
||||
|
||||
pos++;
|
||||
int r = is.read();
|
||||
if ((b & 0xff) != r) {
|
||||
os.flush();
|
||||
|
||||
boolean output = false;
|
||||
|
||||
if (output) {
|
||||
System.out.print("Last written:");
|
||||
for (int i = 0; i < TEMPSIZE; i++) {
|
||||
System.out.print("" + Integer.toHexString(temp[(tempPos + i) % TEMPSIZE]) + " ");
|
||||
}
|
||||
System.out.println("");
|
||||
System.out.println("More expected:");
|
||||
for (int i = 0; i < TEMPSIZE; i++) {
|
||||
System.out.println("" + Integer.toHexString(is.read()));
|
||||
}
|
||||
|
||||
System.out.println("");
|
||||
System.out.println(Integer.toHexString(r) + " expected but " + Integer.toHexString(b) + " found");
|
||||
}
|
||||
throw new NotSameException(pos);
|
||||
}
|
||||
os.write(b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc;
|
||||
|
||||
|
||||
public class NotSameException extends RuntimeException {
|
||||
public NotSameException(long pos) {
|
||||
super("Streams are not the same at pos:" + pos);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2;
|
||||
|
||||
import com.jpexs.asdec.abc.types.Multiname;
|
||||
import com.jpexs.asdec.abc.types.Namespace;
|
||||
import com.jpexs.asdec.abc.types.NamespaceSet;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
public class ConstantPool {
|
||||
public long constant_int[];
|
||||
public long constant_uint[];
|
||||
public double constant_double[];
|
||||
public String constant_string[];
|
||||
public Namespace constant_namespace[];
|
||||
public NamespaceSet constant_namespace_set[];
|
||||
public Multiname constant_multiname[];
|
||||
|
||||
public int addInt(long value) {
|
||||
constant_int = Arrays.copyOf(constant_int, constant_int.length + 1);
|
||||
constant_int[constant_int.length - 1] = value;
|
||||
return constant_int.length - 1;
|
||||
}
|
||||
|
||||
public int addUInt(long value) {
|
||||
constant_uint = Arrays.copyOf(constant_uint, constant_uint.length + 1);
|
||||
constant_uint[constant_uint.length - 1] = value;
|
||||
return constant_uint.length - 1;
|
||||
}
|
||||
|
||||
public int addDouble(double value) {
|
||||
constant_double = Arrays.copyOf(constant_double, constant_double.length + 1);
|
||||
constant_double[constant_double.length - 1] = value;
|
||||
return constant_double.length - 1;
|
||||
}
|
||||
|
||||
public int addString(String value) {
|
||||
constant_string = Arrays.copyOf(constant_string, constant_string.length + 1);
|
||||
constant_string[constant_string.length - 1] = value;
|
||||
return constant_string.length - 1;
|
||||
}
|
||||
|
||||
public int getIntId(long value) {
|
||||
for (int i = 1; i < constant_int.length; i++) {
|
||||
if (constant_int[i] == value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getUIntId(long value) {
|
||||
for (int i = 1; i < constant_uint.length; i++) {
|
||||
if (constant_uint[i] == value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getDoubleId(double value) {
|
||||
for (int i = 1; i < constant_double.length; i++) {
|
||||
if (constant_double[i] == value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getStringId(String s) {
|
||||
for (int i = 1; i < constant_string.length; i++) {
|
||||
if (constant_string[i].equals(s)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getMultiNameId(String s) {
|
||||
for (int i = 1; i < constant_multiname.length; i++) {
|
||||
if (constant_multiname[i].getName(this).equals(s)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void dump(OutputStream os) {
|
||||
PrintStream output = new PrintStream(os);
|
||||
String s = "";
|
||||
for (int i = 1; i < constant_int.length; i++) {
|
||||
output.println("INT[" + i + "]=" + constant_int[i]);
|
||||
}
|
||||
for (int i = 1; i < constant_uint.length; i++) {
|
||||
output.println("UINT[" + i + "]=" + constant_uint[i]);
|
||||
}
|
||||
for (int i = 1; i < constant_double.length; i++) {
|
||||
output.println("Double[" + i + "]=" + constant_double[i]);
|
||||
}
|
||||
for (int i = 1; i < constant_string.length; i++) {
|
||||
output.println("String[" + i + "]=" + constant_string[i]);
|
||||
}
|
||||
for (int i = 1; i < constant_namespace.length; i++) {
|
||||
output.println("Namespace[" + i + "]=" + constant_namespace[i].toString(this));
|
||||
}
|
||||
for (int i = 1; i < constant_namespace_set.length; i++) {
|
||||
output.println("NamespaceSet[" + i + "]=" + constant_namespace_set[i].toString(this));
|
||||
}
|
||||
|
||||
for (int i = 1; i < constant_multiname.length; i++) {
|
||||
output.println("Multiname[" + i + "]=" + constant_multiname[i].toString(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2;
|
||||
|
||||
|
||||
public class ConvertException extends Exception {
|
||||
public int line;
|
||||
public ConvertException(String s,int line) {
|
||||
super(s+" on line "+line);
|
||||
this.line=line;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2;
|
||||
|
||||
|
||||
public class InvalidInstructionArguments extends RuntimeException {
|
||||
|
||||
public InvalidInstructionArguments() {
|
||||
super("Invalid method arguments");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class LocalDataArea {
|
||||
public Stack operandStack = new Stack();
|
||||
public Stack scopeStack = new Stack();
|
||||
public List localRegisters = new ArrayList<Object>();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2;
|
||||
|
||||
|
||||
public class UnknownInstructionCode extends RuntimeException {
|
||||
public int code;
|
||||
|
||||
public UnknownInstructionCode(int code) {
|
||||
super("Unknown instruction code:" + Integer.toHexString(code));
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class UnknownJumpException extends RuntimeException {
|
||||
public Stack stack;
|
||||
public int ip;
|
||||
public List<TreeItem> output;
|
||||
|
||||
public UnknownJumpException(Stack stack, int ip, List<TreeItem> output) {
|
||||
this.stack = stack;
|
||||
this.ip = ip;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Unknown jump to " + ip;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions;
|
||||
|
||||
import com.jpexs.asdec.abc.ABCOutputStream;
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.helpers.Helper;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class AVM2Instruction {
|
||||
|
||||
public InstructionDefinition definition;
|
||||
public int operands[];
|
||||
public long offset;
|
||||
public byte bytes[];
|
||||
public String comment;
|
||||
public boolean ignored = false;
|
||||
|
||||
public AVM2Instruction(long offset, InstructionDefinition definition, int[] operands, byte bytes[]) {
|
||||
this.definition = definition;
|
||||
this.operands = operands;
|
||||
this.offset = offset;
|
||||
this.bytes = bytes;
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
try {
|
||||
ABCOutputStream aos = new ABCOutputStream(bos);
|
||||
aos.write(definition.instructionCode);
|
||||
for (int i = 0; i < definition.operands.length; i++) {
|
||||
int opt = definition.operands[i] & 0xff00;
|
||||
switch (opt) {
|
||||
case AVM2Code.OPT_S24:
|
||||
aos.writeS24(operands[i]);
|
||||
break;
|
||||
case AVM2Code.OPT_U30:
|
||||
aos.writeU30(operands[i]);
|
||||
break;
|
||||
case AVM2Code.OPT_U8:
|
||||
aos.writeU8(operands[i]);
|
||||
break;
|
||||
case AVM2Code.OPT_BYTE:
|
||||
aos.writeU8(0xff & operands[i]);
|
||||
break;
|
||||
case AVM2Code.OPT_CASE_OFFSETS:
|
||||
|
||||
aos.writeU30(operands[i]); //case count
|
||||
for (int j = i + 1; j < operands.length; j++) {
|
||||
aos.writeS24(operands[j]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
//ignored
|
||||
}
|
||||
return bos.toByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String s = definition.instructionName;
|
||||
for (int i = 0; i < operands.length; i++) {
|
||||
s += " " + operands[i];
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public List<Long> getOffsets() {
|
||||
List<Long> ret = new ArrayList<Long>();
|
||||
String s = "";
|
||||
for (int i = 0; i < definition.operands.length; i++) {
|
||||
switch (definition.operands[i]) {
|
||||
case AVM2Code.DAT_OFFSET:
|
||||
ret.add(offset + operands[i] + getBytes().length);
|
||||
break;
|
||||
case AVM2Code.DAT_CASE_BASEOFFSET:
|
||||
ret.add(offset + operands[i]);
|
||||
break;
|
||||
case AVM2Code.OPT_CASE_OFFSETS:
|
||||
for (int j = i + 1; j < operands.length; j++) {
|
||||
ret.add(offset + operands[j]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String getParams(ConstantPool constants) {
|
||||
String s = "";
|
||||
for (int i = 0; i < definition.operands.length; i++) {
|
||||
switch (definition.operands[i]) {
|
||||
case AVM2Code.DAT_MULTINAME_INDEX:
|
||||
s += " m[" + operands[i] + "]\"" + Helper.escapeString(constants.constant_multiname[operands[i]].toString(constants)) + "\"";
|
||||
break;
|
||||
case AVM2Code.DAT_STRING_INDEX:
|
||||
s += " \"" + Helper.escapeString(constants.constant_string[operands[i]]) + "\"";
|
||||
break;
|
||||
case AVM2Code.DAT_INT_INDEX:
|
||||
s += " " + constants.constant_int[operands[i]] + "";
|
||||
break;
|
||||
case AVM2Code.DAT_UINT_INDEX:
|
||||
s += " " + constants.constant_uint[operands[i]] + "";
|
||||
break;
|
||||
case AVM2Code.DAT_DOUBLE_INDEX:
|
||||
s += " " + constants.constant_double[operands[i]] + "";
|
||||
break;
|
||||
case AVM2Code.DAT_OFFSET:
|
||||
s += " ";
|
||||
if (operands[i] > 0) {
|
||||
//s += "+";
|
||||
}//operands[i]
|
||||
s += "ofs" + Helper.formatAddress(offset + operands[i] + getBytes().length) + "";
|
||||
break;
|
||||
case AVM2Code.DAT_CASE_BASEOFFSET:
|
||||
s += " ";
|
||||
if (operands[i] > 0) {
|
||||
//s += "+";
|
||||
}//operands[i]
|
||||
s += "ofs" + Helper.formatAddress(offset + operands[i]) + "";
|
||||
break;
|
||||
case AVM2Code.OPT_CASE_OFFSETS:
|
||||
s += " " + operands[i];
|
||||
for (int j = i + 1; j < operands.length; j++) {
|
||||
s += " ";
|
||||
if (operands[j] > 0) {
|
||||
//s += "+";
|
||||
}//operands[j]
|
||||
s += "ofs" + Helper.formatAddress(offset + operands[j]) + "";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
s += " " + operands[i];
|
||||
}
|
||||
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
if (ignored) {
|
||||
return " ;ignored";
|
||||
}
|
||||
if ((comment == null) || comment.equals("")) {
|
||||
return "";
|
||||
}
|
||||
return " ;" + comment;
|
||||
}
|
||||
|
||||
public String toString(ConstantPool constants) {
|
||||
String s = Helper.formatAddress(offset) + " " + Helper.padSpaceRight(Helper.byteArrToString(getBytes()), 30) + definition.instructionName;
|
||||
s += getParams(constants) + getComment();
|
||||
return s;
|
||||
}
|
||||
|
||||
public String toStringNoAddress(ConstantPool constants) {
|
||||
String s = definition.instructionName;
|
||||
s += getParams(constants) + getComment();
|
||||
return s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public interface IfTypeIns {
|
||||
public abstract void translateInverted(java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, AVM2Instruction ins);
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.FullMultinameTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
import com.jpexs.asdec.helpers.Highlighting;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class InstructionDefinition {
|
||||
|
||||
|
||||
protected String hilighOffset(String text, long offset) {
|
||||
return Highlighting.hilighOffset(text, offset);
|
||||
}
|
||||
|
||||
public int operands[];
|
||||
public String instructionName = "";
|
||||
public int instructionCode = 0;
|
||||
|
||||
public static String localRegName(int reg) {
|
||||
if (reg == 0) return "this";
|
||||
return "_loc" + reg + "_";
|
||||
}
|
||||
|
||||
public InstructionDefinition(int instructionCode, String instructionName, int operands[]) {
|
||||
this.instructionCode = instructionCode;
|
||||
this.instructionName = instructionName;
|
||||
this.operands = operands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String s = instructionName;
|
||||
for (int i = 0; i < operands.length; i++) {
|
||||
if ((operands[i] & 0xff00) == AVM2Code.OPT_U30) {
|
||||
s += " U30";
|
||||
}
|
||||
if ((operands[i] & 0xff00) == AVM2Code.OPT_U8) {
|
||||
s += " U8";
|
||||
}
|
||||
if ((operands[i] & 0xff00) == AVM2Code.OPT_BYTE) {
|
||||
s += " BYTE";
|
||||
}
|
||||
if ((operands[i] & 0xff00) == AVM2Code.OPT_S24) {
|
||||
s += " S24";
|
||||
}
|
||||
if ((operands[i] & 0xff00) == AVM2Code.OPT_CASE_OFFSETS) {
|
||||
s += " U30 S24,[S24]...";
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
}
|
||||
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
|
||||
}
|
||||
|
||||
protected FullMultinameTreeItem resolveMultiname(Stack<TreeItem> stack, ConstantPool constants, int multinameIndex, AVM2Instruction ins) {
|
||||
TreeItem ns = null;
|
||||
TreeItem name = null;
|
||||
if (constants.constant_multiname[multinameIndex].needsNs()) {
|
||||
ns = (TreeItem) stack.pop();
|
||||
}
|
||||
if (constants.constant_multiname[multinameIndex].needsName()) {
|
||||
name = (TreeItem) stack.pop();
|
||||
}
|
||||
return new FullMultinameTreeItem(ins, multinameIndex, name, ns);
|
||||
}
|
||||
|
||||
protected int resolvedCount(ConstantPool constants, int multinameIndex) {
|
||||
int pos = 0;
|
||||
if (constants.constant_multiname[multinameIndex].needsNs()) {
|
||||
pos++;
|
||||
}
|
||||
if (constants.constant_multiname[multinameIndex].needsName()) {
|
||||
pos++;
|
||||
}
|
||||
return pos;
|
||||
|
||||
}
|
||||
|
||||
protected String resolveMultinameNoPop(int pos, Stack<TreeItem> stack, ConstantPool constants, int multinameIndex, AVM2Instruction ins) {
|
||||
String ns = "";
|
||||
String name = "";
|
||||
if (constants.constant_multiname[multinameIndex].needsNs()) {
|
||||
ns = "[" + stack.get(pos) + "]";
|
||||
pos++;
|
||||
}
|
||||
if (constants.constant_multiname[multinameIndex].needsName()) {
|
||||
name = stack.get(pos).toString();
|
||||
} else {
|
||||
name = hilighOffset(constants.constant_multiname[multinameIndex].getName(constants), ins.offset);
|
||||
}
|
||||
return name + ns;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public interface SetTypeIns {
|
||||
public abstract String getObject(Stack<TreeItem> stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.AddTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class AddIIns extends AddIns {
|
||||
|
||||
public AddIIns() {
|
||||
instructionName = "add_i";
|
||||
instructionCode = 0xc5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new AddTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.AddTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class AddIns extends InstructionDefinition {
|
||||
|
||||
public AddIns() {
|
||||
super(0xa0, "add", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
Object o1 = lda.operandStack.pop();
|
||||
Object o2 = lda.operandStack.pop();
|
||||
if ((o1 instanceof Long) && ((o2 instanceof Long))) {
|
||||
Long ret = new Long(((Long) o1).longValue() + ((Long) o2).longValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else if ((o1 instanceof Double) && ((o2 instanceof Double))) {
|
||||
Double ret = new Double(((Double) o1).doubleValue() + ((Double) o2).doubleValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else if ((o1 instanceof Long) && ((o2 instanceof Double))) {
|
||||
Double ret = new Double(((Long) o1).longValue() + ((Double) o2).doubleValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else if ((o1 instanceof Double) && ((o2 instanceof Long))) {
|
||||
Double ret = new Double(((Double) o1).doubleValue() + ((Long) o2).longValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else {
|
||||
String s = o1.toString() + o2.toString();
|
||||
lda.operandStack.push(s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new AddTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.DecrementTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class DecrementIIns extends InstructionDefinition {
|
||||
|
||||
public DecrementIIns() {
|
||||
super(0xc1, "decrement_i", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
Object obj = lda.operandStack.pop();
|
||||
if (obj instanceof Long) {
|
||||
Long obj2 = ((Long) obj).longValue() - 1;
|
||||
lda.operandStack.push(obj2);
|
||||
} else if (obj instanceof Double) {
|
||||
Double obj2 = ((Double) obj).doubleValue() - 1;
|
||||
lda.operandStack.push(obj2);
|
||||
}
|
||||
if (obj instanceof String) {
|
||||
Double obj2 = Double.parseDouble((String) obj) - 1;
|
||||
lda.operandStack.push(obj2);
|
||||
} else {
|
||||
throw new RuntimeException("Cannot decrement local register");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
stack.push(new DecrementTreeItem(ins, (TreeItem) stack.pop()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.DecrementTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class DecrementIns extends InstructionDefinition {
|
||||
|
||||
public DecrementIns() {
|
||||
super(0x93, "decrement", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
Object obj = lda.operandStack.pop();
|
||||
if (obj instanceof Long) {
|
||||
Long obj2 = ((Long) obj).longValue() - 1;
|
||||
lda.operandStack.push(obj2);
|
||||
} else if (obj instanceof Double) {
|
||||
Double obj2 = ((Double) obj).doubleValue() - 1;
|
||||
lda.operandStack.push(obj2);
|
||||
}
|
||||
if (obj instanceof String) {
|
||||
Double obj2 = Double.parseDouble((String) obj) - 1;
|
||||
lda.operandStack.push(obj2);
|
||||
} else {
|
||||
throw new RuntimeException("Cannot decrement local register");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
stack.push(new DecrementTreeItem(ins, (TreeItem) stack.pop()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.DivideTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class DivideIns extends InstructionDefinition {
|
||||
|
||||
public DivideIns() {
|
||||
super(0xa3, "divide", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
Object o1 = lda.operandStack.pop();
|
||||
Object o2 = lda.operandStack.pop();
|
||||
if ((o1 instanceof Long) && ((o2 instanceof Long))) {
|
||||
Long ret = new Long(((Long) o1).longValue() / ((Long) o2).longValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else if ((o1 instanceof Double) && ((o2 instanceof Double))) {
|
||||
Double ret = new Double(((Double) o1).doubleValue() / ((Double) o2).doubleValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else if ((o1 instanceof Long) && ((o2 instanceof Double))) {
|
||||
Double ret = new Double(((Long) o1).longValue() / ((Double) o2).doubleValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else if ((o1 instanceof Double) && ((o2 instanceof Long))) {
|
||||
Double ret = new Double(((Double) o1).doubleValue() / ((Long) o2).longValue());
|
||||
lda.operandStack.push(ret);
|
||||
} else {
|
||||
throw new RuntimeException("Cannot divide");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new DivideTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.IncrementTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IncrementIIns extends InstructionDefinition {
|
||||
|
||||
public IncrementIIns() {
|
||||
super(0xc0, "increment_i", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
stack.push(new IncrementTreeItem(ins, (TreeItem) stack.pop()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.IncrementTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IncrementIns extends InstructionDefinition {
|
||||
|
||||
public IncrementIns() {
|
||||
super(0x91, "increment", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
stack.push(new IncrementTreeItem(ins, (TreeItem) stack.pop()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.ModuloTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class ModuloIns extends InstructionDefinition {
|
||||
|
||||
public ModuloIns() {
|
||||
super(0xa4, "modulo", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new ModuloTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.MultiplyTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class MultiplyIIns extends InstructionDefinition {
|
||||
|
||||
public MultiplyIIns() {
|
||||
super(0xc7, "multiply_i", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new MultiplyTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.MultiplyTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class MultiplyIns extends InstructionDefinition {
|
||||
|
||||
public MultiplyIns() {
|
||||
super(0xa2, "multiply", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new MultiplyTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.NegTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class NegateIIns extends InstructionDefinition {
|
||||
|
||||
public NegateIIns() {
|
||||
super(0xc4, "negate_i", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v = (TreeItem) stack.pop();
|
||||
stack.push(new NegTreeItem(ins, v));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.NegTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class NegateIns extends InstructionDefinition {
|
||||
|
||||
public NegateIns() {
|
||||
super(0x90, "negate", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v = (TreeItem) stack.pop();
|
||||
stack.push(new NegTreeItem(ins, v));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.NotTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class NotIns extends InstructionDefinition {
|
||||
|
||||
public NotIns() {
|
||||
super(0x96, "not", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v = (TreeItem) stack.pop();
|
||||
stack.push(new NotTreeItem(ins, v));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.SubtractTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class SubtractIIns extends InstructionDefinition {
|
||||
|
||||
public SubtractIIns() {
|
||||
super(0xc6, "subtract_i", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new SubtractTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.arithmetic;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.SubtractTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class SubtractIns extends InstructionDefinition {
|
||||
|
||||
public SubtractIns() {
|
||||
super(0xa1, "subtract", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new SubtractTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.bitwise;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.BitAndTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class BitAndIns extends InstructionDefinition {
|
||||
|
||||
public BitAndIns() {
|
||||
super(0xa8, "bitand", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
Long value2 = (Long) lda.operandStack.pop();
|
||||
Long value1 = (Long) lda.operandStack.pop();
|
||||
Long value3 = value1 & value2;
|
||||
lda.operandStack.push(value3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new BitAndTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.bitwise;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.BitNotTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class BitNotIns extends InstructionDefinition {
|
||||
|
||||
public BitNotIns() {
|
||||
super(0x97, "bitnot", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
Long value = (Long) lda.operandStack.pop();
|
||||
Long ret = new Long(-value.longValue());
|
||||
lda.operandStack.push(ret);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v = (TreeItem) stack.pop();
|
||||
stack.push(new BitNotTreeItem(ins, v));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.bitwise;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.BitOrTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class BitOrIns extends InstructionDefinition {
|
||||
|
||||
public BitOrIns() {
|
||||
super(0xa9, "bitor", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
Long value2 = (Long) lda.operandStack.pop();
|
||||
Long value1 = (Long) lda.operandStack.pop();
|
||||
Long value3 = value1 | value2;
|
||||
lda.operandStack.push(value3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new BitOrTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.bitwise;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.BitXorTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class BitXorIns extends InstructionDefinition {
|
||||
|
||||
public BitXorIns() {
|
||||
super(0xaa, "bitxor", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
Long value2 = (Long) lda.operandStack.pop();
|
||||
Long value1 = (Long) lda.operandStack.pop();
|
||||
Long value3 = value1 ^ value2;
|
||||
lda.operandStack.push(value3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new BitXorTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.bitwise;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.LShiftTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class LShiftIns extends InstructionDefinition {
|
||||
|
||||
public LShiftIns() {
|
||||
super(0xa5, "lshift", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new LShiftTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.bitwise;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.RShiftTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class RShiftIns extends InstructionDefinition {
|
||||
|
||||
public RShiftIns() {
|
||||
super(0xa6, "rshift", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new RShiftTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.bitwise;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.URShiftTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class URShiftIns extends InstructionDefinition {
|
||||
|
||||
public URShiftIns() {
|
||||
super(0xa7, "urshift", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new URShiftTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.comparsion;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.EqTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class EqualsIns extends InstructionDefinition {
|
||||
|
||||
public EqualsIns() {
|
||||
super(0xab, "equals", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
Object obj1 = lda.operandStack.pop();
|
||||
Object obj2 = lda.operandStack.pop();
|
||||
Boolean res = obj1.equals(obj2);
|
||||
lda.operandStack.push(res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new EqTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.comparsion;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.GeTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class GreaterEqualsIns extends InstructionDefinition {
|
||||
|
||||
public GreaterEqualsIns() {
|
||||
super(0xb0, "greaterequals", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new GeTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.comparsion;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.LtTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class GreaterThanIns extends InstructionDefinition {
|
||||
|
||||
public GreaterThanIns() {
|
||||
super(0xaf, "greaterthan", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new LtTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.comparsion;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.LeTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class LessEqualsIns extends InstructionDefinition {
|
||||
|
||||
public LessEqualsIns() {
|
||||
super(0xae, "lessequals", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new LeTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.comparsion;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.GtTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class LessThanIns extends InstructionDefinition {
|
||||
|
||||
public LessThanIns() {
|
||||
super(0xad, "lessthan", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new GtTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.comparsion;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.StrictEqTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class StrictEqualsIns extends InstructionDefinition {
|
||||
|
||||
public StrictEqualsIns() {
|
||||
super(0xac, "strictequals", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new StrictEqTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.ConstructTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class ConstructIns extends InstructionDefinition {
|
||||
|
||||
public ConstructIns() {
|
||||
super(0x42, "construct", new int[]{AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
int argCount = (int) ((Long) arguments.get(0)).longValue();
|
||||
List passArguments = new ArrayList();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
Object obj = lda.operandStack.pop();
|
||||
throw new RuntimeException("Cannot call constructor");
|
||||
//call construct property of obj
|
||||
//push new instance
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int argCount = ins.operands[0];
|
||||
List<TreeItem> args = new ArrayList<TreeItem>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, (TreeItem) stack.pop());
|
||||
}
|
||||
TreeItem obj = (TreeItem) stack.pop();
|
||||
stack.push(new ConstructTreeItem(ins, obj, args));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.ConstructPropTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.FullMultinameTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class ConstructPropIns extends InstructionDefinition {
|
||||
|
||||
public ConstructPropIns() {
|
||||
super(0x4a, "constructprop", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
int multinameIndex = (int) ((Long) arguments.get(0)).longValue();
|
||||
int argCount = (int) ((Long) arguments.get(1)).longValue();
|
||||
List passArguments = new ArrayList();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
//if multiname[multinameIndex] is runtime
|
||||
//pop(name) pop(ns)
|
||||
throw new RuntimeException("Cannot construct property");
|
||||
//create property
|
||||
//push new instance
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int multinameIndex = ins.operands[0];
|
||||
int argCount = ins.operands[1];
|
||||
List<TreeItem> args = new ArrayList<TreeItem>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, (TreeItem) stack.pop());
|
||||
}
|
||||
FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins);
|
||||
TreeItem obj = (TreeItem) stack.pop();
|
||||
|
||||
|
||||
stack.push(new ConstructPropTreeItem(ins, obj, multiname, args));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.ConstructSuperTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class ConstructSuperIns extends InstructionDefinition {
|
||||
|
||||
public ConstructSuperIns() {
|
||||
super(0x49, "constructsuper", new int[]{AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
int argCount = (int) ((Long) arguments.get(0)).longValue();
|
||||
List passArguments = new ArrayList();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
Object obj = lda.operandStack.pop();
|
||||
throw new RuntimeException("Cannot call super constructor");
|
||||
//call construct property of obj
|
||||
//do not push anything
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int argCount = ins.operands[0];
|
||||
List<TreeItem> args = new ArrayList<TreeItem>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, (TreeItem) stack.pop());
|
||||
}
|
||||
TreeItem obj = (TreeItem) stack.pop();
|
||||
output.add(new ConstructSuperTreeItem(ins, obj, args));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.NewActivationTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class NewActivationIns extends InstructionDefinition {
|
||||
|
||||
public NewActivationIns() {
|
||||
super(0x57, "newactivation", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
stack.push(new NewActivationTreeItem(ins));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.NewArrayTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class NewArrayIns extends InstructionDefinition {
|
||||
|
||||
public NewArrayIns() {
|
||||
super(0x56, "newarray", new int[]{AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int argCount = ins.operands[0];
|
||||
List<TreeItem> args = new ArrayList<TreeItem>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, (TreeItem) stack.pop());
|
||||
}
|
||||
stack.push(new NewArrayTreeItem(ins, args));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.clauses.ExceptionTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class NewCatchIns extends InstructionDefinition {
|
||||
|
||||
public NewCatchIns() {
|
||||
super(0x5a, "newcatch", new int[]{AVM2Code.DAT_EXCEPTION_INDEX});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int exInfo = ins.operands[0];
|
||||
stack.push(new ExceptionTreeItem(body.exceptions[exInfo]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.UnparsedTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class NewClassIns extends InstructionDefinition {
|
||||
|
||||
public NewClassIns() {
|
||||
super(0x58, "newclass", new int[]{AVM2Code.DAT_CLASS_INDEX});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int clsIndex = ins.operands[0];
|
||||
String baseType = stack.pop().toString();
|
||||
stack.push(new UnparsedTreeItem(ins, "new class(" + clsIndex + ") extends " + baseType));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.NewFunctionTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodBody;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class NewFunctionIns extends InstructionDefinition {
|
||||
|
||||
public NewFunctionIns() {
|
||||
super(0x40, "newfunction", new int[]{AVM2Code.DAT_METHOD_INDEX});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int methodIndex = ins.operands[0];
|
||||
MethodBody mybody = abc.findBody(methodIndex);
|
||||
String bodyStr = "";
|
||||
if (mybody != null) {
|
||||
bodyStr = mybody.toString(isStatic, classIndex, abc, constants, method_info, false);
|
||||
}
|
||||
stack.push(new NewFunctionTreeItem(ins, method_info[methodIndex].getParamStr(constants), method_info[methodIndex].getReturnTypeStr(constants), bodyStr));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.construction;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.NameValuePair;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.NewObjectTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class NewObjectIns extends InstructionDefinition {
|
||||
|
||||
public NewObjectIns() {
|
||||
super(0x55, "newobject", new int[]{AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int argCount = ins.operands[0];
|
||||
List<NameValuePair> args = new ArrayList<NameValuePair>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
TreeItem value = (TreeItem) stack.pop();
|
||||
TreeItem name = (TreeItem) stack.pop();
|
||||
args.add(0, new NameValuePair(name, value));
|
||||
}
|
||||
stack.push(new NewObjectTreeItem(ins, args));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.debug;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
|
||||
|
||||
public class DebugFileIns extends InstructionDefinition {
|
||||
|
||||
public DebugFileIns() {
|
||||
super(0xf1, "debugfile", new int[]{AVM2Code.DAT_STRING_INDEX});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.debug;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
|
||||
|
||||
public class DebugIns extends InstructionDefinition {
|
||||
|
||||
public DebugIns() {
|
||||
super(0xef, "debug", new int[]{AVM2Code.DAT_DEBUG_TYPE, AVM2Code.DAT_STRING_INDEX, AVM2Code.DAT_REGISTER_INDEX, AVM2Code.OPT_U30});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.debug;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
|
||||
|
||||
public class DebugLineIns extends InstructionDefinition {
|
||||
|
||||
public DebugLineIns() {
|
||||
super(0xf0, "debugline", new int[]{AVM2Code.DAT_LINENUM});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.executing;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.CallTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class CallIns extends InstructionDefinition {
|
||||
|
||||
public CallIns() {
|
||||
super(0x41, "call", new int[]{AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
int argCount = (int) ((Long) arguments.get(0)).longValue();
|
||||
List passArguments = new ArrayList();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
Object receiver = lda.operandStack.pop();
|
||||
Object function = lda.operandStack.pop();
|
||||
throw new RuntimeException("Call to unknown function");
|
||||
//push(result)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int argCount = ins.operands[0];
|
||||
List<TreeItem> args = new ArrayList<TreeItem>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, (TreeItem) stack.pop());
|
||||
}
|
||||
TreeItem receiver = (TreeItem) stack.pop();
|
||||
TreeItem function = (TreeItem) stack.pop();
|
||||
stack.push(new CallTreeItem(ins, receiver, function, args));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.executing;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.CallMethodTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class CallMethodIns extends InstructionDefinition {
|
||||
|
||||
public CallMethodIns() {
|
||||
super(0x43, "callmethod", new int[]{AVM2Code.DAT_METHOD_INDEX, AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
int methodIndex = (int) ((Long) arguments.get(0)).longValue(); //index of object's method
|
||||
int argCount = (int) ((Long) arguments.get(1)).longValue();
|
||||
List passArguments = new ArrayList();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
Object receiver = lda.operandStack.pop();
|
||||
throw new RuntimeException("Call to unknown method");
|
||||
//push(result)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int methodIndex = ins.operands[0];
|
||||
int argCount = ins.operands[1];
|
||||
List<TreeItem> args = new ArrayList<TreeItem>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, (TreeItem) stack.pop());
|
||||
}
|
||||
TreeItem receiver = (TreeItem) stack.pop();
|
||||
String methodName = method_info[methodIndex].getName(constants);
|
||||
stack.push(new CallMethodTreeItem(ins, receiver, methodName, args));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.executing;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.CallPropertyTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.FullMultinameTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class CallPropLexIns extends CallPropertyIns {
|
||||
|
||||
public CallPropLexIns() {
|
||||
instructionName = "callproplex";
|
||||
instructionCode = 0x4c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int multinameIndex = ins.operands[0];
|
||||
int argCount = ins.operands[1];
|
||||
List<TreeItem> args = new ArrayList<TreeItem>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, (TreeItem) stack.pop());
|
||||
}
|
||||
FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins);
|
||||
TreeItem receiver = (TreeItem) stack.pop();
|
||||
|
||||
stack.push(new CallPropertyTreeItem(ins, false, receiver, multiname, args));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.executing;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.CallPropertyTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.FullMultinameTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class CallPropVoidIns extends InstructionDefinition {
|
||||
|
||||
public CallPropVoidIns() {
|
||||
super(0x4f, "callpropvoid", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
//same as callproperty
|
||||
|
||||
int multinameIndex = (int) ((Long) arguments.get(0)).longValue();
|
||||
int argCount = (int) ((Long) arguments.get(1)).longValue();
|
||||
List passArguments = new ArrayList();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
//if multiname[multinameIndex] is runtime
|
||||
//pop(name) pop(ns)
|
||||
Object obj = lda.operandStack.pop();
|
||||
throw new RuntimeException("Call to unknown property");
|
||||
//do not push anything
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int multinameIndex = ins.operands[0];
|
||||
int argCount = ins.operands[1];
|
||||
List<TreeItem> args = new ArrayList<TreeItem>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, (TreeItem) stack.pop());
|
||||
}
|
||||
FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins);
|
||||
|
||||
TreeItem receiver = (TreeItem) stack.pop();
|
||||
|
||||
output.add(new CallPropertyTreeItem(ins, true, receiver, multiname, args));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.executing;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.CallPropertyTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.FullMultinameTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class CallPropertyIns extends InstructionDefinition {
|
||||
|
||||
public CallPropertyIns() {
|
||||
super(0x46, "callproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
int multinameIndex = (int) ((Long) arguments.get(0)).longValue();
|
||||
int argCount = (int) ((Long) arguments.get(1)).longValue();
|
||||
List passArguments = new ArrayList();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
//if multiname[multinameIndex] is runtime
|
||||
//pop(name) pop(ns)
|
||||
Object obj = lda.operandStack.pop();
|
||||
throw new RuntimeException("Call to unknown property");
|
||||
//push(result)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int multinameIndex = ins.operands[0];
|
||||
int argCount = ins.operands[1];
|
||||
List<TreeItem> args = new ArrayList<TreeItem>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, (TreeItem) stack.pop());
|
||||
}
|
||||
FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins);
|
||||
|
||||
TreeItem receiver = (TreeItem) stack.pop();
|
||||
|
||||
stack.push(new CallPropertyTreeItem(ins, false, receiver, multiname, args));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.executing;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.CallStaticTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class CallStaticIns extends InstructionDefinition {
|
||||
|
||||
public CallStaticIns() {
|
||||
super(0x44, "callstatic", new int[]{AVM2Code.DAT_METHOD_INDEX, AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
int methodIndex = (int) ((Long) arguments.get(0)).longValue(); //index of method_info
|
||||
int argCount = (int) ((Long) arguments.get(1)).longValue();
|
||||
List passArguments = new ArrayList();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
Object receiver = lda.operandStack.pop();
|
||||
throw new RuntimeException("Call to unknown static method");
|
||||
//push(result)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int methodIndex = ins.operands[0];
|
||||
int argCount = ins.operands[1];
|
||||
List<TreeItem> args = new ArrayList<TreeItem>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, (TreeItem) stack.pop());
|
||||
}
|
||||
TreeItem receiver = (TreeItem) stack.pop();
|
||||
String methodName = method_info[methodIndex].getName(constants);
|
||||
stack.push(new CallStaticTreeItem(ins, receiver, methodName, args));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.executing;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.CallSuperTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.FullMultinameTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class CallSuperIns extends InstructionDefinition {
|
||||
|
||||
public CallSuperIns() {
|
||||
super(0x45, "callsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
int multinameIndex = (int) ((Long) arguments.get(0)).longValue();
|
||||
int argCount = (int) ((Long) arguments.get(1)).longValue();
|
||||
List passArguments = new ArrayList();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
//if multiname[multinameIndex] is runtime
|
||||
//pop(name) pop(ns)
|
||||
Object receiver = lda.operandStack.pop();
|
||||
throw new RuntimeException("Call to unknown super method");
|
||||
//push(result)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int multinameIndex = ins.operands[0];
|
||||
int argCount = ins.operands[1];
|
||||
List<TreeItem> args = new ArrayList<TreeItem>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add(0, (TreeItem) stack.pop());
|
||||
}
|
||||
FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins);
|
||||
TreeItem receiver = (TreeItem) stack.pop();
|
||||
|
||||
stack.push(new CallSuperTreeItem(ins, false, receiver, multiname, args));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.executing;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.CallSuperTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.FullMultinameTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class CallSuperVoidIns extends InstructionDefinition {
|
||||
|
||||
public CallSuperVoidIns() {
|
||||
super(0x4e, "callsupervoid", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
int multinameIndex = (int) ((Long) arguments.get(0)).longValue();
|
||||
int argCount = (int) ((Long) arguments.get(1)).longValue();
|
||||
List passArguments = new ArrayList();
|
||||
for (int i = argCount - 1; i >= 0; i--) {
|
||||
passArguments.set(i, lda.operandStack.pop());
|
||||
}
|
||||
//if multiname[multinameIndex] is runtime
|
||||
//pop(name) pop(ns)
|
||||
Object receiver = lda.operandStack.pop();
|
||||
throw new RuntimeException("Call to unknown super method");
|
||||
//do not push anything
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int multinameIndex = ins.operands[0];
|
||||
int argCount = ins.operands[1];
|
||||
List<TreeItem> args = new ArrayList<TreeItem>();
|
||||
for (int a = 0; a < argCount; a++) {
|
||||
args.add((TreeItem) stack.pop());
|
||||
}
|
||||
FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins);
|
||||
TreeItem receiver = (TreeItem) stack.pop();
|
||||
|
||||
output.add(new CallSuperTreeItem(ins, true, receiver, multiname, args));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.EqTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.NeqTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IfEqIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfEqIns() {
|
||||
super(0x13, "ifeq", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new EqTreeItem(ins, v1, v2));
|
||||
}
|
||||
|
||||
public void translateInverted(java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, AVM2Instruction ins) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new NeqTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.NotTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IfFalseIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfFalseIns() {
|
||||
super(0x12, "iffalse", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new NotTreeItem(ins, v1));
|
||||
}
|
||||
|
||||
public void translateInverted(java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, AVM2Instruction ins) {
|
||||
//String v1 = stack.pop().toString();
|
||||
//stack.push("(" + v1 + ")");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.GeTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.LtTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IfGeIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfGeIns() {
|
||||
super(0x18, "ifge", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new GeTreeItem(ins, v1, v2));
|
||||
}
|
||||
|
||||
public void translateInverted(java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, AVM2Instruction ins) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new LtTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.GtTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.LeTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IfGtIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfGtIns() {
|
||||
super(0x17, "ifgt", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new GtTreeItem(ins, v1, v2));
|
||||
}
|
||||
|
||||
public void translateInverted(java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, AVM2Instruction ins) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new LeTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.GtTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.LeTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IfLeIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfLeIns() {
|
||||
super(0x16, "ifle", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new LeTreeItem(ins, v1, v2));
|
||||
}
|
||||
|
||||
public void translateInverted(java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, AVM2Instruction ins) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new GtTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.GeTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.LtTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IfLtIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfLtIns() {
|
||||
super(0x15, "iflt", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new LtTreeItem(ins, v1, v2));
|
||||
}
|
||||
|
||||
public void translateInverted(java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, AVM2Instruction ins) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new GeTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.GeTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.LtTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IfNGeIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfNGeIns() {
|
||||
super(0x0f, "ifnge", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new LtTreeItem(ins, v1, v2));
|
||||
}
|
||||
|
||||
public void translateInverted(java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, AVM2Instruction ins) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new GeTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.GtTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.LeTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IfNGtIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfNGtIns() {
|
||||
super(0x0e, "ifngt", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new LeTreeItem(ins, v1, v2));
|
||||
}
|
||||
|
||||
public void translateInverted(java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, AVM2Instruction ins) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new GtTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.GtTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.LeTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IfNLeIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfNLeIns() {
|
||||
super(0x0d, "ifnle", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new GtTreeItem(ins, v1, v2));
|
||||
}
|
||||
|
||||
public void translateInverted(java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, AVM2Instruction ins) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new LeTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.GeTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.LtTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IfNLtIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfNLtIns() {
|
||||
super(0x0c, "ifnlt", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new GeTreeItem(ins, v1, v2));
|
||||
}
|
||||
|
||||
public void translateInverted(java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, AVM2Instruction ins) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new LtTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.EqTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.NeqTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IfNeIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfNeIns() {
|
||||
super(0x14, "ifne", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new NeqTreeItem(ins, v1, v2));
|
||||
}
|
||||
|
||||
public void translateInverted(java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, AVM2Instruction ins) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new EqTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.StrictEqTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.StrictNeqTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IfStrictEqIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfStrictEqIns() {
|
||||
super(0x19, "ifstricteq", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new StrictEqTreeItem(ins, v1, v2));
|
||||
}
|
||||
|
||||
public void translateInverted(java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, AVM2Instruction ins) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new StrictNeqTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.StrictEqTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.StrictNeqTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IfStrictNeIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfStrictNeIns() {
|
||||
super(0x1A, "ifstrictne", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new StrictNeqTreeItem(ins, v1, v2));
|
||||
}
|
||||
|
||||
public void translateInverted(java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, AVM2Instruction ins) {
|
||||
TreeItem v2 = (TreeItem) stack.pop();
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new StrictEqTreeItem(ins, v1, v2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.NotTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IfTrueIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public IfTrueIns() {
|
||||
super(0x11, "iftrue", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
//String v1 = stack.pop().toString();
|
||||
//stack.push("(" + v1 + ")");
|
||||
}
|
||||
|
||||
public void translateInverted(java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, AVM2Instruction ins) {
|
||||
TreeItem v1 = (TreeItem) stack.pop();
|
||||
stack.push(new NotTreeItem(ins, v1));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.IfTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.BooleanTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class JumpIns extends InstructionDefinition implements IfTypeIns {
|
||||
|
||||
public JumpIns() {
|
||||
super(0x10, "jump", new int[]{AVM2Code.DAT_OFFSET});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
stack.push(new BooleanTreeItem(ins, Boolean.TRUE));// + ins.operands[0]);
|
||||
}
|
||||
|
||||
public void translateInverted(java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, AVM2Instruction ins) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.jumps;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class LookupSwitchIns extends InstructionDefinition {
|
||||
|
||||
public LookupSwitchIns() {
|
||||
super(0x1b, "lookupswitch", new int[]{AVM2Code.DAT_CASE_BASEOFFSET, AVM2Code.OPT_CASE_OFFSETS});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int defaultOffset = ins.operands[0];
|
||||
int caseCount = ins.operands[1];
|
||||
//stack.push("switch(...)");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.DecLocalTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class DecLocalIIns extends InstructionDefinition {
|
||||
|
||||
public DecLocalIIns() {
|
||||
super(0xc3, "declocal_i", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
int locRegIndex = (int) ((Long) arguments.get(0)).longValue();
|
||||
Object obj = lda.localRegisters.get(locRegIndex);
|
||||
if (obj instanceof Long) {
|
||||
Long obj2 = ((Long) obj).longValue() - 1;
|
||||
lda.localRegisters.set(locRegIndex, obj2);
|
||||
} else if (obj instanceof Double) {
|
||||
Double obj2 = ((Double) obj).doubleValue() - 1;
|
||||
lda.localRegisters.set(locRegIndex, obj2);
|
||||
}
|
||||
if (obj instanceof String) {
|
||||
Double obj2 = Double.parseDouble((String) obj) - 1;
|
||||
lda.localRegisters.set(locRegIndex, obj2);
|
||||
} else {
|
||||
throw new RuntimeException("Cannot decrement local register");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int regIndex = ins.operands[0];
|
||||
output.add(new DecLocalTreeItem(ins, regIndex));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.LocalDataArea;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.DecLocalTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class DecLocalIns extends InstructionDefinition {
|
||||
|
||||
public DecLocalIns() {
|
||||
super(0x94, "declocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(LocalDataArea lda, ConstantPool constants, List arguments) {
|
||||
int locRegIndex = (int) ((Long) arguments.get(0)).longValue();
|
||||
Object obj = lda.localRegisters.get(locRegIndex);
|
||||
if (obj instanceof Long) {
|
||||
Long obj2 = ((Long) obj).longValue() - 1;
|
||||
lda.localRegisters.set(locRegIndex, obj2);
|
||||
} else if (obj instanceof Double) {
|
||||
Double obj2 = ((Double) obj).doubleValue() - 1;
|
||||
lda.localRegisters.set(locRegIndex, obj2);
|
||||
}
|
||||
if (obj instanceof String) {
|
||||
Double obj2 = Double.parseDouble((String) obj) - 1;
|
||||
lda.localRegisters.set(locRegIndex, obj2);
|
||||
} else {
|
||||
throw new RuntimeException("Cannot decrement local register");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int regIndex = ins.operands[0];
|
||||
output.add(new DecLocalTreeItem(ins, regIndex));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.ClassTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.ThisTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class GetLocal0Ins extends InstructionDefinition implements GetLocalTypeIns {
|
||||
|
||||
public GetLocal0Ins() {
|
||||
super(0xd0, "getlocal_0", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
if (isStatic) {
|
||||
stack.push(new ClassTreeItem(abc.instance_info[classIndex].getName(constants).getName(constants)));
|
||||
} else {
|
||||
stack.push(new ThisTreeItem());
|
||||
}
|
||||
}
|
||||
|
||||
public int getRegisterId(AVM2Instruction par0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.LocalRegTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class GetLocal1Ins extends InstructionDefinition implements GetLocalTypeIns {
|
||||
|
||||
public GetLocal1Ins() {
|
||||
super(0xd1, "getlocal_1", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
stack.push(new LocalRegTreeItem(ins, 1, localRegs.get(1)));
|
||||
}
|
||||
|
||||
public int getRegisterId(AVM2Instruction par0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.LocalRegTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class GetLocal2Ins extends InstructionDefinition implements GetLocalTypeIns {
|
||||
|
||||
public GetLocal2Ins() {
|
||||
super(0xd2, "getlocal_2", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
stack.push(new LocalRegTreeItem(ins, 2, localRegs.get(2)));
|
||||
}
|
||||
|
||||
public int getRegisterId(AVM2Instruction par0) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.LocalRegTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class GetLocal3Ins extends InstructionDefinition implements GetLocalTypeIns {
|
||||
|
||||
public GetLocal3Ins() {
|
||||
super(0xd3, "getlocal_3", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
stack.push(new LocalRegTreeItem(ins, 3, localRegs.get(3)));
|
||||
}
|
||||
|
||||
public int getRegisterId(AVM2Instruction par0) {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.LocalRegTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class GetLocalIns extends InstructionDefinition implements GetLocalTypeIns {
|
||||
|
||||
public GetLocalIns() {
|
||||
super(0x62, "getlocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int regIndex = ins.operands[0];
|
||||
stack.push(new LocalRegTreeItem(ins, regIndex, localRegs.get(regIndex)));
|
||||
}
|
||||
|
||||
public int getRegisterId(AVM2Instruction ins) {
|
||||
return ins.operands[0];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
|
||||
|
||||
public interface GetLocalTypeIns {
|
||||
public abstract int getRegisterId(AVM2Instruction ins);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.IncLocalTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IncLocalIIns extends InstructionDefinition {
|
||||
|
||||
public IncLocalIIns() {
|
||||
super(0xc2, "inclocal_i", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int regIndex = ins.operands[0];
|
||||
output.add(new IncLocalTreeItem(ins, regIndex));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.IncLocalTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class IncLocalIns extends InstructionDefinition {
|
||||
|
||||
public IncLocalIns() {
|
||||
super(0x92, "inclocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
int regIndex = ins.operands[0];
|
||||
output.add(new IncLocalTreeItem(ins, regIndex));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class KillIns extends InstructionDefinition {
|
||||
|
||||
public KillIns() {
|
||||
super(0x08, "kill", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
//kill local register
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.SetTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.FindPropertyTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.NewActivationTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.SetLocalTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class SetLocal0Ins extends InstructionDefinition implements SetTypeIns, SetLocalTypeIns {
|
||||
|
||||
public SetLocal0Ins() {
|
||||
super(0xd4, "setlocal_0", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem val = (TreeItem) stack.pop();
|
||||
localRegs.put(0, val);
|
||||
if (val instanceof NewActivationTreeItem) return;
|
||||
if (val instanceof FindPropertyTreeItem) return;
|
||||
//if(val.startsWith("catchscope ")) return;
|
||||
//if(val.startsWith("newactivation()")) return;
|
||||
output.add(new SetLocalTreeItem(ins, 0, val));
|
||||
}
|
||||
|
||||
public String getObject(Stack<TreeItem> stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body) {
|
||||
return localRegName(0);
|
||||
}
|
||||
|
||||
public int getRegisterId(AVM2Instruction ins) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.SetTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.FindPropertyTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.NewActivationTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.SetLocalTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class SetLocal1Ins extends InstructionDefinition implements SetTypeIns, SetLocalTypeIns {
|
||||
|
||||
public SetLocal1Ins() {
|
||||
super(0xd5, "setlocal_1", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem val = (TreeItem) stack.pop();
|
||||
localRegs.put(1, val);
|
||||
if (val instanceof NewActivationTreeItem) return;
|
||||
if (val instanceof FindPropertyTreeItem) return;
|
||||
//if(val.startsWith("catchscope ")) return;
|
||||
//if(val.startsWith("newactivation()")) return;
|
||||
output.add(new SetLocalTreeItem(ins, 1, val));
|
||||
}
|
||||
|
||||
public String getObject(Stack<TreeItem> stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body) {
|
||||
return localRegName(1);
|
||||
}
|
||||
|
||||
public int getRegisterId(AVM2Instruction ins) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.SetTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.FindPropertyTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.NewActivationTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.SetLocalTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class SetLocal2Ins extends InstructionDefinition implements SetTypeIns, SetLocalTypeIns {
|
||||
|
||||
public SetLocal2Ins() {
|
||||
super(0xd6, "setlocal_2", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem val = (TreeItem) stack.pop();
|
||||
localRegs.put(2, val);
|
||||
if (val instanceof NewActivationTreeItem) return;
|
||||
if (val instanceof FindPropertyTreeItem) return;
|
||||
//if(val.startsWith("catchscope ")) return;
|
||||
//if(val.startsWith("newactivation()")) return;
|
||||
output.add(new SetLocalTreeItem(ins, 2, val));
|
||||
}
|
||||
|
||||
public String getObject(Stack<TreeItem> stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body) {
|
||||
return localRegName(2);
|
||||
}
|
||||
|
||||
public int getRegisterId(AVM2Instruction ins) {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.SetTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.FindPropertyTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.NewActivationTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.SetLocalTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class SetLocal3Ins extends InstructionDefinition implements SetTypeIns, SetLocalTypeIns {
|
||||
|
||||
public SetLocal3Ins() {
|
||||
super(0xd7, "setlocal_3", new int[]{});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem val = (TreeItem) stack.pop();
|
||||
localRegs.put(3, val);
|
||||
if (val instanceof NewActivationTreeItem) return;
|
||||
if (val instanceof FindPropertyTreeItem) return;
|
||||
//if(val.startsWith("catchscope ")) return;
|
||||
//if(val.startsWith("newactivation()")) return;
|
||||
output.add(new SetLocalTreeItem(ins, 3, val));
|
||||
}
|
||||
|
||||
public String getObject(Stack<TreeItem> stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body) {
|
||||
return localRegName(3);
|
||||
}
|
||||
|
||||
public int getRegisterId(AVM2Instruction ins) {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2010. JPEXS
|
||||
*/
|
||||
|
||||
package com.jpexs.asdec.abc.avm2.instructions.localregs;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.SetTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.FindPropertyTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.NewActivationTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.SetLocalTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
public class SetLocalIns extends InstructionDefinition implements SetTypeIns, SetLocalTypeIns {
|
||||
|
||||
public SetLocalIns() {
|
||||
super(0x63, "setlocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, java.util.Stack<TreeItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body, com.jpexs.asdec.abc.ABC abc) {
|
||||
TreeItem val = (TreeItem) stack.pop();
|
||||
localRegs.put(ins.operands[0], val);
|
||||
if (val instanceof NewActivationTreeItem) return;
|
||||
if (val instanceof FindPropertyTreeItem) return;
|
||||
//if(val.startsWith("catchscope ")) return;
|
||||
//if(val.startsWith("newactivation()")) return;
|
||||
output.add(new SetLocalTreeItem(ins, ins.operands[0], val));
|
||||
}
|
||||
|
||||
public String getObject(Stack<TreeItem> stack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<TreeItem> output, com.jpexs.asdec.abc.types.MethodBody body) {
|
||||
return localRegName(ins.operands[0]);
|
||||
}
|
||||
|
||||
public int getRegisterId(AVM2Instruction ins) {
|
||||
return ins.operands[0];
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user