mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-10 01:14:39 +00:00
code reformating, unused imports strip
This commit is contained in:
@@ -17,8 +17,6 @@
|
||||
package com.jpexs.asdec;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.parser.ASM3Parser;
|
||||
import com.jpexs.asdec.abc.avm2.parser.ParseException;
|
||||
import com.jpexs.asdec.abc.types.MethodBody;
|
||||
import com.jpexs.asdec.gui.AboutDialog;
|
||||
import com.jpexs.asdec.gui.LoadingDialog;
|
||||
@@ -144,7 +142,7 @@ public class Main {
|
||||
public static void startWork(String name) {
|
||||
startWork(name, -1);
|
||||
}
|
||||
|
||||
|
||||
public static void startWork(String name, int percent) {
|
||||
working = true;
|
||||
if (mainFrame != null) {
|
||||
@@ -482,13 +480,14 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
public static final void printASM(AVM2Code code){
|
||||
String s=Highlighting.stripHilights(code.toASMSource(null, new MethodBody()));
|
||||
String ss[]=s.split("\n");
|
||||
for(int i=0;i<ss.length;i++){
|
||||
System.out.println(""+i+":"+ss[i]);
|
||||
}
|
||||
public static final void printASM(AVM2Code code) {
|
||||
String s = Highlighting.stripHilights(code.toASMSource(null, new MethodBody()));
|
||||
String ss[] = s.split("\n");
|
||||
for (int i = 0; i < ss.length; i++) {
|
||||
System.out.println("" + i + ":" + ss[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
@@ -496,7 +495,7 @@ public class Main {
|
||||
View.setLookAndFeel();
|
||||
Configuration.load();
|
||||
checkSWT(args);
|
||||
|
||||
|
||||
int pos = 0;
|
||||
if (args.length > 0) {
|
||||
if (args[0].equals("-debug")) {
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.asdec;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -11,53 +27,50 @@ import java.io.InputStream;
|
||||
public class ReReadableInputStream extends InputStream {
|
||||
|
||||
InputStream is;
|
||||
ByteArrayOutputStream baos=new ByteArrayOutputStream();
|
||||
byte []converted;
|
||||
int pos=0;
|
||||
int count=0;
|
||||
|
||||
public byte[] getAllRead(){
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte[] converted;
|
||||
int pos = 0;
|
||||
int count = 0;
|
||||
|
||||
public byte[] getAllRead() {
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
public int getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ReReadableInputStream(InputStream is) {
|
||||
this.is=is;
|
||||
}
|
||||
|
||||
|
||||
public void setPos(int pos) throws IOException{
|
||||
if(pos>count){
|
||||
skip(pos-count);
|
||||
}
|
||||
this.pos=pos;
|
||||
public ReReadableInputStream(InputStream is) {
|
||||
this.is = is;
|
||||
}
|
||||
|
||||
|
||||
public void setPos(int pos) throws IOException {
|
||||
if (pos > count) {
|
||||
skip(pos - count);
|
||||
}
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
if(pos<count){
|
||||
if(converted==null){
|
||||
converted=baos.toByteArray();
|
||||
if (pos < count) {
|
||||
if (converted == null) {
|
||||
converted = baos.toByteArray();
|
||||
}
|
||||
int ret=converted[pos]&0xff;
|
||||
int ret = converted[pos] & 0xff;
|
||||
pos++;
|
||||
return ret;
|
||||
}
|
||||
int i= is.read();
|
||||
int i = is.read();
|
||||
baos.write(i);
|
||||
count++;
|
||||
pos++;
|
||||
converted=null;
|
||||
converted = null;
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
return (pos<count?count-pos:0)+is.available();
|
||||
}
|
||||
return (pos < count ? count - pos : 0) + is.available();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.jpexs.asdec;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.instructions.other.NopIns;
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.IgnoredPair;
|
||||
import com.jpexs.asdec.action.parser.ASMParser;
|
||||
@@ -39,7 +38,6 @@ import com.jpexs.asdec.types.shaperecords.EndShapeRecord;
|
||||
import com.jpexs.asdec.types.shaperecords.SHAPERECORD;
|
||||
import com.jpexs.asdec.types.shaperecords.StraightEdgeRecord;
|
||||
import com.jpexs.asdec.types.shaperecords.StyleChangeRecord;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -512,7 +510,7 @@ public class SWFInputStream extends InputStream {
|
||||
|
||||
private void readActionListAtPos(Stack<TreeItem> stack, ConstantPool cpool, SWFInputStream sis, ReReadableInputStream rri, int ip, List<Action> ret) throws IOException {
|
||||
boolean debugMode = false;
|
||||
boolean displayCompiletime=false;
|
||||
boolean displayCompiletime = false;
|
||||
rri.setPos(ip);
|
||||
Action a;
|
||||
List<TreeItem> output = new ArrayList<TreeItem>();
|
||||
@@ -575,27 +573,25 @@ public class SWFInputStream extends InputStream {
|
||||
}
|
||||
a = new ActionNop();
|
||||
}
|
||||
if(displayCompiletime){
|
||||
if (displayCompiletime) {
|
||||
beforeInsert = new ActionPop();
|
||||
}
|
||||
else{
|
||||
List<IgnoredPair> needed=top.getNeededActions();
|
||||
for(IgnoredPair ig:needed){
|
||||
if(ig.action instanceof ActionPush){
|
||||
if(!((ActionPush)ig.action).ignoredParts.contains(ig.pos)){
|
||||
((ActionPush)ig.action).ignoredParts.add(ig.pos);
|
||||
} else {
|
||||
List<IgnoredPair> needed = top.getNeededActions();
|
||||
for (IgnoredPair ig : needed) {
|
||||
if (ig.action instanceof ActionPush) {
|
||||
if (!((ActionPush) ig.action).ignoredParts.contains(ig.pos)) {
|
||||
((ActionPush) ig.action).ignoredParts.add(ig.pos);
|
||||
|
||||
if(((ActionPush)ig.action).ignoredParts.size()==((ActionPush)ig.action).values.size())
|
||||
{
|
||||
ig.action.ignored=true;
|
||||
if (((ActionPush) ig.action).ignoredParts.size() == ((ActionPush) ig.action).values.size()) {
|
||||
ig.action.ignored = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ig.action.ignored = true;
|
||||
}
|
||||
}else{
|
||||
ig.action.ignored=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
goaif = true;
|
||||
}
|
||||
|
||||
@@ -21,18 +21,12 @@ 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.parser.ASM3Parser;
|
||||
import com.jpexs.asdec.abc.avm2.parser.ParseException;
|
||||
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.TraitClass;
|
||||
import com.jpexs.asdec.abc.types.traits.TraitMethodGetterSetter;
|
||||
import com.jpexs.asdec.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.asdec.abc.types.traits.Traits;
|
||||
import com.jpexs.asdec.abc.usages.*;
|
||||
import com.jpexs.asdec.helpers.Helper;
|
||||
import com.jpexs.asdec.helpers.Highlighting;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
@@ -40,7 +34,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Stack;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -118,7 +111,7 @@ public class ABC {
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
for (int i = 1; i < constants.constant_namespace.length; i++) {
|
||||
for (int i = 1; i < constants.constant_namespace.length; i++) {
|
||||
if (deobfuscateNameSpace(namesMap, constants.constant_namespace[i].name_index)) {
|
||||
ret++;
|
||||
}
|
||||
@@ -677,12 +670,12 @@ public class ABC {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isValidNSPart(String s){
|
||||
private boolean isValidNSPart(String s) {
|
||||
boolean isValid = true;
|
||||
if (isReserved(s)) {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
|
||||
if (isValid) {
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (s.charAt(i) > 127) {
|
||||
@@ -699,32 +692,32 @@ public class ABC {
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
|
||||
public boolean deobfuscateNameSpace(HashMap<String, String> namesMap, int strIndex) {
|
||||
if (strIndex <= 0) {
|
||||
return false;
|
||||
}
|
||||
String s = constants.constant_string[strIndex];
|
||||
boolean isValid = isValidNSPart(s);
|
||||
boolean isValid = isValidNSPart(s);
|
||||
if (!isValid) {
|
||||
if (namesMap.containsKey(s)) {
|
||||
constants.constant_string[strIndex] = namesMap.get(s);
|
||||
} else {
|
||||
String parts[]=null;
|
||||
if(s.contains(".")){
|
||||
parts=s.split("\\.");
|
||||
}else{
|
||||
parts=new String[]{s};
|
||||
String parts[] = null;
|
||||
if (s.contains(".")) {
|
||||
parts = s.split("\\.");
|
||||
} else {
|
||||
parts = new String[]{s};
|
||||
}
|
||||
String ret="";
|
||||
for(int p=0;p<parts.length;p++){
|
||||
if(p>0){
|
||||
ret+=".";
|
||||
String ret = "";
|
||||
for (int p = 0; p < parts.length; p++) {
|
||||
if (p > 0) {
|
||||
ret += ".";
|
||||
}
|
||||
if(!isValidNSPart(parts[p])){
|
||||
ret+=fooString(constants.constant_string[strIndex], false, DEFAULT_FOO_SIZE);
|
||||
}else{
|
||||
ret+=parts[p];
|
||||
if (!isValidNSPart(parts[p])) {
|
||||
ret += fooString(constants.constant_string[strIndex], false, DEFAULT_FOO_SIZE);
|
||||
} else {
|
||||
ret += parts[p];
|
||||
}
|
||||
}
|
||||
constants.constant_string[strIndex] = ret;
|
||||
|
||||
@@ -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;
|
||||
@@ -44,7 +43,6 @@ import com.jpexs.asdec.abc.avm2.treemodel.*;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.clauses.*;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.AndTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.OrTreeItem;
|
||||
import com.jpexs.asdec.abc.gui.DialogMissingSymbolHandler;
|
||||
import com.jpexs.asdec.abc.types.ABCException;
|
||||
import com.jpexs.asdec.abc.types.MethodBody;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
@@ -60,8 +58,6 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.swing.text.Highlighter;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.TagInstruction;
|
||||
|
||||
public class AVM2Code implements Serializable {
|
||||
|
||||
@@ -729,7 +725,7 @@ public class AVM2Code implements Serializable {
|
||||
long ofs = 0;
|
||||
int ip = 0;
|
||||
int largeLimit = 20000;
|
||||
boolean markOffsets=code.size()<=largeLimit;
|
||||
boolean markOffsets = code.size() <= largeLimit;
|
||||
for (AVM2Instruction ins : code) {
|
||||
if (ins.labelname != null) {
|
||||
ret.append(ins.labelname + ":");
|
||||
@@ -754,7 +750,7 @@ public class AVM2Code implements Serializable {
|
||||
if (ins2.isIgnored()) {
|
||||
continue;
|
||||
}
|
||||
t = Highlighting.hilighOffset("", ins2.mappedOffset>-1?ins2.mappedOffset:ofs) + ins2.toStringNoAddress(constants, new ArrayList<String>()) + " ;copy from " + Helper.formatAddress(pos2adr((Integer) o)) + "\n";
|
||||
t = Highlighting.hilighOffset("", ins2.mappedOffset > -1 ? ins2.mappedOffset : ofs) + ins2.toStringNoAddress(constants, new ArrayList<String>()) + " ;copy from " + Helper.formatAddress(pos2adr((Integer) o)) + "\n";
|
||||
ret.append(t);
|
||||
outputMap.add((Integer) o);
|
||||
} else if (o instanceof ControlFlowTag) {
|
||||
@@ -775,11 +771,11 @@ public class AVM2Code implements Serializable {
|
||||
if (ins.changeJumpTo > -1) {
|
||||
t = ins.definition.instructionName + " ofs" + Helper.formatAddress(pos2adr(ins.changeJumpTo));
|
||||
}
|
||||
if(markOffsets){
|
||||
t = Highlighting.hilighOffset("", ins.mappedOffset>-1?ins.mappedOffset:ofs) + t + "\n";
|
||||
}else{
|
||||
if (markOffsets) {
|
||||
t = Highlighting.hilighOffset("", ins.mappedOffset > -1 ? ins.mappedOffset : ofs) + t + "\n";
|
||||
} else {
|
||||
t = t + "\n";
|
||||
}
|
||||
}
|
||||
ret.append(t);
|
||||
outputMap.add(ip);
|
||||
}
|
||||
@@ -787,7 +783,7 @@ public class AVM2Code implements Serializable {
|
||||
ofs += ins.getBytes().length;
|
||||
ip++;
|
||||
}
|
||||
String r=ret.toString();
|
||||
String r = ret.toString();
|
||||
return r;
|
||||
}
|
||||
private boolean cacheActual = false;
|
||||
@@ -1038,7 +1034,7 @@ public class AVM2Code implements Serializable {
|
||||
return pos2adr(fixIPAfterDebugLine(adr2pos(addr)));
|
||||
}
|
||||
|
||||
public ConvertOutput toSourceOutput(boolean processJumps,boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, Stack<TreeItem> scopeStack, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, int start, int end, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, boolean visited[]) throws ConvertException {
|
||||
public ConvertOutput toSourceOutput(boolean processJumps, boolean isStatic, int classIndex, java.util.HashMap<Integer, TreeItem> localRegs, Stack<TreeItem> stack, Stack<TreeItem> scopeStack, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, int start, int end, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, boolean visited[]) throws ConvertException {
|
||||
boolean debugMode = DEBUG_MODE;
|
||||
if (debugMode) {
|
||||
System.out.println("OPEN SubSource:" + start + "-" + end + " " + code.get(start).toString() + " to " + code.get(end).toString());
|
||||
@@ -1126,7 +1122,7 @@ public class AVM2Code implements Serializable {
|
||||
if (swins.operands.length >= 3) {
|
||||
if (swins.operands[0] == swins.getBytes().length) {
|
||||
if (adr2pos(pos2adr(f) + swins.operands[2]) < finStart) {
|
||||
finallyCommands = toSourceOutput(processJumps,isStatic, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, finStart, f - 1, localRegNames, fullyQualifiedNames, visited).output;
|
||||
finallyCommands = toSourceOutput(processJumps, isStatic, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, finStart, f - 1, localRegNames, fullyQualifiedNames, visited).output;
|
||||
returnPos = f + 1;
|
||||
break;
|
||||
}
|
||||
@@ -1151,10 +1147,10 @@ public class AVM2Code implements Serializable {
|
||||
}
|
||||
Stack<TreeItem> substack = new Stack<TreeItem>();
|
||||
substack.add(new ExceptionTreeItem(catchedExceptions.get(e)));
|
||||
catchedCommands.add(toSourceOutput(processJumps,isStatic, classIndex, localRegs, substack, new Stack<TreeItem>(), abc, constants, method_info, body, adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(e).target)), eendpos, localRegNames, fullyQualifiedNames, visited).output);
|
||||
catchedCommands.add(toSourceOutput(processJumps, isStatic, classIndex, localRegs, substack, new Stack<TreeItem>(), abc, constants, method_info, body, adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(e).target)), eendpos, localRegNames, fullyQualifiedNames, visited).output);
|
||||
}
|
||||
|
||||
List<TreeItem> tryCommands = toSourceOutput(processJumps,isStatic, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip, endpos - 1, localRegNames, fullyQualifiedNames, visited).output;
|
||||
List<TreeItem> tryCommands = toSourceOutput(processJumps, isStatic, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip, endpos - 1, localRegNames, fullyQualifiedNames, visited).output;
|
||||
|
||||
|
||||
output.add(new TryTreeItem(tryCommands, catchedExceptions, catchedCommands, finallyCommands));
|
||||
@@ -1328,7 +1324,7 @@ public class AVM2Code implements Serializable {
|
||||
throw new ConvertException("Unknown pattern: no setlocal before lookupswitch", switchPos);
|
||||
}
|
||||
loopList.add(new Loop(ip, switchPos + 1));
|
||||
Stack<TreeItem> substack = toSourceOutput(processJumps,isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, jumpPos, evalTo - 1, localRegNames, fullyQualifiedNames, visited).stack;
|
||||
Stack<TreeItem> substack = toSourceOutput(processJumps, isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, jumpPos, evalTo - 1, localRegNames, fullyQualifiedNames, visited).stack;
|
||||
TreeItem switchedValue = substack.pop();
|
||||
//output.add("loop" + (switchPos + 1) + ":");
|
||||
int switchBreak = switchPos + 1;
|
||||
@@ -1363,7 +1359,7 @@ public class AVM2Code implements Serializable {
|
||||
|
||||
|
||||
if (evalTo > -1) {
|
||||
substack = toSourceOutput(processJumps,isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, curPos, evalTo - 1, localRegNames, fullyQualifiedNames, visited).stack;
|
||||
substack = toSourceOutput(processJumps, isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, curPos, evalTo - 1, localRegNames, fullyQualifiedNames, visited).stack;
|
||||
casesList.add(substack.pop());
|
||||
}
|
||||
int substart = adr2pos(code.get(switchPos).operands[2 + casePos] + pos2adr(switchPos));
|
||||
@@ -1375,7 +1371,7 @@ public class AVM2Code implements Serializable {
|
||||
if (evalTo == -1) {
|
||||
subend--;
|
||||
}
|
||||
List commands = toSourceOutput(processJumps,isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, substart, subend, localRegNames, fullyQualifiedNames, visited).output;
|
||||
List commands = toSourceOutput(processJumps, isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, substart, subend, localRegNames, fullyQualifiedNames, visited).output;
|
||||
if ((evalTo == -1) && (casePos + 1 < code.get(switchPos).operands.length - 2)) {
|
||||
if (commands.size() == 1) {
|
||||
commands.remove(0);
|
||||
@@ -1397,12 +1393,12 @@ public class AVM2Code implements Serializable {
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
if(processJumps){
|
||||
List<Integer> valMapping=new ArrayList<Integer>();
|
||||
for(int i=0;i<casesList.size();i++){
|
||||
if (processJumps) {
|
||||
List<Integer> valMapping = new ArrayList<Integer>();
|
||||
for (int i = 0; i < casesList.size(); i++) {
|
||||
valMapping.add(i);
|
||||
}
|
||||
output.add(new SwitchTreeItem(code.get(switchPos), switchBreak, switchedValue, casesList, caseCommands, defaultCommands,valMapping));
|
||||
output.add(new SwitchTreeItem(code.get(switchPos), switchBreak, switchedValue, casesList, caseCommands, defaultCommands, valMapping));
|
||||
}
|
||||
ip = switchPos + 1;
|
||||
continue;
|
||||
@@ -1427,7 +1423,7 @@ public class AVM2Code implements Serializable {
|
||||
if (debugMode) {
|
||||
System.out.println("expression branch");
|
||||
}
|
||||
ConvertOutput co = toSourceOutput(processJumps,isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, jumpPos, adr2pos(afterBackJumpAddr) - 2, localRegNames, fullyQualifiedNames, visited);
|
||||
ConvertOutput co = toSourceOutput(processJumps, isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, jumpPos, adr2pos(afterBackJumpAddr) - 2, localRegNames, fullyQualifiedNames, visited);
|
||||
Stack<TreeItem> substack = co.stack;
|
||||
backJumpIns.definition.translate(isStatic, classIndex, localRegs, substack, scopeStack, constants, backJumpIns, method_info, output, body, abc, localRegNames, fullyQualifiedNames);
|
||||
|
||||
@@ -1439,7 +1435,7 @@ public class AVM2Code implements Serializable {
|
||||
if (debugMode) {
|
||||
System.out.println("subins branch");
|
||||
}
|
||||
subins = toSourceOutput(processJumps,isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, adr2pos(secondAddr) + 1/*label*/, jumpPos - 1, localRegNames, fullyQualifiedNames, visited).output;
|
||||
subins = toSourceOutput(processJumps, isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, adr2pos(secondAddr) + 1/*label*/, jumpPos - 1, localRegNames, fullyQualifiedNames, visited).output;
|
||||
} catch (UnknownJumpException uje) {
|
||||
if ((uje.ip >= start) && (uje.ip <= end)) {
|
||||
currentLoop.loopContinue = uje.ip;
|
||||
@@ -1467,7 +1463,7 @@ public class AVM2Code implements Serializable {
|
||||
if (debugMode) {
|
||||
System.out.println("final expression branch");
|
||||
}
|
||||
finalExpression = toSourceOutput(processJumps,isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, uje.ip, jumpPos - 1, localRegNames, fullyQualifiedNames, visited).output;
|
||||
finalExpression = toSourceOutput(processJumps, isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, uje.ip, jumpPos - 1, localRegNames, fullyQualifiedNames, visited).output;
|
||||
isFor = true;
|
||||
} else {
|
||||
throw new ConvertException("Unknown pattern: jump to nowhere", ip);
|
||||
@@ -1600,7 +1596,7 @@ public class AVM2Code implements Serializable {
|
||||
addr = pos2adr(ip);
|
||||
insAfter = code.get(ip + 1);
|
||||
}
|
||||
|
||||
|
||||
boolean isAnd;
|
||||
if (processJumps && (insAfter.definition instanceof IfFalseIns)) {
|
||||
//stack.add("(" + stack.pop() + ")&&");
|
||||
@@ -1621,7 +1617,7 @@ public class AVM2Code implements Serializable {
|
||||
if (((GetLocalTypeIns) code.get(t).definition).getRegisterId(code.get(t)) == reg) {
|
||||
if (code.get(t + 1).definition instanceof KillIns) {
|
||||
if (code.get(t + 1).operands[0] == reg) {
|
||||
ConvertOutput assignment = toSourceOutput(processJumps,isStatic, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip + 2, t - 1, localRegNames, fullyQualifiedNames, visited);
|
||||
ConvertOutput assignment = toSourceOutput(processJumps, isStatic, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip + 2, t - 1, localRegNames, fullyQualifiedNames, visited);
|
||||
stack.push(assignment.output.remove(assignment.output.size() - 1));
|
||||
ip = t + 2;
|
||||
continue iploop;
|
||||
@@ -1652,18 +1648,18 @@ public class AVM2Code implements Serializable {
|
||||
ip++;
|
||||
break;
|
||||
//throw new ConvertException("Unknown pattern after DUP:" + insComparsion.toString());
|
||||
}
|
||||
if(processJumps){
|
||||
}
|
||||
if (processJumps) {
|
||||
addr = addr + ins.getBytes().length + insAfter.getBytes().length + insAfter.operands[0];
|
||||
nextPos = adr2pos(addr) - 1;
|
||||
if (isAnd) {
|
||||
stack.add(new AndTreeItem(insAfter, stack.pop(), toSourceOutput(processJumps,isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, ip + 3, nextPos, localRegNames, fullyQualifiedNames, visited).stack.pop()));
|
||||
stack.add(new AndTreeItem(insAfter, stack.pop(), toSourceOutput(processJumps, isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, ip + 3, nextPos, localRegNames, fullyQualifiedNames, visited).stack.pop()));
|
||||
} else {
|
||||
stack.add(new OrTreeItem(insAfter, stack.pop(), toSourceOutput(processJumps,isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, ip + 3, nextPos, localRegNames, fullyQualifiedNames, visited).stack.pop()));
|
||||
stack.add(new OrTreeItem(insAfter, stack.pop(), toSourceOutput(processJumps, isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, ip + 3, nextPos, localRegNames, fullyQualifiedNames, visited).stack.pop()));
|
||||
}
|
||||
ins = code.get(nextPos + 1);
|
||||
ip = nextPos + 1;
|
||||
}
|
||||
}
|
||||
} while (ins.definition instanceof DupIns);
|
||||
} else if (ins.definition instanceof IfTypeIns) {
|
||||
int targetAddr = pos2adr(ip) + ins.getBytes().length + ins.operands[0];
|
||||
@@ -1720,7 +1716,7 @@ public class AVM2Code implements Serializable {
|
||||
if (debugMode) {
|
||||
System.out.println("true branch");
|
||||
}
|
||||
ConvertOutput onTrue = toSourceOutput(processJumps,isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, ip + 1, targetIns - 1 - ((hasElse || hasReturn) ? 1 : 0), localRegNames, fullyQualifiedNames, visited);
|
||||
ConvertOutput onTrue = toSourceOutput(processJumps, isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, ip + 1, targetIns - 1 - ((hasElse || hasReturn) ? 1 : 0), localRegNames, fullyQualifiedNames, visited);
|
||||
ip = targetIns;
|
||||
ConvertOutput onFalse = new ConvertOutput(new Stack<TreeItem>(), new ArrayList<TreeItem>());
|
||||
if (hasElse) {
|
||||
@@ -1729,7 +1725,7 @@ public class AVM2Code implements Serializable {
|
||||
if (debugMode) {
|
||||
System.out.println("false branch");
|
||||
}
|
||||
onFalse = toSourceOutput(processJumps,isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, targetIns, finalIns - 1, localRegNames, fullyQualifiedNames, visited);
|
||||
onFalse = toSourceOutput(processJumps, isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, targetIns, finalIns - 1, localRegNames, fullyQualifiedNames, visited);
|
||||
ip = finalIns;
|
||||
}
|
||||
if ((onTrue.stack.size() > 0) && (onFalse != null) && (onFalse.stack.size() > 0)) {
|
||||
@@ -1791,12 +1787,12 @@ public class AVM2Code implements Serializable {
|
||||
System.out.println("CLOSE SubSource:" + start + "-" + end + " " + code.get(start).toString() + " to " + code.get(end).toString());
|
||||
}
|
||||
/*if (hideTemporaryRegisters) {
|
||||
clearTemporaryRegisters(output);
|
||||
}*/
|
||||
clearTemporaryRegisters(output);
|
||||
}*/
|
||||
return new ConvertOutput(stack, output);
|
||||
} catch (ConvertException cex) {
|
||||
throw cex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String tabString(int len) {
|
||||
@@ -1807,11 +1803,10 @@ public class AVM2Code implements Serializable {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String toSource(String path,boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, HashMap<Integer, String> localRegNames, Stack<TreeItem> scopeStack, boolean isStaticInitializer, List<String> fullyQualifiedNames, Traits initTraits) {
|
||||
return toSource(path,isStatic, classIndex, abc, constants, method_info, body, false, localRegNames, scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits);
|
||||
public String toSource(String path, boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, HashMap<Integer, String> localRegNames, Stack<TreeItem> scopeStack, boolean isStaticInitializer, List<String> fullyQualifiedNames, Traits initTraits) {
|
||||
return toSource(path, isStatic, classIndex, abc, constants, method_info, body, false, localRegNames, scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits);
|
||||
}
|
||||
|
||||
|
||||
public int getRegisterCount() {
|
||||
int maxRegister = -1;
|
||||
for (AVM2Instruction ins : code) {
|
||||
@@ -1882,7 +1877,7 @@ public class AVM2Code implements Serializable {
|
||||
ignoredIns = new ArrayList<Integer>();
|
||||
}
|
||||
|
||||
public String toSource(String path,boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, boolean hilighted, HashMap<Integer, String> localRegNames, Stack<TreeItem> scopeStack, boolean isStaticInitializer, List<String> fullyQualifiedNames, Traits initTraits) {
|
||||
public String toSource(String path, boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, boolean hilighted, HashMap<Integer, String> localRegNames, Stack<TreeItem> scopeStack, boolean isStaticInitializer, List<String> fullyQualifiedNames, Traits initTraits) {
|
||||
initToSource();
|
||||
List<TreeItem> list;
|
||||
String s;
|
||||
@@ -1900,104 +1895,104 @@ public class AVM2Code implements Serializable {
|
||||
|
||||
//try {
|
||||
|
||||
try{
|
||||
list = AVM2Graph.translateViaGraph(path,this, abc, body);
|
||||
}catch(Exception ex2){
|
||||
Logger.getLogger(AVM2Code.class.getName()).log(Level.SEVERE, "Decompilation error in "+path,ex2);
|
||||
return "/*\r\n * Decompilation error\r\n * Code may be obfuscated\r\n * Error Message: " + ex2.getMessage() + "\r\n */";
|
||||
}
|
||||
/*try{
|
||||
list=toSourceOutput(true,isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, 0, code.size() - 1, localRegNames, fullyQualifiedNames, null).output;
|
||||
}catch(Exception ex){
|
||||
try {
|
||||
list = AVM2Graph.translateViaGraph(path, this, abc, body);
|
||||
} catch (Exception ex2) {
|
||||
Logger.getLogger(AVM2Code.class.getName()).log(Level.SEVERE, "Decompilation error in " + path, ex2);
|
||||
return "/*\r\n * Decompilation error\r\n * Code may be obfuscated\r\n * Error Message: " + ex2.getMessage() + "\r\n */";
|
||||
}
|
||||
/*try{
|
||||
list=toSourceOutput(true,isStatic, classIndex, localRegs, new Stack<TreeItem>(), scopeStack, abc, constants, method_info, body, 0, code.size() - 1, localRegNames, fullyQualifiedNames, null).output;
|
||||
}catch(Exception ex){
|
||||
|
||||
}*/
|
||||
if (initTraits != null) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
TreeItem ti = list.get(i);
|
||||
if ((ti instanceof InitPropertyTreeItem) || (ti instanceof SetPropertyTreeItem)) {
|
||||
int multinameIndex = 0;
|
||||
TreeItem value = null;
|
||||
if (ti instanceof InitPropertyTreeItem) {
|
||||
multinameIndex = ((InitPropertyTreeItem) ti).propertyName.multinameIndex;
|
||||
value = ((InitPropertyTreeItem) ti).value;
|
||||
}
|
||||
if (ti instanceof SetPropertyTreeItem) {
|
||||
multinameIndex = ((SetPropertyTreeItem) ti).propertyName.multinameIndex;
|
||||
value = ((SetPropertyTreeItem) ti).value;
|
||||
}
|
||||
for (Trait t : initTraits.traits) {
|
||||
if (t.name_index == multinameIndex) {
|
||||
if ((t instanceof TraitSlotConst)) {
|
||||
if (((TraitSlotConst) t).isConst() || isStaticInitializer) {
|
||||
((TraitSlotConst) t).assignedValue = value;
|
||||
list.remove(i);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isStaticInitializer) {
|
||||
List<TreeItem> newList = new ArrayList<TreeItem>();
|
||||
for (TreeItem ti : list) {
|
||||
if (!(ti instanceof ReturnVoidTreeItem)) {
|
||||
if (!(ti instanceof InitPropertyTreeItem)) {
|
||||
if (!(ti instanceof SetPropertyTreeItem)) {
|
||||
newList.add(ti);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
list = newList;
|
||||
if (list.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
//Declarations
|
||||
boolean declaredRegisters[] = new boolean[regCount];
|
||||
for (int b = 0; b < declaredRegisters.length; b++) {
|
||||
declaredRegisters[b] = false;
|
||||
}
|
||||
List<Slot> declaredSlots = new ArrayList<Slot>();
|
||||
}*/
|
||||
if (initTraits != null) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
TreeItem ti = list.get(i);
|
||||
if (ti instanceof SetLocalTreeItem) {
|
||||
int reg = ((SetLocalTreeItem) ti).regIndex;
|
||||
if (!declaredRegisters[reg]) {
|
||||
list.set(i, new DeclarationTreeItem(ti));
|
||||
declaredRegisters[reg] = true;
|
||||
if ((ti instanceof InitPropertyTreeItem) || (ti instanceof SetPropertyTreeItem)) {
|
||||
int multinameIndex = 0;
|
||||
TreeItem value = null;
|
||||
if (ti instanceof InitPropertyTreeItem) {
|
||||
multinameIndex = ((InitPropertyTreeItem) ti).propertyName.multinameIndex;
|
||||
value = ((InitPropertyTreeItem) ti).value;
|
||||
}
|
||||
}
|
||||
if (ti instanceof SetSlotTreeItem) {
|
||||
SetSlotTreeItem ssti = (SetSlotTreeItem) ti;
|
||||
Slot sl = new Slot(ssti.scope, ssti.slotName);
|
||||
if (!declaredSlots.contains(sl)) {
|
||||
String type = "*";
|
||||
for (int t = 0; t < body.traits.traits.length; t++) {
|
||||
if (body.traits.traits[t].getName(abc) == sl.multiname) {
|
||||
if (body.traits.traits[t] instanceof TraitSlotConst) {
|
||||
type = ((TraitSlotConst) body.traits.traits[t]).getType(constants, fullyQualifiedNames);
|
||||
if (ti instanceof SetPropertyTreeItem) {
|
||||
multinameIndex = ((SetPropertyTreeItem) ti).propertyName.multinameIndex;
|
||||
value = ((SetPropertyTreeItem) ti).value;
|
||||
}
|
||||
for (Trait t : initTraits.traits) {
|
||||
if (t.name_index == multinameIndex) {
|
||||
if ((t instanceof TraitSlotConst)) {
|
||||
if (((TraitSlotConst) t).isConst() || isStaticInitializer) {
|
||||
((TraitSlotConst) t).assignedValue = value;
|
||||
list.remove(i);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
list.set(i, new DeclarationTreeItem(ti, type));
|
||||
declaredSlots.add(sl);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isStaticInitializer) {
|
||||
List<TreeItem> newList = new ArrayList<TreeItem>();
|
||||
for (TreeItem ti : list) {
|
||||
if (!(ti instanceof ReturnVoidTreeItem)) {
|
||||
if (!(ti instanceof InitPropertyTreeItem)) {
|
||||
if (!(ti instanceof SetPropertyTreeItem)) {
|
||||
newList.add(ti);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
list = newList;
|
||||
if (list.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
//Declarations
|
||||
boolean declaredRegisters[] = new boolean[regCount];
|
||||
for (int b = 0; b < declaredRegisters.length; b++) {
|
||||
declaredRegisters[b] = false;
|
||||
}
|
||||
List<Slot> declaredSlots = new ArrayList<Slot>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
TreeItem ti = list.get(i);
|
||||
if (ti instanceof SetLocalTreeItem) {
|
||||
int reg = ((SetLocalTreeItem) ti).regIndex;
|
||||
if (!declaredRegisters[reg]) {
|
||||
list.set(i, new DeclarationTreeItem(ti));
|
||||
declaredRegisters[reg] = true;
|
||||
}
|
||||
}
|
||||
if (ti instanceof SetSlotTreeItem) {
|
||||
SetSlotTreeItem ssti = (SetSlotTreeItem) ti;
|
||||
Slot sl = new Slot(ssti.scope, ssti.slotName);
|
||||
if (!declaredSlots.contains(sl)) {
|
||||
String type = "*";
|
||||
for (int t = 0; t < body.traits.traits.length; t++) {
|
||||
if (body.traits.traits[t].getName(abc) == sl.multiname) {
|
||||
if (body.traits.traits[t] instanceof TraitSlotConst) {
|
||||
type = ((TraitSlotConst) body.traits.traits[t]).getType(constants, fullyQualifiedNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
list.set(i, new DeclarationTreeItem(ti, type));
|
||||
declaredSlots.add(sl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s = listToString(list, constants, localRegNames, fullyQualifiedNames);
|
||||
s = listToString(list, constants, localRegNames, fullyQualifiedNames);
|
||||
/*} catch (Exception ex) {
|
||||
Logger.getLogger(AVM2Code.class.getName()).log(Level.SEVERE, "Error in method "+path, ex);
|
||||
s = "/ *\r\n * Decompilation error\r\n * Code may be obfuscated\r\n * Error Message: " + ex.getMessage() + "\r\n * /";
|
||||
return s;
|
||||
}*/
|
||||
Logger.getLogger(AVM2Code.class.getName()).log(Level.SEVERE, "Error in method "+path, ex);
|
||||
s = "/ *\r\n * Decompilation error\r\n * Code may be obfuscated\r\n * Error Message: " + ex.getMessage() + "\r\n * /";
|
||||
return s;
|
||||
}*/
|
||||
|
||||
|
||||
StringBuffer sub = new StringBuffer();
|
||||
@@ -2006,7 +2001,7 @@ public class AVM2Code implements Serializable {
|
||||
String parts[] = s.split("\r\n");
|
||||
|
||||
boolean processLoops = true;
|
||||
|
||||
|
||||
if (processLoops) {
|
||||
try {
|
||||
Stack<String> loopStack = new Stack<String>();
|
||||
@@ -2086,8 +2081,8 @@ public class AVM2Code implements Serializable {
|
||||
if (!hilighted) {
|
||||
return Highlighting.stripHilights(sub.toString());
|
||||
}
|
||||
String ret=sub.toString();
|
||||
|
||||
String ret = sub.toString();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2243,8 +2238,8 @@ public class AVM2Code implements Serializable {
|
||||
code.add(pos, instruction);
|
||||
}
|
||||
|
||||
public int removeTraps(ConstantPool constants, MethodBody body) {
|
||||
|
||||
public int removeTraps(ConstantPool constants, MethodBody body) {
|
||||
|
||||
removeDeadCode(constants, body);
|
||||
boolean isSecure = true;
|
||||
try {
|
||||
@@ -2386,7 +2381,7 @@ public class AVM2Code implements Serializable {
|
||||
}
|
||||
}
|
||||
} while (found);
|
||||
removeIgnored(constants,body);
|
||||
removeIgnored(constants, body);
|
||||
removeDeadCode(constants, body);
|
||||
} else {
|
||||
//isSecure = false;
|
||||
@@ -2400,7 +2395,7 @@ public class AVM2Code implements Serializable {
|
||||
}
|
||||
int ret = isSecure ? 1 : 0;
|
||||
ret += visitCodeTrap(body, new int[code.size()]);
|
||||
removeIgnored(constants,body);
|
||||
removeIgnored(constants, body);
|
||||
removeDeadCode(constants, body);
|
||||
|
||||
return ret;
|
||||
@@ -2743,7 +2738,9 @@ public class AVM2Code implements Serializable {
|
||||
|
||||
boolean allJumpsOrIfs = true;
|
||||
for (int ref : refs.get(ip)) {
|
||||
if(ref<0) continue;
|
||||
if (ref < 0) {
|
||||
continue;
|
||||
}
|
||||
if (!(code.get(ref).definition instanceof JumpIns)) {
|
||||
if (!(code.get(ref).definition instanceof IfTypeIns)) {
|
||||
allJumpsOrIfs = false;
|
||||
@@ -2758,7 +2755,9 @@ public class AVM2Code implements Serializable {
|
||||
}
|
||||
if (allJumpsOrIfs) {
|
||||
for (int ref : refs.get(ip)) {
|
||||
if(ref<0) continue;
|
||||
if (ref < 0) {
|
||||
continue;
|
||||
}
|
||||
code.get(ref).changeJumpTo = newip;
|
||||
}
|
||||
}
|
||||
@@ -2856,18 +2855,17 @@ public class AVM2Code implements Serializable {
|
||||
}
|
||||
|
||||
/*private void removeIgnored(MethodBody body) {
|
||||
for (int rem = code.size() - 1; rem >= 0; rem--) {
|
||||
if (code.get(rem).ignored) {
|
||||
removeInstruction(rem, body);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public void removeIgnored(ConstantPool constants,MethodBody body){
|
||||
for (int rem = code.size() - 1; rem >= 0; rem--) {
|
||||
if (code.get(rem).ignored) {
|
||||
removeInstruction(rem, body);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
public void removeIgnored(ConstantPool constants, MethodBody body) {
|
||||
try {
|
||||
List<Integer> outputMap=new ArrayList<Integer>();
|
||||
String src=toASMSource(constants, body,outputMap);
|
||||
AVM2Code acode=ASM3Parser.parse(new ByteArrayInputStream(src.getBytes()), constants, body);
|
||||
List<Integer> outputMap = new ArrayList<Integer>();
|
||||
String src = toASMSource(constants, body, outputMap);
|
||||
AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(src.getBytes()), constants, body);
|
||||
for (int i = 0; i < acode.code.size(); i++) {
|
||||
if (outputMap.size() > i) {
|
||||
int tpos = outputMap.get(i);
|
||||
@@ -2879,9 +2877,9 @@ public class AVM2Code implements Serializable {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.code=acode.code;
|
||||
} catch (Exception ex){
|
||||
}
|
||||
this.code = acode.code;
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
invalidateCache();
|
||||
}
|
||||
|
||||
@@ -2891,18 +2889,18 @@ public class AVM2Code implements Serializable {
|
||||
int cnt = 0;
|
||||
for (int i = code.size() - 1; i >= 0; i--) {
|
||||
if (refs.get(i).isEmpty()) {
|
||||
code.get(i).ignored=true;
|
||||
code.get(i).ignored = true;
|
||||
//removeInstruction(i, body);
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
removeIgnored(constants, body);
|
||||
for (int i = code.size() - 1; i >= 0; i--) {
|
||||
AVM2Instruction ins = code.get(i);
|
||||
if (ins.definition instanceof JumpIns) {
|
||||
if (ins.operands[0] == 0) {
|
||||
code.get(i).ignored=true;
|
||||
code.get(i).ignored = true;
|
||||
//removeInstruction(i, body);
|
||||
cnt++;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.asdec.abc.avm2;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
@@ -10,11 +26,11 @@ import java.util.Stack;
|
||||
*/
|
||||
public class ConvertOutput {
|
||||
|
||||
public Stack<TreeItem> stack;
|
||||
public List<TreeItem> output;
|
||||
public Stack<TreeItem> stack;
|
||||
public List<TreeItem> output;
|
||||
|
||||
public ConvertOutput(Stack<TreeItem> stack, List<TreeItem> output) {
|
||||
this.stack = stack;
|
||||
this.output = output;
|
||||
}
|
||||
public ConvertOutput(Stack<TreeItem> stack, List<TreeItem> output) {
|
||||
this.stack = stack;
|
||||
this.output = output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
*/
|
||||
package com.jpexs.asdec.abc.avm2.graph;
|
||||
|
||||
import com.jpexs.asdec.graph.Graph;
|
||||
import com.jpexs.asdec.graph.GraphPart;
|
||||
import com.jpexs.asdec.graph.Loop;
|
||||
import com.jpexs.asdec.graph.GraphPartMulti;
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.ConvertException;
|
||||
@@ -33,10 +29,7 @@ import com.jpexs.asdec.abc.avm2.instructions.jumps.JumpIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.jumps.LookupSwitchIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.localregs.GetLocalTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.localregs.KillIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.localregs.SetLocalTypeIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.other.LabelIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.other.NextNameIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.other.NextValueIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.other.ReturnValueIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.other.ReturnVoidIns;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.other.ThrowIns;
|
||||
@@ -75,7 +68,10 @@ import com.jpexs.asdec.abc.avm2.treemodel.operations.LogicalOp;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.operations.OrTreeItem;
|
||||
import com.jpexs.asdec.abc.types.ABCException;
|
||||
import com.jpexs.asdec.abc.types.MethodBody;
|
||||
import com.jpexs.asdec.helpers.Highlighting;
|
||||
import com.jpexs.asdec.graph.Graph;
|
||||
import com.jpexs.asdec.graph.GraphPart;
|
||||
import com.jpexs.asdec.graph.GraphPartMulti;
|
||||
import com.jpexs.asdec.graph.Loop;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@@ -89,7 +85,7 @@ import java.util.logging.Logger;
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class AVM2Graph extends Graph{
|
||||
public class AVM2Graph extends Graph {
|
||||
|
||||
private AVM2Code code;
|
||||
private ABC abc;
|
||||
@@ -101,12 +97,10 @@ public class AVM2Graph extends Graph{
|
||||
this.abc = abc;
|
||||
this.body = body;
|
||||
for (GraphPart head : heads) {
|
||||
fixGraph(head);
|
||||
fixGraph(head);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static List<TreeItem> translateViaGraph(String path, AVM2Code code, ABC abc, MethodBody body) {
|
||||
AVM2Graph g = new AVM2Graph(code, abc, body);
|
||||
List<GraphPart> allParts = new ArrayList<GraphPart>();
|
||||
@@ -116,8 +110,6 @@ public class AVM2Graph extends Graph{
|
||||
return g.printGraph(path, new Stack<TreeItem>(), new Stack<TreeItem>(), allParts, new ArrayList<ABCException>(), new ArrayList<Integer>(), 0, null, g.heads.get(0), null, new ArrayList<Loop>(), new HashMap<Integer, TreeItem>(), body, new ArrayList<Integer>());
|
||||
}
|
||||
|
||||
|
||||
|
||||
private TreeItem checkLoop(GraphPart part, GraphPart stopPart, List<Loop> loops) {
|
||||
if (part == stopPart) {
|
||||
return null;
|
||||
@@ -486,12 +478,12 @@ public class AVM2Graph extends Graph{
|
||||
}
|
||||
}
|
||||
boolean loop = false;
|
||||
boolean reversed=false;
|
||||
boolean reversed = false;
|
||||
if ((!part.nextParts.isEmpty()) && part.nextParts.get(0).leadsTo(part, loopContinues)) {
|
||||
loop = true;
|
||||
}else if ((part.nextParts.size()>1) && part.nextParts.get(1).leadsTo(part, loopContinues)) {
|
||||
} else if ((part.nextParts.size() > 1) && part.nextParts.get(1).leadsTo(part, loopContinues)) {
|
||||
loop = true;
|
||||
reversed=true;
|
||||
reversed = true;
|
||||
}
|
||||
if (((part.nextParts.size() == 2) || ((part.nextParts.size() == 1) && loop)) && (!isSwitch)) {
|
||||
|
||||
@@ -512,7 +504,7 @@ public class AVM2Graph extends Graph{
|
||||
}
|
||||
|
||||
if (part.nextParts.size() > 1) {
|
||||
currentLoop.loopBreak = part.nextParts.get(reversed?0:1);
|
||||
currentLoop.loopBreak = part.nextParts.get(reversed ? 0 : 1);
|
||||
}
|
||||
|
||||
int breakIp = -1;
|
||||
@@ -541,7 +533,7 @@ public class AVM2Graph extends Graph{
|
||||
GraphPart finalPart = null;
|
||||
boolean isFor = false;
|
||||
try {
|
||||
loopBody = printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, part.nextParts.get(reversed?1:0), stopPart, loops, localRegs, body, ignoredSwitches);
|
||||
loopBody = printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, part.nextParts.get(reversed ? 1 : 0), stopPart, loops, localRegs, body, ignoredSwitches);
|
||||
} catch (ForException fex) {
|
||||
loopBody = fex.output;
|
||||
finalCommands = fex.finalOutput;
|
||||
@@ -551,9 +543,8 @@ public class AVM2Graph extends Graph{
|
||||
finalPart = fex.continuePart;
|
||||
isFor = true;
|
||||
for (Object o : finalPart.forContinues) {
|
||||
if(o instanceof ContinueTreeItem)
|
||||
{
|
||||
((ContinueTreeItem)o).loopPos = breakIp;
|
||||
if (o instanceof ContinueTreeItem) {
|
||||
((ContinueTreeItem) o).loopPos = breakIp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -632,16 +623,16 @@ public class AVM2Graph extends Graph{
|
||||
|
||||
if (onTrue.isEmpty() && onFalse.isEmpty() && (trueStack.size() > stackSizeBefore) && (falseStack.size() > stackSizeBefore)) {
|
||||
stack.push(new TernarOpTreeItem(null, expr, trueStack.pop(), falseStack.pop()));
|
||||
} else {
|
||||
} else {
|
||||
ret.add(new IfTreeItem(null, expr, onTrue, onFalse));
|
||||
|
||||
|
||||
//Same continues in onTrue and onFalse gets continue on parent level
|
||||
if((!onTrue.isEmpty())&&(!onFalse.isEmpty())){
|
||||
if(onTrue.get(onTrue.size()-1) instanceof ContinueTreeItem){
|
||||
if(onFalse.get(onFalse.size()-1) instanceof ContinueTreeItem){
|
||||
if(((ContinueTreeItem)onTrue.get(onTrue.size()-1)).loopPos==((ContinueTreeItem)onFalse.get(onFalse.size()-1)).loopPos){
|
||||
onTrue.remove(onTrue.size()-1);
|
||||
ret.add(onFalse.remove(onFalse.size()-1));
|
||||
if ((!onTrue.isEmpty()) && (!onFalse.isEmpty())) {
|
||||
if (onTrue.get(onTrue.size() - 1) instanceof ContinueTreeItem) {
|
||||
if (onFalse.get(onFalse.size() - 1) instanceof ContinueTreeItem) {
|
||||
if (((ContinueTreeItem) onTrue.get(onTrue.size() - 1)).loopPos == ((ContinueTreeItem) onFalse.get(onFalse.size() - 1)).loopPos) {
|
||||
onTrue.remove(onTrue.size() - 1);
|
||||
ret.add(onFalse.remove(onFalse.size() - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -650,7 +641,7 @@ public class AVM2Graph extends Graph{
|
||||
}
|
||||
if (loop && (part.nextParts.size() > 1)) {
|
||||
loops.remove(currentLoop); //remove loop so no break shows up
|
||||
ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level, part, part.nextParts.get(reversed?0:1), stopPart, loops, localRegs, body, ignoredSwitches));
|
||||
ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level, part, part.nextParts.get(reversed ? 0 : 1), stopPart, loops, localRegs, body, ignoredSwitches));
|
||||
}
|
||||
|
||||
if (next != null) {
|
||||
@@ -805,8 +796,6 @@ public class AVM2Graph extends Graph{
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private List<GraphPart> makeGraph(AVM2Code code, List<GraphPart> allBlocks, MethodBody body) {
|
||||
HashMap<Integer, List<Integer>> refs = code.visitCode(body);
|
||||
List<GraphPart> ret = new ArrayList<GraphPart>();
|
||||
|
||||
@@ -1,22 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.asdec.abc.avm2.graph;
|
||||
|
||||
import com.jpexs.asdec.graph.GraphPart;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.graph.GraphPart;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ForException extends RuntimeException{
|
||||
public class ForException extends RuntimeException {
|
||||
|
||||
public List<TreeItem> output;
|
||||
public List<TreeItem> finalOutput;
|
||||
public GraphPart continuePart;
|
||||
|
||||
public ForException(List<TreeItem> output,List<TreeItem> finalOutput, GraphPart continuePart) {
|
||||
this.output=output;
|
||||
this.finalOutput=finalOutput;
|
||||
this.continuePart=continuePart;
|
||||
|
||||
public ForException(List<TreeItem> output, List<TreeItem> finalOutput, GraphPart continuePart) {
|
||||
this.output = output;
|
||||
this.finalOutput = finalOutput;
|
||||
this.continuePart = continuePart;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AVM2Instruction implements Serializable{
|
||||
public class AVM2Instruction implements Serializable {
|
||||
|
||||
public InstructionDefinition definition;
|
||||
public int operands[];
|
||||
@@ -35,8 +35,8 @@ public class AVM2Instruction implements Serializable{
|
||||
public String comment;
|
||||
public boolean ignored = false;
|
||||
public String labelname;
|
||||
public long mappedOffset=-1;
|
||||
public int changeJumpTo=-1;
|
||||
public long mappedOffset = -1;
|
||||
public int changeJumpTo = -1;
|
||||
|
||||
public AVM2Instruction(long offset, InstructionDefinition definition, int[] operands, byte bytes[]) {
|
||||
this.definition = definition;
|
||||
@@ -214,8 +214,6 @@ public class AVM2Instruction implements Serializable{
|
||||
public boolean isIgnored() {
|
||||
return ignored;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String toString(ConstantPool constants, List<String> fullyQualifiedNames) {
|
||||
String s = Helper.formatAddress(offset) + " " + Helper.padSpaceRight(Helper.byteArrToString(getBytes()), 30) + definition.instructionName;
|
||||
@@ -228,6 +226,5 @@ public class AVM2Instruction implements Serializable{
|
||||
s += getParams(constants, fullyQualifiedNames) + getComment();
|
||||
return s;
|
||||
}
|
||||
|
||||
public List replaceWith;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
public class InstructionDefinition implements Serializable{
|
||||
public class InstructionDefinition implements Serializable {
|
||||
|
||||
protected String hilighOffset(String text, long offset) {
|
||||
return Highlighting.hilighOffset(text, offset);
|
||||
|
||||
@@ -25,7 +25,4 @@ public class TagInstruction extends InstructionDefinition {
|
||||
public TagInstruction(String tagName) {
|
||||
super(-1, tagName, new int[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ 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.ConstructTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.FullMultinameTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.XMLTreeItem;
|
||||
|
||||
@@ -43,7 +43,7 @@ public class NewFunctionIns extends InstructionDefinition {
|
||||
String bodyStr = "";
|
||||
String paramStr = "";
|
||||
if (mybody != null) {
|
||||
bodyStr = Highlighting.hilighMethodEnd() + mybody.toString("",false, isStatic, classIndex, abc, constants, method_info, new Stack<TreeItem>()/*scopeStack*/, false, true, fullyQualifiedNames, null) + Highlighting.hilighMethodBegin(body.method_info);
|
||||
bodyStr = Highlighting.hilighMethodEnd() + mybody.toString("", false, isStatic, classIndex, abc, constants, method_info, new Stack<TreeItem>()/*scopeStack*/, false, true, fullyQualifiedNames, null) + Highlighting.hilighMethodBegin(body.method_info);
|
||||
paramStr = method_info[methodIndex].getParamStr(constants, mybody, abc, fullyQualifiedNames);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class GetScopeObjectIns extends InstructionDefinition {
|
||||
@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, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
|
||||
int index = ins.operands[0];
|
||||
if(scopeStack.size()<=index){
|
||||
if (scopeStack.size() <= index) {
|
||||
System.out.println("uuu");
|
||||
}
|
||||
stack.push(scopeStack.get(index));
|
||||
|
||||
@@ -21,7 +21,6 @@ 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.HasNextTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.InTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.LocalRegTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
|
||||
@@ -21,7 +21,6 @@ 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.HasNextTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.InTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class NextValueIns extends InstructionDefinition {
|
||||
@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, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
|
||||
TreeItem index = stack.pop();
|
||||
TreeItem obj = stack.pop();
|
||||
TreeItem obj = stack.pop();
|
||||
stack.push(new NextValueTreeItem(ins, index, obj));
|
||||
}
|
||||
|
||||
|
||||
@@ -24,10 +24,8 @@ import com.jpexs.asdec.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.WithEndTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.WithObjectTreeItem;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.WithTreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodBody;
|
||||
import com.jpexs.asdec.abc.types.MethodInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
@@ -48,8 +46,8 @@ public class PopScopeIns extends InstructionDefinition {
|
||||
TreeItem scope = (TreeItem) scopeStack.pop();
|
||||
if (scope instanceof WithObjectTreeItem) {
|
||||
scope = ((WithObjectTreeItem) scope).scope;
|
||||
output.add(new WithEndTreeItem(ins,scope));
|
||||
}
|
||||
output.add(new WithEndTreeItem(ins, scope));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.asdec.abc.avm2.treemodel;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
@@ -10,22 +26,21 @@ import java.util.List;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class CommentTreeItem extends TreeItem {
|
||||
|
||||
public String comment;
|
||||
public CommentTreeItem(AVM2Instruction instruction,String comment) {
|
||||
|
||||
public CommentTreeItem(AVM2Instruction instruction, String comment) {
|
||||
super(instruction, NOPRECEDENCE);
|
||||
this.comment=comment;
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
|
||||
return "//"+comment;
|
||||
return "//" + comment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsSemicolon() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ConstructPropTreeItem extends TreeItem {
|
||||
String objstr = object.toString(constants, localRegNames, fullyQualifiedNames);
|
||||
if (!objstr.equals("")) {
|
||||
objstr += ".";
|
||||
}
|
||||
}
|
||||
return hilight("new ") + objstr + propertyName.toString(constants, localRegNames, fullyQualifiedNames) + hilight("(") + argStr + hilight(")");
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,19 @@
|
||||
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.asdec.abc.avm2.treemodel;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
@@ -11,17 +26,18 @@ import java.util.List;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class HasNextTreeItem extends TreeItem {
|
||||
|
||||
public TreeItem object;
|
||||
public TreeItem collection;
|
||||
|
||||
public HasNextTreeItem(AVM2Instruction instruction, TreeItem object, TreeItem collection) {
|
||||
super(instruction, NOPRECEDENCE);
|
||||
this.object=object;
|
||||
this.collection=collection;
|
||||
this.object = object;
|
||||
this.collection = collection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
|
||||
return collection.toString(constants, localRegNames, fullyQualifiedNames)+" hasNext "+object.toString(constants, localRegNames, fullyQualifiedNames);
|
||||
return collection.toString(constants, localRegNames, fullyQualifiedNames) + " hasNext " + object.toString(constants, localRegNames, fullyQualifiedNames);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.asdec.abc.avm2.treemodel;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
@@ -13,15 +29,15 @@ public class NextNameTreeItem extends TreeItem {
|
||||
|
||||
TreeItem index;
|
||||
TreeItem obj;
|
||||
public NextNameTreeItem(AVM2Instruction instruction,TreeItem index,TreeItem obj) {
|
||||
|
||||
public NextNameTreeItem(AVM2Instruction instruction, TreeItem index, TreeItem obj) {
|
||||
super(instruction, NOPRECEDENCE);
|
||||
this.index=index;
|
||||
this.obj=obj;
|
||||
this.index = index;
|
||||
this.obj = obj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
|
||||
return "nextName("+index.toString(constants, localRegNames, fullyQualifiedNames) +","+obj.toString(constants, localRegNames, fullyQualifiedNames)+")";
|
||||
return "nextName(" + index.toString(constants, localRegNames, fullyQualifiedNames) + "," + obj.toString(constants, localRegNames, fullyQualifiedNames) + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.asdec.abc.avm2.treemodel;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
@@ -13,15 +29,15 @@ public class NextValueTreeItem extends TreeItem {
|
||||
|
||||
TreeItem index;
|
||||
TreeItem obj;
|
||||
public NextValueTreeItem(AVM2Instruction instruction,TreeItem index,TreeItem obj) {
|
||||
|
||||
public NextValueTreeItem(AVM2Instruction instruction, TreeItem index, TreeItem obj) {
|
||||
super(instruction, NOPRECEDENCE);
|
||||
this.index=index;
|
||||
this.obj=obj;
|
||||
this.index = index;
|
||||
this.obj = obj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
|
||||
return "nextValue("+index.toString(constants, localRegNames, fullyQualifiedNames) +","+obj.toString(constants, localRegNames, fullyQualifiedNames)+")";
|
||||
return "nextValue(" + index.toString(constants, localRegNames, fullyQualifiedNames) + "," + obj.toString(constants, localRegNames, fullyQualifiedNames) + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ public class SetSlotTreeItem extends TreeItem implements SetTypeTreeItem, Assign
|
||||
}
|
||||
}
|
||||
}*/
|
||||
if(slotName==null){
|
||||
return ret+"/*UnknownSlot*/";
|
||||
if (slotName == null) {
|
||||
return ret + "/*UnknownSlot*/";
|
||||
}
|
||||
return ret + hilight(slotName.getName(constants, fullyQualifiedNames));
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.helpers.Highlighting;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
public abstract class TreeItem {
|
||||
|
||||
@@ -69,9 +68,9 @@ public abstract class TreeItem {
|
||||
if (instruction == null) {
|
||||
return str;
|
||||
}
|
||||
if(instruction.mappedOffset>=0){
|
||||
if (instruction.mappedOffset >= 0) {
|
||||
return Highlighting.hilighOffset(str, instruction.mappedOffset);
|
||||
}else{
|
||||
} else {
|
||||
return Highlighting.hilighOffset(str, instruction.offset);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class WithEndTreeItem extends TreeItem {
|
||||
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
|
||||
return hilight("}");
|
||||
}
|
||||
|
||||
|
||||
public boolean needsSemicolon() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -44,12 +44,12 @@ public class WithTreeItem extends TreeItem {
|
||||
String ret;
|
||||
ret = hilight("with(") + scope.toString(constants, localRegNames, fullyQualifiedNames) + hilight(")\r\n{\r\n");
|
||||
/*for (TreeItem ti : items) {
|
||||
ret += ti.toString(constants, localRegNames, fullyQualifiedNames) + "\r\n";
|
||||
}
|
||||
ret += hilight("}");*/
|
||||
ret += ti.toString(constants, localRegNames, fullyQualifiedNames) + "\r\n";
|
||||
}
|
||||
ret += hilight("}");*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public boolean needsSemicolon() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ForInTreeItem extends LoopTreeItem implements Block {
|
||||
}
|
||||
this.expression = expression;
|
||||
this.commands = commands;
|
||||
|
||||
|
||||
if ((!commands.isEmpty()) && (commands.get(commands.size() - 1) instanceof ContinueTreeItem)) {
|
||||
if (((ContinueTreeItem) commands.get(commands.size() - 1)).loopPos == loopBreak) {
|
||||
commands.remove(commands.size() - 1);
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ForTreeItem extends LoopTreeItem implements Block {
|
||||
this.expression = expression;
|
||||
this.finalCommands = finalCommands;
|
||||
this.commands = commands;
|
||||
|
||||
|
||||
if ((!commands.isEmpty()) && (commands.get(commands.size() - 1) instanceof ContinueTreeItem)) {
|
||||
if (((ContinueTreeItem) commands.get(commands.size() - 1)).loopPos == loopBreak) {
|
||||
commands.remove(commands.size() - 1);
|
||||
|
||||
@@ -34,13 +34,13 @@ public class SwitchTreeItem extends LoopTreeItem implements Block {
|
||||
public List<TreeItem> defaultCommands;
|
||||
public List<Integer> valuesMapping;
|
||||
|
||||
public SwitchTreeItem(AVM2Instruction instruction, int switchBreak, TreeItem switchedObject, List<TreeItem> caseValues, List<List<TreeItem>> caseCommands, List<TreeItem> defaultCommands,List<Integer> valuesMapping) {
|
||||
public SwitchTreeItem(AVM2Instruction instruction, int switchBreak, TreeItem switchedObject, List<TreeItem> caseValues, List<List<TreeItem>> caseCommands, List<TreeItem> defaultCommands, List<Integer> valuesMapping) {
|
||||
super(instruction, switchBreak, -1);
|
||||
this.switchedObject = switchedObject;
|
||||
this.caseValues = caseValues;
|
||||
this.caseCommands = caseCommands;
|
||||
this.defaultCommands = defaultCommands;
|
||||
this.valuesMapping=valuesMapping;
|
||||
this.valuesMapping = valuesMapping;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,9 +49,9 @@ public class SwitchTreeItem extends LoopTreeItem implements Block {
|
||||
ret += "loop" + loopBreak + ":\r\n";
|
||||
ret += hilight("switch(") + switchedObject.toString(constants, localRegNames, fullyQualifiedNames) + hilight(")") + "\r\n{\r\n";
|
||||
for (int i = 0; i < caseCommands.size(); i++) {
|
||||
for(int k=0;k<valuesMapping.size();k++){
|
||||
if(valuesMapping.get(k)==i){
|
||||
ret += "case " + caseValues.get(k).toString(constants, localRegNames, fullyQualifiedNames) + ":\r\n";
|
||||
for (int k = 0; k < valuesMapping.size(); k++) {
|
||||
if (valuesMapping.get(k) == i) {
|
||||
ret += "case " + caseValues.get(k).toString(constants, localRegNames, fullyQualifiedNames) + ":\r\n";
|
||||
}
|
||||
}
|
||||
ret += AVM2Code.IDENTOPEN + "\r\n";
|
||||
@@ -61,7 +61,7 @@ public class SwitchTreeItem extends LoopTreeItem implements Block {
|
||||
ret += AVM2Code.IDENTCLOSE + "\r\n";
|
||||
}
|
||||
if (defaultCommands.size() > 0) {
|
||||
if(!((defaultCommands.size()==1)&&(defaultCommands.get(0) instanceof BreakTreeItem)&&(((BreakTreeItem)defaultCommands.get(0)).loopPos==loopBreak))){
|
||||
if (!((defaultCommands.size() == 1) && (defaultCommands.get(0) instanceof BreakTreeItem) && (((BreakTreeItem) defaultCommands.get(0)).loopPos == loopBreak))) {
|
||||
ret += hilight("default") + ":\r\n";
|
||||
ret += AVM2Code.IDENTOPEN + "\r\n";
|
||||
for (int j = 0; j < defaultCommands.size(); j++) {
|
||||
@@ -69,7 +69,7 @@ public class SwitchTreeItem extends LoopTreeItem implements Block {
|
||||
}
|
||||
ret += AVM2Code.IDENTCLOSE + "\r\n";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
ret += hilight("}") + "\r\n";
|
||||
ret += ":loop" + loopBreak;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class WhileTreeItem extends LoopTreeItem implements Block {
|
||||
super(instruction, loopBreak, loopContinue);
|
||||
this.expression = expression;
|
||||
this.commands = commands;
|
||||
|
||||
|
||||
if ((!commands.isEmpty()) && (commands.get(commands.size() - 1) instanceof ContinueTreeItem)) {
|
||||
if (((ContinueTreeItem) commands.get(commands.size() - 1)).loopPos == loopBreak) {
|
||||
commands.remove(commands.size() - 1);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class EqTreeItem extends BinaryOpTreeItem implements LogicalOp {
|
||||
public EqTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) {
|
||||
super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "==");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TreeItem invert() {
|
||||
return new NeqTreeItem(instruction, leftSide, rightSide);
|
||||
|
||||
@@ -19,12 +19,12 @@ package com.jpexs.asdec.abc.avm2.treemodel.operations;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
|
||||
public class GeTreeItem extends BinaryOpTreeItem implements LogicalOp{
|
||||
public class GeTreeItem extends BinaryOpTreeItem implements LogicalOp {
|
||||
|
||||
public GeTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) {
|
||||
super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, ">=");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TreeItem invert() {
|
||||
return new LtTreeItem(instruction, leftSide, rightSide);
|
||||
|
||||
@@ -19,12 +19,12 @@ package com.jpexs.asdec.abc.avm2.treemodel.operations;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
|
||||
public class GtTreeItem extends BinaryOpTreeItem implements LogicalOp{
|
||||
public class GtTreeItem extends BinaryOpTreeItem implements LogicalOp {
|
||||
|
||||
public GtTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) {
|
||||
super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, ">");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TreeItem invert() {
|
||||
return new LeTreeItem(instruction, leftSide, rightSide);
|
||||
|
||||
@@ -19,12 +19,12 @@ package com.jpexs.asdec.abc.avm2.treemodel.operations;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
|
||||
public class LeTreeItem extends BinaryOpTreeItem implements LogicalOp{
|
||||
public class LeTreeItem extends BinaryOpTreeItem implements LogicalOp {
|
||||
|
||||
public LeTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) {
|
||||
super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, "<=");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TreeItem invert() {
|
||||
return new GtTreeItem(instruction, leftSide, rightSide);
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.asdec.abc.avm2.treemodel.operations;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
@@ -7,5 +23,6 @@ import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface LogicalOp {
|
||||
|
||||
public TreeItem invert();
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ package com.jpexs.asdec.abc.avm2.treemodel.operations;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
|
||||
public class LtTreeItem extends BinaryOpTreeItem implements LogicalOp{
|
||||
public class LtTreeItem extends BinaryOpTreeItem implements LogicalOp {
|
||||
|
||||
public LtTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) {
|
||||
super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, "<");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TreeItem invert() {
|
||||
return new GeTreeItem(instruction, leftSide, rightSide);
|
||||
|
||||
@@ -19,7 +19,7 @@ package com.jpexs.asdec.abc.avm2.treemodel.operations;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
|
||||
public class NotTreeItem extends UnaryOpTreeItem implements LogicalOp{
|
||||
public class NotTreeItem extends UnaryOpTreeItem implements LogicalOp {
|
||||
|
||||
public NotTreeItem(AVM2Instruction instruction, TreeItem value) {
|
||||
super(instruction, PRECEDENCE_UNARY, value, "!");
|
||||
@@ -34,7 +34,7 @@ public class NotTreeItem extends UnaryOpTreeItem implements LogicalOp{
|
||||
public boolean isFalse() {
|
||||
return !value.isFalse();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TreeItem invert() {
|
||||
return value;
|
||||
|
||||
@@ -19,12 +19,12 @@ package com.jpexs.asdec.abc.avm2.treemodel.operations;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
|
||||
public class StrictEqTreeItem extends BinaryOpTreeItem implements LogicalOp{
|
||||
public class StrictEqTreeItem extends BinaryOpTreeItem implements LogicalOp {
|
||||
|
||||
public StrictEqTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) {
|
||||
super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "===");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TreeItem invert() {
|
||||
return new StrictNeqTreeItem(instruction, leftSide, rightSide);
|
||||
|
||||
@@ -19,12 +19,12 @@ package com.jpexs.asdec.abc.avm2.treemodel.operations;
|
||||
import com.jpexs.asdec.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
|
||||
public class StrictNeqTreeItem extends BinaryOpTreeItem implements LogicalOp{
|
||||
public class StrictNeqTreeItem extends BinaryOpTreeItem implements LogicalOp {
|
||||
|
||||
public StrictNeqTreeItem(AVM2Instruction instruction, TreeItem leftSide, TreeItem rightSide) {
|
||||
super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "!==");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TreeItem invert() {
|
||||
return new StrictEqTreeItem(instruction, leftSide, rightSide);
|
||||
|
||||
@@ -147,7 +147,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
|
||||
oneList.add(list.get(index));
|
||||
this.abc = list.get(index).abc;
|
||||
classTree.setDoABCTags(oneList);
|
||||
}
|
||||
}
|
||||
updateConstList();
|
||||
}
|
||||
|
||||
@@ -183,9 +183,9 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
decompiledTextArea = new DecompiledEditorPane(this);
|
||||
decompiledScrollPane = new JScrollPane(decompiledTextArea);
|
||||
decompiledScrollPane = new JScrollPane(decompiledTextArea);
|
||||
detailPanel = new DetailPanel(this);
|
||||
JPanel panB = new JPanel();
|
||||
panB.setLayout(new BorderLayout());
|
||||
@@ -243,7 +243,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
|
||||
|
||||
JPanel treePanel = new JPanel();
|
||||
treePanel.setLayout(new BorderLayout());
|
||||
treePanel.add(new JScrollPane(classTree = new ClassesListTree(list,this)), BorderLayout.CENTER);
|
||||
treePanel.add(new JScrollPane(classTree = new ClassesListTree(list, this)), BorderLayout.CENTER);
|
||||
JPanel searchPanel = new JPanel();
|
||||
searchPanel.setLayout(new BorderLayout());
|
||||
searchPanel.add(filterField, BorderLayout.CENTER);
|
||||
@@ -289,7 +289,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
|
||||
constantTable.setAutoCreateRowSorter(true);
|
||||
|
||||
final List<DoABCTag> inlist = list;
|
||||
final ABCPanel t=this;
|
||||
final ABCPanel t = this;
|
||||
constantTable.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
@@ -301,7 +301,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
|
||||
}
|
||||
int multinameIndex = constantTable.convertRowIndexToModel(rowIndex);
|
||||
if (multinameIndex > 0) {
|
||||
UsageFrame usageFrame = new UsageFrame(inlist, abc, multinameIndex,t);
|
||||
UsageFrame usageFrame = new UsageFrame(inlist, abc, multinameIndex, t);
|
||||
usageFrame.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,8 +43,6 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi
|
||||
public void setIgnoreCarret(boolean ignoreCarret) {
|
||||
this.ignoreCarret = ignoreCarret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ASMSourceEditorPane(DecompiledEditorPane decompiledEditor) {
|
||||
this.decompiledEditor = decompiledEditor;
|
||||
@@ -52,7 +50,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi
|
||||
}
|
||||
|
||||
public void hilighOffset(long offset) {
|
||||
if(isEditable()){
|
||||
if (isEditable()) {
|
||||
return;
|
||||
}
|
||||
for (Highlighting h2 : disassembledHilights) {
|
||||
@@ -73,7 +71,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi
|
||||
}
|
||||
|
||||
public void graph() {
|
||||
AVM2Graph gr = new AVM2Graph(abc.bodies[bodyIndex].code,abc,abc.bodies[bodyIndex]);
|
||||
AVM2Graph gr = new AVM2Graph(abc.bodies[bodyIndex].code, abc, abc.bodies[bodyIndex]);
|
||||
(new GraphFrame(gr, "")).setVisible(true);
|
||||
}
|
||||
|
||||
@@ -102,7 +100,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi
|
||||
@Override
|
||||
public void setText(String t) {
|
||||
disassembledHilights = Highlighting.getInstrHighlights(t);
|
||||
t=Highlighting.stripHilights(t);
|
||||
t = Highlighting.stripHilights(t);
|
||||
super.setText(t);
|
||||
}
|
||||
|
||||
@@ -180,7 +178,7 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi
|
||||
|
||||
@Override
|
||||
public void caretUpdate(CaretEvent e) {
|
||||
if(isEditable()){
|
||||
if (isEditable()) {
|
||||
return;
|
||||
}
|
||||
if (ignoreCarret) {
|
||||
|
||||
@@ -45,10 +45,10 @@ public class ClassesListTree extends JTree implements TreeSelectionListener {
|
||||
scrollPathToVisible(treePath);
|
||||
}
|
||||
|
||||
public ClassesListTree(List<DoABCTag> list,ABCPanel abcPanel) {
|
||||
public ClassesListTree(List<DoABCTag> list, ABCPanel abcPanel) {
|
||||
this.abcList = list;
|
||||
this.treeList = getTreeList(list);
|
||||
this.abcPanel=abcPanel;
|
||||
this.abcPanel = abcPanel;
|
||||
setModel(new ClassesListTreeModel(this.treeList));
|
||||
addTreeSelectionListener(this);
|
||||
DefaultTreeCellRenderer treeRenderer = new DefaultTreeCellRenderer();
|
||||
|
||||
@@ -16,28 +16,19 @@
|
||||
*/
|
||||
package com.jpexs.asdec.abc.gui;
|
||||
|
||||
import com.jpexs.asdec.Main;
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.avm2.ConvertException;
|
||||
import com.jpexs.asdec.abc.types.ScriptInfo;
|
||||
import com.jpexs.asdec.abc.types.traits.Trait;
|
||||
import com.jpexs.asdec.abc.types.traits.TraitSlotConst;
|
||||
import com.jpexs.asdec.helpers.Highlighting;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JViewport;
|
||||
import javax.swing.event.CaretEvent;
|
||||
import javax.swing.event.CaretListener;
|
||||
import javax.swing.text.Caret;
|
||||
|
||||
public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretListener {
|
||||
|
||||
@@ -82,7 +73,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
}
|
||||
|
||||
private boolean displayMethod(int pos, int methodIndex) {
|
||||
if(abc==null){
|
||||
if (abc == null) {
|
||||
return false;
|
||||
}
|
||||
int bi = abc.findBodyIndex(methodIndex);
|
||||
@@ -121,7 +112,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
}
|
||||
|
||||
public void caretUpdate(CaretEvent e) {
|
||||
if(abc==null){
|
||||
if (abc == null) {
|
||||
return;
|
||||
}
|
||||
if (ignoreCarret) {
|
||||
@@ -140,7 +131,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (Highlighting tm : methodHighlights) {
|
||||
if ((pos >= tm.startPos) && (pos < tm.startPos + tm.len)) {
|
||||
displayMethod(pos, (int) tm.offset);
|
||||
@@ -154,7 +145,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (classIndex == -1) {
|
||||
setNoTrait();
|
||||
return;
|
||||
@@ -216,20 +207,20 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
if ((th.startPos > tc.startPos) && (th.startPos + th.len < tc.startPos + tc.len)) {
|
||||
if (th.offset == traitId) {
|
||||
try {
|
||||
ignoreCarret=true;
|
||||
ignoreCarret = true;
|
||||
setCaretPosition(th.startPos + th.len - 1);
|
||||
ignoreCarret=false;
|
||||
ignoreCarret = false;
|
||||
} catch (IllegalArgumentException iae) {
|
||||
}
|
||||
final int pos = th.startPos;
|
||||
new Timer().schedule(new TimerTask() {
|
||||
public void run() {
|
||||
try {
|
||||
setCaretPosition(pos);
|
||||
setCaretPosition(pos);
|
||||
} catch (IllegalArgumentException iae) {
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
}, 100);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -242,7 +233,6 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
|
||||
setCaretPosition(0);
|
||||
}
|
||||
|
||||
|
||||
public DecompiledEditorPane(ABCPanel abcPanel) {
|
||||
setEditable(false);
|
||||
@@ -252,12 +242,11 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
}
|
||||
private List<DoABCTag> abcList;
|
||||
|
||||
public void clearScriptCache()
|
||||
{
|
||||
public void clearScriptCache() {
|
||||
bufferedClasses.clear();
|
||||
}
|
||||
|
||||
public void setScript(ScriptInfo script, ABC abc, List<DoABCTag> abcList) {
|
||||
|
||||
public void setScript(ScriptInfo script, ABC abc, List<DoABCTag> abcList) {
|
||||
if (script == null) {
|
||||
highlights = new ArrayList<Highlighting>();
|
||||
traitHighlights = new ArrayList<Highlighting>();
|
||||
@@ -269,7 +258,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
|
||||
String hilightedCode;
|
||||
if (!bufferedClasses.containsKey(script)) {
|
||||
hilightedCode = script.convert(abcList, abc, false, true);
|
||||
hilightedCode = script.convert(abcList, abc, false, true);
|
||||
highlights = Highlighting.getInstrHighlights(hilightedCode);
|
||||
traitHighlights = Highlighting.getTraitHighlights(hilightedCode);
|
||||
methodHighlights = Highlighting.getMethodHighlights(hilightedCode);
|
||||
@@ -287,11 +276,11 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
this.abc = abc;
|
||||
this.abcList = abcList;
|
||||
this.script = script;
|
||||
setText(hilightedCode);
|
||||
setText(hilightedCode);
|
||||
}
|
||||
|
||||
public void reloadClass() {
|
||||
int ci=classIndex;
|
||||
int ci = classIndex;
|
||||
if (bufferedClasses.containsKey(script)) {
|
||||
bufferedClasses.remove(script);
|
||||
}
|
||||
|
||||
@@ -17,22 +17,16 @@
|
||||
package com.jpexs.asdec.abc.gui;
|
||||
|
||||
import com.jpexs.asdec.gui.View;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Hashtable;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSlider;
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.jpexs.asdec.abc.gui;
|
||||
|
||||
import com.jpexs.asdec.Main;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.FlowLayout;
|
||||
@@ -50,7 +49,7 @@ public class DetailPanel extends JPanel implements ActionListener {
|
||||
private ABCPanel abcPanel;
|
||||
|
||||
public DetailPanel(ABCPanel abcPanel) {
|
||||
this.abcPanel=abcPanel;
|
||||
this.abcPanel = abcPanel;
|
||||
innerPanel = new JPanel();
|
||||
CardLayout layout = new CardLayout();
|
||||
innerPanel.setLayout(layout);
|
||||
@@ -111,7 +110,7 @@ public class DetailPanel extends JPanel implements ActionListener {
|
||||
boolean b = cardMap.get(name) instanceof TraitDetail;
|
||||
buttonsPanel.setVisible(b);
|
||||
selectedCard = name;
|
||||
selectedLabel.setText(selectedCard);
|
||||
selectedLabel.setText(selectedCard);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@@ -127,7 +126,7 @@ public class DetailPanel extends JPanel implements ActionListener {
|
||||
if (cardMap.get(selectedCard) instanceof TraitDetail) {
|
||||
if (((TraitDetail) cardMap.get(selectedCard)).save()) {
|
||||
int lasttrait = abcPanel.decompiledTextArea.lastTraitIndex;
|
||||
abcPanel.decompiledTextArea.reloadClass();
|
||||
abcPanel.decompiledTextArea.reloadClass();
|
||||
abcPanel.decompiledTextArea.gotoTrait(lasttrait);
|
||||
JOptionPane.showMessageDialog(this, "Trait Successfully saved");
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.jpexs.asdec.abc.gui;
|
||||
|
||||
import com.jpexs.asdec.abc.avm2.graph.AVM2Graph;
|
||||
import com.jpexs.asdec.graph.Graph;
|
||||
import com.jpexs.asdec.graph.GraphPart;
|
||||
import com.jpexs.asdec.gui.View;
|
||||
@@ -25,7 +24,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
@@ -53,27 +51,27 @@ public class GraphFrame extends JFrame {
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
g.setColor(Color.black);
|
||||
paintPart(g, graph.heads.get(0), 0, getPartWidth(graph.heads.get(0), new HashSet<GraphPart>()) * (BLOCK_WIDTH + SPACE_HORIZONTAL) / 2, new HashMap<GraphPart,Point>());
|
||||
paintPart(g, graph.heads.get(0), 0, getPartWidth(graph.heads.get(0), new HashSet<GraphPart>()) * (BLOCK_WIDTH + SPACE_HORIZONTAL) / 2, new HashMap<GraphPart, Point>());
|
||||
}
|
||||
|
||||
private void paintPart(Graphics g, GraphPart part, int y, int x, HashMap<GraphPart,Point> used) {
|
||||
HashMap<GraphPart,Point> l = new HashMap<GraphPart,Point>();
|
||||
private void paintPart(Graphics g, GraphPart part, int y, int x, HashMap<GraphPart, Point> used) {
|
||||
HashMap<GraphPart, Point> l = new HashMap<GraphPart, Point>();
|
||||
l.putAll(used);
|
||||
HashSet<GraphPart> hs=new HashSet<GraphPart>();
|
||||
HashSet<GraphPart> hs = new HashSet<GraphPart>();
|
||||
hs.addAll(l.keySet());
|
||||
int totalWidthParts = getPartWidth(part, hs);
|
||||
int totalWidth = totalWidthParts * (BLOCK_WIDTH + SPACE_HORIZONTAL);
|
||||
|
||||
|
||||
if (used.containsKey(part)) {
|
||||
g.setColor(Color.black);
|
||||
Point p=used.get(part);
|
||||
Point p = used.get(part);
|
||||
g.drawLine(x, y, p.x, p.y);
|
||||
return;
|
||||
}
|
||||
g.drawRect(x - BLOCK_WIDTH / 2 - SPACE_HORIZONTAL / 2, y, BLOCK_WIDTH, BLOCK_HEIGHT);
|
||||
g.drawString(part.toString(), x - BLOCK_WIDTH / 2, y + BLOCK_HEIGHT);
|
||||
|
||||
used.put(part,new Point(x,y));
|
||||
|
||||
used.put(part, new Point(x, y));
|
||||
if (part.nextParts.size() > 0) {
|
||||
int cx = x - totalWidth / 2;
|
||||
for (int p = 0; p < part.nextParts.size(); p++) {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.jpexs.asdec.abc.gui;
|
||||
|
||||
import com.jpexs.asdec.Main;
|
||||
import com.jpexs.asdec.abc.types.MethodBody;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
@@ -43,9 +42,10 @@ public class MethodBodyParamsPanel extends JPanel implements ChangeListener {
|
||||
public JCheckBox autoFillCheckBox = new JCheckBox("Auto fill on code save (GLOBAL SETTING)");
|
||||
public JLabel experimentalLabel = new JLabel("...EXPERIMENTAL");
|
||||
private ABCPanel abcPanel;
|
||||
|
||||
public MethodBodyParamsPanel(ABCPanel abcPanel) {
|
||||
setLayout(null);
|
||||
this.abcPanel=abcPanel;
|
||||
this.abcPanel = abcPanel;
|
||||
|
||||
maxStackLabel.setBounds(10, 10, 150, 25);
|
||||
maxStackField.setBounds(10 + 150 + 10, 10, 75, 25);
|
||||
|
||||
@@ -35,11 +35,11 @@ public class MethodCodePanel extends JPanel implements ActionListener {
|
||||
|
||||
private ASMSourceEditorPane sourceTextArea;
|
||||
public JPanel buttonsPanel;
|
||||
|
||||
public void focusEditor(){
|
||||
|
||||
public void focusEditor() {
|
||||
sourceTextArea.requestFocusInWindow();
|
||||
}
|
||||
|
||||
|
||||
public void setIgnoreCarret(boolean ignoreCarret) {
|
||||
sourceTextArea.setIgnoreCarret(ignoreCarret);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.jpexs.asdec.abc.gui;
|
||||
|
||||
import com.jpexs.asdec.Main;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
@@ -32,7 +31,7 @@ public class MethodTraitDetailPanel extends JTabbedPane implements TraitDetail {
|
||||
public ABCPanel abcPanel;
|
||||
|
||||
public MethodTraitDetailPanel(ABCPanel abcPanel) {
|
||||
this.abcPanel=abcPanel;
|
||||
this.abcPanel = abcPanel;
|
||||
methodCodePanel = new MethodCodePanel(abcPanel.decompiledTextArea);
|
||||
methodBodyParamsPanel = new MethodBodyParamsPanel(abcPanel);
|
||||
methodInfoPanel = new MethodInfoPanel();
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.jpexs.asdec.abc.gui;
|
||||
|
||||
import com.jpexs.asdec.Main;
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.util.List;
|
||||
@@ -31,13 +30,14 @@ public class TraitsList extends JList implements ListSelectionListener {
|
||||
List<DoABCTag> abcTags;
|
||||
int classIndex = -1;
|
||||
private ABCPanel abcPanel;
|
||||
|
||||
public int getClassIndex() {
|
||||
return classIndex;
|
||||
}
|
||||
|
||||
public TraitsList(ABCPanel abcPanel) {
|
||||
addListSelectionListener(this);
|
||||
this.abcPanel=abcPanel;
|
||||
this.abcPanel = abcPanel;
|
||||
setCellRenderer(new IconListRenderer());
|
||||
}
|
||||
|
||||
|
||||
@@ -46,9 +46,9 @@ public class TraitsListModel implements ListModel {
|
||||
|
||||
public Object getElementAt(int index) {
|
||||
if (index < abc.class_info[classIndex].static_traits.traits.length) {
|
||||
return abc.class_info[classIndex].static_traits.traits[index].convertHeader("",abcTags, abc, true, false, classIndex, false, new ArrayList<String>());
|
||||
return abc.class_info[classIndex].static_traits.traits[index].convertHeader("", abcTags, abc, true, false, classIndex, false, new ArrayList<String>());
|
||||
} else if (index < abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length) {
|
||||
return abc.instance_info[classIndex].instance_traits.traits[index - abc.class_info[classIndex].static_traits.traits.length].convertHeader("",abcTags, abc, false, false, classIndex, false, new ArrayList<String>());
|
||||
return abc.instance_info[classIndex].instance_traits.traits[index - abc.class_info[classIndex].static_traits.traits.length].convertHeader("", abcTags, abc, false, false, classIndex, false, new ArrayList<String>());
|
||||
} else if (index == abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length) {
|
||||
return STR_INSTANCE_INITIALIZER;
|
||||
} else {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.jpexs.asdec.abc.gui;
|
||||
|
||||
import com.jpexs.asdec.Main;
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.usages.InsideClassMultinameUsage;
|
||||
import com.jpexs.asdec.abc.usages.MethodMultinameUsage;
|
||||
@@ -47,8 +46,8 @@ public class UsageFrame extends JFrame implements ActionListener, MouseListener
|
||||
private ABC abc;
|
||||
private ABCPanel abcPanel;
|
||||
|
||||
public UsageFrame(List<DoABCTag> abcTags, ABC abc, int multinameIndex,ABCPanel abcPanel) {
|
||||
this.abcPanel=abcPanel;
|
||||
public UsageFrame(List<DoABCTag> abcTags, ABC abc, int multinameIndex, ABCPanel abcPanel) {
|
||||
this.abcPanel = abcPanel;
|
||||
List<MultinameUsage> usages = abc.findMultinameUsage(multinameIndex);
|
||||
this.abc = abc;
|
||||
usageListModel = new UsageListModel(abcTags, abc);
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.jpexs.asdec.helpers.Helper;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class ABCException implements Serializable{
|
||||
public class ABCException implements Serializable {
|
||||
|
||||
public int start;
|
||||
public int end;
|
||||
|
||||
@@ -21,20 +21,14 @@ import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.avm2.AVM2Code;
|
||||
import com.jpexs.asdec.abc.avm2.CodeStats;
|
||||
import com.jpexs.asdec.abc.avm2.ConstantPool;
|
||||
import com.jpexs.asdec.abc.avm2.parser.ASM3Parser;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.traits.Traits;
|
||||
import com.jpexs.asdec.helpers.Helper;
|
||||
import com.jpexs.asdec.helpers.Highlighting;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class MethodBody implements Cloneable, Serializable {
|
||||
|
||||
|
||||
@@ -42,28 +42,28 @@ public class ScriptInfo {
|
||||
}
|
||||
|
||||
public String getPath(ABC abc) {
|
||||
String packageName="";
|
||||
String scriptName="";
|
||||
int classCount=0;
|
||||
String packageName = "";
|
||||
String scriptName = "";
|
||||
int classCount = 0;
|
||||
for (Trait t : traits.traits) {
|
||||
Multiname name = t.getName(abc);
|
||||
Namespace ns = name.getNamespace(abc.constants);
|
||||
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
|
||||
packageName=ns.getName(abc.constants);
|
||||
scriptName= name.getName(abc.constants, new ArrayList<String>());
|
||||
if(t instanceof TraitClass){
|
||||
packageName = ns.getName(abc.constants);
|
||||
scriptName = name.getName(abc.constants, new ArrayList<String>());
|
||||
if (t instanceof TraitClass) {
|
||||
classCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(classCount>1){
|
||||
if (classCount > 1) {
|
||||
scriptName = "[script]";
|
||||
}
|
||||
return packageName+"."+scriptName;
|
||||
return packageName + "." + scriptName;
|
||||
}
|
||||
|
||||
public String convert(List<DoABCTag> abcTags, ABC abc, boolean pcode, boolean highlighting) {
|
||||
return traits.convert("",abcTags, abc, false, pcode, true, -1, highlighting, new ArrayList<String>());
|
||||
return traits.convert("", abcTags, abc, false, pcode, true, -1, highlighting, new ArrayList<String>());
|
||||
}
|
||||
|
||||
public void export(ABC abc, List<DoABCTag> abcList, String directory, boolean pcode) throws IOException {
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Trait implements Serializable{
|
||||
public abstract class Trait implements Serializable {
|
||||
|
||||
public int name_index;
|
||||
public int kindType;
|
||||
@@ -82,7 +82,7 @@ public abstract class Trait implements Serializable{
|
||||
}
|
||||
}
|
||||
|
||||
if ((!nsname.contains(":"))&&(!nsname.equals(""))) {
|
||||
if ((!nsname.contains(":")) && (!nsname.equals(""))) {
|
||||
ret += " " + nsname;
|
||||
}
|
||||
if (ns != null) {
|
||||
@@ -114,11 +114,11 @@ public abstract class Trait implements Serializable{
|
||||
}
|
||||
|
||||
public String convertPackaged(String path, List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcod, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
return makePackageFromIndex(abc, name_index, convert(path,abcTags, abc, isStatic, pcod, classIndex, highlight, fullyQualifiedNames));
|
||||
return makePackageFromIndex(abc, name_index, convert(path, abcTags, abc, isStatic, pcod, classIndex, highlight, fullyQualifiedNames));
|
||||
}
|
||||
|
||||
public String convertHeader(String path,List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
return convert(path,abcTags, abc, isStatic, pcode, classIndex, highlight, fullyQualifiedNames).trim();
|
||||
public String convertHeader(String path, List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
return convert(path, abcTags, abc, isStatic, pcode, classIndex, highlight, fullyQualifiedNames).trim();
|
||||
}
|
||||
|
||||
protected String makePackageFromIndex(ABC abc, int name_index, String value) {
|
||||
|
||||
@@ -284,14 +284,12 @@ public class TraitClass extends Trait {
|
||||
|
||||
@Override
|
||||
public String convertHeader(String path, List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
String classHeader = abc.instance_info[class_info].getClassHeaderStr(abc, fullyQualifiedNames);
|
||||
return classHeader;
|
||||
String classHeader = abc.instance_info[class_info].getClassHeaderStr(abc, fullyQualifiedNames);
|
||||
return classHeader;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String convert(String path,List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
public String convert(String path, List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
if (!highlight) {
|
||||
Highlighting.doHighlight = false;
|
||||
}
|
||||
@@ -379,7 +377,7 @@ public class TraitClass extends Trait {
|
||||
String bodyStr = "";
|
||||
bodyIndex = abc.findBodyIndex(abc.class_info[class_info].cinit_index);
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = abc.bodies[bodyIndex].toString(packageName+"."+abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames)+".staticinitializer",pcode, true, class_info, abc, abc.constants, abc.method_info, new Stack<TreeItem>(), true, highlight, fullyQualifiedNames, abc.class_info[class_info].static_traits);
|
||||
bodyStr = abc.bodies[bodyIndex].toString(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", pcode, true, class_info, abc, abc.constants, abc.method_info, new Stack<TreeItem>(), true, highlight, fullyQualifiedNames, abc.class_info[class_info].static_traits);
|
||||
}
|
||||
if (Highlighting.stripHilights(bodyStr).equals("")) {
|
||||
toPrint = ABC.addTabs(bodyStr, 3);
|
||||
@@ -413,7 +411,7 @@ public class TraitClass extends Trait {
|
||||
bodyStr = "";
|
||||
bodyIndex = abc.findBodyIndex(abc.instance_info[class_info].iinit_index);
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(packageName+"."+abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) +".initializer",pcode, false, class_info, abc, abc.constants, abc.method_info, new Stack<TreeItem>(), false, highlight, fullyQualifiedNames, abc.instance_info[class_info].instance_traits), 3);
|
||||
bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", pcode, false, class_info, abc, abc.constants, abc.method_info, new Stack<TreeItem>(), false, highlight, fullyQualifiedNames, abc.instance_info[class_info].instance_traits), 3);
|
||||
constructorParams = abc.method_info[abc.instance_info[class_info].iinit_index].getParamStr(abc.constants, abc.bodies[bodyIndex], abc, fullyQualifiedNames);
|
||||
} else {
|
||||
constructorParams = abc.method_info[abc.instance_info[class_info].iinit_index].getParamStr(abc.constants, null, abc, fullyQualifiedNames);
|
||||
@@ -427,9 +425,9 @@ public class TraitClass extends Trait {
|
||||
//}
|
||||
|
||||
//static variables,constants & methods
|
||||
outTraits.add(abc.class_info[class_info].static_traits.convert(packageName+"."+abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames),abcTags, abc, true, pcode, false, class_info, highlight, fullyQualifiedNames));
|
||||
outTraits.add(abc.class_info[class_info].static_traits.convert(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, true, pcode, false, class_info, highlight, fullyQualifiedNames));
|
||||
|
||||
outTraits.add(abc.instance_info[class_info].instance_traits.convert(packageName+"."+abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames),abcTags, abc, false, pcode, false, class_info, highlight, fullyQualifiedNames));
|
||||
outTraits.add(abc.instance_info[class_info].instance_traits.convert(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, false, pcode, false, class_info, highlight, fullyQualifiedNames));
|
||||
|
||||
out.println(Helper.joinStrings(outTraits, "\r\n\r\n"));
|
||||
out.println(ABC.IDENT_STRING + "}");//class
|
||||
|
||||
@@ -35,7 +35,7 @@ public class TraitFunction extends Trait {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertHeader(String path,List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
public String convertHeader(String path, List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
String modifier = getModifiers(abcTags, abc, isStatic) + " ";
|
||||
if (modifier.equals(" ")) {
|
||||
modifier = "";
|
||||
@@ -45,12 +45,12 @@ public class TraitFunction extends Trait {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convert(String path,List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
String header = convertHeader(path,abcTags, abc, isStatic, pcode, classIndex, highlight, fullyQualifiedNames);
|
||||
public String convert(String path, List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
String header = convertHeader(path, abcTags, abc, isStatic, pcode, classIndex, highlight, fullyQualifiedNames);
|
||||
String bodyStr = "";
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path+"."+abc.constants.constant_multiname[name_index].getName(abc.constants, fullyQualifiedNames),pcode, isStatic, classIndex, abc, abc.constants, abc.method_info, new Stack<TreeItem>(), false, highlight, fullyQualifiedNames, null), 3);
|
||||
bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path + "." + abc.constants.constant_multiname[name_index].getName(abc.constants, fullyQualifiedNames), pcode, isStatic, classIndex, abc, abc.constants, abc.method_info, new Stack<TreeItem>(), false, highlight, fullyQualifiedNames, null), 3);
|
||||
}
|
||||
return ABC.IDENT_STRING + ABC.IDENT_STRING + header + (abc.instance_info[classIndex].isInterface() ? ";" : " {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}");
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.abc.types.traits;
|
||||
|
||||
import com.jpexs.asdec.abc.ABC;
|
||||
import com.jpexs.asdec.abc.avm2.graph.AVM2Graph;
|
||||
import com.jpexs.asdec.abc.avm2.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.abc.types.MethodBody;
|
||||
import com.jpexs.asdec.helpers.Helper;
|
||||
@@ -36,7 +35,7 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertHeader(String path,List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
public String convertHeader(String path, List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
String modifier = getModifiers(abcTags, abc, isStatic) + " ";
|
||||
if (modifier.equals(" ")) {
|
||||
modifier = "";
|
||||
@@ -54,14 +53,14 @@ public class TraitMethodGetterSetter extends Trait {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convert(String path,List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
String header = convertHeader(path,abcTags, abc, isStatic, pcode, classIndex, highlight, fullyQualifiedNames);
|
||||
public String convert(String path, List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
String header = convertHeader(path, abcTags, abc, isStatic, pcode, classIndex, highlight, fullyQualifiedNames);
|
||||
|
||||
String bodyStr = "";
|
||||
int bodyIndex = abc.findBodyIndex(method_info);
|
||||
if (bodyIndex != -1) {
|
||||
bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path+"."+getName(abc).getName(abc.constants, fullyQualifiedNames),pcode, isStatic, classIndex, abc, abc.constants, abc.method_info, new Stack<TreeItem>(), false, highlight, fullyQualifiedNames, null), 3);
|
||||
bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames), pcode, isStatic, classIndex, abc, abc.constants, abc.method_info, new Stack<TreeItem>(), false, highlight, fullyQualifiedNames, null), 3);
|
||||
}
|
||||
return ABC.IDENT_STRING + ABC.IDENT_STRING + header + ((classIndex!=-1 && abc.instance_info[classIndex].isInterface()) ? ";" : " {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}");
|
||||
return ABC.IDENT_STRING + ABC.IDENT_STRING + header + ((classIndex != -1 && abc.instance_info[classIndex].isInterface()) ? ";" : " {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class TraitSlotConst extends Trait {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convert(String path,List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
public String convert(String path, List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List<String> fullyQualifiedNames) {
|
||||
String modifier = getModifiers(abcTags, abc, isStatic) + " ";
|
||||
if (modifier.equals(" ")) {
|
||||
modifier = "";
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.jpexs.asdec.tags.DoABCTag;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class Traits implements Serializable{
|
||||
public class Traits implements Serializable {
|
||||
|
||||
public Trait traits[] = new Trait[0];
|
||||
|
||||
@@ -49,7 +49,7 @@ public class Traits implements Serializable{
|
||||
return s;
|
||||
}
|
||||
|
||||
public String convert(String path,List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, boolean makePackages, int classIndex, boolean highlighting, List<String> fullyQualifiedNames) {
|
||||
public String convert(String path, List<DoABCTag> abcTags, ABC abc, boolean isStatic, boolean pcode, boolean makePackages, int classIndex, boolean highlighting, List<String> fullyQualifiedNames) {
|
||||
String s = "";
|
||||
for (int t = 0; t < traits.length; t++) {
|
||||
if (t > 0) {
|
||||
@@ -58,9 +58,9 @@ public class Traits implements Serializable{
|
||||
String plus;
|
||||
//System.out.println(path+":"+traits[t].convertHeader(path, abcTags, abc, isStatic, pcode, classIndex, highlighting, fullyQualifiedNames));
|
||||
if (makePackages) {
|
||||
plus = traits[t].convertPackaged(path,abcTags, abc, isStatic, pcode, classIndex, highlighting, fullyQualifiedNames);
|
||||
plus = traits[t].convertPackaged(path, abcTags, abc, isStatic, pcode, classIndex, highlighting, fullyQualifiedNames);
|
||||
} else {
|
||||
plus = traits[t].convert(path,abcTags, abc, isStatic, pcode, classIndex, highlighting, fullyQualifiedNames);
|
||||
plus = traits[t].convert(path, abcTags, abc, isStatic, pcode, classIndex, highlighting, fullyQualifiedNames);
|
||||
}
|
||||
if (highlighting) {
|
||||
int h = t;
|
||||
|
||||
@@ -39,10 +39,10 @@ public abstract class ConstVarMultinameUsage extends TraitMultinameUsage {
|
||||
return super.toString(abcTags, abc) + " "
|
||||
+ (parentTraitIndex > -1
|
||||
? (isStatic
|
||||
? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader("",abcTags, abc, isStatic, false, classIndex, false, new ArrayList<String>()))
|
||||
: (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader("",abcTags, abc, isStatic, false, classIndex, false, new ArrayList<String>())))
|
||||
? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList<String>()))
|
||||
: (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList<String>())))
|
||||
: "")
|
||||
+ ((TraitSlotConst) traits.traits[traitIndex]).convertHeader("",abcTags, abc, isStatic, false, classIndex, false, new ArrayList<String>());
|
||||
+ ((TraitSlotConst) traits.traits[traitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList<String>());
|
||||
}
|
||||
|
||||
public int getTraitIndex() {
|
||||
|
||||
@@ -48,10 +48,10 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage {
|
||||
: "instance initializer")
|
||||
: ((parentTraitIndex > -1
|
||||
? (isStatic
|
||||
? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader("",abcTags, abc, isStatic, false, classIndex, false, new ArrayList<String>()))
|
||||
: (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader("",abcTags, abc, isStatic, false, classIndex, false, new ArrayList<String>()))) + " "
|
||||
? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList<String>()))
|
||||
: (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList<String>()))) + " "
|
||||
: "")
|
||||
+ (((TraitMethodGetterSetter) traits.traits[traitIndex]).convertHeader("",abcTags, abc, isStatic, false, classIndex, false, new ArrayList<String>()))));
|
||||
+ (((TraitMethodGetterSetter) traits.traits[traitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList<String>()))));
|
||||
}
|
||||
|
||||
public int getTraitIndex() {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.jpexs.asdec.action;
|
||||
|
||||
import com.jpexs.asdec.Main;
|
||||
import com.jpexs.asdec.SWFOutputStream;
|
||||
import com.jpexs.asdec.action.parser.FlasmLexer;
|
||||
import com.jpexs.asdec.action.parser.ParseException;
|
||||
@@ -25,15 +24,11 @@ import com.jpexs.asdec.action.special.ActionNop;
|
||||
import com.jpexs.asdec.action.swf4.*;
|
||||
import com.jpexs.asdec.action.swf5.*;
|
||||
import com.jpexs.asdec.action.swf6.ActionEnumerate2;
|
||||
import com.jpexs.asdec.action.swf6.ActionStrictEquals;
|
||||
import com.jpexs.asdec.action.swf7.ActionDefineFunction2;
|
||||
import com.jpexs.asdec.action.swf7.ActionTry;
|
||||
import com.jpexs.asdec.action.treemodel.*;
|
||||
import com.jpexs.asdec.action.treemodel.clauses.*;
|
||||
import com.jpexs.asdec.action.treemodel.operations.AndTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.operations.EqTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.operations.NotTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.operations.OrTreeItem;
|
||||
import com.jpexs.asdec.helpers.Helper;
|
||||
import com.jpexs.asdec.helpers.Highlighting;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -48,7 +43,7 @@ import java.util.logging.Logger;
|
||||
public class Action {
|
||||
|
||||
public Action beforeInsert;
|
||||
public boolean ignored=false;
|
||||
public boolean ignored = false;
|
||||
/**
|
||||
* Action type identifier
|
||||
*/
|
||||
@@ -125,7 +120,7 @@ public class Action {
|
||||
List<Long> ret = new ArrayList<Long>();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets all ActionIf or ActionJump actions from subactions
|
||||
*
|
||||
@@ -369,20 +364,20 @@ public class Action {
|
||||
if (importantOffsets.contains(offset)) {
|
||||
ret += "loc" + Helper.formatAddress(offset) + ":";
|
||||
}
|
||||
|
||||
if(a.ignored){
|
||||
int len=a.getBytes(version).length;
|
||||
for(int i=0;i<len;i++){
|
||||
ret+="Nop\r\n";
|
||||
}
|
||||
}else{
|
||||
|
||||
if (a.ignored) {
|
||||
int len = a.getBytes(version).length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
ret += "Nop\r\n";
|
||||
}
|
||||
} else {
|
||||
if (a.beforeInsert != null) {
|
||||
ret += a.beforeInsert.getASMSource(importantOffsets, constantPool, version) + "\r\n";
|
||||
}
|
||||
if (!(a instanceof ActionNop)) {
|
||||
ret += Highlighting.hilighOffset("", offset) + a.getASMSource(importantOffsets, constantPool, version) + "\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
offset += a.getBytes(version).length;
|
||||
}
|
||||
if (importantOffsets.contains(offset)) {
|
||||
@@ -698,9 +693,9 @@ public class Action {
|
||||
List<TreeItem> tryCommands = ActionGraph.translateViaGraph(registerNames, atry.tryBody, version);
|
||||
TreeItem catchName;
|
||||
if (atry.catchInRegisterFlag) {
|
||||
catchName = new DirectValueTreeItem(atry,-1, new RegisterNumber(atry.catchRegister), new ArrayList<String>());
|
||||
catchName = new DirectValueTreeItem(atry, -1, new RegisterNumber(atry.catchRegister), new ArrayList<String>());
|
||||
} else {
|
||||
catchName = new DirectValueTreeItem(atry,-1, atry.catchName, new ArrayList<String>());
|
||||
catchName = new DirectValueTreeItem(atry, -1, atry.catchName, new ArrayList<String>());
|
||||
}
|
||||
List<TreeItem> catchExceptions = new ArrayList<TreeItem>();
|
||||
catchExceptions.add(catchName);
|
||||
|
||||
@@ -16,22 +16,16 @@
|
||||
*/
|
||||
package com.jpexs.asdec.action;
|
||||
|
||||
import com.jpexs.asdec.graph.Graph;
|
||||
import com.jpexs.asdec.graph.GraphPart;
|
||||
import com.jpexs.asdec.graph.Loop;
|
||||
import com.jpexs.asdec.graph.GraphPartMulti;
|
||||
import com.jpexs.asdec.action.swf4.ActionIf;
|
||||
import com.jpexs.asdec.action.swf4.ActionJump;
|
||||
import com.jpexs.asdec.action.swf4.Null;
|
||||
import com.jpexs.asdec.action.swf5.ActionReturn;
|
||||
import com.jpexs.asdec.action.swf6.ActionStrictEquals;
|
||||
import com.jpexs.asdec.action.swf7.ActionThrow;
|
||||
import com.jpexs.asdec.action.treemodel.BreakTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.ContinueTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.DirectValueTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.StoreRegisterTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.UnsupportedTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.clauses.DoWhileTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.clauses.ForTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.clauses.IfTreeItem;
|
||||
@@ -43,15 +37,16 @@ import com.jpexs.asdec.action.treemodel.operations.LogicalOp;
|
||||
import com.jpexs.asdec.action.treemodel.operations.NotTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.operations.OrTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.operations.StrictEqTreeItem;
|
||||
import com.jpexs.asdec.helpers.Highlighting;
|
||||
import com.jpexs.asdec.graph.Graph;
|
||||
import com.jpexs.asdec.graph.GraphPart;
|
||||
import com.jpexs.asdec.graph.GraphPartMulti;
|
||||
import com.jpexs.asdec.graph.Loop;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -205,7 +200,7 @@ public class ActionGraph extends Graph {
|
||||
}
|
||||
}
|
||||
if (switchedObject == null) {
|
||||
switchedObject = new DirectValueTreeItem(null,-1, new Null(), null);
|
||||
switchedObject = new DirectValueTreeItem(null, -1, new Null(), null);
|
||||
}
|
||||
HashMap<Integer, TreeItem> caseValuesMap = new HashMap<Integer, TreeItem>();
|
||||
|
||||
@@ -289,7 +284,7 @@ public class ActionGraph extends Graph {
|
||||
if ((defaultPart2 != breakPart) && (defaultCommands.isEmpty())) {
|
||||
defaultPart = defaultPart2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<TreeItem> caseValues = new ArrayList<TreeItem>();
|
||||
for (int i = 0; i < caseBodyParts.size(); i++) {
|
||||
@@ -430,7 +425,7 @@ public class ActionGraph extends Graph {
|
||||
}
|
||||
TreeItem expr = null;
|
||||
if ((code.get(part.end) instanceof ActionJump) || (!(code.get(part.end) instanceof ActionIf))) {
|
||||
expr = new DirectValueTreeItem(null,-1, (Boolean) true, new ArrayList<String>());
|
||||
expr = new DirectValueTreeItem(null, -1, (Boolean) true, new ArrayList<String>());
|
||||
} else {
|
||||
if (stack.isEmpty()) {
|
||||
}
|
||||
@@ -584,7 +579,7 @@ public class ActionGraph extends Graph {
|
||||
} else {
|
||||
ret.add(lop);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
private List<Integer> posCache;
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2013 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.asdec.action;
|
||||
|
||||
/**
|
||||
@@ -5,6 +21,7 @@ package com.jpexs.asdec.action;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class IgnoredPair {
|
||||
|
||||
public Action action;
|
||||
public int pos;
|
||||
|
||||
@@ -12,5 +29,4 @@ public class IgnoredPair {
|
||||
this.action = action;
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.flashlite;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.FSCommand2TreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.jpexs.asdec.SWFOutputStream;
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.parser.FlasmLexer;
|
||||
import com.jpexs.asdec.action.parser.ParseException;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.StrictModeTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
package com.jpexs.asdec.action.special;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.SimpleActionTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.jpexs.asdec.SWFOutputStream;
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.parser.FlasmLexer;
|
||||
import com.jpexs.asdec.action.parser.ParseException;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.GetURLTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.helpers.Helper;
|
||||
@@ -71,5 +70,5 @@ public class ActionGetURL extends Action {
|
||||
@Override
|
||||
public void translate(Stack<TreeItem> stack, List<TreeItem> output, java.util.HashMap<Integer, String> regNames) {
|
||||
output.add(new GetURLTreeItem(this, urlString, targetString));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.jpexs.asdec.SWFOutputStream;
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.parser.FlasmLexer;
|
||||
import com.jpexs.asdec.action.parser.ParseException;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.GotoLabelTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.helpers.Helper;
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.jpexs.asdec.SWFOutputStream;
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.parser.FlasmLexer;
|
||||
import com.jpexs.asdec.action.parser.ParseException;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.GotoFrameTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf3;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.SimpleActionTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf3;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.SimpleActionTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf3;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.SimpleActionTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.jpexs.asdec.SWFOutputStream;
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.parser.FlasmLexer;
|
||||
import com.jpexs.asdec.action.parser.ParseException;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.SetTargetTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.helpers.Helper;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf3;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.SimpleActionTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf3;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.SimpleActionTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf3;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.SimpleActionTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.jpexs.asdec.SWFOutputStream;
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.parser.FlasmLexer;
|
||||
import com.jpexs.asdec.action.parser.ParseException;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.WaitForFrameTreeItem;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf4;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.operations.AddTreeItem;
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf4;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.operations.AndTreeItem;
|
||||
import java.util.List;
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.jpexs.asdec.action.swf4;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.AsciiToCharTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.jpexs.asdec.action.swf4;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.CallTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.jpexs.asdec.action.swf4;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.CharToAsciiTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.jpexs.asdec.action.swf4;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.CloneSpriteTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf4;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.operations.DivideTreeItem;
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf4;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.SimpleActionTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf4;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.operations.EqTreeItem;
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf4;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.DirectValueTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.GetPropertyTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf4;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.SimpleActionTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.jpexs.asdec.SWFOutputStream;
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.parser.FlasmLexer;
|
||||
import com.jpexs.asdec.action.parser.ParseException;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.GetURL2TreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf4;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.GetVariableTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.jpexs.asdec.SWFOutputStream;
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.parser.FlasmLexer;
|
||||
import com.jpexs.asdec.action.parser.ParseException;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.GotoFrame2TreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
@@ -32,12 +32,11 @@ public class ActionJump extends Action {
|
||||
public int offset;
|
||||
public String identifier;
|
||||
|
||||
public ActionJump(int offset){
|
||||
super(0x99,2);
|
||||
this.offset=offset;
|
||||
public ActionJump(int offset) {
|
||||
super(0x99, 2);
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ActionJump(SWFInputStream sis) throws IOException {
|
||||
super(0x99, 2);
|
||||
offset = sis.readSI16();
|
||||
@@ -87,6 +86,4 @@ public class ActionJump extends Action {
|
||||
public String toString() {
|
||||
return "Jump";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf4;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.operations.LtTreeItem;
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf4;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.MBAsciiToCharTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf4;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.MBCharToAsciiTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.List;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.asdec.action.swf4;
|
||||
|
||||
import com.jpexs.asdec.action.Action;
|
||||
import com.jpexs.asdec.action.treemodel.ConstantPool;
|
||||
import com.jpexs.asdec.action.treemodel.MBStringExtractTreeItem;
|
||||
import com.jpexs.asdec.action.treemodel.TreeItem;
|
||||
import java.util.List;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user