mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 12:50:46 +00:00
AS3: Decompiling namespaces
This commit is contained in:
@@ -191,17 +191,17 @@ public class Main {
|
||||
swf = parseSWF(Main.file);
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
DEBUG_COPY = true;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
swf.saveTo(baos);
|
||||
} catch (NotSameException nse) {
|
||||
Logger.getLogger(Main.class.getName()).log(Level.FINE, null, nse);
|
||||
Logger.getLogger(Main.class.getName()).log(Level.FINE, null, nse);
|
||||
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) {
|
||||
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
|
||||
JOptionPane.showMessageDialog(null, "Cannot load SWF file.");
|
||||
loadingDialog.setVisible(false);
|
||||
return false;
|
||||
@@ -213,7 +213,7 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (false) {
|
||||
JOptionPane.showMessageDialog(null, "This SWF file does not contain any ActionScript parts");
|
||||
loadingDialog.setVisible(false);
|
||||
@@ -432,19 +432,19 @@ public class Main {
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
View.setWinLookAndFeel();
|
||||
Configuration.load();
|
||||
int pos=0;
|
||||
if(args.length>0){
|
||||
if(args[0].equals("-debug")){
|
||||
debugMode=true;
|
||||
Configuration.load();
|
||||
int pos = 0;
|
||||
if (args.length > 0) {
|
||||
if (args[0].equals("-debug")) {
|
||||
debugMode = true;
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
initLogging(debugMode);
|
||||
if (args.length < pos+1) {
|
||||
initLogging(debugMode);
|
||||
if (args.length < pos + 1) {
|
||||
autoCheckForUpdates();
|
||||
showModeFrame();
|
||||
}else {
|
||||
} else {
|
||||
if (args[pos].equals("-proxy")) {
|
||||
int port = 55555;
|
||||
for (int i = pos; i < args.length; i++) {
|
||||
@@ -463,18 +463,18 @@ public class Main {
|
||||
addTrayIcon();
|
||||
switchProxy();
|
||||
} else if (args[pos].equals("-export")) {
|
||||
if (args.length < pos+4) {
|
||||
if (args.length < pos + 4) {
|
||||
badArguments();
|
||||
}
|
||||
String exportFormat = args[pos+1];
|
||||
String exportFormat = args[pos + 1];
|
||||
if (!exportFormat.toLowerCase().equals("as")) {
|
||||
if (!exportFormat.toLowerCase().equals("pcode")) {
|
||||
System.err.println("Invalid export format:" + exportFormat);
|
||||
badArguments();
|
||||
}
|
||||
}
|
||||
File outDir = new File(args[pos+2]);
|
||||
File inFile = new File(args[pos+3]);
|
||||
File outDir = new File(args[pos + 2]);
|
||||
File inFile = new File(args[pos + 3]);
|
||||
if (!inFile.exists()) {
|
||||
System.err.println("Input SWF file does not exist!");
|
||||
badArguments();
|
||||
@@ -506,11 +506,11 @@ public class Main {
|
||||
System.exit(1);
|
||||
}
|
||||
} else if (args[pos].equals("-compress")) {
|
||||
if (args.length < pos+3) {
|
||||
if (args.length < pos + 3) {
|
||||
badArguments();
|
||||
}
|
||||
|
||||
if (SWF.fws2cws(new FileInputStream(args[pos+1]), new FileOutputStream(args[pos+2]))) {
|
||||
if (SWF.fws2cws(new FileInputStream(args[pos + 1]), new FileOutputStream(args[pos + 2]))) {
|
||||
System.out.println("OK");
|
||||
} else {
|
||||
System.err.println("FAIL");
|
||||
@@ -520,7 +520,7 @@ public class Main {
|
||||
badArguments();
|
||||
}
|
||||
|
||||
if (SWF.cws2fws(new FileInputStream(args[pos+1]), new FileOutputStream(args[pos+2]))) {
|
||||
if (SWF.cws2fws(new FileInputStream(args[pos + 1]), new FileOutputStream(args[pos + 2]))) {
|
||||
System.out.println("OK");
|
||||
System.exit(0);
|
||||
} else {
|
||||
@@ -533,9 +533,9 @@ public class Main {
|
||||
}
|
||||
try {
|
||||
dump_tags = true;
|
||||
parseSWF(args[pos+1]);
|
||||
parseSWF(args[pos + 1]);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
|
||||
System.exit(1);
|
||||
}
|
||||
System.exit(0);
|
||||
@@ -543,7 +543,7 @@ public class Main {
|
||||
printHeader();
|
||||
printCmdLineUsage();
|
||||
System.exit(0);
|
||||
} else if (args.length == pos+1) {
|
||||
} else if (args.length == pos + 1) {
|
||||
autoCheckForUpdates();
|
||||
openFile(args[pos]);
|
||||
} else {
|
||||
@@ -734,15 +734,15 @@ public class Main {
|
||||
public static void initLogging(boolean debug) {
|
||||
try {
|
||||
Logger logger = Logger.getLogger("");
|
||||
logger.setLevel(debug?Level.CONFIG:Level.WARNING);
|
||||
logger.setLevel(debug ? Level.CONFIG : Level.WARNING);
|
||||
FileHandler fileTxt = new FileHandler("log.txt");
|
||||
|
||||
SimpleFormatter formatterTxt = new SimpleFormatter();
|
||||
fileTxt.setFormatter(formatterTxt);
|
||||
logger.addHandler(fileTxt);
|
||||
|
||||
if(debug){
|
||||
ConsoleHandler conHan=new ConsoleHandler();
|
||||
|
||||
if (debug) {
|
||||
ConsoleHandler conHan = new ConsoleHandler();
|
||||
conHan.setFormatter(formatterTxt);
|
||||
logger.addHandler(conHan);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.jpexs.asdec.helpers.Helper;
|
||||
import com.jpexs.asdec.helpers.Highlighting;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -59,9 +60,8 @@ public class ABC {
|
||||
public static final int MINORwithDECIMAL = 17;
|
||||
public static final boolean AUTOINIT_STATIC_VARIABLES = false;
|
||||
protected HashSet<EventListener> listeners = new HashSet<EventListener>();
|
||||
private static Logger logger = Logger.getLogger(ABC.class.getName());
|
||||
|
||||
private static Logger logger =Logger.getLogger(ABC.class.getName());
|
||||
|
||||
public void addEventListener(EventListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public class ABC {
|
||||
}
|
||||
|
||||
public ABC(InputStream is) throws IOException {
|
||||
ABCInputStream ais = new ABCInputStream(is);
|
||||
ABCInputStream ais = new ABCInputStream(is);
|
||||
minor_version = ais.readU16();
|
||||
major_version = ais.readU16();
|
||||
logger.log(Level.FINE, "ABC minor_version: {0}, major_version: {1}", new Object[]{minor_version, major_version});
|
||||
@@ -101,7 +101,7 @@ public class ABC {
|
||||
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();
|
||||
constants.constant_int[i] = ais.readS32();
|
||||
}
|
||||
|
||||
//constant unsigned integers
|
||||
@@ -254,11 +254,12 @@ public class ABC {
|
||||
method_info[mb.method_info].setBody(mb);
|
||||
bodyIdxFromMethodIdx[mb.method_info] = i;
|
||||
}
|
||||
|
||||
loadNamespaceMap();
|
||||
/*for(ScriptInfo si:script_info){
|
||||
System.out.println("--------------------------------------------");
|
||||
System.out.println(findBody(si.init_index).toString(true, false, -1, this, constants, method_info,new Stack<TreeItem>()));
|
||||
}*/
|
||||
System.out.println("sitrait:"+si.traits.toString(this));
|
||||
}*/
|
||||
}
|
||||
|
||||
public void saveToStream(OutputStream os) throws IOException {
|
||||
@@ -573,6 +574,51 @@ public class ABC {
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Map from multiname index of namespace value to namespace name**/
|
||||
private HashMap<Integer, Integer> namespaceMap;
|
||||
|
||||
private void loadNamespaceMap() {
|
||||
namespaceMap = new HashMap<Integer, Integer>();
|
||||
for (ScriptInfo si : script_info) {
|
||||
for (Trait t : si.traits.traits) {
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst s = ((TraitSlotConst) t);
|
||||
if (s.value_kind == ValueKind.CONSTANT_Namespace) {
|
||||
namespaceMap.put(s.value_index, s.name_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int nsValueToName(int value_index) {
|
||||
if (namespaceMap.containsKey(value_index)) {
|
||||
return namespaceMap.get(value_index);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<String, String> namespacesToString() {
|
||||
HashMap<String, String> ret = new HashMap<String, String>();
|
||||
for (Integer value_index : namespaceMap.keySet()) {
|
||||
int name_index = namespaceMap.get(value_index);
|
||||
String n = "";
|
||||
String packageName = constants.constant_multiname[name_index].getNamespace(constants).getName(constants);
|
||||
n += ("package " + packageName + "\r\n");
|
||||
n += ("{\r\n");
|
||||
Namespace ns = constants.constant_multiname[name_index].getNamespace(constants);
|
||||
String modifiers = ns.getPrefix(this);
|
||||
if (!modifiers.equals("")) {
|
||||
modifiers += " ";
|
||||
}
|
||||
String nsname = constants.constant_multiname[name_index].getName(constants);
|
||||
n += IDENT_STRING + modifiers + "namespace " + nsname + "=\"" + Helper.escapeString(constants.constant_namespace[value_index].getName(constants)) + "\";\r\n";
|
||||
n += ("}\r\n");
|
||||
ret.put(packageName + "." + nsname, n);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String classToString(int i, boolean highlight, boolean pcode) {
|
||||
if (!highlight) {
|
||||
@@ -593,7 +639,7 @@ public class ABC {
|
||||
out.println();
|
||||
|
||||
//class header
|
||||
String classHeader = instance_info[i].getClassHeaderStr(constants);
|
||||
String classHeader = instance_info[i].getClassHeaderStr(this);
|
||||
/*if (classHeader.startsWith("private ")) {
|
||||
classHeader = "public " + classHeader.substring("private ".length());
|
||||
}*/
|
||||
@@ -653,7 +699,7 @@ public class ABC {
|
||||
if (m != null) {
|
||||
Namespace ns = m.getNamespace(constants);
|
||||
if (ns != null) {
|
||||
modifier = ns.getPrefix(constants) + " ";
|
||||
modifier = ns.getPrefix(this) + " ";
|
||||
if (modifier.equals(" ")) {
|
||||
modifier = "";
|
||||
}
|
||||
@@ -687,12 +733,12 @@ public class ABC {
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = addTabs(bodies[bodyIndex].toString(pcode, true, i, this, constants, method_info, new Stack<TreeItem>(), highlight), 3);
|
||||
}
|
||||
toPrint = IDENT_STRING + IDENT_STRING + tm.convert(constants, method_info, this, true) + " {\r\n" + bodyStr + "\r\n" + IDENT_STRING + IDENT_STRING + "}";
|
||||
toPrint = IDENT_STRING + IDENT_STRING + tm.convert(method_info, this, 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, this, true) + ";";
|
||||
toPrint = IDENT_STRING + IDENT_STRING + ts.convert(method_info, this, true) + ";";
|
||||
}
|
||||
if (highlight) {
|
||||
toPrint = Highlighting.hilighTrait(toPrint, ti);
|
||||
@@ -706,7 +752,7 @@ public class ABC {
|
||||
toPrint = "";
|
||||
if (t instanceof TraitSlotConst) {
|
||||
TraitSlotConst ts = (TraitSlotConst) t;
|
||||
toPrint = IDENT_STRING + IDENT_STRING + ts.convert(constants, method_info, this, false) + ";";
|
||||
toPrint = IDENT_STRING + IDENT_STRING + ts.convert(method_info, this, false) + ";";
|
||||
}
|
||||
|
||||
if (t instanceof TraitMethodGetterSetter) {
|
||||
@@ -716,7 +762,7 @@ public class ABC {
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = addTabs(bodies[bodyIndex].toString(pcode, false, i, this, constants, method_info, new Stack<TreeItem>(), highlight), 3);
|
||||
}
|
||||
toPrint = IDENT_STRING + IDENT_STRING + tm.convert(constants, method_info, this, false) + " {\r\n" + bodyStr + "\r\n" + IDENT_STRING + IDENT_STRING + "}";
|
||||
toPrint = IDENT_STRING + IDENT_STRING + tm.convert(method_info, this, false) + " {\r\n" + bodyStr + "\r\n" + IDENT_STRING + IDENT_STRING + "}";
|
||||
}
|
||||
if (highlight) {
|
||||
toPrint = Highlighting.hilighTrait(toPrint, class_info[i].static_traits.traits.length + ti);
|
||||
@@ -742,7 +788,7 @@ public class ABC {
|
||||
if ((packageName != null) && (!packageName.equals(""))) {
|
||||
fullName = packageName + "." + fullName;
|
||||
}
|
||||
String exStr="Exporting " + (i + 1) + "/" + instance_info.length + " " + fullName + " ...";
|
||||
String exStr = "Exporting " + (i + 1) + "/" + instance_info.length + " " + fullName + " ...";
|
||||
informListeners("export", exStr);
|
||||
logger.info(exStr);
|
||||
File outDir = new File(directory + File.separatorChar + packageName.replace('.', File.separatorChar));
|
||||
@@ -754,6 +800,20 @@ public class ABC {
|
||||
fos.write(classToString(i, false, pcode).getBytes());
|
||||
fos.close();
|
||||
}
|
||||
informListeners("export", "Exporting namespaces...");
|
||||
HashMap<String, String> ns = namespacesToString();
|
||||
for (String n : ns.keySet()) {
|
||||
String nsName = n.substring(n.lastIndexOf(".") + 1);
|
||||
String packageName = n.substring(0, n.lastIndexOf("."));
|
||||
File outDir = new File(directory + File.separatorChar + packageName.replace('.', File.separatorChar));
|
||||
if (!outDir.exists()) {
|
||||
outDir.mkdirs();
|
||||
}
|
||||
String fileName = outDir.toString() + File.separator + nsName + ".as";
|
||||
FileOutputStream fos = new FileOutputStream(fileName);
|
||||
fos.write(n.getBytes());
|
||||
fos.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.jpexs.asdec.abc.avm2;
|
||||
|
||||
import com.jpexs.asdec.Main;
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.ABCInputStream;
|
||||
import com.jpexs.asdec.abc.CopyOutputStream;
|
||||
@@ -1491,7 +1490,7 @@ public class AVM2Code {
|
||||
ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames);
|
||||
}
|
||||
ip++;
|
||||
break;
|
||||
break;
|
||||
//}
|
||||
|
||||
} else {
|
||||
@@ -1598,7 +1597,7 @@ public class AVM2Code {
|
||||
if (ex instanceof UnknownJumpException) {
|
||||
throw (UnknownJumpException) ex;
|
||||
}
|
||||
Logger.getLogger(AVM2Code.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(AVM2Code.class.getName()).log(Level.SEVERE, null, ex);
|
||||
throw new ConvertException(ex.getClass().getSimpleName(), ip);
|
||||
}
|
||||
}
|
||||
@@ -1749,7 +1748,7 @@ public class AVM2Code {
|
||||
|
||||
s = listToString(list, constants, localRegNames);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(AVM2Code.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(AVM2Code.class.getName()).log(Level.SEVERE, null, ex);
|
||||
s = "/*\r\n * Decompilation error\r\n * Code may be obfuscated\r\n * Error Message: " + ex.getMessage() + "\r\n */";
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ public class ConstructIns extends InstructionDefinition {
|
||||
@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();*/
|
||||
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
|
||||
|
||||
@@ -40,11 +40,11 @@ public class ConstructPropIns extends InstructionDefinition {
|
||||
@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());
|
||||
}*/
|
||||
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");
|
||||
|
||||
@@ -39,11 +39,11 @@ public class ConstructSuperIns extends InstructionDefinition {
|
||||
@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();*/
|
||||
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
|
||||
|
||||
@@ -39,12 +39,12 @@ public class CallIns extends InstructionDefinition {
|
||||
@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();*/
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -39,12 +39,12 @@ public class CallMethodIns extends InstructionDefinition {
|
||||
@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();*/
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -41,15 +41,15 @@ public class CallPropVoidIns extends InstructionDefinition {
|
||||
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();*/
|
||||
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
|
||||
}
|
||||
|
||||
@@ -40,14 +40,14 @@ public class CallPropertyIns extends InstructionDefinition {
|
||||
@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();*/
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -39,12 +39,12 @@ public class CallStaticIns extends InstructionDefinition {
|
||||
@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();*/
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -40,14 +40,14 @@ public class CallSuperIns extends InstructionDefinition {
|
||||
@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();*/
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -40,14 +40,14 @@ public class CallSuperVoidIns extends InstructionDefinition {
|
||||
@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();*/
|
||||
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
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ConvertBIns extends InstructionDefinition implements CoerceOrConver
|
||||
} else {
|
||||
bval = true;
|
||||
}
|
||||
lda.operandStack.push((Boolean)bval);
|
||||
lda.operandStack.push((Boolean) bval);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -62,20 +62,29 @@ public class ClassesListTree extends JTree implements TreeSelectionListener {
|
||||
if (tp == null) {
|
||||
return;
|
||||
}
|
||||
final int classIndex = tp.getClassIndex();
|
||||
if (classIndex != -1) {
|
||||
if (!Main.isWorking()) {
|
||||
Main.startWork("Decompiling class...");
|
||||
(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
Main.abcMainFrame.navigator.setClassIndex(classIndex);
|
||||
Main.abcMainFrame.decompiledTextArea.setClassIndex(classIndex, abc);
|
||||
Main.abcMainFrame.detailPanel.methodTraitPanel.methodCodePanel.sourceTextArea.setText("");
|
||||
Main.stopWork();
|
||||
}
|
||||
}).start();
|
||||
Object item = tp.getItem();
|
||||
if (item instanceof TreeLeafString) {
|
||||
Main.abcMainFrame.navigator.setClassIndex(-1);
|
||||
Main.abcMainFrame.decompiledTextArea.setClassIndex(-1, abc);
|
||||
Main.abcMainFrame.decompiledTextArea.setText(((TreeLeafString) item).str);
|
||||
}
|
||||
if (item instanceof TreeLeafClass) {
|
||||
final int classIndex = ((TreeLeafClass) item).classIndex;
|
||||
if (classIndex != -1) {
|
||||
if (!Main.isWorking()) {
|
||||
Main.startWork("Decompiling class...");
|
||||
(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
Main.abcMainFrame.navigator.setClassIndex(classIndex);
|
||||
Main.abcMainFrame.decompiledTextArea.setClassIndex(classIndex, abc);
|
||||
Main.abcMainFrame.detailPanel.methodTraitPanel.methodCodePanel.sourceTextArea.setText("");
|
||||
Main.stopWork();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.asdec.abc.gui;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import java.util.HashMap;
|
||||
import javax.swing.event.TreeModelListener;
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
@@ -24,20 +25,20 @@ import javax.swing.tree.TreePath;
|
||||
class ClassIndexVisitor implements TreeVisitor {
|
||||
|
||||
private TreeElement found = null;
|
||||
private int classIndex;
|
||||
private Object item;
|
||||
|
||||
public ClassIndexVisitor(int classIndex) {
|
||||
this.classIndex = classIndex;
|
||||
public ClassIndexVisitor(Object item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public void onBranch(TreeElement branch) {
|
||||
if (branch.getClassIndex() == classIndex) {
|
||||
if (branch.getItem() == item) {
|
||||
found = branch;
|
||||
}
|
||||
}
|
||||
|
||||
public void onLeaf(TreeElement leaf) {
|
||||
if (leaf.getClassIndex() == classIndex) {
|
||||
if (leaf.getItem() == item) {
|
||||
found = leaf;
|
||||
}
|
||||
}
|
||||
@@ -57,17 +58,23 @@ public class ClassesListTreeModel implements TreeModel {
|
||||
for (int i = 0; i < abc.instance_info.length; i++) {
|
||||
String packageName = abc.instance_info[i].getName(abc.constants).getNamespace(abc.constants).getName(abc.constants);
|
||||
String className = abc.instance_info[i].getName(abc.constants).getName(abc.constants);
|
||||
String full = packageName + "." + className;
|
||||
classTree.add(className, packageName, i);
|
||||
//String full = packageName + "." + className;
|
||||
classTree.add(className, packageName, new TreeLeafClass(i));
|
||||
}
|
||||
HashMap<String, String> ns = abc.namespacesToString();
|
||||
for (String n : ns.keySet()) {
|
||||
String nsName = n.substring(n.lastIndexOf(".") + 1);
|
||||
String packageName = n.substring(0, n.lastIndexOf("."));
|
||||
classTree.add(nsName, packageName, new TreeLeafString(ns.get(n)));
|
||||
}
|
||||
}
|
||||
|
||||
public int getClassIndexByPath(String fullPath) {
|
||||
public Object getItemByPath(String fullPath) {
|
||||
TreeElement elem = classTree.get(fullPath);
|
||||
if (elem == null) {
|
||||
return -1;
|
||||
}
|
||||
return elem.getClassIndex();
|
||||
return elem.getItem();
|
||||
}
|
||||
|
||||
public TreeElement getElementByClassIndex(int classIndex) {
|
||||
|
||||
@@ -143,6 +143,13 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements MouseL
|
||||
|
||||
public void setClassIndex(int index, ABC abc) {
|
||||
setText("//Please wait...");
|
||||
if (index == -1) {
|
||||
highlights = new ArrayList<Highlighting>();
|
||||
traitHighlights = new ArrayList<Highlighting>();
|
||||
methodHighlights = new ArrayList<Highlighting>();
|
||||
classIndex = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
String hilightedCode;
|
||||
if (!bufferedClasses.containsKey(index)) {
|
||||
|
||||
@@ -392,8 +392,8 @@ public class MainFrame extends JFrame implements ActionListener, ItemListener {
|
||||
try {
|
||||
Main.saveFile(Main.file);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
|
||||
JOptionPane.showMessageDialog(null, "Cannot save file","Error",JOptionPane.ERROR_MESSAGE);
|
||||
Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
|
||||
JOptionPane.showMessageDialog(null, "Cannot save file", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
if (e.getActionCommand().equals("SAVEAS")) {
|
||||
|
||||
@@ -39,8 +39,12 @@ public class TraitsList extends JList implements ListSelectionListener {
|
||||
}
|
||||
|
||||
public void setClassIndex(int classIndex) {
|
||||
if (abc != null) {
|
||||
setModel(new TraitsListModel(abc, classIndex));
|
||||
if (classIndex == -1) {
|
||||
setModel(new DefaultListModel());
|
||||
} else {
|
||||
if (abc != null) {
|
||||
setModel(new TraitsListModel(abc, classIndex));
|
||||
}
|
||||
}
|
||||
this.classIndex = classIndex;
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ public class TraitsListModel implements ListModel {
|
||||
|
||||
public Object getElementAt(int index) {
|
||||
if (index < abc.class_info[classIndex].static_traits.traits.length) {
|
||||
return abc.class_info[classIndex].static_traits.traits[index].convert(abc.constants, abc.method_info, abc, true);
|
||||
return abc.class_info[classIndex].static_traits.traits[index].convert(abc.method_info, abc, true);
|
||||
} else if (index < abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length) {
|
||||
return abc.instance_info[classIndex].instance_traits.traits[index - abc.class_info[classIndex].static_traits.traits.length].convert(abc.constants, abc.method_info, abc, false);
|
||||
return abc.instance_info[classIndex].instance_traits.traits[index - abc.class_info[classIndex].static_traits.traits.length].convert(abc.method_info, abc, false);
|
||||
} else if (index == abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length) {
|
||||
return STR_INSTANCE_INITIALIZER;
|
||||
} else {
|
||||
|
||||
@@ -22,14 +22,14 @@ public class Tree {
|
||||
|
||||
private final TreeElement ROOT = new TreeElement("", "", -1, null);
|
||||
|
||||
public void add(String name, String path, int classIndex) {
|
||||
public void add(String name, String path, Object item) {
|
||||
StringTokenizer st = new StringTokenizer(path, ".");
|
||||
TreeElement parent = ROOT;
|
||||
while (st.hasMoreTokens()) {
|
||||
String pathElement = st.nextToken();
|
||||
parent = parent.getBranch(pathElement);
|
||||
}
|
||||
parent.addLeaf(name, classIndex);
|
||||
parent.addLeaf(name, item);
|
||||
}
|
||||
|
||||
public TreeElement getRoot() {
|
||||
|
||||
@@ -25,13 +25,13 @@ public class TreeElement {
|
||||
private SortedMap<String, TreeElement> leafs;
|
||||
private String name;
|
||||
private String path;
|
||||
private int classIndex;
|
||||
private Object item;
|
||||
private TreeElement parent;
|
||||
|
||||
public TreeElement(String name, String path, int classIndex, TreeElement parent) {
|
||||
public TreeElement(String name, String path, Object item, TreeElement parent) {
|
||||
this.name = name;
|
||||
this.path = path;
|
||||
this.classIndex = classIndex;
|
||||
this.item = item;
|
||||
this.parent = parent;
|
||||
branches = new TreeMap<String, TreeElement>();
|
||||
leafs = new TreeMap<String, TreeElement>();
|
||||
@@ -58,8 +58,8 @@ public class TreeElement {
|
||||
return new TreePath(pathList.toArray());
|
||||
}
|
||||
|
||||
public int getClassIndex() {
|
||||
return classIndex;
|
||||
public Object getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,8 +76,8 @@ public class TreeElement {
|
||||
return branch;
|
||||
}
|
||||
|
||||
void addLeaf(String pathElement, int classIndex) {
|
||||
TreeElement child = new TreeElement(pathElement, path + "." + pathElement, classIndex, this);
|
||||
void addLeaf(String pathElement, Object item) {
|
||||
TreeElement child = new TreeElement(pathElement, path + "." + pathElement, item, this);
|
||||
leafs.put(pathElement, child);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2012 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.asdec.abc.gui;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TreeLeafClass {
|
||||
|
||||
public int classIndex;
|
||||
|
||||
public TreeLeafClass(int classIndex) {
|
||||
this.classIndex = classIndex;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2012 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.asdec.abc.gui;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TreeLeafString {
|
||||
|
||||
public String str;
|
||||
|
||||
public TreeLeafString(String str) {
|
||||
this.str = str;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.abc.types;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.types.traits.Traits;
|
||||
|
||||
public class ClassInfo {
|
||||
@@ -34,7 +33,7 @@ public class ClassInfo {
|
||||
return "method_index=" + cinit_index + "\r\n" + static_traits.toString(abc);
|
||||
}
|
||||
|
||||
public String getStaticVarsStr(ConstantPool constants, ABC abc) {
|
||||
return static_traits.convert(constants, "\tstatic ", abc);
|
||||
public String getStaticVarsStr(ABC abc) {
|
||||
return static_traits.convert("\tstatic ", abc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,19 +43,19 @@ public class InstanceInfo {
|
||||
public String toString(ABC abc) {
|
||||
String supIndexStr = "[nothing]";
|
||||
if (super_index > 0) {
|
||||
abc.constants.constant_multiname[super_index].toString(abc.constants);
|
||||
supIndexStr = abc.constants.constant_multiname[super_index].toString(abc.constants);
|
||||
}
|
||||
return "name_index=" + abc.constants.constant_multiname[name_index].toString(abc.constants) + " super_index=" + supIndexStr + " flags=" + flags + " protectedNS=" + protectedNS + " interfaces=" + Helper.intArrToString(interfaces) + " method_index=" + iinit_index + "\r\n" + instance_traits.toString(abc);
|
||||
}
|
||||
|
||||
public String getClassHeaderStr(ConstantPool constants) {
|
||||
public String getClassHeaderStr(ABC abc) {
|
||||
String supIndexStr = "";
|
||||
if (super_index > 0) {
|
||||
supIndexStr = " extends " + constants.constant_multiname[super_index].getName(constants);////+" flags="+flags+" protectedNS="+protectedNS+" interfaces="+Helper.intArrToString(interfaces)+" method_index="+iinit_index
|
||||
supIndexStr = " extends " + abc.constants.constant_multiname[super_index].getName(abc.constants);////+" flags="+flags+" protectedNS="+protectedNS+" interfaces="+Helper.intArrToString(interfaces)+" method_index="+iinit_index
|
||||
}
|
||||
String modifiers;
|
||||
Namespace ns = constants.constant_multiname[name_index].getNamespace(constants);
|
||||
modifiers = ns.getPrefix(constants);
|
||||
Namespace ns = abc.constants.constant_multiname[name_index].getNamespace(abc.constants);
|
||||
modifiers = ns.getPrefix(abc);
|
||||
if (!modifiers.equals("")) {
|
||||
modifiers += " ";
|
||||
}
|
||||
@@ -70,11 +70,11 @@ public class InstanceInfo {
|
||||
if ((flags & CLASS_INTERFACE) == CLASS_INTERFACE) {
|
||||
objType = "interface ";
|
||||
}
|
||||
return modifiers + objType + constants.constant_multiname[name_index].getName(constants) + supIndexStr;
|
||||
return modifiers + objType + abc.constants.constant_multiname[name_index].getName(abc.constants) + supIndexStr;
|
||||
}
|
||||
|
||||
public String getInstanceVarsStr(ConstantPool constants, ABC abc) {
|
||||
return instance_traits.convert(constants, "\t", abc);
|
||||
public String getInstanceVarsStr(ABC abc) {
|
||||
return instance_traits.convert("\t", abc);
|
||||
}
|
||||
|
||||
public Multiname getName(ConstantPool constants) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.asdec.abc.types;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
|
||||
public class Namespace {
|
||||
@@ -58,7 +59,7 @@ public class Namespace {
|
||||
return kindStr + (nameStr.equals("") ? "" : " " + nameStr);
|
||||
}
|
||||
|
||||
public String getPrefix(ConstantPool constants) {
|
||||
public String getPrefix(ABC abc) {
|
||||
String kindStr = "?";
|
||||
for (int k = 0; k < nameSpaceKinds.length; k++) {
|
||||
if (nameSpaceKinds[k] == kind) {
|
||||
|
||||
@@ -42,16 +42,20 @@ public class Trait {
|
||||
public static final int TRAIT_FUNCTION = 5;
|
||||
public static final int TRAIT_CONST = 6;
|
||||
|
||||
public String getModifiers(ConstantPool constants, boolean isStatic) {
|
||||
public String getModifiers(ABC abc, boolean isStatic) {
|
||||
String ret = "";
|
||||
if ((kindFlags & ATTR_Override) > 0) {
|
||||
ret += "override";
|
||||
}
|
||||
Multiname m = getMultiName(constants);
|
||||
Multiname m = getMultiName(abc.constants);
|
||||
if (m != null) {
|
||||
Namespace ns = m.getNamespace(constants);
|
||||
int v = abc.nsValueToName(m.namespace_index);
|
||||
if (v > -1) {
|
||||
ret += " " + abc.constants.constant_multiname[v].getName(abc.constants);
|
||||
}
|
||||
Namespace ns = m.getNamespace(abc.constants);
|
||||
if (ns != null) {
|
||||
ret += " " + ns.getPrefix(constants);
|
||||
ret += " " + ns.getPrefix(abc);
|
||||
}
|
||||
}
|
||||
if (isStatic) {
|
||||
@@ -74,12 +78,12 @@ public class Trait {
|
||||
return abc.constants.constant_multiname[name_index].toString(abc.constants) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata);
|
||||
}
|
||||
|
||||
public String convert(ConstantPool constants, MethodInfo[] methodInfo, ABC abc) {
|
||||
return convert(constants, methodInfo, abc, false);
|
||||
public String convert(MethodInfo[] methodInfo, ABC abc) {
|
||||
return convert(methodInfo, abc, false);
|
||||
}
|
||||
|
||||
public String convert(ConstantPool constants, MethodInfo[] methodInfo, ABC abc, boolean isStatic) {
|
||||
return constants.constant_multiname[name_index].toString(constants) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata);
|
||||
public String convert(MethodInfo[] methodInfo, ABC abc, boolean isStatic) {
|
||||
return abc.constants.constant_multiname[name_index].toString(abc.constants) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata);
|
||||
}
|
||||
|
||||
public Multiname getMultiName(ConstantPool constants) {
|
||||
|
||||
@@ -33,8 +33,8 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convert(ConstantPool constants, MethodInfo[] methodInfo, ABC abc, boolean isStatic) {
|
||||
String modifier = getModifiers(constants, isStatic) + " ";
|
||||
public String convert(MethodInfo[] methodInfo, ABC abc, boolean isStatic) {
|
||||
String modifier = getModifiers(abc, isStatic) + " ";
|
||||
if (modifier.equals(" ")) {
|
||||
modifier = "";
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
addKind = "set ";
|
||||
}
|
||||
MethodBody body = abc.findBody(method_info);
|
||||
return modifier + "function " + addKind + getMethodName(constants) + "(" + methodInfo[method_info].getParamStr(constants, body, abc) + ") : " + methodInfo[method_info].getReturnTypeStr(constants);
|
||||
return modifier + "function " + addKind + getMethodName(abc.constants) + "(" + methodInfo[method_info].getParamStr(abc.constants, body, abc) + ") : " + methodInfo[method_info].getReturnTypeStr(abc.constants);
|
||||
}
|
||||
|
||||
public String getMethodName(ConstantPool constants) {
|
||||
|
||||
@@ -74,12 +74,12 @@ public class TraitSlotConst extends Trait {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convert(ConstantPool constants, MethodInfo[] methodInfo, ABC abc, boolean isStatic) {
|
||||
String modifier = getModifiers(constants, isStatic) + " ";
|
||||
public String convert(MethodInfo[] methodInfo, ABC abc, boolean isStatic) {
|
||||
String modifier = getModifiers(abc, isStatic) + " ";
|
||||
if (modifier.equals(" ")) {
|
||||
modifier = "";
|
||||
}
|
||||
return modifier + getNameValueStr(constants);
|
||||
return modifier + getNameValueStr(abc.constants);
|
||||
}
|
||||
|
||||
public boolean isConst() {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.abc.types.traits;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
|
||||
public class Traits {
|
||||
|
||||
@@ -46,13 +45,13 @@ public class Traits {
|
||||
return s;
|
||||
}
|
||||
|
||||
public String convert(ConstantPool constants, String prefix, ABC abc) {
|
||||
public String convert(String prefix, ABC abc) {
|
||||
String s = "";
|
||||
for (int t = 0; t < traits.length; t++) {
|
||||
if (t > 0) {
|
||||
s += "\r\n";
|
||||
}
|
||||
s += prefix + traits[t].convert(constants, null, abc);
|
||||
s += prefix + traits[t].convert(null, abc);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -36,10 +36,10 @@ public abstract class ConstVarMultinameUsage extends TraitMultinameUsage {
|
||||
return super.toString(abc) + " "
|
||||
+ (parentTraitIndex > -1
|
||||
? (isStatic
|
||||
? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convert(abc.constants, abc.method_info, abc, isStatic))
|
||||
: (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convert(abc.constants, abc.method_info, abc, isStatic)))
|
||||
? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convert(abc.method_info, abc, isStatic))
|
||||
: (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convert(abc.method_info, abc, isStatic)))
|
||||
: "")
|
||||
+ ((TraitSlotConst) traits.traits[traitIndex]).convert(abc.constants, abc.method_info, abc, isStatic);
|
||||
+ ((TraitSlotConst) traits.traits[traitIndex]).convert(abc.method_info, abc, isStatic);
|
||||
}
|
||||
|
||||
public int getTraitIndex() {
|
||||
|
||||
@@ -45,10 +45,10 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage {
|
||||
: "instance initializer")
|
||||
: ((parentTraitIndex > -1
|
||||
? (isStatic
|
||||
? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convert(abc.constants, abc.method_info, abc, isStatic))
|
||||
: (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convert(abc.constants, abc.method_info, abc, isStatic))) + " "
|
||||
? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convert(abc.method_info, abc, isStatic))
|
||||
: (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convert(abc.method_info, abc, isStatic))) + " "
|
||||
: "")
|
||||
+ (((TraitMethodGetterSetter) traits.traits[traitIndex]).convert(abc.constants, abc.method_info, abc, isStatic))));
|
||||
+ (((TraitMethodGetterSetter) traits.traits[traitIndex]).convert(abc.method_info, abc, isStatic))));
|
||||
}
|
||||
|
||||
public int getTraitIndex() {
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ActionPush extends Action {
|
||||
values.add(new RegisterNumber(sis.readUI8()));
|
||||
break;
|
||||
case 5:
|
||||
values.add((Boolean)(sis.readUI8() == 1));
|
||||
values.add((Boolean) (sis.readUI8() == 1));
|
||||
break;
|
||||
case 6:
|
||||
values.add(sis.readDOUBLE());
|
||||
@@ -143,7 +143,7 @@ public class ActionPush extends Action {
|
||||
switch (symb.type) {
|
||||
case ParsedSymbol.TYPE_STRING:
|
||||
count++;
|
||||
if (constantPool.contains((String)symb.value)) {
|
||||
if (constantPool.contains((String) symb.value)) {
|
||||
values.add(new ConstantIndex(constantPool.indexOf(symb.value), constantPool));
|
||||
} else {
|
||||
values.add(symb.value);
|
||||
|
||||
@@ -39,7 +39,7 @@ public class IfTreeItem extends TreeItem implements Block {
|
||||
@Override
|
||||
public String toString(ConstantPool constants) {
|
||||
String ret;
|
||||
ret = hilight("if(") + expression.toString(constants) + hilight(")")+"\r\n{\r\n";
|
||||
ret = hilight("if(") + expression.toString(constants) + hilight(")") + "\r\n{\r\n";
|
||||
for (TreeItem ti : onTrue) {
|
||||
ret += ti.toString(constants) + "\r\n";
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.jpexs.asdec.Main;
|
||||
import com.jpexs.asdec.SWFInputStream;
|
||||
import com.jpexs.asdec.SWFOutputStream;
|
||||
import com.jpexs.asdec.abc.CopyOutputStream;
|
||||
import com.jpexs.asdec.abc.gui.MainFrame;
|
||||
import com.jpexs.asdec.types.BUTTONCONDACTION;
|
||||
import com.jpexs.asdec.types.BUTTONRECORD;
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -143,7 +142,7 @@ public class DefineButton2Tag extends Tag implements Container, TagName {
|
||||
sos.writeBUTTONCONDACTIONList(actions);
|
||||
sos.close();
|
||||
} catch (IOException e) {
|
||||
Logger.getLogger(DefineButton2Tag.class.getName()).log(Level.SEVERE, null, e);
|
||||
Logger.getLogger(DefineButton2Tag.class.getName()).log(Level.SEVERE, null, e);
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class DefineButtonTag extends Tag implements ASMSource, TagName {
|
||||
try {
|
||||
actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(DefineButtonTag.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(DefineButtonTag.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return Action.actionsToString(actions, null, version);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class DoActionTag extends Tag implements ASMSource {
|
||||
//actions = sis.readActionList();
|
||||
actionBytes = sis.readBytes(sis.available());
|
||||
} catch (IOException e) {
|
||||
Logger.getLogger(DoActionTag.class.getName()).log(Level.SEVERE, null, e);
|
||||
Logger.getLogger(DoActionTag.class.getName()).log(Level.SEVERE, null, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class DoActionTag extends Tag implements ASMSource {
|
||||
try {
|
||||
actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(DoActionTag.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(DoActionTag.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return Action.actionsToString(actions, null, version);
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public class DoActionTag extends Tag implements ASMSource {
|
||||
try {
|
||||
return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(DoActionTag.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(DoActionTag.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return new ArrayList<Action>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class DoInitActionTag extends Tag implements ASMSource, TagName {
|
||||
try {
|
||||
actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(DoInitActionTag.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(DoInitActionTag.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return Action.actionsToString(actions, null, version);
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class DoInitActionTag extends Tag implements ASMSource, TagName {
|
||||
try {
|
||||
return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(DoInitActionTag.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(DoInitActionTag.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return new ArrayList<Action>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
package com.jpexs.asdec.tags;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Metadata extends Tag {
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.jpexs.asdec.types;
|
||||
import com.jpexs.asdec.SWFInputStream;
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.tags.ASMSource;
|
||||
import com.jpexs.asdec.tags.DoInitActionTag;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -116,7 +115,7 @@ public class BUTTONCONDACTION implements ASMSource {
|
||||
try {
|
||||
actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(BUTTONCONDACTION.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(BUTTONCONDACTION.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return Action.actionsToString(actions, null, version);
|
||||
}
|
||||
@@ -140,7 +139,7 @@ public class BUTTONCONDACTION implements ASMSource {
|
||||
try {
|
||||
return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(BUTTONCONDACTION.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(BUTTONCONDACTION.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return new ArrayList<Action>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.jpexs.asdec.types;
|
||||
import com.jpexs.asdec.SWFInputStream;
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.tags.ASMSource;
|
||||
import com.jpexs.asdec.tags.DoInitActionTag;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -83,7 +82,7 @@ public class CLIPACTIONRECORD implements ASMSource {
|
||||
try {
|
||||
actions = (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(CLIPACTIONRECORD.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(CLIPACTIONRECORD.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return Action.actionsToString(actions, null, version);
|
||||
}
|
||||
@@ -101,7 +100,7 @@ public class CLIPACTIONRECORD implements ASMSource {
|
||||
try {
|
||||
return (new SWFInputStream(new ByteArrayInputStream(actionBytes), version)).readActionList();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(CLIPACTIONRECORD.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(CLIPACTIONRECORD.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return new ArrayList<Action>();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user