From d23c2dbe6367d4d28bfdfc73d9614d68feae8b57 Mon Sep 17 00:00:00 2001 From: Honfika Date: Fri, 1 Nov 2013 01:07:19 +0100 Subject: [PATCH] highlighting refactored --- trunk/build.xml | 11 +- trunk/nbproject/ide-file-targets.xml | 2 +- trunk/src/com/jpexs/decompiler/flash/SWF.java | 2 +- .../com/jpexs/decompiler/flash/TagNode.java | 1 - .../decompiler/flash/abc/ScriptPack.java | 13 +- .../decompiler/flash/abc/avm2/AVM2Code.java | 40 ++-- .../decompiler/flash/abc/avm2/CodeStats.java | 4 +- .../avm2/instructions/AVM2Instruction.java | 4 +- .../instructions/InstructionDefinition.java | 4 +- .../flash/abc/avm2/model/AVM2Item.java | 4 +- .../abc/avm2/model/AlchemyLoadAVM2Item.java | 4 +- .../avm2/model/AlchemySignExtendAVM2Item.java | 4 +- .../abc/avm2/model/AlchemyStoreAVM2Item.java | 4 +- .../abc/avm2/model/ApplyTypeAVM2Item.java | 4 +- .../flash/abc/avm2/model/BooleanAVM2Item.java | 4 +- .../flash/abc/avm2/model/CallAVM2Item.java | 4 +- .../abc/avm2/model/CallMethodAVM2Item.java | 4 +- .../abc/avm2/model/CallPropertyAVM2Item.java | 4 +- .../abc/avm2/model/CallStaticAVM2Item.java | 4 +- .../abc/avm2/model/CallSuperAVM2Item.java | 4 +- .../flash/abc/avm2/model/ClassAVM2Item.java | 4 +- .../flash/abc/avm2/model/CoerceAVM2Item.java | 4 +- .../abc/avm2/model/ConstructAVM2Item.java | 4 +- .../abc/avm2/model/ConstructPropAVM2Item.java | 4 +- .../avm2/model/ConstructSuperAVM2Item.java | 4 +- .../flash/abc/avm2/model/ConvertAVM2Item.java | 4 +- .../abc/avm2/model/DecLocalAVM2Item.java | 4 +- .../abc/avm2/model/DecrementAVM2Item.java | 4 +- .../abc/avm2/model/DefaultXMLNamespace.java | 4 +- .../abc/avm2/model/EscapeXAttrAVM2Item.java | 4 +- .../abc/avm2/model/EscapeXElemAVM2Item.java | 4 +- .../abc/avm2/model/FilteredCheckAVM2Item.java | 4 +- .../abc/avm2/model/FindPropertyAVM2Item.java | 4 +- .../abc/avm2/model/FloatValueAVM2Item.java | 4 +- .../abc/avm2/model/FullMultinameAVM2Item.java | 4 +- .../avm2/model/GetDescendantsAVM2Item.java | 4 +- .../flash/abc/avm2/model/GetLexAVM2Item.java | 4 +- .../abc/avm2/model/GetPropertyAVM2Item.java | 4 +- .../flash/abc/avm2/model/GetSlotAVM2Item.java | 4 +- .../abc/avm2/model/GetSuperAVM2Item.java | 4 +- .../flash/abc/avm2/model/HasNextAVM2Item.java | 4 +- .../flash/abc/avm2/model/InAVM2Item.java | 4 +- .../abc/avm2/model/IncLocalAVM2Item.java | 4 +- .../abc/avm2/model/IncrementAVM2Item.java | 4 +- .../abc/avm2/model/InitPropertyAVM2Item.java | 4 +- .../abc/avm2/model/IntegerValueAVM2Item.java | 4 +- .../abc/avm2/model/LocalRegAVM2Item.java | 4 +- .../abc/avm2/model/NameSpaceAVM2Item.java | 4 +- .../flash/abc/avm2/model/NameValuePair.java | 4 +- .../flash/abc/avm2/model/NanAVM2Item.java | 4 +- .../abc/avm2/model/NewActivationAVM2Item.java | 4 +- .../abc/avm2/model/NewArrayAVM2Item.java | 4 +- .../abc/avm2/model/NewFunctionAVM2Item.java | 11 +- .../abc/avm2/model/NewObjectAVM2Item.java | 4 +- .../abc/avm2/model/NextNameAVM2Item.java | 4 +- .../abc/avm2/model/NextValueAVM2Item.java | 4 +- .../flash/abc/avm2/model/NullAVM2Item.java | 4 +- .../abc/avm2/model/PostDecrementAVM2Item.java | 4 +- .../abc/avm2/model/PostIncrementAVM2Item.java | 4 +- .../abc/avm2/model/ReturnValueAVM2Item.java | 4 +- .../abc/avm2/model/ReturnVoidAVM2Item.java | 4 +- .../flash/abc/avm2/model/ScriptAVM2Item.java | 4 +- .../abc/avm2/model/SetGlobalSlotAVM2Item.java | 4 +- .../abc/avm2/model/SetLocalAVM2Item.java | 4 +- .../abc/avm2/model/SetPropertyAVM2Item.java | 4 +- .../flash/abc/avm2/model/SetSlotAVM2Item.java | 6 +- .../abc/avm2/model/SetSuperAVM2Item.java | 4 +- .../flash/abc/avm2/model/StringAVM2Item.java | 4 +- .../flash/abc/avm2/model/ThisAVM2Item.java | 4 +- .../flash/abc/avm2/model/ThrowAVM2Item.java | 4 +- .../abc/avm2/model/UndefinedAVM2Item.java | 4 +- .../abc/avm2/model/UnparsedAVM2Item.java | 4 +- .../flash/abc/avm2/model/WithAVM2Item.java | 4 +- .../flash/abc/avm2/model/WithEndAVM2Item.java | 4 +- .../abc/avm2/model/WithObjectAVM2Item.java | 4 +- .../flash/abc/avm2/model/XMLAVM2Item.java | 4 +- .../model/clauses/DeclarationAVM2Item.java | 5 +- .../avm2/model/clauses/ExceptionAVM2Item.java | 4 +- .../avm2/model/clauses/FilterAVM2Item.java | 4 +- .../avm2/model/clauses/ForEachInAVM2Item.java | 20 +- .../abc/avm2/model/clauses/ForInAVM2Item.java | 20 +- .../abc/avm2/model/clauses/TryAVM2Item.java | 4 +- .../avm2/model/operations/AddAVM2Item.java | 4 +- .../operations/DeletePropertyAVM2Item.java | 4 +- .../model/operations/SubtractAVM2Item.java | 4 +- .../flash/abc/avm2/parser/ASM3Parser.java | 1 + .../flash/abc/types/MethodBody.java | 79 ++++--- .../flash/abc/types/MethodInfo.java | 6 +- .../flash/abc/types/ScriptInfo.java | 7 - .../flash/abc/types/traits/Trait.java | 32 ++- .../flash/abc/types/traits/TraitClass.java | 38 ++- .../flash/abc/types/traits/TraitFunction.java | 23 +- .../types/traits/TraitMethodGetterSetter.java | 28 ++- .../abc/types/traits/TraitSlotConst.java | 35 +-- .../flash/abc/types/traits/Traits.java | 61 +++-- .../abc/usages/ConstVarMultinameUsage.java | 15 +- .../abc/usages/MethodMultinameUsage.java | 17 +- .../jpexs/decompiler/flash/action/Action.java | 77 +++--- .../flash/action/model/ActionItem.java | 4 +- .../action/model/AsciiToCharActionItem.java | 4 +- .../flash/action/model/CallActionItem.java | 4 +- .../action/model/CallFunctionActionItem.java | 4 +- .../action/model/CallMethodActionItem.java | 4 +- .../flash/action/model/CastOpActionItem.java | 4 +- .../action/model/CharToAsciiActionItem.java | 4 +- .../action/model/CloneSpriteActionItem.java | 4 +- .../action/model/DecrementActionItem.java | 4 +- .../action/model/DefineLocalActionItem.java | 4 +- .../model/DefineRegisterActionItem.java | 4 +- .../flash/action/model/DeleteActionItem.java | 4 +- .../action/model/DirectValueActionItem.java | 27 ++- .../action/model/EnumerateActionItem.java | 4 +- .../flash/action/model/EvalActionItem.java | 4 +- .../flash/action/model/ExtendsActionItem.java | 4 +- .../action/model/FSCommand2ActionItem.java | 4 +- .../action/model/FSCommandActionItem.java | 4 +- .../action/model/FunctionActionItem.java | 4 +- .../action/model/GetMemberActionItem.java | 4 +- .../action/model/GetPropertyActionItem.java | 4 +- .../flash/action/model/GetTimeActionItem.java | 4 +- .../flash/action/model/GetURL2ActionItem.java | 4 +- .../flash/action/model/GetURLActionItem.java | 4 +- .../action/model/GetVariableActionItem.java | 4 +- .../action/model/GetVersionActionItem.java | 4 +- .../action/model/GotoFrame2ActionItem.java | 4 +- .../action/model/GotoFrameActionItem.java | 4 +- .../action/model/GotoLabelActionItem.java | 4 +- .../action/model/ImplementsOpActionItem.java | 4 +- .../action/model/IncrementActionItem.java | 4 +- .../action/model/InitArrayActionItem.java | 4 +- .../action/model/InitObjectActionItem.java | 4 +- .../action/model/LoadMovieActionItem.java | 4 +- .../action/model/LoadMovieNumActionItem.java | 4 +- .../action/model/LoadVariablesActionItem.java | 4 +- .../model/LoadVariablesNumActionItem.java | 4 +- .../action/model/MBAsciiToCharActionItem.java | 4 +- .../action/model/MBCharToAsciiActionItem.java | 4 +- .../model/MBStringExtractActionItem.java | 4 +- .../model/MBStringLengthActionItem.java | 4 +- .../action/model/NewMethodActionItem.java | 4 +- .../action/model/NewObjectActionItem.java | 4 +- .../action/model/NextFrameActionItem.java | 4 +- .../flash/action/model/PlayActionItem.java | 4 +- .../flash/action/model/PopActionItem.java | 4 +- .../action/model/PostDecrementActionItem.java | 4 +- .../action/model/PostIncrementActionItem.java | 4 +- .../action/model/PrevFrameActionItem.java | 4 +- .../flash/action/model/PrintActionItem.java | 4 +- .../action/model/PrintAsBitmapActionItem.java | 4 +- .../model/PrintAsBitmapNumActionItem.java | 4 +- .../action/model/PrintNumActionItem.java | 4 +- .../action/model/RandomNumberActionItem.java | 4 +- .../action/model/RemoveSpriteActionItem.java | 4 +- .../flash/action/model/ReturnActionItem.java | 4 +- .../action/model/SetMemberActionItem.java | 4 +- .../action/model/SetPropertyActionItem.java | 4 +- .../action/model/SetTarget2ActionItem.java | 4 +- .../action/model/SetTargetActionItem.java | 4 +- .../action/model/SetVariableActionItem.java | 4 +- .../action/model/StartDragActionItem.java | 4 +- .../flash/action/model/StopActionItem.java | 4 +- .../action/model/StopAllSoundsActionItem.java | 4 +- .../action/model/StopDragActionItem.java | 4 +- .../action/model/StoreRegisterActionItem.java | 4 +- .../action/model/StrictModeActionItem.java | 4 +- .../action/model/StringExtractActionItem.java | 4 +- .../action/model/StringLengthActionItem.java | 4 +- .../action/model/TargetPathActionItem.java | 4 +- .../flash/action/model/TemporaryRegister.java | 4 +- .../flash/action/model/ThrowActionItem.java | 4 +- .../action/model/ToIntegerActionItem.java | 4 +- .../action/model/ToNumberActionItem.java | 4 +- .../action/model/ToStringActionItem.java | 4 +- .../model/ToggleHighQualityActionItem.java | 4 +- .../flash/action/model/TraceActionItem.java | 4 +- .../flash/action/model/TypeOfActionItem.java | 4 +- .../action/model/UnLoadMovieActionItem.java | 4 +- .../model/UnLoadMovieNumActionItem.java | 4 +- .../action/model/UnsupportedActionItem.java | 4 +- .../action/model/clauses/ClassActionItem.java | 4 +- .../action/model/clauses/ForInActionItem.java | 25 +- .../clauses/IfFrameLoadedActionItem.java | 4 +- .../model/clauses/InterfaceActionItem.java | 4 +- .../model/clauses/TellTargetActionItem.java | 4 +- .../action/model/clauses/TryActionItem.java | 4 +- .../action/model/clauses/WithActionItem.java | 4 +- .../model/operations/AddActionItem.java | 4 +- .../model/operations/SubtractActionItem.java | 4 +- .../flash/action/swf4/ActionPush.java | 9 +- .../action/swf5/ActionDefineFunction.java | 4 +- .../action/swf7/ActionDefineFunction2.java | 4 +- .../flash/gui/abc/ASMSourceEditorPane.java | 62 +++-- .../flash/gui/abc/CachedDecompilation.java | 29 ++- .../flash/gui/abc/DecompiledEditorPane.java | 16 +- .../flash/gui/abc/MethodCodePanel.java | 28 ++- .../gui/abc/SlotConstTraitDetailPanel.java | 4 +- .../flash/gui/abc/TraitsListItem.java | 6 +- .../flash/gui/action/ActionPanel.java | 115 +++++---- .../flash/helpers/GraphTextWriter.java | 157 +++++++++++++ .../decompiler/flash/helpers/HilightType.java | 28 +++ .../flash/helpers/HilightedText.java | 65 ++++++ .../flash/helpers/HilightedTextWriter.java | 217 ++++++++++------- .../flash/helpers/LoopWithType.java | 1 + .../decompiler/flash/helpers/NulWriter.java | 90 +++++++ .../flash/helpers/hilight/Highlighting.java | 221 ++---------------- .../flash/tags/DefineButtonTag.java | 6 +- .../decompiler/flash/tags/DoActionTag.java | 6 +- .../flash/tags/DoInitActionTag.java | 6 +- .../decompiler/flash/tags/base/ASMSource.java | 6 +- .../flash/types/BUTTONCONDACTION.java | 6 +- .../flash/types/CLIPACTIONRECORD.java | 6 +- .../decompiler/flash/xfl/XFLConverter.java | 5 +- .../src/com/jpexs/decompiler/graph/Graph.java | 41 +--- .../decompiler/graph/GraphTargetItem.java | 19 +- .../com/jpexs/decompiler/graph/MarkItem.java | 4 +- .../decompiler/graph/NotCompileTimeItem.java | 4 +- .../decompiler/graph/model/BinaryOpItem.java | 4 +- .../decompiler/graph/model/BlockItem.java | 4 +- .../decompiler/graph/model/BreakItem.java | 15 +- .../graph/model/CommaExpressionItem.java | 4 +- .../decompiler/graph/model/CommentItem.java | 4 +- .../decompiler/graph/model/ContinueItem.java | 15 +- .../decompiler/graph/model/DoWhileItem.java | 20 +- .../decompiler/graph/model/DuplicateItem.java | 4 +- .../jpexs/decompiler/graph/model/ForItem.java | 20 +- .../jpexs/decompiler/graph/model/IfItem.java | 4 +- .../graph/model/IntegerValueItem.java | 4 +- .../graph/model/ParenthesisItem.java | 4 +- .../decompiler/graph/model/ScriptEndItem.java | 4 +- .../decompiler/graph/model/SwitchItem.java | 25 +- .../decompiler/graph/model/TernarOpItem.java | 4 +- .../decompiler/graph/model/TrueItem.java | 4 +- .../decompiler/graph/model/UnaryOpItem.java | 4 +- .../graph/model/UniversalLoopItem.java | 25 +- .../decompiler/graph/model/WhileItem.java | 20 +- trunk/src/com/jpexs/helpers/Helper.java | 15 +- .../flash/ActionScript2AssemblerTest.java | 5 +- .../flash/ActionScript2DeobfuscatorTest.java | 5 +- .../decompiler/flash/ActionScript2Test.java | 5 +- .../decompiler/flash/ActionScript3Test.java | 5 +- .../flash/generators/AS2Generator.java | 4 +- .../flash/generators/AS3Generator.java | 5 +- 242 files changed, 1572 insertions(+), 1075 deletions(-) create mode 100644 trunk/src/com/jpexs/decompiler/flash/helpers/GraphTextWriter.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/helpers/HilightType.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/helpers/HilightedText.java create mode 100644 trunk/src/com/jpexs/decompiler/flash/helpers/NulWriter.java diff --git a/trunk/build.xml b/trunk/build.xml index 1ac80aa23..4b20316ea 100644 --- a/trunk/build.xml +++ b/trunk/build.xml @@ -47,7 +47,14 @@ - - + + + + diff --git a/trunk/nbproject/ide-file-targets.xml b/trunk/nbproject/ide-file-targets.xml index e76453db8..3f140e9c5 100644 --- a/trunk/nbproject/ide-file-targets.xml +++ b/trunk/nbproject/ide-file-targets.xml @@ -13,7 +13,7 @@ - + diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index b789c0941..0502b6e90 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -565,7 +565,7 @@ public class SWF { for (MyEntry item : packs) { for (MyEntry 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; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/TagNode.java b/trunk/src/com/jpexs/decompiler/flash/TagNode.java index 78cf0fb7c..2cd17b356 100644 --- a/trunk/src/com/jpexs/decompiler/flash/TagNode.java +++ b/trunk/src/com/jpexs/decompiler/flash/TagNode.java @@ -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 as = asm.getActions(SWF.DEFAULT_VERSION); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java b/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java index b5a12c51e..a87c28a2b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ScriptPack.java @@ -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(), parallel); + } else { + abc.script_info[scriptIndex].traits.traits[t].convert(null, "", abcList, abc, false, exportMode, scriptIndex, -1, new ArrayList(), 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(), parallel); + abc.script_info[scriptIndex].traits.traits[t].toStringPackaged(null, "", abcList, abc, false, exportMode, scriptIndex, -1, writer, new ArrayList(), parallel); } else { - abc.script_info[scriptIndex].traits.traits[t].convert(null, "", abcList, abc, false, exportMode, scriptIndex, -1, writer, new ArrayList(), parallel); + abc.script_info[scriptIndex].traits.traits[t].toString(null, "", abcList, abc, false, exportMode, scriptIndex, -1, writer, new ArrayList(), 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; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 44ee0a8a8..5929348d0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -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(), exportMode, writer); } - public HilightedTextWriter toASMSource(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, List outputMap, ExportMode exportMode, HilightedTextWriter writer) { + public GraphTextWriter toASMSource(ConstantPool constants, Trait trait, MethodInfo info, MethodBody body, List 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(""); + writer.appendNoHilight("; "); writer.appendNoHilight(Helper.bytesToHexString(ins.getBytes())); - writer.appendNoHilight("\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 localRegNames, Stack scopeStack, boolean isStaticInitializer, List fullyQualifiedNames, Traits initTraits, int staticOperation, HashMap localRegAssigmentIps, HashMap> refs) { + public List toGraphTargetItems(String path, boolean isStatic, int scriptIndex, int classIndex, ABC abc, ConstantPool constants, MethodInfo[] method_info, MethodBody body, HashMap localRegNames, Stack scopeStack, boolean isStaticInitializer, List fullyQualifiedNames, Traits initTraits, int staticOperation, HashMap localRegAssigmentIps, HashMap> refs) { initToSource(); List list; - String s; HashMap 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 registers = (HashMap) localData.get(2); System.out.print("Registers:"); for (int reg : registers.keySet()) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/CodeStats.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/CodeStats.java index d7ef39fab..c2cd10b9b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/CodeStats.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/CodeStats.java @@ -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 fullyQualifiedNames) { + public GraphTextWriter toString(GraphTextWriter writer, ABC abc, List fullyQualifiedNames) { writer.appendNoHilight("Stats: maxstack=" + maxstack + ", maxscope=" + maxscope + ", maxlocal=" + maxlocal).newLine(); int i = 0; int ms = 0; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java index 1212a55ee..5762a2b96 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java @@ -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; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java index cd325c9ab..2a6f7e33c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java @@ -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; } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java index ee02fde05..acd028cac 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AVM2Item.java @@ -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) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyLoadAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyLoadAVM2Item.java index 9d82ba304..a539f0609 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyLoadAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyLoadAVM2Item.java @@ -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*/"); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemySignExtendAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemySignExtendAVM2Item.java index 9ff6481cf..db3d4a5f3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemySignExtendAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemySignExtendAVM2Item.java @@ -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*/"); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyStoreAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyStoreAVM2Item.java index 6ca6de185..9aad30a5b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyStoreAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/AlchemyStoreAVM2Item.java @@ -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(","); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ApplyTypeAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ApplyTypeAVM2Item.java index 4d64d2da0..0bcf698ab 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ApplyTypeAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ApplyTypeAVM2Item.java @@ -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(".<"); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java index c4765716a..7aec184c6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/BooleanAVM2Item.java @@ -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"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallAVM2Item.java index 587566f6c..397c2bfef 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallAVM2Item.java @@ -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 = ""; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallMethodAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallMethodAVM2Item.java index ce8b1a03f..f094e9ae7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallMethodAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallMethodAVM2Item.java @@ -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); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallPropertyAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallPropertyAVM2Item.java index 936c6fe26..9ba5f56ea 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallPropertyAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallPropertyAVM2Item.java @@ -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++) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallStaticAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallStaticAVM2Item.java index 9fb8d9c3c..635e43a59 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallStaticAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CallStaticAVM2Item.java @@ -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); 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 b2fed18f1..7c470314c 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 @@ -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("."); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ClassAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ClassAVM2Item.java index 8a6e81565..380fd5fcf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ClassAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ClassAVM2Item.java @@ -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)); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CoerceAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CoerceAVM2Item.java index 7e075b3c1..f2082d462 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CoerceAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/CoerceAVM2Item.java @@ -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); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructAVM2Item.java index 2fb37f629..d89c6f0e2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructAVM2Item.java @@ -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); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructPropAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructPropAVM2Item.java index 416ca30dc..df58572fc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructPropAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ConstructPropAVM2Item.java @@ -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); 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 9e4b843cd..220f31f54 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 @@ -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("."); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ConvertAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ConvertAVM2Item.java index 906521724..7287baa99 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ConvertAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ConvertAVM2Item.java @@ -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); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/DecLocalAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/DecLocalAVM2Item.java index d93228ef1..1d542af14 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/DecLocalAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/DecLocalAVM2Item.java @@ -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("--"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/DecrementAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/DecrementAVM2Item.java index 865429e89..c704420f6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/DecrementAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/DecrementAVM2Item.java @@ -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"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/DefaultXMLNamespace.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/DefaultXMLNamespace.java index 34dc9aba2..f2792b4a5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/DefaultXMLNamespace.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/DefaultXMLNamespace.java @@ -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); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXAttrAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXAttrAVM2Item.java index df556a355..48b501267 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXAttrAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXAttrAVM2Item.java @@ -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("}"); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXElemAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXElemAVM2Item.java index 1f1d8b638..7c560acf3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXElemAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/EscapeXElemAVM2Item.java @@ -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("}"); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FilteredCheckAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FilteredCheckAVM2Item.java index e7028dc4c..e0c85dfda 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FilteredCheckAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FilteredCheckAVM2Item.java @@ -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); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FindPropertyAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FindPropertyAVM2Item.java index 679b6f9c6..d923c0443 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FindPropertyAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FindPropertyAVM2Item.java @@ -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; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FloatValueAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FloatValueAVM2Item.java index 962123a81..f936a5700 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FloatValueAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/FloatValueAVM2Item.java @@ -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); } 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 730d65fcb..18fec9854 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 @@ -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("::"); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetDescendantsAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetDescendantsAVM2Item.java index 78c08dd69..15b0a46ed 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetDescendantsAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetDescendantsAVM2Item.java @@ -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); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java index dffa98cf9..4df22f6c3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetLexAVM2Item.java @@ -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)); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetPropertyAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetPropertyAVM2Item.java index fb0368968..bcf68b085 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetPropertyAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetPropertyAVM2Item.java @@ -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); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java index e14629138..ad9470f83 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/GetSlotAVM2Item.java @@ -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*/"); } 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 6a3116871..b46520158 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 @@ -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("."); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/HasNextAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/HasNextAVM2Item.java index 25dc4380b..546174177 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/HasNextAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/HasNextAVM2Item.java @@ -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); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/InAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/InAVM2Item.java index ebaec08cb..8f9a9ae13 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/InAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/InAVM2Item.java @@ -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); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/IncLocalAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/IncLocalAVM2Item.java index 8d4d2c656..7ea2310e7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/IncLocalAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/IncLocalAVM2Item.java @@ -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("++"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/IncrementAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/IncrementAVM2Item.java index 0f05776c9..661a293fc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/IncrementAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/IncrementAVM2Item.java @@ -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"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/InitPropertyAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/InitPropertyAVM2Item.java index a2b2b1da8..748fb01a3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/InitPropertyAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/InitPropertyAVM2Item.java @@ -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); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java index b22b6c72a..9df93394a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/IntegerValueAVM2Item.java @@ -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); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java index 2c6339abb..9fba2e576 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/LocalRegAVM2Item.java @@ -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); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NameSpaceAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NameSpaceAVM2Item.java index 5a169717b..11fc4ab76 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NameSpaceAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NameSpaceAVM2Item.java @@ -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("*"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NameValuePair.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NameValuePair.java index 871855597..10741427e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NameValuePair.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NameValuePair.java @@ -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 ":" diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NanAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NanAVM2Item.java index 826a2b84b..cf7ba932c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NanAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NanAVM2Item.java @@ -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"); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewActivationAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewActivationAVM2Item.java index 389021deb..dba17abfc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewActivationAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewActivationAVM2Item.java @@ -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()"); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewArrayAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewArrayAVM2Item.java index ee320293a..4b1be77a7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewArrayAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewArrayAVM2Item.java @@ -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) { diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java index 2134533e0..cd1ca502d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewFunctionAVM2Item.java @@ -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()/*scopeStack*/, false, writer, fullyQualifiedNames, null); + if (writer instanceof NulWriter) { + body.convert(path + "/inner", ExportMode.SOURCE, isStatic, scriptIndex, classIndex, abc, null, constants, methodInfo, new Stack()/*scopeStack*/, false, fullyQualifiedNames, null); + } else { + body.toString(path + "/inner", ExportMode.SOURCE, isStatic, scriptIndex, classIndex, abc, null, constants, methodInfo, new Stack()/*scopeStack*/, false, writer, fullyQualifiedNames, null); + } } catch (Exception ex) { Logger.getLogger(NewFunctionIns.class.getName()).log(Level.SEVERE, "error during newfunction", ex); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewObjectAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewObjectAVM2Item.java index 30e887169..8f7ee3354 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewObjectAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NewObjectAVM2Item.java @@ -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(); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NextNameAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NextNameAVM2Item.java index a962153e7..bc48e4837 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NextNameAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NextNameAVM2Item.java @@ -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(","); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NextValueAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NextValueAVM2Item.java index b78678451..3b778713c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NextValueAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NextValueAVM2Item.java @@ -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(","); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NullAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NullAVM2Item.java index 66ce02b34..71e7c8f68 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NullAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/NullAVM2Item.java @@ -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"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/PostDecrementAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/PostDecrementAVM2Item.java index 34e22085a..ee476c847 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/PostDecrementAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/PostDecrementAVM2Item.java @@ -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("--"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/PostIncrementAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/PostIncrementAVM2Item.java index e3bc58dd2..b2a9ea1f5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/PostIncrementAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/PostIncrementAVM2Item.java @@ -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("++"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ReturnValueAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ReturnValueAVM2Item.java index 1cb4bf038..b5be6ffdb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ReturnValueAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ReturnValueAVM2Item.java @@ -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); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ReturnVoidAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ReturnVoidAVM2Item.java index b6786a662..49f9d103c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ReturnVoidAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ReturnVoidAVM2Item.java @@ -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"); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ScriptAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ScriptAVM2Item.java index 0bfcece6a..11136d21a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ScriptAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ScriptAVM2Item.java @@ -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); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetGlobalSlotAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetGlobalSlotAVM2Item.java index f60bd9753..be65b22d5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetGlobalSlotAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetGlobalSlotAVM2Item.java @@ -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(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java index 2521eab3b..a58ea1443 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetLocalAVM2Item.java @@ -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); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetPropertyAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetPropertyAVM2Item.java index d3acfdd78..02baa3db2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetPropertyAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetPropertyAVM2Item.java @@ -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); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java index 5969bcf18..2108280af 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/SetSlotAVM2Item.java @@ -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) + "."; 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 5ef62d46f..848e94936 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 @@ -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("."); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java index da4027aeb..0f10eaeed 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/StringAVM2Item.java @@ -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) + "\""); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java index 320347bd3..80255814e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ThisAVM2Item.java @@ -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"); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ThrowAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ThrowAVM2Item.java index 14c4130f5..671fa0574 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ThrowAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/ThrowAVM2Item.java @@ -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); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/UndefinedAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/UndefinedAVM2Item.java index 4aa3180a2..4b37c7962 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/UndefinedAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/UndefinedAVM2Item.java @@ -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"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/UnparsedAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/UnparsedAVM2Item.java index 757ace246..b8a636618 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/UnparsedAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/UnparsedAVM2Item.java @@ -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); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/WithAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/WithAVM2Item.java index 194bc6010..7f1da2a7a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/WithAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/WithAVM2Item.java @@ -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(); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/WithEndAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/WithEndAVM2Item.java index 8d0157f92..781945103 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/WithEndAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/WithEndAVM2Item.java @@ -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("}"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/WithObjectAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/WithObjectAVM2Item.java index 625925a61..293c1bcdf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/WithObjectAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/WithObjectAVM2Item.java @@ -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; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/XMLAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/XMLAVM2Item.java index ad665e94c..bae080a13 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/XMLAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/XMLAVM2Item.java @@ -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); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java index 34260100e..5d7769959 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/DeclarationAVM2Item.java @@ -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 = "*"; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ExceptionAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ExceptionAVM2Item.java index 6324439e7..1c320bf0a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ExceptionAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ExceptionAVM2Item.java @@ -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)); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/FilterAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/FilterAVM2Item.java index 5167163b7..ac44221ba 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/FilterAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/FilterAVM2Item.java @@ -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); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ForEachInAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ForEachInAVM2Item.java index 114463506..9874c3ad6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ForEachInAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ForEachInAVM2Item.java @@ -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 commands; + private boolean labelUsed; @Override public List> 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; } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ForInAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ForInAVM2Item.java index bc302ffba..d0e9bf25a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ForInAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/ForInAVM2Item.java @@ -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 commands; + private boolean labelUsed; @Override public List> 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; } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java index 597d731b5..6cddefef3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java @@ -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(); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java index 6f9530945..045057b48 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/AddAVM2Item.java @@ -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("("); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DeletePropertyAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DeletePropertyAVM2Item.java index 5025e69d9..d9136dea7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DeletePropertyAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/DeletePropertyAVM2Item.java @@ -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("["); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java index 805ee01d2..36db0368e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/model/operations/SubtractAVM2Item.java @@ -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("("); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ASM3Parser.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ASM3Parser.java index 7dcaf85da..bc574c33f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ASM3Parser.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ASM3Parser.java @@ -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); 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 0c18591e3..abd7f6b7f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -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 convertedItems; + public transient Exception convertException; + public List getExceptionEntries() { List 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 scopeStack, final boolean isStaticInitializer, final List 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 scopeStack, final boolean isStaticInitializer, final List 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 scopeStack, final boolean isStaticInitializer, final HilightedTextWriter writer, final List 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 scopeStack, final boolean isStaticInitializer, final List 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() { + @Override + public Void call() throws Exception { + MethodBody converted = convertMethodBody(path, isStatic, scriptIndex, classIndex, abc, trait, constants, method_info, scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits); + HashMap 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(), 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 scopeStack, final boolean isStaticInitializer, final GraphTextWriter writer, final List 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() { - @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 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 scopeStack, boolean isStaticInitializer, HilightedTextWriter writer, List 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 scopeStack, boolean isStaticInitializer, List 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(), deobfuscated.visitCode(b)); - writer.endMethod(); - return writer; + return b; } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java index 4752dcb27..f359a71fc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java @@ -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 fullyQualifiedNames) { + public GraphTextWriter getParamStr(GraphTextWriter writer, ConstantPool constants, MethodBody body, ABC abc, List fullyQualifiedNames) { HashMap 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 fullyQualifiedNames) { + public GraphTextWriter getReturnTypeStr(GraphTextWriter writer, ConstantPool constants, List fullyQualifiedNames) { return writer.hilightSpecial(ret_type == 0 ? "*" : constants.constant_multiname[ret_type].getName(constants, fullyQualifiedNames), "returns"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java index fdf0a5a9c..da0566f24 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java @@ -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 fullyQualifiedNames) { return "method_index=" + init_index + "\r\n" + traits.toString(abc, fullyQualifiedNames); } - - public HilightedTextWriter convert(List 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(), parallel); - } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java index d9faf5ece..0d6058baf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Trait.java @@ -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 abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List fullyQualifiedNames, boolean parallel) { + public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List 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 abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List fullyQualifiedNames, boolean parallel) { + public void convert(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List fullyQualifiedNames, boolean parallel) { + } + + public GraphTextWriter toStringPackaged(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List 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 abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List fullyQualifiedNames, boolean parallel) { - convert(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); + public void convertPackaged(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List 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 abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List 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 abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List 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(), parallel); HilightedTextWriter writer = new HilightedTextWriter(false); - convertPackaged(parent, "", abcList, abc, isStatic, exportMode, scriptIndex, classIndex, writer, new ArrayList(), 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(), parallel); + fos.write(writer.toString().getBytes("utf-8")); } } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java index e33322202..3df3d240a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitClass.java @@ -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 abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List fullyQualifiedNames, boolean parallel) { + public GraphTextWriter toStringHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List 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 abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List fullyQualifiedNames, boolean parallel) { + public void convertHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List fullyQualifiedNames, boolean parallel) { + } + + @Override + public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List 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 abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List 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(), 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(), 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]; diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java index c7e126bcb..5989d72ed 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitFunction.java @@ -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 abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List fullyQualifiedNames, boolean parallel) { + public GraphTextWriter toStringHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List 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 abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List fullyQualifiedNames, boolean parallel) { - convertHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); + public void convertHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List fullyQualifiedNames, boolean parallel) { + } + + @Override + public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List 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 abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List 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(), false, fullyQualifiedNames, null); + } + } + } + @Override public int removeTraps(int scriptIndex, int classIndex, boolean isStatic, ABC abc, String path) { int bodyIndex = abc.findBodyIndex(method_info); diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java index a80cf728d..3d6470842 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitMethodGetterSetter.java @@ -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 abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List fullyQualifiedNames, boolean parallel) { + public void convertHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List fullyQualifiedNames, boolean parallel) { + } + + @Override + public GraphTextWriter toStringHeader(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List 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 abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List fullyQualifiedNames, boolean parallel) { - convertHeader(parent, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, writer, fullyQualifiedNames, parallel); + public void convert(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List 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(), false, fullyQualifiedNames, null); + } + } + } + + @Override + public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List 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(), false, writer, fullyQualifiedNames, null); + abc.bodies[bodyIndex].toString(path, exportMode, isStatic, scriptIndex, classIndex, abc, this, abc.constants, abc.method_info, new Stack(), false, writer, fullyQualifiedNames, null); } writer.appendNoHilight("}"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java index 6c83a6be2..b053dadce 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/TraitSlotConst.java @@ -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 fullyQualifiedNames) { + public GraphTextWriter getNameStr(GraphTextWriter writer, ABC abc, List 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 fullyQualifiedNames) { + public void getValueStr(Trait parent, GraphTextWriter writer, ABC abc, List 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 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 abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List fullyQualifiedNames, boolean parallel) { + public GraphTextWriter toString(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, GraphTextWriter writer, List 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 abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List fullyQualifiedNames, boolean parallel) { + } + public boolean isConst() { return kindType == TRAIT_CONST; } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java index 0f8c8845f..fddecf6d6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/traits/Traits.java @@ -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 { + private class TraitConvertTask implements Callable { Trait trait; boolean makePackages; @@ -84,13 +84,12 @@ public class Traits implements Serializable { ExportMode exportMode; int scriptIndex; int classIndex; - HilightedTextWriter writer; List fullyQualifiedNames; int traitIndex; boolean parallel; Trait parent; - public TraitConvertTask(Trait trait, Trait parent, boolean makePackages, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, HilightedTextWriter writer, List fullyQualifiedNames, int traitIndex, boolean parallel) { + public TraitConvertTask(Trait trait, Trait parent, boolean makePackages, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, int scriptIndex, int classIndex, List 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 abcTags, ABC abc, boolean isStatic, ExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, GraphTextWriter writer, List 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 abcTags, ABC abc, boolean isStatic, ExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, HilightedTextWriter writer, List fullyQualifiedNames, boolean parallel) { + public void convert(Trait parent, String path, List abcTags, ABC abc, boolean isStatic, ExportMode exportMode, boolean makePackages, int scriptIndex, int classIndex, List 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> futureResults = null; + List> 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 future = executor.submit(task); + TraitConvertTask task = new TraitConvertTask(traits[t], parent, makePackages, path, abcTags, abc, isStatic, exportMode, scriptIndex, classIndex, fullyQualifiedNames, t, parallel); + Future 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; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java index afee23d5d..4084adcdb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java @@ -38,16 +38,25 @@ public abstract class ConstVarMultinameUsage extends TraitMultinameUsage { @Override public String toString(List 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(), false); + } else { + ((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, new ArrayList(), 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(), false); + ((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); } else { - ((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); + ((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); } } - ((TraitSlotConst) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); + ((TraitSlotConst) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, new ArrayList(), false); + ((TraitSlotConst) traits.traits[traitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); return writer.toString(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java index e82665caf..81bfcd1f8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java @@ -44,6 +44,17 @@ public abstract class MethodMultinameUsage extends TraitMultinameUsage { @Override public String toString(List 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(), false); + } else { + ((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, new ArrayList(), false); + } + } + ((TraitMethodGetterSetter) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, new ArrayList(), 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(), false); + ((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); } else { - ((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); + ((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); } writer.appendNoHilight(" "); } - ((TraitMethodGetterSetter) traits.traits[traitIndex]).convertHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); + ((TraitMethodGetterSetter) traits.traits[traitIndex]).toStringHeader(null, "", abcTags, abc, isStatic, ExportMode.SOURCE, -1/*FIXME*/, classIndex, writer, new ArrayList(), false); } return writer.toString(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/Action.java b/trunk/src/com/jpexs/decompiler/flash/action/Action.java index b002358da..cb06bdfba 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/Action.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/Action.java @@ -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 listeners, long address, List list, List importantOffsets, int version, ExportMode exportMode, HilightedTextWriter writer, long swfPos, String path) { + public static GraphTextWriter actionsToString(List listeners, long address, List list, List importantOffsets, int version, ExportMode exportMode, GraphTextWriter writer, long swfPos, String path) { return actionsToString(listeners, address, list, importantOffsets, new ArrayList(), version, exportMode, writer, swfPos, path); } @@ -406,7 +409,7 @@ public class Action implements GraphSourceItem { * @param path * @return HilightedTextWriter */ - private static HilightedTextWriter actionsToString(List listeners, long address, List list, List importantOffsets, List constantPool, int version, ExportMode exportMode, HilightedTextWriter writer, long swfPos, String path) { + private static GraphTextWriter actionsToString(List listeners, long address, List list, List importantOffsets, List 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("");/* +"0x"+Helper.formatAddress(a.getFileAddress())+": "+*/; + writer.appendNoHilight("; "); writer.appendNoHilight(Helper.bytesToHexString(a.getBytes(version))); - writer.appendNoHilight("").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 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 actions, final int version, final String path, final HilightedTextWriter writer) { + public static HilightedText actionsToSource(final List actions, final int version, final String path, boolean highlight, int indent) { + List tree = null; + Throwable convertException = null; int timeout = Configuration.getConfig("decompilationTimeoutSingleMethod", 60); - int writerPos = writer.getLength(); try { - Helper.timedCall(new Callable() { + tree = Helper.timedCall(new Callable>() { @Override - public Void call() throws Exception { - //List tree = actionsToTree(new HashMap(), actions, version); + public List call() throws Exception { int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC; - - List tree = actionsToTree(new HashMap(), new HashMap(), new HashMap(), actions, version, staticOperation, path); - Graph.graphToString(tree, writer, new LocalData()); - return null; + List tree = actionsToTree(new HashMap(), new HashMap(), new HashMap(), 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 container, List knownAddreses, List constantPool, int version, ExportMode exportMode, HilightedTextWriter writer) { + public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode, GraphTextWriter writer) { writer.appendNoHilight(getASMSource(container, knownAddreses, constantPool, version, exportMode)); return writer; } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/ActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/ActionItem.java index 9d484ce16..72d8a23bd 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/ActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/ActionItem.java @@ -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); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/AsciiToCharActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/AsciiToCharActionItem.java index e7e108cf7..e01a7b0f4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/AsciiToCharActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/AsciiToCharActionItem.java @@ -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(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/CallActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/CallActionItem.java index 592c33b8f..a95b37306 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/CallActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/CallActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionCall; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.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 CallActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("call("); stripQuotes(value, localData, writer); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/CallFunctionActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/CallFunctionActionItem.java index fe99c950b..a5b0269b4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/CallFunctionActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/CallFunctionActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf5.ActionCallFunction; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -43,7 +43,7 @@ public class CallFunctionActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { String paramStr = ""; stripQuotes(functionName, localData, writer); writer.append("("); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/CallMethodActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/CallMethodActionItem.java index 983aeae50..edc8d02f7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/CallMethodActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/CallMethodActionItem.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf5.ActionCallMethod; import com.jpexs.decompiler.flash.ecma.Undefined; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -49,7 +49,7 @@ public class CallMethodActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { boolean blankMethod = false; if (methodName instanceof DirectValueActionItem) { if (((DirectValueActionItem) methodName).value instanceof Undefined) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/CastOpActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/CastOpActionItem.java index b68294837..62919d609 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/CastOpActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/CastOpActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf7.ActionCastOp; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -46,7 +46,7 @@ public class CastOpActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("("); stripQuotes(constructor, localData, writer); writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/CharToAsciiActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/CharToAsciiActionItem.java index f3f12b780..9ea782984 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/CharToAsciiActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/CharToAsciiActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionCharToAscii; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.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 CharToAsciiActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("ord("); value.toString(writer, localData); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/CloneSpriteActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/CloneSpriteActionItem.java index 690724156..a11837175 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/CloneSpriteActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/CloneSpriteActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionCloneSprite; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -49,7 +49,7 @@ public class CloneSpriteActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("duplicateMovieClip("); target.toString(writer, localData); writer.append(","); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/DecrementActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/DecrementActionItem.java index 44c6fcf81..4cee234a1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/DecrementActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/DecrementActionItem.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf5.ActionDecrement; import com.jpexs.decompiler.flash.ecma.*; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -44,7 +44,7 @@ public class DecrementActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { object.toString(writer, localData); return writer.append(" - 1"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/DefineLocalActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/DefineLocalActionItem.java index f0167cb38..a604d586b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/DefineLocalActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/DefineLocalActionItem.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal; import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal2; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -70,7 +70,7 @@ public class DefineLocalActionItem extends ActionItem implements SetTypeActionIt } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("var "); stripQuotes(name, localData, writer); if (value == null) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/DefineRegisterActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/DefineRegisterActionItem.java index dda24edbd..a777aaae3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/DefineRegisterActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/DefineRegisterActionItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.action.model; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.model.LocalData; /** @@ -35,7 +35,7 @@ public class DefineRegisterActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("var " + identifier); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/DeleteActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/DeleteActionItem.java index 5f0d59ed7..f3a665493 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/DeleteActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/DeleteActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf5.ActionDelete; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -46,7 +46,7 @@ public class DeleteActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("delete "); if (object == null) { return propertyName.toString(writer, localData); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java index ae0607cc7..9cecfeabf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/DirectValueActionItem.java @@ -21,7 +21,7 @@ import com.jpexs.decompiler.flash.action.swf4.ConstantIndex; import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.flash.ecma.Undefined; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -87,7 +87,28 @@ public class DirectValueActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendToNoQuotes(HilightedTextWriter writer, LocalData localData) { + public String toStringNoQuotes(LocalData localData) { + if (value instanceof Double) { + if (Double.compare((double) (Double) value, 0) == 0) { + return "0"; + } + } + if (value instanceof Float) { + if (Float.compare((float) (Float) value, 0) == 0) { + return "0"; + } + } + if (value instanceof String) { + return (String) value; + } + if (value instanceof ConstantIndex) { + return this.constants.get(((ConstantIndex) value).index); + } + return value.toString(); + } + + @Override + protected GraphTextWriter appendToNoQuotes(GraphTextWriter writer, LocalData localData) { if (value instanceof Double) { if (Double.compare((double) (Double) value, 0) == 0) { return writer.append("0"); @@ -128,7 +149,7 @@ public class DirectValueActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { if (value instanceof Double) { if (Double.compare((double) (Double) value, 0) == 0) { return writer.append("0"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/EnumerateActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/EnumerateActionItem.java index 90b349c59..1e194d873 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/EnumerateActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/EnumerateActionItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.action.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.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -41,7 +41,7 @@ public class EnumerateActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("enumerate "); return object.toString(writer, localData); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/EvalActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/EvalActionItem.java index d32560d81..ecffdfc4f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/EvalActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/EvalActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionGetVariable; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -36,7 +36,7 @@ public class EvalActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("eval("); value.toString(writer, localData); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/ExtendsActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/ExtendsActionItem.java index f1bf47359..97d733cb2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/ExtendsActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/ExtendsActionItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.action.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.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -35,7 +35,7 @@ public class ExtendsActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { subclass.toString(writer, localData); writer.append(" extends "); return stripQuotes(superclass, localData, writer); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/FSCommand2ActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/FSCommand2ActionItem.java index 06cb4d580..263241151 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/FSCommand2ActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/FSCommand2ActionItem.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.flashlite.ActionFSCommand2; import com.jpexs.decompiler.flash.action.swf4.ActionPush; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -48,7 +48,7 @@ public class FSCommand2ActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("FSCommand2("); command.toString(writer, localData); for (int t = 0; t < arguments.size(); t++) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/FSCommandActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/FSCommandActionItem.java index 075662271..c2fe43808 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/FSCommandActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/FSCommandActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf3.ActionGetURL; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; @@ -38,7 +38,7 @@ public class FSCommandActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("fscommand(\""); writer.append(Helper.escapeString(command)); return writer.append("\")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java index afca854d0..0f5e7820c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/FunctionActionItem.java @@ -24,7 +24,7 @@ import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; import com.jpexs.decompiler.flash.action.swf5.ActionDefineFunction; import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister; import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; @@ -73,7 +73,7 @@ public class FunctionActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { if (true) { //return writer.appendNoHilight("") } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/GetMemberActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/GetMemberActionItem.java index c9c7a03cb..280625da7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/GetMemberActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/GetMemberActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf5.ActionGetMember; -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; @@ -45,7 +45,7 @@ public class GetMemberActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { if (!((memberName instanceof DirectValueActionItem) && (((DirectValueActionItem) memberName).value instanceof String))) { //if(!(functionName instanceof GetVariableActionItem)) object.toString(writer, localData); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/GetPropertyActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/GetPropertyActionItem.java index dca1fd28d..f079b8ae6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/GetPropertyActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/GetPropertyActionItem.java @@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.swf4.ActionGetProperty; 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.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -47,7 +47,7 @@ public class GetPropertyActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { if (isEmptyString(target)) { return writer.append(Action.propertyNames[propertyIndex]); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/GetTimeActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/GetTimeActionItem.java index 29b6c3c24..c3c2a993f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/GetTimeActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/GetTimeActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionGetTime; -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.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; @@ -31,7 +31,7 @@ public class GetTimeActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("getTimer()"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/GetURL2ActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/GetURL2ActionItem.java index 7afb7b0d0..d00eeeac0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/GetURL2ActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/GetURL2ActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2; -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; @@ -41,7 +41,7 @@ public class GetURL2ActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { String methodStr = ""; if (sendVarsMethod == 1) { methodStr = ",\"GET\""; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/GetURLActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/GetURLActionItem.java index 98d21f624..6c78d3617 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/GetURLActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/GetURLActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf3.ActionGetURL; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; @@ -30,7 +30,7 @@ public class GetURLActionItem extends ActionItem { public String targetString; @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("getUrl(\""); writer.append(Helper.escapeString(urlString) + "\", \"" + Helper.escapeString(targetString)); return writer.append("\")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java index 7711d898b..978e98e8d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/GetVariableActionItem.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionGetVariable; 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.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -48,7 +48,7 @@ public class GetVariableActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return stripQuotes(name, localData, writer); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/GetVersionActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/GetVersionActionItem.java index 3ca236c1e..b6db5a158 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/GetVersionActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/GetVersionActionItem.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionGetVariable; 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.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; @@ -35,7 +35,7 @@ public class GetVersionActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("getVersion()"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/GotoFrame2ActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/GotoFrame2ActionItem.java index 69ec88893..daefcc4e9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/GotoFrame2ActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/GotoFrame2ActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionGotoFrame2; -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; @@ -49,7 +49,7 @@ public class GotoFrame2ActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { String prefix = "gotoAndStop"; if (playFlag) { prefix = "gotoAndPlay"; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/GotoFrameActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/GotoFrameActionItem.java index 88bf6bf7b..f3c7ffe7f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/GotoFrameActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/GotoFrameActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf3.ActionGotoFrame; -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.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; @@ -33,7 +33,7 @@ public class GotoFrameActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("gotoAndStop("); writer.append("" + (frame + 1)); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/GotoLabelActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/GotoLabelActionItem.java index 3cf0923db..3d256797a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/GotoLabelActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/GotoLabelActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf3.ActionGoToLabel; -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.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; @@ -34,7 +34,7 @@ public class GotoLabelActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("gotoAndStop(\""); writer.append(Helper.escapeString(label)); return writer.append("\")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/ImplementsOpActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/ImplementsOpActionItem.java index a2ddefd8d..4a81b136a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/ImplementsOpActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/ImplementsOpActionItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.action.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.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -35,7 +35,7 @@ public class ImplementsOpActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { subclass.toString(writer, localData); writer.append(" implements "); for (int i = 0; i < superclasses.size(); i++) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/IncrementActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/IncrementActionItem.java index 87c485b20..a922c74a1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/IncrementActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/IncrementActionItem.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf5.ActionIncrement; import com.jpexs.decompiler.flash.ecma.*; -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; @@ -44,7 +44,7 @@ public class IncrementActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { object.toString(writer, localData); return writer.append(" + 1"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/InitArrayActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/InitArrayActionItem.java index ac5c44899..04fc4750c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/InitArrayActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/InitArrayActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf5.ActionInitArray; -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; @@ -43,7 +43,7 @@ public class InitArrayActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("["); for (int i = 0; i < values.size(); i++) { if (i > 0) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/InitObjectActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/InitObjectActionItem.java index 7ced47ea0..c6c92efa1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/InitObjectActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/InitObjectActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; 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.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -47,7 +47,7 @@ public class InitObjectActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("{"); for (int i = 0; i < values.size(); i++) { if (i > 0) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/LoadMovieActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/LoadMovieActionItem.java index 11532628f..08a155dd9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/LoadMovieActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/LoadMovieActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2; -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; @@ -51,7 +51,7 @@ public class LoadMovieActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { String methodStr = ""; if (method == 1) { methodStr = ",\"GET\""; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/LoadMovieNumActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/LoadMovieNumActionItem.java index 581c66ed6..716e48f73 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/LoadMovieNumActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/LoadMovieNumActionItem.java @@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.model.operations.AddActionItem; import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2; -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; @@ -53,7 +53,7 @@ public class LoadMovieNumActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { String methodStr = ""; if (method == 1) { methodStr = ",\"GET\""; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/LoadVariablesActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/LoadVariablesActionItem.java index d2fc96826..36317327c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/LoadVariablesActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/LoadVariablesActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2; -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; @@ -51,7 +51,7 @@ public class LoadVariablesActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { String methodStr = ""; if (method == 1) { methodStr = ",\"GET\""; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/LoadVariablesNumActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/LoadVariablesNumActionItem.java index e4a87b46c..ad112b10d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/LoadVariablesNumActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/LoadVariablesNumActionItem.java @@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.model.operations.AddActionItem; import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2; -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; @@ -53,7 +53,7 @@ public class LoadVariablesNumActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { String methodStr = ""; if (method == 1) { methodStr = ",\"GET\""; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/MBAsciiToCharActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/MBAsciiToCharActionItem.java index b0f14aaec..ca8ed4a55 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/MBAsciiToCharActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/MBAsciiToCharActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionMBAsciiToChar; -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 MBAsciiToCharActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("mbchr("); value.toString(writer, localData); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/MBCharToAsciiActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/MBCharToAsciiActionItem.java index 97efb8a9f..eadcf5b03 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/MBCharToAsciiActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/MBCharToAsciiActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionMBCharToAscii; -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 MBCharToAsciiActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("mbord("); value.toString(writer, localData); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/MBStringExtractActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/MBStringExtractActionItem.java index e8568dae9..8d190f61e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/MBStringExtractActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/MBStringExtractActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionMBStringExtract; -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; @@ -49,7 +49,7 @@ public class MBStringExtractActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("mbsubstring("); value.toString(writer, localData); writer.append(","); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/MBStringLengthActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/MBStringLengthActionItem.java index d8c13ba64..6534ee525 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/MBStringLengthActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/MBStringLengthActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionMBStringLength; -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; @@ -34,7 +34,7 @@ public class MBStringLengthActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("mblength("); if (value.precedence > precedence) { writer.append("("); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/NewMethodActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/NewMethodActionItem.java index b7e558eb1..805930e52 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/NewMethodActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/NewMethodActionItem.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf5.ActionNewMethod; 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.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -49,7 +49,7 @@ public class NewMethodActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { boolean blankMethod = false; if (methodName instanceof DirectValueActionItem) { if (((DirectValueActionItem) methodName).value instanceof Undefined) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/NewObjectActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/NewObjectActionItem.java index 90e16144f..4aeb7c15b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/NewObjectActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/NewObjectActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf5.ActionNewObject; -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; @@ -46,7 +46,7 @@ public class NewObjectActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("new "); stripQuotes(objectName, localData, writer); writer.append("("); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/NextFrameActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/NextFrameActionItem.java index 6b976cd97..c48bf77a3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/NextFrameActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/NextFrameActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf3.ActionNextFrame; -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.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; @@ -26,7 +26,7 @@ import java.util.List; public class NextFrameActionItem extends ActionItem { @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("nextFrame()"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/PlayActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/PlayActionItem.java index aaa00d9e5..39bec59fa 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/PlayActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/PlayActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf3.ActionPlay; -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.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; @@ -26,7 +26,7 @@ import java.util.List; public class PlayActionItem extends ActionItem { @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("play()"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/PopActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/PopActionItem.java index 446a73cc5..b85026cd0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/PopActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/PopActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionPop; -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.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; @@ -34,7 +34,7 @@ public class PopActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer; } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/PostDecrementActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/PostDecrementActionItem.java index 049c6c617..02dd73e0e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/PostDecrementActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/PostDecrementActionItem.java @@ -25,7 +25,7 @@ import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; import com.jpexs.decompiler.flash.action.swf5.ActionDecrement; import com.jpexs.decompiler.flash.action.swf5.ActionSetMember; import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister; -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; @@ -51,7 +51,7 @@ public class PostDecrementActionItem extends ActionItem implements SetTypeAction } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { object.toString(writer, localData); return writer.append("--"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/PostIncrementActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/PostIncrementActionItem.java index f79512f3f..44a8fb3e5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/PostIncrementActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/PostIncrementActionItem.java @@ -25,7 +25,7 @@ import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; import com.jpexs.decompiler.flash.action.swf5.ActionIncrement; import com.jpexs.decompiler.flash.action.swf5.ActionSetMember; import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister; -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; @@ -51,7 +51,7 @@ public class PostIncrementActionItem extends ActionItem implements SetTypeAction } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { object.toString(writer, localData); return writer.append("++"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/PrevFrameActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/PrevFrameActionItem.java index 2038b73d7..7796842da 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/PrevFrameActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/PrevFrameActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf3.ActionPrevFrame; -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.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; @@ -26,7 +26,7 @@ import java.util.List; public class PrevFrameActionItem extends ActionItem { @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("prevFrame()"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/PrintActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/PrintActionItem.java index 84236ee8c..e6f204c54 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/PrintActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/PrintActionItem.java @@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.model.operations.AddActionItem; import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2; -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; @@ -51,7 +51,7 @@ public class PrintActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("print("); target.toString(writer, localData); writer.append(","); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/PrintAsBitmapActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/PrintAsBitmapActionItem.java index 54efb1d39..c8f9ee556 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/PrintAsBitmapActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/PrintAsBitmapActionItem.java @@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.model.operations.AddActionItem; import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2; -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; @@ -51,7 +51,7 @@ public class PrintAsBitmapActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("printAsBitmap("); target.toString(writer, localData); writer.append(","); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/PrintAsBitmapNumActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/PrintAsBitmapNumActionItem.java index dc6b863df..e74d7e4e9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/PrintAsBitmapNumActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/PrintAsBitmapNumActionItem.java @@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.model.operations.AddActionItem; import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2; -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; @@ -51,7 +51,7 @@ public class PrintAsBitmapNumActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("printAsBitmapNum("); num.toString(writer, localData); writer.append(","); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/PrintNumActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/PrintNumActionItem.java index c0b172998..968c84f5b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/PrintNumActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/PrintNumActionItem.java @@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.model.operations.AddActionItem; import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2; -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; @@ -51,7 +51,7 @@ public class PrintNumActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("printNum("); num.toString(writer, localData); writer.append(","); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/RandomNumberActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/RandomNumberActionItem.java index 2a5d66f29..1dd2c4403 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/RandomNumberActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/RandomNumberActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionRandomNumber; -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 RandomNumberActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("random("); value.toString(writer, localData); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/RemoveSpriteActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/RemoveSpriteActionItem.java index 1e66aed31..342331cd8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/RemoveSpriteActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/RemoveSpriteActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionRemoveSprite; -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 RemoveSpriteActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("removeMovieClip("); value.toString(writer, localData); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/ReturnActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/ReturnActionItem.java index d7549aa38..eb5855a7f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/ReturnActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/ReturnActionItem.java @@ -26,7 +26,7 @@ import com.jpexs.decompiler.flash.action.swf5.ActionEquals2; import com.jpexs.decompiler.flash.action.swf5.ActionReturn; 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.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -45,7 +45,7 @@ public class ReturnActionItem extends ActionItem 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); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/SetMemberActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/SetMemberActionItem.java index 478edf1aa..5a90b1d4c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/SetMemberActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/SetMemberActionItem.java @@ -21,7 +21,7 @@ import com.jpexs.decompiler.flash.action.swf4.ActionPush; import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; import com.jpexs.decompiler.flash.action.swf5.ActionSetMember; import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister; -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.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; @@ -79,7 +79,7 @@ public class SetMemberActionItem extends ActionItem implements SetTypeActionItem } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { if (!((objectName instanceof DirectValueActionItem) && (((DirectValueActionItem) objectName).value instanceof String))) { //if(!(functionName instanceof GetVariableActionItem)) object.toString(writer, localData); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/SetPropertyActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/SetPropertyActionItem.java index 796011249..c26c1ba5e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/SetPropertyActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/SetPropertyActionItem.java @@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.action.swf4.ActionPush; import com.jpexs.decompiler.flash.action.swf4.ActionSetProperty; import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister; -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.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; @@ -71,7 +71,7 @@ public class SetPropertyActionItem extends ActionItem implements SetTypeActionIt } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { if (isEmptyString(target)) { writer.append(Action.propertyNames[propertyIndex] + " = "); return value.toString(writer, localData); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/SetTarget2ActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/SetTarget2ActionItem.java index 5fb8b9530..b894e6504 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/SetTarget2ActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/SetTarget2ActionItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.action.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.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -34,7 +34,7 @@ public class SetTarget2ActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("tellTarget("); target.toString(writer, localData); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/SetTargetActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/SetTargetActionItem.java index 09a7403df..021972461 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/SetTargetActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/SetTargetActionItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.action.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.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; @@ -33,7 +33,7 @@ public class SetTargetActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("tellTarget(\""); writer.append(Helper.escapeString(target)); return writer.append("\")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/SetVariableActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/SetVariableActionItem.java index 7e2f06408..e0bbb9909 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/SetVariableActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/SetVariableActionItem.java @@ -21,7 +21,7 @@ import com.jpexs.decompiler.flash.action.swf4.ActionPush; import com.jpexs.decompiler.flash.action.swf4.ActionSetVariable; import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister; -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.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; @@ -68,7 +68,7 @@ public class SetVariableActionItem extends ActionItem implements SetTypeActionIt } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { if (name instanceof DirectValueActionItem || name instanceof GetVariableActionItem) { stripQuotes(name, localData, writer); writer.append(" = "); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/StartDragActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/StartDragActionItem.java index f6079ea18..47f478e03 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/StartDragActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/StartDragActionItem.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionStartDrag; import com.jpexs.decompiler.flash.ecma.*; -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; @@ -48,7 +48,7 @@ public class StartDragActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { boolean hasConstrains = true; if (constrain instanceof DirectValueActionItem) { if (Double.compare(EcmaScript.toNumber(constrain.getResult()), 0) == 0) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/StopActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/StopActionItem.java index e04107856..7bb1eff6f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/StopActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/StopActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf3.ActionStop; -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.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; @@ -26,7 +26,7 @@ import java.util.List; public class StopActionItem extends ActionItem { @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("stop()"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/StopAllSoundsActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/StopAllSoundsActionItem.java index 66da981a7..7d4cd3198 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/StopAllSoundsActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/StopAllSoundsActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf3.ActionStopSounds; -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.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; @@ -26,7 +26,7 @@ import java.util.List; public class StopAllSoundsActionItem extends ActionItem { @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("stopAllSounds()"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/StopDragActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/StopDragActionItem.java index ecb2c4ec9..bb8b2893d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/StopDragActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/StopDragActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionEndDrag; -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.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; @@ -26,7 +26,7 @@ import java.util.List; public class StopDragActionItem extends ActionItem { @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("stopDrag()"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java index 50b88579c..0769b18de 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/StoreRegisterActionItem.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister; -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.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; @@ -68,7 +68,7 @@ public class StoreRegisterActionItem extends ActionItem implements SetTypeAction } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { if (temporary) { value.toString(writer, localData); } else { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/StrictModeActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/StrictModeActionItem.java index fe2300d0c..b0cba7f85 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/StrictModeActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/StrictModeActionItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.action.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.model.LocalData; @@ -30,7 +30,7 @@ public class StrictModeActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("StrictMode(" + mode + ");"); //I still don't know how AS source of Strict Mode instruction looks like, assuming this... } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/StringExtractActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/StringExtractActionItem.java index 58dccc0ff..012fb9ada 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/StringExtractActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/StringExtractActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionStringExtract; -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; @@ -39,7 +39,7 @@ public class StringExtractActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { value.toString(writer, localData); writer.append(".substr("); index.toString(writer, localData); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/StringLengthActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/StringLengthActionItem.java index c811b6ae3..3f8b971ae 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/StringLengthActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/StringLengthActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionStringLength; -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; @@ -33,7 +33,7 @@ public class StringLengthActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("length("); value.toString(writer, localData); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/TargetPathActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/TargetPathActionItem.java index 1712a9029..93f01df72 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/TargetPathActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/TargetPathActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf5.ActionTargetPath; -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 TargetPathActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("targetPath("); value.toString(writer, localData); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/TemporaryRegister.java b/trunk/src/com/jpexs/decompiler/flash/action/model/TemporaryRegister.java index cc453b9c2..753935138 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/TemporaryRegister.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/TemporaryRegister.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.action.model; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.model.LocalData; @@ -46,7 +46,7 @@ public class TemporaryRegister extends GraphTargetItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return value.toString(writer, localData); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/ThrowActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/ThrowActionItem.java index ced104426..f896bcc9e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/ThrowActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/ThrowActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf7.ActionThrow; -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 ThrowActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("throw "); return value.toString(writer, localData); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/ToIntegerActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/ToIntegerActionItem.java index ba43409c0..1a4b47a47 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/ToIntegerActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/ToIntegerActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionToInteger; -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 ToIntegerActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("int("); value.toString(writer, localData); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/ToNumberActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/ToNumberActionItem.java index b128976f5..c316b7c66 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/ToNumberActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/ToNumberActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf5.ActionToNumber; -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 ToNumberActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("Number("); value.toString(writer, localData); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/ToStringActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/ToStringActionItem.java index 26392594f..a5966fc34 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/ToStringActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/ToStringActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf5.ActionToString; -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 ToStringActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("String("); value.toString(writer, localData); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/ToggleHighQualityActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/ToggleHighQualityActionItem.java index da2ad1765..a119a23df 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/ToggleHighQualityActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/ToggleHighQualityActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf3.ActionToggleQuality; -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.SourceGenerator; import com.jpexs.decompiler.graph.model.LocalData; @@ -26,7 +26,7 @@ import java.util.List; public class ToggleHighQualityActionItem extends ActionItem { @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("toggleHighQuality()"); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/TraceActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/TraceActionItem.java index a5a7531af..ffbc173bf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/TraceActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/TraceActionItem.java @@ -17,7 +17,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionTrace; -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 TraceActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("trace("); value.toString(writer, localData); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/TypeOfActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/TypeOfActionItem.java index 9ced64842..75371ecf0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/TypeOfActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/TypeOfActionItem.java @@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf5.ActionTypeOf; 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.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -35,7 +35,7 @@ public class TypeOfActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("typeof("); value.toString(writer, localData); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/UnLoadMovieActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/UnLoadMovieActionItem.java index d40c0fb29..6273eb2f9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/UnLoadMovieActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/UnLoadMovieActionItem.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.model; import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2; 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; @@ -47,7 +47,7 @@ public class UnLoadMovieActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("unloadMovie("); targetString.toString(writer, localData); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/UnLoadMovieNumActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/UnLoadMovieNumActionItem.java index da7b9566f..4c9fd63e5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/UnLoadMovieNumActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/UnLoadMovieNumActionItem.java @@ -20,7 +20,7 @@ import com.jpexs.decompiler.flash.action.model.operations.AddActionItem; import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; import com.jpexs.decompiler.flash.action.swf4.ActionGetURL2; 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 class UnLoadMovieNumActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("unloadMovieNum("); num.toString(writer, localData); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/UnsupportedActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/UnsupportedActionItem.java index 01df9e129..b458d01ac 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/UnsupportedActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/UnsupportedActionItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.flash.action.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.model.LocalData; @@ -30,7 +30,7 @@ public class UnsupportedActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("//Unsupported by decompiler:" + value); } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/ClassActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/ClassActionItem.java index 6ab237a27..89d9c5d2e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/ClassActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/ClassActionItem.java @@ -25,7 +25,7 @@ import com.jpexs.decompiler.flash.action.model.GetVariableActionItem; import com.jpexs.decompiler.flash.action.model.SetMemberActionItem; import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.collections.MyEntry; import com.jpexs.decompiler.graph.Block; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -155,7 +155,7 @@ public class ClassActionItem extends ActionItem implements Block { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("class "); className.toStringNoQuotes(writer, localData); if (extendsOp != null) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/ForInActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/ForInActionItem.java index 2aa67ce9c..cb457feb7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/ForInActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/ForInActionItem.java @@ -30,8 +30,9 @@ import com.jpexs.decompiler.flash.action.swf5.ActionEquals2; import com.jpexs.decompiler.flash.action.swf5.ActionStoreRegister; import com.jpexs.decompiler.flash.action.swf6.ActionEnumerate2; 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.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; @@ -48,6 +49,7 @@ public class ForInActionItem extends LoopActionItem implements Block { public GraphTargetItem variableName; public GraphTargetItem enumVariable; public List commands; + private boolean labelUsed; @Override public List> getSubs() { @@ -64,9 +66,18 @@ public class ForInActionItem extends LoopActionItem implements Block { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { - writer.startLoop(loop.id, LoopWithType.LOOP_TYPE_LOOP); - writer.append("loop" + loop.id + ":").newLine(); + public boolean needsSemicolon() { + return false; + } + + @Override + 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("); if ((variableName instanceof DirectValueActionItem) && (((DirectValueActionItem) variableName).value instanceof RegisterNumber)) { writer.append("var "); @@ -82,8 +93,10 @@ public class ForInActionItem extends LoopActionItem 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; } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/IfFrameLoadedActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/IfFrameLoadedActionItem.java index 697d2b4ad..52eb1746f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/IfFrameLoadedActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/IfFrameLoadedActionItem.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.model.clauses; import com.jpexs.decompiler.flash.action.model.ActionItem; import com.jpexs.decompiler.flash.action.swf4.ActionWaitForFrame2; -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.Graph; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -45,7 +45,7 @@ public class IfFrameLoadedActionItem extends ActionItem implements Block { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("ifFrameLoaded("); frame.toString(writer, localData); writer.append(")").newLine(); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/InterfaceActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/InterfaceActionItem.java index 3195b3456..48a85774c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/InterfaceActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/InterfaceActionItem.java @@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.action.model.clauses; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.ActionItem; import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; -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; @@ -43,7 +43,7 @@ public class InterfaceActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("interface "); name.toStringNoQuotes(writer, localData); boolean first = true; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/TellTargetActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/TellTargetActionItem.java index 3567d0d8b..33b30f54c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/TellTargetActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/TellTargetActionItem.java @@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.action.model.clauses; import com.jpexs.decompiler.flash.action.model.ActionItem; import com.jpexs.decompiler.flash.action.swf3.ActionSetTarget; import com.jpexs.decompiler.flash.action.swf4.ActionSetTarget2; -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; @@ -40,7 +40,7 @@ public class TellTargetActionItem extends ActionItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("tellTarget("); target.toString(writer, localData); writer.append(")").newLine(); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/TryActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/TryActionItem.java index 4fb58233e..7e8eff0ec 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/TryActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/TryActionItem.java @@ -23,7 +23,7 @@ import com.jpexs.decompiler.flash.action.model.ConstantPool; import com.jpexs.decompiler.flash.action.parser.script.ActionSourceGenerator; import com.jpexs.decompiler.flash.action.swf4.ActionJump; import com.jpexs.decompiler.flash.action.swf7.ActionTry; -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.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -58,7 +58,7 @@ public class TryActionItem extends ActionItem 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(); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/WithActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/WithActionItem.java index 7e8aa9fa1..de8de6b95 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/WithActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/clauses/WithActionItem.java @@ -20,7 +20,7 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.ActionItem; import com.jpexs.decompiler.flash.action.swf5.ActionWith; -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; @@ -46,7 +46,7 @@ public class WithActionItem extends ActionItem { } @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(); diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AddActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AddActionItem.java index bd29a3740..b3a87c2de 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AddActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/AddActionItem.java @@ -19,7 +19,7 @@ package com.jpexs.decompiler.flash.action.model.operations; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.swf5.ActionAdd2; import com.jpexs.decompiler.flash.ecma.*; -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; @@ -37,7 +37,7 @@ public class AddActionItem extends BinaryOpItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { if (rightSide.precedence >= precedence) { //string + vs number + String ret = ""; if (leftSide.precedence > precedence) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/SubtractActionItem.java b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/SubtractActionItem.java index 1e01a5407..83262dfa4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/model/operations/SubtractActionItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/model/operations/SubtractActionItem.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.action.model.operations; import com.jpexs.decompiler.flash.action.swf4.ActionSubtract; import com.jpexs.decompiler.flash.ecma.*; -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; @@ -38,7 +38,7 @@ public class SubtractActionItem 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 String ret = ""; if (leftSide.precedence > precedence) { diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java index 60a4191ca..779162112 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java @@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.flash.ecma.Undefined; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.GraphSourceItem; @@ -228,7 +229,7 @@ public class ActionPush extends Action { } @Override - public HilightedTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode, HilightedTextWriter writer) { + public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode, GraphTextWriter writer) { if (replacement == null || replacement.size() < values.size()) { return toString(writer); } @@ -239,7 +240,7 @@ public class ActionPush extends Action { return writer; } - public HilightedTextWriter paramsToStringReplaced(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode, HilightedTextWriter writer) { + public GraphTextWriter paramsToStringReplaced(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode, GraphTextWriter writer) { if (replacement == null || replacement.size() < values.size()) { return paramsToString(writer); } @@ -280,7 +281,7 @@ public class ActionPush extends Action { return ret; } - public HilightedTextWriter paramsToString(HilightedTextWriter writer) { + public GraphTextWriter paramsToString(GraphTextWriter writer) { int pos = 0; for (int i = 0; i < values.size(); i++) { if (ignoredParts.contains(i)) { @@ -302,7 +303,7 @@ public class ActionPush extends Action { return writer.toString(); } - public HilightedTextWriter toString(HilightedTextWriter writer) { + public GraphTextWriter toString(GraphTextWriter writer) { writer.appendNoHilight("Push "); paramsToString(writer); return writer; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java index b6ddf3a1c..42b214cb8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineFunction.java @@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.FunctionActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemContainer; @@ -167,7 +167,7 @@ public class ActionDefineFunction extends Action implements GraphSourceItemConta } @Override - public HilightedTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode, HilightedTextWriter writer) { + public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode, GraphTextWriter writer) { List oldParamNames = paramNames; if (replacedParamNames != null) { paramNames = replacedParamNames; diff --git a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java index b5aaee438..7a739896a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/swf7/ActionDefineFunction2.java @@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.FunctionActionItem; import com.jpexs.decompiler.flash.action.parser.ParseException; import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemContainer; @@ -234,7 +234,7 @@ public class ActionDefineFunction2 extends Action implements GraphSourceItemCont } @Override - public HilightedTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode, HilightedTextWriter writer) { + public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ExportMode exportMode, GraphTextWriter writer) { List oldParamNames = paramNames; if (replacedParamNames != null) { paramNames = replacedParamNames; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java index 75fd4f3db..75a88428e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/ASMSourceEditorPane.java @@ -26,6 +26,7 @@ import com.jpexs.decompiler.flash.abc.avm2.parser.ParseException; import com.jpexs.decompiler.flash.abc.types.traits.Trait; import com.jpexs.decompiler.flash.gui.GraphFrame; import com.jpexs.decompiler.flash.gui.View; +import com.jpexs.decompiler.flash.helpers.HilightedText; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; import com.jpexs.decompiler.graph.ExportMode; @@ -49,29 +50,43 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi private DecompiledEditorPane decompiledEditor; private boolean ignoreCarret = false; private String name; - private String textWithHex = ""; - private String textNoHex = ""; - private boolean hex = false; + private HilightedText textWithHex; + private HilightedText textNoHex; + private HilightedText textHexOnly; + private ExportMode exportMode = ExportMode.PCODE; private Trait trait; - public boolean isHex() { - return hex; + public ExportMode getExportMode() { + return exportMode; } - public void switchHex() { - setHex(!hex); + private HilightedText getHilightedText(ExportMode exportMode) { + HilightedTextWriter writer = new HilightedTextWriter(true); + abc.bodies[bodyIndex].code.toASMSource(abc.constants, trait, abc.method_info[abc.bodies[bodyIndex].method_info], abc.bodies[bodyIndex], exportMode, writer); + return new HilightedText(writer); } - - public void setHex(boolean hex) { - if (this.hex == hex) { + + public void setHex(ExportMode exportMode, boolean force) { + if (this.exportMode == exportMode & !force) { return; } - this.hex = hex; + this.exportMode = exportMode; long oldOffset = getSelectedOffset(); - if (hex) { + if (exportMode == ExportMode.PCODE) { + if (textNoHex == null) { + textNoHex = getHilightedText(exportMode); + } + setText(textNoHex); + } else if (exportMode == ExportMode.PCODEWITHHEX) { + if (textWithHex == null) { + textWithHex = getHilightedText(exportMode); + } setText(textWithHex); } else { - setText(textNoHex); + if (textHexOnly == null) { + textHexOnly = new HilightedText(Helper.byteArrToString(abc.bodies[bodyIndex].code.getBytes())); + } + setText(textWithHex); } hilighOffset(oldOffset); } @@ -135,12 +150,9 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi if (bodyIndex == -1) { return; } - HilightedTextWriter writer = new HilightedTextWriter(true); - abc.bodies[bodyIndex].code.toASMSource(abc.constants, trait, abc.method_info[abc.bodies[bodyIndex].method_info], abc.bodies[bodyIndex], ExportMode.PCODEWITHHEX, writer); - String textWithHexTags = writer.toString(); - textWithHex = Helper.hexToComments(textWithHexTags); - textNoHex = Helper.stripComments(textWithHexTags); - setText(hex ? textWithHex : textNoHex); + textWithHex = null; + textNoHex = null; + setHex(exportMode, true); } public void graph() { @@ -193,13 +205,19 @@ public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretLi @Override public void setText(String t) { - disassembledHilights = Highlighting.getInstrHighlights(t); - specialHilights = Highlighting.getSpecialHighlights(t); - t = Highlighting.stripHilights(t); + disassembledHilights = new ArrayList<>(); + specialHilights = new ArrayList<>(); super.setText(t); setCaretPosition(0); } + public void setText(HilightedText hilightedText) { + disassembledHilights = hilightedText.instructionHilights; + specialHilights = hilightedText.specialHilights; + super.setText(hilightedText.text); + setCaretPosition(0); + } + public void selectInstruction(int pos) { String text = getText(); int lineCnt = 1; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/CachedDecompilation.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/CachedDecompilation.java index a207bf97d..8de8a5f23 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/CachedDecompilation.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/CachedDecompilation.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.gui.abc; +import com.jpexs.decompiler.flash.helpers.HilightedText; import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; import java.io.Serializable; import java.util.List; @@ -27,30 +28,38 @@ import java.util.List; public class CachedDecompilation implements Serializable { public String text; - public String hilightedText; + public List traitHilights; + public List classHilights; + public List methodHilights; + public List instructionHilights; + public List specialHilights; - public List getHighlights() { - return Highlighting.getInstrHighlights(hilightedText); + public List getInstructionHighlights() { + return instructionHilights; } public List getTraitHighlights() { - return Highlighting.getTraitHighlights(hilightedText); + return traitHilights; } public List getMethodHighlights() { - return Highlighting.getMethodHighlights(hilightedText); + return methodHilights; } public List getClassHighlights() { - return Highlighting.getClassHighlights(hilightedText); + return classHilights; } public List getSpecialHighligths() { - return Highlighting.getSpecialHighlights(hilightedText); + return specialHilights; } - public CachedDecompilation(String hilightedText) { - this.hilightedText = hilightedText; - this.text = Highlighting.stripHilights(hilightedText); + public CachedDecompilation(HilightedText hilightedText) { + this.text = hilightedText.text; + this.traitHilights = hilightedText.traitHilights; + this.classHilights = hilightedText.classHilights; + this.methodHilights = hilightedText.methodHilights; + this.instructionHilights = hilightedText.instructionHilights; + this.specialHilights = hilightedText.specialHilights; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java index 7726267cd..b04214d75 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java @@ -28,11 +28,11 @@ import com.jpexs.decompiler.flash.abc.types.traits.TraitMethodGetterSetter; import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; import static com.jpexs.decompiler.flash.gui.AppStrings.translate; import com.jpexs.decompiler.flash.gui.View; +import com.jpexs.decompiler.flash.helpers.HilightedText; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; import com.jpexs.decompiler.flash.tags.ABCContainerTag; import com.jpexs.decompiler.graph.ExportMode; -import com.jpexs.decompiler.graph.Graph; import com.jpexs.helpers.Cache; import java.util.ArrayList; import java.util.List; @@ -343,7 +343,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL abcPanel.detailPanel.showCard(DetailPanel.SLOT_CONST_TRAIT_CARD, currentTrait); abcPanel.detailPanel.setEditMode(false); currentMethodHighlight = null; - Highlighting spec = Highlighting.search(specialHighlights, pos, "type", "special", currentTraitHighlight.startPos, currentTraitHighlight.startPos + currentTraitHighlight.len); + Highlighting spec = Highlighting.search(specialHighlights, pos, null, null, currentTraitHighlight.startPos, currentTraitHighlight.startPos + currentTraitHighlight.len); if (spec != null) { abcPanel.detailPanel.slotConstTraitPanel.hilightSpecial(spec); } @@ -445,19 +445,21 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL public void cacheScriptPack(ScriptPack scriptLeaf, List abcList) { int maxCacheSize = 50; int scriptIndex = scriptLeaf.scriptIndex; - String hilightedCode = ""; + HilightedText hilightedCode = null; ScriptInfo script = null; ABC abc = scriptLeaf.abc; if (scriptIndex > -1) { script = abc.script_info[scriptIndex]; } if (!cache.contains(scriptLeaf)) { + for (int scriptTraitIndex : scriptLeaf.traitIndices) { + script.traits.traits[scriptTraitIndex].convertPackaged(null, scriptLeaf.getPath().toString(), abcList, abc, false, ExportMode.SOURCE, scriptIndex, -1, new ArrayList(), Configuration.getConfig("parallelSpeedUp", true)); + } HilightedTextWriter writer = new HilightedTextWriter(true); for (int scriptTraitIndex : scriptLeaf.traitIndices) { - script.traits.traits[scriptTraitIndex].convertPackaged(null, scriptLeaf.getPath().toString(), abcList, abc, false, ExportMode.SOURCE, scriptIndex, -1, writer, new ArrayList(), Configuration.getConfig("parallelSpeedUp", true)); + script.traits.traits[scriptTraitIndex].toStringPackaged(null, scriptLeaf.getPath().toString(), abcList, abc, false, ExportMode.SOURCE, scriptIndex, -1, writer, new ArrayList(), Configuration.getConfig("parallelSpeedUp", true)); } - String s = Graph.removeNonRefenrencedLoopLabels(writer.toString(), true); - hilightedCode = s; + hilightedCode = new HilightedText(writer); cache.put(scriptLeaf, new CachedDecompilation(hilightedCode)); } } @@ -487,7 +489,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL cacheScriptPack(scriptLeaf, abcList); CachedDecompilation cd = getCached(scriptLeaf); final String hilightedCode = cd.text; - highlights = cd.getHighlights(); + highlights = cd.getInstructionHighlights(); specialHighlights = cd.getSpecialHighligths(); traitHighlights = cd.getTraitHighlights(); methodHighlights = cd.getMethodHighlights(); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java index b45b0ba57..5b3a3f329 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/MethodCodePanel.java @@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Trait; import static com.jpexs.decompiler.flash.gui.AppStrings.translate; import com.jpexs.decompiler.flash.gui.Main; import com.jpexs.decompiler.flash.gui.View; +import com.jpexs.decompiler.graph.ExportMode; import java.awt.BorderLayout; import java.awt.Font; import java.awt.Insets; @@ -42,6 +43,7 @@ public class MethodCodePanel extends JPanel implements ActionListener { private ASMSourceEditorPane sourceTextArea; public JPanel buttonsPanel; private JToggleButton hexButton; + private JToggleButton hexOnlyButton; public void focusEditor() { sourceTextArea.requestFocusInWindow(); @@ -106,9 +108,18 @@ public class MethodCodePanel extends JPanel implements ActionListener { hexButton.setToolTipText(translate("button.viewhex")); hexButton.setMargin(new Insets(3, 3, 3, 3)); + // todo: find icon, and set visible + hexOnlyButton = new JToggleButton(View.getIcon("hex16")); + hexOnlyButton.setActionCommand("HEXONLY"); + hexOnlyButton.addActionListener(this); + hexOnlyButton.setToolTipText(translate("button.viewhex")); + hexOnlyButton.setMargin(new Insets(3, 3, 3, 3)); + hexOnlyButton.setVisible(false); + buttonsPanel.add(graphButton); buttonsPanel.add(hexButton); + buttonsPanel.add(hexOnlyButton); buttonsPanel.add(new JPanel()); // buttonsPanel.add(saveButton); // buttonsPan.add(execButton); @@ -125,17 +136,24 @@ public class MethodCodePanel extends JPanel implements ActionListener { sourceTextArea.graph(); } - if (e.getActionCommand().equals("HEX")) { - sourceTextArea.setHex(hexButton.isSelected()); + if (e.getActionCommand().equals("HEX") || e.getActionCommand().equals("HEXONLY")) { + sourceTextArea.setHex(getExportMode(), false); } } + private ExportMode getExportMode() { + ExportMode exportMode = hexOnlyButton.isSelected() ? ExportMode.HEX : + (hexButton.isSelected() ? ExportMode.PCODEWITHHEX : ExportMode.PCODE); + return exportMode; + } + public void setEditMode(boolean val) { if (val) { - sourceTextArea.setHex(false); + sourceTextArea.setHex(ExportMode.PCODE, false); } else { - if (hexButton.isSelected()) { - sourceTextArea.setHex(true); + ExportMode exportMode = getExportMode(); + if (exportMode != ExportMode.PCODE) { + sourceTextArea.setHex(exportMode, false); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java index 1ffa1f4cb..80ce266ec 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/SlotConstTraitDetailPanel.java @@ -102,9 +102,9 @@ public class SlotConstTraitDetailPanel extends JPanel implements TraitDetail { writer.appendNoHilight(" value "); writer.hilightSpecial((new ValueKind(trait.value_index, trait.value_kind).toASMString(abc.constants)), "traitvalue"); String s = writer.toString(); - specialHilights = Highlighting.getSpecialHighlights(s); + specialHilights = writer.specialHilights; showWarning = trait.isConst() || isStatic; - slotConstEditor.setText(Highlighting.stripHilights(s)); + slotConstEditor.setText(s); } @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java b/trunk/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java index 35bd53122..19c85daf5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/abc/TraitsListItem.java @@ -68,12 +68,14 @@ public class TraitsListItem { public String toString() { String s = ""; if ((type != Type.INITIALIZER) && isStatic) { + abc.class_info[classIndex].static_traits.traits[index].convertHeader(null, "", abcTags, abc, true, ExportMode.SOURCE, scriptIndex, classIndex, new ArrayList(), false); HilightedTextWriter writer = new HilightedTextWriter(false); - abc.class_info[classIndex].static_traits.traits[index].convertHeader(null, "", abcTags, abc, true, ExportMode.SOURCE, scriptIndex, classIndex, writer, new ArrayList(), false); + abc.class_info[classIndex].static_traits.traits[index].toStringHeader(null, "", abcTags, abc, true, ExportMode.SOURCE, scriptIndex, classIndex, writer, new ArrayList(), false); s = writer.toString(); } else if ((type != Type.INITIALIZER) && (!isStatic)) { + abc.instance_info[classIndex].instance_traits.traits[index].convertHeader(null, "", abcTags, abc, false, ExportMode.SOURCE, scriptIndex, classIndex, new ArrayList(), false); HilightedTextWriter writer = new HilightedTextWriter(false); - abc.instance_info[classIndex].instance_traits.traits[index].convertHeader(null, "", abcTags, abc, false, ExportMode.SOURCE, scriptIndex, classIndex, writer, new ArrayList(), false); + abc.instance_info[classIndex].instance_traits.traits[index].toStringHeader(null, "", abcTags, abc, false, ExportMode.SOURCE, scriptIndex, classIndex, writer, new ArrayList(), false); s = writer.toString(); } else if (!isStatic) { s = STR_INSTANCE_INITIALIZER; diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index 7e88828fe..f7124bd33 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -34,11 +34,13 @@ import com.jpexs.decompiler.flash.gui.Main; import com.jpexs.decompiler.flash.gui.TagTreeModel; import com.jpexs.decompiler.flash.gui.View; import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane; +import com.jpexs.decompiler.flash.helpers.HilightedText; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.graph.ExportMode; +import static com.jpexs.decompiler.graph.ExportMode.HEX; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.helpers.Cache; import com.jpexs.helpers.Helper; @@ -96,16 +98,15 @@ public class ActionPanel extends JPanel implements ActionListener { public JLabel decLabel = new HeaderLabel(translate("panel.decompiled")); public List decompiledHilights = new ArrayList<>(); public List disassembledHilights = new ArrayList<>(); - public String lastDisasm = ""; private boolean ignoreCarret = false; private boolean editMode = false; private boolean editDecompiledMode = false; private List lastCode; private ASMSource src; public JPanel topButtonsPan; - private String srcWithHex; - private String srcNoHex; - private String srcHexOnly; + private HilightedText srcWithHex; + private HilightedText srcNoHex; + private HilightedText srcHexOnly; private String lastDecompiled = ""; private ASMSource lastASM; public JPanel searchPanel; @@ -174,9 +175,9 @@ public class ActionPanel extends JPanel implements ActionListener { if (actions == null) { actions = src.getActions(SWF.DEFAULT_VERSION); } - String s = Action.actionsToSource(actions, SWF.DEFAULT_VERSION, src.toString()/*FIXME?*/, true, 0); - List hilights = Highlighting.getInstrHighlights(s); - String srcNoHex = Highlighting.stripHilights(s); + HilightedText text = Action.actionsToSource(actions, SWF.DEFAULT_VERSION, src.toString()/*FIXME?*/, true, 0); + List hilights = text.instructionHilights; + String srcNoHex = text.text; cache.put(src, new CachedScript(srcNoHex, hilights)); } } @@ -247,9 +248,9 @@ public class ActionPanel extends JPanel implements ActionListener { return false; } - public void setText(String text) { + public void setText(HilightedText text) { int pos = editor.getCaretPosition(); - Highlighting lastH = new Highlighting(0, 0, 0); + Highlighting lastH = null; for (Highlighting h : disassembledHilights) { if (pos < h.startPos) { break; @@ -258,8 +259,8 @@ public class ActionPanel extends JPanel implements ActionListener { } String offset = lastH == null ? "0" : lastH.getPropertyString("offset"); editor.setText("; " + translate("work.gettinghilights") + "..."); - disassembledHilights = Highlighting.getInstrHighlights(text); - String stripped = Highlighting.stripHilights(text); + disassembledHilights = text.instructionHilights; + String stripped = text.text; /*if(stripped.length()>30000){ editor.setContentType("text/plain"); }else{ @@ -275,10 +276,58 @@ public class ActionPanel extends JPanel implements ActionListener { } - public void setHex(boolean hex, boolean hexOnly) { - setText(hex ? srcWithHex : (hexOnly ? srcHexOnly : srcNoHex)); + private HilightedText getHilightedText(ExportMode exportMode) { + ASMSource asm = (ASMSource) src; + DisassemblyListener listener = getDisassemblyListener(); + asm.addDisassemblyListener(listener); + HilightedTextWriter writer = new HilightedTextWriter(true); + asm.getASMSource(SWF.DEFAULT_VERSION, exportMode, writer, lastCode); + asm.removeDisassemblyListener(listener); + return new HilightedText(writer); + } + + public void setHex(ExportMode exportMode) { + if (exportMode != ExportMode.HEX) { + if (exportMode == exportMode.PCODE) { + if (srcNoHex == null) { + srcNoHex = getHilightedText(exportMode); + } + setText(srcNoHex); + } else { + if (srcWithHex == null) { + srcWithHex = getHilightedText(exportMode); + } + setText(srcWithHex); + } + } else { + if (srcHexOnly == null) { + srcHexOnly = new HilightedText(Helper.byteArrToString(src.getActionBytes())); + } + setText(srcHexOnly); + } } + private DisassemblyListener getDisassemblyListener() { + DisassemblyListener listener = new DisassemblyListener() { + int percent = 0; + String phase = ""; + + @Override + public void progress(String phase, long pos, long total) { + if (total < 1) { + return; + } + int newpercent = (int) (pos * 100 / total); + if (((newpercent > percent) || (!this.phase.equals(phase))) && newpercent <= 100) { + percent = newpercent; + this.phase = phase; + editor.setText("; " + translate("work.disassembling") + " - " + phase + " " + percent + "%..."); + } + } + }; + return listener; + } + public void setSource(final ASMSource src, final boolean useCache) { this.src = src; Main.startWork(translate("work.decompiling") + "..."); @@ -290,34 +339,15 @@ public class ActionPanel extends JPanel implements ActionListener { if (Configuration.getConfig("decompile", true)) { decompiledEditor.setText("//" + translate("work.waitingfordissasembly") + "..."); } - DisassemblyListener listener = new DisassemblyListener() { - int percent = 0; - String phase = ""; - - @Override - public void progress(String phase, long pos, long total) { - if (total < 1) { - return; - } - int newpercent = (int) (pos * 100 / total); - if (((newpercent > percent) || (!this.phase.equals(phase))) && newpercent <= 100) { - percent = newpercent; - this.phase = phase; - editor.setText("; " + translate("work.disassembling") + " - " + phase + " " + percent + "%..."); - } - } - }; + DisassemblyListener listener = getDisassemblyListener(); asm.addDisassemblyListener(listener); List actions = asm.getActions(SWF.DEFAULT_VERSION); lastCode = actions; - HilightedTextWriter writer = new HilightedTextWriter(true); - asm.getASMSource(SWF.DEFAULT_VERSION, ExportMode.PCODEWITHHEX, writer, actions); - lastDisasm = writer.toString(); asm.removeDisassemblyListener(listener); - srcWithHex = Helper.hexToComments(lastDisasm); - srcNoHex = Helper.stripComments(lastDisasm); - srcHexOnly = Helper.byteArrToString(src.getActionBytes()); - setHex(hexButton.isSelected(), hexOnlyButton.isSelected()); + srcWithHex = null; + srcNoHex = null; + srcHexOnly = null; + setHex(getExportMode()); if (Configuration.getConfig("decompile", true)) { decompiledEditor.setText("//" + translate("work.decompiling") + "..."); String stripped = ""; @@ -530,6 +560,7 @@ public class ActionPanel extends JPanel implements ActionListener { } decompiledEditor.getCaret().setVisible(true); int pos = decompiledEditor.getCaretPosition(); + System.out.println("pos: " + pos); Highlighting h = Highlighting.search(decompiledHilights, pos); if (h != null) { Highlighting h2 = Highlighting.search(disassembledHilights, "offset", h.getPropertyString("offset")); @@ -655,10 +686,10 @@ public class ActionPanel extends JPanel implements ActionListener { } else if (e.getActionCommand().equals("EDITACTION")) { setEditMode(true); } else if (e.getActionCommand().equals("HEX")) { - setHex(hexButton.isSelected(), hexOnlyButton.isSelected()); + setHex(getExportMode()); } else if (e.getActionCommand().equals("CANCELACTION")) { setEditMode(false); - setHex(hexButton.isSelected(), hexOnlyButton.isSelected()); + setHex(getExportMode()); } else if (e.getActionCommand().equals("SAVEACTION")) { try { String text = editor.getText(); @@ -698,6 +729,12 @@ public class ActionPanel extends JPanel implements ActionListener { } } + private ExportMode getExportMode() { + ExportMode exportMode = hexOnlyButton.isSelected() ? ExportMode.HEX : + (hexButton.isSelected() ? ExportMode.PCODEWITHHEX : ExportMode.PCODE); + return exportMode; + } + public byte[] getBytesFromHexaText(String text) { Scanner scanner = new Scanner(text); scanner.nextLine(); // ignore first line diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/GraphTextWriter.java b/trunk/src/com/jpexs/decompiler/flash/helpers/GraphTextWriter.java new file mode 100644 index 000000000..44747fc2f --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/helpers/GraphTextWriter.java @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2010-2013 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.helpers; + +import com.jpexs.decompiler.graph.GraphSourceItem; + +/** + * Provides methods for highlighting positions of instructions in the text. + * + * @author JPEXS + */ +public class GraphTextWriter { + + public GraphTextWriter() { + } + + public boolean getIsHighlighted() { + return false; + } + + /** + * Highlights specified text as instruction by adding special tags + * + * @param offset Offset of instruction + * @return HilightedTextWriter + */ + public GraphTextWriter startOffset(GraphSourceItem src, int pos) { + return this; + } + + public GraphTextWriter endOffset() { + return this; + } + + /** + * Highlights specified text as method by adding special tags + * + * @param index MethodInfo index + * @return HilightedTextWriter + */ + public GraphTextWriter startMethod(long index) { + return this; + } + + public GraphTextWriter endMethod() { + return this; + } + + /** + * Highlights specified text as class by adding special tags + * + * @param index Class index + * @return HilightedTextWriter + */ + public GraphTextWriter startClass(long index) { + return this; + } + + public GraphTextWriter endClass() { + return this; + } + + /** + * Highlights specified text as trait by adding special tags + * + * @param index Trait index + * @return HilightedTextWriter + */ + public GraphTextWriter startTrait(long index) { + return this; + } + + public GraphTextWriter endTrait() { + return this; + } + + public GraphTextWriter hilightSpecial(String text, String type) { + return this; + } + + public GraphTextWriter hilightSpecial(String text, String type, int index) { + return this; + } + + public static String hilighOffset(String text, long offset) { + return ""; + } + + public GraphTextWriter append(String str) { + return this; + } + + public GraphTextWriter append(String str, long offset) { + return this; + } + + public GraphTextWriter appendNoHilight(int i) { + return this; + } + + public GraphTextWriter appendNoHilight(String str) { + return this; + } + + public GraphTextWriter indent() { + return this; + } + + public GraphTextWriter unindent() { + return this; + } + + public GraphTextWriter newLine() { + return this; + } + + public GraphTextWriter stripSemicolon() { + return this; + } + + public void setLength(int length) { + } + + public int getLength() { + return 0; + } + + public int getIndent() { + return 0; + } + + @Override + public String toString() { + return ""; + } + + public void mark() { + } + + public boolean getMark() { + return false; + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/HilightType.java b/trunk/src/com/jpexs/decompiler/flash/helpers/HilightType.java new file mode 100644 index 000000000..56484a938 --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/helpers/HilightType.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2010-2013 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.helpers; + +/** + * Provides methods for highlighting positions of instructions in the text. + * + * @author JPEXS + */ +public enum HilightType { + + TRAIT, CLASS, METHOD, OFFSET, SPECIAL + +} diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/HilightedText.java b/trunk/src/com/jpexs/decompiler/flash/helpers/HilightedText.java new file mode 100644 index 000000000..8136ade7a --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/helpers/HilightedText.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2010-2013 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.helpers; + +import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; +import java.io.Serializable; +import java.util.List; + +/** + * Provides methods for highlighting positions of instructions in the text. + * + * @author JPEXS + */ +public class HilightedText implements Serializable { + + public String text; + public List traitHilights; + public List classHilights; + public List methodHilights; + public List instructionHilights; + public List specialHilights; + + public List getTraitHighlights() { + return traitHilights; + } + + public List getMethodHighlights() { + return methodHilights; + } + + public List getClassHighlights() { + return classHilights; + } + + public List getSpecialHighligths() { + return specialHilights; + } + + public HilightedText(HilightedTextWriter writer) { + this.text = writer.toString(); + this.traitHilights = writer.traitHilights; + this.classHilights = writer.classHilights; + this.methodHilights = writer.methodHilights; + this.instructionHilights = writer.instructionHilights; + this.specialHilights = writer.specialHilights; + } + + public HilightedText(String text) { + this.text = text; + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/HilightedTextWriter.java b/trunk/src/com/jpexs/decompiler/flash/helpers/HilightedTextWriter.java index f77a45b3b..843e40728 100644 --- a/trunk/src/com/jpexs/decompiler/flash/helpers/HilightedTextWriter.java +++ b/trunk/src/com/jpexs/decompiler/flash/helpers/HilightedTextWriter.java @@ -16,9 +16,16 @@ */ package com.jpexs.decompiler.flash.helpers; +import com.jpexs.decompiler.flash.Configuration; +import static com.jpexs.decompiler.flash.helpers.HilightType.CLASS; +import static com.jpexs.decompiler.flash.helpers.HilightType.SPECIAL; import com.jpexs.decompiler.flash.helpers.hilight.Highlighting; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.helpers.Helper; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.Stack; /** @@ -26,7 +33,7 @@ import java.util.Stack; * * @author JPEXS */ -public class HilightedTextWriter { +public class HilightedTextWriter extends GraphTextWriter { public static final String INDENT_STRING = " "; private StringBuilder sb = new StringBuilder(); @@ -34,19 +41,31 @@ public class HilightedTextWriter { private boolean newLine = true; private int indent = 0; private Stack offsets = new Stack<>(); - private Stack loopStack = new Stack<>(); private Stack stringAddedStack = new Stack<>(); private boolean stringAdded = false; + private long startTime; + private boolean toStringCalled = false; + private int newLineCount = 0; + private Stack hilightStack = new Stack<>(); + public List traitHilights = new ArrayList<>(); + public List classHilights = new ArrayList<>(); + public List methodHilights = new ArrayList<>(); + public List instructionHilights = new ArrayList<>(); + public List specialHilights = new ArrayList<>(); + public HilightedTextWriter(boolean hilight) { + startTime = System.currentTimeMillis(); this.hilight = hilight; } public HilightedTextWriter(boolean hilight, int indent) { + startTime = System.currentTimeMillis(); this.hilight = hilight; this.indent = indent; } + @Override public boolean getIsHighlighted() { return hilight; } @@ -57,6 +76,7 @@ public class HilightedTextWriter { * @param offset Offset of instruction * @return HilightedTextWriter */ + @Override public HilightedTextWriter startOffset(GraphSourceItem src, int pos) { GraphSourceItemPosition itemPos = new GraphSourceItemPosition(); itemPos.graphSourceItem = src; @@ -65,6 +85,7 @@ public class HilightedTextWriter { return this; } + @Override public HilightedTextWriter endOffset() { offsets.pop(); return this; @@ -76,12 +97,16 @@ public class HilightedTextWriter { * @param index MethodInfo index * @return HilightedTextWriter */ + @Override public HilightedTextWriter startMethod(long index) { - return start("type=method;index=" + index); + Map data = new HashMap<>(); + data.put("index", Long.toString(index)); + return start(data, HilightType.METHOD); } + @Override public HilightedTextWriter endMethod() { - return end(); + return end(HilightType.METHOD); } /** @@ -90,12 +115,16 @@ public class HilightedTextWriter { * @param index Class index * @return HilightedTextWriter */ + @Override public HilightedTextWriter startClass(long index) { - return start("type=class;index=" + index); + Map data = new HashMap<>(); + data.put("index", Long.toString(index)); + return start(data, HilightType.CLASS); } + @Override public HilightedTextWriter endClass() { - return end(); + return end(HilightType.CLASS); } /** @@ -104,128 +133,101 @@ public class HilightedTextWriter { * @param index Trait index * @return HilightedTextWriter */ + @Override public HilightedTextWriter startTrait(long index) { - return start("type=trait;index=" + index); + Map data = new HashMap<>(); + data.put("index", Long.toString(index)); + return start(data, HilightType.TRAIT); } + @Override public HilightedTextWriter endTrait() { - return end(); + return end(HilightType.TRAIT); } + @Override public HilightedTextWriter hilightSpecial(String text, String type) { return hilightSpecial(text, type, 0); } + @Override public HilightedTextWriter hilightSpecial(String text, String type, int index) { - start("type=special;subtype=" + type + ";index=" + index); + Map data = new HashMap<>(); + data.put("subtype", type); + data.put("index", Long.toString(index)); + start(data, HilightType.SPECIAL); appendNoHilight(text); - return end(); + return end(HilightType.SPECIAL); } - public HilightedTextWriter startLoop(long loopId, int loopType) { - LoopWithType loop = new LoopWithType(); - loop.loopId = loopId; - loop.type = loopType; - loopStack.add(loop); - return this; - } - - public HilightedTextWriter endLoop(long loopId) { - LoopWithType loopIdInStack = loopStack.pop(); - if (loopId != loopIdInStack.loopId) { - throw new Error("LoopId mismatch"); - } - return this; - } - - public long getLoop() { - if (loopStack.isEmpty()) { - return -1; - } - return loopStack.peek().loopId; - } - - public long getNonSwitchLoop() { - if (loopStack.isEmpty()) { - return -1; - } - - int pos = loopStack.size() - 1; - LoopWithType loop; - do { - loop = loopStack.get(pos); - pos--; - } while ((pos >= 0) && (loop.type == LoopWithType.LOOP_TYPE_SWITCH)); - - if (loop.type == LoopWithType.LOOP_TYPE_SWITCH) { - return -1; - } - - return loop.loopId; - } - - public static String hilighOffset(String text, long offset) { - String data = "type=instruction;offset=" + offset; - return Highlighting.HLOPEN + Helper.escapeString(data) + Highlighting.HLEND + text + Highlighting.HLCLOSE; - } - + @Override public HilightedTextWriter append(String str) { GraphSourceItemPosition itemPos = offsets.peek(); GraphSourceItem src = itemPos.graphSourceItem; int pos = itemPos.position; + Highlighting h = null; if (src != null && hilight) { - appendToSb(hilighOffset(str, src.getOffset() + pos + 1)); - } else { - appendToSb(str); + Map data = new HashMap<>(); + data.put("offset", Long.toString(src.getOffset() + pos + 1)); + h = new Highlighting(sb.length() - newLineCount, data, HilightType.OFFSET, str); + instructionHilights.add(h); + } + appendToSb(str); + if (h != null) { + h.len = sb.length() - newLineCount - h.startPos; } return this; } + @Override public HilightedTextWriter append(String str, long offset) { + Highlighting h = null; if (hilight) { - appendToSb(hilighOffset(str, offset)); - } else { - appendToSb(str); + Map data = new HashMap<>(); + data.put("offset", Long.toString(offset)); + h = new Highlighting(sb.length() - newLineCount, data, HilightType.OFFSET, str); + instructionHilights.add(h); + } + appendToSb(str); + if (h != null) { + h.len = sb.length() - newLineCount - h.startPos; } return this; } + @Override public HilightedTextWriter appendNoHilight(int i) { appendNoHilight(Integer.toString(i)); return this; } + @Override public HilightedTextWriter appendNoHilight(String str) { appendToSb(str); return this; } - public HilightedTextWriter appendWithoutIndent(String str) { - if (!newLine) { - newLine(); - } - newLine = false; - appendToSb(str); - newLine(); - return this; - } - + @Override public HilightedTextWriter indent() { indent++; return this; } + @Override public HilightedTextWriter unindent() { indent--; return this; } + @Override public HilightedTextWriter newLine() { appendToSb("\r\n"); newLine = true; + newLineCount++; return this; } + @Override public HilightedTextWriter stripSemicolon() { // hack if (sb.charAt(sb.length() - 1) == ';') { @@ -234,50 +236,97 @@ public class HilightedTextWriter { return this; } - public HilightedTextWriter removeFromEnd(int count) { - sb.setLength(sb.length() - count); - return this; - } - + @Override public void setLength(int length) { + if (length >= sb.length()) { + return; + } + + String remove = sb.substring(length); + int removedNewLines = 0; + for (int i = 0; i < remove.length(); i++) { + if (remove.charAt(i) == '\n') { + removedNewLines++; + } + } + newLineCount -= removedNewLines; + sb.setLength(length); } + @Override public int getLength() { return sb.length(); } + @Override public int getIndent() { return indent; } + @Override public String toString() { + if (toStringCalled) { + throw new Error("HilightedTextWriter.toString() was already called."); + } + if (Configuration.debugMode) { + long stopTime = System.currentTimeMillis(); + long time = stopTime - startTime; + if (time > 500) { + System.out.println("Rendering is too slow: " + Helper.formatTimeSec(time) + " length: " + sb.length()); + } + } + toStringCalled = true; return sb.toString(); } + @Override public void mark() { stringAddedStack.add(stringAdded); stringAdded = false; } + @Override public boolean getMark() { boolean result = stringAdded; stringAdded = stringAddedStack.pop() || result; return result; } - private HilightedTextWriter start(String data) { + private HilightedTextWriter start(Map data, HilightType type) { if (hilight) { - sb.append(Highlighting.HLOPEN); - sb.append(Helper.escapeString(data)); - sb.append(Highlighting.HLEND); + Highlighting h = new Highlighting(sb.length() - newLineCount, data, type, null); + hilightStack.add(h); } return this; } - private HilightedTextWriter end() { + private HilightedTextWriter end(HilightType expectedType) { if (hilight) { - sb.append(Highlighting.HLCLOSE); + Highlighting h = hilightStack.pop(); + h.len = sb.length() - newLineCount - h.startPos; + + if (!expectedType.equals(h.type)) { + throw new Error("Hilighting mismatch."); + } + + switch (h.type) { + case CLASS: + classHilights.add(h); + break; + case METHOD: + methodHilights.add(h); + break; + case TRAIT: + traitHilights.add(h); + break; + case SPECIAL: + specialHilights.add(h); + break; + case OFFSET: + instructionHilights.add(h); + break; + } } return this; } diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/LoopWithType.java b/trunk/src/com/jpexs/decompiler/flash/helpers/LoopWithType.java index 965b08895..7c70bdd7d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/helpers/LoopWithType.java +++ b/trunk/src/com/jpexs/decompiler/flash/helpers/LoopWithType.java @@ -28,5 +28,6 @@ public class LoopWithType { public long loopId; public int type; + public boolean used; } diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/NulWriter.java b/trunk/src/com/jpexs/decompiler/flash/helpers/NulWriter.java new file mode 100644 index 000000000..fbe7f9d1d --- /dev/null +++ b/trunk/src/com/jpexs/decompiler/flash/helpers/NulWriter.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2010-2013 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.helpers; + +import java.util.Stack; + +/** + * Provides methods for highlighting positions of instructions in the text. + * + * @author JPEXS + */ +public class NulWriter extends GraphTextWriter { + + private Stack loopStack = new Stack<>(); + + public NulWriter() { + } + + public void startLoop(long loopId, int loopType) { + LoopWithType loop = new LoopWithType(); + loop.loopId = loopId; + loop.type = loopType; + loopStack.add(loop); + } + + public LoopWithType endLoop(long loopId) { + LoopWithType loopIdInStack = loopStack.pop(); + if (loopId != loopIdInStack.loopId) { + throw new Error("LoopId mismatch"); + } + return loopIdInStack; + } + + public long getLoop() { + if (loopStack.isEmpty()) { + return -1; + } + return loopStack.peek().loopId; + } + + public long getNonSwitchLoop() { + if (loopStack.isEmpty()) { + return -1; + } + + int pos = loopStack.size() - 1; + LoopWithType loop; + do { + loop = loopStack.get(pos); + pos--; + } while ((pos >= 0) && (loop.type == LoopWithType.LOOP_TYPE_SWITCH)); + + if (loop.type == LoopWithType.LOOP_TYPE_SWITCH) { + return -1; + } + + return loop.loopId; + } + + public void setLoopUsed(long loopId) { + if (loopStack.isEmpty()) { + return; + } + + int pos = loopStack.size() - 1; + LoopWithType loop = null; + do { + loop = loopStack.get(pos); + pos--; + } while ((pos >= 0) && (loop.loopId != loopId)); + + if (loop.loopId == loopId) { + loop.used = true; + } + } +} diff --git a/trunk/src/com/jpexs/decompiler/flash/helpers/hilight/Highlighting.java b/trunk/src/com/jpexs/decompiler/flash/helpers/hilight/Highlighting.java index c0f8f6698..15b3720c0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/helpers/hilight/Highlighting.java +++ b/trunk/src/com/jpexs/decompiler/flash/helpers/hilight/Highlighting.java @@ -16,17 +16,13 @@ */ package com.jpexs.decompiler.flash.helpers.hilight; -import com.jpexs.helpers.Helper; -import java.io.IOException; +import com.jpexs.decompiler.flash.Configuration; +import com.jpexs.decompiler.flash.helpers.HilightType; import java.io.Serializable; -import java.io.StringReader; -import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Stack; -import java.util.logging.Level; -import java.util.logging.Logger; /** * Provides methods for highlighting positions of instructions in the text. @@ -35,7 +31,8 @@ import java.util.logging.Logger; */ public class Highlighting implements Serializable { - public String data; + public HilightType type; + public String hilightedText; /** * Starting position */ @@ -66,10 +63,6 @@ public class Highlighting implements Serializable { return search(list, pos, null, null, -1, -1); } - public static Highlighting search(List list, long pos, String type) { - return search(list, pos, "type", null, -1, -1); - } - public static Highlighting search(List list, String property, String value) { return search(list, -1, property, value, -1, -1); } @@ -112,6 +105,13 @@ public class Highlighting implements Serializable { return ret; } } + + if (Configuration.debugMode) { + if (ret != null) { + System.out.println("Highlight found: " + ret.hilightedText); + } + } + return ret; } @@ -122,7 +122,7 @@ public class Highlighting implements Serializable { */ @Override public String toString() { - return "" + startPos + "-" + (startPos + len) + " data:" + data; + return startPos + "-" + (startPos + len) + " type:" + type; } /** @@ -130,197 +130,14 @@ public class Highlighting implements Serializable { * @param startPos Starting position * @param len Length of highlighted text * @param data Highlighting data + * @param type Highlighting type */ - public Highlighting(int startPos, int len, String data) { + public Highlighting(int startPos, Map data, HilightType type, String text) { this.startPos = startPos; - this.len = len; - this.data = data; - parseData(); - } - - private void parseData() { - properties = new HashMap<>(); - String pairs[]; - if (data.contains(";")) { - pairs = data.split(";"); - } else { - pairs = new String[]{data}; + this.type = type; + if (Configuration.debugMode) { + this.hilightedText = text; } - for (String p : pairs) { - String keyval[]; - if (p.contains("=")) { - keyval = p.split("="); - } else { - keyval = new String[]{p, p}; - } - properties.put(keyval[0], keyval[1]); - } - } - - public Highlighting(int startPos, int len, long offset) { - this(startPos, len, ""); - } - public static final String HLOPEN = ""; - public static final String HLCLOSE = ""; - - public static List getHilights(String text) { - return getHilights(text, null); - } - - public static List getHilights(String text, String typePrefix) { - text = text.replace("\r\n", "\n"); - List tokens = getHilightTokens(text); - Stack positions = new Stack<>(); - Stack datas = new Stack<>(); - int pos = 0; - List ret = new ArrayList<>(); - for (HilightToken token : tokens) { - switch (token.type) { - case HILIGHTSTART: - positions.push(pos); - datas.push(token.value); - break; - case HILIGHTEND: - int start = positions.pop(); - String data = datas.pop(); - Highlighting hl = new Highlighting(start, pos - start, data); - if (typePrefix == null || data.startsWith(typePrefix)) { - ret.add(hl); - } - break; - case TEXT: - pos += token.tokenLength; - break; - } - } - return ret; - } - - public static List getHilightTokens(String text) { - HilightLexer lexer = new HilightLexer(new StringReader(text)); - HilightToken tok; - List ret = new ArrayList<>(); - try { - while (true) { - tok = lexer.lex(); - if (tok.type == TokenType.EOF) { - break; - } - ret.add(tok); - } - } catch (ParseException | IOException ex) { - Logger.getLogger(Highlighting.class.getName()).log(Level.SEVERE, "Error during getting hilight tokens", ex); - } - return ret; - } - - /** - * Strips all highlights from the text - * - * @param text Text to strip highlights in - * @return Text with no highlights - */ - public static String stripHilights(String text) { - List tokens = getHilightTokens(text); - StringBuilder ret = new StringBuilder(); - for (HilightToken token : tokens) { - if (token.type == TokenType.TEXT) { - ret.append(token.value); - } - } - return ret.toString(); - } - - public static String trim(String highlighted) { - - List tokens = getHilightTokens(highlighted); - boolean first = true; - StringBuilder str = new StringBuilder(); - int lastPos = 0; - int lastLen = 0; - for (HilightToken t : tokens) { - switch (t.type) { - case TEXT: - String s = t.value; - if (first) { - while ((!s.equals("")) && "\r\n ".contains("" + s.charAt(0))) { - s = s.substring(1); - } - first = false; - } - String s2 = s; - lastLen = 0; - while ((!s2.equals("")) && "\r\n ".contains("" + s2.charAt(s2.length() - 1))) { - s2 = s2.substring(0, s2.length() - 1); - lastLen++; - } - str.append(s); - lastPos = str.length(); - break; - case HILIGHTEND: - str.append(HLCLOSE); - break; - case HILIGHTSTART: - str.append(HLOPEN); - str.append(Helper.escapeString(t.value)); - str.append(HLEND); - break; - } - } - if (lastLen > 0) { - str.replace(lastPos - lastLen, lastPos, ""); - } - return str.toString(); - } - - /** - * Gets all trait highlight objects from specified text - * - * @param text Text to get highlights from - * @return List of trait highlights - */ - public static List getTraitHighlights(String text) { - return getHilights(text, "type=trait;"); - } - - /** - * Gets all method highlight objects from specified text - * - * @param text Text to get highlights from - * @return List of method highlights - */ - public static List getMethodHighlights(String text) { - return getHilights(text, "type=method;"); - } - - /** - * Gets all special highlight objects from specified text - * - * @param text Text to get highlights from - * @return List of special highlights - */ - public static List getSpecialHighlights(String text) { - return getHilights(text, "type=special;"); - } - - /** - * Gets all instruction highlight objects from specified text - * - * @param text Text to get highlights from - * @return List of instruction highlights - */ - public static List getInstrHighlights(String text) { - return getHilights(text, "type=instruction;"); - } - - /** - * Gets all class highlight objects from specified text - * - * @param text Text to get highlights from - * @return List of class highlights - */ - public static List getClassHighlights(String text) { - return getHilights(text, "type=class;"); + this.properties = data; } } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java index 21c2cb112..9af76378c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java @@ -25,7 +25,7 @@ import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.abc.CopyOutputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionListReader; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.BoundedTag; import com.jpexs.decompiler.flash.tags.base.ButtonTag; @@ -139,7 +139,7 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT * @return ASM source */ @Override - public HilightedTextWriter getASMSource(int version, ExportMode exportMode, HilightedTextWriter writer, List actions) { + public GraphTextWriter getASMSource(int version, ExportMode exportMode, GraphTextWriter writer, List actions) { if (actions == null) { actions = getActions(version); } @@ -200,7 +200,7 @@ public class DefineButtonTag extends CharacterTag implements ASMSource, BoundedT } @Override - public HilightedTextWriter getActionBytesAsHex(HilightedTextWriter writer) { + public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer) { return Helper.byteArrayToHex(writer, actionBytes); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java index f7961cb12..49a411e8c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoActionTag.java @@ -21,7 +21,7 @@ import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionListReader; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.graph.ExportMode; import com.jpexs.helpers.Helper; @@ -77,7 +77,7 @@ public class DoActionTag extends Tag implements ASMSource { * @return ASM source */ @Override - public HilightedTextWriter getASMSource(int version, ExportMode exportMode, HilightedTextWriter writer, List actions) { + public GraphTextWriter getASMSource(int version, ExportMode exportMode, GraphTextWriter writer, List actions) { if (actions == null) { actions = getActions(version); } @@ -144,7 +144,7 @@ public class DoActionTag extends Tag implements ASMSource { } @Override - public HilightedTextWriter getActionBytesAsHex(HilightedTextWriter writer) { + public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer) { return Helper.byteArrayToHex(writer, actionBytes); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java b/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java index caa2460cc..b599d8e40 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/DoInitActionTag.java @@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionListReader; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.CharacterIdTag; import com.jpexs.decompiler.graph.ExportMode; @@ -103,7 +103,7 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource { * @return ASM source */ @Override - public HilightedTextWriter getASMSource(int version, ExportMode exportMode, HilightedTextWriter writer, List actions) { + public GraphTextWriter getASMSource(int version, ExportMode exportMode, GraphTextWriter writer, List actions) { if (actions == null) { actions = getActions(version); } @@ -153,7 +153,7 @@ public class DoInitActionTag extends CharacterIdTag implements ASMSource { } @Override - public HilightedTextWriter getActionBytesAsHex(HilightedTextWriter writer) { + public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer) { return Helper.byteArrayToHex(writer, actionBytes); } diff --git a/trunk/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java b/trunk/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java index ca71b40cf..88bba9850 100644 --- a/trunk/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java +++ b/trunk/src/com/jpexs/decompiler/flash/tags/base/ASMSource.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.tags.base; import com.jpexs.decompiler.flash.DisassemblyListener; import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.ExportMode; import java.util.List; @@ -36,7 +36,7 @@ public interface ASMSource { * @param hex Add hexadecimal? * @return ASM source */ - public HilightedTextWriter getASMSource(int version, ExportMode exportMode, HilightedTextWriter writer, List actions); + public GraphTextWriter getASMSource(int version, ExportMode exportMode, GraphTextWriter writer, List actions); /** * Whether or not this object contains ASM source @@ -65,7 +65,7 @@ public interface ASMSource { public void setActionBytes(byte[] actionBytes); - public HilightedTextWriter getActionBytesAsHex(HilightedTextWriter writer); + public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer); public long getPos(); diff --git a/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java b/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java index a5dbf8ee7..06c04a09e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/BUTTONCONDACTION.java @@ -20,7 +20,7 @@ import com.jpexs.decompiler.flash.DisassemblyListener; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionListReader; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.ContainerItem; @@ -149,7 +149,7 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem { * @return ASM source */ @Override - public HilightedTextWriter getASMSource(int version, ExportMode exportMode, HilightedTextWriter writer, List actions) { + public GraphTextWriter getASMSource(int version, ExportMode exportMode, GraphTextWriter writer, List actions) { if (actions == null) { actions = getActions(version); } @@ -200,7 +200,7 @@ public class BUTTONCONDACTION implements ASMSource, Exportable, ContainerItem { } @Override - public HilightedTextWriter getActionBytesAsHex(HilightedTextWriter writer) { + public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer) { return Helper.byteArrayToHex(writer, actionBytes); } diff --git a/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java b/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java index e4de6a0e3..6305c030d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java +++ b/trunk/src/com/jpexs/decompiler/flash/types/CLIPACTIONRECORD.java @@ -20,7 +20,7 @@ import com.jpexs.decompiler.flash.DisassemblyListener; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.ActionListReader; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; import com.jpexs.decompiler.flash.tags.base.ContainerItem; @@ -154,7 +154,7 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem { * @return ASM source */ @Override - public HilightedTextWriter getASMSource(int version, ExportMode exportMode, HilightedTextWriter writer, List actions) { + public GraphTextWriter getASMSource(int version, ExportMode exportMode, GraphTextWriter writer, List actions) { if (actions == null) { actions = getActions(version); } @@ -198,7 +198,7 @@ public class CLIPACTIONRECORD implements ASMSource, Exportable, ContainerItem { } @Override - public HilightedTextWriter getActionBytesAsHex(HilightedTextWriter writer) { + public GraphTextWriter getActionBytesAsHex(GraphTextWriter writer) { return Helper.byteArrayToHex(writer, actionBytes); } diff --git a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java index c4cf1fcf7..85beb25df 100644 --- a/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java +++ b/trunk/src/com/jpexs/decompiler/flash/xfl/XFLConverter.java @@ -22,6 +22,7 @@ import com.jpexs.decompiler.flash.RunnableIOEx; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.helpers.HilightedText; import com.jpexs.decompiler.flash.tags.CSMTextSettingsTag; import com.jpexs.decompiler.flash.tags.DefineButton2Tag; import com.jpexs.decompiler.flash.tags.DefineButtonCxformTag; @@ -1111,8 +1112,8 @@ public class XFLConverter { } private static String convertActionScript(ASMSource as) { - String decompiledAS = Action.actionsToSource(as.getActions(SWF.DEFAULT_VERSION), SWF.DEFAULT_VERSION, as.toString(), false, as.getActionSourceIndent()); - return as.getActionSourcePrefix() + decompiledAS + as.getActionSourceSuffix(); + HilightedText decompiledAS = Action.actionsToSource(as.getActions(SWF.DEFAULT_VERSION), SWF.DEFAULT_VERSION, as.toString(), false, as.getActionSourceIndent()); + return as.getActionSourcePrefix() + decompiledAS.text + as.getActionSourceSuffix(); } private static long getTimestamp() { diff --git a/trunk/src/com/jpexs/decompiler/graph/Graph.java b/trunk/src/com/jpexs/decompiler/graph/Graph.java index 12c96d37f..c4b45f88e 100644 --- a/trunk/src/com/jpexs/decompiler/graph/Graph.java +++ b/trunk/src/com/jpexs/decompiler/graph/Graph.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.graph; import com.jpexs.decompiler.flash.action.Action; 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.flash.helpers.hilight.Highlighting; import com.jpexs.decompiler.graph.model.AndItem; import com.jpexs.decompiler.graph.model.BreakItem; @@ -2147,7 +2147,7 @@ public class Graph { * @param localData * @return String */ - public static HilightedTextWriter graphToString(List tree, HilightedTextWriter writer, LocalData localData) { + public static GraphTextWriter graphToString(List tree, GraphTextWriter writer, LocalData localData) { for (GraphTargetItem ti : tree) { if (!ti.isEmpty()) { ti.toStringSemicoloned(writer, localData).newLine(); @@ -2156,43 +2156,6 @@ public class Graph { return writer; } - public static String removeNonRefenrencedLoopLabels(String source, boolean hilighted) { - String[] parts = source.split("\r\n"); - String labelPattern = "loop(switch)?[0-9]*:"; - StringBuilder ret = new StringBuilder(); - for (int p = 0; p < parts.length; p++) { - String strippedP = (hilighted ? Highlighting.stripHilights(parts[p]) : parts[p]).trim(); - if (strippedP.matches(labelPattern)) {//endsWith(":") && (!strippedP.startsWith("case ")) && (!strippedP.equals("default:"))) { - String loopname = strippedP.substring(0, strippedP.length() - 1); - boolean dorefer = false; - for (int q = p + 1; q < parts.length; q++) { - String strippedQ = (hilighted ? Highlighting.stripHilights(parts[q]) : parts[q]).trim(); - if (strippedQ.equals("break " + loopname.replace("switch", "") + ";")) { - dorefer = true; - break; - } - if (strippedQ.equals("continue " + loopname + ";")) { - dorefer = true; - break; - } - if (strippedQ.equals(":" + loopname)) { - break; - } - } - if (!dorefer) { - continue; - } - } - if (strippedP.startsWith(":")) { - continue; - } - - ret.append(parts[p]); - ret.append("\r\n"); - } - return ret.toString(); - } - public List prepareBranchLocalData(List localData) { return localData; } diff --git a/trunk/src/com/jpexs/decompiler/graph/GraphTargetItem.java b/trunk/src/com/jpexs/decompiler/graph/GraphTargetItem.java index b1686a54f..9b01c7c05 100644 --- a/trunk/src/com/jpexs/decompiler/graph/GraphTargetItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/GraphTargetItem.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.graph; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.graph.model.BinaryOp; import com.jpexs.decompiler.graph.model.LocalData; @@ -83,7 +84,7 @@ public abstract class GraphTargetItem implements Serializable { return ret; } - public HilightedTextWriter toStringSemicoloned(HilightedTextWriter writer, LocalData localData) { + public GraphTextWriter toStringSemicoloned(GraphTextWriter writer, LocalData localData) { writer.startOffset(src, pos); appendTo(writer, localData); if (needsSemicolon()) { @@ -102,15 +103,15 @@ public abstract class GraphTargetItem implements Serializable { return this.getClass().getName(); } - public HilightedTextWriter toString(HilightedTextWriter writer, LocalData localData) { + public GraphTextWriter toString(GraphTextWriter writer, LocalData localData) { writer.startOffset(src, pos); appendTo(writer, localData); writer.endOffset(); return writer; } - protected abstract HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData); - + protected abstract GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData); + public String toString(LocalData localData) { HilightedTextWriter writer = new HilightedTextWriter(false); toString(writer, localData); @@ -145,19 +146,17 @@ public abstract class GraphTargetItem implements Serializable { } public String toStringNoQuotes(LocalData localData) { - HilightedTextWriter writer = new HilightedTextWriter(false); - toStringNoQuotes(writer, localData); - return writer.toString(); + return toString(); } - public HilightedTextWriter toStringNoQuotes(HilightedTextWriter writer, LocalData localData) { + public GraphTextWriter toStringNoQuotes(GraphTextWriter writer, LocalData localData) { writer.startOffset(src, pos); appendToNoQuotes(writer, localData); writer.endOffset(); return writer; } - protected HilightedTextWriter appendToNoQuotes(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendToNoQuotes(GraphTextWriter writer, LocalData localData) { return toString(writer, localData); } @@ -173,7 +172,7 @@ public abstract class GraphTargetItem implements Serializable { return false; } - public HilightedTextWriter toStringNL(HilightedTextWriter writer, LocalData localData) { + public GraphTextWriter toStringNL(GraphTextWriter writer, LocalData localData) { writer.startOffset(src, pos); appendTo(writer, localData); if (needsNewLine()) { diff --git a/trunk/src/com/jpexs/decompiler/graph/MarkItem.java b/trunk/src/com/jpexs/decompiler/graph/MarkItem.java index 61922b159..caf6ad919 100644 --- a/trunk/src/com/jpexs/decompiler/graph/MarkItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/MarkItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.graph; -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 MarkItem extends GraphTargetItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("//decompiler mark:" + mark); } diff --git a/trunk/src/com/jpexs/decompiler/graph/NotCompileTimeItem.java b/trunk/src/com/jpexs/decompiler/graph/NotCompileTimeItem.java index cc3099b8b..f5e17c1fd 100644 --- a/trunk/src/com/jpexs/decompiler/graph/NotCompileTimeItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/NotCompileTimeItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.graph; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.model.LocalData; /** @@ -46,7 +46,7 @@ public class NotCompileTimeItem extends GraphTargetItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return object.toString(writer, localData); } diff --git a/trunk/src/com/jpexs/decompiler/graph/model/BinaryOpItem.java b/trunk/src/com/jpexs/decompiler/graph/model/BinaryOpItem.java index e106b148f..e3f45b7b0 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/BinaryOpItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/BinaryOpItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.graph.model; -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.GraphSourceItem; import com.jpexs.decompiler.graph.GraphSourceItemPos; @@ -47,7 +47,7 @@ public abstract class BinaryOpItem extends GraphTargetItem implements BinaryOp { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { if (leftSide.getPrecedence() > precedence) { writer.append("("); leftSide.toString(writer, localData); diff --git a/trunk/src/com/jpexs/decompiler/graph/model/BlockItem.java b/trunk/src/com/jpexs/decompiler/graph/model/BlockItem.java index e2af36a78..983844baf 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/BlockItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/BlockItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.graph.model; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.Graph; import com.jpexs.decompiler.graph.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -37,7 +37,7 @@ public class BlockItem extends GraphTargetItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("{").newLine(); writer.indent(); Graph.graphToString(commands, writer, localData); diff --git a/trunk/src/com/jpexs/decompiler/graph/model/BreakItem.java b/trunk/src/com/jpexs/decompiler/graph/model/BreakItem.java index 39b1c5a00..a8dde8575 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/BreakItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/BreakItem.java @@ -1,6 +1,7 @@ package com.jpexs.decompiler.graph.model; -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.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -13,6 +14,7 @@ import java.util.List; public class BreakItem extends GraphTargetItem { public long loopId; + private boolean labelRequired; public BreakItem(GraphSourceItem src, long loopId) { super(src, NOPRECEDENCE); @@ -20,9 +22,16 @@ public class BreakItem extends GraphTargetItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("break"); - if (loopId != writer.getLoop()) { + if (writer instanceof NulWriter) { + NulWriter nulWriter = (NulWriter) writer; + labelRequired = loopId != nulWriter.getLoop(); + if (labelRequired) { + nulWriter.setLoopUsed(loopId); + } + } + if (labelRequired) { writer.append(" loop" + loopId); } return writer; diff --git a/trunk/src/com/jpexs/decompiler/graph/model/CommaExpressionItem.java b/trunk/src/com/jpexs/decompiler/graph/model/CommaExpressionItem.java index 1be01b6b5..b9d3e3bca 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/CommaExpressionItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/CommaExpressionItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.graph.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.SourceGenerator; @@ -36,7 +36,7 @@ public class CommaExpressionItem extends GraphTargetItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { boolean first = true; for (GraphTargetItem t : commands) { if (!first) { diff --git a/trunk/src/com/jpexs/decompiler/graph/model/CommentItem.java b/trunk/src/com/jpexs/decompiler/graph/model/CommentItem.java index bdb25b239..1639507c8 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/CommentItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/CommentItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.graph.model; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphTargetItem; /** @@ -33,7 +33,7 @@ public class CommentItem extends GraphTargetItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("/* " + comment + " */"); } diff --git a/trunk/src/com/jpexs/decompiler/graph/model/ContinueItem.java b/trunk/src/com/jpexs/decompiler/graph/model/ContinueItem.java index 24b28e2b4..88dcaf1d1 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/ContinueItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/ContinueItem.java @@ -1,6 +1,7 @@ package com.jpexs.decompiler.graph.model; -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.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.SourceGenerator; @@ -13,6 +14,7 @@ import java.util.List; public class ContinueItem extends GraphTargetItem { public long loopId; + private boolean labelRequired; public ContinueItem(GraphSourceItem src, long loopId) { super(src, NOPRECEDENCE); @@ -20,9 +22,16 @@ public class ContinueItem extends GraphTargetItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("continue"); - if (loopId != writer.getNonSwitchLoop()) { + if (writer instanceof NulWriter) { + NulWriter nulWriter = (NulWriter) writer; + labelRequired = loopId != nulWriter.getNonSwitchLoop(); + if (labelRequired) { + nulWriter.setLoopUsed(loopId); + } + } + if (labelRequired) { writer.append(" loop" + loopId); } return writer; diff --git a/trunk/src/com/jpexs/decompiler/graph/model/DoWhileItem.java b/trunk/src/com/jpexs/decompiler/graph/model/DoWhileItem.java index b11930068..1ab5d0523 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/DoWhileItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/DoWhileItem.java @@ -16,8 +16,9 @@ */ package com.jpexs.decompiler.graph.model; -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; @@ -30,6 +31,7 @@ public class DoWhileItem extends LoopItem implements Block { public List commands; public List expression; + private boolean labelUsed; @Override public boolean needsSemicolon() { @@ -50,9 +52,13 @@ public class DoWhileItem 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("do").newLine(); writer.append("{").newLine(); writer.indent(); @@ -76,8 +82,10 @@ public class DoWhileItem extends LoopItem implements Block { } 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; } diff --git a/trunk/src/com/jpexs/decompiler/graph/model/DuplicateItem.java b/trunk/src/com/jpexs/decompiler/graph/model/DuplicateItem.java index f22de66f1..3f9f7b779 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/DuplicateItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/DuplicateItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.graph.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.SourceGenerator; @@ -39,7 +39,7 @@ public class DuplicateItem extends GraphTargetItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return value.toString(writer, localData); } diff --git a/trunk/src/com/jpexs/decompiler/graph/model/ForItem.java b/trunk/src/com/jpexs/decompiler/graph/model/ForItem.java index 4021aec85..d07672e38 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/ForItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/ForItem.java @@ -16,8 +16,9 @@ */ package com.jpexs.decompiler.graph.model; -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; @@ -32,6 +33,7 @@ public class ForItem extends LoopItem implements Block { public GraphTargetItem expression; public List finalCommands; public List commands; + private boolean labelUsed; @Override public List> getSubs() { @@ -51,9 +53,13 @@ public class ForItem 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("); int p = 0; for (int i = 0; i < firstCommands.size(); i++) { @@ -93,8 +99,10 @@ public class ForItem extends LoopItem implements Block { } writer.unindent(); writer.append("}").newLine(); - writer.append(":loop" + loop.id).newLine(); - writer.endLoop(loop.id); + if (writer instanceof NulWriter) { + LoopWithType loopOjb = ((NulWriter)writer).endLoop(loop.id); + labelUsed = loopOjb.used; + } return writer; } diff --git a/trunk/src/com/jpexs/decompiler/graph/model/IfItem.java b/trunk/src/com/jpexs/decompiler/graph/model/IfItem.java index 47c6d85d4..5d9ac8210 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/IfItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/IfItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.graph.model; -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.GraphSourceItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -51,7 +51,7 @@ public class IfItem extends GraphTargetItem implements Block { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { GraphTargetItem expr = expression; List ifBranch = onTrue; List elseBranch = onFalse; diff --git a/trunk/src/com/jpexs/decompiler/graph/model/IntegerValueItem.java b/trunk/src/com/jpexs/decompiler/graph/model/IntegerValueItem.java index b06110c4f..ce803c004 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/IntegerValueItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/IntegerValueItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.graph.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; @@ -34,7 +34,7 @@ public class IntegerValueItem extends GraphTargetItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("" + intValue); } diff --git a/trunk/src/com/jpexs/decompiler/graph/model/ParenthesisItem.java b/trunk/src/com/jpexs/decompiler/graph/model/ParenthesisItem.java index 678bfdc20..33217e10f 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/ParenthesisItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/ParenthesisItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.graph.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.SourceGenerator; @@ -34,7 +34,7 @@ public class ParenthesisItem extends GraphTargetItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append("("); value.toString(writer, localData); return writer.append(")"); diff --git a/trunk/src/com/jpexs/decompiler/graph/model/ScriptEndItem.java b/trunk/src/com/jpexs/decompiler/graph/model/ScriptEndItem.java index f1bfd1a0f..6394bd02c 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/ScriptEndItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/ScriptEndItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.graph.model; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.graph.GraphTargetItem; /** @@ -30,7 +30,7 @@ public class ScriptEndItem extends GraphTargetItem implements ExitItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer; } diff --git a/trunk/src/com/jpexs/decompiler/graph/model/SwitchItem.java b/trunk/src/com/jpexs/decompiler/graph/model/SwitchItem.java index 4a24bef89..5831aec68 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/SwitchItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/SwitchItem.java @@ -16,8 +16,9 @@ */ package com.jpexs.decompiler.graph.model; -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; @@ -33,6 +34,7 @@ public class SwitchItem extends LoopItem implements Block { public List> caseCommands; public List defaultCommands; public List valuesMapping; + private boolean labelUsed; @Override public List> getSubs() { @@ -52,9 +54,18 @@ public class SwitchItem extends LoopItem implements Block { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { - writer.startLoop(loop.id, LoopWithType.LOOP_TYPE_SWITCH); - writer.append("loopswitch" + loop.id + ":").newLine(); + public boolean needsSemicolon() { + return false; + } + + @Override + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { + if (writer instanceof NulWriter) { + ((NulWriter)writer).startLoop(loop.id, LoopWithType.LOOP_TYPE_SWITCH); + } + if (labelUsed) { + writer.append("loopswitch" + loop.id + ":").newLine(); + } writer.append("switch("); switchedObject.toString(writer, localData); writer.append(")").newLine(); @@ -91,8 +102,10 @@ public class SwitchItem 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; } diff --git a/trunk/src/com/jpexs/decompiler/graph/model/TernarOpItem.java b/trunk/src/com/jpexs/decompiler/graph/model/TernarOpItem.java index f294e642e..17169ce26 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/TernarOpItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/TernarOpItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.graph.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.SourceGenerator; @@ -36,7 +36,7 @@ public class TernarOpItem extends GraphTargetItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { expression.toString(writer, localData); writer.append("?"); onTrue.toString(writer, localData); diff --git a/trunk/src/com/jpexs/decompiler/graph/model/TrueItem.java b/trunk/src/com/jpexs/decompiler/graph/model/TrueItem.java index 8dc6b75c5..f17e81420 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/TrueItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/TrueItem.java @@ -1,6 +1,6 @@ package com.jpexs.decompiler.graph.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; @@ -15,7 +15,7 @@ public class TrueItem extends GraphTargetItem { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { return writer.append("true"); } diff --git a/trunk/src/com/jpexs/decompiler/graph/model/UnaryOpItem.java b/trunk/src/com/jpexs/decompiler/graph/model/UnaryOpItem.java index 077d3f800..6b5f723a4 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/UnaryOpItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/UnaryOpItem.java @@ -16,7 +16,7 @@ */ package com.jpexs.decompiler.graph.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.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -34,7 +34,7 @@ public abstract class UnaryOpItem extends GraphTargetItem implements UnaryOp { } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { + protected GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) { writer.append(operator); if (value != null) { if (value.precedence > precedence) { diff --git a/trunk/src/com/jpexs/decompiler/graph/model/UniversalLoopItem.java b/trunk/src/com/jpexs/decompiler/graph/model/UniversalLoopItem.java index 6f46998f5..a8364e3e9 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/UniversalLoopItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/UniversalLoopItem.java @@ -16,8 +16,9 @@ */ package com.jpexs.decompiler.graph.model; -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; @@ -32,15 +33,25 @@ import java.util.List; public class UniversalLoopItem extends LoopItem implements Block { public List commands; + private boolean labelUsed; public UniversalLoopItem(GraphSourceItem src, Loop loop) { super(src, loop); } @Override - protected HilightedTextWriter appendTo(HilightedTextWriter writer, LocalData localData) { - writer.startLoop(loop.id, LoopWithType.LOOP_TYPE_LOOP); - writer.append("loop" + loop.id + ":").newLine(); + public boolean needsSemicolon() { + return false; + } + + @Override + 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("while(true)").newLine(); writer.append("{").newLine(); writer.indent(); @@ -51,8 +62,10 @@ public class UniversalLoopItem 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; } diff --git a/trunk/src/com/jpexs/decompiler/graph/model/WhileItem.java b/trunk/src/com/jpexs/decompiler/graph/model/WhileItem.java index 5b5e4980f..2d1f28533 100644 --- a/trunk/src/com/jpexs/decompiler/graph/model/WhileItem.java +++ b/trunk/src/com/jpexs/decompiler/graph/model/WhileItem.java @@ -16,8 +16,9 @@ */ package com.jpexs.decompiler.graph.model; -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; @@ -30,6 +31,7 @@ public class WhileItem extends LoopItem implements Block { public List expression; public List commands; + private boolean labelUsed; @Override public List> getSubs() { @@ -45,9 +47,13 @@ public class WhileItem 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("while("); for (int i = 0; i < expression.size(); i++) { if (expression.get(i).isEmpty()) { @@ -68,8 +74,10 @@ public class WhileItem 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; } diff --git a/trunk/src/com/jpexs/helpers/Helper.java b/trunk/src/com/jpexs/helpers/Helper.java index 8d8549eb3..579092fe1 100644 --- a/trunk/src/com/jpexs/helpers/Helper.java +++ b/trunk/src/com/jpexs/helpers/Helper.java @@ -17,6 +17,7 @@ package com.jpexs.helpers; import com.jpexs.decompiler.flash.gui.Freed; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.model.LocalData; @@ -373,13 +374,13 @@ public class Helper { } } - public static String stripComments(String str) { - return str.replaceAll("[^\r\n]*\r?\n", ""); - } + //public static String stripComments(String str) { + // return str.replaceAll("[^\r\n]*\r?\n", ""); + //} - public static String hexToComments(String str) { - return str.replaceAll("([^\r\n]*)(\r?\n)", "; $1$2"); - } + //public static String hexToComments(String str) { + // return str.replaceAll("([^\r\n]*)(\r?\n)", "; $1$2"); + //} public static String stackToString(Stack stack, LocalData localData) { String ret = "["; @@ -549,7 +550,7 @@ public class Helper { return timeStr; } - public static HilightedTextWriter byteArrayToHex(HilightedTextWriter writer, byte[] data) { + public static GraphTextWriter byteArrayToHex(GraphTextWriter writer, byte[] data) { writer.appendNoHilight("#hexdata").newLine(); /* // hex data from decompiled actions diff --git a/trunk/test/com/jpexs/decompiler/flash/ActionScript2AssemblerTest.java b/trunk/test/com/jpexs/decompiler/flash/ActionScript2AssemblerTest.java index eb7cde301..8a58a8410 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.HilightedText; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.tags.DoActionTag; import com.jpexs.decompiler.graph.ExportMode; @@ -40,12 +41,12 @@ 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, 0); + HilightedText actualResult = Action.actionsToSource(doa.getActions(swf.version), swf.version, "", false, 0); HilightedTextWriter writer = new HilightedTextWriter(false); doa.getASMSource(swf.version, ExportMode.PCODE, writer, null); String decompiled = writer.toString(); - assertEquals(actualResult.trim(), "ok = false;"); + assertEquals(actualResult.text.trim(), "ok = false;"); assertTrue(decompiled.contains("Push \"ok\" false")); } catch (IOException | ParseException ex) { fail(); diff --git a/trunk/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java b/trunk/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java index 497a42b6e..21df5922f 100644 --- a/trunk/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java +++ b/trunk/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java @@ -19,6 +19,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.HilightedText; import com.jpexs.decompiler.flash.tags.DoActionTag; import java.io.FileInputStream; import java.io.IOException; @@ -73,9 +74,9 @@ 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, 0); + HilightedText actualResult = Action.actionsToSource(doa.getActions(swf.version), swf.version, "", false, 0); - assertTrue(actualResult.contains("case \"c\":")); + assertTrue(actualResult.text.contains("case \"c\":")); } catch (IOException | ParseException ex) { fail(); } diff --git a/trunk/test/com/jpexs/decompiler/flash/ActionScript2Test.java b/trunk/test/com/jpexs/decompiler/flash/ActionScript2Test.java index 0c67ff49c..990656308 100644 --- a/trunk/test/com/jpexs/decompiler/flash/ActionScript2Test.java +++ b/trunk/test/com/jpexs/decompiler/flash/ActionScript2Test.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash; import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.helpers.HilightedText; import com.jpexs.decompiler.flash.tags.DoActionTag; import com.jpexs.decompiler.flash.tags.ShowFrameTag; import com.jpexs.decompiler.flash.tags.Tag; @@ -41,8 +42,8 @@ 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, 0); - actualResult = actualResult.replaceAll("[ \r\n]", ""); + HilightedText hilightedText = Action.actionsToSource(doa.getActions(swf.version), swf.version, "", false, 0); + String actualResult = hilightedText.text.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 5ad1fb466..54b3bdd74 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.HilightedText; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import com.jpexs.decompiler.flash.tags.Tag; @@ -44,8 +45,8 @@ 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, ExportMode.SOURCE, 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]", ""); + HilightedTextWriter writer = abc.bodies[bodyIndex].toString(methodName, ExportMode.SOURCE, isStatic, -1/*FIX?*/, clsIndex, abc,null, abc.constants, abc.method_info, new Stack(), false, new ArrayList(), abc.instance_info[clsIndex].instance_traits); + String actualResult = writer.toString().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 8d022d142..67e72ff9e 100644 --- a/trunk/test/com/jpexs/decompiler/flash/generators/AS2Generator.java +++ b/trunk/test/com/jpexs/decompiler/flash/generators/AS2Generator.java @@ -3,6 +3,7 @@ package com.jpexs.decompiler.flash.generators; import com.jpexs.decompiler.flash.Configuration; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.helpers.HilightedText; import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import com.jpexs.decompiler.flash.tags.DoActionTag; import com.jpexs.decompiler.flash.tags.ShowFrameTag; @@ -34,7 +35,8 @@ public class AS2Generator { if (doa == null) { continue; } - String src = Action.actionsToSource(doa.getActions(swf.version), swf.version,"",false, 0); + HilightedText hilightedText = Action.actionsToSource(doa.getActions(swf.version), swf.version,"",false, 0); + String src = hilightedText.text; 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 424e6e169..93db3da44 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.HilightedText; import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; import com.jpexs.decompiler.flash.tags.DoABCDefineTag; import com.jpexs.decompiler.flash.tags.Tag; @@ -45,8 +46,8 @@ public class AS3Generator { s.append("(){\r\ndecompileMethod(\""); s.append(name); s.append("\", "); - String src = abc.findBody(((TraitMethodGetterSetter) t).method_info).toString("", ExportMode.SOURCE, 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]+"); + HilightedTextWriter src = abc.findBody(((TraitMethodGetterSetter) t).method_info).toString("", ExportMode.SOURCE, 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.toString().split("[\r\n]+"); for (int i = 0; i < srcs.length; i++) { String ss = srcs[i]; s.append("\"");