using stringbuilder for generating the AS source

This commit is contained in:
Honfika
2013-10-12 21:38:15 +02:00
parent 3f34d66f47
commit 0c9ea12f03
195 changed files with 1522 additions and 841 deletions

View File

@@ -72,6 +72,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter;
import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphPart;
@@ -705,17 +706,15 @@ public class AVM2Code implements Serializable {
return s.toString();
}
public String toString(boolean highlight, ConstantPool constants) {
StringBuilder s = new StringBuilder();
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
int i = 0;
for (AVM2Instruction instruction : code) {
s.append(Helper.formatAddress(i));
s.append(" ");
s.append(instruction.toString(highlight, constants, new ArrayList<String>()));
s.append("\r\n");
writer.appendNoHilight(Helper.formatAddress(i));
writer.appendNoHilight(" ");
instruction.toString(writer, constants, new ArrayList<String>()).appendNewLine();
i++;
}
return s.toString();
return writer;
}
public String toASMSource(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, boolean hex, boolean highlight) {

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import java.util.List;
/**
@@ -32,8 +33,8 @@ public class CodeStats {
public boolean has_activation = false;
public InstructionStats[] instructionStats;
public String toString(boolean highlight, ABC abc, List<String> fullyQualifiedNames) {
String ret = "Stats: maxstack=" + maxstack + ", maxscope=" + maxscope + ", maxlocal=" + maxlocal + "\r\n";
public HilightedTextWriter toString(HilightedTextWriter writer, ABC abc, List<String> fullyQualifiedNames) {
writer.appendNoHilight("Stats: maxstack=" + maxstack + ", maxscope=" + maxscope + ", maxlocal=" + maxlocal).appendNewLine();
int i = 0;
int ms = 0;
for (InstructionStats stats : instructionStats) {
@@ -41,10 +42,10 @@ public class CodeStats {
if (stats.stackpos > ms) {
ms = stats.stackpos;
}
ret += "" + i + ":" + stats.stackpos + (deltastack >= 0 ? "+" + deltastack : deltastack) + "," + stats.scopepos + " " + stats.ins.toString(highlight, abc.constants, fullyQualifiedNames) + "\r\n";
writer.appendNoHilight(i + ":" + stats.stackpos + (deltastack >= 0 ? "+" + deltastack : deltastack) + "," + stats.scopepos + " " + stats.ins.toString(writer, abc.constants, fullyQualifiedNames)).appendNewLine();
i++;
}
return ret;
return writer;
}
public CodeStats(AVM2Code code) {

View File

@@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ReturnVoidIns;
import com.jpexs.decompiler.flash.abc.avm2.instructions.other.ThrowIns;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSource;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -263,10 +264,10 @@ public class AVM2Instruction implements Serializable, GraphSourceItem {
return ignored;
}
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;
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, List<String> fullyQualifiedNames) {
writer.appendNoHilight(Helper.formatAddress(offset) + " " + Helper.padSpaceRight(Helper.byteArrToString(getBytes()), 30) + definition.instructionName);
writer.appendNoHilight(getParams(constants, fullyQualifiedNames) + getComment());
return writer;
}
public String toStringNoAddress(ConstantPool constants, List<String> fullyQualifiedNames) {

View File

@@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import com.jpexs.decompiler.flash.abc.avm2.model.UnparsedAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
@@ -39,7 +40,9 @@ 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, MethodBody body, 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(false, Helper.toList(constants, localRegNames, fullyQualifiedNames));
HilightedTextWriter writer = new HilightedTextWriter(false);
stack.pop().toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
String baseType = writer.toString();
stack.push(new UnparsedAVM2Item(ins, "new " + abc.constants.constant_multiname[abc.instance_info[clsIndex].name_index].getName(constants, fullyQualifiedNames) + ".class extends " + baseType));
}

View File

@@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.SetSuperAVM2Item;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.abc.types.MethodInfo;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -52,7 +53,9 @@ public class SetSuperIns extends InstructionDefinition implements SetTypeIns {
public String getObject(Stack<AVM2Item> stack, ABC abc, AVM2Instruction ins, List<AVM2Item> output, 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(false, abc.constants, localRegNames, fullyQualifiedNames);
HilightedTextWriter writer = new HilightedTextWriter(false);
stack.get(1 + resolvedCount(abc.constants, multinameIndex)).toString(writer, abc.constants, localRegNames, fullyQualifiedNames);
String obj = writer.toString();
return obj + ".super." + multiname;
}

View File

@@ -18,8 +18,10 @@ 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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import static com.jpexs.decompiler.graph.GraphTargetItem.PRECEDENCE_PRIMARY;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
import java.util.List;
@@ -35,18 +37,20 @@ public abstract class AVM2Item extends GraphTargetItem {
@Override
@SuppressWarnings("unchecked")
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 HilightedTextWriter toString(HilightedTextWriter writer, List<Object> localData) {
return toString(writer, (ConstantPool) localData.get(0), (HashMap<Integer, String>) localData.get(1), (List<String>) localData.get(2));
}
public abstract String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames);
public abstract HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames);
public String toStringNoH(ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return toString(false, constants, localRegNames, fullyQualifiedNames);
HilightedTextWriter writer = new HilightedTextWriter(false);
toString(writer, constants, localRegNames, fullyQualifiedNames);
return writer.toString();
}
public String toStringSemicoloned(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return toString(highlight, constants, localRegNames, fullyQualifiedNames) + (needsSemicolon() ? ";" : "");
public String toStringSemicoloned(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return toString(writer, constants, localRegNames, fullyQualifiedNames) + (needsSemicolon() ? ";" : "");
}
@Override
@@ -54,29 +58,45 @@ public abstract class AVM2Item extends GraphTargetItem {
return true;
}
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 = hilight("(", highlight) + obStr + hilight(")", highlight);
}
protected HilightedTextWriter formatProperty(HilightedTextWriter writer, ConstantPool constants, GraphTargetItem object, GraphTargetItem propertyName, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
boolean empty = false;
if (object instanceof LocalRegAVM2Item) {
if (((LocalRegAVM2Item) object).computedValue != null) {
if (((LocalRegAVM2Item) object).computedValue.getThroughNotCompilable() instanceof FindPropertyAVM2Item) {
obStr = "";
empty = true;
}
}
}
if (obStr.equals("")) {
return propertyName.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames));
if (!empty) {
if (object.precedence > PRECEDENCE_PRIMARY) {
hilight("(", writer);
object.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
hilight(")", writer);
empty = false;
} else {
int writerLength = writer.getLength();
object.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
if (writerLength == writer.getLength()) {
empty = true;
}
}
}
if (empty) {
return propertyName.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
}
if (propertyName instanceof FullMultinameAVM2Item) {
if (((FullMultinameAVM2Item) propertyName).name != null) {
return obStr + propertyName.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames));
return propertyName.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
} else {
return obStr + hilight(".", highlight) + propertyName.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames));
hilight(".", writer);
return propertyName.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
}
} else {
return obStr + hilight("[", highlight) + propertyName.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight("]", highlight);
hilight("[", writer);
propertyName.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
return hilight("]", writer);
}
}

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
@@ -38,7 +39,9 @@ public class AlchemyLoadAVM2Item extends AVM2Item {
}
@Override
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);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight("op_" + name + "(", writer);
ofs.toString(writer, constants, localRegNames, fullyQualifiedNames);
return hilight(") /*Alchemy*/", writer);
}
}

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
@@ -37,7 +38,9 @@ public class AlchemySignExtendAVM2Item extends AVM2Item {
}
@Override
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);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight("op_" + name + "(", writer);
value.toString(writer, constants, localRegNames, fullyQualifiedNames);
return hilight(") /*Alchemy*/", writer);
}
}

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
@@ -39,7 +40,11 @@ public class AlchemyStoreAVM2Item extends AVM2Item {
}
@Override
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);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight("op_" + name + "(", writer);
ofs.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight(",", writer);
value.toString(writer, constants, localRegNames, fullyQualifiedNames);
return hilight(") /*Alchemy*/", writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
@@ -35,24 +36,23 @@ public class ApplyTypeAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
StringBuilder ret = new StringBuilder();
ret.append(object.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)));
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
object.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
if (!params.isEmpty()) {
ret.append(hilight(".<", highlight));
hilight(".<", writer);
for (int i = 0; i < params.size(); i++) {
if (i > 0) {
ret.append(hilight(",", highlight));
hilight(",", writer);
}
GraphTargetItem p = params.get(i);
if (p instanceof NullAVM2Item) {
ret.append(hilight("*", highlight));
hilight("*", writer);
} else {
ret.append(p.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)));
p.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
}
}
ret.append(hilight(">", highlight));
hilight(">", writer);
}
return ret.toString();
return writer;
}
}

