diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallSuperAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallSuperAVM2Item.java index 4c59046dc..26afc902f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallSuperAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallSuperAVM2Item.java @@ -39,7 +39,7 @@ public class CallSuperAVM2Item extends AVM2Item { @Override protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { - if (!receiver.toString(false, localData).equals("this")) { + if (!receiver.toString(localData).equals("this")) { receiver.toString(writer, localData); writer.append("."); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructSuperAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructSuperAVM2Item.java index 182483eed..9f2af88b9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructSuperAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructSuperAVM2Item.java @@ -35,7 +35,7 @@ public class ConstructSuperAVM2Item extends AVM2Item { @Override protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { - if (!object.toString(false, localData).equals("this")) { + if (!object.toString(localData).equals("this")) { object.toString(writer, localData); writer.append("."); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java index 5ce694640..730d65fcb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FullMultinameAVM2Item.java @@ -59,13 +59,13 @@ public class FullMultinameAVM2Item extends AVM2Item { public boolean isXML(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { String cname; if (name != null) { - cname = name.toString(false, LocalData.create(constants, localRegNames, fullyQualifiedNames)); + cname = name.toString(LocalData.create(constants, localRegNames, fullyQualifiedNames)); } else { cname = (constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames)); } String cns = ""; if (namespace != null) { - cns = namespace.toString(false, LocalData.create(constants, localRegNames, fullyQualifiedNames)); + cns = namespace.toString(LocalData.create(constants, localRegNames, fullyQualifiedNames)); } else { Namespace ns = constants.constant_multiname[multinameIndex].getNamespace(constants); if ((ns != null) && (ns.name_index != 0)) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSuperAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSuperAVM2Item.java index d53247f2e..b2b1a5aa4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSuperAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSuperAVM2Item.java @@ -34,7 +34,7 @@ public class GetSuperAVM2Item extends AVM2Item { @Override protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { - if (!object.toString(false, localData).equals("this")) { + if (!object.toString(localData).equals("this")) { object.toString(writer, localData); writer.append("."); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSuperAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSuperAVM2Item.java index ca91dff0e..600d2e814 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSuperAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSuperAVM2Item.java @@ -42,7 +42,7 @@ public class SetSuperAVM2Item extends AVM2Item { @Override protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { - if (!object.toString(false, localData).equals("this")) { + if (!object.toString(localData).equals("this")) { object.toString(writer, localData); writer.append("."); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java index fbdab1f35..0a2e25605 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -109,6 +109,14 @@ public class MethodBody implements Cloneable, Serializable { return ret; } + public String toString(final String path, boolean pcode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final MethodInfo[] method_info, final Stack scopeStack, final boolean isStaticInitializer, final List fullyQualifiedNames, final Traits initTraits) { + HilightedTextWriter writer = new HilightedTextWriter(false); + toString(path, pcode, isStatic, scriptIndex, classIndex, abc, trait, constants, method_info, scopeStack, isStaticInitializer, writer, fullyQualifiedNames, initTraits); + String src = writer.toString(); + src = Graph.removeNonRefenrencedLoopLabels(src); + return src; + } + public HilightedTextWriter toString(final String path, boolean pcode, final boolean isStatic, final int scriptIndex, final int classIndex, final ABC abc, final Trait trait, final ConstantPool constants, final MethodInfo[] method_info, final Stack scopeStack, final boolean isStaticInitializer, final HilightedTextWriter writer, final List fullyQualifiedNames, final Traits initTraits) { if (debugMode) { System.err.println("Decompiling " + path); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java b/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java index bd86881d0..d7df4fe58 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/ActionListReader.java @@ -673,7 +673,7 @@ public class ActionListReader { HashMap vars = (HashMap) localData.get(1); System.err.print("variables: "); for (Map.Entry v : vars.entrySet()) { - System.err.print("'" + v + "' = " + v.getValue().toString(false, LocalData.create(cpool)) + ", "); + System.err.print("'" + v + "' = " + v.getValue().toString(LocalData.create(cpool)) + ", "); } System.err.println(); String add = ""; diff --git a/trunk/src/com/jpexs/decompiler/graph/GraphTargetItem.java b/trunk/src/com/jpexs/decompiler/graph/GraphTargetItem.java index 0da24dfad..b1686a54f 100644 --- a/trunk/src/com/jpexs/decompiler/graph/GraphTargetItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/GraphTargetItem.java @@ -111,8 +111,8 @@ public abstract class GraphTargetItem implements Serializable { protected abstract HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData); - public String toString(boolean highlight, LocalData localData) { - HilightedTextWriter writer = new HilightedTextWriter(highlight); + public String toString(LocalData localData) { + HilightedTextWriter writer = new HilightedTextWriter(false); toString(writer, localData); return writer.toString(); } diff --git a/trunk/src/com/jpexs/helpers/Helper.java b/trunk/src/com/jpexs/helpers/Helper.java index cba1b433c..1e15d53fb 100644 --- a/trunk/src/com/jpexs/helpers/Helper.java +++ b/trunk/src/com/jpexs/helpers/Helper.java @@ -386,7 +386,7 @@ public class Helper { if (i < stack.size() - 1) { ret += ", "; } - ret += stack.get(i).toString(false, localData); + ret += stack.get(i).toString(localData); } ret += "]"; return ret; diff --git a/trunk/test/com/jpexs/decompiler/flash/ActionScript2AssemblerTest.java b/trunk/test/com/jpexs/decompiler/flash/ActionScript2AssemblerTest.java index e5ea1a244..2a24a2730 100644 --- a/trunk/test/com/jpexs/decompiler/flash/ActionScript2AssemblerTest.java +++ b/trunk/test/com/jpexs/decompiler/flash/ActionScript2AssemblerTest.java @@ -3,6 +3,7 @@ package com.jpexs.decompiler.flash; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser; +import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.tags.DoActionTag; import java.io.FileInputStream; import java.io.IOException; @@ -38,8 +39,10 @@ public class ActionScript2AssemblerTest extends ActionStript2TestBase { DoActionTag doa = getFirstActionTag(); doa.setActionBytes(Action.actionsToBytes(actions, true, swf.version)); - String actualResult = Action.actionsToSource(doa.getActions(swf.version), swf.version, "", false); - String decompiled = doa.getASMSource(swf.version, false, false, null); + String actualResult = Action.actionsToSource(doa.getActions(swf.version), swf.version, "", false, 0); + HilightedTextWriter writer = new HilightedTextWriter(false); + doa.getASMSource(swf.version, false, writer, null); + String decompiled = writer.toString(); assertEquals(actualResult.trim(), "ok = false;"); assertTrue(decompiled.contains("Push \"ok\" false")); diff --git a/trunk/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java b/trunk/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java index 621dd1974..497a42b6e 100644 --- a/trunk/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java +++ b/trunk/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java @@ -73,7 +73,7 @@ public class ActionScript2DeobfuscatorTest extends ActionStript2TestBase { DoActionTag doa = getFirstActionTag(); doa.setActionBytes(Action.actionsToBytes(actions, true, swf.version)); - String actualResult = Action.actionsToSource(doa.getActions(swf.version), swf.version, "", false); + String actualResult = Action.actionsToSource(doa.getActions(swf.version), swf.version, "", false, 0); assertTrue(actualResult.contains("case \"c\":")); } catch (IOException | ParseException ex) { diff --git a/trunk/test/com/jpexs/decompiler/flash/ActionScript2Test.java b/trunk/test/com/jpexs/decompiler/flash/ActionScript2Test.java index 1f06c3469..0c67ff49c 100644 --- a/trunk/test/com/jpexs/decompiler/flash/ActionScript2Test.java +++ b/trunk/test/com/jpexs/decompiler/flash/ActionScript2Test.java @@ -41,7 +41,7 @@ public class ActionScript2Test extends ActionStript2TestBase { private void compareSrc(int frame, String expectedResult) { DoActionTag doa = getFrameSource(frame); assertNotNull(doa); - String actualResult = Action.actionsToSource(doa.getActions(swf.version), swf.version, "", false); + String actualResult = Action.actionsToSource(doa.getActions(swf.version), swf.version, "", false, 0); actualResult = actualResult.replaceAll("[ \r\n]", ""); expectedResult = expectedResult.replaceAll("[ \r\n]", ""); assertEquals(actualResult, expectedResult); diff --git a/trunk/test/com/jpexs/decompiler/flash/ActionScript3Test.java b/trunk/test/com/jpexs/decompiler/flash/ActionScript3Test.java index c4f985b6d..3484d99d2 100644 --- a/trunk/test/com/jpexs/decompiler/flash/ActionScript3Test.java +++ b/trunk/test/com/jpexs/decompiler/flash/ActionScript3Test.java @@ -1,6 +1,7 @@ package com.jpexs.decompiler.flash; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -42,7 +43,7 @@ public class ActionScript3Test { private void decompileMethod(String methodName, String expectedResult, boolean isStatic) { int bodyIndex = abc.findMethodBodyByName(clsIndex, methodName); assertTrue(bodyIndex > -1); - String actualResult = abc.bodies[bodyIndex].toString(methodName, false, isStatic, -1/*FIX?*/, clsIndex, abc,null, abc.constants, abc.method_info, new Stack(), false, false, true, new ArrayList(), abc.instance_info[clsIndex].instance_traits); + String actualResult = abc.bodies[bodyIndex].toString(methodName, false, isStatic, -1/*FIX?*/, clsIndex, abc,null, abc.constants, abc.method_info, new Stack(), false, new ArrayList(), abc.instance_info[clsIndex].instance_traits); actualResult = actualResult.replaceAll("[ \r\n]", ""); expectedResult = expectedResult.replaceAll("[ \r\n]", ""); assertEquals(actualResult, expectedResult); diff --git a/trunk/test/com/jpexs/decompiler/flash/generators/AS2Generator.java b/trunk/test/com/jpexs/decompiler/flash/generators/AS2Generator.java index e43e81020..8d022d142 100644 --- a/trunk/test/com/jpexs/decompiler/flash/generators/AS2Generator.java +++ b/trunk/test/com/jpexs/decompiler/flash/generators/AS2Generator.java @@ -34,7 +34,7 @@ public class AS2Generator { if (doa == null) { continue; } - String src = Action.actionsToSource(doa.getActions(swf.version), swf.version,"",false); + String src = Action.actionsToSource(doa.getActions(swf.version), swf.version,"",false, 0); if (src.trim().equals("")) { doa = null; continue; diff --git a/trunk/test/com/jpexs/decompiler/flash/generators/AS3Generator.java b/trunk/test/com/jpexs/decompiler/flash/generators/AS3Generator.java index 1d44c7d15..3b2b41f02 100644 --- a/trunk/test/com/jpexs/decompiler/flash/generators/AS3Generator.java +++ b/trunk/test/com/jpexs/decompiler/flash/generators/AS3Generator.java @@ -5,6 +5,7 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; +import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -43,7 +44,7 @@ public class AS3Generator { s.append("(){\r\ndecompileMethod(\""); s.append(name); s.append("\", "); - String src = abc.findBody(((TraitMethodGetterSetter) t).method_info).toString("", false, false, -1/*FIX?*/, classId, abc, null,abc.constants, abc.method_info, new Stack(), false, false, true, new ArrayList(), abc.instance_info[classId].instance_traits); + String src = abc.findBody(((TraitMethodGetterSetter) t).method_info).toString("", false, false, -1/*FIX?*/, classId, abc, null,abc.constants, abc.method_info, new Stack(), false, new ArrayList(), abc.instance_info[classId].instance_traits); String[] srcs = src.split("[\r\n]+"); for (int i = 0; i < srcs.length; i++) { String ss = srcs[i];