highlighting refactored

This commit is contained in:
Honfika
2013-11-01 01:07:19 +01:00
parent 2cf26a4c31
commit d23c2dbe63
242 changed files with 1572 additions and 1075 deletions

View File

@@ -47,7 +47,14 @@
<property name="INSTALLERCONFIG" value="${basedir}/installer.cfg"/>
<property name="INSTALLERPROJECT" value="${basedir}/installer.iss"/>
<property name="EXECONFIG" value="${basedir}/build_exe.xml"/>
<property name="RUNPARAMS" value=""/>
<!-- <property name="RUNPARAMS" value=""/> -->
<!--
<property name="RUNPARAMS" value="-onerror ignore -affinity 8 -priority low -config autoDeobfuscate=1,parallelSpeedUp=0,cacheOnDisk=0 -export as c:\5\out c:\5\bomberman1.swf"/>
<property name="RUNPARAMS" value="-onerror ignore -affinity 8 -priority low -config autoDeobfuscate=1,parallelSpeedUp=0,cacheOnDisk=0 -export as c:\5\out c:\5\klone.swf"/>
<property name="RUNPARAMS" value="c:\5\bomberman1.swf"/>
-->
<property name="RUNPARAMS" value=""/>
<!-- <property name="RUNPARAMS" value="-onerror ignore -affinity 8 -priority low -config autoDeobfuscate=0,parallelSpeedUp=0,cacheOnDisk=0 -export pcode c:\5 c:\5\effect.swf"/>
-->
<import file="build_common.xml"/>
</project>

View File

@@ -13,7 +13,7 @@
<classpath refid="cp"/>
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
<jvmarg value="-Xmx1024m"/>
<jvmarg value="-Xmx6144m"/>
<arg line="${RUNPARAMS}"/>
</java>
</target>

View File