View File

@@ -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.HilightedTextWriter;
import java.util.HashMap;
import java.util.List;
@@ -31,8 +32,8 @@ public class BooleanAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight(value ? "true" : "false", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight(value ? "true" : "false", writer);
}
@Override

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -36,25 +37,28 @@ public class CallAVM2Item extends AVM2Item {
}
@Override
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(",", highlight);
}
args = args + arguments.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
/*String recPart = ""; receiver.toString(constants, localRegNames) + hilight(".", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
/*String recPart = ""; receiver.toString(constants, localRegNames) + hilight(".", writer);
if (receiver instanceof NewActivationAVM2Item) {
recPart = "";
}
if (receiver instanceof ThisAVM2Item) {
recPart = "";
}*/
String fstr = function.toString(highlight, constants, localRegNames, fullyQualifiedNames);
if (function.precedence > precedence) {
fstr = hilight("(", highlight) + fstr + hilight(")", highlight);
hilight("(", writer);
function.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight(")", writer);
} else {
function.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
return fstr + hilight("(", highlight) + args + hilight(")", highlight);
hilight("(", writer);
for (int a = 0; a < arguments.size(); a++) {
if (a > 0) {
hilight(",", writer);
}
arguments.get(a).toString(writer, constants, localRegNames, fullyQualifiedNames);
}
return hilight(")", writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
@@ -37,14 +38,17 @@ public class CallMethodAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String args = "";
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
receiver.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
hilight(".", writer);
hilight(methodName, writer);
hilight("(", writer);
for (int a = 0; a < arguments.size(); a++) {
if (a > 0) {
args = args + hilight(",", highlight);
hilight(",", writer);
}
args = args + arguments.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames);
arguments.get(a).toString(writer, constants, localRegNames, fullyQualifiedNames);
}
return receiver.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight(".", highlight) + methodName + hilight("(", highlight) + args + hilight(")", highlight);
return hilight(")", writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -38,14 +39,15 @@ public class CallPropertyAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String args = "";
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
formatProperty(writer, constants, receiver, propertyName, localRegNames, fullyQualifiedNames);
hilight("(", writer);
for (int a = 0; a < arguments.size(); a++) {
if (a > 0) {
args = args + hilight(",", highlight);
hilight(",", writer);
}
args = args + arguments.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames);
arguments.get(a).toString(writer, constants, localRegNames, fullyQualifiedNames);
}
return formatProperty(highlight, constants, receiver, propertyName, localRegNames, fullyQualifiedNames) + hilight("(", highlight) + args + hilight(")", highlight);
return hilight(")", writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
@@ -37,14 +38,17 @@ public class CallStaticAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String args = "";
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
receiver.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
hilight(".", writer);
hilight(methodName, writer);
hilight("(", writer);
for (int a = 0; a < arguments.size(); a++) {
if (a > 0) {
args = args + hilight(",", highlight);
hilight(",", writer);
}
args = args + arguments.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames);
arguments.get(a).toString(writer, constants, localRegNames, fullyQualifiedNames);
}
return receiver.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight(".", highlight) + methodName + hilight("(", highlight) + args + hilight(")", highlight);
return hilight(")", writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
@@ -39,18 +40,21 @@ public class CallSuperAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
if (!receiver.toString(false, constants, localRegNames, fullyQualifiedNames).equals("this.")) {
receiver.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight(".", writer);
}
hilight("super.", writer);
multiname.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight("(", writer);
String args = "";
for (int a = 0; a < arguments.size(); a++) {
if (a > 0) {
args = args + hilight(",", highlight);
hilight(",", writer);
}
args = args + arguments.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames, highlight);
arguments.get(a).toString(writer, constants, localRegNames, fullyQualifiedNames);
}
String calee = receiver.toString(highlight, constants, localRegNames, fullyQualifiedNames, highlight) + hilight(".", highlight);
if (Highlighting.stripHilights(calee).equals("this.")) {
calee = "";
}
return calee + hilight("super.", highlight) + multiname.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight("(", highlight) + args + hilight(")", highlight);
return hilight(")", writer);
}
}

View File

@@ -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.types.Multiname;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import java.util.HashMap;
import java.util.List;
@@ -31,7 +32,7 @@ public class ClassAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight(className.getName(constants, fullyQualifiedNames), highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight(className.getName(constants, fullyQualifiedNames), writer);
}
}

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.ecma.Null;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -36,9 +37,9 @@ public class CoerceAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
//return hilight("("+type+")", highlight)+
return value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
return value.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
@Override

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -34,18 +35,20 @@ public class ConstructAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String argStr = "";
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
if (object instanceof NewFunctionAVM2Item) {
hilight("new ", writer);
return object.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
hilight("new ", writer);
object.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight("(", writer);
for (int a = 0; a < args.size(); a++) {
if (a > 0) {
argStr = argStr + hilight(",", highlight);
hilight(",", writer);
}
argStr = argStr + args.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames);
args.get(a).toString(writer, constants, localRegNames, fullyQualifiedNames);
}
if (object instanceof NewFunctionAVM2Item) {
return hilight("new ", highlight) + object.toString(highlight, constants, localRegNames, fullyQualifiedNames);
}
String obStr = object.toString(highlight, constants, localRegNames, fullyQualifiedNames);
return hilight("new ", highlight) + obStr + hilight("(", highlight) + argStr + hilight(")", highlight);
return hilight(")", writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -36,19 +37,21 @@ public class ConstructPropAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String argStr = "";
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight("new ", writer);
int idx = writer.getLength();
object.toString(writer, constants, localRegNames, fullyQualifiedNames);
if (idx > writer.getLength()) {
hilight(".", writer);
}
propertyName.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight("(", writer);
for (int a = 0; a < args.size(); a++) {
if (a > 0) {
argStr = argStr + hilight(",", highlight);
hilight(",", writer);
}
argStr = argStr + args.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames);
args.get(a).toString(writer, constants, localRegNames, fullyQualifiedNames);
}
String objstr = object.toString(highlight, constants, localRegNames, fullyQualifiedNames);
if (!objstr.equals("")) {
objstr += hilight(".", highlight);
}
return hilight("new ", highlight) + objstr + propertyName.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight("(", highlight) + argStr + hilight(")", highlight);
return hilight(")", writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
@@ -35,19 +36,18 @@ public class ConstructSuperAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String argStr = "";
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
if (!object.toString(false, constants, localRegNames, fullyQualifiedNames).equals("this.")) {
object.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight(".", writer);
}
hilight("super(", writer);
for (int a = 0; a < args.size(); a++) {
if (a > 0) {
argStr = argStr + hilight(",", highlight);
hilight(",", writer);
}
argStr = argStr + args.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames);
args.get(a).toString(writer, constants, localRegNames, fullyQualifiedNames);
}
String calee = object.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(".", highlight);
if (Highlighting.stripHilights(calee).equals("this.")) {
calee = "";
}
return calee + hilight("super(", highlight) + argStr + hilight(")", highlight);
return hilight(")", writer);
}
}

