merged honfika changes + some fixes to make tests work

This commit is contained in:
Jindra Pet��k
2013-08-25 16:09:42 +02:00
448 changed files with 7155 additions and 626 deletions
@@ -884,7 +884,7 @@ public class SWFInputStream extends InputStream {
HashMap<String, GraphTargetItem> vars = (HashMap<String, GraphTargetItem>) localData.get(1);
System.err.print("variables: ");
for (Entry<String, GraphTargetItem> v : vars.entrySet()) {
System.err.print("'" + v + "' = " + Highlighting.stripHilights(v.getValue().toString(cpool)) + ", ");
System.err.print("'" + v + "' = " + v.getValue().toString(false, cpool) + ", ");
}
System.err.println();
String add = "";
@@ -298,11 +298,11 @@ public class TagNode {
String res;
ASMSource asm = ((ASMSource) node.tag);
if (isPcode) {
res = asm.getActionSourcePrefix() + Helper.indentRows(asm.getActionSourceIndent(), Highlighting.stripHilights(asm.getASMSource(SWF.DEFAULT_VERSION, false)), Graph.INDENT_STRING) + asm.getActionSourceSuffix();
res = asm.getActionSourcePrefix() + Helper.indentRows(asm.getActionSourceIndent(), asm.getASMSource(SWF.DEFAULT_VERSION, false, false), Graph.INDENT_STRING) + asm.getActionSourceSuffix();
} else {
List<Action> as = asm.getActions(SWF.DEFAULT_VERSION);
Action.setActionsAddresses(as, 0, SWF.DEFAULT_VERSION);
res = asm.getActionSourcePrefix() + Helper.indentRows(asm.getActionSourceIndent(), Highlighting.stripHilights(Action.actionsToSource(as, SWF.DEFAULT_VERSION, ""/*FIXME*/)), Graph.INDENT_STRING) + asm.getActionSourceSuffix();
res = asm.getActionSourcePrefix() + Helper.indentRows(asm.getActionSourceIndent(), Action.actionsToSource(as, SWF.DEFAULT_VERSION, ""/*FIXME*/, false), Graph.INDENT_STRING) + asm.getActionSourceSuffix();
}
try (FileOutputStream fos = new FileOutputStream(f)) {
fos.write(res.getBytes("utf-8"));
@@ -702,24 +702,24 @@ public class AVM2Code implements Serializable {
return s.toString();
}
public String toString(ConstantPool constants) {
public String toString(boolean highlight, ConstantPool constants) {
StringBuilder s = new StringBuilder();
int i = 0;
for (AVM2Instruction instruction : code) {
s.append(Helper.formatAddress(i));
s.append(" ");
s.append(instruction.toString(constants, new ArrayList<String>()));
s.append(instruction.toString(highlight, constants, new ArrayList<String>()));
s.append("\r\n");
i++;
}
return s.toString();
}
public String toASMSource(ConstantPool constants, MethodBody body, boolean hex) {
return toASMSource(constants, body, new ArrayList<Integer>(), hex);
public String toASMSource(ConstantPool constants, MethodBody body, boolean hex, boolean highlight) {
return toASMSource(constants, body, new ArrayList<Integer>(), hex, highlight);
}
public String toASMSource(ConstantPool constants, MethodBody body, List<Integer> outputMap, boolean hex) {
public String toASMSource(ConstantPool constants, MethodBody body, List<Integer> outputMap, boolean hex, boolean highlight) {
invalidateCache();
StringBuffer ret = new StringBuffer();
String t = "";
@@ -776,7 +776,8 @@ 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 = highlight ? Highlighting.hilighOffset("", ins2.mappedOffset > -1 ? ins2.mappedOffset : ofs) : "";
t += 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) {
@@ -814,7 +815,7 @@ public class AVM2Code implements Serializable {
}
}
if (markOffsets) {
t = Highlighting.hilighOffset("", ins.mappedOffset > -1 ? ins.mappedOffset : ofs) + t + "\n";
t = (highlight ? Highlighting.hilighOffset("", ins.mappedOffset > -1 ? ins.mappedOffset : ofs) : "") + t + "\n";
} else {
t = t + "\n";
}
@@ -1374,10 +1375,7 @@ public class AVM2Code implements Serializable {
list.remove(lastPos);
}
s = Graph.graphToString(list, constants, localRegNames, fullyQualifiedNames);
if (!hilighted) {
return Highlighting.stripHilights(s);
}
s = Graph.graphToString(list, hilighted, constants, localRegNames, fullyQualifiedNames);
return s;
}
@@ -1958,7 +1956,7 @@ public class AVM2Code implements Serializable {
invalidateCache();
try {
List<Integer> outputMap = new ArrayList<>();
String src = Highlighting.stripHilights(toASMSource(constants, body, outputMap, false));
String src = toASMSource(constants, body, outputMap, false, false);
AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(src.getBytes("UTF-8")), constants, null, body);
for (int i = 0; i < acode.code.size(); i++) {
@@ -1998,7 +1996,7 @@ public class AVM2Code implements Serializable {
public void removeIgnored(ConstantPool constants, MethodBody body) {
try {
List<Integer> outputMap = new ArrayList<>();
String src = toASMSource(constants, body, outputMap, false);
String src = toASMSource(constants, body, outputMap, false, false);
AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(src.getBytes("UTF-8")), constants, body);
for (int i = 0; i < acode.code.size(); i++) {
if (outputMap.size() > i) {
@@ -32,7 +32,7 @@ public class CodeStats {
public boolean has_activation = false;
public InstructionStats instructionStats[];
public String toString(ABC abc, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ABC abc, List<String> fullyQualifiedNames) {
String ret = "Stats: maxstack=" + maxstack + ", maxscope=" + maxscope + ", maxlocal=" + maxlocal + "\r\n";
int i = 0;
int ms = 0;
@@ -41,7 +41,7 @@ public class CodeStats {
if (stats.stackpos > ms) {
ms = stats.stackpos;
}
ret += "" + i + ":" + stats.stackpos + (deltastack >= 0 ? "+" + deltastack : deltastack) + "," + stats.scopepos + " " + stats.ins.toString(abc.constants, fullyQualifiedNames) + "\r\n";
ret += "" + i + ":" + stats.stackpos + (deltastack >= 0 ? "+" + deltastack : deltastack) + "," + stats.scopepos + " " + stats.ins.toString(highlight, abc.constants, fullyQualifiedNames) + "\r\n";
i++;
}
return ret;
@@ -241,7 +241,7 @@ public class AVM2Instruction implements Serializable, GraphSourceItem {
return ignored;
}
public String toString(ConstantPool constants, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, List<String> fullyQualifiedNames) {
String s = Helper.formatAddress(offset) + " " + Helper.padSpaceRight(Helper.byteArrToString(getBytes()), 30) + definition.instructionName;
s += getParams(constants, fullyQualifiedNames) + getComment();
return s;
@@ -38,7 +38,7 @@ public class NewClassIns extends InstructionDefinition {
@Override
public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap<Integer, GraphTargetItem> localRegs, Stack<GraphTargetItem> stack, java.util.Stack<GraphTargetItem> scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List<GraphTargetItem> output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames, String path, HashMap<Integer, Integer> localRegsAssignmentIps, int ip, HashMap<Integer, List<Integer>> refs, AVM2Code code) {
int clsIndex = ins.operands[0];
String baseType = stack.pop().toString(Helper.toList(constants, localRegNames, fullyQualifiedNames));
String baseType = stack.pop().toString(false, Helper.toList(constants, localRegNames, fullyQualifiedNames));
stack.push(new UnparsedAVM2Item(ins, "new " + abc.constants.constant_multiname[abc.instance_info[clsIndex].name_index].getName(constants, fullyQualifiedNames) + ".class extends " + baseType));
}
@@ -51,7 +51,7 @@ public class SetSuperIns extends InstructionDefinition implements SetTypeIns {
public String getObject(Stack<AVM2Item> stack, ABC abc, AVM2Instruction ins, List<AVM2Item> output, com.jpexs.decompiler.flash.abc.types.MethodBody body, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
int multinameIndex = ins.operands[0];
String multiname = resolveMultinameNoPop(1, stack, abc.constants, multinameIndex, ins, fullyQualifiedNames);
String obj = stack.get(1 + resolvedCount(abc.constants, multinameIndex)).toString(abc.constants, localRegNames, fullyQualifiedNames);
String obj = stack.get(1 + resolvedCount(abc.constants, multinameIndex)).toString(false, abc.constants, localRegNames, fullyQualifiedNames);
return obj + ".super." + multiname;
}
@@ -36,18 +36,18 @@ public abstract class AVM2Item extends GraphTargetItem {
@Override
@SuppressWarnings("unchecked")
public String toString(List<Object> localData) {
return toString((ConstantPool) localData.get(0), (HashMap<Integer, String>) localData.get(1), (List<String>) localData.get(2));
public String toString(boolean highlight, List<Object> localData) {
return toString(highlight, (ConstantPool) localData.get(0), (HashMap<Integer, String>) localData.get(1), (List<String>) localData.get(2));
}
public abstract String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames);
public abstract String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames);
public String toStringNoH(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return Highlighting.stripHilights(toString(constants, localRegNames, fullyQualifiedNames));
return toString(false, constants, localRegNames, fullyQualifiedNames);
}
public String toStringSemicoloned(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return toString(constants, localRegNames, fullyQualifiedNames) + (needsSemicolon() ? ";" : "");
public String toStringSemicoloned(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return toString(highlight, constants, localRegNames, fullyQualifiedNames) + (needsSemicolon() ? ";" : "");
}
@Override
@@ -55,8 +55,8 @@ public abstract class AVM2Item extends GraphTargetItem {
return true;
}
protected String formatProperty(ConstantPool constants, GraphTargetItem object, GraphTargetItem propertyName, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String obStr = object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames));
protected String formatProperty(boolean highlight, ConstantPool constants, GraphTargetItem object, GraphTargetItem propertyName, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String obStr = object.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames));
if (object.precedence > PRECEDENCE_PRIMARY) {
obStr = "(" + obStr + ")";
}
@@ -68,16 +68,16 @@ public abstract class AVM2Item extends GraphTargetItem {
}
}
if (obStr.equals("")) {
return propertyName.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames));
return propertyName.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames));
}
if (propertyName instanceof FullMultinameAVM2Item) {
if (((FullMultinameAVM2Item) propertyName).name != null) {
return obStr + propertyName.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames));
return obStr + propertyName.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames));
} else {
return obStr + "." + propertyName.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames));
return obStr + "." + propertyName.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames));
}
} else {
return obStr + "[" + propertyName.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "]";
return obStr + "[" + propertyName.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "]";
}
}
@@ -38,7 +38,7 @@ public class AlchemyLoadAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("op_" + name + "(") + ofs.toString(constants, localRegNames, fullyQualifiedNames) + hilight(") /*Alchemy*/");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("op_" + name + "(", highlight) + ofs.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(") /*Alchemy*/", highlight);
}
}
@@ -37,7 +37,7 @@ public class AlchemySignExtendAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("op_" + name + "(") + value.toString(constants, localRegNames, fullyQualifiedNames) + hilight(") /*Alchemy*/");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("op_" + name + "(", highlight) + value.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(") /*Alchemy*/", highlight);
}
}
@@ -39,7 +39,7 @@ public class AlchemyStoreAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("op_" + name + "(") + ofs.toString(constants, localRegNames, fullyQualifiedNames) + hilight(",") + value.toString(constants, localRegNames, fullyQualifiedNames) + hilight(") /*Alchemy*/");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("op_" + name + "(", highlight) + ofs.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(",", highlight) + value.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(") /*Alchemy*/", highlight);
}
}
@@ -35,20 +35,20 @@ public class ApplyTypeAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
StringBuilder ret = new StringBuilder();
ret.append(object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)));
ret.append(object.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)));
if (!params.isEmpty()) {
ret.append(hilight(".<"));
ret.append(hilight(".<", highlight));
for (int i = 0; i < params.size(); i++) {
if (i > 0) {
ret.append(hilight(","));
ret.append(hilight(",", highlight));
}
GraphTargetItem p = params.get(i);
if (p instanceof NullAVM2Item) {
ret.append("*");
} else {
ret.append(p.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)));
ret.append(p.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)));
}
}
ret.append(">");
@@ -31,8 +31,8 @@ public class BooleanAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return value.toString();
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight(value?"true":"false", highlight);
}
@Override
@@ -36,25 +36,25 @@ public class CallAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String args = "";
for (int a = 0; a < arguments.size(); a++) {
if (a > 0) {
args = args + ",";
}
args = args + arguments.get(a).toString(constants, localRegNames, fullyQualifiedNames);
args = args + arguments.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
/*String recPart = ""; receiver.toString(constants, localRegNames) + hilight(".");
/*String recPart = ""; receiver.toString(constants, localRegNames) + hilight(".", highlight);
if (receiver instanceof NewActivationAVM2Item) {
recPart = "";
}
if (receiver instanceof ThisAVM2Item) {
recPart = "";
}*/
String fstr = function.toString(constants, localRegNames, fullyQualifiedNames);
String fstr = function.toString(highlight, constants, localRegNames, fullyQualifiedNames);
if (function.precedence > precedence) {
fstr = "(" + fstr + ")";
}
return fstr + hilight("(") + args + hilight(")");
return fstr + hilight("(", highlight) + args + hilight(")", highlight);
}
}
@@ -37,14 +37,14 @@ public class CallMethodAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String args = "";
for (int a = 0; a < arguments.size(); a++) {
if (a > 0) {
args = args + ",";
}
args = args + arguments.get(a).toString(constants, localRegNames, fullyQualifiedNames);
args = args + arguments.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
return receiver.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight(".") + methodName + hilight("(") + args + hilight(")");
return receiver.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight(".", highlight) + methodName + hilight("(", highlight) + args + hilight(")", highlight);
}
}
@@ -38,14 +38,14 @@ public class CallPropertyAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String args = "";
for (int a = 0; a < arguments.size(); a++) {
if (a > 0) {
args = args + hilight(",");
args = args + hilight(",", highlight);
}
args = args + arguments.get(a).toString(constants, localRegNames, fullyQualifiedNames);
args = args + arguments.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
return formatProperty(constants, receiver, propertyName, localRegNames, fullyQualifiedNames) + hilight("(") + args + hilight(")");
return formatProperty(highlight, constants, receiver, propertyName, localRegNames, fullyQualifiedNames) + hilight("(", highlight) + args + hilight(")", highlight);
}
}
@@ -37,14 +37,14 @@ public class CallStaticAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String args = "";
for (int a = 0; a < arguments.size(); a++) {
if (a > 0) {
args = args + ",";
}
args = args + arguments.get(a).toString(constants, localRegNames, fullyQualifiedNames);
args = args + arguments.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
return receiver.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight(".") + methodName + hilight("(") + args + hilight(")");
return receiver.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight(".", highlight) + methodName + hilight("(", highlight) + args + hilight(")", highlight);
}
}
@@ -39,18 +39,18 @@ public class CallSuperAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String args = "";
for (int a = 0; a < arguments.size(); a++) {
if (a > 0) {
args = args + ",";
}
args = args + arguments.get(a).toString(constants, localRegNames, fullyQualifiedNames);
args = args + arguments.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames, highlight);
}
String calee = receiver.toString(constants, localRegNames, fullyQualifiedNames) + ".";
String calee = receiver.toString(highlight, constants, localRegNames, fullyQualifiedNames, highlight) + ".";
if (Highlighting.stripHilights(calee).equals("this.")) {
calee = "";
}
return calee + hilight("super.") + multiname.toString(constants, localRegNames, fullyQualifiedNames) + hilight("(") + args + hilight(")");
return calee + hilight("super.", highlight) + multiname.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight("(", highlight) + args + hilight(")", highlight);
}
}
@@ -31,7 +31,7 @@ public class ClassAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return className.getName(constants, fullyQualifiedNames);
}
}
@@ -36,9 +36,9 @@ public class CoerceAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
//return hilight("("+type+")")+
return value.toString(constants, localRegNames, fullyQualifiedNames);
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
//return hilight("("+type+")", highlight)+
return value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
@Override
@@ -34,19 +34,19 @@ public class ConstructAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String argStr = "";
for (int a = 0; a < args.size(); a++) {
if (a > 0) {
argStr = argStr + ",";
}
argStr = argStr + args.get(a).toString(constants, localRegNames, fullyQualifiedNames);
argStr = argStr + args.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
if (object instanceof NewFunctionAVM2Item) {
return hilight("new ") + object.toString(constants, localRegNames, fullyQualifiedNames);
return hilight("new ", highlight) + object.toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
String obStr = object.toString(constants, localRegNames, fullyQualifiedNames);
return hilight("new ") + obStr + hilight("(") + argStr + hilight(")");
String obStr = object.toString(highlight, constants, localRegNames, fullyQualifiedNames);
return hilight("new ", highlight) + obStr + hilight("(", highlight) + argStr + hilight(")", highlight);
}
}
@@ -36,19 +36,19 @@ public class ConstructPropAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String argStr = "";
for (int a = 0; a < args.size(); a++) {
if (a > 0) {
argStr = argStr + ",";
}
argStr = argStr + args.get(a).toString(constants, localRegNames, fullyQualifiedNames);
argStr = argStr + args.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
String objstr = object.toString(constants, localRegNames, fullyQualifiedNames);
String objstr = object.toString(highlight, constants, localRegNames, fullyQualifiedNames);
if (!objstr.equals("")) {
objstr += ".";
}
return hilight("new ") + objstr + propertyName.toString(constants, localRegNames, fullyQualifiedNames) + hilight("(") + argStr + hilight(")");
return hilight("new ", highlight) + objstr + propertyName.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight("(", highlight) + argStr + hilight(")", highlight);
}
}
@@ -35,19 +35,19 @@ public class ConstructSuperAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String argStr = "";
for (int a = 0; a < args.size(); a++) {
if (a > 0) {
argStr = argStr + ",";
}
argStr = argStr + args.get(a).toString(constants, localRegNames, fullyQualifiedNames);
argStr = argStr + args.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
String calee = object.toString(constants, localRegNames, fullyQualifiedNames) + ".";
String calee = object.toString(highlight, constants, localRegNames, fullyQualifiedNames) + ".";
if (Highlighting.stripHilights(calee).equals("this.")) {
calee = "";
}
return calee + hilight("super(") + argStr + hilight(")");
return calee + hilight("super(", highlight) + argStr + hilight(")", highlight);
}
}
@@ -35,8 +35,8 @@ public class ConvertAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return value.toString(constants, localRegNames, fullyQualifiedNames);
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
@Override
@@ -31,7 +31,7 @@ public class DecLocalAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return localRegName(localRegNames, regIndex) + hilight("--");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return localRegName(localRegNames, regIndex) + hilight("--", highlight);
}
}
@@ -31,8 +31,8 @@ public class DecrementAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return value.toString(constants, localRegNames, fullyQualifiedNames) + hilight("-1");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return value.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight("-1", highlight);
}
@Override
@@ -37,7 +37,7 @@ public class DefaultXMLNamespace extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("default xml namespace = ") + ns.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames));
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("default xml namespace = ", highlight) + ns.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames));
}
}
@@ -35,7 +35,7 @@ public class EscapeXAttrAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("{") + value.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight("}");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("{", highlight) + value.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight("}", highlight);
}
}
@@ -37,7 +37,7 @@ public class EscapeXElemAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("{") + expression.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight("}");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("{", highlight) + expression.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight("}", highlight);
}
}
@@ -37,7 +37,7 @@ public class FilteredCheckAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames));
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return object.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames));
}
}
@@ -31,7 +31,7 @@ public class FindPropertyAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return "";
}
}
@@ -31,8 +31,8 @@ public class FloatValueAVM2Item extends NumberValueAVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("" + value);
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("" + value, highlight);
}
@Override
@@ -57,13 +57,13 @@ public class FullMultinameAVM2Item extends AVM2Item {
public boolean isXML(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String cname;
if (name != null) {
cname = name.toString(constants, localRegNames, fullyQualifiedNames);
cname = name.toString(false, constants, localRegNames, fullyQualifiedNames);
} else {
cname = (constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames));
}
String cns = "";
if (namespace != null) {
cns = namespace.toString(constants, localRegNames, fullyQualifiedNames);
cns = namespace.toString(false, constants, localRegNames, fullyQualifiedNames);
} else {
Namespace ns = constants.constant_multiname[multinameIndex].getNamespace(constants);
if ((ns != null) && (ns.name_index != 0)) {
@@ -74,15 +74,15 @@ public class FullMultinameAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String ret = "";
if (name != null) {
ret = "[" + name.toString(constants, localRegNames, fullyQualifiedNames) + "]";
ret = "[" + name.toString(highlight, constants, localRegNames, fullyQualifiedNames) + "]";
} else {
ret = hilight(constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames));
ret = hilight(constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames), highlight);
}
if (namespace != null) {
ret = namespace.toString(constants, localRegNames, fullyQualifiedNames) + "::" + ret;
ret = namespace.toString(highlight, constants, localRegNames, fullyQualifiedNames) + "::" + ret;
} else {
/*Namespace ns = constants.constant_multiname[multinameIndex].getNamespace(constants);
if ((ns != null)&&(ns.name_index!=0)) {
@@ -34,7 +34,7 @@ public class GetDescendantsAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return object.toString(constants, localRegNames, fullyQualifiedNames) + hilight("..") + multiname.toString(constants, localRegNames, fullyQualifiedNames);
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return object.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight("..", highlight) + multiname.toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
}
@@ -32,7 +32,7 @@ public class GetLexAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight(propertyName.getName(constants, fullyQualifiedNames));
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight(propertyName.getName(constants, fullyQualifiedNames), highlight);
}
}
@@ -34,7 +34,7 @@ public class GetPropertyAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return formatProperty(constants, object, propertyName, localRegNames, fullyQualifiedNames);
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return formatProperty(highlight, constants, object, propertyName, localRegNames, fullyQualifiedNames);
}
}
@@ -35,10 +35,10 @@ public class GetSlotAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
if (slotName == null) {
return hilight("/*UnknownSlot*/");
return hilight("/*UnknownSlot*/", highlight);
}
return hilight(slotName.getName(constants, fullyQualifiedNames));
return hilight(slotName.getName(constants, fullyQualifiedNames), highlight);
}
}
@@ -35,11 +35,11 @@ public class GetSuperAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String calee = object.toString(constants, localRegNames, fullyQualifiedNames) + ".";
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String calee = object.toString(highlight, constants, localRegNames, fullyQualifiedNames) + ".";
if (Highlighting.stripHilights(calee).equals("this.")) {
calee = "";
}
return calee + hilight("super.") + propertyName.toString(constants, localRegNames, fullyQualifiedNames);
return calee + hilight("super.", highlight) + propertyName.toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
}
@@ -39,7 +39,7 @@ public class HasNextAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return collection.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + " hasNext " + object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames));
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return collection.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + " hasNext " + object.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames));
}
}
@@ -34,7 +34,7 @@ public class InAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return object.toString(constants, localRegNames, fullyQualifiedNames) + hilight(" in ") + collection.toString(constants, localRegNames, fullyQualifiedNames);
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return object.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(" in ", highlight) + collection.toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
}
@@ -31,7 +31,7 @@ public class IncLocalAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return localRegName(localRegNames, regIndex) + hilight("++");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return localRegName(localRegNames, regIndex) + hilight("++", highlight);
}
}
@@ -31,8 +31,8 @@ public class IncrementAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return value.toString(constants, localRegNames, fullyQualifiedNames) + hilight("+1");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return value.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight("+1", highlight);
}
@Override
@@ -37,8 +37,8 @@ public class InitPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, A
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return formatProperty(constants, object, propertyName, localRegNames, fullyQualifiedNames) + hilight(" = ") + value.toString(constants, localRegNames, fullyQualifiedNames);
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return formatProperty(highlight, constants, object, propertyName, localRegNames, fullyQualifiedNames) + hilight(" = ", highlight) + value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
@Override
@@ -31,8 +31,8 @@ public class IntegerValueAVM2Item extends NumberValueAVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("" + value);
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("" + value, highlight);
}
@Override
@@ -49,11 +49,11 @@ public class LocalRegAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
if (computedValue instanceof FilterAVM2Item) {
return computedValue.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames));
return computedValue.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames));
}
return hilight(localRegName(localRegNames, regIndex));
return hilight(localRegName(localRegNames, regIndex), highlight);
}
@Override
@@ -31,10 +31,10 @@ public class NameSpaceAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
if (namespaceIndex == 0) {
return "*";
}
return hilight(constants.constant_namespace[namespaceIndex].toString(constants));
return hilight(constants.constant_namespace[namespaceIndex].toString(constants), highlight);
}
}
@@ -34,11 +34,11 @@ public class NameValuePair extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String valueStr = value.toString(constants, localRegNames, fullyQualifiedNames);
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String valueStr = value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
if (value instanceof TernarOpItem) { //Ternar operator contains ":"
valueStr = "(" + valueStr + ")";
}
return name.toString(constants, localRegNames, fullyQualifiedNames) + ":" + valueStr;
return name.toString(highlight, constants, localRegNames, fullyQualifiedNames) + ":" + valueStr;
}
}
@@ -28,7 +28,7 @@ public class NanAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("NaN");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("NaN", highlight);
}
}
@@ -31,7 +31,7 @@ public class NewActivationAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("newactivation()");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("newactivation()", highlight);
}
}
@@ -32,14 +32,14 @@ public class NewArrayAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String args = "";
for (int a = 0; a < values.size(); a++) {
if (a > 0) {
args = args + ",";
}
args = args + values.get(a).toString(constants, localRegNames, fullyQualifiedNames);
args = args + values.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
return hilight("[") + args + hilight("]");
return hilight("[", highlight) + args + hilight("]", highlight);
}
}
@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.Highlighting;
import java.util.HashMap;
import java.util.List;
@@ -37,7 +38,7 @@ public class NewFunctionAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("function" + (!functionName.equals("") ? " " + functionName : "") + "(" + paramStr + "):" + returnStr + "\r\n{\r\n") + functionBody + "\r\n" + hilight("}");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("function" + (!functionName.equals("") ? " " + functionName : "") + "(" + paramStr + "):" + returnStr + "\r\n{\r\n", highlight) + (highlight?functionBody:Highlighting.stripHilights(functionBody)) + "\r\n" + hilight("}", highlight);
}
}
@@ -32,17 +32,17 @@ public class NewObjectAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String params = "";
for (int n = 0; n < pairs.size(); n++) {
if (n > 0) {
params += ",\r\n";
}
params += pairs.get(n).toString(constants, localRegNames, fullyQualifiedNames);
params += pairs.get(n).toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
if (pairs.size() < 2) {
return hilight("{") + params + hilight("}");
return hilight("{", highlight) + params + hilight("}", highlight);
}
return "\r\n" + Graph.INDENTOPEN + "\r\n" + hilight("{") + "\r\n" + params + "\r\n" + hilight("}") + "\r\n" + Graph.INDENTCLOSE + "\r\n";
return "\r\n" + Graph.INDENTOPEN + "\r\n" + hilight("{", highlight) + "\r\n" + params + "\r\n" + hilight("}", highlight) + "\r\n" + Graph.INDENTCLOSE + "\r\n";
}
}
@@ -39,7 +39,7 @@ public class NextNameAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return "nextName(" + index.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "," + obj.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + ")";
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return "nextName(" + index.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "," + obj.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + ")";
}
}
@@ -39,7 +39,7 @@ public class NextValueAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return "nextValue(" + index.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "," + obj.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + ")";
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return "nextValue(" + index.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "," + obj.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + ")";
}
}
@@ -29,8 +29,8 @@ public class NullAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("null");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("null", highlight);
}
@Override
@@ -34,8 +34,8 @@ public class PostDecrementAVM2Item extends AVM2Item implements AssignmentAVM2Ite
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight("--");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return object.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight("--", highlight);
}
@Override
@@ -34,8 +34,8 @@ public class PostIncrementAVM2Item extends AVM2Item implements AssignmentAVM2Ite
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight("++");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return object.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight("++", highlight);
}
@Override
@@ -33,12 +33,12 @@ public class ReturnValueAVM2Item extends AVM2Item implements ExitItem {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String vaStr = value.toString(constants, localRegNames, fullyQualifiedNames);
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String vaStr = value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
String prefix = "\r\n" + Graph.INDENTOPEN + "\r\n";
if (vaStr.startsWith(prefix)) { //NewObjectAVM2Item
vaStr = vaStr.substring(prefix.length());
}
return hilight("return ") + vaStr;
return hilight("return ", highlight) + vaStr;
}
}
@@ -29,7 +29,7 @@ public class ReturnVoidAVM2Item extends AVM2Item implements ExitItem {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("return");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("return", highlight);
}
}
@@ -34,7 +34,7 @@ public class ScriptAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return "script" + scriptIndex;
}
}
@@ -40,8 +40,8 @@ public class SetGlobalSlotAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("setglobalslot(" + slotId + ",") + value.toString(constants, localRegNames, fullyQualifiedNames) + hilight(")");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("setglobalslot(" + slotId + ",", highlight) + value.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(")", highlight);
}
@Override
@@ -35,8 +35,8 @@ public class SetLocalAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assig
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight(localRegName(localRegNames, regIndex) + " = ") + value.toString(constants, localRegNames, fullyQualifiedNames);
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight(localRegName(localRegNames, regIndex) + " = ", highlight) + value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
@Override
@@ -43,8 +43,8 @@ public class SetPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, As
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return formatProperty(constants, object, propertyName, localRegNames, fullyQualifiedNames) + hilight(" = ") + value.toString(constants, localRegNames, fullyQualifiedNames);
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return formatProperty(highlight, constants, object, propertyName, localRegNames, fullyQualifiedNames) + hilight(" = ", highlight) + value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
@Override
@@ -44,12 +44,12 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return getName(constants, localRegNames, fullyQualifiedNames) + hilight(" = ") + value.toString(constants, localRegNames, fullyQualifiedNames);
return getName(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(" = ", highlight) + value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
public String getName(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String getName(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String ret = "";
/*ret = scope.toString(constants, localRegNames) + ".";
@@ -66,7 +66,7 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign
if (slotName == null) {
return ret + "/*UnknownSlot*/";
}
return ret + hilight(slotName.getName(constants, fullyQualifiedNames));
return ret + hilight(slotName.getName(constants, fullyQualifiedNames), highlight);
}
@Override
@@ -43,12 +43,12 @@ public class SetSuperAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String calee = object.toString(constants, localRegNames, fullyQualifiedNames) + ".";
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String calee = object.toString(highlight, constants, localRegNames, fullyQualifiedNames) + ".";
if (Highlighting.stripHilights(calee).equals("this.")) {
calee = "";
}
return calee + hilight("super.") + propertyName.toString(constants, localRegNames, fullyQualifiedNames) + hilight(" = ") + value.toString(constants, localRegNames, fullyQualifiedNames);
return calee + hilight("super.", highlight) + propertyName.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(" = ", highlight) + value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
@Override
@@ -32,8 +32,8 @@ public class StringAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("\"" + Helper.escapeString(value) + "\"");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("\"" + Helper.escapeString(value) + "\"", highlight);
}
@Override
@@ -31,7 +31,7 @@ public class ThisAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return "this";
}
}
@@ -31,7 +31,7 @@ public class ThrowAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("throw ") + value.toString(constants, localRegNames, fullyQualifiedNames);
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("throw ", highlight) + value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
}
@@ -29,8 +29,8 @@ public class UndefinedAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("undefined");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("undefined", highlight);
}
@Override
@@ -31,7 +31,7 @@ public class UnparsedAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return value;
}
}
@@ -41,13 +41,13 @@ public class WithAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String ret;
ret = hilight("with(") + scope.toString(constants, localRegNames, fullyQualifiedNames) + hilight(")\r\n{\r\n");
ret = hilight("with(", highlight) + scope.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(")\r\n{\r\n", highlight);
/*for (GraphTargetItem ti : items) {
ret += ti.toString(constants, localRegNames, fullyQualifiedNames) + "\r\n";
}
ret += hilight("}");*/
ret += hilight("}", highlight);*/
return ret;
}
@@ -32,8 +32,8 @@ public class WithEndAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("}");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("}", highlight);
}
@Override
@@ -32,7 +32,7 @@ public class WithObjectAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return "";
}
}
@@ -36,13 +36,13 @@ public class XMLAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String ret = "";
for (GraphTargetItem part : parts) {
if (part instanceof StringAVM2Item) {
ret += ((StringAVM2Item) part).value;
} else {
ret += part.toString(constants, localRegNames, fullyQualifiedNames);
ret += part.toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
}
return ret;
@@ -47,7 +47,7 @@ public class DeclarationAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
if (assignment instanceof SetLocalAVM2Item) {
SetLocalAVM2Item lti = (SetLocalAVM2Item) assignment;
String type = "*";
@@ -57,12 +57,12 @@ public class DeclarationAVM2Item extends AVM2Item {
if (lti.value instanceof ConvertAVM2Item) {
type = ((ConvertAVM2Item) lti.value).type;
}
return "var " + hilight(localRegName(localRegNames, lti.regIndex) + ":" + type + " = ") + lti.value.toString(constants, localRegNames, fullyQualifiedNames);
return "var " + hilight(localRegName(localRegNames, lti.regIndex) + ":" + type + " = ", highlight) + lti.value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
if (assignment instanceof SetSlotAVM2Item) {
SetSlotAVM2Item ssti = (SetSlotAVM2Item) assignment;
return "var " + ssti.getName(constants, localRegNames, fullyQualifiedNames) + ":" + type + hilight(" = ") + ssti.value.toString(constants, localRegNames, fullyQualifiedNames);
return "var " + ssti.getName(highlight, constants, localRegNames, fullyQualifiedNames) + ":" + type + hilight(" = ", highlight) + ssti.value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
return "var " + assignment.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames));
return "var " + assignment.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames));
}
}
@@ -32,7 +32,7 @@ public class ExceptionAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return exception.getVarName(constants, fullyQualifiedNames);
}
}
@@ -39,7 +39,7 @@ public class FilterAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return collection.toString(constants, localRegNames, fullyQualifiedNames) + hilight(".(") + expression.toString(constants, localRegNames, fullyQualifiedNames) + hilight(")");
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return collection.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(".(", highlight) + expression.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(")", highlight);
}
}
@@ -67,16 +67,16 @@ public class ForEachInAVM2Item extends LoopItem implements Block {
}
@Override
public String toString(List<Object> localData) {
public String toString(boolean highlight, List<Object> localData) {
String ret = "";
ret += "loop" + loop.id + ":\r\n";
ret += hilight("for each (") + expression.toString(localData) + ")\r\n{\r\n";
ret += hilight("for each (", highlight) + expression.toString(highlight, localData) + ")\r\n{\r\n";
for (GraphTargetItem ti : commands) {
if (!ti.isEmpty()) {
ret += ti.toStringSemicoloned(localData) + "\r\n";
ret += ti.toStringSemicoloned(highlight, localData) + "\r\n";
}
}
ret += hilight("}") + "\r\n";
ret += hilight("}", highlight) + "\r\n";
ret += ":loop" + loop.id;
return ret;
}
@@ -67,16 +67,16 @@ public class ForInAVM2Item extends LoopItem implements Block {
}
@Override
public String toString(List<Object> localData) {
public String toString(boolean highlight, List<Object> localData) {
String ret = "";
ret += "loop" + loop.id + ":\r\n";
ret += hilight("for (") + expression.toString(localData) + hilight(")") + "\r\n{\r\n";
ret += hilight("for (", highlight) + expression.toString(highlight, localData) + hilight(")", highlight) + "\r\n{\r\n";
for (GraphTargetItem ti : commands) {
if (!ti.isEmpty()) {
ret += ti.toStringSemicoloned(localData) + "\r\n";
ret += ti.toStringSemicoloned(highlight, localData) + "\r\n";
}
}
ret += hilight("}") + "\r\n";
ret += hilight("}", highlight) + "\r\n";
ret += ":loop" + loop.id;
return ret;
}
@@ -52,12 +52,12 @@ public class TryAVM2Item extends AVM2Item implements Block {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String ret = "";
ret += "try\r\n{\r\n";
for (GraphTargetItem ti : tryCommands) {
if (!ti.isEmpty()) {
ret += ti.toStringSemicoloned(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "\r\n";
ret += ti.toStringSemicoloned(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "\r\n";
}
}
ret += "}";
@@ -66,7 +66,7 @@ public class TryAVM2Item extends AVM2Item implements Block {
List<GraphTargetItem> commands = catchCommands.get(e);
for (GraphTargetItem ti : commands) {
if (!ti.isEmpty()) {
ret += ti.toStringSemicoloned(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "\r\n";
ret += ti.toStringSemicoloned(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "\r\n";
}
}
ret += "}";
@@ -75,7 +75,7 @@ public class TryAVM2Item extends AVM2Item implements Block {
ret += "\r\nfinally\r\n{\r\n";
for (GraphTargetItem ti : finallyCommands) {
if (!ti.isEmpty()) {
ret += ti.toStringSemicoloned(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "\r\n";
ret += ti.toStringSemicoloned(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "\r\n";
}
}
ret += "}";
@@ -30,22 +30,22 @@ public class AddAVM2Item extends BinaryOpItem {
}
@Override
public String toString(List<Object> localData) {
public String toString(boolean highlight, List<Object> localData) {
if (rightSide.precedence >= precedence) { //string + vs number +
String ret = "";
if (leftSide.precedence > precedence) {
ret += "(" + leftSide.toString(localData) + ")";
ret += "(" + leftSide.toString(highlight, localData) + ")";
} else {
ret += leftSide.toString(localData);
ret += leftSide.toString(highlight, localData);
}
ret += " ";
ret += hilight(operator);
ret += hilight(operator, highlight);
ret += " ";
ret += "(" + rightSide.toString(localData) + ")";
ret += "(" + rightSide.toString(highlight, localData) + ")";
return ret;
} else {
return super.toString(localData);
return super.toString(highlight, localData);
}
}
@@ -36,7 +36,7 @@ public class DeletePropertyAVM2Item extends AVM2Item {
}
@Override
public String toString(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("delete ") + object.toString(constants, localRegNames, fullyQualifiedNames) + "[" + propertyName.toString(constants, localRegNames, fullyQualifiedNames) + "]";
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("delete ", highlight) + object.toString(highlight, constants, localRegNames, fullyQualifiedNames) + "[" + propertyName.toString(highlight, constants, localRegNames, fullyQualifiedNames) + "]";
}
}
@@ -34,22 +34,22 @@ public class SubtractAVM2Item extends BinaryOpItem {
}
@Override
public String toString(List<Object> localData) {
public String toString(boolean highlight, List<Object> localData) {
if (rightSide.precedence >= precedence) { // >= add or subtract too
String ret = "";
if (leftSide.precedence > precedence) {
ret += "(" + leftSide.toString(localData) + ")";
ret += "(" + leftSide.toString(highlight, localData) + ")";
} else {
ret += leftSide.toString(localData);
ret += leftSide.toString(highlight, localData);
}
ret += " ";
ret += hilight(operator);
ret += hilight(operator, highlight);
ret += " ";
ret += "(" + rightSide.toString(localData) + ")";
ret += "(" + rightSide.toString(highlight, localData) + ")";
return ret;
} else {
return super.toString(localData);
return super.toString(highlight, localData);
}
}
}
@@ -114,7 +114,7 @@ public class MethodBody implements Cloneable, Serializable {
}
String s = "";
if (pcode) {
s += code.toASMSource(constants, this, false);
s += code.toASMSource(constants, this, false, hilight);
} else {
if (!Configuration.getConfig("decompile", true)) {
s = "//Decompilation skipped";
@@ -91,7 +91,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
}
if (assignedValue != null) {
valueStr = Highlighting.stripHilights(assignedValue.toString(abc.constants, new HashMap<Integer, String>(), fullyQualifiedNames));
valueStr = assignedValue.toString(false, abc.constants, new HashMap<Integer, String>(), fullyQualifiedNames);
}
return valueStr;
}
@@ -394,8 +394,8 @@ public class Action implements GraphSourceItem {
* @param path
* @return ASM source as String
*/
public static String actionsToString(List<DisassemblyListener> listeners, long address, List<Action> list, List<Long> importantOffsets, int version, boolean hex, long swfPos, String path) {
return actionsToString(listeners, address, list, importantOffsets, new ArrayList<String>(), version, hex, swfPos, path);
public static String actionsToString(List<DisassemblyListener> listeners, long address, List<Action> list, List<Long> importantOffsets, int version, boolean hex, boolean highlight, long swfPos, String path) {
return actionsToString(listeners, address, list, importantOffsets, new ArrayList<String>(), version, hex, highlight, swfPos, path);
}
/**
@@ -412,7 +412,7 @@ public class Action implements GraphSourceItem {
* @param path
* @return ASM source as String
*/
private static String actionsToString(List<DisassemblyListener> listeners, long address, List<Action> list, List<Long> importantOffsets, List<String> constantPool, int version, boolean hex, long swfPos, String path) {
private static String actionsToString(List<DisassemblyListener> listeners, long address, List<Action> list, List<Long> importantOffsets, List<String> constantPool, int version, boolean hex, boolean highlight, long swfPos, String path) {
long offset;
if (importantOffsets == null) {
//setActionsAddresses(list, 0, version);
@@ -493,7 +493,7 @@ public class Action implements GraphSourceItem {
ret.append("\r\n");
lastPush = false;
}
ret.append(Highlighting.hilighOffset("", offset));
ret.append(highlight ? Highlighting.hilighOffset("", offset) : "");
ret.append(a.replaceWith.getASMSource(list, importantOffsets, constantPool, version, hex));
ret.append("\r\n");
} else if (a.isIgnored()) {
@@ -533,7 +533,7 @@ public class Action implements GraphSourceItem {
add = "";
if ((a instanceof ActionPush) && lastPush) {
ret.append(" ");
ret.append(((ActionPush) a).paramsToStringReplaced(list, importantOffsets, constantPool, version, hex));
ret.append(((ActionPush) a).paramsToStringReplaced(list, importantOffsets, constantPool, version, hex, highlight));
} else {
if (lastPush) {
ret.append("\r\n");
@@ -541,7 +541,7 @@ public class Action implements GraphSourceItem {
}
ret.append(Highlighting.hilighOffset("", offset));
ret.append(highlight ? Highlighting.hilighOffset("", offset) : "");
if (a instanceof ActionIf) {
ActionIf aif = (ActionIf) a;
@@ -565,7 +565,7 @@ public class Action implements GraphSourceItem {
}
}
} else {
ret.append(a.getASMSourceReplaced(list, importantOffsets, constantPool, version, hex));
ret.append(a.getASMSourceReplaced(list, importantOffsets, constantPool, version, hex, highlight));
}
ret.append(a.isIgnored() ? "; ignored" : "");
ret.append(add);
@@ -715,7 +715,7 @@ public class Action implements GraphSourceItem {
* @param path
* @return String with Source code
*/
public static String actionsToSource(final List<Action> actions, final int version, final String path) {
public static String actionsToSource(final List<Action> actions, final int version, final String path, final boolean highlight) {
int timeout = Configuration.getConfig("decompilationTimeoutSingleMethod", 60);
try {
return Helper.timedCall(new Callable<String>() {
@@ -726,7 +726,7 @@ public class Action implements GraphSourceItem {
List<GraphTargetItem> tree = actionsToTree(new HashMap<Integer, String>(), new HashMap<String, GraphTargetItem>(), new HashMap<String, GraphTargetItem>(), actions, version, staticOperation, path);
return Graph.graphToString(tree);
return Graph.graphToString(tree, highlight);
}
}, timeout, TimeUnit.SECONDS);
} catch (TimeoutException ex) {
@@ -1198,7 +1198,7 @@ public class Action implements GraphSourceItem {
}
String s = null;
try {
s = Highlighting.stripHilights(Action.actionsToString(new ArrayList<DisassemblyListener>(), address, ret, null, version, false, swfPos, path));
s = Action.actionsToString(new ArrayList<DisassemblyListener>(), address, ret, null, version, false, false, swfPos, path);
ret = ASMParser.parse(address, swfPos, true, new StringReader(s), SWF.DEFAULT_VERSION);
} catch (Exception ex) {
Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "parsing error", ex);
@@ -1226,7 +1226,7 @@ public class Action implements GraphSourceItem {
}
}
public String getASMSourceReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, boolean hex) {
public String getASMSourceReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, boolean hex, boolean highlight) {
return getASMSource(container, knownAddreses, constantPool, version, hex);
}
@@ -35,12 +35,11 @@ public abstract class ActionItem extends GraphTargetItem implements Serializable
super(instruction, precedence);
}
public abstract String toString(ConstantPool constants);
public abstract String toString(boolean highlight, ConstantPool constants);
@Override
public String toString() {
public String toString(boolean highlight) {
ConstantPool c = null;
return toString(c);
return toString(highlight, c);
}
protected boolean isEmptyString(GraphTargetItem target) {
@@ -55,26 +54,26 @@ public abstract class ActionItem extends GraphTargetItem implements Serializable
return false;
}
protected String stripQuotes(GraphTargetItem target, ConstantPool constants) {
protected String stripQuotes(GraphTargetItem target, ConstantPool constants, boolean highlight) {
if (target instanceof DirectValueActionItem) {
if (((DirectValueActionItem) target).value instanceof String) {
return (String) ((DirectValueActionItem) target).hilight((String) ((DirectValueActionItem) target).value);
return (String) ((DirectValueActionItem) target).hilight((String) ((DirectValueActionItem) target).value, highlight);
}
}
if (target == null) {
return "";
} else {
return target.toString(constants);
return target.toString(highlight, constants);
}
}
@Override
public String toString(List<Object> localData) {
public String toString(boolean highlight, List<Object> localData) {
if (localData.isEmpty()) {
ConstantPool c = null;
return toString(c);
return toString(highlight, c);
}
return toString((ConstantPool) localData.get(0));
return toString(highlight, (ConstantPool) localData.get(0));
}
protected List<GraphSourceItem> toSourceCall(List<Object> localData, SourceGenerator gen, List<GraphTargetItem> list) {
@@ -30,8 +30,8 @@ public class AsciiToCharActionItem extends ActionItem {
}
@Override
public String toString(ConstantPool constants) {
return hilight("chr(") + value.toString(constants) + hilight(")");
public String toString(boolean highlight, ConstantPool constants) {
return hilight("chr(", highlight) + value.toString(highlight, constants) + hilight(")", highlight);
}
@Override
@@ -30,8 +30,8 @@ public class CallActionItem extends ActionItem {
}
@Override
public String toString(ConstantPool constants) {
return hilight("call(") + stripQuotes(value, constants) + hilight(")");
public String toString(boolean highlight, ConstantPool constants) {
return hilight("call(", highlight) + stripQuotes(value, constants, highlight) + hilight(")", highlight);
}
@Override
@@ -40,15 +40,15 @@ public class CallFunctionActionItem extends ActionItem {
}
@Override
public String toString(ConstantPool constants) {
public String toString(boolean highlight, ConstantPool constants) {
String paramStr = "";
for (int t = 0; t < arguments.size(); t++) {
if (t > 0) {
paramStr += hilight(",");
paramStr += hilight(",", highlight);
}
paramStr += arguments.get(t).toStringNL(constants);
paramStr += arguments.get(t).toStringNL(highlight, constants);
}
return stripQuotes(functionName, constants) + hilight("(") + paramStr + hilight(")");
return stripQuotes(functionName, constants, highlight) + hilight("(", highlight) + paramStr + hilight(")", highlight);
}
@Override
@@ -46,13 +46,13 @@ public class CallMethodActionItem extends ActionItem {
}
@Override
public String toString(ConstantPool constants) {
public String toString(boolean highlight, ConstantPool constants) {
String paramStr = "";
for (int t = 0; t < arguments.size(); t++) {
if (t > 0) {
paramStr += hilight(",");
paramStr += hilight(",", highlight);
}
paramStr += arguments.get(t).toStringNL(constants);
paramStr += arguments.get(t).toStringNL(highlight, constants);
}
boolean blankMethod = false;
if (methodName instanceof DirectValueActionItem) {
@@ -66,13 +66,13 @@ public class CallMethodActionItem extends ActionItem {
}
}
if (blankMethod) {
return scriptObject.toString(constants) + hilight("(") + paramStr + hilight(")");
return scriptObject.toString(highlight, constants) + hilight("(", highlight) + paramStr + hilight(")", highlight);
}
String soStr = scriptObject.toString(constants);
String soStr = scriptObject.toString(highlight, constants);
if (scriptObject.precedence > this.precedence) {
soStr = "(" + soStr + ")";
}
return soStr + hilight(".") + stripQuotes(methodName, constants) + hilight("(") + paramStr + hilight(")");
return soStr + hilight(".", highlight) + stripQuotes(methodName, constants, highlight) + hilight("(", highlight) + paramStr + hilight(")", highlight);
}
@Override
@@ -44,8 +44,8 @@ public class CastOpActionItem extends ActionItem {
}
@Override
public String toString(ConstantPool constants) {
return hilight("(") + stripQuotes(constructor, constants) + hilight(")") + object.toString(Helper.toList(constants));
public String toString(boolean highlight, ConstantPool constants) {
return hilight("(", highlight) + stripQuotes(constructor, constants, highlight) + hilight(")", highlight) + object.toString(highlight, Helper.toList(constants));
}
@Override
@@ -30,8 +30,8 @@ public class CharToAsciiActionItem extends ActionItem {
}
@Override
public String toString(ConstantPool constants) {
return hilight("ord(") + value.toString(constants) + hilight(")");
public String toString(boolean highlight, ConstantPool constants) {
return hilight("ord(", highlight) + value.toString(highlight, constants) + hilight(")", highlight);
}
@Override
@@ -46,8 +46,8 @@ public class CloneSpriteActionItem extends ActionItem {
}
@Override
public String toString(ConstantPool constants) {
return hilight("duplicateMovieClip(") + target.toString(constants) + hilight(",") + source.toString(constants) + hilight(",") + depth.toString(constants) + hilight(")");
public String toString(boolean highlight, ConstantPool constants) {
return hilight("duplicateMovieClip(", highlight) + target.toString(highlight, constants) + hilight(",", highlight) + source.toString(highlight, constants) + hilight(",", highlight) + depth.toString(highlight, constants) + hilight(")", highlight);
}
@Override
@@ -41,8 +41,8 @@ public class DecrementActionItem extends ActionItem {
}
@Override
public String toString(ConstantPool constants) {
return object.toString(constants) + hilight(" - 1");
public String toString(boolean highlight, ConstantPool constants) {
return object.toString(highlight, constants) + hilight(" - 1", highlight);
}
@Override
@@ -67,11 +67,11 @@ public class DefineLocalActionItem extends ActionItem implements SetTypeActionIt
}
@Override
public String toString(ConstantPool constants) {
public String toString(boolean highlight, ConstantPool constants) {
if (value == null) {
return hilight("var ") + stripQuotes(name, constants);
return hilight("var ", highlight) + stripQuotes(name, constants, highlight);
}
return hilight("var ") + stripQuotes(name, constants) + hilight(" = ") + value.toString(constants);
return hilight("var ", highlight) + stripQuotes(name, constants, highlight) + hilight(" = ", highlight) + value.toString(highlight, constants);
}
@Override
@@ -32,7 +32,7 @@ public class DefineRegisterActionItem extends ActionItem {
}
@Override
public String toString(ConstantPool constants) {
public String toString(boolean highlight, ConstantPool constants) {
return "var " + identifier;
}
@@ -43,11 +43,11 @@ public class DeleteActionItem extends ActionItem {
}
@Override
public String toString(ConstantPool constants) {
public String toString(boolean highlight, ConstantPool constants) {
if (object == null) {
return hilight("delete ") + propertyName.toString(constants);
return hilight("delete ", highlight) + propertyName.toString(highlight, constants);
}
return hilight("delete ") + object.toString(constants) + "." + stripQuotes(propertyName, constants);
return hilight("delete ", highlight) + object.toString(highlight, constants) + "." + stripQuotes(propertyName, constants, highlight);
}
@Override
@@ -85,24 +85,24 @@ public class DirectValueActionItem extends ActionItem {
}
@Override
public String toStringNoQuotes(List<Object> localData) {
public String toStringNoQuotes(boolean highlight, List<Object> localData) {
if (value instanceof Double) {
if (Double.compare((double) (Double) value, 0) == 0) {
return hilight("0");
return hilight("0", highlight);
}
}
if (value instanceof Float) {
if (Float.compare((float) (Float) value, 0) == 0) {
return hilight("0");
return hilight("0", highlight);
}
}
if (value instanceof String) {
return hilight((String) value);
return hilight((String) value, highlight);
}
if (value instanceof ConstantIndex) {
return hilight(this.constants.get(((ConstantIndex) value).index));
return hilight(this.constants.get(((ConstantIndex) value).index), highlight);
}
return hilight(value.toString());
return hilight(value.toString(), highlight);
}
public String toStringNoH(ConstantPool constants) {
@@ -126,27 +126,27 @@ public class DirectValueActionItem extends ActionItem {
}
@Override
public String toString(ConstantPool constants) {
public String toString(boolean highlight, ConstantPool constants) {
if (value instanceof Double) {
if (Double.compare((double) (Double) value, 0) == 0) {
return hilight("0");
return hilight("0", highlight);
}
}
if (value instanceof Float) {
if (Float.compare((float) (Float) value, 0) == 0) {
return hilight("0");
return hilight("0", highlight);
}
}
if (value instanceof String) {
return hilight("\"" + Helper.escapeString((String) value) + "\"");
return hilight("\"" + Helper.escapeString((String) value) + "\"", highlight);
}
if (value instanceof ConstantIndex) {
return hilight("\"" + Helper.escapeString(this.constants.get(((ConstantIndex) value).index)) + "\"");
return hilight("\"" + Helper.escapeString(this.constants.get(((ConstantIndex) value).index)) + "\"", highlight);
}
if (value instanceof RegisterNumber) {
return hilight(((RegisterNumber) value).translate());
return hilight(((RegisterNumber) value).translate(), highlight);
}
return hilight(value.toString());
return hilight(value.toString(), highlight);
}
@Override
@@ -39,8 +39,8 @@ public class EnumerateActionItem extends ActionItem {
}
@Override
public String toString(ConstantPool constants) {
return "enumerate " + object.toString(Helper.toList(constants));
public String toString(boolean highlight, ConstantPool constants) {
return "enumerate " + object.toString(highlight, Helper.toList(constants));
}
@Override

Some files were not shown because too many files have changed in this diff Show More