Merge origin/master

This commit is contained in:
Jindra Petřík
2015-12-03 17:08:03 +01:00
35 changed files with 321 additions and 184 deletions

View File

@@ -312,7 +312,7 @@ public class AVM2Code implements Cloneable {
public static int toSourceLimit = -1;
public List<AVM2Instruction> code = new ArrayList<>();
public List<AVM2Instruction> code;
public static boolean DEBUG_REWRITE = false;
@@ -635,13 +635,20 @@ public class AVM2Code implements Cloneable {
}
}
public boolean hideTemporaryRegisters = true;
public static final String IDENTOPEN = "/*IDENTOPEN*/";
public static final String IDENTCLOSE = "/*IDENTCLOSE*/";
public AVM2Code() {
code = new ArrayList<>();
}
public AVM2Code(int capacity) {
code = new ArrayList<>(capacity);
}
public AVM2Code(ArrayList<AVM2Instruction> instructions) {
code = instructions;
}
public Object execute(HashMap<Integer, Object> arguments, AVM2ConstantPool constants) throws AVM2ExecutionException {
@@ -726,14 +733,14 @@ public class AVM2Code implements Cloneable {
}
if (ins.definition instanceof JumpIns) {
try {
pos = adr2pos(pos2adr(pos) + ins.getBytesLength() + ins.operands[0]);
pos = adr2pos(ins.getTargetAddress());
continue;
} catch (ConvertException ex) {
return false;
}
} else if (ins.definition instanceof IfTypeIns) {
try {
int newpos = adr2pos(pos2adr(pos) + ins.getBytesLength() + ins.operands[0]);
int newpos = adr2pos(ins.getTargetAddress());
calculateDebugFileLine(debugFile, debugLine, newpos, abc, seen);
} catch (ConvertException ex) {
return false;
@@ -995,6 +1002,7 @@ public class AVM2Code implements Cloneable {
diParent.sortChildren();
}
code = new ArrayList<>(codeMap.size());
AVM2Instruction prev = null;
for (int i = 0; i < availableBytes; i++) {
AVM2Instruction ins = codeMap.get((long) i);
@@ -1037,7 +1045,7 @@ public class AVM2Code implements Cloneable {
public void markOffsets() {
long offset = 0;
for (int i = 0; i < code.size(); i++) {
code.get(i).offset = offset;
code.get(i).setOffset(offset);
offset += code.get(i).getBytesLength();
}
}
@@ -1232,7 +1240,7 @@ public class AVM2Code implements Cloneable {
Helper.byteArrayToHexWithHeader(writer, getBytes());
} else if (exportMode == ScriptExportMode.PCODE || exportMode == ScriptExportMode.PCODE_HEX) {
for (AVM2Instruction ins : code) {
long ofs = ins.offset;
long ofs = ins.getOffset();
if (exportMode == ScriptExportMode.PCODE_HEX) {
writer.appendNoHilight("; ");
writer.appendNoHilight(Helper.bytesToHexString(ins.getBytes()));
@@ -1277,7 +1285,7 @@ public class AVM2Code implements Cloneable {
if (body != null) {
for (ABCException exception : body.exceptions) {
ret.add((long) exception.start);
ret.add((long) exception.end);
// ret.add((long) exception.end); // end is not important
ret.add((long) exception.target);
}
}
@@ -1289,6 +1297,16 @@ public class AVM2Code implements Cloneable {
return ret;
}
public AVM2Instruction adr2ins(long address) throws ConvertException {
int pos = adr2pos(address, false);
if (pos == code.size()) {
// end
return null;
}
return code.get(pos);
}
public int adr2pos(long address) throws ConvertException {
return adr2pos(address, false);
}
@@ -1310,7 +1328,7 @@ public class AVM2Code implements Cloneable {
while (max >= min) {
int mid = (min + max) / 2;
long midValue = code.get(mid).offset;
long midValue = code.get(mid).getOffset();
if (midValue == address) {
return mid;
} else if (midValue < address) {
@@ -1331,7 +1349,7 @@ public class AVM2Code implements Cloneable {
if (pos == code.size()) {
return getEndOffset();
}
return (int) code.get(pos).offset;
return (int) code.get(pos).getOffset();
}
public long getEndOffset() {
@@ -1340,7 +1358,7 @@ public class AVM2Code implements Cloneable {
}
AVM2Instruction ins = code.get(code.size() - 1);
return (int) (ins.offset + ins.getBytesLength());
return (int) (ins.getOffset() + ins.getBytesLength());
}
/**
@@ -1956,11 +1974,11 @@ public class AVM2Code implements Cloneable {
for (int i = 0; i < code.size(); i++) {
AVM2Instruction ins = code.get(i);
if (ins.definition instanceof LookupSwitchIns) {
long target = ins.offset + ins.operands[0];
ins.operands[0] = updater.updateOperandOffset(ins.offset, target, ins.operands[0]);
long target = ins.getOffset() + ins.operands[0];
ins.operands[0] = updater.updateOperandOffset(ins.getOffset(), target, ins.operands[0]);
for (int k = 2; k < ins.operands.length; k++) {
target = ins.offset + ins.operands[k];
ins.operands[k] = updater.updateOperandOffset(ins.offset, target, ins.operands[k]);
target = ins.getOffset() + ins.operands[k];
ins.operands[k] = updater.updateOperandOffset(ins.getOffset(), target, ins.operands[k]);
}
} else {
/*for (int j = 0; j < ins.definition.operands.length; j++) {
@@ -1970,16 +1988,16 @@ public class AVM2Code implements Cloneable {
}
}*/
//Faster, but not so universal
if ((ins.definition instanceof JumpIns) || (ins.definition instanceof IfTypeIns)) {
long target = ins.offset + ins.getBytesLength() + ins.operands[0];
if (ins.definition instanceof IfTypeIns) {
long target = ins.getTargetAddress();
try {
ins.operands[0] = updater.updateOperandOffset(ins.offset, target, ins.operands[0]);
ins.operands[0] = updater.updateOperandOffset(ins.getOffset(), target, ins.operands[0]);
} catch (ConvertException cex) {
throw new ConvertException("Invalid offset (" + ins + ")", i);
}
}
}
ins.offset = updater.updateInstructionOffset(ins.offset);
ins.setOffset(updater.updateInstructionOffset(ins.getOffset()));
}
for (ABCException ex : body.exceptions) {
@@ -2053,7 +2071,7 @@ public class AVM2Code implements Cloneable {
}
AVM2Instruction ins = code.get(pos);
final long remOffset = ins.offset;
final long remOffset = ins.getOffset();
int bc = ins.getBytesLength();
final int byteCount = bc;
@@ -2118,7 +2136,7 @@ public class AVM2Code implements Cloneable {
*/
public void replaceInstruction(int pos, AVM2Instruction instruction, MethodBody body) {
AVM2Instruction oldInstruction = code.get(pos);
instruction.offset = oldInstruction.offset;
instruction.setOffset(oldInstruction.getOffset());
int oldByteCount = oldInstruction.getBytesLength();
int newByteCount = instruction.getBytesLength();
int byteDelta = newByteCount - oldByteCount;
@@ -2128,7 +2146,7 @@ public class AVM2Code implements Cloneable {
@Override
public long updateInstructionOffset(long address) {
if (address > instruction.offset) {
if (address > instruction.getOffset()) {
return address + byteDelta;
}
return address;
@@ -2136,10 +2154,10 @@ public class AVM2Code implements Cloneable {
@Override
public int updateOperandOffset(long insAddr, long targetAddress, int offset) {
if (targetAddress > instruction.offset && insAddr <= instruction.offset) {
if (targetAddress > instruction.getOffset() && insAddr <= instruction.getOffset()) {
return offset + byteDelta;
}
if (targetAddress <= instruction.offset && insAddr > instruction.offset) {
if (targetAddress <= instruction.getOffset() && insAddr > instruction.getOffset()) {
return offset - byteDelta;
}
return offset;
@@ -2170,11 +2188,11 @@ public class AVM2Code implements Cloneable {
}
final int byteCount = instruction.getBytesLength();
if (pos == code.size()) {
instruction.offset = code.get(pos - 1).offset + code.get(pos - 1).getBytesLength();
instruction.setOffset(code.get(pos - 1).getOffset() + code.get(pos - 1).getBytesLength());
} else {
instruction.offset = code.get(pos).offset;
instruction.setOffset(code.get(pos).getOffset());
}
final long x = instruction.offset;
final long x = instruction.getOffset();
updateOffsets(new OffsetUpdater() {
@Override
@@ -2222,7 +2240,7 @@ public class AVM2Code implements Cloneable {
return offset_jt;
}
}, body);
instruction.offset = x;
instruction.setOffset(x);
code.add(pos, instruction);
//checkValidOffsets(body);
}
@@ -2314,14 +2332,14 @@ public class AVM2Code implements Cloneable {
}
if (ins.definition instanceof JumpIns) {
try {
pos = adr2pos(pos2adr(pos) + ins.getBytesLength() + ins.operands[0]);
pos = adr2pos(ins.getTargetAddress());
continue;
} catch (ConvertException ex) {
return false;
}
} else if (ins.definition instanceof IfTypeIns) {
try {
int newpos = adr2pos(pos2adr(pos) + ins.getBytesLength() + ins.operands[0]);
int newpos = adr2pos(ins.getTargetAddress());
walkCode(stats, newpos, stack, scope, abc);
} catch (ConvertException ex) {
return false;
@@ -2451,14 +2469,14 @@ public class AVM2Code implements Cloneable {
}
if (ins.definition instanceof JumpIns) {
try {
ip = adr2pos(pos2adr(ip) + ins.getBytesLength() + ins.operands[0]);
ip = adr2pos(ins.getTargetAddress());
continue;
} catch (ConvertException ex) {
logger.log(Level.FINE, null, ex);
}
} else if (ins.definition instanceof IfTypeIns) {
try {
toVisit.add(adr2pos(pos2adr(ip) + ins.getBytesLength() + ins.operands[0]));
toVisit.add(adr2pos(ins.getTargetAddress()));
toVisitLast.add(ip);
} catch (ConvertException ex) {
logger.log(Level.FINE, null, ex);

View File

@@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
import com.jpexs.decompiler.flash.ecma.Null;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.flash.types.annotations.Internal;
import com.jpexs.decompiler.flash.types.annotations.SWFField;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.helpers.HashArrayList;
import com.jpexs.helpers.utf8.Utf8PrintWriter;
@@ -39,21 +40,29 @@ public class AVM2ConstantPool implements Cloneable {
private static final Logger logger = Logger.getLogger(AVM2ConstantPool.class.getName());
@SWFField
private HashArrayList<Long> constant_int = new HashArrayList<>();
@SWFField
private HashArrayList<Long> constant_uint = new HashArrayList<>();
@SWFField
private HashArrayList<Double> constant_double = new HashArrayList<>();
/* Only for some minor versions */
@SWFField
private HashArrayList<Decimal> constant_decimal = new HashArrayList<>();
@SWFField
private HashArrayList<String> constant_string = new HashArrayList<>();
@SWFField
private HashArrayList<Namespace> constant_namespace = new HashArrayList<>();
@SWFField
private HashArrayList<NamespaceSet> constant_namespace_set = new HashArrayList<>();
@SWFField
private HashArrayList<Multiname> constant_multiname = new HashArrayList<>();
public AVM2ConstantPool() {

View File

@@ -149,7 +149,7 @@ public class AVM2DeobfuscatorGetSet extends SWFDecompilerAdapter {
int regId = ((SetLocalTypeIns) def).getRegisterId(ins);
if (!stack.isEmpty() && (stack.peek() instanceof LocalRegAVM2Item) && (((LocalRegAVM2Item) stack.peek()).regIndex == regId)) {
stack.pop();
code.replaceInstruction(idx, new AVM2Instruction(ins.offset, DeobfuscatePopIns.getInstance(), null), body);
code.replaceInstruction(idx, new AVM2Instruction(ins.getOffset(), DeobfuscatePopIns.getInstance(), null), body);
idx++;
continue;
}
@@ -185,7 +185,7 @@ public class AVM2DeobfuscatorGetSet extends SWFDecompilerAdapter {
boolean ifed = false;
if (def instanceof JumpIns) {
long address = ins.offset + ins.getBytesLength() + ins.operands[0];
long address = ins.getTargetAddress();
idx = code.adr2pos(address);
if (idx == -1) {

View File

@@ -50,7 +50,7 @@ public class AVM2DeobfuscatorJumps extends SWFDecompilerAdapter {
for (int i = 0; i < code.code.size(); i++) {
AVM2Instruction ins = code.code.get(i);
if (ins.definition instanceof JumpIns) {
long targetAddr = ins.offset + ins.operands[0] + ins.getBytesLength();
long targetAddr = ins.getTargetAddress();
{
for (int r : refs.get(i)) {
if (r >= 0) { //Not Exception start/end
@@ -58,7 +58,7 @@ public class AVM2DeobfuscatorJumps extends SWFDecompilerAdapter {
if ((srcIns.definition instanceof JumpIns) || ((srcIns.definition instanceof IfTypeIns) && (r != i - 1))) {
int oldop = srcIns.operands[0];
srcIns.operands[0] = (int) (targetAddr - (srcIns.offset + srcIns.getBytesLength()));
srcIns.operands[0] = (int) (targetAddr - (srcIns.getOffset() + srcIns.getBytesLength()));
if (srcIns.operands[0] != oldop) {
found = true;
}

View File

@@ -167,7 +167,7 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
SetLocalTypeIns slt = (SetLocalTypeIns) ins.definition;
int regId = slt.getRegisterId(ins);
if (singleRegisters.containsKey(regId)) {
code.replaceInstruction(i, new AVM2Instruction(ins.offset, DeobfuscatePopIns.getInstance(), null), body);
code.replaceInstruction(i, new AVM2Instruction(ins.getOffset(), DeobfuscatePopIns.getInstance(), null), body);
}
}
@@ -264,7 +264,7 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
if (ins.definition instanceof JumpIns) {
long address = ins.offset + ins.getBytesLength() + ins.operands[0];
long address = ins.getTargetAddress();
idx = code.adr2pos(address);//code.indexOf(code.getByAddress(address));
if (idx == -1) {
throw new TranslateException("Jump target not found: " + address);

View File

@@ -20,9 +20,7 @@ import com.jpexs.decompiler.flash.BaseLocalData;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.AVM2LocalData;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.DeobfuscatePopIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.instructions.debug.DebugIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.jumps.JumpIns;
@@ -35,7 +33,6 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ThrowIns;
import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.parser.script.Reference;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphPart;
@@ -48,7 +45,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
@@ -150,7 +146,6 @@ public class AVM2DeobfuscatorRegistersOld extends AVM2DeobfuscatorSimpleOld {
originalBody.exceptions = body.exceptions;
originalBody.setCode(body.getCode());
}
private int getFirstRegisterSetter(Reference<AVM2Instruction> assignment, int classIndex, boolean isStatic, int scriptIndex, ABC abc, MethodBody body, Set<Integer> ignoredRegisters, Set<Integer> ignoredGets) throws InterruptedException {
@@ -232,7 +227,7 @@ public class AVM2DeobfuscatorRegistersOld extends AVM2DeobfuscatorSimpleOld {
if (ins.definition instanceof JumpIns) {
long address = ins.offset + ins.getBytesLength() + ins.operands[0];
long address = ins.getTargetAddress();
idx = code.adr2pos(address);//code.indexOf(code.getByAddress(address));
if (idx == -1) {
throw new TranslateException("Jump target not found: " + address);

View File

@@ -170,7 +170,7 @@ public class AVM2DeobfuscatorSimple extends SWFDecompilerAdapter {
}
AVM2Instruction ins = code.code.get(idx);
if (instructionsProcessed > 0 && refs.contains(ins.offset)) {
if (instructionsProcessed > 0 && refs.contains(ins.getOffset())) {
break;
}
@@ -199,51 +199,13 @@ public class AVM2DeobfuscatorSimple extends SWFDecompilerAdapter {
}
}
if (def instanceof NewFunctionIns) {
if (idx + 1 < code.code.size()) {
if (code.code.get(idx + 1).definition instanceof PopIns) {
code.removeInstruction(idx + 1, body);
code.removeInstruction(idx, body);
modified = true;
continue;
}
}
} else {
// do not throw EmptyStackException, much faster
int requiredStackSize = def.getStackPopCount(ins, abc);
if (stack.size() < requiredStackSize) {
break;
}
if (requiredStackSize > 0 && !def.isNotCompileTimeSupported()) {
boolean notCompileTime = false;
for (int i = 0; i < requiredStackSize; i++) {
if (stack.peek(i + 1) == NotCompileTime.INSTANCE) {
notCompileTime = true;
break;
}
}
if (notCompileTime) {
break;
}
}
if (localData.scopeStack.size() < -def.getScopeStackDelta(ins, abc)) {
break;
}
boolean supported;
try {
localData.jump = null;
supported = def.execute(localData, abc.constants, ins);
} catch (AVM2ExecutionException ex) {
supported = false;
}
if (!supported) {
break;
}
if (def instanceof NewFunctionIns
&& idx + 1 < code.code.size()
&& code.code.get(idx + 1).definition instanceof PopIns) {
code.removeInstruction(idx + 1, body);
code.removeInstruction(idx, body);
modified = true;
continue;
}
boolean ok = false;
@@ -301,9 +263,47 @@ public class AVM2DeobfuscatorSimple extends SWFDecompilerAdapter {
break;
}
if (!(def instanceof NewFunctionIns)) {
// do not throw EmptyStackException, much faster
int requiredStackSize = def.getStackPopCount(ins, abc);
if (stack.size() < requiredStackSize) {
break;
}
if (requiredStackSize > 0 && !def.isNotCompileTimeSupported()) {
boolean notCompileTime = false;
for (int i = 0; i < requiredStackSize; i++) {
if (stack.peek(i + 1) == NotCompileTime.INSTANCE) {
notCompileTime = true;
break;
}
}
if (notCompileTime) {
break;
}
}
if (localData.scopeStack.size() < -def.getScopeStackDelta(ins, abc)) {
break;
}
boolean supported;
try {
localData.jump = null;
supported = def.execute(localData, abc.constants, ins);
} catch (AVM2ExecutionException ex) {
supported = false;
}
if (!supported) {
break;
}
}
boolean ifed = false;
if (def instanceof IfTypeIns && !(def instanceof JumpIns)) {
long address = ins.offset + ins.getBytesLength() + ins.operands[0];
long address = ins.getTargetAddress();
int nidx = code.adr2pos(address);
AVM2Instruction tarIns = code.code.get(nidx);
@@ -315,17 +315,17 @@ public class AVM2DeobfuscatorSimple extends SWFDecompilerAdapter {
AVM2Instruction jumpIns = new AVM2Instruction(0, AVM2Instructions.Jump, new int[]{0});
//jumpIns.operands[0] = ins.operands[0] /*- ins.getBytes().length*/ + jumpIns.getBytes().length;
code.replaceInstruction(idx, jumpIns, body);
jumpIns.operands[0] = (int) (tarIns.offset - jumpIns.offset - jumpIns.getBytesLength());
jumpIns.operands[0] = (int) (tarIns.getOffset() - jumpIns.getOffset() - jumpIns.getBytesLength());
for (int s = 0; s < stackCount; s++) {
code.insertInstruction(idx, new AVM2Instruction(ins.offset, DeobfuscatePopIns.getInstance(), null), true, body);
code.insertInstruction(idx, new AVM2Instruction(ins.getOffset(), DeobfuscatePopIns.getInstance(), null), true, body);
}
idx = code.adr2pos(jumpIns.offset + jumpIns.getBytesLength() + jumpIns.operands[0]);
idx = code.adr2pos(jumpIns.getTargetAddress());
} else {
//System.err.println("replacing " + ins + " on " + idx + " with pop");
code.replaceInstruction(idx, new AVM2Instruction(ins.offset, DeobfuscatePopIns.getInstance(), null), body);
code.replaceInstruction(idx, new AVM2Instruction(ins.getOffset(), DeobfuscatePopIns.getInstance(), null), body);
for (int s = 1 /*first is replaced*/; s < stackCount; s++) {
code.insertInstruction(idx, new AVM2Instruction(ins.offset, DeobfuscatePopIns.getInstance(), null), true, body);
code.insertInstruction(idx, new AVM2Instruction(ins.getOffset(), DeobfuscatePopIns.getInstance(), null), true, body);
}
//ins.definition = DeobfuscatePopIns.getInstance();
idx++;

View File

@@ -342,7 +342,7 @@ public class AVM2DeobfuscatorSimpleOld extends SWFDecompilerAdapter {
boolean ifed = false;
if (def instanceof JumpIns) {
long address = ins.offset + ins.getBytesLength() + ins.operands[0];
long address = ins.getTargetAddress();
idx = code.adr2pos(address);
if (idx == -1) {
@@ -355,7 +355,7 @@ public class AVM2DeobfuscatorSimpleOld extends SWFDecompilerAdapter {
GraphTargetItem top = stack.pop();
Object res = top.getResult();
long address = ins.offset + ins.getBytesLength() + ins.operands[0];
long address = ins.getTargetAddress();
int nidx = code.adr2pos(address);//code.indexOf(code.getByAddress(address));
AVM2Instruction tarIns = code.code.get(nidx);
@@ -367,17 +367,17 @@ public class AVM2DeobfuscatorSimpleOld extends SWFDecompilerAdapter {
AVM2Instruction jumpIns = new AVM2Instruction(0, AVM2Instructions.Jump, new int[]{0});
//jumpIns.operands[0] = ins.operands[0] /*- ins.getBytes().length*/ + jumpIns.getBytes().length;
code.replaceInstruction(idx, jumpIns, body);
jumpIns.operands[0] = (int) (tarIns.offset - jumpIns.offset - jumpIns.getBytesLength());
jumpIns.operands[0] = (int) (tarIns.getOffset() - jumpIns.getOffset() - jumpIns.getBytesLength());
for (int s = 0; s < stackCount; s++) {
code.insertInstruction(idx, new AVM2Instruction(ins.offset, DeobfuscatePopIns.getInstance(), null), true, body);
code.insertInstruction(idx, new AVM2Instruction(ins.getOffset(), DeobfuscatePopIns.getInstance(), null), true, body);
}
idx = code.adr2pos(jumpIns.offset + jumpIns.getBytesLength() + jumpIns.operands[0]);
idx = code.adr2pos(jumpIns.getTargetAddress());
} else {
//System.err.println("replacing " + ins + " on " + idx + " with pop");
code.replaceInstruction(idx, new AVM2Instruction(ins.offset, DeobfuscatePopIns.getInstance(), null), body);
code.replaceInstruction(idx, new AVM2Instruction(ins.getOffset(), DeobfuscatePopIns.getInstance(), null), body);
for (int s = 1 /*first is replaced*/; s < stackCount; s++) {
code.insertInstruction(idx, new AVM2Instruction(ins.offset, DeobfuscatePopIns.getInstance(), null), true, body);
code.insertInstruction(idx, new AVM2Instruction(ins.getOffset(), DeobfuscatePopIns.getInstance(), null), true, body);
}
//ins.definition = DeobfuscatePopIns.getInstance();
idx++;

View File

@@ -47,7 +47,7 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
public int[] operands;
public long offset;
private long offset;
public String comment;
@@ -375,12 +375,24 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
return offset;
}
public void setOffset(long offset) {
this.offset = offset;
}
public long getTargetAddress() {
return offset + 4 /*getBytesLength()*/ + operands[0];
}
public void setTargetOffset(int offset) {
operands[0] = offset;
}
@Override
public List<Integer> getBranches(GraphSource code) {
List<Integer> ret = new ArrayList<>();
if (definition instanceof IfTypeIns) {
ret.add(code.adr2pos(offset + getBytesLength() + operands[0]));
ret.add(code.adr2pos(getTargetAddress()));
if (!(definition instanceof JumpIns)) {
ret.add(code.adr2pos(offset + getBytesLength()));
}

View File

@@ -238,7 +238,7 @@ public abstract class InstructionDefinition implements Serializable {
if (constants.getMultiname(multinameIndex).needsName()) {
name = stack.get(pos).toString();
} else {
name = GraphTextWriter.hilighOffset(constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames, false), ins.offset);
name = GraphTextWriter.hilighOffset(constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames, false), ins.getOffset());
}
return name + ns;
}

View File

@@ -969,9 +969,9 @@ public class ASM3Parser {
AVM2Instruction ins = code.code.get((int) oi.insPosition);
int relOffset;
if (oi instanceof CaseOffsetItem) {
relOffset = li.offset - (int) ins.offset;
relOffset = li.offset - (int) ins.getOffset();
} else {
relOffset = li.offset - ((int) ins.offset + ins.getBytesLength());
relOffset = li.offset - ((int) ins.getOffset() + ins.getBytesLength());
}
ins.operands[oi.insOperandIndex] = relOffset;
}

View File

@@ -201,8 +201,8 @@ public class AVM2SourceGenerator implements SourceGenerator {
return ret;
}
public List<AVM2Instruction> toInsList(List<GraphSourceItem> items) {
List<AVM2Instruction> ret = new ArrayList<>();
public ArrayList<AVM2Instruction> toInsList(List<GraphSourceItem> items) {
ArrayList<AVM2Instruction> ret = new ArrayList<>();
for (GraphSourceItem s : items) {
if (s instanceof AVM2Instruction) {
ret.add((AVM2Instruction) s);
@@ -1675,9 +1675,8 @@ public class AVM2SourceGenerator implements SourceGenerator {
mbody.method_info = abcIndex.getSelectedAbc().addMethodInfo(mi);
mi.setBody(mbody);
List<AVM2Instruction> mbodyCode = toInsList(src);
mbody.setCode(new AVM2Code());
mbody.getCode().code = mbodyCode;
ArrayList<AVM2Instruction> mbodyCode = toInsList(src);
mbody.setCode(new AVM2Code(mbodyCode));
if (needsActivation) {
if (localData.traitUsages.containsKey(mbody)) {

View File

@@ -122,6 +122,7 @@ public abstract class Action implements GraphSourceItem {
*/
public int actionLength;
// todo: honfika: rename to offset to be similar with AS3
private long address;
@Override
@@ -208,6 +209,7 @@ public abstract class Action implements GraphSourceItem {
}
public int getTotalActionLength() {
// honfika: todo rename to getBytesLength to match the name with the similar method in AS3
return actionLength + 1 + (actionCode >= 0x80 ? 2 : 0);
}

View File

@@ -57,6 +57,11 @@ public class FastActionList implements Collection<ActionItem> {
getJumps(actions, actionItemMap);
}
public final ActionItem insertItemBefore(ActionItem item, Action action) {
ActionItem newItem = new ActionItem(action);
return insertItemBefore(item, newItem);
}
public final ActionItem insertItemAfter(ActionItem item, Action action) {
ActionItem newItem = new ActionItem(action);
return insertItemAfter(item, newItem);
@@ -667,7 +672,7 @@ public class FastActionList implements Collection<ActionItem> {
if (o instanceof ActionItem) {
item = (ActionItem) o;
} else if (o instanceof Action) {
item = actionItemMap.get(o);
item = actionItemMap.get((Action) o);
}
if (item == null) {

View File

@@ -550,6 +550,10 @@ public class ASMParser {
}
}
if (ret.size() == 0 || !(ret.get(ret.size() - 1) instanceof ActionEnd)) {
ret.add(new ActionEnd());
}
return ret;
}
}

View File

@@ -126,10 +126,11 @@ public class ActionIf extends Action {
public List<Integer> getBranches(GraphSource code) {
List<Integer> ret = super.getBranches(code);
int length = getTotalActionLength();
int jmp = code.adr2pos(getAddress() + length + offset);
long targetAddress = getTargetAddress();
int jmp = code.adr2pos(targetAddress);
int after = code.adr2pos(getAddress() + length);
if (jmp == -1) {
Logger.getLogger(ActionIf.class.getName()).log(Level.SEVERE, "Invalid IF jump to ofs" + Helper.formatAddress(getAddress() + length + offset));
Logger.getLogger(ActionIf.class.getName()).log(Level.SEVERE, "Invalid IF jump to ofs" + Helper.formatAddress(targetAddress));
ret.add(after);
} else {
ret.add(jmp);

View File

@@ -117,11 +117,12 @@ public class ActionJump extends Action {
@Override
public List<Integer> getBranches(GraphSource code) {
List<Integer> ret = super.getBranches(code);
int length = getBytesLength();
int ofs = code.adr2pos(getAddress() + length + offset);
long targetAddress = getTargetAddress();
int ofs = code.adr2pos(targetAddress);
if (ofs == -1) {
int length = getBytesLength();
ofs = code.adr2pos(getAddress() + length);
Logger.getLogger(ActionJump.class.getName()).log(Level.SEVERE, "Invalid jump to ofs" + Helper.formatAddress(getAddress() + length + offset) + " from ofs" + Helper.formatAddress(getAddress()));
Logger.getLogger(ActionJump.class.getName()).log(Level.SEVERE, "Invalid jump to ofs" + Helper.formatAddress(targetAddress) + " from ofs" + Helper.formatAddress(getAddress()));
}
ret.add(ofs);
return ret;

View File

@@ -96,6 +96,7 @@ import com.jpexs.decompiler.flash.types.shaperecords.EndShapeRecord;
import com.jpexs.decompiler.flash.types.shaperecords.StraightEdgeRecord;
import com.jpexs.decompiler.flash.types.shaperecords.StyleChangeRecord;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.HashArrayList;
import com.jpexs.helpers.ReflectionTools;
import java.io.IOException;
import java.io.StringReader;
@@ -205,7 +206,7 @@ public class SwfXmlImporter {
Field field = getField(cls, name);
Class childCls = field.getType();
if (List.class.isAssignableFrom(childCls)) {
List list = new ArrayList();
List list = HashArrayList.class.isAssignableFrom(childCls) ? new HashArrayList() : new ArrayList();
for (int j = 0; j < child.getChildNodes().getLength(); j++) {
Node childChildNode = child.getChildNodes().item(j);
if (childChildNode instanceof Element) {

View File

@@ -1793,22 +1793,27 @@ public class Graph {
hasExpr = true;
}
}
}
first = true;
pos = 0;
//This is tied to AS3 switch implementation which has nextparts switched from index 1. TODO: Make more universal
GraphPart defaultPart = hasExpr ? part.nextParts.get(1 + defaultBranch) : part.nextParts.get(0);
for (GraphPart p : part.nextParts) {
if (p != defaultPart) {
for (int i = 1; i < part.nextParts.size(); i++) {
if (hasExpr && i == 1 + defaultBranch) {
continue;
}
if (part.nextParts.get(i) != defaultPart) {
if (caseExpressions.containsKey(pos)) {
caseValues.add(caseExpressions.get(pos));
} else {
caseValues.add(new IntegerValueItem(null, localData.lineStartInstruction, pos));
}
pos++;
}
pos++;
}
first = true;

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.action.ActionList;
import com.jpexs.decompiler.flash.action.fastactionlist.FastActionList;
import com.jpexs.decompiler.flash.action.parser.ActionParseException;
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser;
import com.jpexs.decompiler.flash.action.swf4.ActionJump;
@@ -67,7 +68,7 @@ public class ActionScript2ModificationTest extends ActionScript2TestBase {
return actions;
}
public void testRemoveAction(String actionsString, String expectedResult, int[] actionsToRemove) {
public void testRemoveActionNormal(String actionsString, String expectedResult, int[] actionsToRemove) {
try {
ActionList actions = ASMParser.parse(0, true, actionsString, swf.version, false);
@@ -90,7 +91,38 @@ public class ActionScript2ModificationTest extends ActionScript2TestBase {
}
}
public void testAddAction(String actionsString, String expectedResult, Action action, int index) {
public void testRemoveActionFast(String actionsString, String expectedResult, int[] actionsToRemove) {
try {
ActionList actions = ASMParser.parse(0, true, actionsString, swf.version, false);
FastActionList fastActions = new FastActionList(actions);
for (int i : actionsToRemove) {
fastActions.removeItem(i, 1);
}
actions = fastActions.toActionList();
DoActionTag doa = getFirstActionTag();
doa.setActionBytes(Action.actionsToBytes(actions, true, swf.version));
HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false);
doa.getASMSource(ScriptExportMode.PCODE, writer, doa.getActions());
String actualResult = normalizeLabels(writer.toString());
actualResult = cleanPCode(actualResult);
expectedResult = cleanPCode(expectedResult);
Assert.assertEquals(actualResult, expectedResult);
} catch (IOException | ActionParseException | InterruptedException ex) {
fail();
}
}
public void testRemoveAction(String actionsString, String expectedResult, int[] actionsToRemove) {
testRemoveActionNormal(actionsString, expectedResult, actionsToRemove);
testRemoveActionFast(actionsString, expectedResult, actionsToRemove);
}
public void testAddActionNormal(String actionsString, String expectedResult, Action action, int index) {
try {
ActionList actions = ASMParser.parse(0, true, actionsString, swf.version, false);
@@ -111,6 +143,29 @@ public class ActionScript2ModificationTest extends ActionScript2TestBase {
}
}
public void testAddActionFast(String actionsString, String expectedResult, Action action, int index) {
try {
ActionList actions = ASMParser.parse(0, true, actionsString, swf.version, false);
FastActionList fastActions = new FastActionList(actions);
fastActions.insertItemBefore(fastActions.get(index), action);
actions = fastActions.toActionList();
DoActionTag doa = getFirstActionTag();
doa.setActionBytes(Action.actionsToBytes(actions, true, swf.version));
HighlightedTextWriter writer = new HighlightedTextWriter(new CodeFormatting(), false);
doa.getASMSource(ScriptExportMode.PCODE, writer, doa.getActions());
String actualResult = normalizeLabels(writer.toString());
actualResult = cleanPCode(actualResult);
expectedResult = cleanPCode(expectedResult);
Assert.assertEquals(actualResult, expectedResult);
} catch (IOException | ActionParseException | InterruptedException ex) {
fail();
}
}
@Test
public void testRemoveJumpAction() {
String actionsString
@@ -227,6 +282,33 @@ public class ActionScript2ModificationTest extends ActionScript2TestBase {
testRemoveAction(actionsString, expectedResult, new int[]{7});
}
@Test
public void testAddAtionFirst() {
String actionsString
= "ConstantPool\n"
+ "DefineFunction \"test\" 1 \"p1\" {\n"
+ "Push 1\n"
+ "GetVariable\n"
+ "}\n"
+ "Push 2\n"
+ "If label_1\n"
+ "Push 3\n"
+ "label_1:Push 4";
String expectedResult
= "GetMember\n"
+ "ConstantPool\n"
+ "DefineFunction \"test\" 1 \"p1\" {\n"
+ "Push 1\n"
+ "GetVariable\n"
+ "}\n"
+ "Push 2\n"
+ "If label_1\n"
+ "Push 3\n"
+ "label_1:Push 4";
testAddActionNormal(actionsString, expectedResult, new ActionGetMember(), 0);
testAddActionFast(actionsString, expectedResult, new ActionGetMember(), 0);
}
@Test
public void testAddAtion1() {
String actionsString
@@ -250,7 +332,8 @@ public class ActionScript2ModificationTest extends ActionScript2TestBase {
+ "If label_1\n"
+ "Push 3\n"
+ "label_1:Push 4";
testAddAction(actionsString, expectedResult, new ActionGetMember(), 1);
testAddActionNormal(actionsString, expectedResult, new ActionGetMember(), 1);
testAddActionFast(actionsString, expectedResult, new ActionGetMember(), 1);
}
@Test
@@ -276,7 +359,8 @@ public class ActionScript2ModificationTest extends ActionScript2TestBase {
+ "If label_1\n"
+ "Push 3\n"
+ "label_1:Push 4";
testAddAction(actionsString, expectedResult, new ActionGetMember(), 2);
testAddActionNormal(actionsString, expectedResult, new ActionGetMember(), 2);
testAddActionFast(actionsString, expectedResult, new ActionGetMember(), 2);
}
@Test
@@ -302,7 +386,8 @@ public class ActionScript2ModificationTest extends ActionScript2TestBase {
+ "Push 3\n"
+ "GetMember\n"
+ "label_1:Push 4";
testAddAction(actionsString, expectedResult, new ActionGetMember(), 7);
testAddActionNormal(actionsString, expectedResult, new ActionGetMember(), 7);
testAddActionFast(actionsString, expectedResult, new ActionGetMember(), 7);
}
@Test
@@ -328,7 +413,8 @@ public class ActionScript2ModificationTest extends ActionScript2TestBase {
+ "If label_1\n"
+ "Push 3\n"
+ "label_1:Push 4";
testAddAction(actionsString, expectedResult, new ActionGetMember(), 4);
testAddActionNormal(actionsString, expectedResult, new ActionGetMember(), 4);
testAddActionFast(actionsString, expectedResult, new ActionGetMember(), 4);
}
@Test
@@ -353,6 +439,7 @@ public class ActionScript2ModificationTest extends ActionScript2TestBase {
ActionJump jump = new ActionJump(0);
jump.setAddress(9);
jump.setJumpOffset(24 - 9 - 5);
testAddAction(actionsString, expectedResult, jump, 3);
testAddActionNormal(actionsString, expectedResult, jump, 3);
testAddActionFast(actionsString, expectedResult, jump, 3);
}
}

View File

@@ -164,12 +164,12 @@ public class ActionScript3AssemblerTest extends ActionScriptTestBase {
for (int i = 0; i < code.code.size(); i++) {
AVM2Instruction ins = code.code.get(i);
int length = ins.getBytesLength();
expected.put(ins.offset, i);
expectedNearest.put(ins.offset, i);
Assert.assertEquals(code.pos2adr(i), ins.offset);
expected.put(ins.getOffset(), i);
expectedNearest.put(ins.getOffset(), i);
Assert.assertEquals(code.pos2adr(i), ins.getOffset());
for (int j = 1; j < length; j++) {
expected.put(ins.offset + j, -1);
expectedNearest.put(ins.offset + j, i + 1);
expected.put(ins.getOffset() + j, -1);
expectedNearest.put(ins.getOffset() + j, i + 1);
}
}

View File

@@ -31,7 +31,6 @@ import com.jpexs.decompiler.flash.tags.Tag;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import static org.testng.Assert.assertEquals;
@@ -90,7 +89,6 @@ public class ActionScript3ExecuteTest {
runBody.max_stack = 10;
AVM2Code ccode = new AVM2Code();
ccode.code = new ArrayList<>();
List<AVM2Instruction> code = ccode.code;
code.add(new AVM2Instruction(0, AVM2Instructions.GetLocal0, null));
code.add(new AVM2Instruction(0, AVM2Instructions.PushScope, null));
@@ -98,7 +96,6 @@ public class ActionScript3ExecuteTest {
for (int testMethodId = 1; testMethodId < 10; testMethodId++) {
AVM2Code ccode2 = new AVM2Code();
ccode2.code = new ArrayList<>();
List<AVM2Instruction> code2 = ccode2.code;
code2.add(new AVM2Instruction(0, AVM2Instructions.GetLocal0, null));
code2.add(new AVM2Instruction(0, AVM2Instructions.PushScope, null));

View File

@@ -19,12 +19,7 @@ package com.jpexs.decompiler.flash.gui;
import com.jpexs.debugger.flash.Variable;
import com.jpexs.debugger.flash.messages.in.InBreakAtExt;
import com.jpexs.debugger.flash.messages.in.InFrame;
import com.jpexs.decompiler.flash.gui.AppStrings;
import com.jpexs.decompiler.flash.gui.DebuggerHandler;
import com.jpexs.decompiler.flash.gui.DebuggerHandler.BreakListener;
import com.jpexs.decompiler.flash.gui.HeaderLabel;
import com.jpexs.decompiler.flash.gui.Main;
import com.jpexs.decompiler.flash.gui.View;
import com.jpexs.decompiler.flash.gui.abc.ABCPanel;
import java.awt.BorderLayout;
import java.awt.Color;
@@ -51,15 +46,25 @@ import javax.swing.table.DefaultTableModel;
public class DebugPanel extends JPanel {
private JTable debugRegistersTable;
private JTable debugLocalsTable;
private JTable debugScopeTable;
private JTable callStackTable;
private JTable stackTable;
private JTabbedPane varTabs;
private BreakListener listener;
private JTextArea traceLogTextarea;
private int logLength = 0;
private List<SelectedTab> tabTypes = new ArrayList<>();
private boolean loading = false;
public static enum SelectedTab {
@@ -314,5 +319,4 @@ public class DebugPanel extends JPanel {
public void dispose() {
Main.getDebugHandler().removeBreakListener(listener);
}
}

View File

@@ -21,8 +21,6 @@ import com.jpexs.debugger.flash.DebugMessageListener;
import com.jpexs.debugger.flash.Debugger;
import com.jpexs.debugger.flash.DebuggerCommands;
import com.jpexs.debugger.flash.DebuggerConnection;
import com.jpexs.debugger.flash.SWD;
import com.jpexs.debugger.flash.Variable;
import com.jpexs.debugger.flash.messages.in.InAskBreakpoints;
import com.jpexs.debugger.flash.messages.in.InBreakAt;
import com.jpexs.debugger.flash.messages.in.InBreakAtExt;
@@ -42,15 +40,11 @@ import com.jpexs.debugger.flash.messages.out.OutGetBreakReason;
import com.jpexs.debugger.flash.messages.out.OutGetSwd;
import com.jpexs.debugger.flash.messages.out.OutGetSwf;
import com.jpexs.debugger.flash.messages.out.OutProcessedTag;
import com.jpexs.decompiler.flash.abc.ClassPath;
import com.jpexs.decompiler.flash.abc.ScriptPack;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.helpers.CancellableWorker;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -68,18 +62,27 @@ import java.util.regex.Pattern;
public class DebuggerHandler implements DebugConnectionListener {
private boolean connected = false;
private DebuggerCommands commands = null;
private List<InSwfInfo.SwfInfo> swfs = new ArrayList<>();
private boolean paused = true;
private Map<Integer, String> modulePaths = new HashMap<>();
private Map<String, Integer> classToModule = new HashMap<>();
private Map<String, Set<Integer>> toAddBPointMap = new HashMap<>();
private Map<String, Set<Integer>> confirmedPointMap = new HashMap<>();
private Map<String, Set<Integer>> invalidBreakPointMap = new HashMap<>();
private Map<String, Set<Integer>> toRemoveBPointMap = new HashMap<>();
private int breakIp = -1;
private String breakScriptName = null;
public int getBreakIp() {
@@ -221,6 +224,7 @@ public class DebuggerHandler implements DebugConnectionListener {
private InFrame frame;
private InBreakAtExt breakInfo;
private InBreakReason breakReason;
private final List<BreakListener> breakListeners = new ArrayList<>();
@@ -255,13 +259,11 @@ public class DebuggerHandler implements DebugConnectionListener {
public void connected();
public void disconnected();
}
public static interface TraceListener {
public void trace(String... val);
}
public static interface BreakListener {
@@ -269,7 +271,6 @@ public class DebuggerHandler implements DebugConnectionListener {
public void breakAt(String scriptName, int line);
public void doContinue();
}
public void addBreakListener(BreakListener l) {

View File

@@ -16,7 +16,6 @@
*/
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel;
import com.jpexs.helpers.Helper;
@@ -29,9 +28,6 @@ import java.awt.event.ComponentEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowStateListener;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
/**
@@ -141,5 +137,4 @@ public final class MainFrameClassic extends AppFrame implements MainFrame {
public MainFrameMenu getMenu() {
return mainMenu;
}
}

View File

@@ -373,5 +373,4 @@ public class MainFrameClassicMenu extends MainFrameMenu {
((JComponent) me).setVisible(val);
}
}
}

View File

@@ -16,7 +16,6 @@
*/
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel;
import com.jpexs.decompiler.flash.treeitems.SWFList;
@@ -33,10 +32,7 @@ import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowStateListener;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import org.pushingpixels.flamingo.api.ribbon.JRibbon;
import org.pushingpixels.flamingo.internal.ui.ribbon.appmenu.JRibbonApplicationMenuButton;
@@ -199,5 +195,4 @@ public final class MainFrameRibbon extends AppRibbonFrame {
public MainFrameMenu getMenu() {
return mainMenu;
}
}

View File

@@ -37,7 +37,6 @@ import org.pushingpixels.flamingo.api.common.CommandToggleButtonGroup;
import org.pushingpixels.flamingo.api.common.JCommandButton;
import org.pushingpixels.flamingo.api.common.JCommandButtonPanel;
import org.pushingpixels.flamingo.api.common.JCommandToggleButton;
import org.pushingpixels.flamingo.api.common.RichTooltip;
import org.pushingpixels.flamingo.api.common.popup.JPopupPanel;
import org.pushingpixels.flamingo.api.common.popup.PopupPanelCallback;
import org.pushingpixels.flamingo.api.ribbon.AbstractRibbonBand;
@@ -291,7 +290,7 @@ public class MainFrameRibbonMenu extends MainFrameMenu {
cbut = new JCommandButton(fixCommandTitle(subTitle));
}
if (subKey != null) {
//cbut.setActionRichTooltip(new RichTooltip(subTitle, subKey.toString()));
//cbut.setActionRichTooltip(new RichTooltip(subTitle, subKey.toString()));
}
if (subLoader != null) {
cbut.setCommandButtonKind(JCommandButton.CommandButtonKind.ACTION_AND_POPUP_MAIN_ACTION);
@@ -639,5 +638,4 @@ public class MainFrameRibbonMenu extends MainFrameMenu {
}
}
}

View File

@@ -32,6 +32,7 @@ public interface MenuBuilder {
public static class HotKey {
private static Map<Integer, String> keyCodesToNames = new HashMap<>();
private static Map<String, Integer> keyNamesToCodes = new HashMap<>();
{
@@ -57,8 +58,11 @@ public interface MenuBuilder {
}
public int key;
public boolean shiftDown;
public boolean ctrlDown;
public boolean altDown;
@Override
@@ -163,7 +167,6 @@ public interface MenuBuilder {
return s;
}
}
public static final int PRIORITY_LOW = 1;

View File

@@ -16,11 +16,7 @@
*/
package com.jpexs.decompiler.flash.gui.abc;
import com.jpexs.decompiler.flash.gui.DebugPanel;
import com.jpexs.debugger.flash.Variable;
import com.jpexs.debugger.flash.messages.in.InBreakAtExt;
import com.jpexs.debugger.flash.messages.in.InBreakReason;
import com.jpexs.debugger.flash.messages.in.InFrame;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.ClassPath;
@@ -45,6 +41,7 @@ import com.jpexs.decompiler.flash.abc.usages.TraitMultinameUsage;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.gui.AppDialog;
import com.jpexs.decompiler.flash.gui.AppStrings;
import com.jpexs.decompiler.flash.gui.DebugPanel;
import com.jpexs.decompiler.flash.gui.DebuggerHandler;
import com.jpexs.decompiler.flash.gui.HeaderLabel;
import com.jpexs.decompiler.flash.gui.Main;
@@ -87,7 +84,6 @@ import java.awt.event.MouseMotionListener;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
@@ -105,7 +101,6 @@ import javax.swing.JTable;
import javax.swing.JToggleButton;
import javax.swing.SwingConstants;
import javax.swing.border.BevelBorder;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
@@ -272,6 +267,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
// DebuggerHandler.VariableChangedListener varChangeListener;
List<TableModelListener> tableListeners = new ArrayList<>();
private List<Variable> vars;
public VariablesTableModel(List<Variable> vars) {
@@ -348,7 +344,6 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<ABC
public void removeTableModelListener(TableModelListener l) {
tableListeners.remove(l);
}
}
public ABCPanel(MainPanel mainPanel) {

View File

@@ -30,7 +30,6 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.regex.Pattern;
/**
*
@@ -59,10 +58,13 @@ public class Debugger {
private final int id;
public boolean finished = false;
private final Map<String, String> parameters = new HashMap<>();
public static final int MSG_STRING = 0;
public static final int MSG_LOADER_URL = 1;
public static final int MSG_LOADER_BYTES = 2;
public String getParameter(String name, String defValue) {

View File

@@ -35,25 +35,35 @@ import jsyntaxpane.components.LineNumbersBreakpointsRuler;
public class DebuggableEditorPane extends LineMarkedEditorPane implements BreakPointListener, LineMarkerPainter {
private static final Color BG_CURRENT_COLOR = new Color(0xd6, 0xe8, 0xe2);
private static final Color BG_RULER_COLOR = new Color(0xe9, 0xe8, 0xe2);
private static final Color BG_BREAKPOINT_COLOR = new Color(0xfc, 0x9d, 0x9f);
private static final Color FG_BREAKPOINT_COLOR = null;
private static final int PRIORITY_BREAKPOINT = 20;
private static final Color BG_IP_COLOR = new Color(0xbd, 0xe6, 0xaa);
private static final Color FG_IP_COLOR = null;
private static final int PRIORITY_IP = 0;
private static final Color BG_INVALID_BREAKPOINT_COLOR = new Color(0xdc, 0xdc, 0xd8);
private static final Color FG_INVALID_BREAKPOINT_COLOR = null;
private static final int PRIORITY_INVALID_BREAKPOINT = 10;
public static final LineMarker BREAKPOINT_MARKER = new LineMarker(FG_BREAKPOINT_COLOR, BG_BREAKPOINT_COLOR, PRIORITY_BREAKPOINT);
public static final LineMarker IP_MARKER = new LineMarker(FG_IP_COLOR, BG_IP_COLOR, PRIORITY_IP);
public static final LineMarker INVALID_BREAKPOINT_MARKER = new LineMarker(FG_INVALID_BREAKPOINT_COLOR, BG_INVALID_BREAKPOINT_COLOR, PRIORITY_INVALID_BREAKPOINT);
protected String scriptName = null;
private LineNumbersBreakpointsRuler ruler;
public synchronized void setScriptName(String scriptName) {
@@ -180,5 +190,4 @@ public class DebuggableEditorPane extends LineMarkedEditorPane implements BreakP
super.removeColorMarker(line, lm);
ruler.repaint();
}
}

View File

@@ -65,6 +65,7 @@ public class LineMarkedEditorPane extends UndoFixedEditorPane implements LinkHan
private static final int truncateLimit = 2 * 1024 * 1024;
public static final Color BG_SELECTED_LINE = new Color(0xe9, 0xef, 0xf8);
public static final Color BG_ERROR_LINE = new Color(255, 200, 200);
private int lastLine = -1;
@@ -80,8 +81,11 @@ public class LineMarkedEditorPane extends UndoFixedEditorPane implements LinkHan
public static class LineMarker implements Comparable<LineMarker> {
private Color bgColor;
private Color color;
private FgPainter fgPainter;
//private int line;
private int priority;
@@ -140,6 +144,7 @@ public class LineMarkedEditorPane extends UndoFixedEditorPane implements LinkHan
}
}
//(Map<Integer, TreeSet<LineMarker>>)
private Map<Integer, SortedSet<LineMarker>> lineMarkers = Collections.synchronizedMap(new HashMap<Integer, SortedSet<LineMarker>>());
public void setLineMarkers(Map<Integer, SortedSet<LineMarker>> colorMarkers) {
@@ -415,7 +420,7 @@ public class LineMarkedEditorPane extends UndoFixedEditorPane implements LinkHan
t = t.substring(0, truncateLimit) + "\r\n" + AppStrings.translate("editorTruncateWarning").replace("%chars%", Integer.toString(truncateLimit));
}
super.setText(t);
setCaretPosition(0); //scroll to top
setCaretPosition(0); //scroll to top
}
public static class FgPainter extends DefaultHighlighter.DefaultHighlightPainter {
@@ -613,5 +618,4 @@ public class LineMarkedEditorPane extends UndoFixedEditorPane implements LinkHan
}
}
}
}

View File

@@ -301,7 +301,6 @@ public class AdobeFlashExecutor {
int multinameId = abc.constants.getMultinameId(multiname, true);
AVM2Code ccode = new AVM2Code();
ccode.code = new ArrayList<>();
List<AVM2Instruction> code = ccode.code;
code.add(new AVM2Instruction(0, AVM2Instructions.GetLocal0, null));
code.add(new AVM2Instruction(0, AVM2Instructions.PushScope, null));

View File

@@ -84,7 +84,6 @@ import java.util.Random;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import org.testng.annotations.Test;
/**
*
@@ -109,7 +108,6 @@ public class FlashPlayerTest {
List<AS3ExecuteTask> tasks = new ArrayList<>();
for (int p1 = 0; p1 < pushes.length; p1++) {
AVM2Code ccode = new AVM2Code();
ccode.code = new ArrayList<>();
List<AVM2Instruction> code = ccode.code;
code.add(new AVM2Instruction(0, AVM2Instructions.GetLocal0, null));
code.add(new AVM2Instruction(0, AVM2Instructions.PushScope, null));
@@ -213,7 +211,6 @@ public class FlashPlayerTest {
}
AVM2Code ccode = new AVM2Code();
ccode.code = new ArrayList<>();
List<AVM2Instruction> code = ccode.code;
code.add(new AVM2Instruction(0, AVM2Instructions.GetLocal0, null));
code.add(new AVM2Instruction(0, AVM2Instructions.PushScope, null));