View File

@@ -19,6 +19,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.ecma.EcmaScript;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -35,8 +36,8 @@ public class ConvertAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return value.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
@Override

View File

@@ -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.HilightedTextWriter;
import java.util.HashMap;
import java.util.List;
@@ -31,7 +32,8 @@ public class DecLocalAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight(localRegName(localRegNames, regIndex), highlight) + hilight("--", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight(localRegName(localRegNames, regIndex), writer);
return hilight("--", writer);
}
}

View File

@@ -19,6 +19,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.ecma.EcmaScript;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -31,8 +32,9 @@ public class DecrementAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return value.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight("-1", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
value.toString(writer, constants, localRegNames, fullyQualifiedNames);
return hilight("-1", writer);
}
@Override

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
@@ -37,7 +38,8 @@ public class DefaultXMLNamespace extends AVM2Item {
}
@Override
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));
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight("default xml namespace = ", writer);
return ns.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
@@ -35,7 +36,9 @@ public class EscapeXAttrAVM2Item extends AVM2Item {
}
@Override
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);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight("{", writer);
value.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
return hilight("}", writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
@@ -37,7 +38,9 @@ public class EscapeXElemAVM2Item extends AVM2Item {
}
@Override
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);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight("{", writer);
expression.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
return hilight("}", writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
@@ -37,7 +38,7 @@ public class FilteredCheckAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return object.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames));
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return object.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
}
}

View File

@@ -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.HilightedTextWriter;
import java.util.HashMap;
import java.util.List;
@@ -31,7 +32,7 @@ public class FindPropertyAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return "";
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return writer;
}
}

View File

@@ -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.HilightedTextWriter;
import java.util.HashMap;
import java.util.List;
@@ -31,8 +32,8 @@ public class FloatValueAVM2Item extends NumberValueAVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("" + value, highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("" + value, writer);
}
@Override

View File

@@ -19,6 +19,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.abc.types.Namespace;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -74,22 +75,24 @@ public class FullMultinameAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String ret = "";
if (name != null) {
ret = hilight("[", highlight) + name.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight("]", highlight);
} else {
ret = hilight(constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames), highlight);
}
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
if (namespace != null) {
ret = namespace.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight("::", highlight) + ret;
namespace.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight("::", writer);
} else {
/*Namespace ns = constants.constant_multiname[multinameIndex].getNamespace(constants);
if ((ns != null)&&(ns.name_index!=0)) {
ret = hilight(ns.getName(constants) + "::")+ret;
}*/
}
return ret;
if (name != null) {
hilight("[", writer);
name.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight("]", writer);
} else {
hilight(constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames), writer);
}
return writer;
}
public boolean compareSame(FullMultinameAVM2Item other) {

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -34,7 +35,9 @@ public class GetDescendantsAVM2Item extends AVM2Item {
}
@Override
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);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
object.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight("..", writer);
return multiname.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
}

View File

@@ -19,6 +19,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.abc.types.Multiname;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import java.util.HashMap;
import java.util.List;
@@ -32,7 +33,7 @@ public class GetLexAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight(propertyName.getName(constants, fullyQualifiedNames), highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight(propertyName.getName(constants, fullyQualifiedNames), writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -34,7 +35,7 @@ public class GetPropertyAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return formatProperty(highlight, constants, object, propertyName, localRegNames, fullyQualifiedNames);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return formatProperty(writer, constants, object, propertyName, localRegNames, fullyQualifiedNames);
}
}

View File

@@ -19,6 +19,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.abc.types.Multiname;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -35,10 +36,10 @@ public class GetSlotAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
if (slotName == null) {
return hilight("/*UnknownSlot*/", highlight);
return hilight("/*UnknownSlot*/", writer);
}
return hilight(slotName.getName(constants, fullyQualifiedNames), highlight);
return hilight(slotName.getName(constants, fullyQualifiedNames), writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
@@ -35,11 +36,12 @@ public class GetSuperAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String calee = object.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(".", highlight);
if (Highlighting.stripHilights(calee).equals("this.")) {
calee = "";
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
if (!object.toString(false, constants, localRegNames, fullyQualifiedNames).equals("this.")) {
object.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight(".", writer);
}
return calee + hilight("super.", highlight) + propertyName.toString(highlight, constants, localRegNames, fullyQualifiedNames);
hilight("super.", writer);
return propertyName.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
@@ -39,7 +40,9 @@ public class HasNextAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return collection.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight(" hasNext ", highlight) + object.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames));
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
collection.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
hilight(" hasNext ", writer);
return object.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -34,7 +35,9 @@ public class InAVM2Item extends AVM2Item {
}
@Override
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);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
object.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight(" in ", writer);
return collection.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
}

View File

@@ -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.HilightedTextWriter;
import java.util.HashMap;
import java.util.List;
@@ -31,7 +32,8 @@ public class IncLocalAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight(localRegName(localRegNames, regIndex), highlight) + hilight("++", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight(localRegName(localRegNames, regIndex), writer);
return hilight("++", writer);
}
}

View File

@@ -19,6 +19,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.ecma.EcmaScript;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -31,8 +32,9 @@ public class IncrementAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return value.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight("+1", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
value.toString(writer, constants, localRegNames, fullyQualifiedNames);
return hilight("+1", writer);
}
@Override

View File

@@ -19,6 +19,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.abc.avm2.model.clauses.AssignmentAVM2Item;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -37,8 +38,10 @@ public class InitPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, A
}
@Override
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);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
formatProperty(writer, constants, object, propertyName, localRegNames, fullyQualifiedNames);
hilight(" = ", writer);
return value.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
@Override

View File

@@ -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.HilightedTextWriter;
import java.util.HashMap;
import java.util.List;
@@ -31,8 +32,8 @@ public class IntegerValueAVM2Item extends NumberValueAVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("" + value, highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("" + value, writer);
}
@Override

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.FilterAVM2Item;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
@@ -49,11 +50,11 @@ public class LocalRegAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
if (computedValue instanceof FilterAVM2Item) {
return computedValue.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames));
return computedValue.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
}
return hilight(localRegName(localRegNames, regIndex), highlight);
return hilight(localRegName(localRegNames, regIndex), writer);
}
@Override

View File

@@ -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.HilightedTextWriter;
import java.util.HashMap;
import java.util.List;
@@ -31,10 +32,10 @@ public class NameSpaceAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
if (namespaceIndex == 0) {
return hilight("*", highlight);
return hilight("*", writer);
}
return hilight(constants.constant_namespace[namespaceIndex].toString(constants), highlight);
return hilight(constants.constant_namespace[namespaceIndex].toString(constants), writer);
}
}

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.TernarOpItem;
import java.util.HashMap;
@@ -34,11 +35,16 @@ public class NameValuePair extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String valueStr = value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
name.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight(":", writer);
if (value instanceof TernarOpItem) { //Ternar operator contains ":"
valueStr = hilight("(", highlight) + valueStr + hilight(")", highlight);
hilight("(", writer);
value.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight(")", writer);
} else {
value.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
return name.toString(highlight, constants, localRegNames, fullyQualifiedNames) + ":" + valueStr;
return writer;
}
}