@@ -565,7 +565,7 @@ public class SWF {
for (MyEntry<ClassPath, ScriptPack> item : packs) {
for (MyEntry<ClassPath, ScriptPack> itemOld : ret) {
if (item.key.equals(itemOld.key)) {
Logger.getLogger(SWF.class.getName()).log(Level.SEVERE, "Duplicate pack path found!");
Logger.getLogger(SWF.class.getName()).log(Level.SEVERE, "Duplicate pack path found (" + itemOld.key + ")!");
break;
}
}

View File

@@ -306,7 +306,6 @@ public class TagNode {
HilightedTextWriter writer = new HilightedTextWriter(false, asm.getActionSourceIndent());
asm.getASMSource(SWF.DEFAULT_VERSION, exportMode, writer, null);
String str = writer.toString();
str = Helper.hexToComments(str);
res = asm.getActionSourcePrefix() + str + asm.getActionSourceSuffix();
} else {
List<Action> as = asm.getActions(SWF.DEFAULT_VERSION);

View File

@@ -121,15 +121,18 @@ public class ScriptPack {
for (int t : traitIndices) {
Multiname name = abc.script_info[scriptIndex].traits.traits[t].getName(abc);
Namespace ns = name.getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
abc.script_info[scriptIndex].traits.traits[t].convertPackaged(null, "", abcList, abc, false, exportMode, scriptIndex, -1, new ArrayList<String>(), parallel);
} else {
abc.script_info[scriptIndex].traits.traits[t].convert(null, "", abcList, abc, false, exportMode, scriptIndex, -1, new ArrayList<String>(), parallel);
}
HilightedTextWriter writer = new HilightedTextWriter(false);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
abc.script_info[scriptIndex].traits.traits[t].convertPackaged(null, "", abcList, abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
abc.script_info[scriptIndex].traits.traits[t].toStringPackaged(null, "", abcList, abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
} else {
abc.script_info[scriptIndex].traits.traits[t].convert(null, "", abcList, abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
abc.script_info[scriptIndex].traits.traits[t].toString(null, "", abcList, abc, false, exportMode, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
}
String s = Graph.removeNonRefenrencedLoopLabels(writer.toString(), false);
s = Helper.hexToComments(s);
fos.write(s.getBytes("utf-8"));
fos.write(writer.toString().getBytes("utf-8"));
}
}
return file;

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.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
import com.jpexs.decompiler.graph.ExportMode;
@@ -708,7 +709,7 @@ public class AVM2Code implements Serializable {
return s.toString();
}
public HilightedTextWriter toString(HilightedTextWriter writer, LocalData localData) {
public GraphTextWriter toString(GraphTextWriter writer, LocalData localData) {
int i = 0;
for (AVM2Instruction instruction : code) {
writer.appendNoHilight(Helper.formatAddress(i));
@@ -719,11 +720,11 @@ public class AVM2Code implements Serializable {
return writer;
}
public HilightedTextWriter toASMSource(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, ExportMode exportMode, HilightedTextWriter writer) {
public GraphTextWriter toASMSource(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, ExportMode exportMode, GraphTextWriter writer) {
return toASMSource(constants, trait, info, body, new ArrayList<Integer>(), exportMode, writer);
}
public HilightedTextWriter toASMSource(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, List<Integer> outputMap, ExportMode exportMode, HilightedTextWriter writer) {
public GraphTextWriter toASMSource(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, List<Integer> outputMap, ExportMode exportMode, GraphTextWriter writer) {
invalidateCache();
if (trait != null) {
if (trait instanceof TraitFunction) {
@@ -906,9 +907,9 @@ public class AVM2Code implements Serializable {
} else {
for (AVM2Instruction ins : code) {
if (exportMode == ExportMode.PCODEWITHHEX) {
writer.appendNoHilight("<ffdec:hex>");
writer.appendNoHilight("; ");
writer.appendNoHilight(Helper.bytesToHexString(ins.getBytes()));
writer.appendNoHilight("</ffdec:hex>\n");
writer.newLine();
}
if (ins.labelname != null) {
writer.appendNoHilight(ins.labelname + ":");
@@ -1137,7 +1138,7 @@ public class AVM2Code implements Serializable {
visited[ip] = true;
AVM2Instruction ins = code.get(ip);
if (debugMode) {
System.err.println("translating ip " + ip + " ins " + ins.toString() + " stack:" + Highlighting.stripHilights(stack.toString()) + " scopeStack:" + Highlighting.stripHilights(scopeStack.toString()));
System.err.println("translating ip " + ip + " ins " + ins.toString() + " stack:" + stack.toString() + " scopeStack:" + scopeStack.toString());
}
if (ins.definition instanceof NewFunctionIns) {
if (ip + 1 <= end) {
@@ -1405,30 +1406,17 @@ public class AVM2Code implements Serializable {
ignoredIns = new ArrayList<>();
}
public HilightedTextWriter toSource(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, ConstantPool constants, MethodInfo[] method_info, MethodBody body, HilightedTextWriter writer, HashMap<Integer, String> localRegNames, Stack<GraphTargetItem> scopeStack, boolean isStaticInitializer, List<String> fullyQualifiedNames, Traits initTraits, int staticOperation, HashMap<Integer, Integer> localRegAssigmentIps, HashMap<Integer, List<Integer>> refs) {
public List<GraphTargetItem> toGraphTargetItems(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, ConstantPool constants, MethodInfo[] method_info, MethodBody body, HashMap<Integer, String> localRegNames, Stack<GraphTargetItem> scopeStack, boolean isStaticInitializer, List<String> fullyQualifiedNames, Traits initTraits, int staticOperation, HashMap<Integer, Integer> localRegAssigmentIps, HashMap<Integer, List<Integer>> refs) {
initToSource();
List<GraphTargetItem> list;
String s;
HashMap<Integer, GraphTargetItem> localRegs = new HashMap<>();
int regCount = getRegisterCount();
//try {
try {
list = AVM2Graph.translateViaGraph(path, this, abc, body, isStatic, scriptIndex, classIndex, localRegs, scopeStack, localRegNames, fullyQualifiedNames, staticOperation, localRegAssigmentIps, refs);
} catch (Exception | OutOfMemoryError | StackOverflowError ex2) {
Logger.getLogger(AVM2Code.class.getName()).log(Level.SEVERE, "Decompilation error in " + path, ex2);
if (ex2 instanceof OutOfMemoryError) {
System.gc();
}
writer.appendNoHilight("/*").newLine();
writer.appendNoHilight(" * Decompilation error").newLine();
writer.appendNoHilight(" * Code may be obfuscated").newLine();
writer.appendNoHilight(" * Error type: " + ex2.getClass().getSimpleName()).newLine();
writer.appendNoHilight(" */").newLine();
return writer.appendNoHilight("throw new IllegalOperationError(\"Not decompiled due to error\");").newLine();
}
list = AVM2Graph.translateViaGraph(path, this, abc, body, isStatic, scriptIndex, classIndex, localRegs, scopeStack, localRegNames, fullyQualifiedNames, staticOperation, localRegAssigmentIps, refs);
if (initTraits != null) {
for (int i = 0; i < list.size(); i++) {
GraphTargetItem ti = list.get(i);
@@ -1475,7 +1463,7 @@ public class AVM2Code implements Serializable {
}
list = newList;
if (list.isEmpty()) {
return writer;
return list;
}
}
//Declarations
@@ -1525,9 +1513,7 @@ public class AVM2Code implements Serializable {
list.remove(lastPos);
}
Graph.graphToString(list, writer, LocalData.create(constants, localRegNames, fullyQualifiedNames));
return writer;
return list;
}
public void removeInstruction(int pos, MethodBody body) {
@@ -2444,7 +2430,7 @@ public class AVM2Code implements Serializable {
}
if (debugMode) {
System.out.println((indeterminate ? "useV " : "") + (secondPass ? "secondPass " : "") + "Visit " + ip + ": " + ins + " stack:" + Highlighting.stripHilights(stack.toString()));
System.out.println((indeterminate ? "useV " : "") + (secondPass ? "secondPass " : "") + "Visit " + ip + ": " + ins + " stack:" + stack.toString());
HashMap<Integer, GraphTargetItem> registers = (HashMap<Integer, GraphTargetItem>) localData.get(2);
System.out.print("Registers:");
for (int reg : registers.keySet()) {

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
@@ -34,7 +34,7 @@ public class CodeStats {
public boolean has_activation = false;
public InstructionStats[] instructionStats;
public HilightedTextWriter toString(HilightedTextWriter writer, ABC abc, List<String> fullyQualifiedNames) {
public GraphTextWriter toString(GraphTextWriter writer, ABC abc, List<String> fullyQualifiedNames) {
writer.appendNoHilight("Stats: maxstack=" + maxstack + ", maxscope=" + maxscope + ", maxlocal=" + maxlocal).newLine();
int i = 0;
int ms = 0;

View File

@@ -27,7 +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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphSource;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -265,7 +265,7 @@ public class AVM2Instruction implements Serializable, GraphSourceItem {
return ignored;
}
public HilightedTextWriter toString(HilightedTextWriter writer, LocalData localData) {
public GraphTextWriter toString(GraphTextWriter writer, LocalData localData) {
writer.appendNoHilight(Helper.formatAddress(offset) + " " + Helper.padSpaceRight(Helper.byteArrToString(getBytes()), 30) + definition.instructionName);
writer.appendNoHilight(getParams(localData.constantsAvm2, localData.fullyQualifiedNames) + getComment());
return writer;

View File

@@ -29,7 +29,7 @@ import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import java.io.Serializable;
import java.util.HashMap;
@@ -117,7 +117,7 @@ public class InstructionDefinition implements Serializable {
if (constants.constant_multiname[multinameIndex].needsName()) {
name = stack.get(pos).toString();
} else {
name = HilightedTextWriter.hilighOffset(constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames), ins.offset);
name = GraphTextWriter.hilighOffset(constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames), ins.offset);
}
return name + ns;
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import static com.jpexs.decompiler.graph.GraphTargetItem.PRECEDENCE_PRIMARY;
@@ -38,7 +38,7 @@ public abstract class AVM2Item extends GraphTargetItem {
return true;
}
protected HilightedTextWriter formatProperty(HilightedTextWriter writer, GraphTargetItem object, GraphTargetItem propertyName, LocalData localData) {
protected GraphTextWriter formatProperty(GraphTextWriter writer, GraphTargetItem object, GraphTargetItem propertyName, LocalData localData) {
boolean empty = false;
if (object instanceof LocalRegAVM2Item) {
if (((LocalRegAVM2Item) object).computedValue != null) {

View File

@@ -16,7 +16,7 @@
*/
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -37,7 +37,7 @@ public class AlchemyLoadAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append("op_" + name + "(");
ofs.toString(writer, localData);
return writer.append(") /*Alchemy*/");

View File

@@ -16,7 +16,7 @@
*/
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -36,7 +36,7 @@ public class AlchemySignExtendAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append("op_" + name + "(");
value.toString(writer, localData);
return writer.append(") /*Alchemy*/");

View File

@@ -16,7 +16,7 @@
*/
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -38,7 +38,7 @@ public class AlchemyStoreAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append("op_" + name + "(");
ofs.toString(writer, localData);
writer.append(",");

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
@@ -34,7 +34,7 @@ public class ApplyTypeAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
object.toString(writer, localData);
if (!params.isEmpty()) {
writer.append(".<");

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
public class BooleanAVM2Item extends AVM2Item {
@@ -30,7 +30,7 @@ public class BooleanAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append(value ? "true" : "false");
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
@@ -36,7 +36,7 @@ public class CallAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
/*String recPart = ""; receiver.toString(constants, localRegNames) + writer.append(".");
if (receiver instanceof NewActivationAVM2Item) {
recPart = "";

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
@@ -36,7 +36,7 @@ public class CallMethodAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
receiver.toString(writer, localData);
writer.append(".");
writer.append(methodName);

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
@@ -38,7 +38,7 @@ public class CallPropertyAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
formatProperty(writer, receiver, propertyName, localData);
writer.append("(");
for (int a = 0; a < arguments.size(); a++) {

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
@@ -36,7 +36,7 @@ public class CallStaticAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
receiver.toString(writer, localData);
writer.append(".");
writer.append(methodName);

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
@@ -38,7 +38,7 @@ public class CallSuperAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
if (!receiver.toString().equals("this")) {
receiver.toString(writer, localData);
writer.append(".");

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
public class ClassAVM2Item extends AVM2Item {
@@ -30,7 +30,7 @@ public class ClassAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append(className.getName(localData.constantsAvm2, localData.fullyQualifiedNames));
}
}

View File

@@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -35,7 +35,7 @@ public class CoerceAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
//return hilight("("+type+")", highlight)+
return value.toString(writer, localData);
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
@@ -34,7 +34,7 @@ public class ConstructAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
if (object instanceof NewFunctionAVM2Item) {
writer.append("new ");
return object.toString(writer, localData);

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
@@ -36,7 +36,7 @@ public class ConstructPropAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append("new ");
int idx = writer.getLength();
object.toString(writer, localData);

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
@@ -34,7 +34,7 @@ public class ConstructSuperAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
if (!object.toString().equals("this")) {
object.toString(writer, localData);
writer.append(".");

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -34,7 +34,7 @@ public class ConvertAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return value.toString(writer, localData);
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
public class DecLocalAVM2Item extends AVM2Item {
@@ -30,7 +30,7 @@ public class DecLocalAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append(localRegName(localData.localRegNames, regIndex));
return writer.append("--");
}

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -30,7 +30,7 @@ public class DecrementAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
value.toString(writer, localData);
return writer.append("-1");
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -35,7 +35,7 @@ public class DefaultXMLNamespace extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append("default xml namespace = ");
return ns.toString(writer, localData);
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -33,7 +33,7 @@ public class EscapeXAttrAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append("{");
value.toString(writer, localData);
return writer.append("}");

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -35,7 +35,7 @@ public class EscapeXElemAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append("{");
expression.toString(writer, localData);
return writer.append("}");

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -35,7 +35,7 @@ public class FilteredCheckAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return object.toString(writer, localData);
}
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
public class FindPropertyAVM2Item extends AVM2Item {
@@ -30,7 +30,7 @@ public class FindPropertyAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer;
}
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
public class FloatValueAVM2Item extends NumberValueAVM2Item {
@@ -30,7 +30,7 @@ public class FloatValueAVM2Item extends NumberValueAVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append("" + value);
}

View File

@@ -19,7 +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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.HashMap;
@@ -76,7 +76,7 @@ public class FullMultinameAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
if (namespace != null) {
namespace.toString(writer, localData);
writer.append("::");

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -33,7 +33,7 @@ public class GetDescendantsAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
object.toString(writer, localData);
writer.append("..");
return multiname.toString(writer, localData);

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
public class GetLexAVM2Item extends AVM2Item {
@@ -31,7 +31,7 @@ public class GetLexAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append(propertyName.getName(localData.constantsAvm2, localData.fullyQualifiedNames));
}
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -33,7 +33,7 @@ public class GetPropertyAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return formatProperty(writer, object, propertyName, localData);
}
}

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -34,7 +34,7 @@ public class GetSlotAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
if (slotName == null) {
return writer.append("/*UnknownSlot*/");
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -33,7 +33,7 @@ public class GetSuperAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
if (!object.toString().equals("this")) {
object.toString(writer, localData);
writer.append(".");

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -37,7 +37,7 @@ public class HasNextAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
collection.toString(writer, localData);
writer.append(" hasNext ");
return object.toString(writer, localData);

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -33,7 +33,7 @@ public class InAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
object.toString(writer, localData);
writer.append(" in ");
return collection.toString(writer, localData);

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
public class IncLocalAVM2Item extends AVM2Item {
@@ -30,7 +30,7 @@ public class IncLocalAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append(localRegName(localData.localRegNames, regIndex));
return writer.append("++");
}

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -30,7 +30,7 @@ public class IncrementAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
value.toString(writer, localData);
return writer.append("+1");
}

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -36,7 +36,7 @@ public class InitPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, A
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
formatProperty(writer, object, propertyName, localData);
writer.append(" = ");
return value.toString(writer, localData);

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
public class IntegerValueAVM2Item extends NumberValueAVM2Item {
@@ -30,7 +30,7 @@ public class IntegerValueAVM2Item extends NumberValueAVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append("" + value);
}

View File

@@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -47,7 +47,7 @@ public class LocalRegAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
if (computedValue instanceof FilterAVM2Item) {
return computedValue.toString(writer, localData);
}

View File

@@ -18,7 +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.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
public class NameSpaceAVM2Item extends AVM2Item {
@@ -31,7 +31,7 @@ public class NameSpaceAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
if (namespaceIndex == 0) {
return writer.append("*");
}

View File

@@ -16,7 +16,7 @@
*/
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.decompiler.graph.model.TernarOpItem;
@@ -33,7 +33,7 @@ public class NameValuePair extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
name.toString(writer, localData);
writer.append(":");
if (value instanceof TernarOpItem) { //Ternar operator contains ":"

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
public class NanAVM2Item extends AVM2Item {
@@ -27,7 +27,7 @@ public class NanAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append("NaN");
}
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.HashMap;
@@ -31,7 +31,7 @@ public class NewActivationAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append("newactivation()");
}
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
@@ -32,7 +32,7 @@ public class NewArrayAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append("[");
for (int a = 0; a < values.size(); a++) {
if (a > 0) {

View File

@@ -22,7 +22,8 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.construction.NewFunctionIns;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -59,7 +60,7 @@ public class NewFunctionAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
MethodBody body = abc.findBody(methodIndex);
writer.append("function" + (!functionName.equals("") ? " " + functionName : ""));
writer.startMethod(methodIndex);
@@ -72,7 +73,11 @@ public class NewFunctionAVM2Item extends AVM2Item {
writer.append("{").newLine();
if (body != null) {
try {
body.toString(path + "/inner", ExportMode.SOURCE, isStatic, scriptIndex, classIndex, abc, null, constants, methodInfo, new Stack<GraphTargetItem>()/*scopeStack*/, false, writer, fullyQualifiedNames, null);
if (writer instanceof NulWriter) {
body.convert(path + "/inner", ExportMode.SOURCE, isStatic, scriptIndex, classIndex, abc, null, constants, methodInfo, new Stack<GraphTargetItem>()/*scopeStack*/, false, fullyQualifiedNames, null);
} else {
body.toString(path + "/inner", ExportMode.SOURCE, isStatic, scriptIndex, classIndex, abc, null, constants, methodInfo, new Stack<GraphTargetItem>()/*scopeStack*/, false, writer, fullyQualifiedNames, null);
}
} catch (Exception ex) {
Logger.getLogger(NewFunctionIns.class.getName()).log(Level.SEVERE, "error during newfunction", ex);
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
@@ -31,7 +31,7 @@ public class NewObjectAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
boolean singleLine = pairs.size() < 2;
if (!singleLine) {
writer.newLine();

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -37,7 +37,7 @@ public class NextNameAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append("nextName(");
index.toString(writer, localData);
writer.append(",");

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -37,7 +37,7 @@ public class NextValueAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append("nextValue(");
index.toString(writer, localData);
writer.append(",");

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.ecma.Null;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
public class NullAVM2Item extends AVM2Item {
@@ -28,7 +28,7 @@ public class NullAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append("null");
}

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -32,7 +32,7 @@ public class PostDecrementAVM2Item extends AVM2Item implements AssignmentAVM2Ite
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
object.toString(writer, localData);
return writer.append("--");
}

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -32,7 +32,7 @@ public class PostIncrementAVM2Item extends AVM2Item implements AssignmentAVM2Ite
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
object.toString(writer, localData);
return writer.append("++");
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.ExitItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -31,7 +31,7 @@ public class ReturnValueAVM2Item extends AVM2Item implements ExitItem {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append("return ");
return value.toString(writer, localData);
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.ExitItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -28,7 +28,7 @@ public class ReturnVoidAVM2Item extends AVM2Item implements ExitItem {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append("return");
}
}

View File

@@ -16,7 +16,7 @@
*/
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
/**
@@ -33,7 +33,7 @@ public class ScriptAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append("script" + scriptIndex);
}
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphPart;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -39,7 +39,7 @@ public class SetGlobalSlotAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append("setglobalslot(" + slotId + ",");
value.toString(writer, localData);
return writer.append(")");

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -34,7 +34,7 @@ public class SetLocalAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assig
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append(localRegName(localData.localRegNames, regIndex) + " = ");
return value.toString(writer, localData);
}

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphPart;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -42,7 +42,7 @@ public class SetPropertyAVM2Item extends AVM2Item implements SetTypeAVM2Item, As
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
formatProperty(writer, object, propertyName, localData);
writer.append(" = ");
return value.toString(writer, localData);

View File

@@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphPart;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -43,13 +43,13 @@ public class SetSlotAVM2Item extends AVM2Item implements SetTypeAVM2Item, Assign
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
getName(writer, localData);
writer.append(" = ");
return value.toString(writer, localData);
}
public HilightedTextWriter getName(HilightedTextWriter writer, LocalData localData) {
public GraphTextWriter getName(GraphTextWriter writer, LocalData localData) {
/*ret = scope.toString(constants, localRegNames) + ".";
if (!(scope instanceof NewActivationAVM2Item)) {
ret = scope.toString(constants, localRegNames) + ".";

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphPart;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -41,7 +41,7 @@ public class SetSuperAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
if (!object.toString().equals("this")) {
object.toString(writer, localData);
writer.append(".");

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.helpers.Helper;
@@ -31,7 +31,7 @@ public class StringAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append("\"" + Helper.escapeString(value) + "\"");
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
public class ThisAVM2Item extends AVM2Item {
@@ -35,7 +35,7 @@ public class ThisAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append("this");
}
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -30,7 +30,7 @@ public class ThrowAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append("throw ");
return value.toString(writer, localData);
}

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
public class UndefinedAVM2Item extends AVM2Item {
@@ -28,7 +28,7 @@ public class UndefinedAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append("undefined");
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
public class UnparsedAVM2Item extends AVM2Item {
@@ -30,7 +30,7 @@ public class UnparsedAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append(value);
}
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.ArrayList;
@@ -41,7 +41,7 @@ public class WithAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append("with(");
scope.toString(writer, localData);
writer.append(")").newLine();

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -31,7 +31,7 @@ public class WithEndAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append("}");
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -31,7 +31,7 @@ public class WithObjectAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer;
}
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import java.util.List;
@@ -36,7 +36,7 @@ public class XMLAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
for (GraphTargetItem part : parts) {
if (part instanceof StringAVM2Item) {
writer.append(((StringAVM2Item) part).value);

View File

@@ -17,11 +17,12 @@
package com.jpexs.decompiler.flash.abc.avm2.model.clauses;
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
import static com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item.localRegName;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -45,7 +46,7 @@ public class DeclarationAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
if (assignment instanceof SetLocalAVM2Item) {
SetLocalAVM2Item lti = (SetLocalAVM2Item) assignment;
String type = "*";

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.clauses;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.model.LocalData;
public class ExceptionAVM2Item extends AVM2Item {
@@ -31,7 +31,7 @@ public class ExceptionAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
return writer.append(exception.getVarName(localData.constantsAvm2, localData.fullyQualifiedNames));
}
}

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.clauses;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -38,7 +38,7 @@ public class FilterAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
collection.toString(writer, localData);
writer.append(".(");
expression.toString(writer, localData);

View File

@@ -19,8 +19,9 @@ 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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.LoopWithType;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import com.jpexs.decompiler.graph.Block;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -35,6 +36,7 @@ public class ForEachInAVM2Item extends LoopItem implements Block {
public InAVM2Item expression;
public List<GraphTargetItem> commands;
private boolean labelUsed;
@Override
public List<List<GraphTargetItem>> getSubs() {
@@ -70,9 +72,13 @@ public class ForEachInAVM2Item extends LoopItem implements Block {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
writer.startLoop(loop.id, LoopWithType.LOOP_TYPE_LOOP);
writer.append("loop" + loop.id + ":").newLine();
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
if (writer instanceof NulWriter) {
((NulWriter)writer).startLoop(loop.id, LoopWithType.LOOP_TYPE_LOOP);
}
if (labelUsed) {
writer.append("loop" + loop.id + ":").newLine();
}
writer.append("for each (");
expression.toString(writer, localData);
writer.append(")").newLine();
@@ -85,8 +91,10 @@ public class ForEachInAVM2Item extends LoopItem implements Block {
}
writer.unindent();
writer.append("}").newLine();
writer.append(":loop" + loop.id);
writer.endLoop(loop.id);
if (writer instanceof NulWriter) {
LoopWithType loopOjb = ((NulWriter)writer).endLoop(loop.id);
labelUsed = loopOjb.used;
}
return writer;
}

View File

@@ -19,8 +19,9 @@ 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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.LoopWithType;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import com.jpexs.decompiler.graph.Block;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -35,6 +36,7 @@ public class ForInAVM2Item extends LoopItem implements Block {
public InAVM2Item expression;
public List<GraphTargetItem> commands;
private boolean labelUsed;
@Override
public List<List<GraphTargetItem>> getSubs() {
@@ -70,9 +72,13 @@ public class ForInAVM2Item extends LoopItem implements Block {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
writer.startLoop(loop.id, LoopWithType.LOOP_TYPE_LOOP);
writer.append("loop" + loop.id + ":").newLine();
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
if (writer instanceof NulWriter) {
((NulWriter)writer).startLoop(loop.id, LoopWithType.LOOP_TYPE_LOOP);
}
if (labelUsed) {
writer.append("loop" + loop.id + ":").newLine();
}
writer.append("for (");
expression.toString(writer, localData);
writer.append(")").newLine();
@@ -85,8 +91,10 @@ public class ForInAVM2Item extends LoopItem implements Block {
}
writer.unindent();
writer.append("}").newLine();
writer.append(":loop" + loop.id);
writer.endLoop(loop.id);
if (writer instanceof NulWriter) {
LoopWithType loopOjb = ((NulWriter)writer).endLoop(loop.id);
labelUsed = loopOjb.used;
}
return writer;
}

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.model.clauses;
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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.Block;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.ContinueItem;
@@ -51,7 +51,7 @@ public class TryAVM2Item extends AVM2Item implements Block {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append("try").newLine();
writer.append("{").newLine();
writer.indent();

View File

@@ -19,7 +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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -31,7 +31,7 @@ public class AddAVM2Item extends BinaryOpItem {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
if (rightSide.precedence >= precedence) { //string + vs number +
if (leftSide.precedence > precedence) {
writer.append("(");

View File

@@ -19,7 +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.abc.avm2.model.AVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -35,7 +35,7 @@ public class DeletePropertyAVM2Item extends AVM2Item {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append("delete ");
object.toString(writer, localData);
writer.append("[");

View File

@@ -18,7 +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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.BinaryOpItem;
import com.jpexs.decompiler.graph.model.LocalData;
@@ -35,7 +35,7 @@ public class SubtractAVM2Item extends BinaryOpItem {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
if (rightSide.precedence >= precedence) { // >= add or subtract too
if (leftSide.precedence > precedence) {
writer.append("(");

View File

@@ -407,6 +407,7 @@ public class ASM3Parser {
/*case ParsedSymbol.TYPE_KEYWORD_DECIMAL:
value_kind = ValueKind.CONSTANT_Decimal;
break;*/
case ParsedSymbol.TYPE_STRING:
case ParsedSymbol.TYPE_KEYWORD_UTF8:
value_kind = ValueKind.CONSTANT_Utf8;
expected(ParsedSymbol.TYPE_PARENT_OPEN, "(", lexer);

View File

@@ -23,11 +23,13 @@ import com.jpexs.decompiler.flash.abc.avm2.CodeStats;
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.action.Action;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.model.LocalData;
import com.jpexs.helpers.Helper;
import java.io.Serializable;
import java.util.ArrayList;
@@ -53,7 +55,9 @@ public class MethodBody implements Cloneable, Serializable {
public AVM2Code code;
public ABCException[] exceptions = new ABCException[0];
public Traits traits = new Traits();
public transient List<GraphTargetItem> convertedItems;
public transient Exception convertException;
public List<Integer> getExceptionEntries() {
List<Integer> ret = new ArrayList<>();
for (ABCException e : exceptions) {
@@ -110,18 +114,41 @@ public class MethodBody implements Cloneable, Serializable {
return ret;
}
public String toString(final String path, ExportMode exportMode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final MethodInfo[] method_info, final Stack<GraphTargetItem> scopeStack, final boolean isStaticInitializer, final List<String> fullyQualifiedNames, final Traits initTraits) {
public HilightedTextWriter toString(final String path, ExportMode exportMode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final MethodInfo[] method_info, final Stack<GraphTargetItem> scopeStack, final boolean isStaticInitializer, final List<String> fullyQualifiedNames, final Traits initTraits) {
convert(path, exportMode, isStatic, scriptIndex, classIndex, abc, trait, constants, method_info, scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits);
HilightedTextWriter writer = new HilightedTextWriter(false);
toString(path, exportMode, isStatic, scriptIndex, classIndex, abc, trait, constants, method_info, scopeStack, isStaticInitializer, writer, fullyQualifiedNames, initTraits);
String src = writer.toString();
src = Graph.removeNonRefenrencedLoopLabels(src, false);
return src;
return writer;
}
public HilightedTextWriter toString(final String path, ExportMode exportMode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final MethodInfo[] method_info, final Stack<GraphTargetItem> scopeStack, final boolean isStaticInitializer, final HilightedTextWriter writer, final List<String> fullyQualifiedNames, final Traits initTraits) {
public void convert(final String path, ExportMode exportMode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final MethodInfo[] method_info, final Stack<GraphTargetItem> scopeStack, final boolean isStaticInitializer, final List<String> fullyQualifiedNames, final Traits initTraits) {
if (debugMode) {
System.err.println("Decompiling " + path);
}
if (exportMode == ExportMode.SOURCE) {
int timeout = Configuration.getConfig("decompilationTimeoutSingleMethod", 60);
try {
Helper.timedCall(new Callable<Void>() {
@Override
public Void call() throws Exception {
MethodBody converted = convertMethodBody(path, isStatic, scriptIndex, classIndex, abc, trait, constants, method_info, scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits);
HashMap<Integer, String> localRegNames = getLocalRegNames(abc);
convertedItems = converted.code.toGraphTargetItems(path, isStatic, scriptIndex, classIndex, abc, constants, method_info, converted, localRegNames, scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits, Graph.SOP_USE_STATIC, new HashMap<Integer, Integer>(), converted.code.visitCode(converted));
Graph.graphToString(convertedItems, new NulWriter(), LocalData.create(constants, localRegNames, fullyQualifiedNames));
return null;
}
}, timeout, TimeUnit.SECONDS);
} catch (InterruptedException | TimeoutException | ExecutionException ex) {
Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Decompilation error", ex);
convertException = ex;
if (ex instanceof ExecutionException && ex.getCause() instanceof Exception) {
convertException = (Exception) ex.getCause();
}
}
}
}
public GraphTextWriter toString(final String path, ExportMode exportMode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final MethodInfo[] method_info, final Stack<GraphTargetItem> scopeStack, final boolean isStaticInitializer, final GraphTextWriter writer, final List<String> fullyQualifiedNames, final Traits initTraits) {
if (exportMode != ExportMode.SOURCE) {
writer.indent();
code.toASMSource(constants, trait, method_info[this.method_info], this, exportMode, writer);
@@ -137,33 +164,36 @@ public class MethodBody implements Cloneable, Serializable {
}
writer.indent();
int timeout = Configuration.getConfig("decompilationTimeoutSingleMethod", 60);
int writerPos = writer.getLength();
try {
Helper.timedCall(new Callable<Void>() {
@Override
public Void call() throws Exception {
toSource(path, isStatic, scriptIndex, classIndex, abc, trait, constants, method_info, scopeStack, isStaticInitializer, writer, fullyQualifiedNames, initTraits);
return null;
}
}, timeout, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException ex) {
Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error", ex);
writer.setLength(writerPos); // remove already rendered code
if (convertException == null) {
HashMap<Integer, String> localRegNames = getLocalRegNames(abc);
writer.startMethod(this.method_info);
Graph.graphToString(convertedItems, writer, LocalData.create(constants, localRegNames, fullyQualifiedNames));
writer.endMethod();
} else if (convertException instanceof TimeoutException) {
Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Decompilation error", convertException);
writer.appendNoHilight("/*").newLine();
writer.appendNoHilight(" * Decompilation error").newLine();
writer.appendNoHilight(" * Timeout (" + Helper.formatTimeToText(timeout) + ") was reached").newLine();
writer.appendNoHilight(" */").newLine();
writer.appendNoHilight("throw new IllegalOperationError(\"Not decompiled due to timeout\");").newLine();
} else {
Logger.getLogger(MethodBody.class.getName()).log(Level.SEVERE, "Decompilation error", convertException);
writer.appendNoHilight("/*").newLine();
writer.appendNoHilight(" * Decompilation error").newLine();
writer.appendNoHilight(" * Code may be obfuscated").newLine();
writer.appendNoHilight(" * Error type: " + convertException.getClass().getSimpleName()).newLine();
writer.appendNoHilight(" */").newLine();
writer.appendNoHilight("throw new IllegalOperationError(\"Not decompiled due to error\");").newLine();
}
writer.unindent();
}
return writer;
}
public HilightedTextWriter toSource(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, Trait trait, ConstantPool constants, MethodInfo[] method_info, Stack<GraphTargetItem> scopeStack, boolean isStaticInitializer, HilightedTextWriter writer, List<String> fullyQualifiedNames, Traits initTraits) {
AVM2Code deobfuscated = null;
public MethodBody convertMethodBody(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, Trait trait, ConstantPool constants, MethodInfo[] method_info, Stack<GraphTargetItem> scopeStack, boolean isStaticInitializer, List<String> fullyQualifiedNames, Traits initTraits) {
MethodBody b = (MethodBody) Helper.deepCopy(this);
deobfuscated = b.code;
AVM2Code deobfuscated = b.code;
deobfuscated.markMappedOffsets();
if (Configuration.getConfig("autoDeobfuscate", true)) {
try {
@@ -174,10 +204,7 @@ public class MethodBody implements Cloneable, Serializable {
}
//deobfuscated.restoreControlFlow(constants, b);
writer.startMethod(this.method_info);
deobfuscated.toSource(path, isStatic, scriptIndex, classIndex, abc, constants, method_info, b, writer, getLocalRegNames(abc), scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits, Graph.SOP_USE_STATIC, new HashMap<Integer, Integer>(), deobfuscated.visitCode(b));
writer.endMethod();
return writer;
return b;
}
@Override

View File

@@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.abc.types;
import com.jpexs.decompiler.flash.Configuration;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.helpers.Helper;
import java.util.HashMap;
import java.util.List;
@@ -242,7 +242,7 @@ public class MethodInfo {
return constants.constant_string[name_index];
}
public HilightedTextWriter getParamStr(HilightedTextWriter writer, ConstantPool constants, MethodBody body, ABC abc, List<String> fullyQualifiedNames) {
public GraphTextWriter getParamStr(GraphTextWriter writer, ConstantPool constants, MethodBody body, ABC abc, List<String> fullyQualifiedNames) {
HashMap<Integer, String> localRegNames = new HashMap<>();
if (body != null) {
localRegNames = body.code.getLocalRegNamesFromDebug(abc);
@@ -288,7 +288,7 @@ public class MethodInfo {
return writer;
}
public HilightedTextWriter getReturnTypeStr(HilightedTextWriter writer, ConstantPool constants, List<String> fullyQualifiedNames) {
public GraphTextWriter getReturnTypeStr(GraphTextWriter writer, ConstantPool constants, List<String> fullyQualifiedNames) {
return writer.hilightSpecial(ret_type == 0 ? "*" : constants.constant_multiname[ret_type].getName(constants, fullyQualifiedNames), "returns");
}

View File

@@ -21,10 +21,7 @@ import com.jpexs.decompiler.flash.abc.ClassPath;
import com.jpexs.decompiler.flash.abc.ScriptPack;
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.collections.MyEntry;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
import java.util.ArrayList;
import java.util.List;
@@ -80,8 +77,4 @@ public class ScriptInfo {
public String toString(ABC abc, List<String> fullyQualifiedNames) {
return "method_index=" + init_index + "\r\n" + traits.toString(abc, fullyQualifiedNames);
}
public HilightedTextWriter convert(List<ABCContainerTag> abcTags, ABC abc, ExportMode exportMode, HilightedTextWriter writer, int scriptIndex, boolean parallel) {
return traits.convert(null, "", abcTags, abc, false, exportMode, true, scriptIndex, -1, writer, new ArrayList<String>(), parallel);
}
}

View File

@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.types.traits;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
@@ -116,19 +117,22 @@ public abstract class Trait implements Serializable {
return abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata);
}
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
public GraphTextWriter toString(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
writer.appendNoHilight(abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata));
return writer;
}
public HilightedTextWriter convertPackaged(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
public void convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List<String> fullyQualifiedNames, boolean parallel) {
}
public GraphTextWriter toStringPackaged(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
Namespace ns = abc.constants.constant_multiname[name_index].getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
String nsname = ns.getName(abc.constants);
writer.appendNoHilight("package " + nsname).newLine();
writer.appendNoHilight("{").newLine();
writer.indent();
convert(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
toString(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
writer.newLine();
writer.unindent();
writer.appendNoHilight("}");
@@ -136,11 +140,23 @@ public abstract class Trait implements Serializable {
return writer;
}
public HilightedTextWriter convertHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
convert(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
public void convertPackaged(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List<String> fullyQualifiedNames, boolean parallel) {
Namespace ns = abc.constants.constant_multiname[name_index].getNamespace(abc.constants);
if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) {
String nsname = ns.getName(abc.constants);
convert(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, fullyQualifiedNames, parallel);
}
}
public GraphTextWriter toStringHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
toString(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
return writer;
}
public void convertHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List<String> fullyQualifiedNames, boolean parallel) {
convert(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, fullyQualifiedNames, parallel);
}
public Multiname getName(ABC abc) {
if (name_index == 0) {
return null;
@@ -174,10 +190,10 @@ public abstract class Trait implements Serializable {
}
String fileName = outDir.toString() + File.separator + objectName + ".as";
try (FileOutputStream fos = new FileOutputStream(fileName)) {
convertPackaged(parent, "", abcList, abc, isStatic, exportMode, scriptIndex, classIndex, new ArrayList<String>(), parallel);
HilightedTextWriter writer = new HilightedTextWriter(false);
convertPackaged(parent, "", abcList, abc, isStatic, exportMode, scriptIndex, classIndex, writer, new ArrayList<String>(), parallel);
String s = Graph.removeNonRefenrencedLoopLabels(writer.toString(), false);
fos.write(s.getBytes("utf-8"));
toStringPackaged(parent, "", abcList, abc, isStatic, exportMode, scriptIndex, classIndex, writer, new ArrayList<String>(), parallel);
fos.write(writer.toString().getBytes("utf-8"));
}
}
}

View File

@@ -31,7 +31,7 @@ import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.abc.types.NamespaceSet;
import com.jpexs.decompiler.flash.abc.types.ScriptInfo;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -323,13 +323,17 @@ public class TraitClass extends Trait implements TraitWithSlot {
}
@Override
public HilightedTextWriter convertHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
public GraphTextWriter toStringHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
String classHeader = abc.instance_info[class_info].getClassHeaderStr(abc, fullyQualifiedNames);
return writer.appendNoHilight(classHeader);
}
@Override
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
public void convertHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List<String> fullyQualifiedNames, boolean parallel) {
}
@Override
public GraphTextWriter toString(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
writer.startClass(class_info);
String packageName = abc.instance_info[class_info].getName(abc.constants).getNamespace(abc.constants).getName(abc.constants);
@@ -477,9 +481,9 @@ public class TraitClass extends Trait implements TraitWithSlot {
}
//static variables,constants & methods
abc.class_info[class_info].static_traits.convert(this, path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
abc.class_info[class_info].static_traits.toString(this, path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, true, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
abc.instance_info[class_info].instance_traits.convert(this, path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
abc.instance_info[class_info].instance_traits.toString(this, path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, false, exportMode, false, scriptIndex, class_info, writer, fullyQualifiedNames, parallel);
writer.unindent();
writer.appendNoHilight("}"); // class
@@ -487,6 +491,30 @@ public class TraitClass extends Trait implements TraitWithSlot {
return writer;
}
@Override
public void convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List<String> fullyQualifiedNames, boolean parallel) {
fullyQualifiedNames = new ArrayList<>();
int bodyIndex = abc.findBodyIndex(abc.class_info[class_info].cinit_index);
if (bodyIndex != -1) {
abc.bodies[bodyIndex].convert(path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", exportMode, true, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), true, fullyQualifiedNames, abc.class_info[class_info].static_traits);
}
//constructor
if (!abc.instance_info[class_info].isInterface()) {
bodyIndex = abc.findBodyIndex(abc.instance_info[class_info].iinit_index);
if (bodyIndex != -1) {
abc.bodies[bodyIndex].convert(path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", exportMode, false, scriptIndex, class_info, abc, this, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, fullyQualifiedNames, abc.instance_info[class_info].instance_traits);
}
}
//static variables,constants & methods
abc.class_info[class_info].static_traits.convert(this, path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, true, exportMode, false, scriptIndex, class_info, fullyQualifiedNames, parallel);
abc.instance_info[class_info].instance_traits.convert(this, path +/*packageName +*/ "/" + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, false, exportMode, false, scriptIndex, class_info, fullyQualifiedNames, parallel);
}
@Override
public Multiname getName(ABC abc) {
return abc.constants.constant_multiname[abc.instance_info[class_info].name_index];

View File

@@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.types.traits;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -42,7 +42,7 @@ public class TraitFunction extends Trait implements TraitWithSlot {
}
@Override
public HilightedTextWriter convertHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
public GraphTextWriter toStringHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
String modifier = getModifiers(abcTags, abc, isStatic) + " ";
MethodBody body = abc.findBody(method_info);
if (body == null) {
@@ -62,8 +62,12 @@ public class TraitFunction extends Trait implements TraitWithSlot {
}
@Override
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
convertHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
public void convertHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List<String> fullyQualifiedNames, boolean parallel) {
}
@Override
public GraphTextWriter toString(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
toStringHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
if (abc.instance_info[classIndex].isInterface()) {
writer.appendNoHilight(";");
} else {
@@ -78,6 +82,17 @@ public class TraitFunction extends Trait implements TraitWithSlot {
return writer;
}
@Override
public void convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List<String> fullyQualifiedNames, boolean parallel) {
convertHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, fullyQualifiedNames, parallel);
if (!abc.instance_info[classIndex].isInterface()) {
int bodyIndex = abc.findBodyIndex(method_info);
if (bodyIndex != -1) {
abc.bodies[bodyIndex].convert(path + "." + abc.constants.constant_multiname[name_index].getName(abc.constants, fullyQualifiedNames), exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, fullyQualifiedNames, null);
}
}
}
@Override
public int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc, String path) {
int bodyIndex = abc.findBodyIndex(method_info);

View File

@@ -18,6 +18,9 @@ package com.jpexs.decompiler.flash.abc.types.traits;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import static com.jpexs.decompiler.flash.abc.types.traits.Trait.TRAIT_GETTER;
import static com.jpexs.decompiler.flash.abc.types.traits.Trait.TRAIT_SETTER;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
@@ -37,7 +40,11 @@ public class TraitMethodGetterSetter extends Trait {
}
@Override
public HilightedTextWriter convertHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
public void convertHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List<String> fullyQualifiedNames, boolean parallel) {
}
@Override
public GraphTextWriter toStringHeader(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
String modifier = getModifiers(abcTags, abc, isStatic) + " ";
if (modifier.equals(" ")) {
modifier = "";
@@ -66,15 +73,28 @@ public class TraitMethodGetterSetter extends Trait {
}
@Override
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
convertHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
public void convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List<String> fullyQualifiedNames, boolean parallel) {
path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames);
convertHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, fullyQualifiedNames, parallel);
int bodyIndex = abc.findBodyIndex(method_info);
if (!(classIndex != -1 && abc.instance_info[classIndex].isInterface() || bodyIndex == -1)) {
if (bodyIndex != -1) {
abc.bodies[bodyIndex].convert(path, exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, fullyQualifiedNames, null);
}
}
}
@Override
public GraphTextWriter toString(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
path = path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames);
toStringHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
int bodyIndex = abc.findBodyIndex(method_info);
if (classIndex != -1 && abc.instance_info[classIndex].isInterface() || bodyIndex == -1) {
writer.appendNoHilight(";");
} else {
writer.appendNoHilight(" {").newLine();
if (bodyIndex != -1) {
abc.bodies[bodyIndex].toString(path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames), exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, writer, fullyQualifiedNames, null);
abc.bodies[bodyIndex].toString(path, exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new Stack<GraphTargetItem>(), false, writer, fullyQualifiedNames, null);
}
writer.appendNoHilight("}");
}

View File

@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.abc.types.ValueKind;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
@@ -60,7 +61,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
return typeStr;
}
public HilightedTextWriter getNameStr(HilightedTextWriter writer, ABC abc, List<String> fullyQualifiedNames) {
public GraphTextWriter getNameStr(GraphTextWriter writer, ABC abc, List<String> fullyQualifiedNames) {
String typeStr = getType(abc.constants, fullyQualifiedNames);
if (typeStr.equals("*")) {
typeStr = "";
@@ -85,7 +86,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
return writer;
}
public boolean getValueStr(Trait parent, HilightedTextWriter writer, ABC abc, List<String> fullyQualifiedNames) {
public void getValueStr(Trait parent, GraphTextWriter writer, ABC abc, List<String> fullyQualifiedNames) {
if (assignedValue != null) {
if (parent instanceof TraitClass) {
TraitClass tc = (TraitClass) parent;
@@ -100,28 +101,13 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
writer.endMethod();
writer.endTrait();
}
return true;
return;
}
if (value_kind != 0) {
ValueKind val = new ValueKind(value_index, value_kind);
writer.hilightSpecial(val.toString(abc.constants), "traitvalue");
return true;
}
return false;
}
public String getNameValueStr(Trait parent, ABC abc, List<String> fullyQualifiedNames) {
HilightedTextWriter writer = new HilightedTextWriter(false);
getNameStr(writer, abc, fullyQualifiedNames);
writer.appendNoHilight(" = ");
boolean hasValue = getValueStr(parent, writer, abc, fullyQualifiedNames);
if (!hasValue) {
writer.removeFromEnd(3);
}
writer.appendNoHilight(";");
return writer.toString();
}
public boolean isNamespace() {
@@ -133,7 +119,7 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
}
@Override
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
public GraphTextWriter toString(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
String modifier = getModifiers(abcTags, abc, isStatic) + " ";
if (modifier.equals(" ")) {
modifier = "";
@@ -155,14 +141,17 @@ public class TraitSlotConst extends Trait implements TraitWithSlot {
}
writer.appendNoHilight(modifier);
getNameStr(writer, abc, fullyQualifiedNames);
writer.appendNoHilight(" = ");
boolean hasValue = getValueStr(parent, writer, abc, fullyQualifiedNames);
if (!hasValue) {
writer.removeFromEnd(3);
if (assignedValue != null || value_kind != 0) {
writer.appendNoHilight(" = ");
getValueStr(parent, writer, abc, fullyQualifiedNames);
}
return writer.appendNoHilight(";");
}
@Override
public void convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List<String> fullyQualifiedNames, boolean parallel) {
}
public boolean isConst() {
return kindType == TRAIT_CONST;
}

View File

@@ -17,7 +17,7 @@
package com.jpexs.decompiler.flash.abc.types.traits;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.graph.ExportMode;
import java.io.Serializable;
@@ -73,7 +73,7 @@ public class Traits implements Serializable {
return s;
}
private class TraitConvertTask implements Callable<HilightedTextWriter> {
private class TraitConvertTask implements Callable<Void> {
Trait trait;
boolean makePackages;
@@ -84,13 +84,12 @@ public class Traits implements Serializable {
ExportMode exportMode;
int scriptIndex;
int classIndex;
HilightedTextWriter writer;
List<String> fullyQualifiedNames;
int traitIndex;
boolean parallel;
Trait parent;
public TraitConvertTask(Trait trait, Trait parent, boolean makePackages, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, int traitIndex, boolean parallel) {
public TraitConvertTask(Trait trait, Trait parent, boolean makePackages, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List<String> fullyQualifiedNames, int traitIndex, boolean parallel) {
this.trait = trait;
this.parent = parent;
this.makePackages = makePackages;
@@ -101,74 +100,86 @@ public class Traits implements Serializable {
this.exportMode = exportMode;
this.scriptIndex = scriptIndex;
this.classIndex = classIndex;
this.writer = writer;
this.fullyQualifiedNames = fullyQualifiedNames;
this.traitIndex = traitIndex;
this.parallel = parallel;
}
@Override
public HilightedTextWriter call() {
public Void call() {
int h = traitIndex;
if (classIndex != -1) {
if (!isStatic) {
h = h + abc.class_info[classIndex].static_traits.traits.length;
}
}
if (makePackages) {
trait.convertPackaged(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, fullyQualifiedNames, parallel);
} else {
trait.convert(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, fullyQualifiedNames, parallel);
}
return null;
}
}
public GraphTextWriter toString(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, GraphTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
for (int t = 0; t < traits.length; t++) {
if (t > 0) {
writer.newLine();
}
Trait trait = traits[t];
int h = t;
if (classIndex != -1) {
if (!isStatic) {
h = h + abc.class_info[classIndex].static_traits.traits.length;
}
}
if (trait instanceof TraitClass) {
writer.startClass(((TraitClass) trait).class_info);
} else {
writer.startTrait(h);
}
if (makePackages) {
trait.convertPackaged(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
trait.toStringPackaged(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
} else {
trait.convert(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
trait.toString(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel);
}
if (trait instanceof TraitClass) {
writer.endClass();
} else {
writer.endTrait();
}
return writer;
writer.newLine();
}
return writer;
}
public HilightedTextWriter convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, HilightedTextWriter writer, List<String> fullyQualifiedNames, boolean parallel) {
public void convert(Trait parent, String path, List<ABCContainerTag> abcTags, ABC abc, boolean isStatic, ExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, List<String> fullyQualifiedNames, boolean parallel) {
if (!parallel || traits.length < 2) {
for (int t = 0; t < traits.length; t++) {
if (t > 0) {
writer.newLine();
}
TraitConvertTask task = new TraitConvertTask(traits[t], parent, makePackages, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, t, parallel);
TraitConvertTask task = new TraitConvertTask(traits[t], parent, makePackages, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, fullyQualifiedNames, t, parallel);
task.call();
writer.newLine();
}
} else {
ExecutorService executor = Executors.newFixedThreadPool(20);
List<Future<HilightedTextWriter>> futureResults = null;
List<Future<Void>> futureResults = null;
futureResults = new ArrayList<>();
for (int t = 0; t < traits.length; t++) {
HilightedTextWriter writer2 = new HilightedTextWriter(writer.getIsHighlighted(), writer.getIndent());
TraitConvertTask task = new TraitConvertTask(traits[t], parent, makePackages, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer2, fullyQualifiedNames, t, parallel);
Future<HilightedTextWriter> future = executor.submit(task);
TraitConvertTask task = new TraitConvertTask(traits[t], parent, makePackages, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, fullyQualifiedNames, t, parallel);
Future<Void> future = executor.submit(task);
futureResults.add(future);
}
for (int f = 0; f < futureResults.size(); f++) {
if (f > 0) {
writer.newLine();
}
try {
HilightedTextWriter taskResult = futureResults.get(f).get();
writer.appendWithoutIndent(taskResult.toString());
futureResults.get(f).get();
} catch (InterruptedException | ExecutionException ex) {
Logger.getLogger(Traits.class.getName()).log(Level.SEVERE, "Error during traits converting", ex);
}
}
executor.shutdown();
}
return writer;
}
}

View File

@@ -38,16 +38,25 @@ public abstract class ConstVarMultinameUsage extends TraitMultinameUsage {
@Override
public String toString(List<ABCContainerTag> abcTags, ABC abc) {
if (parentTraitIndex > -1) {
if (isStatic) {
((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, new ArrayList<String>(), false);
} else {
((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, new ArrayList<String>(), false);
}
}
HilightedTextWriter writer = new HilightedTextWriter(false);
writer.appendNoHilight(super.toString(abcTags, abc) + " ");
if (parentTraitIndex > -1) {
if (isStatic) {
((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
} else {
((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
}
}
((TraitSlotConst) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
((TraitSlotConst) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, new ArrayList<String>(), false);
((TraitSlotConst) traits.traits[traitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
return writer.toString();
}

View File

@@ -44,6 +44,17 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage {
@Override
public String toString(List<ABCContainerTag> abcTags, ABC abc) {
if (!isInitializer) {
if (parentTraitIndex > -1) {
if (isStatic){
((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, new ArrayList<String>(), false);
} else {
((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, new ArrayList<String>(), false);
}
}
((TraitMethodGetterSetter) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, new ArrayList<String>(), false);
}
HilightedTextWriter writer = new HilightedTextWriter(false);
writer.appendNoHilight(super.toString(abcTags, abc));
writer.appendNoHilight(" ");
@@ -56,13 +67,13 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage {
} else {
if (parentTraitIndex > -1) {
if (isStatic){
((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
} else {
((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
}
writer.appendNoHilight(" ");
}
((TraitMethodGetterSetter) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
((TraitMethodGetterSetter) traits.traits[traitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList<String>(), false);
}
return writer.toString();
}

View File

@@ -43,12 +43,14 @@ import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol;
import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser;
import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer;
import com.jpexs.decompiler.flash.action.special.ActionEnd;
import com.jpexs.decompiler.flash.action.special.ActionNop;
import com.jpexs.decompiler.flash.action.swf4.*;
import com.jpexs.decompiler.flash.action.swf5.*;
import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2;
import com.jpexs.decompiler.flash.ecma.Null;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.flash.helpers.HilightedText;
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
import com.jpexs.decompiler.flash.helpers.NulWriter;
import com.jpexs.decompiler.flash.helpers.collections.MyEntry;
import com.jpexs.decompiler.graph.ExportMode;
import com.jpexs.decompiler.graph.Graph;
@@ -66,6 +68,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
@@ -388,7 +391,7 @@ public class Action implements GraphSourceItem {
* @param path
* @return HilightedTextWriter
*/
public static HilightedTextWriter actionsToString(List<DisassemblyListener> listeners, long address, List<Action> list, List<Long> importantOffsets, int version, ExportMode exportMode, HilightedTextWriter writer, long swfPos, String path) {
public static GraphTextWriter actionsToString(List<DisassemblyListener> listeners, long address, List<Action> list, List<Long> importantOffsets, int version, ExportMode exportMode, GraphTextWriter writer, long swfPos, String path) {
return actionsToString(listeners, address, list, importantOffsets, new ArrayList<String>(), version, exportMode, writer, swfPos, path);
}
@@ -406,7 +409,7 @@ public class Action implements GraphSourceItem {
* @param path
* @return HilightedTextWriter
*/
private static HilightedTextWriter actionsToString(List<DisassemblyListener> listeners, long address, List<Action> list, List<Long> importantOffsets, List<String> constantPool, int version, ExportMode exportMode, HilightedTextWriter writer, long swfPos, String path) {
private static GraphTextWriter actionsToString(List<DisassemblyListener> listeners, long address, List<Action> list, List<Long> importantOffsets, List<String> constantPool, int version, ExportMode exportMode, GraphTextWriter writer, long swfPos, String path) {
long offset;
if (importantOffsets == null) {
//setActionsAddresses(list, 0, version);
@@ -435,9 +438,9 @@ public class Action implements GraphSourceItem {
writer.newLine();
lastPush = false;
}
writer.appendNoHilight("<ffdec:hex>");/* +"0x"+Helper.formatAddress(a.getFileAddress())+": "+*/;
writer.appendNoHilight("; ");
writer.appendNoHilight(Helper.bytesToHexString(a.getBytes(version)));
writer.appendNoHilight("</ffdec:hex>").newLine();
writer.newLine();
}
offset = a.getAddress();
@@ -693,60 +696,50 @@ public class Action implements GraphSourceItem {
* @param actions List of actions
* @param version SWF version
* @param path
* @return HilightedTextWriter with Source code
* @return String with Source code
*/
public static String actionsToSource(List<Action> actions, int version, String path, boolean highlight, int indent) {
HilightedTextWriter writer = new HilightedTextWriter(highlight, indent);
Action.actionsToSource(actions, SWF.DEFAULT_VERSION, ""/*FIXME*/, writer);
String s = Graph.removeNonRefenrencedLoopLabels(writer.toString(), highlight);
return s;
}
/**
* Converts list of actions to ActionScript source code
*
* @param actions List of actions
* @param version SWF version
* @param path
* @return HilightedTextWriter with Source code
*/
public static HilightedTextWriter actionsToSource(final List<Action> actions, final int version, final String path, final HilightedTextWriter writer) {
public static HilightedText actionsToSource(final List<Action> actions, final int version, final String path, boolean highlight, int indent) {
List<GraphTargetItem> tree = null;
Throwable convertException = null;
int timeout = Configuration.getConfig("decompilationTimeoutSingleMethod", 60);
int writerPos = writer.getLength();
try {
Helper.timedCall(new Callable<Void>() {
tree = Helper.timedCall(new Callable<List<GraphTargetItem>>() {
@Override
public Void call() throws Exception {
//List<ActionItem> tree = actionsToTree(new HashMap<Integer, String>(), actions, version);
public List<GraphTargetItem> call() throws Exception {
int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC;
List<GraphTargetItem> tree = actionsToTree(new HashMap<Integer, String>(), new HashMap<String, GraphTargetItem>(), new HashMap<String, GraphTargetItem>(), actions, version, staticOperation, path);
Graph.graphToString(tree, writer, new LocalData());
return null;
List<GraphTargetItem> tree = actionsToTree(new HashMap<Integer, String>(), new HashMap<String, GraphTargetItem>(), new HashMap<String, GraphTargetItem>(), actions, version, staticOperation, path);
Graph.graphToString(tree, new NulWriter(), new LocalData());
return tree;
}
}, timeout, TimeUnit.SECONDS);
} catch (TimeoutException ex) {
} catch (InterruptedException | TimeoutException | ExecutionException | OutOfMemoryError | StackOverflowError ex) {
Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error", ex);
writer.setLength(writerPos); // remove already rendered code
convertException = ex;
if (ex instanceof ExecutionException && ex.getCause() instanceof Exception) {
convertException = (Exception) ex.getCause();
}
}
HilightedTextWriter writer = new HilightedTextWriter(highlight, indent);
if (convertException == null) {
Graph.graphToString(tree, writer, new LocalData());
} else if (convertException instanceof TimeoutException) {
Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error", convertException);
writer.appendNoHilight("/*").newLine();
writer.appendNoHilight(" * Decompilation error").newLine();
writer.appendNoHilight(" * Timeout (" + Helper.formatTimeToText(timeout) + ") was reached").newLine();
writer.appendNoHilight(" */").newLine();
writer.appendNoHilight("throw new IllegalOperationError(\"Not decompiled due to timeout\");").newLine();
} catch (Exception | OutOfMemoryError | StackOverflowError ex2) {
Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error", ex2);
if (ex2 instanceof OutOfMemoryError) {
System.gc();
}
writer.setLength(writerPos); // remove already rendered code
} else {
Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error", convertException);
writer.appendNoHilight("/*").newLine();
writer.appendNoHilight(" * Decompilation error").newLine();
writer.appendNoHilight(" * Code may be obfuscated").newLine();
writer.appendNoHilight(" * Error type: " + ex2.getClass().getSimpleName()).newLine();
writer.appendNoHilight(" * Error type: " + convertException.getClass().getSimpleName()).newLine();
writer.appendNoHilight(" */").newLine();
return writer.appendNoHilight("throw new IllegalOperationError(\"Not decompiled due to error\");").newLine();
writer.appendNoHilight("throw new IllegalOperationError(\"Not decompiled due to error\");").newLine();
}
return writer;
return new HilightedText(writer);
}
/**
@@ -1236,7 +1229,7 @@ public class Action implements GraphSourceItem {
}
}
public HilightedTextWriter getASMSourceReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode, HilightedTextWriter writer) {
public GraphTextWriter getASMSourceReplaced(List<? extends GraphSourceItem> container, List<Long> knownAddreses, List<String> constantPool, int version, ExportMode exportMode, GraphTextWriter writer) {
writer.appendNoHilight(getASMSource(container, knownAddreses, constantPool, version, exportMode));
return writer;
}

View File

@@ -18,7 +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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.SourceGenerator;
@@ -49,7 +49,7 @@ public abstract class ActionItem extends GraphTargetItem implements Serializable
return false;
}
protected HilightedTextWriter stripQuotes(GraphTargetItem target, LocalData localData, HilightedTextWriter writer) {
protected GraphTextWriter stripQuotes(GraphTargetItem target, LocalData localData, GraphTextWriter writer) {
if (target instanceof DirectValueActionItem) {
if (((DirectValueActionItem) target).value instanceof String) {
return writer.append((String) ((DirectValueActionItem) target).value);

View File

@@ -17,7 +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.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphSourceItemPos;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -33,7 +33,7 @@ public class AsciiToCharActionItem extends ActionItem {
}
@Override
protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) {
protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
writer.append("chr(");
value.toString(writer, localData);
return writer.append(")");

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