View File

@@ -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.HilightedTextWriter;
import java.util.HashMap;
import java.util.List;
@@ -28,7 +29,7 @@ public class NanAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("NaN", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("NaN", writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -31,7 +32,7 @@ public class NewActivationAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("newactivation()", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("newactivation()", writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -32,14 +33,14 @@ public class NewArrayAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String args = "";
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight("[", writer);
for (int a = 0; a < values.size(); a++) {
if (a > 0) {
args = args + hilight(",", highlight);
hilight(",", writer);
}
args = args + values.get(a).toString(highlight, constants, localRegNames, fullyQualifiedNames);
values.get(a).toString(writer, constants, localRegNames, fullyQualifiedNames);
}
return hilight("[", highlight) + args + hilight("]", highlight);
return hilight("]", writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
import com.jpexs.decompiler.graph.Graph;
import java.util.HashMap;
@@ -41,15 +42,18 @@ public class NewFunctionAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String ret = hilight("function" + (!functionName.equals("") ? " " + functionName : ""), highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight("function" + (!functionName.equals("") ? " " + functionName : ""), writer);
boolean highlight = writer.getIsHighlighted();
String mhead = "(" + (highlight ? paramStr : Highlighting.stripHilights(paramStr)) + "):" + (highlight ? returnStr : Highlighting.stripHilights(returnStr));
ret += highlight ? Highlighting.hilighMethod(mhead, methodIndex) : mhead;
ret += "\r\n" + hilight("{", highlight) + "\r\n";
ret += Graph.INDENTOPEN + "\r\n";
ret += (highlight ? functionBody : Highlighting.stripHilights(functionBody)) + "\r\n";
ret += Graph.INDENTCLOSE + "\r\n";
ret += hilight("}", highlight);
return ret;
writer.appendNoHilight(writer.getIsHighlighted() ? Highlighting.hilighMethod(mhead, methodIndex) : mhead);
writer.appendNewLine();
hilight("{", writer).appendNewLine();
hilight(Graph.INDENTOPEN, writer).appendNewLine();
writer.appendNoHilight((writer.getIsHighlighted() ? functionBody : Highlighting.stripHilights(functionBody)));
writer.appendNewLine();
hilight(Graph.INDENTCLOSE, writer).appendNewLine();
hilight("}", writer);
return writer;
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.Graph;
import java.util.HashMap;
import java.util.List;
@@ -32,23 +33,32 @@ public class NewObjectAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String params = "";
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
boolean singleLine = pairs.size() < 2;
if (!singleLine) {
writer.appendNewLine();
hilight(Graph.INDENTOPEN, writer).appendNewLine();
}
hilight("{", writer);
if (!singleLine) {
writer.appendNewLine();
hilight(Graph.INDENTOPEN, writer).appendNewLine();
}
for (int n = 0; n < pairs.size(); n++) {
if (n > 0) {
params += hilight(",", highlight) + "\r\n";
hilight(",", writer).appendNewLine();
}
params += pairs.get(n).toString(highlight, constants, localRegNames, fullyQualifiedNames);
pairs.get(n).toString(writer, constants, localRegNames, fullyQualifiedNames);
}
if (pairs.size() < 2) {
return hilight("{", highlight) + params + hilight("}", highlight);
if (!singleLine) {
writer.appendNewLine();
hilight(Graph.INDENTCLOSE, writer).appendNewLine();
}
String ret = "\r\n" + Graph.INDENTOPEN + "\r\n";
ret += hilight("{", highlight) + "\r\n";
ret += Graph.INDENTOPEN + "\r\n";
ret += params + "\r\n";
ret += Graph.INDENTCLOSE + "\r\n";
ret += hilight("}", highlight) + "\r\n" + Graph.INDENTCLOSE + "\r\n";
return ret;
hilight("}", writer);
if (!singleLine) {
writer.appendNewLine();
hilight(Graph.INDENTCLOSE, writer).appendNewLine();
}
return writer;
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
@@ -39,7 +40,11 @@ public class NextNameAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("nextName(", highlight) + index.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight(",", highlight) + obj.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight(")", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight("nextName(", writer);
index.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
hilight(",", writer);
obj.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
return hilight(")", writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
@@ -39,7 +40,11 @@ public class NextValueAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("nextValue(", highlight) + index.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight(",", highlight) + obj.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight(")", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight("nextValue(", writer);
index.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
hilight(",", writer);
obj.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
return hilight(")", writer);
}
}

View File

@@ -19,6 +19,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.ecma.Null;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import java.util.HashMap;
import java.util.List;
@@ -29,8 +30,8 @@ public class NullAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("null", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("null", writer);
}
@Override

View File

@@ -19,6 +19,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.abc.avm2.model.clauses.AssignmentAVM2Item;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
@@ -34,8 +35,9 @@ public class PostDecrementAVM2Item extends AVM2Item implements AssignmentAVM2Ite
}
@Override
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);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
object.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
return hilight("--", writer);
}
@Override

View File

@@ -19,6 +19,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.abc.avm2.model.clauses.AssignmentAVM2Item;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
@@ -34,8 +35,9 @@ public class PostIncrementAVM2Item extends AVM2Item implements AssignmentAVM2Ite
}
@Override
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);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
object.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
return hilight("++", writer);
}
@Override

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.ExitItem;
@@ -33,12 +34,8 @@ public class ReturnValueAVM2Item extends AVM2Item implements ExitItem {
}
@Override
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 ", highlight) + vaStr;
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight("return ", writer);
return value.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.model.ExitItem;
import java.util.HashMap;
import java.util.List;
@@ -29,7 +30,7 @@ public class ReturnVoidAVM2Item extends AVM2Item implements ExitItem {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("return", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("return", writer);
}
}

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import java.util.HashMap;
import java.util.List;
@@ -34,7 +35,7 @@ public class ScriptAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("script" + scriptIndex, highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("script" + scriptIndex, writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphPart;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
@@ -40,8 +41,10 @@ public class SetGlobalSlotAVM2Item extends AVM2Item {
}
@Override
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);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight("setglobalslot(" + slotId + ",", writer);
value.toString(writer, constants, localRegNames, fullyQualifiedNames);
return hilight(")", writer);
}
@Override

View File

@@ -19,6 +19,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.abc.avm2.model.clauses.AssignmentAVM2Item;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -35,8 +36,9 @@ public class SetLocalAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assig
}
@Override
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);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight(localRegName(localRegNames, regIndex) + " = ", writer);
return value.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
@Override

View File

@@ -19,6 +19,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.abc.avm2.model.clauses.AssignmentAVM2Item;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphPart;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
@@ -43,8 +44,10 @@ public class SetPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, As
}
@Override
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);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
formatProperty(writer, constants, object, propertyName, localRegNames, fullyQualifiedNames);
hilight(" = ", writer);
return value.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
@Override

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.model.clauses.AssignmentAVM2Item;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphPart;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
@@ -44,12 +45,13 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return getName(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(" = ", highlight) + value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
getName(writer, constants, localRegNames, fullyQualifiedNames);
hilight(" = ", writer);
return value.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
public String getName(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public String getName(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String ret = "";
/*ret = scope.toString(constants, localRegNames) + ".";
@@ -64,9 +66,9 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign
}
}*/
if (slotName == null) {
return ret + hilight("/*UnknownSlot*/", highlight);
return ret + hilight("/*UnknownSlot*/", writer);
}
return ret + hilight(slotName.getName(constants, fullyQualifiedNames), highlight);
return ret + hilight(slotName.getName(constants, fullyQualifiedNames), writer);
}
@Override

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
import com.jpexs.decompiler.graph.GraphPart;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -43,12 +44,15 @@ public class SetSuperAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String calee = object.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(".", highlight);
if (Highlighting.stripHilights(calee).equals("this.")) {
calee = "";
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
if (!object.toString(false, constants, localRegNames, fullyQualifiedNames).equals("this.")) {
object.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight(".", writer);
}
return calee + hilight("super.", highlight) + propertyName.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(" = ", highlight) + value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
hilight("super.", writer);
propertyName.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight(" = ", writer);
return value.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
@Override

View File

@@ -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.HilightedTextWriter;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
import java.util.List;
@@ -32,8 +33,8 @@ public class StringAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("\"" + Helper.escapeString(value) + "\"", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("\"" + Helper.escapeString(value) + "\"", writer);
}
@Override

View File

@@ -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.types.Multiname;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import java.util.HashMap;
import java.util.List;
@@ -31,7 +32,7 @@ public class ThisAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("this", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("this", writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -31,7 +32,8 @@ public class ThrowAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("throw ", highlight) + value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight("throw ", writer);
return value.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
}

View File

@@ -19,6 +19,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.ecma.Undefined;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import java.util.HashMap;
import java.util.List;
@@ -29,8 +30,8 @@ public class UndefinedAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("undefined", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("undefined", writer);
}
@Override

View File

@@ -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.HilightedTextWriter;
import java.util.HashMap;
import java.util.List;
@@ -31,7 +32,7 @@ public class UnparsedAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight(value, highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight(value, writer);
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.ArrayList;
@@ -42,16 +43,17 @@ public class WithAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String ret;
ret = hilight("with(", highlight) + scope.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(")", highlight) + "\r\n" + hilight("{", highlight) + "\r\n";
ret += Graph.INDENTOPEN + "\r\n";
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight("with(", writer);
scope.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight(")", writer).appendNewLine();
hilight("{", writer).appendNewLine();
hilight(Graph.INDENTOPEN, writer).appendNewLine();
/*for (GraphTargetItem ti : items) {
ret += ti.toString(constants, localRegNames, fullyQualifiedNames) + "\r\n";
}*/
ret += Graph.INDENTCLOSE + "\r\n";
ret += hilight("}", highlight);
return ret;
hilight(Graph.INDENTCLOSE, writer).appendNewLine();
return hilight("}", writer);
}
@Override

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -32,8 +33,8 @@ public class WithEndAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("}", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("}", writer);
}
@Override

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -32,7 +33,7 @@ public class WithObjectAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return "";
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return writer;
}
}

View File

@@ -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.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -36,15 +37,14 @@ public class XMLAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String ret = "";
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
for (GraphTargetItem part : parts) {
if (part instanceof StringAVM2Item) {
ret += hilight(((StringAVM2Item) part).value, highlight);
hilight(((StringAVM2Item) part).value, writer);
} else {
ret += part.toString(highlight, constants, localRegNames, fullyQualifiedNames);
part.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
}
return ret;
return writer;
}
}

View File

@@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.SetLocalAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.SetSlotAVM2Item;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
@@ -47,7 +48,7 @@ public class DeclarationAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
if (assignment instanceof SetLocalAVM2Item) {
SetLocalAVM2Item lti = (SetLocalAVM2Item) assignment;
String type = "*";
@@ -57,12 +58,20 @@ public class DeclarationAVM2Item extends AVM2Item {
if (lti.value instanceof ConvertAVM2Item) {
type = ((ConvertAVM2Item) lti.value).type;
}
return hilight("var ", highlight) + hilight(localRegName(localRegNames, lti.regIndex) + ":" + type + " = ", highlight) + lti.value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
hilight("var ", writer);
hilight(localRegName(localRegNames, lti.regIndex) + ":" + type + " = ", writer);
return lti.value.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
if (assignment instanceof SetSlotAVM2Item) {
SetSlotAVM2Item ssti = (SetSlotAVM2Item) assignment;
return hilight("var ", highlight) + ssti.getName(highlight, constants, localRegNames, fullyQualifiedNames) + hilight(":", highlight) + hilight(type, highlight) + hilight(" = ", highlight) + ssti.value.toString(highlight, constants, localRegNames, fullyQualifiedNames);
hilight("var ", writer);
ssti.getName(writer, constants, localRegNames, fullyQualifiedNames);
hilight(":", writer);
hilight(type, writer);
hilight(" = ", writer);
return ssti.value.toString(writer, constants, localRegNames, fullyQualifiedNames);
}
return hilight("var ", highlight) + assignment.toString(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames));
hilight("var ", writer);
return assignment.toString(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames));
}
}

View File

@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.clauses;
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
import com.jpexs.decompiler.flash.abc.types.ABCException;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import java.util.HashMap;
import java.util.List;
@@ -32,7 +33,7 @@ public class ExceptionAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight(exception.getVarName(constants, fullyQualifiedNames), highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight(exception.getVarName(constants, fullyQualifiedNames), writer);
}
}

View File

@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.clauses;
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -39,7 +40,10 @@ public class FilterAVM2Item extends AVM2Item {
}
@Override
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);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
collection.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight(".(", writer);
expression.toString(writer, constants, localRegNames, fullyQualifiedNames);
return hilight(")", writer);
}
}

View File

@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.clauses;
import com.jpexs.decompiler.flash.abc.avm2.model.InAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.SetTypeAVM2Item;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.Block;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -68,20 +69,22 @@ public class ForEachInAVM2Item extends LoopItem implements Block {
}
@Override
public String toString(boolean highlight, List<Object> localData) {
String ret = "";
ret += hilight("loop" + loop.id + ":", highlight) + "\r\n";
ret += hilight("for each (", highlight) + expression.toString(highlight, localData) + hilight(")", highlight) + "\r\n" + hilight("{", highlight) + "\r\n";
ret += Graph.INDENTOPEN + "\r\n";
public HilightedTextWriter toString(HilightedTextWriter writer, List<Object> localData) {
hilight("loop" + loop.id + ":", writer).appendNewLine();
hilight("for each (", writer);
expression.toString(writer, localData);
hilight(")", writer).appendNewLine();
hilight("{", writer).appendNewLine();
hilight(Graph.INDENTOPEN, writer).appendNewLine();
for (GraphTargetItem ti : commands) {
if (!ti.isEmpty()) {
ret += ti.toStringSemicoloned(highlight, localData) + "\r\n";
ti.toStringSemicoloned(writer, localData).appendNewLine();
}
}
ret += Graph.INDENTCLOSE + "\r\n";
ret += hilight("}", highlight) + "\r\n";
ret += hilight(":loop" + loop.id, highlight);
return ret;
hilight(Graph.INDENTCLOSE, writer).appendNewLine();
hilight("}", writer).appendNewLine();
hilight(":loop" + loop.id, writer);
return writer;
}
@Override

View File

@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.clauses;
import com.jpexs.decompiler.flash.abc.avm2.model.InAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.SetTypeAVM2Item;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.Block;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -68,20 +69,22 @@ public class ForInAVM2Item extends LoopItem implements Block {
}
@Override
public String toString(boolean highlight, List<Object> localData) {
String ret = "";
ret += hilight("loop" + loop.id + ":", highlight) + "\r\n";
ret += hilight("for (", highlight) + expression.toString(highlight, localData) + hilight(")", highlight) + "\r\n" + hilight("{", highlight) + "\r\n";
ret += Graph.INDENTOPEN + "\r\n";
public HilightedTextWriter toString(HilightedTextWriter writer, List<Object> localData) {
hilight("loop" + loop.id + ":", writer).appendNewLine();
hilight("for (", writer);
expression.toString(writer, localData);
hilight(")", writer).appendNewLine();
hilight("{", writer).appendNewLine();
hilight(Graph.INDENTOPEN, writer).appendNewLine();
for (GraphTargetItem ti : commands) {
if (!ti.isEmpty()) {
ret += ti.toStringSemicoloned(highlight, localData) + "\r\n";
ti.toStringSemicoloned(writer, localData).appendNewLine();
}
}
ret += Graph.INDENTCLOSE + "\r\n";
ret += hilight("}", highlight) + "\r\n";
ret += hilight(":loop" + loop.id, highlight);
return ret;
hilight(Graph.INDENTCLOSE, writer).appendNewLine();
hilight("}", writer).appendNewLine();
hilight(":loop" + loop.id, writer);
return writer;
}
@Override

View File

@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.clauses;
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
import com.jpexs.decompiler.flash.abc.types.ABCException;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.Block;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -53,41 +54,46 @@ public class TryAVM2Item extends AVM2Item implements Block {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
String ret = "";
ret += hilight("try", highlight) + "\r\n" + hilight("{", highlight) + "\r\n";
ret += Graph.INDENTOPEN + "\r\n";
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight("try", writer).appendNewLine();
hilight("{", writer).appendNewLine();
hilight(Graph.INDENTOPEN, writer).appendNewLine();
for (GraphTargetItem ti : tryCommands) {
if (!ti.isEmpty()) {
ret += ti.toStringSemicoloned(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "\r\n";
ti.toStringSemicoloned(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames)).appendNewLine();
}
}
ret += Graph.INDENTCLOSE + "\r\n";
ret += hilight("}", highlight);
hilight(Graph.INDENTCLOSE, writer).appendNewLine();
hilight("}", writer);
for (int e = 0; e < catchExceptions.size(); e++) {
ret += "\r\n" + hilight("catch(" + catchExceptions.get(e).getVarName(constants, fullyQualifiedNames) + ":" + catchExceptions.get(e).getTypeName(constants, fullyQualifiedNames) + ")", highlight) + "\r\n" + hilight("{", highlight) + "\r\n";
ret += Graph.INDENTOPEN + "\r\n";
writer.appendNewLine();
hilight("catch(" + catchExceptions.get(e).getVarName(constants, fullyQualifiedNames) + ":" + catchExceptions.get(e).getTypeName(constants, fullyQualifiedNames) + ")", writer);
writer.appendNewLine();
hilight("{", writer).appendNewLine();
hilight(Graph.INDENTOPEN, writer).appendNewLine();
List<GraphTargetItem> commands = catchCommands.get(e);
for (GraphTargetItem ti : commands) {
if (!ti.isEmpty()) {
ret += ti.toStringSemicoloned(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "\r\n";
ti.toStringSemicoloned(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames)).appendNewLine();
}
}
ret += Graph.INDENTCLOSE + "\r\n";
ret += hilight("}", highlight);
hilight(Graph.INDENTCLOSE, writer).appendNewLine();
hilight("}", writer);
}
if (finallyCommands.size() > 0) {
ret += "\r\n" + hilight("finally", highlight) + "\r\n" + hilight("{", highlight) + "\r\n";
ret += Graph.INDENTOPEN + "\r\n";
writer.appendNewLine();
hilight("finally", writer).appendNewLine();
hilight("{", writer).appendNewLine();
hilight(Graph.INDENTOPEN, writer).appendNewLine();
for (GraphTargetItem ti : finallyCommands) {
if (!ti.isEmpty()) {
ret += ti.toStringSemicoloned(highlight, Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "\r\n";
ti.toStringSemicoloned(writer, Helper.toList(constants, localRegNames, fullyQualifiedNames)).appendNewLine();
}
}
ret += Graph.INDENTCLOSE + "\r\n";
ret += hilight("}", highlight);
hilight(Graph.INDENTCLOSE, writer).appendNewLine();
hilight("}", writer);
}
return ret;
return writer;
}
@Override

View File

@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.ecma.EcmaType;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import java.util.List;
@@ -30,22 +31,24 @@ public class AddAVM2Item extends BinaryOpItem {
}
@Override
public String toString(boolean highlight, List<Object> localData) {
public HilightedTextWriter toString(HilightedTextWriter writer, List<Object> localData) {
if (rightSide.precedence >= precedence) { //string + vs number +
String ret = "";
if (leftSide.precedence > precedence) {
ret += hilight("(", highlight) + leftSide.toString(highlight, localData) + hilight(")", highlight);
hilight("(", writer);
leftSide.toString(writer, localData);
hilight(")", writer);
} else {
ret += leftSide.toString(highlight, localData);
leftSide.toString(writer, localData);
}
ret += " ";
ret += hilight(operator, highlight);
ret += " ";
hilight(" ", writer);
hilight(operator, writer);
hilight(" ", writer);
ret += hilight("(", highlight) + rightSide.toString(highlight, localData) + hilight(")", highlight);
return ret;
hilight("(", writer);
rightSide.toString(writer, localData);
return hilight(")", writer);
} else {
return super.toString(highlight, localData);
return super.toString(writer, localData);
}
}

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.util.HashMap;
import java.util.List;
@@ -36,7 +37,11 @@ public class DeletePropertyAVM2Item extends AVM2Item {
}
@Override
public String toString(boolean highlight, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
return hilight("delete ", highlight) + object.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight("[", highlight) + propertyName.toString(highlight, constants, localRegNames, fullyQualifiedNames) + hilight("]", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants, HashMap<Integer, String> localRegNames, List<String> fullyQualifiedNames) {
hilight("delete ", writer);
object.toString(writer, constants, localRegNames, fullyQualifiedNames);
hilight("[", writer);
propertyName.toString(writer, constants, localRegNames, fullyQualifiedNames);
return hilight("]", writer);
}
}

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import java.util.List;
@@ -34,22 +35,24 @@ public class SubtractAVM2Item extends BinaryOpItem {
}
@Override
public String toString(boolean highlight, List<Object> localData) {
public HilightedTextWriter toString(HilightedTextWriter writer, List<Object> localData) {
if (rightSide.precedence >= precedence) { // >= add or subtract too
String ret = "";
if (leftSide.precedence > precedence) {
ret += hilight("(", highlight) + leftSide.toString(highlight, localData) + hilight(")", highlight);
hilight("(", writer);
leftSide.toString(writer, localData);
hilight(")", writer);
} else {
ret += leftSide.toString(highlight, localData);
leftSide.toString(writer, localData);
}
ret += " ";
ret += hilight(operator, highlight);
ret += " ";
hilight(" ", writer);
hilight(operator, writer);
hilight(" ", writer);
ret += hilight("(", highlight) + rightSide.toString(highlight, localData) + hilight(")", highlight);
return ret;
hilight("(", writer);
rightSide.toString(writer, localData);
return hilight(")", writer);
} else {
return super.toString(highlight, localData);
return super.toString(writer, localData);
}
}
}

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.action.swf4.ActionPop;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
@@ -35,11 +36,11 @@ public abstract class ActionItem extends GraphTargetItem implements Serializable
super(instruction, precedence);
}
public abstract String toString(boolean highlight, ConstantPool constants);
public abstract HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants);
public String toString(boolean highlight) {
public HilightedTextWriter toString(HilightedTextWriter writer) {
ConstantPool c = null;
return toString(highlight, c);
return toString(writer, c);
}
protected boolean isEmptyString(GraphTargetItem target) {
@@ -54,26 +55,26 @@ public abstract class ActionItem extends GraphTargetItem implements Serializable
return false;
}
protected String stripQuotes(GraphTargetItem target, ConstantPool constants, boolean highlight) {
protected HilightedTextWriter stripQuotes(GraphTargetItem target, ConstantPool constants, HilightedTextWriter writer) {
if (target instanceof DirectValueActionItem) {
if (((DirectValueActionItem) target).value instanceof String) {
return (String) ((DirectValueActionItem) target).hilight((String) ((DirectValueActionItem) target).value, highlight);
return ((DirectValueActionItem) target).hilight((String) ((DirectValueActionItem) target).value, writer);
}
}
if (target == null) {
return "";
return writer;
} else {
return target.toString(highlight, constants);
return target.toString(writer, constants);
}
}
@Override
public String toString(boolean highlight, List<Object> localData) {
public HilightedTextWriter toString(HilightedTextWriter writer, List<Object> localData) {
if (localData.isEmpty()) {
ConstantPool c = null;
return toString(highlight, c);
return toString(writer, c);
}
return toString(highlight, (ConstantPool) localData.get(0));
return toString(writer, (ConstantPool) localData.get(0));
}
protected List<GraphSourceItem> toSourceCall(List<Object> localData, SourceGenerator gen, List<GraphTargetItem> list) {

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.action.swf4.ActionAsciiToChar;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -31,8 +32,10 @@ public class AsciiToCharActionItem extends ActionItem {
}
@Override
public String toString(boolean highlight, ConstantPool constants) {
return hilight("chr(", highlight) + value.toString(highlight, constants) + hilight(")", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
hilight("chr(", writer);
value.toString(writer, constants);
return hilight(")", writer);
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.action.swf4.ActionCall;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -31,8 +32,10 @@ public class CallActionItem extends ActionItem {
}
@Override
public String toString(boolean highlight, ConstantPool constants) {
return hilight("call(", highlight) + stripQuotes(value, constants, highlight) + hilight(")", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
hilight("call(", writer);
stripQuotes(value, constants, writer);
return hilight(")", writer);
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.action.swf5.ActionCallFunction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -41,15 +42,17 @@ public class CallFunctionActionItem extends ActionItem {
}
@Override
public String toString(boolean highlight, ConstantPool constants) {
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
String paramStr = "";
stripQuotes(functionName, constants, writer);
hilight("(", writer);
for (int t = 0; t < arguments.size(); t++) {
if (t > 0) {
paramStr += hilight(",", highlight);
hilight(",", writer);
}
paramStr += arguments.get(t).toStringNL(highlight, constants);
arguments.get(t).toStringNL(writer, constants);
}
return stripQuotes(functionName, constants, highlight) + hilight("(", highlight) + paramStr + hilight(")", highlight);
return hilight(")", writer);
}
@Override

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.action.swf5.ActionCallMethod;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -47,14 +48,7 @@ public class CallMethodActionItem extends ActionItem {
}
@Override
public String toString(boolean highlight, ConstantPool constants) {
String paramStr = "";
for (int t = 0; t < arguments.size(); t++) {
if (t > 0) {
paramStr += hilight(",", highlight);
}
paramStr += arguments.get(t).toStringNL(highlight, constants);
}
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
boolean blankMethod = false;
if (methodName instanceof DirectValueActionItem) {
if (((DirectValueActionItem) methodName).value instanceof Undefined) {
@@ -66,14 +60,29 @@ public class CallMethodActionItem extends ActionItem {
}
}
}
if (blankMethod) {
return scriptObject.toString(highlight, constants) + hilight("(", highlight) + paramStr + hilight(")", highlight);
if (!blankMethod) {
if (scriptObject.precedence > this.precedence) {
hilight("(", writer);
scriptObject.toString(writer, constants);
hilight(")", writer);
} else {
scriptObject.toString(writer, constants);
}
hilight(".", writer);
stripQuotes(methodName, constants, writer);
} else {
scriptObject.toString(writer, constants);
}
String soStr = scriptObject.toString(highlight, constants);
if (scriptObject.precedence > this.precedence) {
soStr = hilight("(", highlight) + soStr + hilight(")", highlight);
hilight("(", writer);
for (int t = 0; t < arguments.size(); t++) {
if (t > 0) {
hilight(",", writer);
}
arguments.get(t).toStringNL(writer, constants);
}
return soStr + hilight(".", highlight) + stripQuotes(methodName, constants, highlight) + hilight("(", highlight) + paramStr + hilight(")", highlight);
return hilight(")", writer);
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.action.swf7.ActionCastOp;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -45,8 +46,11 @@ public class CastOpActionItem extends ActionItem {
}
@Override
public String toString(boolean highlight, ConstantPool constants) {
return hilight("(", highlight) + stripQuotes(constructor, constants, highlight) + hilight(")", highlight) + object.toString(highlight, Helper.toList(constants));
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
hilight("(", writer);
stripQuotes(constructor, constants, writer);
hilight(")", writer);
return object.toString(writer, Helper.toList(constants));
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.action.swf4.ActionCharToAscii;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -31,8 +32,10 @@ public class CharToAsciiActionItem extends ActionItem {
}
@Override
public String toString(boolean highlight, ConstantPool constants) {
return hilight("ord(", highlight) + value.toString(highlight, constants) + hilight(")", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
hilight("ord(", writer);
value.toString(writer, constants);
return hilight(")", writer);
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.action.swf4.ActionCloneSprite;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -47,8 +48,14 @@ public class CloneSpriteActionItem extends ActionItem {
}
@Override
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);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
hilight("duplicateMovieClip(", writer);
target.toString(writer, constants);
hilight(",", writer);
source.toString(writer, constants);
hilight(",", writer);
depth.toString(writer, constants);
return hilight(")", writer);
}
@Override

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.action.swf5.ActionDecrement;
import com.jpexs.decompiler.flash.ecma.*;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -42,8 +43,9 @@ public class DecrementActionItem extends ActionItem {
}
@Override
public String toString(boolean highlight, ConstantPool constants) {
return object.toString(highlight, constants) + hilight(" - 1", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
object.toString(writer, constants);
return hilight(" - 1", writer);
}
@Override

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal;
import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal2;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -68,11 +69,14 @@ public class DefineLocalActionItem extends ActionItem implements SetTypeActionIt
}
@Override
public String toString(boolean highlight, ConstantPool constants) {
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
hilight("var ", writer);
stripQuotes(name, constants, writer);
if (value == null) {
return hilight("var ", highlight) + stripQuotes(name, constants, highlight);
return writer;
}
return hilight("var ", highlight) + stripQuotes(name, constants, highlight) + hilight(" = ", highlight) + value.toString(highlight, constants);
hilight(" = ", writer);
return value.toString(writer, constants);
}
@Override

View File

@@ -16,6 +16,8 @@
*/
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
/**
*
* @author JPEXS
@@ -32,8 +34,8 @@ public class DefineRegisterActionItem extends ActionItem {
}
@Override
public String toString(boolean highlight, ConstantPool constants) {
return hilight("var " + identifier, highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
return hilight("var " + identifier, writer);
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.action.swf5.ActionDelete;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -44,11 +45,14 @@ public class DeleteActionItem extends ActionItem {
}
@Override
public String toString(boolean highlight, ConstantPool constants) {
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
hilight("delete ", writer);
if (object == null) {
return hilight("delete ", highlight) + propertyName.toString(highlight, constants);
return propertyName.toString(writer, constants);
}
return hilight("delete ", highlight) + object.toString(highlight, constants) + hilight(".", highlight) + stripQuotes(propertyName, constants, highlight);
object.toString(writer, constants);
hilight(".", writer);
return stripQuotes(propertyName, constants, writer);
}
@Override

View File

@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.action.swf4.ConstantIndex;
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
import com.jpexs.decompiler.flash.ecma.Null;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
@@ -85,24 +86,24 @@ public class DirectValueActionItem extends ActionItem {
}
@Override
public String toStringNoQuotes(boolean highlight, List<Object> localData) {
public HilightedTextWriter toStringNoQuotes(HilightedTextWriter writer, List<Object> localData) {
if (value instanceof Double) {
if (Double.compare((double) (Double) value, 0) == 0) {
return hilight("0", highlight);
return hilight("0", writer);
}
}
if (value instanceof Float) {
if (Float.compare((float) (Float) value, 0) == 0) {
return hilight("0", highlight);
return hilight("0", writer);
}
}
if (value instanceof String) {
return hilight((String) value, highlight);
return hilight((String) value, writer);
}
if (value instanceof ConstantIndex) {
return hilight(this.constants.get(((ConstantIndex) value).index), highlight);
return hilight(this.constants.get(((ConstantIndex) value).index), writer);
}
return hilight(value.toString(), highlight);
return hilight(value.toString(), writer);
}
public String toStringNoH(ConstantPool constants) {
@@ -126,27 +127,27 @@ public class DirectValueActionItem extends ActionItem {
}
@Override
public String toString(boolean highlight, ConstantPool constants) {
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
if (value instanceof Double) {
if (Double.compare((double) (Double) value, 0) == 0) {
return hilight("0", highlight);
return hilight("0", writer);
}
}
if (value instanceof Float) {
if (Float.compare((float) (Float) value, 0) == 0) {
return hilight("0", highlight);
return hilight("0", writer);
}
}
if (value instanceof String) {
return hilight("\"" + Helper.escapeString((String) value) + "\"", highlight);
return hilight("\"" + Helper.escapeString((String) value) + "\"", writer);
}
if (value instanceof ConstantIndex) {
return hilight("\"" + Helper.escapeString(this.constants.get(((ConstantIndex) value).index)) + "\"", highlight);
return hilight("\"" + Helper.escapeString(this.constants.get(((ConstantIndex) value).index)) + "\"", writer);
}
if (value instanceof RegisterNumber) {
return hilight(((RegisterNumber) value).translate(), highlight);
return hilight(((RegisterNumber) value).translate(), writer);
}
return hilight(value.toString(), highlight);
return hilight(value.toString(), writer);
}
@Override

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -40,8 +41,9 @@ public class EnumerateActionItem extends ActionItem {
}
@Override
public String toString(boolean highlight, ConstantPool constants) {
return hilight("enumerate ", highlight) + object.toString(highlight, Helper.toList(constants));
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
hilight("enumerate ", writer);
return object.toString(writer, Helper.toList(constants));
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.action.swf4.ActionGetVariable;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
@@ -34,8 +35,10 @@ public class EvalActionItem extends ActionItem {
}
@Override
public String toString(boolean highlight, ConstantPool constants) {
return hilight("eval(", highlight) + value.toString(highlight, constants) + hilight(")", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
hilight("eval(", writer);
value.toString(writer, constants);
return hilight(")", writer);
}
@Override

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -34,10 +35,12 @@ public class ExtendsActionItem extends ActionItem {
}
@Override
public String toString(boolean highlight, ConstantPool constants) {
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
List<Object> localData = new ArrayList<>();
localData.add(constants);
return subclass.toString(highlight, localData) + hilight(" extends ", highlight) + stripQuotes(superclass, constants, highlight);
subclass.toString(writer, localData);
hilight(" extends ", writer);
return stripQuotes(superclass, constants, writer);
}
@Override

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.action.flashlite.ActionFSCommand2;
import com.jpexs.decompiler.flash.action.swf4.ActionPush;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -46,13 +47,14 @@ public class FSCommand2ActionItem extends ActionItem {
}
@Override
public String toString(boolean highlight, ConstantPool constants) {
String paramStr = "";
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
hilight("FSCommand2(", writer);
command.toString(writer, constants);
for (int t = 0; t < arguments.size(); t++) {
paramStr += hilight(",", highlight);
paramStr += arguments.get(t).toString(highlight, constants);
hilight(",", writer);
arguments.get(t).toString(writer, constants);
}
return hilight("FSCommand2(", highlight) + command.toString(highlight, constants) + paramStr + hilight(")", highlight);
return hilight(")", writer);
}
@Override

View File

@@ -17,6 +17,7 @@
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.action.swf3.ActionGetURL;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.SourceGenerator;
import com.jpexs.helpers.Helper;
@@ -36,8 +37,10 @@ public class FSCommandActionItem extends ActionItem {
}
@Override
public String toString(boolean highlight, ConstantPool constants) {
return hilight("fscommand(\"", highlight) + Helper.escapeString(command) + hilight("\")", highlight);
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
hilight("fscommand(\"", writer);
hilight(Helper.escapeString(command), writer);
return hilight("\")", writer);
}
@Override

View File

@@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
import com.jpexs.decompiler.flash.action.swf5.ActionDefineFunction;
import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister;
import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
@@ -71,33 +72,35 @@ public class FunctionActionItem extends ActionItem {
}
@Override
public String toString(boolean highlight, ConstantPool constants) {
public HilightedTextWriter toString(HilightedTextWriter writer, ConstantPool constants) {
if (true) {
//return "<func>";
//return writer.appendNoHilight("<func>")
}
String ret = hilight("function", highlight);
hilight("function", writer);
if (calculatedFunctionName != null) {
ret += " " + calculatedFunctionName.toStringNoQuotes(highlight, constants);
hilight(" ", writer);
calculatedFunctionName.toStringNoQuotes(writer, constants);
} else if (!functionName.equals("")) {
ret += " " + functionName;
hilight(" ", writer);
hilight(functionName, writer);
}
ret += hilight("(", highlight);
hilight("(", writer);
for (int p = 0; p < paramNames.size(); p++) {
if (p > 0) {
ret += hilight(", ", highlight);
hilight(", ", writer);
}
String pname = paramNames.get(p);
if (pname == null || pname.equals("")) {
pname = new RegisterNumber(regStart + p).translate();
}
ret += hilight(pname, highlight);
hilight(pname, writer);
}
ret += hilight(")", highlight) + "\r\n" + hilight("{", highlight) + "\r\n";
ret += Graph.INDENTOPEN + "\r\n";
ret += Graph.graphToString(actions, highlight, false, constants);
ret += Graph.INDENTCLOSE + "\r\n";
ret += hilight("}", highlight);
return ret;
hilight(")", writer).appendNewLine();
hilight("{", writer).appendNewLine();
hilight(Graph.INDENTOPEN, writer).appendNewLine();
writer.appendNoHilight(Graph.graphToString(actions, writer.getIsHighlighted(), false, constants));
hilight(Graph.INDENTCLOSE, writer).appendNewLine();
return hilight("}", writer);
}
@Override

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