From be106cc34bf9fdc50aa82c5929f2cf5e1d0145e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=F8=EDk?= Date: Sat, 30 Mar 2013 16:43:26 +0100 Subject: [PATCH] Issue #45 Unicode character cannot save Code formatting --- .../jpexs/decompiler/flash/Configuration.java | 374 +- .../jpexs/decompiler/flash/EventListener.java | 2 +- .../src/com/jpexs/decompiler/flash/Main.java | 1415 +- .../decompiler/flash/PercentListener.java | 2 +- .../flash/ReReadableInputStream.java | 94 +- trunk/src/com/jpexs/decompiler/flash/SWF.java | 1878 +- .../decompiler/flash/SWFInputStream.java | 5344 +- .../decompiler/flash/SWFOutputStream.java | 2936 +- .../com/jpexs/decompiler/flash/abc/ABC.java | 1518 +- .../decompiler/flash/abc/ABCInputStream.java | 638 +- .../decompiler/flash/abc/ABCOutputStream.java | 436 +- .../flash/abc/CopyOutputStream.java | 82 +- .../flash/abc/NotSameException.java | 6 +- .../decompiler/flash/abc/avm2/AVM2Code.java | 4742 +- .../decompiler/flash/abc/avm2/CodeStats.java | 52 +- .../flash/abc/avm2/ConstantPool.java | 228 +- .../flash/abc/avm2/ConvertException.java | 10 +- .../flash/abc/avm2/ConvertOutput.java | 12 +- .../flash/abc/avm2/InstructionStats.java | 14 +- .../abc/avm2/InvalidInstructionArguments.java | 6 +- .../flash/abc/avm2/LocalDataArea.java | 6 +- .../abc/avm2/UnknownInstructionCode.java | 10 +- .../flash/abc/avm2/UnknownJumpException.java | 24 +- .../flash/abc/avm2/graph/AVM2Graph.java | 2916 +- .../flash/abc/avm2/graph/AVM2GraphSource.java | 94 +- .../avm2/instructions/AVM2Instruction.java | 460 +- .../abc/avm2/instructions/IfTypeIns.java | 2 +- .../instructions/InstructionDefinition.java | 158 +- .../abc/avm2/instructions/SetTypeIns.java | 2 +- .../abc/avm2/instructions/TagInstruction.java | 6 +- .../avm2/instructions/arithmetic/AddIIns.java | 28 +- .../avm2/instructions/arithmetic/AddIns.java | 68 +- .../arithmetic/DecrementIIns.java | 56 +- .../instructions/arithmetic/DecrementIns.java | 56 +- .../instructions/arithmetic/DivideIns.java | 66 +- .../arithmetic/IncrementIIns.java | 22 +- .../instructions/arithmetic/IncrementIns.java | 22 +- .../instructions/arithmetic/ModuloIns.java | 48 +- .../instructions/arithmetic/MultiplyIIns.java | 26 +- .../instructions/arithmetic/MultiplyIns.java | 66 +- .../instructions/arithmetic/NegateIIns.java | 24 +- .../instructions/arithmetic/NegateIns.java | 24 +- .../avm2/instructions/arithmetic/NotIns.java | 24 +- .../instructions/arithmetic/SubtractIIns.java | 26 +- .../instructions/arithmetic/SubtractIns.java | 26 +- .../avm2/instructions/bitwise/BitAndIns.java | 40 +- .../avm2/instructions/bitwise/BitNotIns.java | 36 +- .../avm2/instructions/bitwise/BitOrIns.java | 40 +- .../avm2/instructions/bitwise/BitXorIns.java | 40 +- .../avm2/instructions/bitwise/LShiftIns.java | 26 +- .../avm2/instructions/bitwise/RShiftIns.java | 26 +- .../avm2/instructions/bitwise/URShiftIns.java | 26 +- .../instructions/comparsion/EqualsIns.java | 40 +- .../comparsion/GreaterEqualsIns.java | 26 +- .../comparsion/GreaterThanIns.java | 26 +- .../comparsion/LessEqualsIns.java | 26 +- .../instructions/comparsion/LessThanIns.java | 26 +- .../comparsion/StrictEqualsIns.java | 26 +- .../construction/ConstructIns.java | 136 +- .../construction/ConstructPropIns.java | 100 +- .../construction/ConstructSuperIns.java | 58 +- .../construction/NewActivationIns.java | 22 +- .../construction/NewArrayIns.java | 32 +- .../construction/NewCatchIns.java | 24 +- .../construction/NewClassIns.java | 26 +- .../construction/NewFunctionIns.java | 46 +- .../construction/NewObjectIns.java | 36 +- .../avm2/instructions/debug/DebugFileIns.java | 6 +- .../abc/avm2/instructions/debug/DebugIns.java | 6 +- .../avm2/instructions/debug/DebugLineIns.java | 6 +- .../avm2/instructions/executing/CallIns.java | 60 +- .../instructions/executing/CallMethodIns.java | 62 +- .../executing/CallPropLexIns.java | 56 +- .../executing/CallPropVoidIns.java | 84 +- .../executing/CallPropertyIns.java | 82 +- .../instructions/executing/CallStaticIns.java | 62 +- .../instructions/executing/CallSuperIns.java | 82 +- .../executing/CallSuperVoidIns.java | 82 +- .../abc/avm2/instructions/jumps/IfEqIns.java | 38 +- .../avm2/instructions/jumps/IfFalseIns.java | 34 +- .../abc/avm2/instructions/jumps/IfGeIns.java | 38 +- .../abc/avm2/instructions/jumps/IfGtIns.java | 38 +- .../abc/avm2/instructions/jumps/IfLeIns.java | 38 +- .../abc/avm2/instructions/jumps/IfLtIns.java | 38 +- .../abc/avm2/instructions/jumps/IfNGeIns.java | 38 +- .../abc/avm2/instructions/jumps/IfNGtIns.java | 38 +- .../abc/avm2/instructions/jumps/IfNLeIns.java | 38 +- .../abc/avm2/instructions/jumps/IfNLtIns.java | 38 +- .../abc/avm2/instructions/jumps/IfNeIns.java | 38 +- .../instructions/jumps/IfStrictEqIns.java | 38 +- .../instructions/jumps/IfStrictNeIns.java | 38 +- .../avm2/instructions/jumps/IfTrueIns.java | 34 +- .../abc/avm2/instructions/jumps/JumpIns.java | 20 +- .../instructions/jumps/LookupSwitchIns.java | 26 +- .../instructions/localregs/DecLocalIIns.java | 52 +- .../instructions/localregs/DecLocalIns.java | 52 +- .../instructions/localregs/GetLocal0Ins.java | 46 +- .../instructions/localregs/GetLocal1Ins.java | 38 +- .../instructions/localregs/GetLocal2Ins.java | 38 +- .../instructions/localregs/GetLocal3Ins.java | 38 +- .../instructions/localregs/GetLocalIns.java | 40 +- .../localregs/GetLocalTypeIns.java | 2 +- .../instructions/localregs/IncLocalIIns.java | 16 +- .../instructions/localregs/IncLocalIns.java | 16 +- .../avm2/instructions/localregs/KillIns.java | 14 +- .../instructions/localregs/SetLocal0Ins.java | 14 +- .../instructions/localregs/SetLocal1Ins.java | 14 +- .../instructions/localregs/SetLocal2Ins.java | 14 +- .../instructions/localregs/SetLocal3Ins.java | 14 +- .../instructions/localregs/SetLocalIns.java | 14 +- .../localregs/SetLocalTypeIns.java | 138 +- .../instructions/other/DeletePropertyIns.java | 64 +- .../instructions/other/FindPropertyIns.java | 56 +- .../other/FindPropertyStrictIns.java | 56 +- .../instructions/other/GetDescendantsIns.java | 60 +- .../instructions/other/GetGlobalScopeIns.java | 38 +- .../instructions/other/GetGlobalSlotIns.java | 50 +- .../avm2/instructions/other/GetLexIns.java | 26 +- .../instructions/other/GetPropertyIns.java | 44 +- .../instructions/other/GetScopeObjectIns.java | 24 +- .../avm2/instructions/other/GetSlotIns.java | 60 +- .../avm2/instructions/other/GetSuperIns.java | 44 +- .../avm2/instructions/other/HasNext2Ins.java | 20 +- .../avm2/instructions/other/HasNextIns.java | 26 +- .../abc/avm2/instructions/other/InIns.java | 26 +- .../instructions/other/InitPropertyIns.java | 46 +- .../abc/avm2/instructions/other/LabelIns.java | 6 +- .../avm2/instructions/other/NextNameIns.java | 26 +- .../avm2/instructions/other/NextValueIns.java | 26 +- .../abc/avm2/instructions/other/NopIns.java | 6 +- .../instructions/other/ReturnValueIns.java | 22 +- .../instructions/other/ReturnVoidIns.java | 14 +- .../instructions/other/SetGlobalSlotIns.java | 30 +- .../instructions/other/SetPropertyIns.java | 178 +- .../avm2/instructions/other/SetSlotIns.java | 212 +- .../avm2/instructions/other/SetSuperIns.java | 60 +- .../abc/avm2/instructions/other/ThrowIns.java | 22 +- .../abc/avm2/instructions/stack/DupIns.java | 41 +- .../abc/avm2/instructions/stack/PopIns.java | 60 +- .../avm2/instructions/stack/PopScopeIns.java | 38 +- .../avm2/instructions/stack/PushByteIns.java | 30 +- .../instructions/stack/PushDoubleIns.java | 30 +- .../avm2/instructions/stack/PushFalseIns.java | 30 +- .../avm2/instructions/stack/PushIntIns.java | 30 +- .../instructions/stack/PushNamespaceIns.java | 22 +- .../avm2/instructions/stack/PushNanIns.java | 22 +- .../avm2/instructions/stack/PushNullIns.java | 22 +- .../avm2/instructions/stack/PushScopeIns.java | 38 +- .../avm2/instructions/stack/PushShortIns.java | 30 +- .../instructions/stack/PushStringIns.java | 30 +- .../avm2/instructions/stack/PushTrueIns.java | 30 +- .../avm2/instructions/stack/PushUIntIns.java | 30 +- .../instructions/stack/PushUndefinedIns.java | 22 +- .../avm2/instructions/stack/PushWithIns.java | 36 +- .../abc/avm2/instructions/stack/SwapIns.java | 46 +- .../avm2/instructions/types/ApplyTypeIns.java | 52 +- .../avm2/instructions/types/AsTypeIns.java | 40 +- .../instructions/types/AsTypeLateIns.java | 42 +- .../avm2/instructions/types/CoerceAIns.java | 44 +- .../avm2/instructions/types/CoerceIns.java | 44 +- .../types/CoerceOrConvertTypeIns.java | 2 +- .../avm2/instructions/types/CoerceSIns.java | 40 +- .../avm2/instructions/types/ConvertBIns.java | 60 +- .../avm2/instructions/types/ConvertDIns.java | 74 +- .../avm2/instructions/types/ConvertIIns.java | 70 +- .../avm2/instructions/types/ConvertOIns.java | 38 +- .../avm2/instructions/types/ConvertSIns.java | 40 +- .../avm2/instructions/types/ConvertUIns.java | 38 +- .../instructions/types/InstanceOfIns.java | 26 +- .../avm2/instructions/types/IsTypeIns.java | 26 +- .../instructions/types/IsTypeLateIns.java | 26 +- .../avm2/instructions/types/TypeOfIns.java | 22 +- .../avm2/instructions/xml/CheckFilterIns.java | 32 +- .../abc/avm2/instructions/xml/DXNSIns.java | 26 +- .../avm2/instructions/xml/DXNSLateIns.java | 34 +- .../avm2/instructions/xml/EscXAttrIns.java | 34 +- .../avm2/instructions/xml/EscXElemIns.java | 34 +- .../flash/abc/avm2/parser/ASM3Parser.java | 527 +- .../flash/abc/avm2/parser/Flasm3Lexer.java | 1822 +- .../abc/avm2/parser/MissingSymbolHandler.java | 8 +- .../flash/abc/avm2/parser/ParseException.java | 14 +- .../flash/abc/avm2/parser/ParsedSymbol.java | 42 +- .../abc/avm2/treemodel/ApplyTypeTreeItem.java | 52 +- .../abc/avm2/treemodel/BooleanTreeItem.java | 58 +- .../avm2/treemodel/CallMethodTreeItem.java | 40 +- .../avm2/treemodel/CallPropertyTreeItem.java | 44 +- .../avm2/treemodel/CallStaticTreeItem.java | 40 +- .../abc/avm2/treemodel/CallSuperTreeItem.java | 52 +- .../abc/avm2/treemodel/CallTreeItem.java | 60 +- .../abc/avm2/treemodel/ClassTreeItem.java | 18 +- .../abc/avm2/treemodel/CoerceTreeItem.java | 32 +- .../abc/avm2/treemodel/CommentTreeItem.java | 26 +- .../avm2/treemodel/ConstructPropTreeItem.java | 48 +- .../treemodel/ConstructSuperTreeItem.java | 44 +- .../abc/avm2/treemodel/ConstructTreeItem.java | 44 +- .../abc/avm2/treemodel/ConvertTreeItem.java | 32 +- .../abc/avm2/treemodel/DecLocalTreeItem.java | 18 +- .../abc/avm2/treemodel/DecrementTreeItem.java | 18 +- .../avm2/treemodel/DefaultXMLNamespace.java | 18 +- .../avm2/treemodel/EscapeXAttrTreeItem.java | 18 +- .../avm2/treemodel/EscapeXElemTreeItem.java | 18 +- .../avm2/treemodel/FilteredCheckTreeItem.java | 18 +- .../avm2/treemodel/FindPropertyTreeItem.java | 18 +- .../avm2/treemodel/FloatValueTreeItem.java | 34 +- .../avm2/treemodel/FullMultinameTreeItem.java | 176 +- .../treemodel/GetDescendantsTreeItem.java | 22 +- .../abc/avm2/treemodel/GetLexTreeItem.java | 18 +- .../avm2/treemodel/GetPropertyTreeItem.java | 22 +- .../abc/avm2/treemodel/GetSlotTreeItem.java | 24 +- .../abc/avm2/treemodel/GetSuperTreeItem.java | 30 +- .../abc/avm2/treemodel/HasNextTreeItem.java | 22 +- .../flash/abc/avm2/treemodel/InTreeItem.java | 22 +- .../abc/avm2/treemodel/IncLocalTreeItem.java | 18 +- .../abc/avm2/treemodel/IncrementTreeItem.java | 18 +- .../avm2/treemodel/InitPropertyTreeItem.java | 42 +- .../avm2/treemodel/IntegerValueTreeItem.java | 34 +- .../abc/avm2/treemodel/LocalRegTreeItem.java | 66 +- .../abc/avm2/treemodel/NameSpaceTreeItem.java | 24 +- .../abc/avm2/treemodel/NameValuePair.java | 28 +- .../flash/abc/avm2/treemodel/NanTreeItem.java | 14 +- .../avm2/treemodel/NewActivationTreeItem.java | 16 +- .../abc/avm2/treemodel/NewArrayTreeItem.java | 32 +- .../avm2/treemodel/NewFunctionTreeItem.java | 30 +- .../abc/avm2/treemodel/NewObjectTreeItem.java | 32 +- .../abc/avm2/treemodel/NextNameTreeItem.java | 22 +- .../abc/avm2/treemodel/NextValueTreeItem.java | 22 +- .../abc/avm2/treemodel/NullTreeItem.java | 38 +- .../avm2/treemodel/NumberValueTreeItem.java | 6 +- .../avm2/treemodel/PostDecrementTreeItem.java | 18 +- .../avm2/treemodel/PostIncrementTreeItem.java | 18 +- .../avm2/treemodel/ReturnValueTreeItem.java | 18 +- .../avm2/treemodel/ReturnVoidTreeItem.java | 14 +- .../avm2/treemodel/SetGlobalSlotTreeItem.java | 22 +- .../abc/avm2/treemodel/SetLocalTreeItem.java | 38 +- .../avm2/treemodel/SetPropertyTreeItem.java | 42 +- .../abc/avm2/treemodel/SetSlotTreeItem.java | 78 +- .../abc/avm2/treemodel/SetSuperTreeItem.java | 34 +- .../abc/avm2/treemodel/SetTypeTreeItem.java | 4 +- .../abc/avm2/treemodel/StringTreeItem.java | 18 +- .../abc/avm2/treemodel/ThisTreeItem.java | 18 +- .../abc/avm2/treemodel/ThrowTreeItem.java | 18 +- .../flash/abc/avm2/treemodel/TreeItem.java | 164 +- .../abc/avm2/treemodel/UndefinedTreeItem.java | 14 +- .../abc/avm2/treemodel/UnparsedTreeItem.java | 18 +- .../abc/avm2/treemodel/WithEndTreeItem.java | 26 +- .../avm2/treemodel/WithObjectTreeItem.java | 18 +- .../abc/avm2/treemodel/WithTreeItem.java | 52 +- .../flash/abc/avm2/treemodel/XMLTreeItem.java | 34 +- .../clauses/DeclarationTreeItem.java | 58 +- .../treemodel/clauses/ExceptionTreeItem.java | 18 +- .../treemodel/clauses/FilterTreeItem.java | 22 +- .../treemodel/clauses/ForEachInTreeItem.java | 110 +- .../avm2/treemodel/clauses/ForInTreeItem.java | 110 +- .../treemodel/clauses/TernarOpTreeItem.java | 26 +- .../avm2/treemodel/clauses/TryTreeItem.java | 148 +- .../treemodel/operations/AddTreeItem.java | 46 +- .../treemodel/operations/AndTreeItem.java | 8 +- .../treemodel/operations/AsTypeTreeItem.java | 6 +- .../treemodel/operations/BitAndTreeItem.java | 14 +- .../treemodel/operations/BitNotTreeItem.java | 14 +- .../treemodel/operations/BitOrTreeItem.java | 14 +- .../treemodel/operations/BitXorTreeItem.java | 14 +- .../operations/DeletePropertyTreeItem.java | 22 +- .../treemodel/operations/DivideTreeItem.java | 14 +- .../avm2/treemodel/operations/EqTreeItem.java | 22 +- .../avm2/treemodel/operations/GeTreeItem.java | 22 +- .../avm2/treemodel/operations/GtTreeItem.java | 22 +- .../avm2/treemodel/operations/InTreeItem.java | 6 +- .../operations/InstanceOfTreeItem.java | 6 +- .../treemodel/operations/IsTypeTreeItem.java | 6 +- .../treemodel/operations/LShiftTreeItem.java | 14 +- .../avm2/treemodel/operations/LeTreeItem.java | 22 +- .../avm2/treemodel/operations/LtTreeItem.java | 22 +- .../treemodel/operations/ModuloTreeItem.java | 14 +- .../operations/MultiplyTreeItem.java | 14 +- .../treemodel/operations/NegTreeItem.java | 14 +- .../treemodel/operations/NeqTreeItem.java | 22 +- .../avm2/treemodel/operations/OrTreeItem.java | 16 +- .../operations/PreDecrementTreeItem.java | 6 +- .../operations/PreIncrementTreeItem.java | 6 +- .../treemodel/operations/RShiftTreeItem.java | 14 +- .../operations/StrictEqTreeItem.java | 22 +- .../operations/StrictNeqTreeItem.java | 22 +- .../operations/SubtractTreeItem.java | 14 +- .../treemodel/operations/TypeOfTreeItem.java | 6 +- .../treemodel/operations/URShiftTreeItem.java | 14 +- .../flash/abc/gui/ABCComboBoxModel.java | 72 +- .../decompiler/flash/abc/gui/ABCPanel.java | 632 +- .../flash/abc/gui/ASMSourceEditorPane.java | 342 +- .../flash/abc/gui/ClassesListTree.java | 218 +- .../flash/abc/gui/ClassesListTreeModel.java | 212 +- .../flash/abc/gui/ConstantsListModel.java | 140 +- .../flash/abc/gui/DecompiledEditorPane.java | 524 +- .../flash/abc/gui/DeobfuscationDialog.java | 132 +- .../decompiler/flash/abc/gui/DetailPanel.java | 184 +- .../abc/gui/DialogMissingSymbolHandler.java | 32 +- .../flash/abc/gui/IconListRenderer.java | 74 +- .../flash/abc/gui/LineMarkedEditorPane.java | 68 +- .../flash/abc/gui/MethodBodyParamsPanel.java | 178 +- .../flash/abc/gui/MethodCodePanel.java | 176 +- .../flash/abc/gui/MethodInfoPanel.java | 166 +- .../flash/abc/gui/MethodTraitDetailPanel.java | 66 +- .../abc/gui/SlotConstTraitDetailPanel.java | 88 +- .../decompiler/flash/abc/gui/TraitDetail.java | 4 +- .../decompiler/flash/abc/gui/TraitsList.java | 90 +- .../flash/abc/gui/TraitsListItem.java | 166 +- .../flash/abc/gui/TraitsListModel.java | 100 +- .../jpexs/decompiler/flash/abc/gui/Tree.java | 46 +- .../decompiler/flash/abc/gui/TreeElement.java | 254 +- .../flash/abc/gui/TreeLeafScript.java | 12 +- .../decompiler/flash/abc/gui/TreeVisitor.java | 4 +- .../decompiler/flash/abc/gui/UsageFrame.java | 184 +- .../flash/abc/gui/UsageListModel.java | 34 +- .../gui/tablemodels/DecimalTableModel.java | 252 +- .../abc/gui/tablemodels/DoubleTableModel.java | 256 +- .../abc/gui/tablemodels/IntTableModel.java | 252 +- .../gui/tablemodels/MultinameTableModel.java | 312 +- .../tablemodels/NamespaceSetTableModel.java | 264 +- .../gui/tablemodels/NamespaceTableModel.java | 274 +- .../abc/gui/tablemodels/StringTableModel.java | 252 +- .../abc/gui/tablemodels/UIntTableModel.java | 252 +- .../methodinfo_parser/MethodInfoLexer.java | 2022 +- .../methodinfo_parser/MethodInfoParser.java | 526 +- .../abc/methodinfo_parser/ParseException.java | 14 +- .../abc/methodinfo_parser/ParsedSymbol.java | 64 +- .../flash/abc/types/ABCException.java | 68 +- .../decompiler/flash/abc/types/ClassInfo.java | 18 +- .../decompiler/flash/abc/types/Decimal.java | 16 +- .../flash/abc/types/InstanceInfo.java | 140 +- .../flash/abc/types/MetadataInfo.java | 52 +- .../flash/abc/types/MethodBody.java | 232 +- .../flash/abc/types/MethodInfo.java | 446 +- .../decompiler/flash/abc/types/Multiname.java | 414 +- .../decompiler/flash/abc/types/Namespace.java | 108 +- .../flash/abc/types/NamespaceSet.java | 22 +- .../flash/abc/types/ScriptInfo.java | 88 +- .../decompiler/flash/abc/types/ValueKind.java | 190 +- .../flash/abc/types/traits/Trait.java | 196 +- .../flash/abc/types/traits/TraitClass.java | 736 +- .../flash/abc/types/traits/TraitFunction.java | 50 +- .../types/traits/TraitMethodGetterSetter.java | 70 +- .../abc/types/traits/TraitSlotConst.java | 160 +- .../flash/abc/types/traits/Traits.java | 102 +- .../abc/usages/ClassNameMultinameUsage.java | 14 +- .../abc/usages/ConstVarMultinameUsage.java | 38 +- .../usages/ConstVarNameMultinameUsage.java | 14 +- .../usages/ConstVarTypeMultinameUsage.java | 14 +- .../abc/usages/ExtendsMultinameUsage.java | 14 +- .../abc/usages/ImplementsMultinameUsage.java | 14 +- .../abc/usages/InsideClassMultinameUsage.java | 32 +- .../abc/usages/MethodBodyMultinameUsage.java | 14 +- .../abc/usages/MethodMultinameUsage.java | 54 +- .../abc/usages/MethodNameMultinameUsage.java | 14 +- .../usages/MethodParamsMultinameUsage.java | 14 +- .../MethodReturnTypeMultinameUsage.java | 14 +- .../flash/abc/usages/MultinameUsage.java | 2 +- .../flash/abc/usages/TraitMultinameUsage.java | 22 +- .../abc/usages/TypeNameMultinameUsage.java | 16 +- .../jpexs/decompiler/flash/action/Action.java | 1985 +- .../decompiler/flash/action/ActionGraph.java | 1816 +- .../flash/action/ActionGraphSource.java | 108 +- .../flash/action/UnknownActionException.java | 10 +- .../flash/action/UnknownJumpException.java | 66 +- .../action/flashlite/ActionFSCommand2.java | 34 +- .../action/flashlite/ActionStrictMode.java | 56 +- .../flash/action/gui/ActionPanel.java | 494 +- .../flash/action/parser/ASMParser.java | 552 +- .../flash/action/parser/FlasmLexer.java | 1818 +- .../decompiler/flash/action/parser/Label.java | 12 +- .../flash/action/parser/ParseException.java | 14 +- .../flash/action/parser/ParsedSymbol.java | 52 +- .../flash/action/special/ActionContainer.java | 4 +- .../flash/action/special/ActionEnd.java | 24 +- .../flash/action/special/ActionNop.java | 22 +- .../flash/action/swf3/ActionGetURL.java | 68 +- .../flash/action/swf3/ActionGoToLabel.java | 60 +- .../flash/action/swf3/ActionGotoFrame.java | 56 +- .../flash/action/swf3/ActionNextFrame.java | 22 +- .../flash/action/swf3/ActionPlay.java | 22 +- .../flash/action/swf3/ActionPrevFrame.java | 22 +- .../flash/action/swf3/ActionSetTarget.java | 60 +- .../flash/action/swf3/ActionStop.java | 22 +- .../flash/action/swf3/ActionStopSounds.java | 22 +- .../action/swf3/ActionToggleQuality.java | 22 +- .../flash/action/swf3/ActionWaitForFrame.java | 64 +- .../flash/action/swf4/ActionAdd.java | 26 +- .../flash/action/swf4/ActionAnd.java | 26 +- .../flash/action/swf4/ActionAsciiToChar.java | 24 +- .../flash/action/swf4/ActionCall.java | 22 +- .../flash/action/swf4/ActionCharToAscii.java | 24 +- .../flash/action/swf4/ActionCloneSprite.java | 28 +- .../flash/action/swf4/ActionDivide.java | 26 +- .../flash/action/swf4/ActionEndDrag.java | 22 +- .../flash/action/swf4/ActionEquals.java | 26 +- .../flash/action/swf4/ActionGetProperty.java | 38 +- .../flash/action/swf4/ActionGetTime.java | 22 +- .../flash/action/swf4/ActionGetURL2.java | 84 +- .../flash/action/swf4/ActionGetVariable.java | 30 +- .../flash/action/swf4/ActionGotoFrame2.java | 90 +- .../flash/action/swf4/ActionIf.java | 126 +- .../flash/action/swf4/ActionJump.java | 118 +- .../flash/action/swf4/ActionLess.java | 26 +- .../action/swf4/ActionMBAsciiToChar.java | 24 +- .../action/swf4/ActionMBCharToAscii.java | 24 +- .../action/swf4/ActionMBStringExtract.java | 28 +- .../action/swf4/ActionMBStringLength.java | 24 +- .../flash/action/swf4/ActionMultiply.java | 26 +- .../flash/action/swf4/ActionNot.java | 24 +- .../flash/action/swf4/ActionOr.java | 26 +- .../flash/action/swf4/ActionPop.java | 40 +- .../flash/action/swf4/ActionPush.java | 400 +- .../flash/action/swf4/ActionRandomNumber.java | 24 +- .../flash/action/swf4/ActionRemoveSprite.java | 24 +- .../flash/action/swf4/ActionSetProperty.java | 40 +- .../flash/action/swf4/ActionSetTarget2.java | 24 +- .../flash/action/swf4/ActionSetVariable.java | 30 +- .../flash/action/swf4/ActionStartDrag.java | 70 +- .../flash/action/swf4/ActionStringAdd.java | 26 +- .../flash/action/swf4/ActionStringEquals.java | 26 +- .../action/swf4/ActionStringExtract.java | 28 +- .../flash/action/swf4/ActionStringLength.java | 24 +- .../flash/action/swf4/ActionStringLess.java | 26 +- .../flash/action/swf4/ActionSubtract.java | 26 +- .../flash/action/swf4/ActionToInteger.java | 24 +- .../flash/action/swf4/ActionTrace.java | 24 +- .../action/swf4/ActionWaitForFrame2.java | 58 +- .../flash/action/swf4/ConstantIndex.java | 40 +- .../decompiler/flash/action/swf4/Null.java | 8 +- .../flash/action/swf4/RegisterNumber.java | 30 +- .../flash/action/swf4/Undefined.java | 8 +- .../flash/action/swf5/ActionAdd2.java | 26 +- .../flash/action/swf5/ActionBitAnd.java | 26 +- .../flash/action/swf5/ActionBitLShift.java | 26 +- .../flash/action/swf5/ActionBitOr.java | 26 +- .../flash/action/swf5/ActionBitRShift.java | 26 +- .../flash/action/swf5/ActionBitURShift.java | 26 +- .../flash/action/swf5/ActionBitXor.java | 26 +- .../flash/action/swf5/ActionCallFunction.java | 38 +- .../flash/action/swf5/ActionCallMethod.java | 36 +- .../flash/action/swf5/ActionConstantPool.java | 98 +- .../flash/action/swf5/ActionDecrement.java | 24 +- .../action/swf5/ActionDefineFunction.java | 302 +- .../flash/action/swf5/ActionDefineLocal.java | 28 +- .../flash/action/swf5/ActionDefineLocal2.java | 24 +- .../flash/action/swf5/ActionDelete.java | 28 +- .../flash/action/swf5/ActionDelete2.java | 26 +- .../flash/action/swf5/ActionEnumerate.java | 26 +- .../flash/action/swf5/ActionEquals2.java | 26 +- .../flash/action/swf5/ActionGetMember.java | 26 +- .../flash/action/swf5/ActionIncrement.java | 24 +- .../flash/action/swf5/ActionInitArray.java | 32 +- .../flash/action/swf5/ActionInitObject.java | 36 +- .../flash/action/swf5/ActionLess2.java | 26 +- .../flash/action/swf5/ActionModulo.java | 26 +- .../flash/action/swf5/ActionNewMethod.java | 36 +- .../flash/action/swf5/ActionNewObject.java | 34 +- .../action/swf5/ActionPushDuplicate.java | 28 +- .../flash/action/swf5/ActionReturn.java | 32 +- .../flash/action/swf5/ActionSetMember.java | 28 +- .../flash/action/swf5/ActionStackSwap.java | 32 +- .../action/swf5/ActionStoreRegister.java | 70 +- .../flash/action/swf5/ActionTargetPath.java | 24 +- .../flash/action/swf5/ActionToNumber.java | 24 +- .../flash/action/swf5/ActionToString.java | 24 +- .../flash/action/swf5/ActionTypeOf.java | 24 +- .../flash/action/swf5/ActionWith.java | 130 +- .../flash/action/swf6/ActionEnumerate2.java | 26 +- .../flash/action/swf6/ActionGreater.java | 26 +- .../flash/action/swf6/ActionInstanceOf.java | 26 +- .../flash/action/swf6/ActionStrictEquals.java | 26 +- .../action/swf6/ActionStringGreater.java | 26 +- .../flash/action/swf7/ActionCastOp.java | 26 +- .../action/swf7/ActionDefineFunction2.java | 564 +- .../flash/action/swf7/ActionExtends.java | 26 +- .../flash/action/swf7/ActionImplementsOp.java | 34 +- .../flash/action/swf7/ActionThrow.java | 32 +- .../flash/action/swf7/ActionTry.java | 328 +- .../action/treemodel/AsciiToCharTreeItem.java | 30 +- .../treemodel/CallFunctionTreeItem.java | 98 +- .../action/treemodel/CallMethodTreeItem.java | 86 +- .../flash/action/treemodel/CallTreeItem.java | 30 +- .../action/treemodel/CastOpTreeItem.java | 36 +- .../action/treemodel/CharToAsciiTreeItem.java | 30 +- .../action/treemodel/CloneSpriteTreeItem.java | 42 +- .../flash/action/treemodel/ConstantPool.java | 68 +- .../action/treemodel/DecrementTreeItem.java | 46 +- .../action/treemodel/DefineLocalTreeItem.java | 50 +- .../action/treemodel/DeleteTreeItem.java | 42 +- .../action/treemodel/DirectValueTreeItem.java | 234 +- .../flash/action/treemodel/EachTreeItem.java | 36 +- .../action/treemodel/EnumerateTreeItem.java | 30 +- .../action/treemodel/ExtendsTreeItem.java | 40 +- .../action/treemodel/FSCommand2TreeItem.java | 52 +- .../action/treemodel/FunctionTreeItem.java | 160 +- .../action/treemodel/GetMemberTreeItem.java | 44 +- .../action/treemodel/GetPropertyTreeItem.java | 40 +- .../action/treemodel/GetURL2TreeItem.java | 76 +- .../action/treemodel/GetURLTreeItem.java | 22 +- .../action/treemodel/GetVariableTreeItem.java | 116 +- .../action/treemodel/GotoFrame2TreeItem.java | 50 +- .../action/treemodel/GotoFrameTreeItem.java | 18 +- .../action/treemodel/GotoLabelTreeItem.java | 18 +- .../treemodel/ImplementsOpTreeItem.java | 54 +- .../action/treemodel/IncrementTreeItem.java | 46 +- .../action/treemodel/InitArrayTreeItem.java | 48 +- .../action/treemodel/InitObjectTreeItem.java | 58 +- .../treemodel/MBAsciiToCharTreeItem.java | 30 +- .../treemodel/MBCharToAsciiTreeItem.java | 30 +- .../treemodel/MBStringExtractTreeItem.java | 42 +- .../treemodel/MBStringLengthTreeItem.java | 38 +- .../action/treemodel/NewMethodTreeItem.java | 94 +- .../action/treemodel/NewObjectTreeItem.java | 54 +- .../treemodel/RandomNumberTreeItem.java | 30 +- .../treemodel/RemoveSpriteTreeItem.java | 30 +- .../action/treemodel/ReturnTreeItem.java | 38 +- .../action/treemodel/SetMemberTreeItem.java | 50 +- .../action/treemodel/SetPropertyTreeItem.java | 54 +- .../action/treemodel/SetTarget2TreeItem.java | 30 +- .../action/treemodel/SetTargetTreeItem.java | 18 +- .../action/treemodel/SetTypeTreeItem.java | 2 +- .../action/treemodel/SetVariableTreeItem.java | 52 +- .../treemodel/SimpleActionTreeItem.java | 18 +- .../action/treemodel/StartDragTreeItem.java | 86 +- .../treemodel/StoreRegisterTreeItem.java | 42 +- .../action/treemodel/StrictModeTreeItem.java | 18 +- .../treemodel/StringExtractTreeItem.java | 42 +- .../action/treemodel/TargetPathTreeItem.java | 30 +- .../flash/action/treemodel/ThrowTreeItem.java | 30 +- .../action/treemodel/ToIntegerTreeItem.java | 30 +- .../action/treemodel/ToNumberTreeItem.java | 30 +- .../action/treemodel/ToStringTreeItem.java | 30 +- .../flash/action/treemodel/TraceTreeItem.java | 30 +- .../flash/action/treemodel/TreeItem.java | 76 +- .../action/treemodel/TypeOfTreeItem.java | 30 +- .../action/treemodel/UnsupportedTreeItem.java | 18 +- .../flash/action/treemodel/VoidTreeItem.java | 18 +- .../treemodel/WaitForFrame2TreeItem.java | 34 +- .../treemodel/WaitForFrameTreeItem.java | 22 +- .../treemodel/clauses/ClassTreeItem.java | 132 +- .../treemodel/clauses/ForInTreeItem.java | 80 +- .../treemodel/clauses/InterfaceTreeItem.java | 58 +- .../treemodel/clauses/LoopTreeItem.java | 10 +- .../treemodel/clauses/TernarOpTreeItem.java | 26 +- .../action/treemodel/clauses/TryTreeItem.java | 144 +- .../treemodel/clauses/WithTreeItem.java | 48 +- .../treemodel/operations/AddTreeItem.java | 14 +- .../treemodel/operations/AndTreeItem.java | 14 +- .../treemodel/operations/AsTypeTreeItem.java | 14 +- .../treemodel/operations/BitAndTreeItem.java | 14 +- .../treemodel/operations/BitNotTreeItem.java | 14 +- .../treemodel/operations/BitOrTreeItem.java | 14 +- .../treemodel/operations/BitXorTreeItem.java | 14 +- .../treemodel/operations/DivideTreeItem.java | 14 +- .../treemodel/operations/EqTreeItem.java | 22 +- .../treemodel/operations/GeTreeItem.java | 22 +- .../treemodel/operations/GtTreeItem.java | 22 +- .../treemodel/operations/InTreeItem.java | 14 +- .../operations/InstanceOfTreeItem.java | 14 +- .../treemodel/operations/IsTypeTreeItem.java | 14 +- .../treemodel/operations/LShiftTreeItem.java | 14 +- .../treemodel/operations/LeTreeItem.java | 22 +- .../treemodel/operations/LtTreeItem.java | 22 +- .../treemodel/operations/ModuloTreeItem.java | 14 +- .../operations/MultiplyTreeItem.java | 14 +- .../treemodel/operations/NegTreeItem.java | 14 +- .../treemodel/operations/NeqTreeItem.java | 22 +- .../treemodel/operations/OrTreeItem.java | 14 +- .../operations/PreDecrementTreeItem.java | 14 +- .../operations/PreIncrementTreeItem.java | 14 +- .../treemodel/operations/RShiftTreeItem.java | 14 +- .../operations/StrictEqTreeItem.java | 22 +- .../operations/StrictNeqTreeItem.java | 22 +- .../operations/StringAddTreeItem.java | 14 +- .../operations/StringEqTreeItem.java | 14 +- .../operations/StringLengthTreeItem.java | 34 +- .../operations/StringLtTreeItem.java | 14 +- .../operations/SubtractTreeItem.java | 14 +- .../treemodel/operations/URShiftTreeItem.java | 14 +- .../jpexs/decompiler/flash/flv/AUDIODATA.java | 86 +- .../com/jpexs/decompiler/flash/flv/DATA.java | 2 +- .../decompiler/flash/flv/FLVOutputStream.java | 232 +- .../jpexs/decompiler/flash/flv/FLVTAG.java | 32 +- .../jpexs/decompiler/flash/flv/VIDEODATA.java | 42 +- .../jpexs/decompiler/flash/graph/AndItem.java | 26 +- .../decompiler/flash/graph/BinaryOpItem.java | 80 +- .../jpexs/decompiler/flash/graph/Block.java | 4 +- .../decompiler/flash/graph/BreakItem.java | 18 +- .../decompiler/flash/graph/ContinueItem.java | 18 +- .../decompiler/flash/graph/DoWhileItem.java | 84 +- .../decompiler/flash/graph/ForTreeItem.java | 140 +- .../jpexs/decompiler/flash/graph/Graph.java | 2770 +- .../decompiler/flash/graph/GraphPart.java | 256 +- .../flash/graph/GraphPartMulti.java | 100 +- .../decompiler/flash/graph/GraphSource.java | 88 +- .../flash/graph/GraphSourceItem.java | 18 +- .../flash/graph/GraphSourceItemPos.java | 12 +- .../flash/graph/GraphTargetItem.java | 186 +- .../jpexs/decompiler/flash/graph/IfItem.java | 122 +- .../decompiler/flash/graph/LogicalOpItem.java | 2 +- .../jpexs/decompiler/flash/graph/Loop.java | 16 +- .../decompiler/flash/graph/LoopItem.java | 10 +- .../jpexs/decompiler/flash/graph/NotItem.java | 30 +- .../jpexs/decompiler/flash/graph/OrItem.java | 26 +- .../decompiler/flash/graph/SwitchItem.java | 140 +- .../decompiler/flash/graph/TernarOpItem.java | 26 +- .../decompiler/flash/graph/TrueItem.java | 14 +- .../decompiler/flash/graph/UnaryOpItem.java | 62 +- .../decompiler/flash/graph/WhileItem.java | 84 +- .../decompiler/flash/gui/AboutDialog.java | 114 +- .../decompiler/flash/gui/ExportDialog.java | 156 +- .../flash/gui/FlashUnsupportedException.java | 6 +- .../jpexs/decompiler/flash/gui/FrameNode.java | 42 +- .../decompiler/flash/gui/GraphFrame.java | 472 +- .../decompiler/flash/gui/GraphTreeFrame.java | 76 +- .../decompiler/flash/gui/ImagePanel.java | 28 +- .../jpexs/decompiler/flash/gui/LinkLabel.java | 94 +- .../decompiler/flash/gui/LoadingDialog.java | 104 +- .../decompiler/flash/gui/LoadingPanel.java | 68 +- .../jpexs/decompiler/flash/gui/MainFrame.java | 2853 +- .../jpexs/decompiler/flash/gui/ModeFrame.java | 116 +- .../jpexs/decompiler/flash/gui/TagNode.java | 444 +- .../decompiler/flash/gui/TagTreeModel.java | 178 +- .../com/jpexs/decompiler/flash/gui/View.java | 102 +- .../flash/gui/player/FlashPlayerPanel.java | 168 +- .../player/jna/platform/win32/BaseTSD.java | 174 +- .../player/jna/platform/win32/Kernel32.java | 168 +- .../jna/platform/win32/SHELLEXECUTEINFO.java | 40 +- .../player/jna/platform/win32/Shell32.java | 12 +- .../player/jna/platform/win32/W32Errors.java | 290 +- .../player/jna/platform/win32/WinBase.java | 1622 +- .../gui/player/jna/platform/win32/WinDef.java | 2158 +- .../player/jna/platform/win32/WinError.java | 72724 ++++++++-------- .../gui/player/jna/platform/win32/WinNT.java | 3019 +- .../gui/player/jna/platform/win32/WinReg.java | 86 +- .../player/jna/platform/win32/WinUser.java | 1545 +- .../flash/gui/proxy/ProxyFrame.java | 638 +- .../flash/gui/proxy/SWFListModel.java | 268 +- .../decompiler/flash/helpers/Helper.java | 584 +- .../flash/helpers/Highlighting.java | 518 +- .../flash/tags/CSMTextSettingsTag.java | 110 +- .../decompiler/flash/tags/DebugIDTag.java | 60 +- .../flash/tags/DefineBinaryDataTag.java | 52 +- .../flash/tags/DefineBitsJPEG2Tag.java | 24 +- .../flash/tags/DefineBitsJPEG3Tag.java | 70 +- .../flash/tags/DefineBitsJPEG4Tag.java | 90 +- .../flash/tags/DefineBitsLossless2Tag.java | 218 +- .../flash/tags/DefineBitsLosslessTag.java | 226 +- .../decompiler/flash/tags/DefineBitsTag.java | 110 +- .../flash/tags/DefineButton2Tag.java | 286 +- .../flash/tags/DefineButtonCxformTag.java | 66 +- .../flash/tags/DefineButtonSoundTag.java | 148 +- .../flash/tags/DefineButtonTag.java | 276 +- .../flash/tags/DefineEditTextTag.java | 322 +- .../decompiler/flash/tags/DefineFont2Tag.java | 336 +- .../decompiler/flash/tags/DefineFont3Tag.java | 336 +- .../decompiler/flash/tags/DefineFont4Tag.java | 88 +- .../flash/tags/DefineFontAlignZonesTag.java | 74 +- .../flash/tags/DefineFontInfo2Tag.java | 132 +- .../flash/tags/DefineFontInfoTag.java | 140 +- .../flash/tags/DefineFontNameTag.java | 20 +- .../decompiler/flash/tags/DefineFontTag.java | 122 +- .../flash/tags/DefineMorphShape2Tag.java | 162 +- .../flash/tags/DefineMorphShapeTag.java | 134 +- .../flash/tags/DefineScalingGridTag.java | 52 +- .../tags/DefineSceneAndFrameLabelDataTag.java | 114 +- .../flash/tags/DefineShape2Tag.java | 44 +- .../flash/tags/DefineShape3Tag.java | 44 +- .../flash/tags/DefineShape4Tag.java | 62 +- .../decompiler/flash/tags/DefineShapeTag.java | 44 +- .../decompiler/flash/tags/DefineSoundTag.java | 120 +- .../flash/tags/DefineSpriteTag.java | 292 +- .../decompiler/flash/tags/DefineText2Tag.java | 140 +- .../decompiler/flash/tags/DefineTextTag.java | 158 +- .../flash/tags/DefineVideoStreamTag.java | 108 +- .../jpexs/decompiler/flash/tags/DoABCTag.java | 128 +- .../decompiler/flash/tags/DoActionTag.java | 176 +- .../flash/tags/DoInitActionTag.java | 204 +- .../flash/tags/EnableDebugger2Tag.java | 72 +- .../flash/tags/EnableDebuggerTag.java | 70 +- .../jpexs/decompiler/flash/tags/EndTag.java | 46 +- .../flash/tags/ExportAssetsTag.java | 92 +- .../flash/tags/FileAttributesTag.java | 92 +- .../decompiler/flash/tags/FrameLabelTag.java | 64 +- .../flash/tags/ImportAssets2Tag.java | 100 +- .../flash/tags/ImportAssetsTag.java | 92 +- .../decompiler/flash/tags/JPEGTablesTag.java | 6 +- .../decompiler/flash/tags/MetadataTag.java | 52 +- .../flash/tags/PlaceObject2Tag.java | 460 +- .../flash/tags/PlaceObject3Tag.java | 592 +- .../decompiler/flash/tags/PlaceObjectTag.java | 160 +- .../flash/tags/PlaceObjectTypeTag.java | 6 +- .../decompiler/flash/tags/ProductInfoTag.java | 68 +- .../decompiler/flash/tags/ProtectTag.java | 74 +- .../flash/tags/RemoveObject2Tag.java | 12 +- .../flash/tags/RemoveObjectTag.java | 78 +- .../flash/tags/ScriptLimitsTag.java | 52 +- .../flash/tags/SetBackgroundColorTag.java | 40 +- .../decompiler/flash/tags/SetTabIndexTag.java | 78 +- .../decompiler/flash/tags/ShowFrameTag.java | 38 +- .../flash/tags/SoundStreamBlockTag.java | 20 +- .../flash/tags/SoundStreamHead2Tag.java | 152 +- .../flash/tags/SoundStreamHeadTag.java | 152 +- .../flash/tags/SoundStreamHeadTypeTag.java | 8 +- .../decompiler/flash/tags/StartSound2Tag.java | 64 +- .../decompiler/flash/tags/StartSoundTag.java | 66 +- .../decompiler/flash/tags/SymbolClassTag.java | 74 +- .../com/jpexs/decompiler/flash/tags/Tag.java | 186 +- .../jpexs/decompiler/flash/tags/TagStub.java | 56 +- .../decompiler/flash/tags/VideoFrameTag.java | 72 +- .../decompiler/flash/tags/base/ASMSource.java | 60 +- .../flash/tags/base/BoundedTag.java | 2 +- .../flash/tags/base/CharacterTag.java | 46 +- .../decompiler/flash/tags/base/Container.java | 24 +- .../decompiler/flash/tags/base/FontTag.java | 4 +- .../decompiler/flash/tags/base/ShapeTag.java | 2 +- .../flash/types/ALPHABITMAPDATA.java | 2 +- .../flash/types/ALPHACOLORMAPDATA.java | 4 +- .../jpexs/decompiler/flash/types/ARGB.java | 40 +- .../decompiler/flash/types/BITMAPDATA.java | 4 +- .../flash/types/BUTTONCONDACTION.java | 231 +- .../decompiler/flash/types/BUTTONRECORD.java | 98 +- .../flash/types/CLIPACTIONRECORD.java | 151 +- .../decompiler/flash/types/CLIPACTIONS.java | 16 +- .../flash/types/CLIPEVENTFLAGS.java | 416 +- .../decompiler/flash/types/COLORMAPDATA.java | 4 +- .../jpexs/decompiler/flash/types/CXFORM.java | 66 +- .../flash/types/CXFORMWITHALPHA.java | 82 +- .../decompiler/flash/types/FILLSTYLE.java | 34 +- .../flash/types/FILLSTYLEARRAY.java | 2 +- .../decompiler/flash/types/FOCALGRADIENT.java | 8 +- .../decompiler/flash/types/GLYPHENTRY.java | 12 +- .../decompiler/flash/types/GRADIENT.java | 22 +- .../decompiler/flash/types/GRADRECORD.java | 8 +- .../decompiler/flash/types/KERNINGRECORD.java | 14 +- .../decompiler/flash/types/LANGCODE.java | 2 +- .../decompiler/flash/types/LINESTYLE.java | 6 +- .../decompiler/flash/types/LINESTYLE2.java | 36 +- .../flash/types/LINESTYLEARRAY.java | 4 +- .../jpexs/decompiler/flash/types/MATRIX.java | 96 +- .../flash/types/MORPHFILLSTYLE.java | 32 +- .../flash/types/MORPHFILLSTYLEARRAY.java | 2 +- .../decompiler/flash/types/MORPHGRADIENT.java | 4 +- .../flash/types/MORPHGRADRECORD.java | 8 +- .../flash/types/MORPHLINESTYLE.java | 8 +- .../flash/types/MORPHLINESTYLE2.java | 40 +- .../flash/types/MORPHLINESTYLEARRAY.java | 4 +- .../jpexs/decompiler/flash/types/PIX15.java | 24 +- .../jpexs/decompiler/flash/types/PIX24.java | 32 +- .../jpexs/decompiler/flash/types/RECT.java | 70 +- .../com/jpexs/decompiler/flash/types/RGB.java | 68 +- .../jpexs/decompiler/flash/types/RGBA.java | 62 +- .../jpexs/decompiler/flash/types/SHAPE.java | 30 +- .../flash/types/SHAPEWITHSTYLE.java | 34 +- .../decompiler/flash/types/SOUNDENVELOPE.java | 6 +- .../decompiler/flash/types/SOUNDINFO.java | 20 +- .../decompiler/flash/types/TEXTRECORD.java | 22 +- .../decompiler/flash/types/ZONEDATA.java | 12 +- .../decompiler/flash/types/ZONERECORD.java | 28 +- .../flash/types/filters/BEVELFILTER.java | 108 +- .../flash/types/filters/BLURFILTER.java | 30 +- .../types/filters/COLORMATRIXFILTER.java | 20 +- .../types/filters/CONVOLUTIONFILTER.java | 76 +- .../flash/types/filters/DROPSHADOWFILTER.java | 92 +- .../flash/types/filters/FILTER.java | 24 +- .../flash/types/filters/GLOWFILTER.java | 76 +- .../types/filters/GRADIENTBEVELFILTER.java | 102 +- .../types/filters/GRADIENTGLOWFILTER.java | 108 +- .../types/shaperecords/CurvedEdgeRecord.java | 74 +- .../types/shaperecords/EndShapeRecord.java | 50 +- .../flash/types/shaperecords/SHAPERECORD.java | 462 +- .../shaperecords/StraightEdgeRecord.java | 100 +- .../types/shaperecords/StyleChangeRecord.java | 100 +- 772 files changed, 84378 insertions(+), 84353 deletions(-) diff --git a/trunk/src/com/jpexs/decompiler/flash/Configuration.java b/trunk/src/com/jpexs/decompiler/flash/Configuration.java index d30236c55..df3bfe6ec 100644 --- a/trunk/src/com/jpexs/decompiler/flash/Configuration.java +++ b/trunk/src/com/jpexs/decompiler/flash/Configuration.java @@ -28,202 +28,202 @@ import javax.swing.JOptionPane; public class Configuration { - private static final String CONFIG_NAME = "config.bin"; - private static final String REPLACEMENTS_NAME = "replacements.cfg"; - private static HashMap config = new HashMap(); - private static final File unspecifiedFile = new File("unspecified"); - private static File directory = unspecifiedFile; + private static final String CONFIG_NAME = "config.bin"; + private static final String REPLACEMENTS_NAME = "replacements.cfg"; + private static HashMap config = new HashMap(); + private static final File unspecifiedFile = new File("unspecified"); + private static File directory = unspecifiedFile; - private enum OSId { + private enum OSId { - WINDOWS, OSX, UNIX - } + WINDOWS, OSX, UNIX + } - private static OSId getOSId() { - PrivilegedAction doGetOSName = new PrivilegedAction() { - @Override - public String run() { - return System.getProperty("os.name"); - } - }; - OSId id = OSId.UNIX; - String osName = AccessController.doPrivileged(doGetOSName); - if (osName != null) { - if (osName.toLowerCase().startsWith("mac os x")) { - id = OSId.OSX; - } else if (osName.contains("Windows")) { - id = OSId.WINDOWS; - } - } - return id; - } + private static OSId getOSId() { + PrivilegedAction doGetOSName = new PrivilegedAction() { + @Override + public String run() { + return System.getProperty("os.name"); + } + }; + OSId id = OSId.UNIX; + String osName = AccessController.doPrivileged(doGetOSName); + if (osName != null) { + if (osName.toLowerCase().startsWith("mac os x")) { + id = OSId.OSX; + } else if (osName.contains("Windows")) { + id = OSId.WINDOWS; + } + } + return id; + } - public static String getASDecHome() { - if (directory == unspecifiedFile) { - directory = null; - String userHome = null; - try { - userHome = System.getProperty("user.home"); - } catch (SecurityException ignore) { - } - if (userHome != null) { - String applicationId = Main.shortApplicationName; - OSId osId = getOSId(); - if (osId == OSId.WINDOWS) { - File appDataDir = null; - try { - String appDataEV = System.getenv("APPDATA"); - if ((appDataEV != null) && (appDataEV.length() > 0)) { - appDataDir = new File(appDataEV); - } - } catch (SecurityException ignore) { - } - String vendorId = Main.vendor; - if ((appDataDir != null) && appDataDir.isDirectory()) { - // ${APPDATA}\{vendorId}\${applicationId} - String path = vendorId + "\\" + applicationId + "\\"; - directory = new File(appDataDir, path); - } else { - // ${userHome}\Application Data\${vendorId}\${applicationId} - String path = "Application Data\\" + vendorId + "\\" + applicationId + "\\"; - directory = new File(userHome, path); - } - } else if (osId == OSId.OSX) { - // ${userHome}/Library/Application Support/${applicationId} - String path = "Library/Application Support/" + applicationId + "/"; - directory = new File(userHome, path); + public static String getASDecHome() { + if (directory == unspecifiedFile) { + directory = null; + String userHome = null; + try { + userHome = System.getProperty("user.home"); + } catch (SecurityException ignore) { + } + if (userHome != null) { + String applicationId = Main.shortApplicationName; + OSId osId = getOSId(); + if (osId == OSId.WINDOWS) { + File appDataDir = null; + try { + String appDataEV = System.getenv("APPDATA"); + if ((appDataEV != null) && (appDataEV.length() > 0)) { + appDataDir = new File(appDataEV); + } + } catch (SecurityException ignore) { + } + String vendorId = Main.vendor; + if ((appDataDir != null) && appDataDir.isDirectory()) { + // ${APPDATA}\{vendorId}\${applicationId} + String path = vendorId + "\\" + applicationId + "\\"; + directory = new File(appDataDir, path); + } else { + // ${userHome}\Application Data\${vendorId}\${applicationId} + String path = "Application Data\\" + vendorId + "\\" + applicationId + "\\"; + directory = new File(userHome, path); + } + } else if (osId == OSId.OSX) { + // ${userHome}/Library/Application Support/${applicationId} + String path = "Library/Application Support/" + applicationId + "/"; + directory = new File(userHome, path); + } else { + // ${userHome}/.${applicationId}/ + String path = "." + applicationId + "/"; + directory = new File(userHome, path); + } + } + } + if (!directory.exists()) { + directory.mkdirs(); + } + String ret = directory.getAbsolutePath(); + if (!ret.endsWith(File.separator)) { + ret += File.separator; + } + return ret; + } + + private static String getReplacementsFile() { + return getASDecHome() + REPLACEMENTS_NAME; + } + + private static String getConfigFile() { + return getASDecHome() + CONFIG_NAME; + } + /** + * List of replacements + */ + public static java.util.List replacements = new ArrayList(); + + /** + * Saves replacements to file for future use + */ + private static void saveReplacements() { + try { + if (replacements.isEmpty()) { + File rf = new File(getReplacementsFile()); + if (rf.exists()) { + rf.delete(); + } } else { - // ${userHome}/.${applicationId}/ - String path = "." + applicationId + "/"; - directory = new File(userHome, path); + File f = new File(getASDecHome()); + if (!f.exists()) { + f.mkdir(); + } + PrintWriter pw = new PrintWriter(new FileWriter(getReplacementsFile())); + for (Replacement r : replacements) { + pw.println(r.urlPattern); + pw.println(r.targetFile); + } + pw.close(); } - } - } - if(!directory.exists()){ - directory.mkdirs(); - } - String ret=directory.getAbsolutePath(); - if(!ret.endsWith(File.separator)){ - ret+=File.separator; - } - return ret; - } + } catch (IOException e) { + } + } - private static String getReplacementsFile() { - return getASDecHome() + REPLACEMENTS_NAME; - } - - private static String getConfigFile() { - return getASDecHome() + CONFIG_NAME; - } - /** - * List of replacements - */ - public static java.util.List replacements = new ArrayList(); - - /** - * Saves replacements to file for future use - */ - private static void saveReplacements() { - try { - if (replacements.isEmpty()) { - File rf = new File(getReplacementsFile()); - if (rf.exists()) { - rf.delete(); + /** + * Load replacements from file + */ + private static void loadReplacements() { + replacements = new ArrayList(); + try { + BufferedReader br = new BufferedReader(new FileReader(getReplacementsFile())); + String s; + while ((s = br.readLine()) != null) { + Replacement r = new Replacement(s, br.readLine()); + replacements.add(r); } - } else { - File f = new File(getASDecHome()); - if (!f.exists()) { - f.mkdir(); + br.close(); + } catch (IOException e) { + } + } + + public static Object getConfig(String cfg) { + return getConfig(cfg, null); + } + + public static Object getConfig(String cfg, Object defaultValue) { + if (!config.containsKey(cfg)) { + return defaultValue; + } + return config.get(cfg); + } + + public static Object setConfig(String cfg, Object value) { + return config.put(cfg, value); + } + + public static void load() { + ObjectInputStream ois = null; + try { + ois = new ObjectInputStream(new FileInputStream(getConfigFile())); + config = (HashMap) ois.readObject(); + } catch (FileNotFoundException ex) { + } catch (ClassNotFoundException cnf) { + } catch (IOException ex) { + } finally { + if (ois != null) { + try { + ois.close(); + } catch (IOException ex1) { + //ignore + } } - PrintWriter pw = new PrintWriter(new FileWriter(getReplacementsFile())); - for (Replacement r : replacements) { - pw.println(r.urlPattern); - pw.println(r.targetFile); + } + loadReplacements(); + } + + public static void save() { + File f = new File(getASDecHome()); + if (!f.exists()) { + f.mkdir(); + } + ObjectOutputStream oos = null; + try { + oos = new ObjectOutputStream(new FileOutputStream(getConfigFile())); + oos.writeObject(config); + } catch (IOException ex) { + JOptionPane.showMessageDialog(null, "Cannot save configuration.", "Error", JOptionPane.ERROR_MESSAGE); + Logger.getLogger(SWFInputStream.class.getName()).severe("Configuration directory is read only."); + } finally { + if (oos != null) { + try { + oos.close(); + } catch (IOException ex1) { + //ignore + } } - pw.close(); - } - } catch (IOException e) { - } - } + } + saveReplacements(); + } - /** - * Load replacements from file - */ - private static void loadReplacements() { - replacements = new ArrayList(); - try { - BufferedReader br = new BufferedReader(new FileReader(getReplacementsFile())); - String s; - while ((s = br.readLine()) != null) { - Replacement r = new Replacement(s, br.readLine()); - replacements.add(r); - } - br.close(); - } catch (IOException e) { - } - } - - public static Object getConfig(String cfg) { - return getConfig(cfg, null); - } - - public static Object getConfig(String cfg, Object defaultValue) { - if (!config.containsKey(cfg)) { - return defaultValue; - } - return config.get(cfg); - } - - public static Object setConfig(String cfg, Object value) { - return config.put(cfg, value); - } - - public static void load() { - ObjectInputStream ois = null; - try { - ois = new ObjectInputStream(new FileInputStream(getConfigFile())); - config = (HashMap) ois.readObject(); - } catch (FileNotFoundException ex) { - } catch (ClassNotFoundException cnf) { - } catch (IOException ex) { - } finally { - if (ois != null) { - try { - ois.close(); - } catch (IOException ex1) { - //ignore - } - } - } - loadReplacements(); - } - - public static void save() { - File f = new File(getASDecHome()); - if (!f.exists()) { - f.mkdir(); - } - ObjectOutputStream oos = null; - try { - oos = new ObjectOutputStream(new FileOutputStream(getConfigFile())); - oos.writeObject(config); - } catch (IOException ex) { - JOptionPane.showMessageDialog(null, "Cannot save configuration.", "Error", JOptionPane.ERROR_MESSAGE); - Logger.getLogger(SWFInputStream.class.getName()).severe("Configuration directory is read only."); - } finally { - if (oos != null) { - try { - oos.close(); - } catch (IOException ex1) { - //ignore - } - } - } - saveReplacements(); - } - - public static List getReplacements() { - return replacements; - } + public static List getReplacements() { + return replacements; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/EventListener.java b/trunk/src/com/jpexs/decompiler/flash/EventListener.java index 246a5df3f..b9fb3d7c9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/EventListener.java +++ b/trunk/src/com/jpexs/decompiler/flash/EventListener.java @@ -22,5 +22,5 @@ package com.jpexs.decompiler.flash; */ public interface EventListener { - public void handleEvent(String event, Object data); + public void handleEvent(String event, Object data); } diff --git a/trunk/src/com/jpexs/decompiler/flash/Main.java b/trunk/src/com/jpexs/decompiler/flash/Main.java index 2bc3251bd..927bb5b07 100644 --- a/trunk/src/com/jpexs/decompiler/flash/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/Main.java @@ -57,747 +57,748 @@ import org.w3c.dom.NodeList; */ public class Main { - public static ProxyFrame proxyFrame; - public static String file; - public static String maskURL; - public static SWF swf; - public static final String version = "1.4.2u1"; - public static final String applicationName = "JPEXS Free Flash Decompiler v." + version; - public static final String shortApplicationName = "FFDec"; - public static final String shortApplicationVerName = shortApplicationName + " v." + version; - public static final String projectPage = "http://www.free-decompiler.com/flash"; - public static final String updatePage = "http://www.free-decompiler.com/flash/?update="+version; - public static final String vendor = "JPEXS"; - public static LoadingDialog loadingDialog; - public static ModeFrame modeFrame; - private static boolean working = false; - private static TrayIcon trayIcon; - private static MenuItem stopMenuItem; - private static boolean commandLineMode = false; - public static MainFrame mainFrame; + public static ProxyFrame proxyFrame; + public static String file; + public static String maskURL; + public static SWF swf; + public static final String version = "1.4.2u1"; + public static final String applicationName = "JPEXS Free Flash Decompiler v." + version; + public static final String shortApplicationName = "FFDec"; + public static final String shortApplicationVerName = shortApplicationName + " v." + version; + public static final String projectPage = "http://www.free-decompiler.com/flash"; + public static final String updatePage = "http://www.free-decompiler.com/flash/?update=" + version; + public static final String vendor = "JPEXS"; + public static LoadingDialog loadingDialog; + public static ModeFrame modeFrame; + private static boolean working = false; + private static TrayIcon trayIcon; + private static MenuItem stopMenuItem; + private static boolean commandLineMode = false; + public static MainFrame mainFrame; - public static boolean isCommandLineMode() { - return commandLineMode; - } - public static final boolean DISPLAY_FILENAME = true; - public static boolean DEBUG_COPY = false; - /** - * Debug mode = throwing an error when comparing original file and recompiled - */ - public static boolean debugMode = false; - /** - * Turn off reading unsafe tags (tags which can cause problems with - * recompiling) - */ - public static boolean DISABLE_DANGEROUS = false; - /** - * Turn off resolving constants in ActionScript 2 - */ - public static final boolean RESOLVE_CONSTANTS = true; - /** - * Turn off decompiling if needed - */ - public static final boolean DO_DECOMPILE = true; - /** - * Find latest constant pool in the code - */ - public static final boolean LATEST_CONSTANTPOOL_HACK = false; - /** - * Dump tags to stdout - */ - public static boolean dump_tags = false; - /** - * Limit of code subs (for obfuscated code) - */ - public static final int SUBLIMITER = 500; - //using parameter names in decompiling may cause problems because oficial programs like Flash CS 5.5 inserts wrong parameter names indices - public static final boolean PARAM_NAMES_ENABLE = false; + public static boolean isCommandLineMode() { + return commandLineMode; + } + public static final boolean DISPLAY_FILENAME = true; + public static boolean DEBUG_COPY = false; + /** + * Debug mode = throwing an error when comparing original file and + * recompiled + */ + public static boolean debugMode = false; + /** + * Turn off reading unsafe tags (tags which can cause problems with + * recompiling) + */ + public static boolean DISABLE_DANGEROUS = false; + /** + * Turn off resolving constants in ActionScript 2 + */ + public static final boolean RESOLVE_CONSTANTS = true; + /** + * Turn off decompiling if needed + */ + public static final boolean DO_DECOMPILE = true; + /** + * Find latest constant pool in the code + */ + public static final boolean LATEST_CONSTANTPOOL_HACK = false; + /** + * Dump tags to stdout + */ + public static boolean dump_tags = false; + /** + * Limit of code subs (for obfuscated code) + */ + public static final int SUBLIMITER = 500; + //using parameter names in decompiling may cause problems because oficial programs like Flash CS 5.5 inserts wrong parameter names indices + public static final boolean PARAM_NAMES_ENABLE = false; - public static String getFileTitle() { - if (maskURL != null) { - return maskURL; - } - return file; - } + public static String getFileTitle() { + if (maskURL != null) { + return maskURL; + } + return file; + } - public static void setSubLimiter(boolean value) { - if (value) { - AVM2Code.toSourceLimit = Main.SUBLIMITER; - } else { - AVM2Code.toSourceLimit = -1; - } - } + public static void setSubLimiter(boolean value) { + if (value) { + AVM2Code.toSourceLimit = Main.SUBLIMITER; + } else { + AVM2Code.toSourceLimit = -1; + } + } - public static boolean isWorking() { - return working; - } + public static boolean isWorking() { + return working; + } - public static void showProxy() { - if (proxyFrame == null) { - proxyFrame = new ProxyFrame(); - } - proxyFrame.setVisible(true); - proxyFrame.setState(Frame.NORMAL); - } + public static void showProxy() { + if (proxyFrame == null) { + proxyFrame = new ProxyFrame(); + } + proxyFrame.setVisible(true); + proxyFrame.setState(Frame.NORMAL); + } - public static void startWork(String name) { - startWork(name, -1); - } + public static void startWork(String name) { + startWork(name, -1); + } - public static void startWork(String name, int percent) { - working = true; - if (mainFrame != null) { - mainFrame.setWorkStatus(name); - if (percent == -1) { - mainFrame.hidePercent(); - } else { - mainFrame.setPercent(percent); - } - } - if (loadingDialog != null) { - loadingDialog.setDetail(name); - if (percent == -1) { - loadingDialog.hidePercent(); - } else { - loadingDialog.setPercent(percent); - } - } - if (Main.isCommandLineMode()) { - System.out.println(name); - } - } - - public static void stopWork() { - working = false; - if (mainFrame != null) { - mainFrame.setWorkStatus(""); - } - if (loadingDialog != null) { - loadingDialog.setDetail(""); - } - } - - public static SWF parseSWF(String file) throws Exception { - FileInputStream fis = new FileInputStream(file); - InputStream bis = new BufferedInputStream(fis); - SWF locswf = new SWF(bis, new PercentListener() { - @Override - public void percent(int p) { - startWork("Reading SWF", p); - } - }); - locswf.addEventListener(new EventListener() { - @Override - public void handleEvent(String event, Object data) { - if (event.equals("export")) { - startWork((String) data); + public static void startWork(String name, int percent) { + working = true; + if (mainFrame != null) { + mainFrame.setWorkStatus(name); + if (percent == -1) { + mainFrame.hidePercent(); + } else { + mainFrame.setPercent(percent); } - } - }); - return locswf; - } + } + if (loadingDialog != null) { + loadingDialog.setDetail(name); + if (percent == -1) { + loadingDialog.hidePercent(); + } else { + loadingDialog.setPercent(percent); + } + } + if (Main.isCommandLineMode()) { + System.out.println(name); + } + } - public static void saveFile(String outfile) throws IOException { - file = outfile; - swf.saveTo(new FileOutputStream(outfile)); - } + public static void stopWork() { + working = false; + if (mainFrame != null) { + mainFrame.setWorkStatus(""); + } + if (loadingDialog != null) { + loadingDialog.setDetail(""); + } + } - private static class OpenFileWorker extends SwingWorker { + public static SWF parseSWF(String file) throws Exception { + FileInputStream fis = new FileInputStream(file); + InputStream bis = new BufferedInputStream(fis); + SWF locswf = new SWF(bis, new PercentListener() { + @Override + public void percent(int p) { + startWork("Reading SWF", p); + } + }); + locswf.addEventListener(new EventListener() { + @Override + public void handleEvent(String event, Object data) { + if (event.equals("export")) { + startWork((String) data); + } + } + }); + return locswf; + } - @Override - protected Object doInBackground() throws Exception { - try { - Main.startWork("Reading SWF..."); - swf = parseSWF(Main.file); - FileInputStream fis = new FileInputStream(file); - DEBUG_COPY = true; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - /*try { - swf.saveTo(baos); - } catch (NotSameException nse) { - Logger.getLogger(Main.class.getName()).log(Level.FINE, null, nse); - JOptionPane.showMessageDialog(null, "WARNING: The SWF decompiler may have problems saving this file. Recommended usage is READ ONLY."); - }*/ - DEBUG_COPY = false; - //DEBUG_COPY=true; - } catch (Exception ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); - JOptionPane.showMessageDialog(null, "Cannot load SWF file."); - loadingDialog.setVisible(false); - return false; - } + public static void saveFile(String outfile) throws IOException { + file = outfile; + swf.saveTo(new FileOutputStream(outfile)); + } - try { - Main.startWork("Creating window..."); - mainFrame = new MainFrame(swf); - loadingDialog.setVisible(false); - mainFrame.setVisible(true); - Main.stopWork(); - } catch (Exception ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); - } - return true; - } - } + private static class OpenFileWorker extends SwingWorker { - public static boolean openFile(String swfFile) { - if (mainFrame != null) { - mainFrame.setVisible(false); - } - Main.file = swfFile; - if (Main.loadingDialog == null) { - Main.loadingDialog = new LoadingDialog(); - } - Main.loadingDialog.setVisible(true); - (new OpenFileWorker()).execute(); - return true; - } + @Override + protected Object doInBackground() throws Exception { + try { + Main.startWork("Reading SWF..."); + swf = parseSWF(Main.file); + FileInputStream fis = new FileInputStream(file); + DEBUG_COPY = true; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + /*try { + swf.saveTo(baos); + } catch (NotSameException nse) { + Logger.getLogger(Main.class.getName()).log(Level.FINE, null, nse); + JOptionPane.showMessageDialog(null, "WARNING: The SWF decompiler may have problems saving this file. Recommended usage is READ ONLY."); + }*/ + DEBUG_COPY = false; + //DEBUG_COPY=true; + } catch (Exception ex) { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + JOptionPane.showMessageDialog(null, "Cannot load SWF file."); + loadingDialog.setVisible(false); + return false; + } - public static boolean saveFileDialog() { - JFileChooser fc = new JFileChooser(); - fc.setCurrentDirectory(new File((String) Configuration.getConfig("lastSaveDir", "."))); - JFrame f = new JFrame(); - View.setWindowIcon(f); - int returnVal = fc.showSaveDialog(f); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - try { - Main.saveFile(file.getAbsolutePath()); - Configuration.setConfig("lastSaveDir", file.getParentFile().getAbsolutePath()); - maskURL = null; + try { + Main.startWork("Creating window..."); + mainFrame = new MainFrame(swf); + loadingDialog.setVisible(false); + mainFrame.setVisible(true); + Main.stopWork(); + } catch (Exception ex) { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + } return true; - } catch (IOException ex) { - JOptionPane.showMessageDialog(null, "Cannot write to the file"); - } - } - return false; - } + } + } - public static boolean openFileDialog() { - maskURL = null; - JFileChooser fc = new JFileChooser(); - fc.setCurrentDirectory(new File((String) Configuration.getConfig("lastOpenDir", "."))); - fc.setFileFilter(new FileFilter() { - @Override - public boolean accept(File f) { - return (f.getName().endsWith(".swf")) || (f.isDirectory()); - } + public static boolean openFile(String swfFile) { + if (mainFrame != null) { + mainFrame.setVisible(false); + } + Main.file = swfFile; + if (Main.loadingDialog == null) { + Main.loadingDialog = new LoadingDialog(); + } + Main.loadingDialog.setVisible(true); + (new OpenFileWorker()).execute(); + return true; + } - @Override - public String getDescription() { - return "SWF files (*.swf)"; - } - }); - JFrame f = new JFrame(); - View.setWindowIcon(f); - int returnVal = fc.showOpenDialog(f); - if (returnVal == JFileChooser.APPROVE_OPTION) { - Configuration.setConfig("lastOpenDir", fc.getSelectedFile().getParentFile().getAbsolutePath()); - File selfile = fc.getSelectedFile(); - Main.openFile(selfile.getAbsolutePath()); - return true; - } else { - return false; - } - } - - public static void showModeFrame() { - if (modeFrame == null) { - modeFrame = new ModeFrame(); - } - modeFrame.setVisible(true); - } - - public static void updateLicense() { - updateLicenseInDir(new File(".\\src\\")); - } - - /** - * Script for updating license header in java files :-) - * - * @param dir Star directory (e.g. "src/") - */ - public static void updateLicenseInDir(File dir) { - int defaultStartYear = 2010; - int defaultFinalYear = 2013; - String defaultAuthor = "JPEXS"; - String defaultYearStr = "" + defaultStartYear; - if (defaultFinalYear != defaultStartYear) { - defaultYearStr += "-" + defaultFinalYear; - } - String license = "/*\r\n * Copyright (C) {year} {author}\r\n * \r\n * This program is free software: you can redistribute it and/or modify\r\n * it under the terms of the GNU General Public License as published by\r\n * the Free Software Foundation, either version 3 of the License, or\r\n * (at your option) any later version.\r\n * \r\n * This program is distributed in the hope that it will be useful,\r\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n * GNU General Public License for more details.\r\n * \r\n * You should have received a copy of the GNU General Public License\r\n * along with this program. If not, see .\r\n */"; - - File files[] = dir.listFiles(); - for (File f : files) { - if (f.isDirectory()) { - updateLicenseInDir(f); - } else { - if (f.getName().endsWith(".java")) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintWriter pw = null; - try { - pw = new PrintWriter(new OutputStreamWriter(baos, "utf8")); - } catch (UnsupportedEncodingException ex) { - } - try { - BufferedReader br = new BufferedReader(new FileReader(f)); - String s; - boolean packageFound = false; - String author = defaultAuthor; - String yearStr = defaultYearStr; - while ((s = br.readLine()) != null) { - if (!packageFound) { - if (s.trim().startsWith("package")) { - packageFound = true; - pw.println(license.replace("{year}", yearStr).replace("{author}", author)); - } else { - Matcher mAuthor = Pattern.compile("^.*Copyright \\(C\\) ([0-9]+)(-[0-9]+)? (.*)$").matcher(s); - if (mAuthor.matches()) { - author = mAuthor.group(3).trim(); - int startYear = Integer.parseInt(mAuthor.group(1).trim()); - if (startYear == defaultFinalYear) { - yearStr = "" + startYear; - } else { - yearStr = "" + startYear + "-" + defaultFinalYear; - } - if (!author.equals(defaultAuthor)) { - System.out.println("Detected nodefault author:" + author + " in " + f.getAbsolutePath()); - } - } - } - } - if (packageFound) { - pw.println(s); - } - } - br.close(); - pw.close(); - } catch (IOException ex) { - } - - FileOutputStream fos; - try { - fos = new FileOutputStream(f); - fos.write(baos.toByteArray()); - fos.close(); - } catch (IOException ex) { - } - } - } - } - - } - - public static void badArguments() { - System.err.println("Error: Bad Commandline Arguments!"); - printCmdLineUsage(); - System.exit(1); - } - - public static void printHeader() { - System.out.println(applicationName); - for (int i = 0; i < applicationName.length(); i++) { - System.out.print("-"); - } - System.out.println(); - } - - public static void printCmdLineUsage() { - System.out.println("Commandline arguments:"); - System.out.println(" 1) -help | --help | /?"); - System.out.println(" ...shows commandline arguments (this help)"); - System.out.println(" 2) infile"); - System.out.println(" ...opens SWF file with the decompiler GUI"); - System.out.println(" 3) -proxy (-PXXX)"); - System.out.println(" ...auto start proxy in the tray. Optional parameter -P specifies port for proxy. Defaults to 55555. "); - System.out.println(" 4) -export (as|pcode|image|shape|movie|sound) outdirectory infile"); - System.out.println(" ...export infile sources to outdirectory as AsctionScript code (\"as\" argument) or as PCode (\"pcode\" argument), images, shapes or movies"); - System.out.println(" 5) -dumpSWF infile"); - System.out.println(" ...dumps list of SWF tags to console"); - System.out.println(" 6) -compress infile outfile"); - System.out.println(" ...Compress SWF infile and save it to outfile"); - System.out.println(" 7) -decompress infile outfile"); - System.out.println(" ...Decompress infile and save it to outfile"); - System.out.println(); - System.out.println("Examples:"); - System.out.println("java -jar FFDec.jar myfile.swf"); - System.out.println("java -jar FFDec.jar -proxy"); - System.out.println("java -jar FFDec.jar -proxy -P1234"); - System.out.println("java -jar FFDec.jar -export as \"C:\\decompiled\\\" myfile.swf"); - System.out.println("java -jar FFDec.jar -export pcode \"C:\\decompiled\\\" myfile.swf"); - System.out.println("java -jar FFDec.jar -dumpSWF myfile.swf"); - System.out.println("java -jar FFDec.jar -compress myfile.swf myfiledec.swf"); - System.out.println("java -jar FFDec.jar -decompress myfiledec.swf myfile.swf"); - } - - private static void copyFile(String from, String to) throws IOException { - FileInputStream fis = new FileInputStream(from); - FileOutputStream fos = new FileOutputStream(to); - byte buf[] = new byte[4096]; - int cnt = 0; - while ((cnt = fis.read(buf)) > 0) { - fos.write(buf, 0, cnt); - } - fis.close(); - fos.close(); - } - - /** - * @param args the command line arguments - */ - public static void main(String[] args) throws IOException { - View.setLookAndFeel(); - Configuration.load(); - - int pos = 0; - if (args.length > 0) { - if (args[0].equals("-debug")) { - debugMode = true; - pos++; - } - } - initLogging(debugMode); - if (args.length < pos + 1) { - autoCheckForUpdates(); - showModeFrame(); - } else { - if (args[pos].equals("-proxy")) { - int port = 55555; - for (int i = pos; i < args.length; i++) { - if (args[i].startsWith("-P")) { - try { - port = Integer.parseInt(args[pos].substring(2)); - } catch (NumberFormatException nex) { - System.err.println("Bad port number"); - } - } - } - if (proxyFrame == null) { - proxyFrame = new ProxyFrame(); - } - proxyFrame.setPort(port); - addTrayIcon(); - switchProxy(); - } else if (args[pos].equals("-export")) { - if (args.length < pos + 4) { - badArguments(); - } - String exportFormat = args[pos + 1]; - if (!exportFormat.toLowerCase().equals("as")) { - if (!exportFormat.toLowerCase().equals("pcode")) { - if (!exportFormat.toLowerCase().equals("image")) { - if (!exportFormat.toLowerCase().equals("shape")) { - if (!exportFormat.toLowerCase().equals("movie")) { - if (!exportFormat.toLowerCase().equals("sound")) { - System.err.println("Invalid export format:" + exportFormat); - badArguments(); - } - } - } - } - } - } - File outDir = new File(args[pos + 2]); - File inFile = new File(args[pos + 3]); - if (!inFile.exists()) { - System.err.println("Input SWF file does not exist!"); - badArguments(); - } - commandLineMode = true; - boolean exportOK; + public static boolean saveFileDialog() { + JFileChooser fc = new JFileChooser(); + fc.setCurrentDirectory(new File((String) Configuration.getConfig("lastSaveDir", "."))); + JFrame f = new JFrame(); + View.setWindowIcon(f); + int returnVal = fc.showSaveDialog(f); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = fc.getSelectedFile(); try { - printHeader(); - SWF exfile = new SWF(new FileInputStream(inFile)); - exfile.addEventListener(new EventListener() { - @Override - public void handleEvent(String event, Object data) { - if (event.equals("export")) { - System.out.println((String) data); - } - } - }); - if (exportFormat.equals("image")) { - exfile.exportImages(outDir.getAbsolutePath()); - exportOK = true; - } else if (exportFormat.equals("shape")) { - exfile.exportShapes(outDir.getAbsolutePath()); - exportOK = true; - } else if (exportFormat.equals("as") || exportFormat.equals("pcode")) { - exportOK = exfile.exportActionScript(outDir.getAbsolutePath(), exportFormat.equals("pcode")); - } else if (exportFormat.equals("movie")) { - exfile.exportMovies(outDir.getAbsolutePath()); - exportOK = true; - } else if (exportFormat.equals("sound")) { - exfile.exportSounds(outDir.getAbsolutePath(), true); - exportOK = true; - } else { - exportOK = false; - } - } catch (Exception ex) { - exportOK = false; - System.err.print("FAIL: Exporting Failed on Exception - "); - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); - System.exit(1); + Main.saveFile(file.getAbsolutePath()); + Configuration.setConfig("lastSaveDir", file.getParentFile().getAbsolutePath()); + maskURL = null; + return true; + } catch (IOException ex) { + JOptionPane.showMessageDialog(null, "Cannot write to the file"); } - if (exportOK) { - System.out.println("OK"); - System.exit(0); - } else { - System.err.println("FAIL"); - System.exit(1); - } - } else if (args[pos].equals("-compress")) { - if (args.length < pos + 3) { - badArguments(); + } + return false; + } + + public static boolean openFileDialog() { + maskURL = null; + JFileChooser fc = new JFileChooser(); + fc.setCurrentDirectory(new File((String) Configuration.getConfig("lastOpenDir", "."))); + fc.setFileFilter(new FileFilter() { + @Override + public boolean accept(File f) { + return (f.getName().endsWith(".swf")) || (f.isDirectory()); } - if (SWF.fws2cws(new FileInputStream(args[pos + 1]), new FileOutputStream(args[pos + 2]))) { - System.out.println("OK"); - } else { - System.err.println("FAIL"); - } - } else if (args[pos].equals("-decompress")) { - if (args.length < pos + 3) { - badArguments(); + @Override + public String getDescription() { + return "SWF files (*.swf)"; } + }); + JFrame f = new JFrame(); + View.setWindowIcon(f); + int returnVal = fc.showOpenDialog(f); + if (returnVal == JFileChooser.APPROVE_OPTION) { + Configuration.setConfig("lastOpenDir", fc.getSelectedFile().getParentFile().getAbsolutePath()); + File selfile = fc.getSelectedFile(); + Main.openFile(selfile.getAbsolutePath()); + return true; + } else { + return false; + } + } - if (SWF.cws2fws(new FileInputStream(args[pos + 1]), new FileOutputStream(args[pos + 2]))) { - System.out.println("OK"); - System.exit(0); + public static void showModeFrame() { + if (modeFrame == null) { + modeFrame = new ModeFrame(); + } + modeFrame.setVisible(true); + } + + public static void updateLicense() { + updateLicenseInDir(new File(".\\src\\")); + } + + /** + * Script for updating license header in java files :-) + * + * @param dir Star directory (e.g. "src/") + */ + public static void updateLicenseInDir(File dir) { + int defaultStartYear = 2010; + int defaultFinalYear = 2013; + String defaultAuthor = "JPEXS"; + String defaultYearStr = "" + defaultStartYear; + if (defaultFinalYear != defaultStartYear) { + defaultYearStr += "-" + defaultFinalYear; + } + String license = "/*\r\n * Copyright (C) {year} {author}\r\n * \r\n * This program is free software: you can redistribute it and/or modify\r\n * it under the terms of the GNU General Public License as published by\r\n * the Free Software Foundation, either version 3 of the License, or\r\n * (at your option) any later version.\r\n * \r\n * This program is distributed in the hope that it will be useful,\r\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n * GNU General Public License for more details.\r\n * \r\n * You should have received a copy of the GNU General Public License\r\n * along with this program. If not, see .\r\n */"; + + File files[] = dir.listFiles(); + for (File f : files) { + if (f.isDirectory()) { + updateLicenseInDir(f); } else { - System.err.println("FAIL"); - System.exit(1); + if (f.getName().endsWith(".java")) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintWriter pw = null; + try { + pw = new PrintWriter(new OutputStreamWriter(baos, "utf8")); + } catch (UnsupportedEncodingException ex) { + } + try { + BufferedReader br = new BufferedReader(new FileReader(f)); + String s; + boolean packageFound = false; + String author = defaultAuthor; + String yearStr = defaultYearStr; + while ((s = br.readLine()) != null) { + if (!packageFound) { + if (s.trim().startsWith("package")) { + packageFound = true; + pw.println(license.replace("{year}", yearStr).replace("{author}", author)); + } else { + Matcher mAuthor = Pattern.compile("^.*Copyright \\(C\\) ([0-9]+)(-[0-9]+)? (.*)$").matcher(s); + if (mAuthor.matches()) { + author = mAuthor.group(3).trim(); + int startYear = Integer.parseInt(mAuthor.group(1).trim()); + if (startYear == defaultFinalYear) { + yearStr = "" + startYear; + } else { + yearStr = "" + startYear + "-" + defaultFinalYear; + } + if (!author.equals(defaultAuthor)) { + System.out.println("Detected nodefault author:" + author + " in " + f.getAbsolutePath()); + } + } + } + } + if (packageFound) { + pw.println(s); + } + } + br.close(); + pw.close(); + } catch (IOException ex) { + } + + FileOutputStream fos; + try { + fos = new FileOutputStream(f); + fos.write(baos.toByteArray()); + fos.close(); + } catch (IOException ex) { + } + } } - } else if (args[pos].equals("-dumpSWF")) { - if (args.length < pos + 2) { - badArguments(); + } + + } + + public static void badArguments() { + System.err.println("Error: Bad Commandline Arguments!"); + printCmdLineUsage(); + System.exit(1); + } + + public static void printHeader() { + System.out.println(applicationName); + for (int i = 0; i < applicationName.length(); i++) { + System.out.print("-"); + } + System.out.println(); + } + + public static void printCmdLineUsage() { + System.out.println("Commandline arguments:"); + System.out.println(" 1) -help | --help | /?"); + System.out.println(" ...shows commandline arguments (this help)"); + System.out.println(" 2) infile"); + System.out.println(" ...opens SWF file with the decompiler GUI"); + System.out.println(" 3) -proxy (-PXXX)"); + System.out.println(" ...auto start proxy in the tray. Optional parameter -P specifies port for proxy. Defaults to 55555. "); + System.out.println(" 4) -export (as|pcode|image|shape|movie|sound) outdirectory infile"); + System.out.println(" ...export infile sources to outdirectory as AsctionScript code (\"as\" argument) or as PCode (\"pcode\" argument), images, shapes or movies"); + System.out.println(" 5) -dumpSWF infile"); + System.out.println(" ...dumps list of SWF tags to console"); + System.out.println(" 6) -compress infile outfile"); + System.out.println(" ...Compress SWF infile and save it to outfile"); + System.out.println(" 7) -decompress infile outfile"); + System.out.println(" ...Decompress infile and save it to outfile"); + System.out.println(); + System.out.println("Examples:"); + System.out.println("java -jar FFDec.jar myfile.swf"); + System.out.println("java -jar FFDec.jar -proxy"); + System.out.println("java -jar FFDec.jar -proxy -P1234"); + System.out.println("java -jar FFDec.jar -export as \"C:\\decompiled\\\" myfile.swf"); + System.out.println("java -jar FFDec.jar -export pcode \"C:\\decompiled\\\" myfile.swf"); + System.out.println("java -jar FFDec.jar -dumpSWF myfile.swf"); + System.out.println("java -jar FFDec.jar -compress myfile.swf myfiledec.swf"); + System.out.println("java -jar FFDec.jar -decompress myfiledec.swf myfile.swf"); + } + + private static void copyFile(String from, String to) throws IOException { + FileInputStream fis = new FileInputStream(from); + FileOutputStream fos = new FileOutputStream(to); + byte buf[] = new byte[4096]; + int cnt = 0; + while ((cnt = fis.read(buf)) > 0) { + fos.write(buf, 0, cnt); + } + fis.close(); + fos.close(); + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) throws IOException { + View.setLookAndFeel(); + Configuration.load(); + + int pos = 0; + if (args.length > 0) { + if (args[0].equals("-debug")) { + debugMode = true; + pos++; } - try { - dump_tags = true; - SWF swf = parseSWF(args[pos + 1]); - } catch (Exception ex) { - Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); - System.exit(1); - } - System.exit(0); - } else if (args[pos].equals("-help") || args[pos].equals("--help") || args[pos].equals("/?")) { - printHeader(); - printCmdLineUsage(); - System.exit(0); - } else if (args.length == pos + 1) { + } + initLogging(debugMode); + if (args.length < pos + 1) { autoCheckForUpdates(); - openFile(args[pos]); - } else { - badArguments(); - } - } - } - - public static String tempFile(String url) { - File f = new File(Configuration.getASDecHome() + "saved" + File.separator); - if (!f.exists()) { - f.mkdirs(); - } - return Configuration.getASDecHome() + "saved" + File.separator + "asdec_" + Integer.toHexString(url.hashCode()) + ".tmp"; - - } - - public static void removeTrayIcon() { - if (SystemTray.isSupported()) { - SystemTray tray = SystemTray.getSystemTray(); - if (trayIcon != null) { - tray.remove(trayIcon); - trayIcon = null; - } - } - } - - public static void switchProxy() { - proxyFrame.switchState(); - if (stopMenuItem != null) { - if (proxyFrame.isRunning()) { - stopMenuItem.setLabel("Stop proxy"); - } else { - stopMenuItem.setLabel("Start proxy"); - } - } - } - - public static void addTrayIcon() { - if (trayIcon != null) { - return; - } - if (SystemTray.isSupported()) { - SystemTray tray = SystemTray.getSystemTray(); - trayIcon = new TrayIcon(View.loadImage("proxy16"), "JP ASDec Proxy"); - trayIcon.setImageAutoSize(true); - PopupMenu trayPopup = new PopupMenu(); - - - ActionListener trayListener = new ActionListener() { - /** - * Invoked when an action occurs. - */ - @Override - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("EXIT")) { - Main.exit(); - } - if (e.getActionCommand().equals("SHOW")) { - Main.showProxy(); - } - if (e.getActionCommand().equals("SWITCH")) { - Main.switchProxy(); - } - } - }; - - - MenuItem showMenuItem = new MenuItem("Show proxy"); - showMenuItem.setActionCommand("SHOW"); - showMenuItem.addActionListener(trayListener); - trayPopup.add(showMenuItem); - stopMenuItem = new MenuItem("Start proxy"); - stopMenuItem.setActionCommand("SWITCH"); - stopMenuItem.addActionListener(trayListener); - trayPopup.add(stopMenuItem); - trayPopup.addSeparator(); - MenuItem exitMenuItem = new MenuItem("Exit"); - exitMenuItem.setActionCommand("EXIT"); - exitMenuItem.addActionListener(trayListener); - trayPopup.add(exitMenuItem); - - trayIcon.setPopupMenu(trayPopup); - trayIcon.addMouseListener(new MouseAdapter() { - /** - * {@inheritDoc} - */ - @Override - public void mouseClicked(MouseEvent e) { - if (e.getButton() == MouseEvent.BUTTON1) { - Main.showProxy(); - } - } - }); - try { - tray.add(trayIcon); - } catch (AWTException ex) { - } - } - } - - public static void exit() { - Configuration.save(); - FlashPlayerPanel.unload(); - System.exit(0); - } - - public static void about() { - (new AboutDialog()).setVisible(true); - } - - public static void autoCheckForUpdates() { - Calendar lastUpdatesCheckDate = (Calendar) Configuration.getConfig("lastUpdatesCheckDate", null); - if ((lastUpdatesCheckDate == null) || (lastUpdatesCheckDate.getTime().getTime() < Calendar.getInstance().getTime().getTime() - 1000 * 60 * 60 * 24)) { - checkForUpdates(); - } - } - - public static boolean checkForUpdates() { - try { - Socket sock = new Socket("code.google.com", 80); - OutputStream os = sock.getOutputStream(); - os.write("GET /feeds/p/asdec/downloads/basic HTTP/1.1\r\nHost: code.google.com\r\nConnection: close\r\n\r\n".getBytes()); - BufferedReader br = new BufferedReader(new InputStreamReader(sock.getInputStream())); - String s; - String response = ""; - boolean start = false; - while ((s = br.readLine()) != null) { - if (start) { - response += s + "\r\n"; - } - if (s.equals("")) { - start = true; - } - } - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - Document doc = builder.parse(new ByteArrayInputStream(response.getBytes())); - NodeList contents = doc.getElementsByTagName("content"); - for (int i = 0; i < contents.getLength(); i++) { - Node nod = contents.item(i); - String cont = nod.getTextContent().trim(); - String parts[] = cont.split("\n"); - boolean isUpdate = false; - for (String part : parts) { - if (part.trim().equals("Update")) { - isUpdate = true; - break; - } - } - if ((parts.length > 4) && (isUpdate)) { - String downloadName = parts[1]; - String link = parts[parts.length - 2]; - if (isUpdate) { - String downVersion = "NEW"; - if (downloadName.startsWith(shortApplicationName + " version ")) { - downVersion = downloadName.substring((shortApplicationName + " version ").length()); - if (downVersion.contains(" ")) { - downVersion = downVersion.substring(0, downVersion.indexOf(" ")); - } - } - if (link.startsWith(" 4) && (isUpdate)) { + String downloadName = parts[1]; + String link = parts[parts.length - 2]; + if (isUpdate) { + String downVersion = "NEW"; + if (downloadName.startsWith(shortApplicationName + " version ")) { + downVersion = downloadName.substring((shortApplicationName + " version ").length()); + if (downVersion.contains(" ")) { + downVersion = downVersion.substring(0, downVersion.indexOf(" ")); + } + } + if (link.startsWith(" count) { - this.pos = count; - skip(pos - count); - } - this.pos = pos; - } + public void setPos(int pos) throws IOException { + if (pos > count) { + this.pos = count; + skip(pos - count); + } + this.pos = pos; + } - @Override - public int read() throws IOException { - if (pos < count) { - if (converted == null) { - converted = baos.toByteArray(); - } - int ret = converted[pos] & 0xff; - pos++; - return ret; - } - int i = is.read(); - if (i > -1) { - baos.write(i); - count++; - } - pos++; - converted = null; + @Override + public int read() throws IOException { + if (pos < count) { + if (converted == null) { + converted = baos.toByteArray(); + } + int ret = converted[pos] & 0xff; + pos++; + return ret; + } + int i = is.read(); + if (i > -1) { + baos.write(i); + count++; + } + pos++; + converted = null; - return i; - } + return i; + } - @Override - public int available() throws IOException { - return (count + is.available()) - pos; - } + @Override + public int available() throws IOException { + return (count + is.available()) - pos; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/SWF.java b/trunk/src/com/jpexs/decompiler/flash/SWF.java index 848743bc8..7a4558a9e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWF.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWF.java @@ -97,1012 +97,1012 @@ import javax.imageio.ImageIO; */ public class SWF { - /** - * Default version of SWF file format - */ - public static final int DEFAULT_VERSION = 10; - /** - * Tags inside of file - */ - public List tags = new ArrayList(); - /** - * Rectangle for the display - */ - public RECT displayRect; - /** - * Movie frame rate - */ - public int frameRate; - /** - * Number of frames in movie - */ - public int frameCount; - /** - * Version of SWF - */ - public int version; - /** - * Size of the file - */ - public long fileSize; - /** - * Use compression - */ - public boolean compressed = false; - /** - * Use LZMA compression - */ - public boolean lzma = false; - /** - * Compressed size of the file (LZMA) - */ - public long compressedSize; - /** - * LZMA Properties - */ - public byte lzmaProperties[]; + /** + * Default version of SWF file format + */ + public static final int DEFAULT_VERSION = 10; + /** + * Tags inside of file + */ + public List tags = new ArrayList(); + /** + * Rectangle for the display + */ + public RECT displayRect; + /** + * Movie frame rate + */ + public int frameRate; + /** + * Number of frames in movie + */ + public int frameCount; + /** + * Version of SWF + */ + public int version; + /** + * Size of the file + */ + public long fileSize; + /** + * Use compression + */ + public boolean compressed = false; + /** + * Use LZMA compression + */ + public boolean lzma = false; + /** + * Compressed size of the file (LZMA) + */ + public long compressedSize; + /** + * LZMA Properties + */ + public byte lzmaProperties[]; - /** - * Gets all tags with specified id - * - * @param tagId Identificator of tag type - * @return List of tags - */ - public List getTagData(int tagId) { - List ret = new ArrayList(); - for (Tag tag : tags) { - if (tag.getId() == tagId) { - ret.add(tag); - } - } - return ret; - } - - /** - * Saves this SWF into new file - * - * @param os OutputStream to save SWF in - * @throws IOException - */ - public void saveTo(OutputStream os) throws IOException { - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - sos.writeRECT(displayRect); - sos.writeUI8(0); - sos.writeUI8(frameRate); - sos.writeUI16(frameCount); - - sos.writeTags(tags); - sos.writeUI16(0); - sos.close(); - if (compressed && lzma) { - os.write('Z'); - } else if (compressed) { - os.write('C'); - } else { - os.write('F'); - } - os.write('W'); - os.write('S'); - os.write(version); - byte data[] = baos.toByteArray(); - sos = new SWFOutputStream(os, version); - sos.writeUI32(data.length + 8); - - if (compressed) { - if (lzma) { - Encoder enc = new Encoder(); - int val = lzmaProperties[0] & 0xFF; - int lc = val % 9; - int remainder = val / 9; - int lp = remainder % 5; - int pb = remainder / 5; - int dictionarySize = 0; - for (int i = 0; i < 4; i++) { - dictionarySize += ((int) (lzmaProperties[1 + i]) & 0xFF) << (i * 8); - } - enc.SetDictionarySize(dictionarySize); - enc.SetLcLpPb(lc, lp, pb); - baos = new ByteArrayOutputStream(); - enc.SetEndMarkerMode(true); - enc.Code(new ByteArrayInputStream(data), baos, -1, -1, null); - data = baos.toByteArray(); - byte udata[] = new byte[4]; - udata[0] = (byte) (data.length & 0xFF); - udata[1] = (byte) ((data.length >> 8) & 0xFF); - udata[2] = (byte) ((data.length >> 16) & 0xFF); - udata[3] = (byte) ((data.length >> 24) & 0xFF); - os.write(udata); - os.write(lzmaProperties); - } else { - os = new DeflaterOutputStream(os); + /** + * Gets all tags with specified id + * + * @param tagId Identificator of tag type + * @return List of tags + */ + public List getTagData(int tagId) { + List ret = new ArrayList(); + for (Tag tag : tags) { + if (tag.getId() == tagId) { + ret.add(tag); } - } - os.write(data); - } finally { - if (os != null) { - os.close(); - } - } + } + return ret; + } - } + /** + * Saves this SWF into new file + * + * @param os OutputStream to save SWF in + * @throws IOException + */ + public void saveTo(OutputStream os) throws IOException { + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + sos.writeRECT(displayRect); + sos.writeUI8(0); + sos.writeUI8(frameRate); + sos.writeUI16(frameCount); - public SWF(InputStream is) throws IOException { - this(is, null); - } + sos.writeTags(tags); + sos.writeUI16(0); + sos.close(); + if (compressed && lzma) { + os.write('Z'); + } else if (compressed) { + os.write('C'); + } else { + os.write('F'); + } + os.write('W'); + os.write('S'); + os.write(version); + byte data[] = baos.toByteArray(); + sos = new SWFOutputStream(os, version); + sos.writeUI32(data.length + 8); - /** - * Construct SWF from stream - * - * @param is Stream to read SWF from - * @throws IOException - */ - public SWF(InputStream is, PercentListener listener) throws IOException { - byte hdr[] = new byte[3]; - is.read(hdr); - String shdr = new String(hdr); - if ((!shdr.equals("FWS")) && (!shdr.equals("CWS")) && (!shdr.equals("ZWS"))) { - throw new IOException("Invalid SWF file"); - } - version = is.read(); - SWFInputStream sis = new SWFInputStream(is, version, 4); - fileSize = sis.readUI32(); + if (compressed) { + if (lzma) { + Encoder enc = new Encoder(); + int val = lzmaProperties[0] & 0xFF; + int lc = val % 9; + int remainder = val / 9; + int lp = remainder % 5; + int pb = remainder / 5; + int dictionarySize = 0; + for (int i = 0; i < 4; i++) { + dictionarySize += ((int) (lzmaProperties[1 + i]) & 0xFF) << (i * 8); + } + enc.SetDictionarySize(dictionarySize); + enc.SetLcLpPb(lc, lp, pb); + baos = new ByteArrayOutputStream(); + enc.SetEndMarkerMode(true); + enc.Code(new ByteArrayInputStream(data), baos, -1, -1, null); + data = baos.toByteArray(); + byte udata[] = new byte[4]; + udata[0] = (byte) (data.length & 0xFF); + udata[1] = (byte) ((data.length >> 8) & 0xFF); + udata[2] = (byte) ((data.length >> 16) & 0xFF); + udata[3] = (byte) ((data.length >> 24) & 0xFF); + os.write(udata); + os.write(lzmaProperties); + } else { + os = new DeflaterOutputStream(os); + } + } + os.write(data); + } finally { + if (os != null) { + os.close(); + } + } - if (hdr[0] == 'C') { - sis = new SWFInputStream(new InflaterInputStream(is), version, 8); - compressed = true; - } + } - if (hdr[0] == 'Z') { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - long outSize = sis.readUI32(); - int propertiesSize = 5; - lzmaProperties = new byte[propertiesSize]; - if (sis.read(lzmaProperties, 0, propertiesSize) != propertiesSize) { - throw new IOException("LZMA:input .lzma file is too short"); - } - SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(); - if (!decoder.SetDecoderProperties(lzmaProperties)) { - throw new IOException("LZMA:Incorrect stream properties"); - } + public SWF(InputStream is) throws IOException { + this(is, null); + } - if (!decoder.Code(sis, baos, fileSize - 8)) { - throw new IOException("LZMA:Error in data stream"); - } - sis = new SWFInputStream(new ByteArrayInputStream(baos.toByteArray()), version, 8); - compressed = true; - lzma = true; - } + /** + * Construct SWF from stream + * + * @param is Stream to read SWF from + * @throws IOException + */ + public SWF(InputStream is, PercentListener listener) throws IOException { + byte hdr[] = new byte[3]; + is.read(hdr); + String shdr = new String(hdr); + if ((!shdr.equals("FWS")) && (!shdr.equals("CWS")) && (!shdr.equals("ZWS"))) { + throw new IOException("Invalid SWF file"); + } + version = is.read(); + SWFInputStream sis = new SWFInputStream(is, version, 4); + fileSize = sis.readUI32(); + if (hdr[0] == 'C') { + sis = new SWFInputStream(new InflaterInputStream(is), version, 8); + compressed = true; + } - if (listener != null) { - sis.addPercentListener(listener); - } - sis.setPercentMax(fileSize); - displayRect = sis.readRECT(); - // FIXED8 (16 bit fixed point) frameRate - int tmpFirstByetOfFrameRate = sis.readUI8(); - frameRate = sis.readUI8(); - frameCount = sis.readUI16(); - tags = sis.readTagList(0); - } - - /** - * Compress SWF file - * - * @param fis Input stream - * @param fos Output stream - */ - public static boolean fws2cws(InputStream fis, OutputStream fos) { - try { - byte swfHead[] = new byte[8]; - fis.read(swfHead); - - if (swfHead[0] != 'F') { - fis.close(); - return false; - } - swfHead[0] = 'C'; - fos.write(swfHead); - fos = new DeflaterOutputStream(fos); - int i; - while ((i = fis.read()) != -1) { - fos.write(i); - } - - fis.close(); - fos.close(); - } catch (FileNotFoundException ex) { - return false; - } catch (IOException ex) { - return false; - } - return true; - } - - /** - * Decompress SWF file - * - * @param fis Input stream - * @param fos Output stream - */ - public static boolean cws2fws(InputStream fis, OutputStream fos) { - try { - byte swfHead[] = new byte[8]; - fis.read(swfHead); - InflaterInputStream iis = new InflaterInputStream(fis); - if (swfHead[0] != 'C') { - fis.close(); - return false; - } - swfHead[0] = 'F'; - fos.write(swfHead); - int i; - while ((i = iis.read()) != -1) { - fos.write(i); - } - - fis.close(); - fos.close(); - } catch (FileNotFoundException ex) { - return false; - } catch (IOException ex) { - return false; - } - return true; - } - - /** - * Decompress LZMA compressed SWF file - * - * @param fis Input stream - * @param fos Output stream - */ - public static boolean zws2fws(InputStream fis, OutputStream fos) { - try { - byte hdr[] = new byte[3]; - fis.read(hdr); - String shdr = new String(hdr); - if (!shdr.equals("ZWS")) { - return false; - } - int version = fis.read(); - SWFInputStream sis = new SWFInputStream(fis, version, 4); - long fileSize = sis.readUI32(); - - if (hdr[0] == 'Z') { + if (hdr[0] == 'Z') { ByteArrayOutputStream baos = new ByteArrayOutputStream(); long outSize = sis.readUI32(); int propertiesSize = 5; - byte lzmaProperties[] = new byte[propertiesSize]; + lzmaProperties = new byte[propertiesSize]; if (sis.read(lzmaProperties, 0, propertiesSize) != propertiesSize) { - throw new IOException("LZMA:input .lzma file is too short"); + throw new IOException("LZMA:input .lzma file is too short"); } SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(); if (!decoder.SetDecoderProperties(lzmaProperties)) { - throw new IOException("LZMA:Incorrect stream properties"); + throw new IOException("LZMA:Incorrect stream properties"); } if (!decoder.Code(sis, baos, fileSize - 8)) { - throw new IOException("LZMA:Error in data stream"); + throw new IOException("LZMA:Error in data stream"); } - SWFOutputStream sos = new SWFOutputStream(fos, version); - sos.write("FWS".getBytes()); - sos.write(version); - sos.writeUI32(fileSize); - sos.write(baos.toByteArray()); - sos.close(); - } else { + sis = new SWFInputStream(new ByteArrayInputStream(baos.toByteArray()), version, 8); + compressed = true; + lzma = true; + } + + + if (listener != null) { + sis.addPercentListener(listener); + } + sis.setPercentMax(fileSize); + displayRect = sis.readRECT(); + // FIXED8 (16 bit fixed point) frameRate + int tmpFirstByetOfFrameRate = sis.readUI8(); + frameRate = sis.readUI8(); + frameCount = sis.readUI16(); + tags = sis.readTagList(0); + } + + /** + * Compress SWF file + * + * @param fis Input stream + * @param fos Output stream + */ + public static boolean fws2cws(InputStream fis, OutputStream fos) { + try { + byte swfHead[] = new byte[8]; + fis.read(swfHead); + + if (swfHead[0] != 'F') { + fis.close(); + return false; + } + swfHead[0] = 'C'; + fos.write(swfHead); + fos = new DeflaterOutputStream(fos); + int i; + while ((i = fis.read()) != -1) { + fos.write(i); + } + + fis.close(); + fos.close(); + } catch (FileNotFoundException ex) { return false; - } - } catch (FileNotFoundException ex) { - return false; - } catch (IOException ex) { - return false; - } - return true; - } + } catch (IOException ex) { + return false; + } + return true; + } - public boolean exportActionScript(String outdir, boolean isPcode) throws Exception { - boolean asV3Found = false; - final EventListener evl = new EventListener() { - @Override - public void handleEvent(String event, Object data) { - if (event.equals("export")) { - informListeners(event, data); + /** + * Decompress SWF file + * + * @param fis Input stream + * @param fos Output stream + */ + public static boolean cws2fws(InputStream fis, OutputStream fos) { + try { + byte swfHead[] = new byte[8]; + fis.read(swfHead); + InflaterInputStream iis = new InflaterInputStream(fis); + if (swfHead[0] != 'C') { + fis.close(); + return false; + } + swfHead[0] = 'F'; + fos.write(swfHead); + int i; + while ((i = iis.read()) != -1) { + fos.write(i); } - } - }; - List abcTags = new ArrayList(); - for (Tag t : tags) { - if (t instanceof DoABCTag) { - abcTags.add((DoABCTag) t); - asV3Found = true; - } - } - for (int i = 0; i < abcTags.size(); i++) { - DoABCTag t = abcTags.get(i); - t.abc.addEventListener(evl); - t.abc.export(outdir, isPcode, abcTags, "tag " + (i + 1) + "/" + abcTags.size() + " "); - } - if (!asV3Found) { - List list2 = new ArrayList(); - list2.addAll(tags); - List list = createASTagList(list2, null); + fis.close(); + fos.close(); + } catch (FileNotFoundException ex) { + return false; + } catch (IOException ex) { + return false; + } + return true; + } - TagNode.setExport(list, true); - if (!outdir.endsWith(File.separator)) { - outdir += File.separator; - } - outdir += "scripts" + File.separator; - return TagNode.exportNodeAS(list, outdir, isPcode, evl); - } - return asV3Found; - } + /** + * Decompress LZMA compressed SWF file + * + * @param fis Input stream + * @param fos Output stream + */ + public static boolean zws2fws(InputStream fis, OutputStream fos) { + try { + byte hdr[] = new byte[3]; + fis.read(hdr); + String shdr = new String(hdr); + if (!shdr.equals("ZWS")) { + return false; + } + int version = fis.read(); + SWFInputStream sis = new SWFInputStream(fis, version, 4); + long fileSize = sis.readUI32(); - public static List createASTagList(List list, Object parent) { - List ret = new ArrayList(); - int frame = 1; - List frames = new ArrayList(); + if (hdr[0] == 'Z') { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + long outSize = sis.readUI32(); + int propertiesSize = 5; + byte lzmaProperties[] = new byte[propertiesSize]; + if (sis.read(lzmaProperties, 0, propertiesSize) != propertiesSize) { + throw new IOException("LZMA:input .lzma file is too short"); + } + SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder(); + if (!decoder.SetDecoderProperties(lzmaProperties)) { + throw new IOException("LZMA:Incorrect stream properties"); + } - List exportAssetsTags = new ArrayList(); - for (Object t : list) { - if (t instanceof ExportAssetsTag) { - exportAssetsTags.add((ExportAssetsTag) t); - } - if (t instanceof ShowFrameTag) { - TagNode tti = new TagNode(new FrameNode(frame, parent, false)); + if (!decoder.Code(sis, baos, fileSize - 8)) { + throw new IOException("LZMA:Error in data stream"); + } + SWFOutputStream sos = new SWFOutputStream(fos, version); + sos.write("FWS".getBytes()); + sos.write(version); + sos.writeUI32(fileSize); + sos.write(baos.toByteArray()); + sos.close(); + } else { + return false; + } + } catch (FileNotFoundException ex) { + return false; + } catch (IOException ex) { + return false; + } + return true; + } - for (int r = ret.size() - 1; r >= 0; r--) { - if (!(ret.get(r).tag instanceof DefineSpriteTag)) { - if (!(ret.get(r).tag instanceof DefineButtonTag)) { - if (!(ret.get(r).tag instanceof DefineButton2Tag)) { - if (!(ret.get(r).tag instanceof DoInitActionTag)) { - tti.subItems.add(ret.get(r)); - ret.remove(r); + public boolean exportActionScript(String outdir, boolean isPcode) throws Exception { + boolean asV3Found = false; + final EventListener evl = new EventListener() { + @Override + public void handleEvent(String event, Object data) { + if (event.equals("export")) { + informListeners(event, data); + } + } + }; + List abcTags = new ArrayList(); + for (Tag t : tags) { + if (t instanceof DoABCTag) { + abcTags.add((DoABCTag) t); + asV3Found = true; + } + } + for (int i = 0; i < abcTags.size(); i++) { + DoABCTag t = abcTags.get(i); + t.abc.addEventListener(evl); + t.abc.export(outdir, isPcode, abcTags, "tag " + (i + 1) + "/" + abcTags.size() + " "); + } + + if (!asV3Found) { + List list2 = new ArrayList(); + list2.addAll(tags); + List list = createASTagList(list2, null); + + TagNode.setExport(list, true); + if (!outdir.endsWith(File.separator)) { + outdir += File.separator; + } + outdir += "scripts" + File.separator; + return TagNode.exportNodeAS(list, outdir, isPcode, evl); + } + return asV3Found; + } + + public static List createASTagList(List list, Object parent) { + List ret = new ArrayList(); + int frame = 1; + List frames = new ArrayList(); + + List exportAssetsTags = new ArrayList(); + for (Object t : list) { + if (t instanceof ExportAssetsTag) { + exportAssetsTags.add((ExportAssetsTag) t); + } + if (t instanceof ShowFrameTag) { + TagNode tti = new TagNode(new FrameNode(frame, parent, false)); + + for (int r = ret.size() - 1; r >= 0; r--) { + if (!(ret.get(r).tag instanceof DefineSpriteTag)) { + if (!(ret.get(r).tag instanceof DefineButtonTag)) { + if (!(ret.get(r).tag instanceof DefineButton2Tag)) { + if (!(ret.get(r).tag instanceof DoInitActionTag)) { + tti.subItems.add(ret.get(r)); + ret.remove(r); + } + } } - } - } - } - } - frame++; - frames.add(tti); - } else if (t instanceof ASMSource) { - TagNode tti = new TagNode(t); - ret.add(tti); - } else if (t instanceof Container) { - if (((Container) t).getItemCount() > 0) { + } + } + frame++; + frames.add(tti); + } else if (t instanceof ASMSource) { + TagNode tti = new TagNode(t); + ret.add(tti); + } else if (t instanceof Container) { + if (((Container) t).getItemCount() > 0) { - TagNode tti = new TagNode(t); - List subItems = ((Container) t).getSubItems(); + TagNode tti = new TagNode(t); + List subItems = ((Container) t).getSubItems(); - tti.subItems = createASTagList(subItems, t); - ret.add(tti); - } - } - - } - ret.addAll(frames); - for (int i = ret.size() - 1; i >= 0; i--) { - if (ret.get(i).tag instanceof DefineSpriteTag) { - ((DefineSpriteTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; - } - if (ret.get(i).tag instanceof DefineButtonTag) { - ((DefineButtonTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; - } - if (ret.get(i).tag instanceof DefineButton2Tag) { - ((DefineButton2Tag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; - } - if (ret.get(i).tag instanceof DoInitActionTag) { - ((DoInitActionTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; - } - if (ret.get(i).tag instanceof ASMSource) { - ASMSource ass = (ASMSource) ret.get(i).tag; - if (ass.containsSource()) { - continue; - } - } - if (ret.get(i).subItems.isEmpty()) { - ret.remove(i); - } - } - return ret; - } - protected HashSet listeners = new HashSet(); - - public void addEventListener(EventListener listener) { - listeners.add(listener); - } - - public void removeEventListener(EventListener listener) { - listeners.remove(listener); - } - - protected void informListeners(String event, Object data) { - for (EventListener listener : listeners) { - listener.handleEvent(event, data); - } - } - - private static String getImageFormat(byte data[]) { - if (hasErrorHeader(data)) { - return "jpg"; - } - if (data.length > 2 && ((data[0] & 0xff) == 0xff) && ((data[1] & 0xff) == 0xd8)) { - return "jpg"; - } - if (data.length > 6 && ((data[0] & 0xff) == 0x47) && ((data[1] & 0xff) == 0x49) && ((data[2] & 0xff) == 0x46) && ((data[3] & 0xff) == 0x38) && ((data[4] & 0xff) == 0x39) && ((data[5] & 0xff) == 0x61)) { - return "gif"; - } - - if (data.length > 8 && ((data[0] & 0xff) == 0x89) && ((data[1] & 0xff) == 0x50) && ((data[2] & 0xff) == 0x4e) && ((data[3] & 0xff) == 0x47) && ((data[4] & 0xff) == 0x0d) && ((data[5] & 0xff) == 0x0a) && ((data[6] & 0xff) == 0x1a) && ((data[7] & 0xff) == 0x0a)) { - return "png"; - } - - return "unk"; - } - - public static boolean hasErrorHeader(byte data[]) { - if (data.length > 4) { - if ((data[0] & 0xff) == 0xff) { - if ((data[1] & 0xff) == 0xd9) { - if ((data[2] & 0xff) == 0xff) { - if ((data[3] & 0xff) == 0xd8) { - return true; - } - } - } - } - } - return false; - } - - public static void populateSoundStreamBlocks(List tags, Tag head, List output) { - boolean found = false; - for (Object t : tags) { - if (t == head) { - found = true; - continue; - } - if (!found) { - continue; - } - if (t instanceof SoundStreamBlockTag) { - output.add((SoundStreamBlockTag) t); - } - if (t instanceof SoundStreamHeadTypeTag) { - break; - } - if (t instanceof Container) { - populateSoundStreamBlocks(((Container) t).getSubItems(), head, output); - } - } - } - - public void populateVideoFrames(int streamId, List tags, HashMap output) { - for (Object t : tags) { - if (t instanceof VideoFrameTag) { - output.put(((VideoFrameTag) t).frameNum, (VideoFrameTag) t); - } - if (t instanceof Container) { - populateVideoFrames(streamId, ((Container) t).getSubItems(), output); - } - } - } - - public void exportMovies(String outdir) throws IOException { - exportMovies(outdir, tags); - } - - public void exportSounds(String outdir, boolean mp3) throws IOException { - exportSounds(outdir, tags, mp3); - } - - public void exportSounds(String outdir, List tags, boolean mp3) throws IOException { - if (tags.isEmpty()) { - return; - } - if (!(new File(outdir)).exists()) { - (new File(outdir)).mkdirs(); - } - List os = new ArrayList(this.tags); - for (Tag t : tags) { - FileOutputStream fos = null; - try { - int id = 0; - if (t instanceof DefineSoundTag) { - id = ((DefineSoundTag) t).soundId; - } - if (mp3) { + tti.subItems = createASTagList(subItems, t); + ret.add(tti); + } } - if (t instanceof DefineSoundTag) { - DefineSoundTag st = (DefineSoundTag) t; - if ((st.soundFormat == 2) && mp3) { - fos = new FileOutputStream(outdir + File.separator + id + ".mp3"); - fos.write(st.soundData); - } else { - fos = new FileOutputStream(outdir + File.separator + id + ".flv"); - FLVOutputStream flv = new FLVOutputStream(fos); - flv.writeHeader(true, false); - flv.writeTag(new FLVTAG(0, new AUDIODATA(st.soundFormat, st.soundRate, st.soundSize, st.soundType, st.soundData))); - } + } + ret.addAll(frames); + for (int i = ret.size() - 1; i >= 0; i--) { + if (ret.get(i).tag instanceof DefineSpriteTag) { + ((DefineSpriteTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).tag instanceof DefineButtonTag) { + ((DefineButtonTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).tag instanceof DefineButton2Tag) { + ((DefineButton2Tag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).tag instanceof DoInitActionTag) { + ((DoInitActionTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).tag instanceof ASMSource) { + ASMSource ass = (ASMSource) ret.get(i).tag; + if (ass.containsSource()) { + continue; + } + } + if (ret.get(i).subItems.isEmpty()) { + ret.remove(i); + } + } + return ret; + } + protected HashSet listeners = new HashSet(); + + public void addEventListener(EventListener listener) { + listeners.add(listener); + } + + public void removeEventListener(EventListener listener) { + listeners.remove(listener); + } + + protected void informListeners(String event, Object data) { + for (EventListener listener : listeners) { + listener.handleEvent(event, data); + } + } + + private static String getImageFormat(byte data[]) { + if (hasErrorHeader(data)) { + return "jpg"; + } + if (data.length > 2 && ((data[0] & 0xff) == 0xff) && ((data[1] & 0xff) == 0xd8)) { + return "jpg"; + } + if (data.length > 6 && ((data[0] & 0xff) == 0x47) && ((data[1] & 0xff) == 0x49) && ((data[2] & 0xff) == 0x46) && ((data[3] & 0xff) == 0x38) && ((data[4] & 0xff) == 0x39) && ((data[5] & 0xff) == 0x61)) { + return "gif"; + } + + if (data.length > 8 && ((data[0] & 0xff) == 0x89) && ((data[1] & 0xff) == 0x50) && ((data[2] & 0xff) == 0x4e) && ((data[3] & 0xff) == 0x47) && ((data[4] & 0xff) == 0x0d) && ((data[5] & 0xff) == 0x0a) && ((data[6] & 0xff) == 0x1a) && ((data[7] & 0xff) == 0x0a)) { + return "png"; + } + + return "unk"; + } + + public static boolean hasErrorHeader(byte data[]) { + if (data.length > 4) { + if ((data[0] & 0xff) == 0xff) { + if ((data[1] & 0xff) == 0xd9) { + if ((data[2] & 0xff) == 0xff) { + if ((data[3] & 0xff) == 0xd8) { + return true; + } + } + } + } + } + return false; + } + + public static void populateSoundStreamBlocks(List tags, Tag head, List output) { + boolean found = false; + for (Object t : tags) { + if (t == head) { + found = true; + continue; + } + if (!found) { + continue; + } + if (t instanceof SoundStreamBlockTag) { + output.add((SoundStreamBlockTag) t); } if (t instanceof SoundStreamHeadTypeTag) { - SoundStreamHeadTypeTag shead = (SoundStreamHeadTypeTag) t; - List blocks = new ArrayList(); - List objs = new ArrayList(this.tags); - populateSoundStreamBlocks(objs, t, blocks); - if ((shead.getSoundFormat() == 2) && mp3) { - fos = new FileOutputStream(outdir + File.separator + id + ".mp3"); - for (int b = 0; b < blocks.size(); b++) { - byte data[] = blocks.get(b).getData(SWF.DEFAULT_VERSION); - fos.write(data, 4, data.length - 4); - } - } else { - fos = new FileOutputStream(outdir + File.separator + id + ".flv"); - FLVOutputStream flv = new FLVOutputStream(fos); - flv.writeHeader(true, false); - - int ms = (int) (1000.0f / ((float) frameRate)); - for (int b = 0; b < blocks.size(); b++) { - byte data[] = blocks.get(b).getData(SWF.DEFAULT_VERSION); - if (shead.getSoundFormat() == 2) { //MP3 - data = Arrays.copyOfRange(data, 4, data.length); - } - flv.writeTag(new FLVTAG(ms * b, new AUDIODATA(shead.getSoundFormat(), shead.getSoundRate(), shead.getSoundSize(), shead.getSoundType(), data))); - } - } + break; } - } finally { - if (fos != null) { - try { - fos.close(); - } catch (Exception ex) { - //ignore - } + if (t instanceof Container) { + populateSoundStreamBlocks(((Container) t).getSubItems(), head, output); } - } + } + } - } - } + public void populateVideoFrames(int streamId, List tags, HashMap output) { + for (Object t : tags) { + if (t instanceof VideoFrameTag) { + output.put(((VideoFrameTag) t).frameNum, (VideoFrameTag) t); + } + if (t instanceof Container) { + populateVideoFrames(streamId, ((Container) t).getSubItems(), output); + } + } + } - public void exportMovies(String outdir, List tags) throws IOException { - if (tags.isEmpty()) { - return; - } - if (!(new File(outdir)).exists()) { - (new File(outdir)).mkdirs(); - } - List os = new ArrayList(this.tags); - for (Tag t : tags) { - if (t instanceof DefineVideoStreamTag) { - DefineVideoStreamTag videoStream = (DefineVideoStreamTag) t; - HashMap frames = new HashMap(); - populateVideoFrames(videoStream.characterID, os, frames); + public void exportMovies(String outdir) throws IOException { + exportMovies(outdir, tags); + } + public void exportSounds(String outdir, boolean mp3) throws IOException { + exportSounds(outdir, tags, mp3); + } + + public void exportSounds(String outdir, List tags, boolean mp3) throws IOException { + if (tags.isEmpty()) { + return; + } + if (!(new File(outdir)).exists()) { + (new File(outdir)).mkdirs(); + } + List os = new ArrayList(this.tags); + for (Tag t : tags) { FileOutputStream fos = null; try { - fos = new FileOutputStream(outdir + File.separator + ((DefineVideoStreamTag) t).characterID + ".flv"); - FLVOutputStream flv = new FLVOutputStream(fos); - flv.writeHeader(false, true); - int ms = (int) (1000.0f / ((float) frameRate)); - for (int i = 0; i < frames.size(); i++) { - VideoFrameTag tag = frames.get(i); - int frameType = 0; - if (videoStream.codecID == 2) { //H263 - SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(tag.videoData), SWF.DEFAULT_VERSION); - sis.readUB(17);//pictureStartCode - sis.readUB(5); //version - sis.readUB(8); //temporalReference - int pictureSize = (int) sis.readUB(3); //pictureSize - if (pictureSize == 0) { - sis.readUB(8); //customWidth - sis.readUB(8); //customHeight - } - if (pictureSize == 1) { - sis.readUB(16); //customWidth - sis.readUB(16); //customHeight - } - int pictureType = (int) sis.readUB(2); - switch (pictureType) { - case 0: //intra - frameType = 1; //keyframe - break; - case 1://inter - frameType = 2; - break; - case 2: //disposable - frameType = 3; - break; - } - } - flv.writeTag(new FLVTAG(i * ms, new VIDEODATA(frameType, videoStream.codecID, tag.videoData))); - } + int id = 0; + if (t instanceof DefineSoundTag) { + id = ((DefineSoundTag) t).soundId; + } + if (mp3) { + } + if (t instanceof DefineSoundTag) { + DefineSoundTag st = (DefineSoundTag) t; + if ((st.soundFormat == 2) && mp3) { + fos = new FileOutputStream(outdir + File.separator + id + ".mp3"); + fos.write(st.soundData); + } else { + fos = new FileOutputStream(outdir + File.separator + id + ".flv"); + FLVOutputStream flv = new FLVOutputStream(fos); + flv.writeHeader(true, false); + flv.writeTag(new FLVTAG(0, new AUDIODATA(st.soundFormat, st.soundRate, st.soundSize, st.soundType, st.soundData))); + } + } + if (t instanceof SoundStreamHeadTypeTag) { + SoundStreamHeadTypeTag shead = (SoundStreamHeadTypeTag) t; + List blocks = new ArrayList(); + List objs = new ArrayList(this.tags); + populateSoundStreamBlocks(objs, t, blocks); + if ((shead.getSoundFormat() == 2) && mp3) { + fos = new FileOutputStream(outdir + File.separator + id + ".mp3"); + for (int b = 0; b < blocks.size(); b++) { + byte data[] = blocks.get(b).getData(SWF.DEFAULT_VERSION); + fos.write(data, 4, data.length - 4); + } + } else { + fos = new FileOutputStream(outdir + File.separator + id + ".flv"); + FLVOutputStream flv = new FLVOutputStream(fos); + flv.writeHeader(true, false); + int ms = (int) (1000.0f / ((float) frameRate)); + for (int b = 0; b < blocks.size(); b++) { + byte data[] = blocks.get(b).getData(SWF.DEFAULT_VERSION); + if (shead.getSoundFormat() == 2) { //MP3 + data = Arrays.copyOfRange(data, 4, data.length); + } + flv.writeTag(new FLVTAG(ms * b, new AUDIODATA(shead.getSoundFormat(), shead.getSoundRate(), shead.getSoundSize(), shead.getSoundType(), data))); + } + } + } } finally { - if (fos != null) { - try { - fos.close(); - } catch (Exception ex) { - //ignore - } - } - } - } - } - } - - public static void exportShapes(String outdir, List tags) throws IOException { - if (tags.isEmpty()) { - return; - } - if (!(new File(outdir)).exists()) { - (new File(outdir)).mkdirs(); - } - for (Tag t : tags) { - if (t instanceof ShapeTag) { - int characterID = 0; - if (t instanceof CharacterTag) { - characterID = ((CharacterTag) t).getCharacterID(); - } - FileOutputStream fos = null; - try { - fos = new FileOutputStream(outdir + File.separator + characterID + ".svg"); - fos.write(((ShapeTag) t).toSVG().getBytes()); - } finally { - if (fos != null) { - try { - fos.close(); - } catch (Exception ex) { - //ignore - } - } - } - } - } - } - - public static void exportImages(String outdir, List tags, JPEGTablesTag jtt) throws IOException { - if (tags.isEmpty()) { - return; - } - if (!(new File(outdir)).exists()) { - (new File(outdir)).mkdirs(); - } - for (Tag t : tags) { - if ((t instanceof DefineBitsJPEG2Tag) || (t instanceof DefineBitsJPEG3Tag) || (t instanceof DefineBitsJPEG4Tag)) { - byte imageData[] = null; - int characterID = 0; - if (t instanceof DefineBitsJPEG2Tag) { - imageData = ((DefineBitsJPEG2Tag) t).imageData; - characterID = ((DefineBitsJPEG2Tag) t).characterID; - } - if (t instanceof DefineBitsJPEG3Tag) { - imageData = ((DefineBitsJPEG3Tag) t).imageData; - characterID = ((DefineBitsJPEG3Tag) t).characterID; - } - if (t instanceof DefineBitsJPEG4Tag) { - imageData = ((DefineBitsJPEG4Tag) t).imageData; - characterID = ((DefineBitsJPEG4Tag) t).characterID; + if (fos != null) { + try { + fos.close(); + } catch (Exception ex) { + //ignore + } + } } - FileOutputStream fos = null; - try { - fos = new FileOutputStream(outdir + File.separator + characterID + "." + getImageFormat(imageData)); - if (hasErrorHeader(imageData)) { - fos.write(imageData, 4, imageData.length - 4); - } else { - fos.write(imageData); - } - } finally { - if (fos != null) { - try { - fos.close(); - } catch (Exception ex) { - //ignore - } - } + } + } + + public void exportMovies(String outdir, List tags) throws IOException { + if (tags.isEmpty()) { + return; + } + if (!(new File(outdir)).exists()) { + (new File(outdir)).mkdirs(); + } + List os = new ArrayList(this.tags); + for (Tag t : tags) { + if (t instanceof DefineVideoStreamTag) { + DefineVideoStreamTag videoStream = (DefineVideoStreamTag) t; + HashMap frames = new HashMap(); + populateVideoFrames(videoStream.characterID, os, frames); + + FileOutputStream fos = null; + try { + fos = new FileOutputStream(outdir + File.separator + ((DefineVideoStreamTag) t).characterID + ".flv"); + FLVOutputStream flv = new FLVOutputStream(fos); + flv.writeHeader(false, true); + int ms = (int) (1000.0f / ((float) frameRate)); + for (int i = 0; i < frames.size(); i++) { + VideoFrameTag tag = frames.get(i); + int frameType = 0; + if (videoStream.codecID == 2) { //H263 + SWFInputStream sis = new SWFInputStream(new ByteArrayInputStream(tag.videoData), SWF.DEFAULT_VERSION); + sis.readUB(17);//pictureStartCode + sis.readUB(5); //version + sis.readUB(8); //temporalReference + int pictureSize = (int) sis.readUB(3); //pictureSize + if (pictureSize == 0) { + sis.readUB(8); //customWidth + sis.readUB(8); //customHeight + } + if (pictureSize == 1) { + sis.readUB(16); //customWidth + sis.readUB(16); //customHeight + } + int pictureType = (int) sis.readUB(2); + switch (pictureType) { + case 0: //intra + frameType = 1; //keyframe + break; + case 1://inter + frameType = 2; + break; + case 2: //disposable + frameType = 3; + break; + } + } + flv.writeTag(new FLVTAG(i * ms, new VIDEODATA(frameType, videoStream.codecID, tag.videoData))); + } + + + } finally { + if (fos != null) { + try { + fos.close(); + } catch (Exception ex) { + //ignore + } + } + } } - } - if (t instanceof DefineBitsLosslessTag) { - DefineBitsLosslessTag dbl = (DefineBitsLosslessTag) t; - ImageIO.write(dbl.getImage(), "PNG", new File(outdir + File.separator + dbl.characterID + ".png")); - } - if (t instanceof DefineBitsLossless2Tag) { - DefineBitsLossless2Tag dbl = (DefineBitsLossless2Tag) t; + } + } - ImageIO.write(dbl.getImage(), "PNG", new File(outdir + File.separator + dbl.characterID + ".png")); - } - if ((jtt != null) && (t instanceof DefineBitsTag)) { - DefineBitsTag dbt = (DefineBitsTag) t; - FileOutputStream fos = null; - try { - fos = new FileOutputStream(outdir + File.separator + dbt.characterID + ".jpg"); - fos.write(dbt.getFullImageData(jtt)); - } finally { - if (fos != null) { - try { - fos.close(); - } catch (Exception ex) { - //ignore - } - } + public static void exportShapes(String outdir, List tags) throws IOException { + if (tags.isEmpty()) { + return; + } + if (!(new File(outdir)).exists()) { + (new File(outdir)).mkdirs(); + } + for (Tag t : tags) { + if (t instanceof ShapeTag) { + int characterID = 0; + if (t instanceof CharacterTag) { + characterID = ((CharacterTag) t).getCharacterID(); + } + FileOutputStream fos = null; + try { + fos = new FileOutputStream(outdir + File.separator + characterID + ".svg"); + fos.write(((ShapeTag) t).toSVG().getBytes()); + } finally { + if (fos != null) { + try { + fos.close(); + } catch (Exception ex) { + //ignore + } + } + } } - } - } - } + } + } - public void exportImages(String outdir) throws IOException { - JPEGTablesTag jtt = null; - for (Tag t : tags) { - if (t instanceof JPEGTablesTag) { - jtt = (JPEGTablesTag) t; - } - } - exportImages(outdir, tags, jtt); - } + public static void exportImages(String outdir, List tags, JPEGTablesTag jtt) throws IOException { + if (tags.isEmpty()) { + return; + } + if (!(new File(outdir)).exists()) { + (new File(outdir)).mkdirs(); + } + for (Tag t : tags) { + if ((t instanceof DefineBitsJPEG2Tag) || (t instanceof DefineBitsJPEG3Tag) || (t instanceof DefineBitsJPEG4Tag)) { + byte imageData[] = null; + int characterID = 0; + if (t instanceof DefineBitsJPEG2Tag) { + imageData = ((DefineBitsJPEG2Tag) t).imageData; + characterID = ((DefineBitsJPEG2Tag) t).characterID; + } + if (t instanceof DefineBitsJPEG3Tag) { + imageData = ((DefineBitsJPEG3Tag) t).imageData; + characterID = ((DefineBitsJPEG3Tag) t).characterID; + } + if (t instanceof DefineBitsJPEG4Tag) { + imageData = ((DefineBitsJPEG4Tag) t).imageData; + characterID = ((DefineBitsJPEG4Tag) t).characterID; + } - public void exportShapes(String outdir) throws IOException { - exportShapes(outdir, tags); - } - public static final String[] reservedWords = { - "as", "break", "case", "catch", "class", "const", "continue", "default", "delete", "do", "each", "else", - "extends", "false", "finally", "for", "function", "get", "if", "implements", "import", "in", "instanceof", - "interface", "internal", "is", "native", "new", "null", "override", "package", "private", "protected", "public", - "return", "set", "super", "switch", "this", "throw", "true", "try", "typeof", "use", "var", /*"void",*/ "while", - "with", "dynamic", "default", "final", "in"}; - - private boolean isReserved(String s) { - for (String rw : reservedWords) { - if (rw.equals(s.trim())) { - return true; - } - } - return false; - } - private HashMap deobfuscated = new HashMap(); - private Random rnd = new Random(); - private final int DEFAULT_FOO_SIZE = 10; - public static final String validFirstCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; - public static final String validNextCharacters = validFirstCharacters + "0123456789"; - public static final String fooCharacters = "bcdfghjklmnpqrstvwz"; - public static final String fooJoinCharacters = "aeiouy"; - private HashMap allVariableNames = new HashMap(); - private HashSet allVariableNamesStr = new HashSet(); - private List allFunctions = new ArrayList(); - - private String fooString(String orig, boolean firstUppercase, int rndSize) { - boolean exists; - String ret; - loopfoo: - do { - exists = false; - int len = 3 + rnd.nextInt(rndSize - 3); - ret = ""; - for (int i = 0; i < len; i++) { - String c = ""; - if ((i % 2) == 0) { - c = "" + fooCharacters.charAt(rnd.nextInt(fooCharacters.length())); - } else { - c = "" + fooJoinCharacters.charAt(rnd.nextInt(fooJoinCharacters.length())); + FileOutputStream fos = null; + try { + fos = new FileOutputStream(outdir + File.separator + characterID + "." + getImageFormat(imageData)); + if (hasErrorHeader(imageData)) { + fos.write(imageData, 4, imageData.length - 4); + } else { + fos.write(imageData); + } + } finally { + if (fos != null) { + try { + fos.close(); + } catch (Exception ex) { + //ignore + } + } + } } - if (i == 0 && firstUppercase) { - c = c.toUpperCase(); + if (t instanceof DefineBitsLosslessTag) { + DefineBitsLosslessTag dbl = (DefineBitsLosslessTag) t; + ImageIO.write(dbl.getImage(), "PNG", new File(outdir + File.separator + dbl.characterID + ".png")); } - ret += c; - } - if (allVariableNamesStr.contains(ret)) { - exists = true; - rndSize = rndSize + 1; - continue loopfoo; - } - if (isReserved(ret)) { - exists = true; - rndSize = rndSize + 1; - continue; - } - if (deobfuscated.containsValue(ret)) { - exists = true; - rndSize = rndSize + 1; - continue; - } - } while (exists); - deobfuscated.put(orig, ret); - return ret; - } + if (t instanceof DefineBitsLossless2Tag) { + DefineBitsLossless2Tag dbl = (DefineBitsLossless2Tag) t; - public String deobfuscateName(HashMap namesMap, String s, boolean firstUppercase) { - boolean isValid = true; - if (isReserved(s)) { - isValid = false; - } - - if (isValid) { - for (int i = 0; i < s.length(); i++) { - if (s.charAt(i) > 127) { - isValid = false; - break; + ImageIO.write(dbl.getImage(), "PNG", new File(outdir + File.separator + dbl.characterID + ".png")); } - } - } + if ((jtt != null) && (t instanceof DefineBitsTag)) { + DefineBitsTag dbt = (DefineBitsTag) t; + FileOutputStream fos = null; + try { + fos = new FileOutputStream(outdir + File.separator + dbt.characterID + ".jpg"); + fos.write(dbt.getFullImageData(jtt)); + } finally { + if (fos != null) { + try { + fos.close(); + } catch (Exception ex) { + //ignore + } + } + } + } + } + } - if (isValid) { - Pattern pat = Pattern.compile("^[" + Pattern.quote(validFirstCharacters) + "]" + "[" + Pattern.quote(validFirstCharacters + validNextCharacters) + "]*$"); - if (!pat.matcher(s).matches()) { + public void exportImages(String outdir) throws IOException { + JPEGTablesTag jtt = null; + for (Tag t : tags) { + if (t instanceof JPEGTablesTag) { + jtt = (JPEGTablesTag) t; + } + } + exportImages(outdir, tags, jtt); + } + + public void exportShapes(String outdir) throws IOException { + exportShapes(outdir, tags); + } + public static final String[] reservedWords = { + "as", "break", "case", "catch", "class", "const", "continue", "default", "delete", "do", "each", "else", + "extends", "false", "finally", "for", "function", "get", "if", "implements", "import", "in", "instanceof", + "interface", "internal", "is", "native", "new", "null", "override", "package", "private", "protected", "public", + "return", "set", "super", "switch", "this", "throw", "true", "try", "typeof", "use", "var", /*"void",*/ "while", + "with", "dynamic", "default", "final", "in"}; + + private boolean isReserved(String s) { + for (String rw : reservedWords) { + if (rw.equals(s.trim())) { + return true; + } + } + return false; + } + private HashMap deobfuscated = new HashMap(); + private Random rnd = new Random(); + private final int DEFAULT_FOO_SIZE = 10; + public static final String validFirstCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; + public static final String validNextCharacters = validFirstCharacters + "0123456789"; + public static final String fooCharacters = "bcdfghjklmnpqrstvwz"; + public static final String fooJoinCharacters = "aeiouy"; + private HashMap allVariableNames = new HashMap(); + private HashSet allVariableNamesStr = new HashSet(); + private List allFunctions = new ArrayList(); + + private String fooString(String orig, boolean firstUppercase, int rndSize) { + boolean exists; + String ret; + loopfoo: + do { + exists = false; + int len = 3 + rnd.nextInt(rndSize - 3); + ret = ""; + for (int i = 0; i < len; i++) { + String c = ""; + if ((i % 2) == 0) { + c = "" + fooCharacters.charAt(rnd.nextInt(fooCharacters.length())); + } else { + c = "" + fooJoinCharacters.charAt(rnd.nextInt(fooJoinCharacters.length())); + } + if (i == 0 && firstUppercase) { + c = c.toUpperCase(); + } + ret += c; + } + if (allVariableNamesStr.contains(ret)) { + exists = true; + rndSize = rndSize + 1; + continue loopfoo; + } + if (isReserved(ret)) { + exists = true; + rndSize = rndSize + 1; + continue; + } + if (deobfuscated.containsValue(ret)) { + exists = true; + rndSize = rndSize + 1; + continue; + } + } while (exists); + deobfuscated.put(orig, ret); + return ret; + } + + public String deobfuscateName(HashMap namesMap, String s, boolean firstUppercase) { + boolean isValid = true; + if (isReserved(s)) { isValid = false; - } - } + } - if (!isValid) { - if (namesMap.containsKey(s)) { - return namesMap.get(s); - } else { - String ret = fooString(s, firstUppercase, DEFAULT_FOO_SIZE); - return ret; - } - } - return null; - } - - private static void getVariables(ConstantPool constantPool, List localData, Stack stack, List output, ActionGraphSource code, int ip, int lastIp, HashMap variables, List functions, List visited) { - boolean debugMode = false; - while ((ip > -1) && ip < code.size()) { - if (visited.contains(ip)) { - break; - } - - lastIp = ip; - GraphSourceItem ins = code.get(ip); - if (debugMode) { - System.out.println("Visit " + ip + ": " + ins + " stack:" + Highlighting.stripHilights(stack.toString())); - } - - GraphTargetItem name = null; - if ((ins instanceof ActionGetVariable) - || (ins instanceof ActionGetMember) - || (ins instanceof ActionDefineLocal2) - || (ins instanceof ActionNewMethod) - || (ins instanceof ActionNewObject) - || (ins instanceof ActionCallMethod) - || (ins instanceof ActionCallFunction)) { - name = stack.peek(); - } - - - if ((ins instanceof ActionDefineFunction) || (ins instanceof ActionDefineFunction2)) { - functions.add(ins); - } - - if (ins instanceof ActionContainer) { - getVariables(variables, functions, new ActionGraphSource(((ActionContainer) ins).getActions(), code.version, new HashMap(), new HashMap(), new HashMap()), 0); - } - - if ((ins instanceof ActionSetVariable) || (ins instanceof ActionSetMember) || (ins instanceof ActionDefineLocal)) { - name = stack.get(stack.size() - 2); - } - if (name instanceof DirectValueTreeItem) { - variables.put((DirectValueTreeItem) name, constantPool); - } - - //for..in return - if (((ins instanceof ActionEquals) || (ins instanceof ActionEquals2)) && (stack.size() == 1) && (stack.peek() instanceof DirectValueTreeItem)) { - stack.push(new DirectValueTreeItem(null, 0, new Null(), new ArrayList())); - } - - if (ins instanceof ActionConstantPool) { - constantPool = new ConstantPool(((ActionConstantPool) ins).constantPool); - } - - try { - ins.translate(localData, stack, output); - } catch (Exception ex) { - Logger.getLogger(SWF.class.getName()).log(Level.SEVERE, "Error during getting variables", ex); - } - if (ins.isExit()) { - break; - } - - if (ins.isBranch() || ins.isJump()) { - if (ins instanceof ActionIf) { - stack.pop(); + if (isValid) { + for (int i = 0; i < s.length(); i++) { + if (s.charAt(i) > 127) { + isValid = false; + break; + } } - visited.add(ip); - List branches = ins.getBranches(code); - for (int b : branches) { - Stack brStack = (Stack) stack.clone(); - if (b >= 0) { - getVariables(constantPool, localData, brStack, output, code, b, ip, variables, functions, visited); - } else { - if (debugMode) { - System.out.println("Negative branch:" + b); - } - } + } + + if (isValid) { + Pattern pat = Pattern.compile("^[" + Pattern.quote(validFirstCharacters) + "]" + "[" + Pattern.quote(validFirstCharacters + validNextCharacters) + "]*$"); + if (!pat.matcher(s).matches()) { + isValid = false; + } + } + + if (!isValid) { + if (namesMap.containsKey(s)) { + return namesMap.get(s); + } else { + String ret = fooString(s, firstUppercase, DEFAULT_FOO_SIZE); + return ret; + } + } + return null; + } + + private static void getVariables(ConstantPool constantPool, List localData, Stack stack, List output, ActionGraphSource code, int ip, int lastIp, HashMap variables, List functions, List visited) { + boolean debugMode = false; + while ((ip > -1) && ip < code.size()) { + if (visited.contains(ip)) { + break; } - break; - } - ip++; - }; - } + lastIp = ip; + GraphSourceItem ins = code.get(ip); + if (debugMode) { + System.out.println("Visit " + ip + ": " + ins + " stack:" + Highlighting.stripHilights(stack.toString())); + } - private static void getVariables(HashMap variables, List functions, ActionGraphSource code, int addr) { - List localData = Helper.toList(new HashMap(), new HashMap(), new HashMap()); - try { - getVariables(null, localData, new Stack(), new ArrayList(), code, code.adr2pos(addr), 0, variables, functions, new ArrayList()); - } catch (Exception ex) { - Logger.getLogger(SWF.class.getName()).log(Level.SEVERE, "Getting variables error", ex); - } - } + GraphTargetItem name = null; + if ((ins instanceof ActionGetVariable) + || (ins instanceof ActionGetMember) + || (ins instanceof ActionDefineLocal2) + || (ins instanceof ActionNewMethod) + || (ins instanceof ActionNewObject) + || (ins instanceof ActionCallMethod) + || (ins instanceof ActionCallFunction)) { + name = stack.peek(); + } - private HashMap getVariables(HashMap variables, List functions, ASMSource src) { - HashMap ret = new HashMap(); - List actions = src.getActions(version); - actionsMap.put(src, actions); - getVariables(variables, functions, new ActionGraphSource(actions, version, new HashMap(), new HashMap(), new HashMap()), 0); - return ret; - } - private HashMap> actionsMap = new HashMap>(); - private void getVariables(List objs) { - for (Object o : objs) { - if (o instanceof ASMSource) { - getVariables(allVariableNames, allFunctions, (ASMSource) o); - } - if (o instanceof Container) { - getVariables(((Container) o).getSubItems()); - } - } - } + if ((ins instanceof ActionDefineFunction) || (ins instanceof ActionDefineFunction2)) { + functions.add(ins); + } - public int deobfuscateAS2Identifiers() { - actionsMap = new HashMap>(); - allFunctions = new ArrayList(); - allVariableNames = new HashMap(); - List objs = new ArrayList(); - int ret = 0; - objs.addAll(tags); - getVariables(objs); - for (GraphSourceItem fun : allFunctions) { - if (fun instanceof ActionDefineFunction) { - ActionDefineFunction f = (ActionDefineFunction) fun; - String changed = deobfuscateName(deobfuscated, f.functionName, false); + if (ins instanceof ActionContainer) { + getVariables(variables, functions, new ActionGraphSource(((ActionContainer) ins).getActions(), code.version, new HashMap(), new HashMap(), new HashMap()), 0); + } + + if ((ins instanceof ActionSetVariable) || (ins instanceof ActionSetMember) || (ins instanceof ActionDefineLocal)) { + name = stack.get(stack.size() - 2); + } + if (name instanceof DirectValueTreeItem) { + variables.put((DirectValueTreeItem) name, constantPool); + } + + //for..in return + if (((ins instanceof ActionEquals) || (ins instanceof ActionEquals2)) && (stack.size() == 1) && (stack.peek() instanceof DirectValueTreeItem)) { + stack.push(new DirectValueTreeItem(null, 0, new Null(), new ArrayList())); + } + + if (ins instanceof ActionConstantPool) { + constantPool = new ConstantPool(((ActionConstantPool) ins).constantPool); + } + + try { + ins.translate(localData, stack, output); + } catch (Exception ex) { + Logger.getLogger(SWF.class.getName()).log(Level.SEVERE, "Error during getting variables", ex); + } + if (ins.isExit()) { + break; + } + + if (ins.isBranch() || ins.isJump()) { + if (ins instanceof ActionIf) { + stack.pop(); + } + visited.add(ip); + List branches = ins.getBranches(code); + for (int b : branches) { + Stack brStack = (Stack) stack.clone(); + if (b >= 0) { + getVariables(constantPool, localData, brStack, output, code, b, ip, variables, functions, visited); + } else { + if (debugMode) { + System.out.println("Negative branch:" + b); + } + } + } + + break; + } + ip++; + }; + } + + private static void getVariables(HashMap variables, List functions, ActionGraphSource code, int addr) { + List localData = Helper.toList(new HashMap(), new HashMap(), new HashMap()); + try { + getVariables(null, localData, new Stack(), new ArrayList(), code, code.adr2pos(addr), 0, variables, functions, new ArrayList()); + } catch (Exception ex) { + Logger.getLogger(SWF.class.getName()).log(Level.SEVERE, "Getting variables error", ex); + } + } + + private HashMap getVariables(HashMap variables, List functions, ASMSource src) { + HashMap ret = new HashMap(); + List actions = src.getActions(version); + actionsMap.put(src, actions); + getVariables(variables, functions, new ActionGraphSource(actions, version, new HashMap(), new HashMap(), new HashMap()), 0); + return ret; + } + private HashMap> actionsMap = new HashMap>(); + + private void getVariables(List objs) { + for (Object o : objs) { + if (o instanceof ASMSource) { + getVariables(allVariableNames, allFunctions, (ASMSource) o); + } + if (o instanceof Container) { + getVariables(((Container) o).getSubItems()); + } + } + } + + public int deobfuscateAS2Identifiers() { + actionsMap = new HashMap>(); + allFunctions = new ArrayList(); + allVariableNames = new HashMap(); + List objs = new ArrayList(); + int ret = 0; + objs.addAll(tags); + getVariables(objs); + for (GraphSourceItem fun : allFunctions) { + if (fun instanceof ActionDefineFunction) { + ActionDefineFunction f = (ActionDefineFunction) fun; + String changed = deobfuscateName(deobfuscated, f.functionName, false); + if (changed != null) { + f.replacedFunctionName = changed; + } + } + if (fun instanceof ActionDefineFunction2) { + ActionDefineFunction2 f = (ActionDefineFunction2) fun; + String changed = deobfuscateName(deobfuscated, f.functionName, false); + if (changed != null) { + f.replacedFunctionName = changed; + } + } + } + for (DirectValueTreeItem ti : allVariableNames.keySet()) { + String name = ti.toStringNoH(allVariableNames.get(ti)); + allVariableNamesStr.add(name); + } + for (DirectValueTreeItem ti : allVariableNames.keySet()) { + String name = ti.toStringNoH(allVariableNames.get(ti)); + String changed = deobfuscateName(deobfuscated, name, false); if (changed != null) { - f.replacedFunctionName = changed; + ActionPush pu = (ActionPush) ti.src; + if (pu.replacement == null) { + pu.replacement = new ArrayList(); + pu.replacement.addAll(pu.values); + } + pu.replacement.set(ti.pos, changed); + ret++; } - } - if (fun instanceof ActionDefineFunction2) { - ActionDefineFunction2 f = (ActionDefineFunction2) fun; - String changed = deobfuscateName(deobfuscated, f.functionName, false); - if (changed != null) { - f.replacedFunctionName = changed; - } - } - } - for (DirectValueTreeItem ti : allVariableNames.keySet()) { - String name = ti.toStringNoH(allVariableNames.get(ti)); - allVariableNamesStr.add(name); - } - for (DirectValueTreeItem ti : allVariableNames.keySet()) { - String name = ti.toStringNoH(allVariableNames.get(ti)); - String changed = deobfuscateName(deobfuscated, name, false); - if (changed != null) { - ActionPush pu = (ActionPush) ti.src; - if (pu.replacement == null) { - pu.replacement = new ArrayList(); - pu.replacement.addAll(pu.values); - } - pu.replacement.set(ti.pos, changed); - ret++; - } - } - for (ASMSource src : actionsMap.keySet()) { - actionsMap.put(src, Action.removeNops(actionsMap.get(src), version)); - src.setActions(actionsMap.get(src), version); - } - return ret; - } + } + for (ASMSource src : actionsMap.keySet()) { + actionsMap.put(src, Action.removeNops(actionsMap.get(src), version)); + src.setActions(actionsMap.get(src), version); + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java index 5c679f00d..44df6e619 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -30,7 +30,6 @@ import com.jpexs.decompiler.flash.action.swf6.*; import com.jpexs.decompiler.flash.action.swf7.*; import com.jpexs.decompiler.flash.action.treemodel.ConstantPool; import com.jpexs.decompiler.flash.action.treemodel.DirectValueTreeItem; -import com.jpexs.decompiler.flash.action.treemodel.SetVariableTreeItem; import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphSourceItemPos; import com.jpexs.decompiler.flash.graph.GraphTargetItem; @@ -72,2766 +71,2767 @@ import java.util.logging.Logger; */ public class SWFInputStream extends InputStream { - private InputStream is; - private Stack margedPos = new Stack(); - private long pos; - private int version; - private static final Logger log = Logger.getLogger(SWFInputStream.class.getName()); - private List listeners = new ArrayList(); - private long percentMax; - private List buffered = new ArrayList(); - private ByteArrayOutputStream buffer; - private static boolean DEOBFUSCATION_ALL_CODE_IN_PREVIOUS_TAG = true; + private InputStream is; + private Stack margedPos = new Stack(); + private long pos; + private int version; + private static final Logger log = Logger.getLogger(SWFInputStream.class.getName()); + private List listeners = new ArrayList(); + private long percentMax; + private List buffered = new ArrayList(); + private ByteArrayOutputStream buffer; + private static boolean DEOBFUSCATION_ALL_CODE_IN_PREVIOUS_TAG = true; - public int getBufferLength() { - return buffer.size(); - } + public int getBufferLength() { + return buffer.size(); + } - public void startBuffer() { - stopBuffer(); - buffer = new ByteArrayOutputStream(); - } + public void startBuffer() { + stopBuffer(); + buffer = new ByteArrayOutputStream(); + } - public byte[] getBuffer() { - return buffer.toByteArray(); - } + public byte[] getBuffer() { + return buffer.toByteArray(); + } - public byte[] stopBuffer() { - if (buffer != null) { - byte[] ret = buffer.toByteArray(); - buffered.add(ret); - buffer = null; - return ret; - } - return null; - } + public byte[] stopBuffer() { + if (buffer != null) { + byte[] ret = buffer.toByteArray(); + buffered.add(ret); + buffer = null; + return ret; + } + return null; + } - public void addPercentListener(PercentListener listener) { - listeners.add(listener); - } + public void addPercentListener(PercentListener listener) { + listeners.add(listener); + } - public void removePercentListener(PercentListener listener) { - int index = listeners.indexOf(listener); - if (index > -1) { - listeners.remove(index); - } - } + public void removePercentListener(PercentListener listener) { + int index = listeners.indexOf(listener); + if (index > -1) { + listeners.remove(index); + } + } - public void setPercentMax(long percentMax) { - this.percentMax = percentMax; - } + public void setPercentMax(long percentMax) { + this.percentMax = percentMax; + } - /** - * Constructor - * - * @param is Existing inputstream - * @param version Version of SWF to read - */ - public SWFInputStream(InputStream is, int version, long startingPos) { - this.version = version; - this.is = is; - pos = startingPos; - } + /** + * Constructor + * + * @param is Existing inputstream + * @param version Version of SWF to read + */ + public SWFInputStream(InputStream is, int version, long startingPos) { + this.version = version; + this.is = is; + pos = startingPos; + } - /** - * Constructor - * - * @param is Existing inputstream - * @param version Version of SWF to read - */ - public SWFInputStream(InputStream is, int version) { - this(is, version, 0L); - } + /** + * Constructor + * + * @param is Existing inputstream + * @param version Version of SWF to read + */ + public SWFInputStream(InputStream is, int version) { + this(is, version, 0L); + } - /** - * Gets position in bytes in the stream - * - * @return Number of bytes - */ - public long getPos() { - return pos; - } + /** + * Gets position in bytes in the stream + * + * @return Number of bytes + */ + public long getPos() { + return pos; + } - /** - * Reads one byte from the stream - * - * @return byte or -1 on error - * @throws IOException - */ - @Override - public int read() throws IOException { - bitPos = 0; - return readNoBitReset(); - } + /** + * Reads one byte from the stream + * + * @return byte or -1 on error + * @throws IOException + */ + @Override + public int read() throws IOException { + bitPos = 0; + return readNoBitReset(); + } - @Override - public int read(byte[] b, int off, int len) throws IOException { - int bytesRead = super.read(b, off, len); - bitPos = 0; - pos += bytesRead; - return bytesRead; - } + @Override + public int read(byte[] b, int off, int len) throws IOException { + int bytesRead = super.read(b, off, len); + bitPos = 0; + pos += bytesRead; + return bytesRead; + } - private void alignByte() { - bitPos = 0; - } - private int lastPercent = -1; + private void alignByte() { + bitPos = 0; + } + private int lastPercent = -1; - private int readNoBitReset() throws IOException { - pos++; - if (percentMax > 0) { - int percent = (int) (pos * 100 / percentMax); - if (lastPercent != percent) { - for (PercentListener pl : listeners) { - pl.percent(percent); + private int readNoBitReset() throws IOException { + pos++; + if (percentMax > 0) { + int percent = (int) (pos * 100 / percentMax); + if (lastPercent != percent) { + for (PercentListener pl : listeners) { + pl.percent(percent); + } + lastPercent = percent; } - lastPercent = percent; - } - } - return is.read(); - } + } + return is.read(); + } - /** - * Reads one UI8 (Unsigned 8bit integer) value from the stream - * - * @return UI8 value or -1 on error - * @throws IOException - */ - public int readUI8() throws IOException { - return read(); - } + /** + * Reads one UI8 (Unsigned 8bit integer) value from the stream + * + * @return UI8 value or -1 on error + * @throws IOException + */ + public int readUI8() throws IOException { + return read(); + } - /** - * Reads one string value from the stream - * - * @return String value - * @throws IOException - */ - public String readString() throws IOException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - int r; - while (true) { - r = read(); - if (r <= 0) { - return new String(baos.toByteArray(), "utf8"); - } - baos.write(r); - } - } - - /** - * Reads one UI32 (Unsigned 32bit integer) value from the stream - * - * @return UI32 value - * @throws IOException - */ - public long readUI32() throws IOException { - return (read() + (read() << 8) + (read() << 16) + (read() << 24)) & 0xffffffff; - } - - /** - * Reads one UI16 (Unsigned 16bit integer) value from the stream - * - * @return UI16 value - * @throws IOException - */ - public int readUI16() throws IOException { - return read() + (read() << 8); - } - - /** - * Reads one SI32 (Signed 32bit integer) value from the stream - * - * @return SI32 value - * @throws IOException - */ - public long readSI32() throws IOException { - long uval = read() + (read() << 8) + (read() << 16) + (read() << 24); - if (uval >= 0x80000000) { - return -(((~uval) & 0xffffffff) + 1); - } else { - return uval; - } - } - - /** - * Reads one SI16 (Signed 16bit integer) value from the stream - * - * @return SI16 value - * @throws IOException - */ - public int readSI16() throws IOException { - int uval = read() + (read() << 8); - if (uval >= 0x8000) { - return -(((~uval) & 0xffff) + 1); - } else { - return uval; - } - } - - /** - * Reads one SI8 (Signed 8bit integer) value from the stream - * - * @return SI8 value - * @throws IOException - */ - public int readSI8() throws IOException { - int uval = read(); - if (uval >= 0x80) { - return -(((~uval) & 0xff) + 1); - } else { - return uval; - } - } - - /** - * Reads one FIXED (Fixed point 16.16) value from the stream - * - * @return FIXED value - * @throws IOException - */ - public double readFIXED() throws IOException { - int afterPoint = readUI16(); - int beforePoint = readUI16(); - return ((double) ((beforePoint << 16) + afterPoint)) / 65536; - } - - /** - * Reads one FIXED8 (Fixed point 8.8) value from the stream - * - * @return FIXED8 value - * @throws IOException - */ - public float readFIXED8() throws IOException { - int afterPoint = read(); - int beforePoint = read(); - return beforePoint + (((float) afterPoint) / 256); - } - - private long readLong() throws IOException { - byte readBuffer[] = readBytes(8); - return (((long) readBuffer[3] << 56) - + ((long) (readBuffer[2] & 255) << 48) - + ((long) (readBuffer[1] & 255) << 40) - + ((long) (readBuffer[0] & 255) << 32) - + ((long) (readBuffer[7] & 255) << 24) - + ((readBuffer[6] & 255) << 16) - + ((readBuffer[5] & 255) << 8) - + ((readBuffer[4] & 255))); - } - - /** - * Reads one DOUBLE (double precision floating point value) value from the - * stream - * - * @return DOUBLE value - * @throws IOException - */ - public double readDOUBLE() throws IOException { - long el = readLong(); - double ret = Double.longBitsToDouble(el); - return ret; - } - - /** - * Reads one FLOAT (single precision floating point value) value from the - * stream - * - * @return FLOAT value - * @throws IOException - */ - public float readFLOAT() throws IOException { - int val = (int) readUI32(); - float ret = Float.intBitsToFloat(val); - /*int sign = val >> 31; - int mantisa = val & 0x3FFFFF; - int exp = (val >> 22) & 0xFF; - float ret =(sign == 1 ? -1 : 1) * (float) Math.pow(2, exp)* (1+((mantisa)/ (float)(1<<23)));*/ - return ret; - } - - /** - * Reads one FLOAT16 (16bit floating point value) value from the stream - * - * @return FLOAT16 value - * @throws IOException - */ - public float readFLOAT16() throws IOException { - int val = readUI16(); - int sign = val >> 15; - int mantisa = val & 0x3FF; - int exp = (val >> 10) & 0x1F; - float ret = (sign == 1 ? -1 : 1) * (float) Math.pow(2, exp) * (1 + ((mantisa) / (float) (1 << 10))); - return ret; - } - - /** - * Reads bytes from the stream - * - * @param count Number of bytes to read - * @return Array of read bytes - * @throws IOException - */ - public byte[] readBytes(long count) throws IOException { - if (count <= 0) { - return new byte[0]; - } - byte ret[] = new byte[(int) count]; - for (int i = 0; i < count; i++) { - ret[i] = (byte) read(); - } - return ret; - } - - /** - * Reads one EncodedU32 (Encoded unsigned 32bit value) value from the stream - * - * @return U32 value - * @throws IOException - */ - public long readEncodedU32() throws IOException { - int result = read(); - if ((result & 0x00000080) == 0) { - return result; - } - result = (result & 0x0000007f) | (read()) << 7; - if ((result & 0x00004000) == 0) { - return result; - } - result = (result & 0x00003fff) | (read()) << 14; - if ((result & 0x00200000) == 0) { - return result; - } - result = (result & 0x001fffff) | (read()) << 21; - if ((result & 0x10000000) == 0) { - return result; - } - result = (result & 0x0fffffff) | (read()) << 28; - return result; - } - private int bitPos = 0; - private int tempByte = 0; - - /** - * Reads UB[nBits] (Unsigned-bit value) value from the stream - * - * @param nBits Number of bits which represent value - * @return Unsigned value - * @throws IOException - */ - public long readUB(int nBits) throws IOException { - if (nBits == 0) { - return 0; - } - long ret = 0; - if (bitPos == 0) { - tempByte = readNoBitReset(); - } - for (int bit = 0; bit < nBits; bit++) { - int nb = (tempByte >> (7 - bitPos)) & 1; - ret = ret + (nb << (nBits - 1 - bit)); - bitPos++; - if (bitPos == 8) { - bitPos = 0; - if (bit != nBits - 1) { - tempByte = readNoBitReset(); + /** + * Reads one string value from the stream + * + * @return String value + * @throws IOException + */ + public String readString() throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + int r; + while (true) { + r = read(); + if (r <= 0) { + return new String(baos.toByteArray(), "utf8"); } - } - } - return ret; - } + baos.write(r); + } + } - /** - * Reads SB[nBits] (Signed-bit value) value from the stream - * - * @param nBits Number of bits which represent value - * @return Signed value - * @throws IOException - */ - public long readSB(int nBits) throws IOException { - int uval = (int) readUB(nBits); + /** + * Reads one UI32 (Unsigned 32bit integer) value from the stream + * + * @return UI32 value + * @throws IOException + */ + public long readUI32() throws IOException { + return (read() + (read() << 8) + (read() << 16) + (read() << 24)) & 0xffffffff; + } - int shift = 32 - nBits; - // sign extension - uval = (uval << shift) >> shift; - return uval; - } + /** + * Reads one UI16 (Unsigned 16bit integer) value from the stream + * + * @return UI16 value + * @throws IOException + */ + public int readUI16() throws IOException { + return read() + (read() << 8); + } - /** - * Reads FB[nBits] (Signed fixed-point bit value) value from the stream - * - * @param nBits Number of bits which represent value - * @return Fixed-point value - * @throws IOException - */ - public float readFB(int nBits) throws IOException { - if (nBits == 0) { - return 0; - } - float val = readSB(nBits); - float ret = val / 0x10000; - return ret; - } + /** + * Reads one SI32 (Signed 32bit integer) value from the stream + * + * @return SI32 value + * @throws IOException + */ + public long readSI32() throws IOException { + long uval = read() + (read() << 8) + (read() << 16) + (read() << 24); + if (uval >= 0x80000000) { + return -(((~uval) & 0xffffffff) + 1); + } else { + return uval; + } + } - /** - * Reads one RECT value from the stream - * - * @return RECT value - * @throws IOException - */ - public RECT readRECT() throws IOException { - RECT ret = new RECT(); - int NBits = (int) readUB(5); - ret.Xmin = (int) readSB(NBits); - ret.Xmax = (int) readSB(NBits); - ret.Ymin = (int) readSB(NBits); - ret.Ymax = (int) readSB(NBits); - ret.nbits = NBits; - alignByte(); - return ret; - } + /** + * Reads one SI16 (Signed 16bit integer) value from the stream + * + * @return SI16 value + * @throws IOException + */ + public int readSI16() throws IOException { + int uval = read() + (read() << 8); + if (uval >= 0x8000) { + return -(((~uval) & 0xffff) + 1); + } else { + return uval; + } + } - public List readActionList() throws IOException { - ReReadableInputStream rri = new ReReadableInputStream(this); - return readActionList(rri, version, 0); - } + /** + * Reads one SI8 (Signed 8bit integer) value from the stream + * + * @return SI8 value + * @throws IOException + */ + public int readSI8() throws IOException { + int uval = read(); + if (uval >= 0x80) { + return -(((~uval) & 0xff) + 1); + } else { + return uval; + } + } - private static void getConstantPool(ConstantPool cpool, List localData, Stack stack, List output, ActionGraphSource code, int ip, int lastIp, List constantPools, List visited, int version) { - boolean debugMode = false; - while ((ip > -1) && ip < code.size()) { - if (visited.contains(ip)) { - break; - } + /** + * Reads one FIXED (Fixed point 16.16) value from the stream + * + * @return FIXED value + * @throws IOException + */ + public double readFIXED() throws IOException { + int afterPoint = readUI16(); + int beforePoint = readUI16(); + return ((double) ((beforePoint << 16) + afterPoint)) / 65536; + } - lastIp = ip; - GraphSourceItem ins = code.get(ip); - if (ins.isIgnored()) { - ip++; - continue; - } + /** + * Reads one FIXED8 (Fixed point 8.8) value from the stream + * + * @return FIXED8 value + * @throws IOException + */ + public float readFIXED8() throws IOException { + int afterPoint = read(); + int beforePoint = read(); + return beforePoint + (((float) afterPoint) / 256); + } - if (ins instanceof ActionPush) { - if (cpool != null) { - ((ActionPush) ins).constantPool = cpool.constants; - cpool.count++; + private long readLong() throws IOException { + byte readBuffer[] = readBytes(8); + return (((long) readBuffer[3] << 56) + + ((long) (readBuffer[2] & 255) << 48) + + ((long) (readBuffer[1] & 255) << 40) + + ((long) (readBuffer[0] & 255) << 32) + + ((long) (readBuffer[7] & 255) << 24) + + ((readBuffer[6] & 255) << 16) + + ((readBuffer[5] & 255) << 8) + + ((readBuffer[4] & 255))); + } + + /** + * Reads one DOUBLE (double precision floating point value) value from the + * stream + * + * @return DOUBLE value + * @throws IOException + */ + public double readDOUBLE() throws IOException { + long el = readLong(); + double ret = Double.longBitsToDouble(el); + return ret; + } + + /** + * Reads one FLOAT (single precision floating point value) value from the + * stream + * + * @return FLOAT value + * @throws IOException + */ + public float readFLOAT() throws IOException { + int val = (int) readUI32(); + float ret = Float.intBitsToFloat(val); + /*int sign = val >> 31; + int mantisa = val & 0x3FFFFF; + int exp = (val >> 22) & 0xFF; + float ret =(sign == 1 ? -1 : 1) * (float) Math.pow(2, exp)* (1+((mantisa)/ (float)(1<<23)));*/ + return ret; + } + + /** + * Reads one FLOAT16 (16bit floating point value) value from the stream + * + * @return FLOAT16 value + * @throws IOException + */ + public float readFLOAT16() throws IOException { + int val = readUI16(); + int sign = val >> 15; + int mantisa = val & 0x3FF; + int exp = (val >> 10) & 0x1F; + float ret = (sign == 1 ? -1 : 1) * (float) Math.pow(2, exp) * (1 + ((mantisa) / (float) (1 << 10))); + return ret; + } + + /** + * Reads bytes from the stream + * + * @param count Number of bytes to read + * @return Array of read bytes + * @throws IOException + */ + public byte[] readBytes(long count) throws IOException { + if (count <= 0) { + return new byte[0]; + } + byte ret[] = new byte[(int) count]; + for (int i = 0; i < count; i++) { + ret[i] = (byte) read(); + } + return ret; + } + + /** + * Reads one EncodedU32 (Encoded unsigned 32bit value) value from the stream + * + * @return U32 value + * @throws IOException + */ + public long readEncodedU32() throws IOException { + int result = read(); + if ((result & 0x00000080) == 0) { + return result; + } + result = (result & 0x0000007f) | (read()) << 7; + if ((result & 0x00004000) == 0) { + return result; + } + result = (result & 0x00003fff) | (read()) << 14; + if ((result & 0x00200000) == 0) { + return result; + } + result = (result & 0x001fffff) | (read()) << 21; + if ((result & 0x10000000) == 0) { + return result; + } + result = (result & 0x0fffffff) | (read()) << 28; + return result; + } + private int bitPos = 0; + private int tempByte = 0; + + /** + * Reads UB[nBits] (Unsigned-bit value) value from the stream + * + * @param nBits Number of bits which represent value + * @return Unsigned value + * @throws IOException + */ + public long readUB(int nBits) throws IOException { + if (nBits == 0) { + return 0; + } + long ret = 0; + if (bitPos == 0) { + tempByte = readNoBitReset(); + } + for (int bit = 0; bit < nBits; bit++) { + int nb = (tempByte >> (7 - bitPos)) & 1; + ret = ret + (nb << (nBits - 1 - bit)); + bitPos++; + if (bitPos == 8) { + bitPos = 0; + if (bit != nBits - 1) { + tempByte = readNoBitReset(); + } } - } - if (ins instanceof ActionDefineFunction) { - if (cpool != null) { - ((ActionDefineFunction) ins).setConstantPool(cpool.constants); - cpool.count++; + } + return ret; + } + + /** + * Reads SB[nBits] (Signed-bit value) value from the stream + * + * @param nBits Number of bits which represent value + * @return Signed value + * @throws IOException + */ + public long readSB(int nBits) throws IOException { + int uval = (int) readUB(nBits); + + int shift = 32 - nBits; + // sign extension + uval = (uval << shift) >> shift; + return uval; + } + + /** + * Reads FB[nBits] (Signed fixed-point bit value) value from the stream + * + * @param nBits Number of bits which represent value + * @return Fixed-point value + * @throws IOException + */ + public float readFB(int nBits) throws IOException { + if (nBits == 0) { + return 0; + } + float val = readSB(nBits); + float ret = val / 0x10000; + return ret; + } + + /** + * Reads one RECT value from the stream + * + * @return RECT value + * @throws IOException + */ + public RECT readRECT() throws IOException { + RECT ret = new RECT(); + int NBits = (int) readUB(5); + ret.Xmin = (int) readSB(NBits); + ret.Xmax = (int) readSB(NBits); + ret.Ymin = (int) readSB(NBits); + ret.Ymax = (int) readSB(NBits); + ret.nbits = NBits; + alignByte(); + return ret; + } + + public List readActionList() throws IOException { + ReReadableInputStream rri = new ReReadableInputStream(this); + return readActionList(rri, version, 0); + } + + private static void getConstantPool(ConstantPool cpool, List localData, Stack stack, List output, ActionGraphSource code, int ip, int lastIp, List constantPools, List visited, int version) { + boolean debugMode = false; + while ((ip > -1) && ip < code.size()) { + if (visited.contains(ip)) { + break; } - } - if (ins instanceof ActionDefineFunction2) { - if (cpool != null) { - ((ActionDefineFunction2) ins).setConstantPool(cpool.constants); - cpool.count++; + + lastIp = ip; + GraphSourceItem ins = code.get(ip); + if (ins.isIgnored()) { + ip++; + continue; } - } - if (debugMode) { - System.out.println("getConstantPool ip " + ip + ": " + ins + " stack:" + Highlighting.stripHilights(stack.toString())); - } - if (ins instanceof ActionConstantPool) { - constantPools.add(new ConstantPool(((ActionConstantPool) ins).constantPool)); - if (cpool == null) { - cpool = new ConstantPool(); + + if (ins instanceof ActionPush) { + if (cpool != null) { + ((ActionPush) ins).constantPool = cpool.constants; + cpool.count++; + } } - cpool.setNew(((ActionConstantPool) ins).constantPool); - } - - //for..in return - if (((ins instanceof ActionEquals) || (ins instanceof ActionEquals2)) && (stack.size() == 1) && (stack.peek() instanceof DirectValueTreeItem)) { - stack.push(new DirectValueTreeItem(null, 0, new Null(), new ArrayList())); - } - try { - ins.translate(localData, stack, output); - } catch (Exception ex) { - Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "Error during getting constantpool", ex); - } - if (ins.isExit()) { - break; - } - - if (ins.isBranch() || ins.isJump()) { - - if (ins instanceof ActionIf && !stack.isEmpty() && (stack.peek().isCompileTime())) { - ActionIf aif = (ActionIf) ins; - if (aif.ignoreUsed && (!aif.jumpUsed)) { - ins.setIgnored(true); - } - if ((!aif.ignoreUsed) && aif.jumpUsed) { - ActionJump jmpIns = new ActionJump(aif.offset); - ((ActionJump) jmpIns).setAddress(aif.getAddress(), version); - code.set(ip, (ActionJump) jmpIns); - } - - if ((aif.ignoreUsed && (!aif.jumpUsed)) || ((!aif.ignoreUsed) && aif.jumpUsed)) { - List needed = stack.peek().getNeededSources(); - for (GraphSourceItemPos ig : needed) { - if (ig.item instanceof ActionPush) { - if (!((ActionPush) ig.item).ignoredParts.contains(ig.pos)) { - ((ActionPush) ig.item).ignoredParts.add(ig.pos); - - if (((ActionPush) ig.item).ignoredParts.size() == ((ActionPush) ig.item).values.size()) { - ((Action) ig.item).ignored = true; - } - } - } else { - ((Action) ig.item).ignored = true; - } - } - } - boolean condition = stack.peek().toBoolean(); - if (debugMode) { - if (condition) { - System.out.println("JUMP"); - } else { - System.out.println("SKIP"); - } - } - stack.pop(); - getConstantPool(cpool, localData, stack, output, code, condition ? (code.adr2pos(((ActionIf) ins).getAddress() + ((ActionIf) ins).getBytes(code.version).length + ((ActionIf) ins).offset)) : ip + 1, ip, constantPools, visited, version); - } else { - if (ins instanceof ActionIf) { - stack.pop(); - } - visited.add(ip); - List branches = ins.getBranches(code); - for (int b : branches) { - Stack brStack = (Stack) stack.clone(); - if (b >= 0) { - getConstantPool(cpool, localData, brStack, output, code, b, ip, constantPools, visited, version); - } else { - if (debugMode) { - System.out.println("Negative branch:" + b); - } - } - } + if (ins instanceof ActionDefineFunction) { + if (cpool != null) { + ((ActionDefineFunction) ins).setConstantPool(cpool.constants); + cpool.count++; + } } - break; - } - ip++; - }; - if (ip < 0) { - System.out.println("Visited Negative: " + ip); - } - } - - public static List getConstantPool(ActionGraphSource code, int addr, int version) { - List ret = new ArrayList(); - List localData = Helper.toList(new HashMap(), new HashMap(), new HashMap()); - try { - getConstantPool(null, localData, new Stack(), new ArrayList(), code, code.adr2pos(addr), 0, ret, new ArrayList(), version); - } catch (Exception ex) { - log.log(Level.SEVERE, "Error during getting constantpool", ex); - } - return ret; - } - - /** - * Reads list of actions from the stream. Reading ends with ActionEndFlag(=0) - * or end of the stream. - * - * @return List of actions - * @throws IOException - */ - public static List readActionList(ReReadableInputStream rri, int version, int ip) throws IOException { - List retdups = new ArrayList(); - ConstantPool cpool = new ConstantPool(); - - Stack stack = new Stack(); - - List localData = Helper.toList(new HashMap(), new HashMap(), new HashMap()); - - - SWFInputStream sis = new SWFInputStream(rri, version); - boolean goesPrev = false; - int method = 1; - /*try { - goesPrev = readActionListAtPos(false, localData, stack, cpool, sis, rri, ip, retdups, ip); - } catch (Exception ex) { - method = 2; - goesPrev = readActionListAtPos(true, localData, stack, cpool, sis, rri, ip, retdups, ip); - }*/ - goesPrev = readActionListAtPos(false, true, localData, stack, cpool, sis, rri, ip, retdups, ip); - - if (goesPrev) { - } else { - if (!retdups.isEmpty()) { - for (int i = 0; i < ip; i++) { - retdups.remove(0); + if (ins instanceof ActionDefineFunction2) { + if (cpool != null) { + ((ActionDefineFunction2) ins).setConstantPool(cpool.constants); + cpool.count++; + } } - } - } - List ret = new ArrayList(); - Action last = null; - for (Action a : retdups) { - if (a != last) { - ret.add(a); - } - last = a; - } - int len = retdups.size(); - for (int i = 0; i < retdups.size(); i++) { - Action a = retdups.get(i); - if (a instanceof ActionEnd) { - if (i < retdups.size() - 1) { - ActionJump jmp = new ActionJump(0); - jmp.offset = retdups.size() - i - jmp.getBytes(version).length; - a.replaceWith = jmp; + if (debugMode) { + System.out.println("getConstantPool ip " + ip + ": " + ins + " stack:" + Highlighting.stripHilights(stack.toString())); } - } - } - - List pools = new ArrayList(); - pools = getConstantPool(new ActionGraphSource(ret, version, new HashMap(), new HashMap(), new HashMap()), ip, version); - - if (pools.size() == 1) { - Action.setConstantPool(ret, pools.get(0)); - } - if (goesPrev && (!DEOBFUSCATION_ALL_CODE_IN_PREVIOUS_TAG)) { - ActionJump aj = new ActionJump(ip); - int skip = aj.getBytes(version).length; - for (Action a : ret) { - a.setAddress(a.getAddress() + skip, version); - } - ret.add(0, aj); - } - String s = null; - //Action.setConstantPool(ret, cpool); - - try { - s = Highlighting.stripHilights(Action.actionsToString(ret, null, version, false)); - ret = ASMParser.parse(false, new ByteArrayInputStream(s.getBytes()), SWF.DEFAULT_VERSION); - } catch (ParseException ex) { - Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "parsing error", ex); - } - return ret; - } - - private static boolean readActionListAtPos(boolean notCompileTime, boolean enableVariables, List localData, Stack stack, ConstantPool cpool, SWFInputStream sis, ReReadableInputStream rri, int ip, List ret, int startIp) throws IOException { - boolean debugMode = false; - boolean decideBranch = false; - boolean retv = false; - rri.setPos(ip); - Action a; - List output = new ArrayList(); - long filePos = rri.getPos(); - Scanner sc = new Scanner(System.in); - int prevIp = ip; - while ((a = sis.readAction()) != null) { - if ((ip < ret.size()) && (!(ret.get(ip) instanceof ActionNop))) { - a = ret.get(ip); - } - a.setAddress(prevIp, SWF.DEFAULT_VERSION); - int info = a.actionLength + 1 + ((a.actionCode > 0x80) ? 2 : 0); - int actual = 0; - if (a instanceof ActionContainer) { - actual = ((ActionContainer) a).getHeaderBytes().length; - } else { - actual = a.getBytes(sis.version).length; - } - if (!(a instanceof ActionContainer)) { - int change = info - (rri.getPos() - ip); - if (change > 0) { - a.afterInsert = new ActionJump(change); + if (ins instanceof ActionConstantPool) { + constantPools.add(new ConstantPool(((ActionConstantPool) ins).constantPool)); + if (cpool == null) { + cpool = new ConstantPool(); + } + cpool.setNew(((ActionConstantPool) ins).constantPool); } - } else { - info = rri.getPos() - ip; - } - if (ip < startIp) { - retv = true; - } - if (debugMode) { - //if(a instanceof ActionIf){ - System.out.println("readActionListAtPos ip: " + (ip - startIp) + " action(len " + a.actionLength + "): " + a + (a.isIgnored()?" (ignored)":"") + " stack:" + Highlighting.stripHilights(stack.toString()) + " " + Helper.byteArrToString(a.getBytes(SWF.DEFAULT_VERSION))); - //} - } - /*if(a instanceof ActionConstantPool){ - throw new IllegalArgumentException("CP found"); - } */ - if (a instanceof ActionPush) { - if (cpool != null) { - ((ActionPush) a).constantPool = cpool.constants; - cpool.count++; - } - } - if (a instanceof ActionDefineFunction) { - if (cpool != null) { - ((ActionDefineFunction) a).setConstantPool(cpool.constants); - cpool.count++; - } - } - if (a instanceof ActionDefineFunction2) { - if (cpool != null) { - ((ActionDefineFunction2) a).setConstantPool(cpool.constants); - cpool.count++; - } - } - long newFilePos = rri.getPos(); - long actionLen = newFilePos - filePos; - ensureCapacity(ret, ip); - int newip = -1; - if (!enableVariables && (!(ret.get(ip) instanceof ActionNop))) { - break; - } - - if (a instanceof ActionConstantPool) { - if (cpool == null) { - cpool = new ConstantPool(); + //for..in return + if (((ins instanceof ActionEquals) || (ins instanceof ActionEquals2)) && (stack.size() == 1) && (stack.peek() instanceof DirectValueTreeItem)) { + stack.push(new DirectValueTreeItem(null, 0, new Null(), new ArrayList())); } - cpool.setNew(((ActionConstantPool) a).constantPool); - } - Action beforeInsert = null; - ActionIf aif = null; - boolean goaif = false; - if (!a.isIgnored()) { try { - if (a instanceof ActionIf) { - aif = (ActionIf) a; - GraphTargetItem top = null; - top = stack.pop(); + ins.translate(localData, stack, output); + } catch (Exception ex) { + Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "Error during getting constantpool", ex); + } + if (ins.isExit()) { + break; + } - int nip = rri.getPos() + aif.offset; + if (ins.isBranch() || ins.isJump()) { - if (decideBranch) { - System.out.print("newip " + nip + ", "); - System.out.print("Action: jump(j),ignore(i),compute(c)?"); - String next = sc.next(); - if (next.equals("j")) { - newip = rri.getPos() + aif.offset; - rri.setPos(newip); + if (ins instanceof ActionIf && !stack.isEmpty() && (stack.peek().isCompileTime())) { + ActionIf aif = (ActionIf) ins; + if (aif.ignoreUsed && (!aif.jumpUsed)) { + ins.setIgnored(true); + } + if ((!aif.ignoreUsed) && aif.jumpUsed) { + ActionJump jmpIns = new ActionJump(aif.offset); + ((ActionJump) jmpIns).setAddress(aif.getAddress(), version); + code.set(ip, (ActionJump) jmpIns); + } - } else if (next.equals("i")) { - } else if (next.equals("c")) { - goaif = true; - } - } else if (top.isCompileTime() && ((!top.isVariableComputed()) || (top.isVariableComputed() && enableVariables && (!notCompileTime)))) { - //if(top.isCompileTime()) { - //if(false){ - if (enableVariables) { - ((ActionIf) a).compileTime = true; - } - if (debugMode) { - System.out.print("is compiletime -> "); - } - if (top.toBoolean()) { - newip = rri.getPos() + aif.offset; - //rri.setPos(newip); - if (((!enableVariables) || (!top.isVariableComputed())) && (!aif.ignoreUsed)) { - a = new ActionJump(aif.offset); - a.setAddress(aif.getAddress(), SWF.DEFAULT_VERSION); - } - aif.jumpUsed = true; - if (aif.ignoreUsed) { - aif.compileTime = false; - } - if (debugMode) { - System.out.println("jump"); - } - } else { - aif.ignoreUsed = true; - if (aif.jumpUsed) { - aif.compileTime = false; - } - if (debugMode) { - System.out.println("ignore"); - } - if (((!enableVariables) || (!top.isVariableComputed())) && (!aif.jumpUsed)) { - //a = new ActionNop(); - aif.setIgnored(true); - //a.setAddress(aif.getAddress(), SWF.DEFAULT_VERSION); - } - } - if (((!enableVariables) || (!top.isVariableComputed())) && (!(aif.jumpUsed && aif.ignoreUsed))) { - List needed = top.getNeededSources(); + if ((aif.ignoreUsed && (!aif.jumpUsed)) || ((!aif.ignoreUsed) && aif.jumpUsed)) { + List needed = stack.peek().getNeededSources(); for (GraphSourceItemPos ig : needed) { - if (ig.item == null) { - continue; - } - if (ig.item instanceof ActionPush) { - if (!((ActionPush) ig.item).ignoredParts.contains(ig.pos)) { - ((ActionPush) ig.item).ignoredParts.add(ig.pos); + if (ig.item instanceof ActionPush) { + if (!((ActionPush) ig.item).ignoredParts.contains(ig.pos)) { + ((ActionPush) ig.item).ignoredParts.add(ig.pos); - if (((ActionPush) ig.item).ignoredParts.size() == ((ActionPush) ig.item).values.size()) { - ((Action) ig.item).ignored = true; - } - } - } else { - ((Action) ig.item).ignored = true; - } + if (((ActionPush) ig.item).ignoredParts.size() == ((ActionPush) ig.item).values.size()) { + ((Action) ig.item).ignored = true; + } + } + } else { + ((Action) ig.item).ignored = true; + } } - } - - } else { - if (debugMode) { - System.out.println("goaif"); - } - //throw new RuntimeException("goaif"); - goaif = true; - } - } else if (a instanceof ActionJump) { - newip = rri.getPos() + ((ActionJump) a).offset; - //if(newip>=0){ - //rri.setPos(newip); - //} - } else { - //return in for..in, TODO:Handle this better way - if (((a instanceof ActionEquals) || (a instanceof ActionEquals2)) && (stack.size() == 1) && (stack.peek() instanceof DirectValueTreeItem)) { - stack.push(new DirectValueTreeItem(null, 0, new Null(), new ArrayList())); - } - if ((a instanceof ActionStoreRegister) && stack.isEmpty()) { - stack.push(new DirectValueTreeItem(null, 0, new Null(), new ArrayList())); - } - a.translate(localData, stack, output); - } - } catch (RuntimeException ex) { - if (!enableVariables) { - throw ex; - } - log.log(Level.SEVERE, "Disassembly exception", ex); - break; + } + boolean condition = stack.peek().toBoolean(); + if (debugMode) { + if (condition) { + System.out.println("JUMP"); + } else { + System.out.println("SKIP"); + } + } + stack.pop(); + getConstantPool(cpool, localData, stack, output, code, condition ? (code.adr2pos(((ActionIf) ins).getAddress() + ((ActionIf) ins).getBytes(code.version).length + ((ActionIf) ins).offset)) : ip + 1, ip, constantPools, visited, version); + } else { + if (ins instanceof ActionIf) { + stack.pop(); + } + visited.add(ip); + List branches = ins.getBranches(code); + for (int b : branches) { + Stack brStack = (Stack) stack.clone(); + if (b >= 0) { + getConstantPool(cpool, localData, brStack, output, code, b, ip, constantPools, visited, version); + } else { + if (debugMode) { + System.out.println("Negative branch:" + b); + } + } + } + } + break; } - } - int nopos = -1; - for (int i = 0; i < actionLen; i++) { - ensureCapacity(ret, ip + i); - if (a instanceof ActionNop) { - int prevPos = (int) a.getAddress(); - a = new ActionNop(); - a.setAddress(prevPos, SWF.DEFAULT_VERSION); - nopos++; - if (nopos > 0) { - a.setAddress(a.getAddress() + 1, SWF.DEFAULT_VERSION); - } + ip++; + }; + if (ip < 0) { + System.out.println("Visited Negative: " + ip); + } + } - if (i == 0) { - a.beforeInsert = beforeInsert; - } + public static List getConstantPool(ActionGraphSource code, int addr, int version) { + List ret = new ArrayList(); + List localData = Helper.toList(new HashMap(), new HashMap(), new HashMap()); + try { + getConstantPool(null, localData, new Stack(), new ArrayList(), code, code.adr2pos(addr), 0, ret, new ArrayList(), version); + } catch (Exception ex) { + log.log(Level.SEVERE, "Error during getting constantpool", ex); + } + return ret; + } + + /** + * Reads list of actions from the stream. Reading ends with + * ActionEndFlag(=0) or end of the stream. + * + * @return List of actions + * @throws IOException + */ + public static List readActionList(ReReadableInputStream rri, int version, int ip) throws IOException { + List retdups = new ArrayList(); + ConstantPool cpool = new ConstantPool(); + + Stack stack = new Stack(); + + List localData = Helper.toList(new HashMap(), new HashMap(), new HashMap()); + + + SWFInputStream sis = new SWFInputStream(rri, version); + boolean goesPrev = false; + int method = 1; + /*try { + goesPrev = readActionListAtPos(false, localData, stack, cpool, sis, rri, ip, retdups, ip); + } catch (Exception ex) { + method = 2; + goesPrev = readActionListAtPos(true, localData, stack, cpool, sis, rri, ip, retdups, ip); + }*/ + goesPrev = readActionListAtPos(false, true, localData, stack, cpool, sis, rri, ip, retdups, ip); + + if (goesPrev) { + } else { + if (!retdups.isEmpty()) { + for (int i = 0; i < ip; i++) { + retdups.remove(0); + } + } + } + List ret = new ArrayList(); + Action last = null; + for (Action a : retdups) { + if (a != last) { + ret.add(a); + } + last = a; + } + int len = retdups.size(); + for (int i = 0; i < retdups.size(); i++) { + Action a = retdups.get(i); + if (a instanceof ActionEnd) { + if (i < retdups.size() - 1) { + ActionJump jmp = new ActionJump(0); + jmp.offset = retdups.size() - i - jmp.getBytes(version).length; + a.replaceWith = jmp; + } + } + } + + List pools = new ArrayList(); + pools = getConstantPool(new ActionGraphSource(ret, version, new HashMap(), new HashMap(), new HashMap()), ip, version); + + if (pools.size() == 1) { + Action.setConstantPool(ret, pools.get(0)); + } + if (goesPrev && (!DEOBFUSCATION_ALL_CODE_IN_PREVIOUS_TAG)) { + ActionJump aj = new ActionJump(ip); + int skip = aj.getBytes(version).length; + for (Action a : ret) { + a.setAddress(a.getAddress() + skip, version); + } + ret.add(0, aj); + } + String s = null; + //Action.setConstantPool(ret, cpool); + + try { + s = Highlighting.stripHilights(Action.actionsToString(ret, null, version, false)); + ret = ASMParser.parse(false, new ByteArrayInputStream(s.getBytes()), SWF.DEFAULT_VERSION); + } catch (ParseException ex) { + Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "parsing error", ex); + } + return ret; + } + + private static boolean readActionListAtPos(boolean notCompileTime, boolean enableVariables, List localData, Stack stack, ConstantPool cpool, SWFInputStream sis, ReReadableInputStream rri, int ip, List ret, int startIp) throws IOException { + boolean debugMode = false; + boolean decideBranch = false; + boolean retv = false; + rri.setPos(ip); + Action a; + List output = new ArrayList(); + long filePos = rri.getPos(); + Scanner sc = new Scanner(System.in); + int prevIp = ip; + while ((a = sis.readAction()) != null) { + if ((ip < ret.size()) && (!(ret.get(ip) instanceof ActionNop))) { + a = ret.get(ip); + } + a.setAddress(prevIp, SWF.DEFAULT_VERSION); + int info = a.actionLength + 1 + ((a.actionCode > 0x80) ? 2 : 0); + int actual = 0; + if (a instanceof ActionContainer) { + actual = ((ActionContainer) a).getHeaderBytes().length; } else { - a.beforeInsert = beforeInsert; + actual = a.getBytes(sis.version).length; } - ret.set(ip + i, a); - } - - if (a instanceof ActionEnd) { - break; - } - if (newip > -1) { - ip = newip; - } else { - ip = ip + info; //(int) actionLen; - } - rri.setPos(ip); - filePos = rri.getPos(); - if (goaif) { - if (aif.ignoreUsed && aif.jumpUsed) { - break; + if (!(a instanceof ActionContainer)) { + int change = info - (rri.getPos() - ip); + if (change > 0) { + a.afterInsert = new ActionJump(change); + } + } else { + info = rri.getPos() - ip; } - aif.ignoreUsed = true; - aif.jumpUsed = true; - int oldPos = rri.getPos(); - Stack substack = (Stack) stack.clone(); - if (readActionListAtPos(true, enableVariables, localData, substack, cpool, sis, rri, rri.getPos() + aif.offset, ret, startIp)) { - retv = true; + if (ip < startIp) { + retv = true; } - rri.setPos(oldPos); - notCompileTime = true; - } - prevIp = ip; - } - return retv; - } - - private static void ensureCapacity(List ret, int index) { - int pos = ret.size(); - while (ret.size() <= index) { - Action a = new ActionNop(); - a.setAddress(pos++, SWF.DEFAULT_VERSION); - ret.add(a); - } - } - - private static void dumpTag(PrintStream out, int version, Tag tag, int level) { - StringBuilder sb = new StringBuilder(); - sb.append(Helper.formatHex((int) tag.getPos(), 8)); - sb.append(": "); - sb.append(Helper.indent(level, "")); - sb.append(Helper.format(tag.toString(), 25 - 2 * level)); - sb.append(" tagId="); - sb.append(Helper.formatInt(tag.getId(), 3)); - sb.append(" len="); - sb.append(Helper.formatInt((int) tag.getOrigDataLength(), 8)); - sb.append(" "); - sb.append(Helper.bytesToHexString(64, tag.getData(version), 0)); - out.println(sb.toString()); -// out.println(Utils.formatHex((int)tag.getPos(), 8) + ": " + Utils.indent(level, "") + Utils.format(tag.toString(), 25 - 2*level) + " tagId="+tag.getId()+" len="+tag.getOrigDataLength()+": "+Utils.bytesToHexString(64, tag.getData(version), 0)); - if (tag.hasSubTags()) { - for (Tag subTag : tag.getSubTags()) { - dumpTag(out, version, subTag, level + 1); - } - } - } - - /** - * Reads list of tags from the stream. Reading ends with End tag(=0) or end - * of the stream. - * - * @return List of tags - * @throws IOException - */ - public List readTagList(int level) throws IOException { - List tags = new ArrayList(); - Tag tag; - Tag previousTag = null; - while (true) { - long pos = getPos(); - tag = readTag(level, pos); - if (tag == null) { - break; - } - tags.add(tag); - if (Main.dump_tags && level == 0) { - dumpTag(System.out, version, tag, level); - } - tag.previousTag = previousTag; - previousTag = tag; - } - return tags; - } - - /** - * Reads one Tag from the stream - * - * @return Tag or null when End tag - * @throws IOException - */ - public Tag readTag(int level, long pos) throws IOException { - int tagIDTagLength = readUI16(); - int tagID = (tagIDTagLength) >> 6; - if (tagID == 0) { - return null; - } - long tagLength = (tagIDTagLength & 0x003F); - boolean readLong = false; - if (tagLength == 0x3f) { - tagLength = readSI32(); - readLong = true; - } - byte data[] = readBytes((int) tagLength); - Tag ret; - try { - switch (tagID) { - case 0: - ret = new EndTag(data, version, pos); - break; - case 1: - ret = new ShowFrameTag(pos); - break; - case 2: - ret = new DefineShapeTag(data, version, pos); - break; - //case 3 - case 4: - ret = new PlaceObjectTag(data, version, pos); - break; - case 5: - ret = new RemoveObjectTag(data, version, pos); - break; - case 6: - ret = new DefineBitsTag(data, version, pos); - break; - case 7: - ret = new DefineButtonTag(data, version, pos); - break; - case 8: - ret = new JPEGTablesTag(data, pos); - break; - case 9: - ret = new SetBackgroundColorTag(data, version, pos); - break; - case 10: - ret = new DefineFontTag(data, version, pos); - break; - case 11: - ret = new DefineTextTag(data, version, pos); - break; - case 12: - ret = new DoActionTag(data, version, pos); - break; - case 13: - ret = new DefineFontInfoTag(data, version, pos); - break; - case 14: - ret = new DefineSoundTag(data, version, pos); - break; - case 15: - ret = new StartSoundTag(data, version, pos); - break; - //case 16 - case 17: - ret = new DefineButtonSoundTag(data, version, pos); - break; - case 18: - ret = new SoundStreamHeadTag(data, version, pos); - break; - case 19: - ret = new SoundStreamBlockTag(data, version, pos); - break; - case 21: - ret = new DefineBitsJPEG2Tag(data, version, pos); - break; - case 20: - ret = new DefineBitsLosslessTag(data, version, pos); - break; - case 22: - ret = new DefineShape2Tag(data, version, pos); - break; - case 23: - ret = new DefineButtonCxformTag(data, version, pos); - break; - case 24: - ret = new ProtectTag(data, version, pos); - break; - //case 25: - case 26: - ret = new PlaceObject2Tag(data, version, pos); - break; - //case 27: - case 28: - ret = new RemoveObject2Tag(data, version, pos); - break; - //case 29: - //case 30: - //case 31: - case 32: - ret = new DefineShape3Tag(data, version, pos); - break; - case 33: - ret = new DefineText2Tag(data, version, pos); - break; - case 34: - ret = new DefineButton2Tag(data, version, pos); - break; - case 35: - ret = new DefineBitsJPEG3Tag(data, version, pos); - break; - case 36: - ret = new DefineBitsLossless2Tag(data, version, pos); - break; - case 37: - ret = new DefineEditTextTag(data, version, pos); - break; - //case 38: - case 39: - ret = new DefineSpriteTag(data, version, level, pos); - break; - //case 40: - case 41: - ret = new ProductInfoTag(data, version, pos); - break; - //case 42: - case 43: - ret = new FrameLabelTag(data, version, pos); - break; - //case 44: - case 45: - ret = new SoundStreamHead2Tag(data, version, pos); - break; - case 46: - ret = new DefineMorphShapeTag(data, version, pos); - break; - //case 47: - case 48: - ret = new DefineFont2Tag(data, version, pos); - break; - //case 49-55: - case 56: - ret = new ExportAssetsTag(data, version, pos); - break; - case 57: - ret = new ImportAssetsTag(data, version, pos); - break; - case 58: - ret = new EnableDebuggerTag(data, version, pos); - break; - case 59: - ret = new DoInitActionTag(data, version, pos); - break; - case 60: - ret = new DefineVideoStreamTag(data, version, pos); - break; - case 61: - ret = new VideoFrameTag(data, version, pos); - break; - case 62: - ret = new DefineFontInfo2Tag(data, version, pos); - break; - case 63: - ret = new DebugIDTag(data, version, pos); - break; - case 64: - ret = new EnableDebugger2Tag(data, version, pos); - break; - case 65: - ret = new ScriptLimitsTag(data, version, pos); - break; - case 66: - ret = new SetTabIndexTag(data, version, pos); - break; - //case 67-68: - case 69: - ret = new FileAttributesTag(data, version, pos); - break; - case 70: - ret = new PlaceObject3Tag(data, version, pos); - break; - case 71: - ret = new ImportAssets2Tag(data, version, pos); - break; - //case 72: - case 73: - ret = new DefineFontAlignZonesTag(data, version, pos); - break; - case 74: - ret = new CSMTextSettingsTag(data, version, pos); - break; - case 75: - ret = new DefineFont3Tag(data, version, pos); - break; - case 76: - ret = new SymbolClassTag(data, version, pos); - break; - case 77: - ret = new MetadataTag(data, version, pos); - break; - case 78: - ret = new DefineScalingGridTag(data, version, pos); - break; - //case 79-81: - case 82: - ret = new DoABCTag(data, version, pos); - break; - case 83: - ret = new DefineShape4Tag(data, version, pos); - break; - case 84: - ret = new DefineMorphShape2Tag(data, version, pos); - break; - //case 85: - case 86: - ret = new DefineSceneAndFrameLabelDataTag(data, version, pos); - break; - case 87: - ret = new DefineBinaryDataTag(data, version, pos); - break; - case 88: - ret = new DefineFontNameTag(data, version, pos); - break; - case 89: - ret = new StartSound2Tag(data, version, pos); - break; - case 90: - ret = new DefineBitsJPEG4Tag(data, version, pos); - break; - case 91: - ret = new DefineFont4Tag(data, version, pos); - break; - default: - ret = new Tag(tagID, "Unknown", data, pos); - } - } catch (Exception ex) { - Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "Error during tag reading", ex); - ret = new Tag(tagID, "ErrorTag", data, pos); - } - ret.forceWriteAsLong = readLong; - byte dataNew[] = ret.getData(version); - - int ignoreFirst = 0; - for (int i = 0; i < data.length; i++) { - if (i >= dataNew.length) { - break; - } - if (dataNew[i] != data[i]) { - if (ignoreFirst > 0) { - ignoreFirst--; - continue; + if (debugMode) { + //if(a instanceof ActionIf){ + System.out.println("readActionListAtPos ip: " + (ip - startIp) + " action(len " + a.actionLength + "): " + a + (a.isIgnored() ? " (ignored)" : "") + " stack:" + Highlighting.stripHilights(stack.toString()) + " " + Helper.byteArrToString(a.getBytes(SWF.DEFAULT_VERSION))); + //} } - String e = ""; - e = ("TAG " + ret.toString() + " WRONG, "); - for (int j = i - 10; j <= i + 5; j++) { - while (j < 0) { - j++; - } - if (j >= data.length) { - break; - } - if (j >= dataNew.length) { - break; - } - if (j >= i) { - e += (Long.toHexString(data[j] & 0xff) + " ( is " + Long.toHexString(dataNew[j] & 0xff) + ") "); - } else { - e += (Long.toHexString(data[j] & 0xff) + " "); - } + /*if(a instanceof ActionConstantPool){ + throw new IllegalArgumentException("CP found"); + } */ + if (a instanceof ActionPush) { + if (cpool != null) { + ((ActionPush) a).constantPool = cpool.constants; + cpool.count++; + } } - log.fine(e); - } - } - return ret; - } + if (a instanceof ActionDefineFunction) { + if (cpool != null) { + ((ActionDefineFunction) a).setConstantPool(cpool.constants); + cpool.count++; + } + } + if (a instanceof ActionDefineFunction2) { + if (cpool != null) { + ((ActionDefineFunction2) a).setConstantPool(cpool.constants); + cpool.count++; + } + } + long newFilePos = rri.getPos(); + long actionLen = newFilePos - filePos; - /** - * Reads one Action from the stream - * - * @return Action or null when ActionEndFlag or end of the stream - * @throws IOException - */ - public Action readAction() throws IOException { - { - int actionCode = readUI8(); - if (actionCode == 0) { - return new ActionEnd(); - } - if (actionCode == -1) { - return null; - } - int actionLength = 0; - if (actionCode >= 0x80) { - actionLength = readUI16(); - } - switch (actionCode) { - //SWF3 Actions - case 0x81: - return new ActionGotoFrame(this); - case 0x83: - return new ActionGetURL(actionLength, this, version); - case 0x04: - return new ActionNextFrame(); - case 0x05: - return new ActionPrevFrame(); - case 0x06: - return new ActionPlay(); - case 0x07: - return new ActionStop(); - case 0x08: - return new ActionToggleQuality(); - case 0x09: - return new ActionStopSounds(); - case 0x8A: - return new ActionWaitForFrame(this); - case 0x8B: - return new ActionSetTarget(actionLength, this, version); - case 0x8C: - return new ActionGoToLabel(actionLength, this, version); - //SWF4 Actions - case 0x96: - return new ActionPush(actionLength, this, version); - case 0x17: - return new ActionPop(); - case 0x0A: - return new ActionAdd(); - case 0x0B: - return new ActionSubtract(); - case 0x0C: - return new ActionMultiply(); - case 0x0D: - return new ActionDivide(); - case 0x0E: - return new ActionEquals(); - case 0x0F: - return new ActionLess(); - case 0x10: - return new ActionAnd(); - case 0x11: - return new ActionOr(); - case 0x12: - return new ActionNot(); - case 0x13: - return new ActionStringEquals(); - case 0x14: - return new ActionStringLength(); - case 0x21: - return new ActionStringAdd(); - case 0x15: - return new ActionStringExtract(); - case 0x29: - return new ActionStringLess(); - case 0x31: - return new ActionMBStringLength(); - case 0x35: - return new ActionMBStringExtract(); - case 0x18: - return new ActionToInteger(); - case 0x32: - return new ActionCharToAscii(); - case 0x33: - return new ActionAsciiToChar(); - case 0x36: - return new ActionMBCharToAscii(); - case 0x37: - return new ActionMBAsciiToChar(); - case 0x99: - return new ActionJump(this); - case 0x9D: - return new ActionIf(this); - case 0x9E: - return new ActionCall(); - case 0x1C: - return new ActionGetVariable(); - case 0x1D: - return new ActionSetVariable(); - case 0x9A: - return new ActionGetURL2(this); - case 0x9F: - return new ActionGotoFrame2(actionLength, this); - case 0x20: - return new ActionSetTarget2(); - case 0x22: - return new ActionGetProperty(); - case 0x23: - return new ActionSetProperty(); - case 0x24: - return new ActionCloneSprite(); - case 0x25: - return new ActionRemoveSprite(); - case 0x27: - return new ActionStartDrag(); - case 0x28: - return new ActionEndDrag(); - case 0x8D: - return new ActionWaitForFrame2(this); - case 0x26: - return new ActionTrace(); - case 0x34: - return new ActionGetTime(); - case 0x30: - return new ActionRandomNumber(); - //SWF5 Actions - case 0x3D: - return new ActionCallFunction(); - case 0x52: - return new ActionCallMethod(); - case 0x88: - return new ActionConstantPool(actionLength, this, version); - case 0x9B: - return new ActionDefineFunction(actionLength, this, version); - case 0x3C: - return new ActionDefineLocal(); - case 0x41: - return new ActionDefineLocal2(); - case 0x3A: - return new ActionDelete(); - case 0x3B: - return new ActionDelete2(); - case 0x46: - return new ActionEnumerate(); - case 0x49: - return new ActionEquals2(); - case 0x4E: - return new ActionGetMember(); - case 0x42: - return new ActionInitArray(); - case 0x43: - return new ActionInitObject(); - case 0x53: - return new ActionNewMethod(); - case 0x40: - return new ActionNewObject(); - case 0x4F: - return new ActionSetMember(); - case 0x45: - return new ActionTargetPath(); - case 0x94: - return new ActionWith(this, version); - case 0x4A: - return new ActionToNumber(); - case 0x4B: - return new ActionToString(); - case 0x44: - return new ActionTypeOf(); - case 0x47: - return new ActionAdd2(); - case 0x48: - return new ActionLess2(); - case 0x3F: - return new ActionModulo(); - case 0x60: - return new ActionBitAnd(); - case 0x63: - return new ActionBitLShift(); - case 0x61: - return new ActionBitOr(); - case 0x64: - return new ActionBitRShift(); - case 0x65: - return new ActionBitURShift(); - case 0x62: - return new ActionBitXor(); - case 0x51: - return new ActionDecrement(); - case 0x50: - return new ActionIncrement(); - case 0x4C: - return new ActionPushDuplicate(); - case 0x3E: - return new ActionReturn(); - case 0x4D: - return new ActionStackSwap(); - case 0x87: - return new ActionStoreRegister(this); - //SWF6 Actions - case 0x54: - return new ActionInstanceOf(); - case 0x55: - return new ActionEnumerate2(); - case 0x66: - return new ActionStrictEquals(); - case 0x67: - return new ActionGreater(); - case 0x68: - return new ActionStringGreater(); - //SWF7 Actions - case 0x8E: - return new ActionDefineFunction2(actionLength, this, version); - case 0x69: - return new ActionExtends(); - case 0x2B: - return new ActionCastOp(); - case 0x2C: - return new ActionImplementsOp(); - case 0x8F: - return new ActionTry(actionLength, this, version); - case 0x2A: - return new ActionThrow(); - default: - if (actionLength > 0) { - //skip(actionLength); - } - //throw new UnknownActionException(actionCode); - Action r = new ActionNop(); - r.actionCode = actionCode; - r.actionLength = actionLength; - return r; - //return new Action(actionCode, actionLength); - } - } - } + ensureCapacity(ret, ip); + int newip = -1; + if (!enableVariables && (!(ret.get(ip) instanceof ActionNop))) { + break; + } - /** - * Reads one MATRIX value from the stream - * - * @return MATRIX value - * @throws IOException - */ - public MATRIX readMatrix() throws IOException { - MATRIX ret = new MATRIX(); - ret.hasScale = readUB(1) == 1; - if (ret.hasScale) { - int NScaleBits = (int) readUB(5); - ret.scaleX = (int) readSB(NScaleBits); - ret.scaleY = (int) readSB(NScaleBits); - ret.bitsScale = NScaleBits; - } - ret.hasRotate = readUB(1) == 1; - if (ret.hasRotate) { - int NRotateBits = (int) readUB(5); - ret.rotateSkew0 = (int) readSB(NRotateBits); - ret.rotateSkew1 = (int) readSB(NRotateBits); - ret.bitsRotate = NRotateBits; - } - int NTranslateBits = (int) readUB(5); - ret.translateX = (int) readSB(NTranslateBits); - ret.translateY = (int) readSB(NTranslateBits); - ret.bitsTranslate = NTranslateBits; - alignByte(); - return ret; - } + if (a instanceof ActionConstantPool) { + if (cpool == null) { + cpool = new ConstantPool(); + } + cpool.setNew(((ActionConstantPool) a).constantPool); + } + Action beforeInsert = null; + ActionIf aif = null; + boolean goaif = false; + if (!a.isIgnored()) { + try { + if (a instanceof ActionIf) { + aif = (ActionIf) a; + GraphTargetItem top = null; + top = stack.pop(); - /** - * Reads one CXFORMWITHALPHA value from the stream - * - * @return CXFORMWITHALPHA value - * @throws IOException - */ - public CXFORMWITHALPHA readCXFORMWITHALPHA() throws IOException { - CXFORMWITHALPHA ret = new CXFORMWITHALPHA(); - ret.hasAddTerms = readUB(1) == 1; - ret.hasMultTerms = readUB(1) == 1; - int Nbits = (int) readUB(4); - ret.nbits = Nbits; - if (ret.hasMultTerms) { - ret.redMultTerm = (int) readSB(Nbits); - ret.greenMultTerm = (int) readSB(Nbits); - ret.blueMultTerm = (int) readSB(Nbits); - ret.alphaMultTerm = (int) readSB(Nbits); - } - if (ret.hasAddTerms) { - ret.redAddTerm = (int) readSB(Nbits); - ret.greenAddTerm = (int) readSB(Nbits); - ret.blueAddTerm = (int) readSB(Nbits); - ret.alphaAddTerm = (int) readSB(Nbits); - } - alignByte(); - return ret; - } + int nip = rri.getPos() + aif.offset; - /** - * Reads one CXFORM value from the stream - * - * @return CXFORM value - * @throws IOException - */ - public CXFORM readCXFORM() throws IOException { - CXFORM ret = new CXFORM(); - ret.hasAddTerms = readUB(1) == 1; - ret.hasMultTerms = readUB(1) == 1; - int Nbits = (int) readUB(4); - ret.nbits = Nbits; - if (ret.hasMultTerms) { - ret.redMultTerm = (int) readSB(Nbits); - ret.greenMultTerm = (int) readSB(Nbits); - ret.blueMultTerm = (int) readSB(Nbits); - } - if (ret.hasAddTerms) { - ret.redAddTerm = (int) readSB(Nbits); - ret.greenAddTerm = (int) readSB(Nbits); - ret.blueAddTerm = (int) readSB(Nbits); - } - alignByte(); - return ret; - } + if (decideBranch) { + System.out.print("newip " + nip + ", "); + System.out.print("Action: jump(j),ignore(i),compute(c)?"); + String next = sc.next(); + if (next.equals("j")) { + newip = rri.getPos() + aif.offset; + rri.setPos(newip); - /** - * Reads one CLIPEVENTFLAGS value from the stream - * - * @return CLIPEVENTFLAGS value - * @throws IOException - */ - public CLIPEVENTFLAGS readCLIPEVENTFLAGS() throws IOException { - CLIPEVENTFLAGS ret = new CLIPEVENTFLAGS(); - ret.clipEventKeyUp = readUB(1) == 1; - ret.clipEventKeyDown = readUB(1) == 1; - ret.clipEventMouseUp = readUB(1) == 1; - ret.clipEventMouseDown = readUB(1) == 1; - ret.clipEventMouseMove = readUB(1) == 1; - ret.clipEventUnload = readUB(1) == 1; - ret.clipEventEnterFrame = readUB(1) == 1; - ret.clipEventLoad = readUB(1) == 1; - ret.clipEventDragOver = readUB(1) == 1; - ret.clipEventRollOut = readUB(1) == 1; - ret.clipEventRollOver = readUB(1) == 1; - ret.clipEventReleaseOutside = readUB(1) == 1; - ret.clipEventRelease = readUB(1) == 1; - ret.clipEventPress = readUB(1) == 1; - ret.clipEventInitialize = readUB(1) == 1; - ret.clipEventData = readUB(1) == 1; - if (version >= 6) { - readUB(5); - ret.clipEventConstruct = readUB(1) == 1; - ret.clipEventKeyPress = readUB(1) == 1; - ret.clipEventDragOut = readUB(1) == 1; - readUB(8); - } - return ret; - } + } else if (next.equals("i")) { + } else if (next.equals("c")) { + goaif = true; + } + } else if (top.isCompileTime() && ((!top.isVariableComputed()) || (top.isVariableComputed() && enableVariables && (!notCompileTime)))) { + //if(top.isCompileTime()) { + //if(false){ + if (enableVariables) { + ((ActionIf) a).compileTime = true; + } + if (debugMode) { + System.out.print("is compiletime -> "); + } + if (top.toBoolean()) { + newip = rri.getPos() + aif.offset; + //rri.setPos(newip); + if (((!enableVariables) || (!top.isVariableComputed())) && (!aif.ignoreUsed)) { + a = new ActionJump(aif.offset); + a.setAddress(aif.getAddress(), SWF.DEFAULT_VERSION); + } + aif.jumpUsed = true; + if (aif.ignoreUsed) { + aif.compileTime = false; + } + if (debugMode) { + System.out.println("jump"); + } + } else { + aif.ignoreUsed = true; + if (aif.jumpUsed) { + aif.compileTime = false; + } + if (debugMode) { + System.out.println("ignore"); + } + if (((!enableVariables) || (!top.isVariableComputed())) && (!aif.jumpUsed)) { + //a = new ActionNop(); + aif.setIgnored(true); + //a.setAddress(aif.getAddress(), SWF.DEFAULT_VERSION); + } + } + if (((!enableVariables) || (!top.isVariableComputed())) && (!(aif.jumpUsed && aif.ignoreUsed))) { + List needed = top.getNeededSources(); + for (GraphSourceItemPos ig : needed) { + if (ig.item == null) { + continue; + } + if (ig.item instanceof ActionPush) { + if (!((ActionPush) ig.item).ignoredParts.contains(ig.pos)) { + ((ActionPush) ig.item).ignoredParts.add(ig.pos); - /** - * Reads one CLIPACTIONRECORD value from the stream - * - * @return CLIPACTIONRECORD value - * @throws IOException - */ - public CLIPACTIONRECORD readCLIPACTIONRECORD() throws IOException { - CLIPACTIONRECORD ret = new CLIPACTIONRECORD(); - ret.eventFlags = readCLIPEVENTFLAGS(); - if (ret.eventFlags.isClear()) { - return null; - } - long actionRecordSize = readUI32(); - if (ret.eventFlags.clipEventKeyPress) { - ret.keyCode = readUI8(); - actionRecordSize--; - } - ret.actionBytes = readBytes(actionRecordSize); - //ret.actions = (new SWFInputStream(new ByteArrayInputStream(readBytes(actionRecordSize)), version)).readActionList(); - return ret; - } + if (((ActionPush) ig.item).ignoredParts.size() == ((ActionPush) ig.item).values.size()) { + ((Action) ig.item).ignored = true; + } + } + } else { + ((Action) ig.item).ignored = true; + } + } + } - /** - * Reads one CLIPACTIONS value from the stream - * - * @return CLIPACTIONS value - * @throws IOException - */ - public CLIPACTIONS readCLIPACTIONS() throws IOException { - CLIPACTIONS ret = new CLIPACTIONS(); - readUI16();//reserved - ret.allEventFlags = readCLIPEVENTFLAGS(); - CLIPACTIONRECORD cr; - ret.clipActionRecords = new ArrayList(); - while ((cr = readCLIPACTIONRECORD()) != null) { - ret.clipActionRecords.add(cr); - } - return ret; - } - - /** - * Reads one COLORMATRIXFILTER value from the stream - * - * @return COLORMATRIXFILTER value - * @throws IOException - */ - public COLORMATRIXFILTER readCOLORMATRIXFILTER() throws IOException { - COLORMATRIXFILTER ret = new COLORMATRIXFILTER(); - ret.matrix = new float[20]; - for (int i = 0; i < 20; i++) { - ret.matrix[i] = readFLOAT(); - } - return ret; - } - - /** - * Reads one RGBA value from the stream - * - * @return RGBA value - * @throws IOException - */ - public RGBA readRGBA() throws IOException { - RGBA ret = new RGBA(); - ret.red = readUI8(); - ret.green = readUI8(); - ret.blue = readUI8(); - ret.alpha = readUI8(); - return ret; - } - - /** - * Reads one ARGB value from the stream - * - * @return ARGB value - * @throws IOException - */ - public ARGB readARGB() throws IOException { - ARGB ret = new ARGB(); - ret.alpha = readUI8(); - ret.red = readUI8(); - ret.green = readUI8(); - ret.blue = readUI8(); - return ret; - } - - /** - * Reads one RGB value from the stream - * - * @return RGB value - * @throws IOException - */ - public RGB readRGB() throws IOException { - RGB ret = new RGB(); - ret.red = readUI8(); - ret.green = readUI8(); - ret.blue = readUI8(); - return ret; - } - - /** - * Reads one CONVOLUTIONFILTER value from the stream - * - * @return CONVOLUTIONFILTER value - * @throws IOException - */ - public CONVOLUTIONFILTER readCONVOLUTIONFILTER() throws IOException { - CONVOLUTIONFILTER ret = new CONVOLUTIONFILTER(); - ret.matrixX = readUI8(); - ret.matrixY = readUI8(); - ret.divisor = readFLOAT(); - ret.bias = readFLOAT(); - ret.matrix = new float[ret.matrixX][ret.matrixY]; - for (int x = 0; x < ret.matrixX; x++) { - for (int y = 0; y < ret.matrixY; y++) { - ret.matrix[x][y] = readFLOAT(); - } - } - ret.defaultColor = readRGBA(); - readUB(6);//reserved - ret.clamp = readUB(1) == 1; - ret.preserveAlpha = readUB(1) == 1; - return ret; - } - - /** - * Reads one BLURFILTER value from the stream - * - * @return BLURFILTER value - * @throws IOException - */ - public BLURFILTER readBLURFILTER() throws IOException { - BLURFILTER ret = new BLURFILTER(); - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.passes = (int) readUB(5); - readUB(3); //reserved - return ret; - } - - /** - * Reads one DROPSHADOWFILTER value from the stream - * - * @return DROPSHADOWFILTER value - * @throws IOException - */ - public DROPSHADOWFILTER readDROPSHADOWFILTER() throws IOException { - DROPSHADOWFILTER ret = new DROPSHADOWFILTER(); - ret.dropShadowColor = readRGBA(); - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.angle = readFIXED(); - ret.distance = readFIXED(); - ret.strength = readFIXED8(); - ret.innerShadow = readUB(1) == 1; - ret.knockout = readUB(1) == 1; - ret.compositeSource = readUB(1) == 1; - ret.passes = (int) readUB(5); - return ret; - } - - /** - * Reads one GLOWFILTER value from the stream - * - * @return GLOWFILTER value - * @throws IOException - */ - public GLOWFILTER readGLOWFILTER() throws IOException { - GLOWFILTER ret = new GLOWFILTER(); - ret.glowColor = readRGBA(); - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.strength = readFIXED8(); - ret.innerGlow = readUB(1) == 1; - ret.knockout = readUB(1) == 1; - ret.compositeSource = readUB(1) == 1; - ret.passes = (int) readUB(5); - return ret; - } - - /** - * Reads one BEVELFILTER value from the stream - * - * @return BEVELFILTER value - * @throws IOException - */ - public BEVELFILTER readBEVELFILTER() throws IOException { - BEVELFILTER ret = new BEVELFILTER(); - ret.shadowColor = readRGBA(); - ret.highlightColor = readRGBA(); - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.angle = readFIXED(); - ret.distance = readFIXED(); - ret.strength = readFIXED8(); - ret.innerShadow = readUB(1) == 1; - ret.knockout = readUB(1) == 1; - ret.compositeSource = readUB(1) == 1; - ret.onTop = readUB(1) == 1; - ret.passes = (int) readUB(4); - return ret; - } - - /** - * Reads one GRADIENTGLOWFILTER value from the stream - * - * @return GRADIENTGLOWFILTER value - * @throws IOException - */ - public GRADIENTGLOWFILTER readGRADIENTGLOWFILTER() throws IOException { - GRADIENTGLOWFILTER ret = new GRADIENTGLOWFILTER(); - int numColors = readUI8(); - ret.gradientColors = new RGBA[numColors]; - ret.gradientRatio = new int[numColors]; - for (int i = 0; i < numColors; i++) { - ret.gradientColors[i] = readRGBA(); - } - for (int i = 0; i < numColors; i++) { - ret.gradientRatio[i] = readUI8(); - } - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.angle = readFIXED(); - ret.distance = readFIXED(); - ret.strength = readFIXED8(); - ret.innerShadow = readUB(1) == 1; - ret.knockout = readUB(1) == 1; - ret.compositeSource = readUB(1) == 1; - ret.onTop = readUB(1) == 1; - ret.passes = (int) readUB(4); - return ret; - } - - /** - * Reads one GRADIENTBEVELFILTER value from the stream - * - * @return GRADIENTBEVELFILTER value - * @throws IOException - */ - public GRADIENTBEVELFILTER readGRADIENTBEVELFILTER() throws IOException { - GRADIENTBEVELFILTER ret = new GRADIENTBEVELFILTER(); - int numColors = readUI8(); - ret.gradientColors = new RGBA[numColors]; - ret.gradientRatio = new int[numColors]; - for (int i = 0; i < numColors; i++) { - ret.gradientColors[i] = readRGBA(); - } - for (int i = 0; i < numColors; i++) { - ret.gradientRatio[i] = readUI8(); - } - ret.blurX = readFIXED(); - ret.blurY = readFIXED(); - ret.angle = readFIXED(); - ret.distance = readFIXED(); - ret.strength = readFIXED8(); - ret.innerShadow = readUB(1) == 1; - ret.knockout = readUB(1) == 1; - ret.compositeSource = readUB(1) == 1; - ret.onTop = readUB(1) == 1; - ret.passes = (int) readUB(4); - return ret; - } - - /** - * Reads list of FILTER values from the stream - * - * @return List of FILTER values - * @throws IOException - */ - public List readFILTERLIST() throws IOException { - List ret = new ArrayList(); - int numberOfFilters = readUI8(); - for (int i = 0; i < numberOfFilters; i++) { - ret.add(readFILTER()); - } - return ret; - } - - /** - * Reads one FILTER value from the stream - * - * @return FILTER value - * @throws IOException - */ - public FILTER readFILTER() throws IOException { - int filterId = readUI8(); - switch (filterId) { - case 0: - return readDROPSHADOWFILTER(); - case 1: - return readBLURFILTER(); - case 2: - return readGLOWFILTER(); - case 3: - return readBEVELFILTER(); - case 4: - return readGRADIENTGLOWFILTER(); - case 5: - return readCONVOLUTIONFILTER(); - case 6: - return readCOLORMATRIXFILTER(); - case 7: - return readGRADIENTBEVELFILTER(); - default: - return null; - } - } - - /** - * Reads list of BUTTONRECORD values from the stream - * - * @param inDefineButton2 Whether read from inside of DefineButton2Tag or not - * @return List of BUTTONRECORD values - * @throws IOException - */ - public List readBUTTONRECORDList(boolean inDefineButton2) throws IOException { - List ret = new ArrayList(); - BUTTONRECORD br; - while ((br = readBUTTONRECORD(inDefineButton2)) != null) { - ret.add(br); - } - return ret; - } - - /** - * Reads one BUTTONRECORD value from the stream - * - * @return BUTTONRECORD value - * @throws IOException - */ - public BUTTONRECORD readBUTTONRECORD(boolean inDefineButton2) throws IOException { - BUTTONRECORD ret = new BUTTONRECORD(); - int res = (int) readUB(2); //reserved - ret.buttonHasBlendMode = readUB(1) == 1; - ret.buttonHasFilterList = readUB(1) == 1; - ret.buttonStateHitTest = readUB(1) == 1; - ret.buttonStateDown = readUB(1) == 1; - ret.buttonStateOver = readUB(1) == 1; - ret.buttonStateUp = readUB(1) == 1; - - if (!ret.buttonHasBlendMode) { - if (!ret.buttonHasFilterList) { - if (!ret.buttonStateHitTest) { - if (!ret.buttonStateDown) { - if (!ret.buttonStateOver) { - if (!ret.buttonStateUp) { - if (res == 0) { - return null; + } else { + if (debugMode) { + System.out.println("goaif"); + } + //throw new RuntimeException("goaif"); + goaif = true; } - } - } - } + } else if (a instanceof ActionJump) { + newip = rri.getPos() + ((ActionJump) a).offset; + //if(newip>=0){ + //rri.setPos(newip); + //} + } else { + //return in for..in, TODO:Handle this better way + if (((a instanceof ActionEquals) || (a instanceof ActionEquals2)) && (stack.size() == 1) && (stack.peek() instanceof DirectValueTreeItem)) { + stack.push(new DirectValueTreeItem(null, 0, new Null(), new ArrayList())); + } + if ((a instanceof ActionStoreRegister) && stack.isEmpty()) { + stack.push(new DirectValueTreeItem(null, 0, new Null(), new ArrayList())); + } + a.translate(localData, stack, output); + } + } catch (RuntimeException ex) { + if (!enableVariables) { + throw ex; + } + log.log(Level.SEVERE, "Disassembly exception", ex); + break; + } } - } - } + int nopos = -1; + for (int i = 0; i < actionLen; i++) { + ensureCapacity(ret, ip + i); + if (a instanceof ActionNop) { + int prevPos = (int) a.getAddress(); + a = new ActionNop(); + a.setAddress(prevPos, SWF.DEFAULT_VERSION); + nopos++; + if (nopos > 0) { + a.setAddress(a.getAddress() + 1, SWF.DEFAULT_VERSION); + } - ret.characterId = readUI16(); - ret.placeDepth = readUI16(); - ret.placeMatrix = readMatrix(); - if (inDefineButton2) { - ret.colorTransform = readCXFORMWITHALPHA(); - if (ret.buttonHasFilterList) { - ret.filterList = readFILTERLIST(); - } - if (ret.buttonHasBlendMode) { - ret.blendMode = readUI8(); - } - } - return ret; - } + if (i == 0) { + a.beforeInsert = beforeInsert; + } + } else { + a.beforeInsert = beforeInsert; + } + ret.set(ip + i, a); + } - /** - * Reads list of BUTTONCONDACTION values from the stream - * - * @return List of BUTTONCONDACTION values - * @throws IOException - */ - public List readBUTTONCONDACTIONList() throws IOException { - List ret = new ArrayList(); - BUTTONCONDACTION bc; - while (!(bc = readBUTTONCONDACTION()).isLast) { - ret.add(bc); - } - ret.add(bc); - return ret; - } + if (a instanceof ActionEnd) { + break; + } + if (newip > -1) { + ip = newip; + } else { + ip = ip + info; //(int) actionLen; + } + rri.setPos(ip); + filePos = rri.getPos(); + if (goaif) { + if (aif.ignoreUsed && aif.jumpUsed) { + break; + } + aif.ignoreUsed = true; + aif.jumpUsed = true; + int oldPos = rri.getPos(); + Stack substack = (Stack) stack.clone(); + if (readActionListAtPos(true, enableVariables, localData, substack, cpool, sis, rri, rri.getPos() + aif.offset, ret, startIp)) { + retv = true; + } + rri.setPos(oldPos); + notCompileTime = true; + } + prevIp = ip; + } + return retv; + } - /** - * Reads one BUTTONCONDACTION value from the stream - * - * @return BUTTONCONDACTION value - * @throws IOException - */ - public BUTTONCONDACTION readBUTTONCONDACTION() throws IOException { - BUTTONCONDACTION ret = new BUTTONCONDACTION(); - int condActionSize = readUI16(); - ret.isLast = condActionSize <= 0; - ret.condIdleToOverDown = readUB(1) == 1; - ret.condOutDownToIdle = readUB(1) == 1; - ret.condOutDownToOverDown = readUB(1) == 1; - ret.condOverDownToOutDown = readUB(1) == 1; - ret.condOverDownToOverUp = readUB(1) == 1; - ret.condOverUpToOverDown = readUB(1) == 1; - ret.condOverUpToIddle = readUB(1) == 1; - ret.condIdleToOverUp = readUB(1) == 1; - ret.condKeyPress = (int) readUB(7); - ret.condOverDownToIddle = readUB(1) == 1; - if (condActionSize <= 0) { - ret.actionBytes = readBytes(available()); - } else { - ret.actionBytes = readBytes(condActionSize - 4); - } - //ret.actions = readActionList(); - return ret; - } + private static void ensureCapacity(List ret, int index) { + int pos = ret.size(); + while (ret.size() <= index) { + Action a = new ActionNop(); + a.setAddress(pos++, SWF.DEFAULT_VERSION); + ret.add(a); + } + } - /** - * Reads one GRADRECORD value from the stream - * - * @return GRADRECORD value - * @throws IOException - */ - public GRADRECORD readGRADRECORD(int shapeNum) throws IOException { - GRADRECORD ret = new GRADRECORD(); - ret.ratio = readUI8(); - if (shapeNum >= 3) { - ret.colorA = readRGBA(); - } else { - ret.color = readRGB(); - } - return ret; - } + private static void dumpTag(PrintStream out, int version, Tag tag, int level) { + StringBuilder sb = new StringBuilder(); + sb.append(Helper.formatHex((int) tag.getPos(), 8)); + sb.append(": "); + sb.append(Helper.indent(level, "")); + sb.append(Helper.format(tag.toString(), 25 - 2 * level)); + sb.append(" tagId="); + sb.append(Helper.formatInt(tag.getId(), 3)); + sb.append(" len="); + sb.append(Helper.formatInt((int) tag.getOrigDataLength(), 8)); + sb.append(" "); + sb.append(Helper.bytesToHexString(64, tag.getData(version), 0)); + out.println(sb.toString()); +// out.println(Utils.formatHex((int)tag.getPos(), 8) + ": " + Utils.indent(level, "") + Utils.format(tag.toString(), 25 - 2*level) + " tagId="+tag.getId()+" len="+tag.getOrigDataLength()+": "+Utils.bytesToHexString(64, tag.getData(version), 0)); + if (tag.hasSubTags()) { + for (Tag subTag : tag.getSubTags()) { + dumpTag(out, version, subTag, level + 1); + } + } + } - /** - * Reads one GRADIENT value from the stream - * - * @return GRADIENT value - * @throws IOException - */ - public GRADIENT readGRADIENT(int shapeNum) throws IOException { - GRADIENT ret = new GRADIENT(); - ret.spreadMode = (int) readUB(2); - ret.interPolationMode = (int) readUB(2); - int numGradients = (int) readUB(4); - ret.gradientRecords = new GRADRECORD[numGradients]; - for (int i = 0; i < numGradients; i++) { - ret.gradientRecords[i] = readGRADRECORD(shapeNum); + /** + * Reads list of tags from the stream. Reading ends with End tag(=0) or end + * of the stream. + * + * @return List of tags + * @throws IOException + */ + public List readTagList(int level) throws IOException { + List tags = new ArrayList(); + Tag tag; + Tag previousTag = null; + while (true) { + long pos = getPos(); + tag = readTag(level, pos); + if (tag == null) { + break; + } + tags.add(tag); + if (Main.dump_tags && level == 0) { + dumpTag(System.out, version, tag, level); + } + tag.previousTag = previousTag; + previousTag = tag; + } + return tags; + } - } - return ret; - } + /** + * Reads one Tag from the stream + * + * @return Tag or null when End tag + * @throws IOException + */ + public Tag readTag(int level, long pos) throws IOException { + int tagIDTagLength = readUI16(); + int tagID = (tagIDTagLength) >> 6; + if (tagID == 0) { + return null; + } + long tagLength = (tagIDTagLength & 0x003F); + boolean readLong = false; + if (tagLength == 0x3f) { + tagLength = readSI32(); + readLong = true; + } + byte data[] = readBytes((int) tagLength); + Tag ret; + try { + switch (tagID) { + case 0: + ret = new EndTag(data, version, pos); + break; + case 1: + ret = new ShowFrameTag(pos); + break; + case 2: + ret = new DefineShapeTag(data, version, pos); + break; + //case 3 + case 4: + ret = new PlaceObjectTag(data, version, pos); + break; + case 5: + ret = new RemoveObjectTag(data, version, pos); + break; + case 6: + ret = new DefineBitsTag(data, version, pos); + break; + case 7: + ret = new DefineButtonTag(data, version, pos); + break; + case 8: + ret = new JPEGTablesTag(data, pos); + break; + case 9: + ret = new SetBackgroundColorTag(data, version, pos); + break; + case 10: + ret = new DefineFontTag(data, version, pos); + break; + case 11: + ret = new DefineTextTag(data, version, pos); + break; + case 12: + ret = new DoActionTag(data, version, pos); + break; + case 13: + ret = new DefineFontInfoTag(data, version, pos); + break; + case 14: + ret = new DefineSoundTag(data, version, pos); + break; + case 15: + ret = new StartSoundTag(data, version, pos); + break; + //case 16 + case 17: + ret = new DefineButtonSoundTag(data, version, pos); + break; + case 18: + ret = new SoundStreamHeadTag(data, version, pos); + break; + case 19: + ret = new SoundStreamBlockTag(data, version, pos); + break; + case 21: + ret = new DefineBitsJPEG2Tag(data, version, pos); + break; + case 20: + ret = new DefineBitsLosslessTag(data, version, pos); + break; + case 22: + ret = new DefineShape2Tag(data, version, pos); + break; + case 23: + ret = new DefineButtonCxformTag(data, version, pos); + break; + case 24: + ret = new ProtectTag(data, version, pos); + break; + //case 25: + case 26: + ret = new PlaceObject2Tag(data, version, pos); + break; + //case 27: + case 28: + ret = new RemoveObject2Tag(data, version, pos); + break; + //case 29: + //case 30: + //case 31: + case 32: + ret = new DefineShape3Tag(data, version, pos); + break; + case 33: + ret = new DefineText2Tag(data, version, pos); + break; + case 34: + ret = new DefineButton2Tag(data, version, pos); + break; + case 35: + ret = new DefineBitsJPEG3Tag(data, version, pos); + break; + case 36: + ret = new DefineBitsLossless2Tag(data, version, pos); + break; + case 37: + ret = new DefineEditTextTag(data, version, pos); + break; + //case 38: + case 39: + ret = new DefineSpriteTag(data, version, level, pos); + break; + //case 40: + case 41: + ret = new ProductInfoTag(data, version, pos); + break; + //case 42: + case 43: + ret = new FrameLabelTag(data, version, pos); + break; + //case 44: + case 45: + ret = new SoundStreamHead2Tag(data, version, pos); + break; + case 46: + ret = new DefineMorphShapeTag(data, version, pos); + break; + //case 47: + case 48: + ret = new DefineFont2Tag(data, version, pos); + break; + //case 49-55: + case 56: + ret = new ExportAssetsTag(data, version, pos); + break; + case 57: + ret = new ImportAssetsTag(data, version, pos); + break; + case 58: + ret = new EnableDebuggerTag(data, version, pos); + break; + case 59: + ret = new DoInitActionTag(data, version, pos); + break; + case 60: + ret = new DefineVideoStreamTag(data, version, pos); + break; + case 61: + ret = new VideoFrameTag(data, version, pos); + break; + case 62: + ret = new DefineFontInfo2Tag(data, version, pos); + break; + case 63: + ret = new DebugIDTag(data, version, pos); + break; + case 64: + ret = new EnableDebugger2Tag(data, version, pos); + break; + case 65: + ret = new ScriptLimitsTag(data, version, pos); + break; + case 66: + ret = new SetTabIndexTag(data, version, pos); + break; + //case 67-68: + case 69: + ret = new FileAttributesTag(data, version, pos); + break; + case 70: + ret = new PlaceObject3Tag(data, version, pos); + break; + case 71: + ret = new ImportAssets2Tag(data, version, pos); + break; + //case 72: + case 73: + ret = new DefineFontAlignZonesTag(data, version, pos); + break; + case 74: + ret = new CSMTextSettingsTag(data, version, pos); + break; + case 75: + ret = new DefineFont3Tag(data, version, pos); + break; + case 76: + ret = new SymbolClassTag(data, version, pos); + break; + case 77: + ret = new MetadataTag(data, version, pos); + break; + case 78: + ret = new DefineScalingGridTag(data, version, pos); + break; + //case 79-81: + case 82: + ret = new DoABCTag(data, version, pos); + break; + case 83: + ret = new DefineShape4Tag(data, version, pos); + break; + case 84: + ret = new DefineMorphShape2Tag(data, version, pos); + break; + //case 85: + case 86: + ret = new DefineSceneAndFrameLabelDataTag(data, version, pos); + break; + case 87: + ret = new DefineBinaryDataTag(data, version, pos); + break; + case 88: + ret = new DefineFontNameTag(data, version, pos); + break; + case 89: + ret = new StartSound2Tag(data, version, pos); + break; + case 90: + ret = new DefineBitsJPEG4Tag(data, version, pos); + break; + case 91: + ret = new DefineFont4Tag(data, version, pos); + break; + default: + ret = new Tag(tagID, "Unknown", data, pos); + } + } catch (Exception ex) { + Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "Error during tag reading", ex); + ret = new Tag(tagID, "ErrorTag", data, pos); + } + ret.forceWriteAsLong = readLong; + byte dataNew[] = ret.getData(version); - /** - * Reads one FOCALGRADIENT value from the stream - * - * @return FOCALGRADIENT value - * @throws IOException - */ - public FOCALGRADIENT readFOCALGRADIENT(int shapeNum) throws IOException { - FOCALGRADIENT ret = new FOCALGRADIENT(); - ret.spreadMode = (int) readUB(2); - ret.interPolationMode = (int) readUB(2); - int numGradients = (int) readUB(4); - ret.gradientRecords = new GRADRECORD[numGradients]; - for (int i = 0; i < numGradients; i++) { - ret.gradientRecords[i] = readGRADRECORD(shapeNum); - } - ret.focalPoint = readFIXED8(); - return ret; - } + int ignoreFirst = 0; + for (int i = 0; i < data.length; i++) { + if (i >= dataNew.length) { + break; + } + if (dataNew[i] != data[i]) { + if (ignoreFirst > 0) { + ignoreFirst--; + continue; + } + String e = ""; + e = ("TAG " + ret.toString() + " WRONG, "); + for (int j = i - 10; j <= i + 5; j++) { + while (j < 0) { + j++; + } + if (j >= data.length) { + break; + } + if (j >= dataNew.length) { + break; + } + if (j >= i) { + e += (Long.toHexString(data[j] & 0xff) + " ( is " + Long.toHexString(dataNew[j] & 0xff) + ") "); + } else { + e += (Long.toHexString(data[j] & 0xff) + " "); + } + } + log.fine(e); + } + } + return ret; + } - /** - * Reads one FILLSTYLE value from the stream - * - * @return FILLSTYLE value - * @throws IOException - */ - public FILLSTYLE readFILLSTYLE(int shapeNum) throws IOException { - FILLSTYLE ret = new FILLSTYLE(); - ret.fillStyleType = readUI8(); - if (ret.fillStyleType == FILLSTYLE.SOLID) { - if (shapeNum >= 3) { + /** + * Reads one Action from the stream + * + * @return Action or null when ActionEndFlag or end of the stream + * @throws IOException + */ + public Action readAction() throws IOException { + { + int actionCode = readUI8(); + if (actionCode == 0) { + return new ActionEnd(); + } + if (actionCode == -1) { + return null; + } + int actionLength = 0; + if (actionCode >= 0x80) { + actionLength = readUI16(); + } + switch (actionCode) { + //SWF3 Actions + case 0x81: + return new ActionGotoFrame(this); + case 0x83: + return new ActionGetURL(actionLength, this, version); + case 0x04: + return new ActionNextFrame(); + case 0x05: + return new ActionPrevFrame(); + case 0x06: + return new ActionPlay(); + case 0x07: + return new ActionStop(); + case 0x08: + return new ActionToggleQuality(); + case 0x09: + return new ActionStopSounds(); + case 0x8A: + return new ActionWaitForFrame(this); + case 0x8B: + return new ActionSetTarget(actionLength, this, version); + case 0x8C: + return new ActionGoToLabel(actionLength, this, version); + //SWF4 Actions + case 0x96: + return new ActionPush(actionLength, this, version); + case 0x17: + return new ActionPop(); + case 0x0A: + return new ActionAdd(); + case 0x0B: + return new ActionSubtract(); + case 0x0C: + return new ActionMultiply(); + case 0x0D: + return new ActionDivide(); + case 0x0E: + return new ActionEquals(); + case 0x0F: + return new ActionLess(); + case 0x10: + return new ActionAnd(); + case 0x11: + return new ActionOr(); + case 0x12: + return new ActionNot(); + case 0x13: + return new ActionStringEquals(); + case 0x14: + return new ActionStringLength(); + case 0x21: + return new ActionStringAdd(); + case 0x15: + return new ActionStringExtract(); + case 0x29: + return new ActionStringLess(); + case 0x31: + return new ActionMBStringLength(); + case 0x35: + return new ActionMBStringExtract(); + case 0x18: + return new ActionToInteger(); + case 0x32: + return new ActionCharToAscii(); + case 0x33: + return new ActionAsciiToChar(); + case 0x36: + return new ActionMBCharToAscii(); + case 0x37: + return new ActionMBAsciiToChar(); + case 0x99: + return new ActionJump(this); + case 0x9D: + return new ActionIf(this); + case 0x9E: + return new ActionCall(); + case 0x1C: + return new ActionGetVariable(); + case 0x1D: + return new ActionSetVariable(); + case 0x9A: + return new ActionGetURL2(this); + case 0x9F: + return new ActionGotoFrame2(actionLength, this); + case 0x20: + return new ActionSetTarget2(); + case 0x22: + return new ActionGetProperty(); + case 0x23: + return new ActionSetProperty(); + case 0x24: + return new ActionCloneSprite(); + case 0x25: + return new ActionRemoveSprite(); + case 0x27: + return new ActionStartDrag(); + case 0x28: + return new ActionEndDrag(); + case 0x8D: + return new ActionWaitForFrame2(this); + case 0x26: + return new ActionTrace(); + case 0x34: + return new ActionGetTime(); + case 0x30: + return new ActionRandomNumber(); + //SWF5 Actions + case 0x3D: + return new ActionCallFunction(); + case 0x52: + return new ActionCallMethod(); + case 0x88: + return new ActionConstantPool(actionLength, this, version); + case 0x9B: + return new ActionDefineFunction(actionLength, this, version); + case 0x3C: + return new ActionDefineLocal(); + case 0x41: + return new ActionDefineLocal2(); + case 0x3A: + return new ActionDelete(); + case 0x3B: + return new ActionDelete2(); + case 0x46: + return new ActionEnumerate(); + case 0x49: + return new ActionEquals2(); + case 0x4E: + return new ActionGetMember(); + case 0x42: + return new ActionInitArray(); + case 0x43: + return new ActionInitObject(); + case 0x53: + return new ActionNewMethod(); + case 0x40: + return new ActionNewObject(); + case 0x4F: + return new ActionSetMember(); + case 0x45: + return new ActionTargetPath(); + case 0x94: + return new ActionWith(this, version); + case 0x4A: + return new ActionToNumber(); + case 0x4B: + return new ActionToString(); + case 0x44: + return new ActionTypeOf(); + case 0x47: + return new ActionAdd2(); + case 0x48: + return new ActionLess2(); + case 0x3F: + return new ActionModulo(); + case 0x60: + return new ActionBitAnd(); + case 0x63: + return new ActionBitLShift(); + case 0x61: + return new ActionBitOr(); + case 0x64: + return new ActionBitRShift(); + case 0x65: + return new ActionBitURShift(); + case 0x62: + return new ActionBitXor(); + case 0x51: + return new ActionDecrement(); + case 0x50: + return new ActionIncrement(); + case 0x4C: + return new ActionPushDuplicate(); + case 0x3E: + return new ActionReturn(); + case 0x4D: + return new ActionStackSwap(); + case 0x87: + return new ActionStoreRegister(this); + //SWF6 Actions + case 0x54: + return new ActionInstanceOf(); + case 0x55: + return new ActionEnumerate2(); + case 0x66: + return new ActionStrictEquals(); + case 0x67: + return new ActionGreater(); + case 0x68: + return new ActionStringGreater(); + //SWF7 Actions + case 0x8E: + return new ActionDefineFunction2(actionLength, this, version); + case 0x69: + return new ActionExtends(); + case 0x2B: + return new ActionCastOp(); + case 0x2C: + return new ActionImplementsOp(); + case 0x8F: + return new ActionTry(actionLength, this, version); + case 0x2A: + return new ActionThrow(); + default: + if (actionLength > 0) { + //skip(actionLength); + } + //throw new UnknownActionException(actionCode); + Action r = new ActionNop(); + r.actionCode = actionCode; + r.actionLength = actionLength; + return r; + //return new Action(actionCode, actionLength); + } + } + } + + /** + * Reads one MATRIX value from the stream + * + * @return MATRIX value + * @throws IOException + */ + public MATRIX readMatrix() throws IOException { + MATRIX ret = new MATRIX(); + ret.hasScale = readUB(1) == 1; + if (ret.hasScale) { + int NScaleBits = (int) readUB(5); + ret.scaleX = (int) readSB(NScaleBits); + ret.scaleY = (int) readSB(NScaleBits); + ret.bitsScale = NScaleBits; + } + ret.hasRotate = readUB(1) == 1; + if (ret.hasRotate) { + int NRotateBits = (int) readUB(5); + ret.rotateSkew0 = (int) readSB(NRotateBits); + ret.rotateSkew1 = (int) readSB(NRotateBits); + ret.bitsRotate = NRotateBits; + } + int NTranslateBits = (int) readUB(5); + ret.translateX = (int) readSB(NTranslateBits); + ret.translateY = (int) readSB(NTranslateBits); + ret.bitsTranslate = NTranslateBits; + alignByte(); + return ret; + } + + /** + * Reads one CXFORMWITHALPHA value from the stream + * + * @return CXFORMWITHALPHA value + * @throws IOException + */ + public CXFORMWITHALPHA readCXFORMWITHALPHA() throws IOException { + CXFORMWITHALPHA ret = new CXFORMWITHALPHA(); + ret.hasAddTerms = readUB(1) == 1; + ret.hasMultTerms = readUB(1) == 1; + int Nbits = (int) readUB(4); + ret.nbits = Nbits; + if (ret.hasMultTerms) { + ret.redMultTerm = (int) readSB(Nbits); + ret.greenMultTerm = (int) readSB(Nbits); + ret.blueMultTerm = (int) readSB(Nbits); + ret.alphaMultTerm = (int) readSB(Nbits); + } + if (ret.hasAddTerms) { + ret.redAddTerm = (int) readSB(Nbits); + ret.greenAddTerm = (int) readSB(Nbits); + ret.blueAddTerm = (int) readSB(Nbits); + ret.alphaAddTerm = (int) readSB(Nbits); + } + alignByte(); + return ret; + } + + /** + * Reads one CXFORM value from the stream + * + * @return CXFORM value + * @throws IOException + */ + public CXFORM readCXFORM() throws IOException { + CXFORM ret = new CXFORM(); + ret.hasAddTerms = readUB(1) == 1; + ret.hasMultTerms = readUB(1) == 1; + int Nbits = (int) readUB(4); + ret.nbits = Nbits; + if (ret.hasMultTerms) { + ret.redMultTerm = (int) readSB(Nbits); + ret.greenMultTerm = (int) readSB(Nbits); + ret.blueMultTerm = (int) readSB(Nbits); + } + if (ret.hasAddTerms) { + ret.redAddTerm = (int) readSB(Nbits); + ret.greenAddTerm = (int) readSB(Nbits); + ret.blueAddTerm = (int) readSB(Nbits); + } + alignByte(); + return ret; + } + + /** + * Reads one CLIPEVENTFLAGS value from the stream + * + * @return CLIPEVENTFLAGS value + * @throws IOException + */ + public CLIPEVENTFLAGS readCLIPEVENTFLAGS() throws IOException { + CLIPEVENTFLAGS ret = new CLIPEVENTFLAGS(); + ret.clipEventKeyUp = readUB(1) == 1; + ret.clipEventKeyDown = readUB(1) == 1; + ret.clipEventMouseUp = readUB(1) == 1; + ret.clipEventMouseDown = readUB(1) == 1; + ret.clipEventMouseMove = readUB(1) == 1; + ret.clipEventUnload = readUB(1) == 1; + ret.clipEventEnterFrame = readUB(1) == 1; + ret.clipEventLoad = readUB(1) == 1; + ret.clipEventDragOver = readUB(1) == 1; + ret.clipEventRollOut = readUB(1) == 1; + ret.clipEventRollOver = readUB(1) == 1; + ret.clipEventReleaseOutside = readUB(1) == 1; + ret.clipEventRelease = readUB(1) == 1; + ret.clipEventPress = readUB(1) == 1; + ret.clipEventInitialize = readUB(1) == 1; + ret.clipEventData = readUB(1) == 1; + if (version >= 6) { + readUB(5); + ret.clipEventConstruct = readUB(1) == 1; + ret.clipEventKeyPress = readUB(1) == 1; + ret.clipEventDragOut = readUB(1) == 1; + readUB(8); + } + return ret; + } + + /** + * Reads one CLIPACTIONRECORD value from the stream + * + * @return CLIPACTIONRECORD value + * @throws IOException + */ + public CLIPACTIONRECORD readCLIPACTIONRECORD() throws IOException { + CLIPACTIONRECORD ret = new CLIPACTIONRECORD(); + ret.eventFlags = readCLIPEVENTFLAGS(); + if (ret.eventFlags.isClear()) { + return null; + } + long actionRecordSize = readUI32(); + if (ret.eventFlags.clipEventKeyPress) { + ret.keyCode = readUI8(); + actionRecordSize--; + } + ret.actionBytes = readBytes(actionRecordSize); + //ret.actions = (new SWFInputStream(new ByteArrayInputStream(readBytes(actionRecordSize)), version)).readActionList(); + return ret; + } + + /** + * Reads one CLIPACTIONS value from the stream + * + * @return CLIPACTIONS value + * @throws IOException + */ + public CLIPACTIONS readCLIPACTIONS() throws IOException { + CLIPACTIONS ret = new CLIPACTIONS(); + readUI16();//reserved + ret.allEventFlags = readCLIPEVENTFLAGS(); + CLIPACTIONRECORD cr; + ret.clipActionRecords = new ArrayList(); + while ((cr = readCLIPACTIONRECORD()) != null) { + ret.clipActionRecords.add(cr); + } + return ret; + } + + /** + * Reads one COLORMATRIXFILTER value from the stream + * + * @return COLORMATRIXFILTER value + * @throws IOException + */ + public COLORMATRIXFILTER readCOLORMATRIXFILTER() throws IOException { + COLORMATRIXFILTER ret = new COLORMATRIXFILTER(); + ret.matrix = new float[20]; + for (int i = 0; i < 20; i++) { + ret.matrix[i] = readFLOAT(); + } + return ret; + } + + /** + * Reads one RGBA value from the stream + * + * @return RGBA value + * @throws IOException + */ + public RGBA readRGBA() throws IOException { + RGBA ret = new RGBA(); + ret.red = readUI8(); + ret.green = readUI8(); + ret.blue = readUI8(); + ret.alpha = readUI8(); + return ret; + } + + /** + * Reads one ARGB value from the stream + * + * @return ARGB value + * @throws IOException + */ + public ARGB readARGB() throws IOException { + ARGB ret = new ARGB(); + ret.alpha = readUI8(); + ret.red = readUI8(); + ret.green = readUI8(); + ret.blue = readUI8(); + return ret; + } + + /** + * Reads one RGB value from the stream + * + * @return RGB value + * @throws IOException + */ + public RGB readRGB() throws IOException { + RGB ret = new RGB(); + ret.red = readUI8(); + ret.green = readUI8(); + ret.blue = readUI8(); + return ret; + } + + /** + * Reads one CONVOLUTIONFILTER value from the stream + * + * @return CONVOLUTIONFILTER value + * @throws IOException + */ + public CONVOLUTIONFILTER readCONVOLUTIONFILTER() throws IOException { + CONVOLUTIONFILTER ret = new CONVOLUTIONFILTER(); + ret.matrixX = readUI8(); + ret.matrixY = readUI8(); + ret.divisor = readFLOAT(); + ret.bias = readFLOAT(); + ret.matrix = new float[ret.matrixX][ret.matrixY]; + for (int x = 0; x < ret.matrixX; x++) { + for (int y = 0; y < ret.matrixY; y++) { + ret.matrix[x][y] = readFLOAT(); + } + } + ret.defaultColor = readRGBA(); + readUB(6);//reserved + ret.clamp = readUB(1) == 1; + ret.preserveAlpha = readUB(1) == 1; + return ret; + } + + /** + * Reads one BLURFILTER value from the stream + * + * @return BLURFILTER value + * @throws IOException + */ + public BLURFILTER readBLURFILTER() throws IOException { + BLURFILTER ret = new BLURFILTER(); + ret.blurX = readFIXED(); + ret.blurY = readFIXED(); + ret.passes = (int) readUB(5); + readUB(3); //reserved + return ret; + } + + /** + * Reads one DROPSHADOWFILTER value from the stream + * + * @return DROPSHADOWFILTER value + * @throws IOException + */ + public DROPSHADOWFILTER readDROPSHADOWFILTER() throws IOException { + DROPSHADOWFILTER ret = new DROPSHADOWFILTER(); + ret.dropShadowColor = readRGBA(); + ret.blurX = readFIXED(); + ret.blurY = readFIXED(); + ret.angle = readFIXED(); + ret.distance = readFIXED(); + ret.strength = readFIXED8(); + ret.innerShadow = readUB(1) == 1; + ret.knockout = readUB(1) == 1; + ret.compositeSource = readUB(1) == 1; + ret.passes = (int) readUB(5); + return ret; + } + + /** + * Reads one GLOWFILTER value from the stream + * + * @return GLOWFILTER value + * @throws IOException + */ + public GLOWFILTER readGLOWFILTER() throws IOException { + GLOWFILTER ret = new GLOWFILTER(); + ret.glowColor = readRGBA(); + ret.blurX = readFIXED(); + ret.blurY = readFIXED(); + ret.strength = readFIXED8(); + ret.innerGlow = readUB(1) == 1; + ret.knockout = readUB(1) == 1; + ret.compositeSource = readUB(1) == 1; + ret.passes = (int) readUB(5); + return ret; + } + + /** + * Reads one BEVELFILTER value from the stream + * + * @return BEVELFILTER value + * @throws IOException + */ + public BEVELFILTER readBEVELFILTER() throws IOException { + BEVELFILTER ret = new BEVELFILTER(); + ret.shadowColor = readRGBA(); + ret.highlightColor = readRGBA(); + ret.blurX = readFIXED(); + ret.blurY = readFIXED(); + ret.angle = readFIXED(); + ret.distance = readFIXED(); + ret.strength = readFIXED8(); + ret.innerShadow = readUB(1) == 1; + ret.knockout = readUB(1) == 1; + ret.compositeSource = readUB(1) == 1; + ret.onTop = readUB(1) == 1; + ret.passes = (int) readUB(4); + return ret; + } + + /** + * Reads one GRADIENTGLOWFILTER value from the stream + * + * @return GRADIENTGLOWFILTER value + * @throws IOException + */ + public GRADIENTGLOWFILTER readGRADIENTGLOWFILTER() throws IOException { + GRADIENTGLOWFILTER ret = new GRADIENTGLOWFILTER(); + int numColors = readUI8(); + ret.gradientColors = new RGBA[numColors]; + ret.gradientRatio = new int[numColors]; + for (int i = 0; i < numColors; i++) { + ret.gradientColors[i] = readRGBA(); + } + for (int i = 0; i < numColors; i++) { + ret.gradientRatio[i] = readUI8(); + } + ret.blurX = readFIXED(); + ret.blurY = readFIXED(); + ret.angle = readFIXED(); + ret.distance = readFIXED(); + ret.strength = readFIXED8(); + ret.innerShadow = readUB(1) == 1; + ret.knockout = readUB(1) == 1; + ret.compositeSource = readUB(1) == 1; + ret.onTop = readUB(1) == 1; + ret.passes = (int) readUB(4); + return ret; + } + + /** + * Reads one GRADIENTBEVELFILTER value from the stream + * + * @return GRADIENTBEVELFILTER value + * @throws IOException + */ + public GRADIENTBEVELFILTER readGRADIENTBEVELFILTER() throws IOException { + GRADIENTBEVELFILTER ret = new GRADIENTBEVELFILTER(); + int numColors = readUI8(); + ret.gradientColors = new RGBA[numColors]; + ret.gradientRatio = new int[numColors]; + for (int i = 0; i < numColors; i++) { + ret.gradientColors[i] = readRGBA(); + } + for (int i = 0; i < numColors; i++) { + ret.gradientRatio[i] = readUI8(); + } + ret.blurX = readFIXED(); + ret.blurY = readFIXED(); + ret.angle = readFIXED(); + ret.distance = readFIXED(); + ret.strength = readFIXED8(); + ret.innerShadow = readUB(1) == 1; + ret.knockout = readUB(1) == 1; + ret.compositeSource = readUB(1) == 1; + ret.onTop = readUB(1) == 1; + ret.passes = (int) readUB(4); + return ret; + } + + /** + * Reads list of FILTER values from the stream + * + * @return List of FILTER values + * @throws IOException + */ + public List readFILTERLIST() throws IOException { + List ret = new ArrayList(); + int numberOfFilters = readUI8(); + for (int i = 0; i < numberOfFilters; i++) { + ret.add(readFILTER()); + } + return ret; + } + + /** + * Reads one FILTER value from the stream + * + * @return FILTER value + * @throws IOException + */ + public FILTER readFILTER() throws IOException { + int filterId = readUI8(); + switch (filterId) { + case 0: + return readDROPSHADOWFILTER(); + case 1: + return readBLURFILTER(); + case 2: + return readGLOWFILTER(); + case 3: + return readBEVELFILTER(); + case 4: + return readGRADIENTGLOWFILTER(); + case 5: + return readCONVOLUTIONFILTER(); + case 6: + return readCOLORMATRIXFILTER(); + case 7: + return readGRADIENTBEVELFILTER(); + default: + return null; + } + } + + /** + * Reads list of BUTTONRECORD values from the stream + * + * @param inDefineButton2 Whether read from inside of DefineButton2Tag or + * not + * @return List of BUTTONRECORD values + * @throws IOException + */ + public List readBUTTONRECORDList(boolean inDefineButton2) throws IOException { + List ret = new ArrayList(); + BUTTONRECORD br; + while ((br = readBUTTONRECORD(inDefineButton2)) != null) { + ret.add(br); + } + return ret; + } + + /** + * Reads one BUTTONRECORD value from the stream + * + * @return BUTTONRECORD value + * @throws IOException + */ + public BUTTONRECORD readBUTTONRECORD(boolean inDefineButton2) throws IOException { + BUTTONRECORD ret = new BUTTONRECORD(); + int res = (int) readUB(2); //reserved + ret.buttonHasBlendMode = readUB(1) == 1; + ret.buttonHasFilterList = readUB(1) == 1; + ret.buttonStateHitTest = readUB(1) == 1; + ret.buttonStateDown = readUB(1) == 1; + ret.buttonStateOver = readUB(1) == 1; + ret.buttonStateUp = readUB(1) == 1; + + if (!ret.buttonHasBlendMode) { + if (!ret.buttonHasFilterList) { + if (!ret.buttonStateHitTest) { + if (!ret.buttonStateDown) { + if (!ret.buttonStateOver) { + if (!ret.buttonStateUp) { + if (res == 0) { + return null; + } + } + } + } + } + } + } + + ret.characterId = readUI16(); + ret.placeDepth = readUI16(); + ret.placeMatrix = readMatrix(); + if (inDefineButton2) { + ret.colorTransform = readCXFORMWITHALPHA(); + if (ret.buttonHasFilterList) { + ret.filterList = readFILTERLIST(); + } + if (ret.buttonHasBlendMode) { + ret.blendMode = readUI8(); + } + } + return ret; + } + + /** + * Reads list of BUTTONCONDACTION values from the stream + * + * @return List of BUTTONCONDACTION values + * @throws IOException + */ + public List readBUTTONCONDACTIONList() throws IOException { + List ret = new ArrayList(); + BUTTONCONDACTION bc; + while (!(bc = readBUTTONCONDACTION()).isLast) { + ret.add(bc); + } + ret.add(bc); + return ret; + } + + /** + * Reads one BUTTONCONDACTION value from the stream + * + * @return BUTTONCONDACTION value + * @throws IOException + */ + public BUTTONCONDACTION readBUTTONCONDACTION() throws IOException { + BUTTONCONDACTION ret = new BUTTONCONDACTION(); + int condActionSize = readUI16(); + ret.isLast = condActionSize <= 0; + ret.condIdleToOverDown = readUB(1) == 1; + ret.condOutDownToIdle = readUB(1) == 1; + ret.condOutDownToOverDown = readUB(1) == 1; + ret.condOverDownToOutDown = readUB(1) == 1; + ret.condOverDownToOverUp = readUB(1) == 1; + ret.condOverUpToOverDown = readUB(1) == 1; + ret.condOverUpToIddle = readUB(1) == 1; + ret.condIdleToOverUp = readUB(1) == 1; + ret.condKeyPress = (int) readUB(7); + ret.condOverDownToIddle = readUB(1) == 1; + if (condActionSize <= 0) { + ret.actionBytes = readBytes(available()); + } else { + ret.actionBytes = readBytes(condActionSize - 4); + } + //ret.actions = readActionList(); + return ret; + } + + /** + * Reads one GRADRECORD value from the stream + * + * @return GRADRECORD value + * @throws IOException + */ + public GRADRECORD readGRADRECORD(int shapeNum) throws IOException { + GRADRECORD ret = new GRADRECORD(); + ret.ratio = readUI8(); + if (shapeNum >= 3) { ret.colorA = readRGBA(); - } else { + } else { ret.color = readRGB(); - } - } - if ((ret.fillStyleType == FILLSTYLE.LINEAR_GRADIENT) - || (ret.fillStyleType == FILLSTYLE.RADIAL_GRADIENT) - || (ret.fillStyleType == FILLSTYLE.FOCAL_RADIAL_GRADIENT)) { - ret.gradientMatrix = readMatrix(); - } - if ((ret.fillStyleType == FILLSTYLE.LINEAR_GRADIENT) - || (ret.fillStyleType == FILLSTYLE.RADIAL_GRADIENT)) { - ret.gradient = readGRADIENT(shapeNum); - } - if (ret.fillStyleType == FILLSTYLE.FOCAL_RADIAL_GRADIENT) { - ret.focalGradient = readFOCALGRADIENT(shapeNum); - } + } + return ret; + } - if ((ret.fillStyleType == FILLSTYLE.REPEATING_BITMAP) - || (ret.fillStyleType == FILLSTYLE.CLIPPED_BITMAP) - || (ret.fillStyleType == FILLSTYLE.NON_SMOOTHED_REPEATING_BITMAP) - || (ret.fillStyleType == FILLSTYLE.NON_SMOOTHED_CLIPPED_BITMAP)) { - ret.bitmapId = readUI16(); - ret.bitmapMatrix = readMatrix(); - } - return ret; - } + /** + * Reads one GRADIENT value from the stream + * + * @return GRADIENT value + * @throws IOException + */ + public GRADIENT readGRADIENT(int shapeNum) throws IOException { + GRADIENT ret = new GRADIENT(); + ret.spreadMode = (int) readUB(2); + ret.interPolationMode = (int) readUB(2); + int numGradients = (int) readUB(4); + ret.gradientRecords = new GRADRECORD[numGradients]; + for (int i = 0; i < numGradients; i++) { + ret.gradientRecords[i] = readGRADRECORD(shapeNum); - /** - * Reads one FILLSTYLEARRAY value from the stream - * - * @return FILLSTYLEARRAY value - * @throws IOException - */ - public FILLSTYLEARRAY readFILLSTYLEARRAY(int shapeNum) throws IOException { + } + return ret; + } - FILLSTYLEARRAY ret = new FILLSTYLEARRAY(); - int fillStyleCount = readUI8(); - if (((shapeNum == 2) || (shapeNum == 3) || (shapeNum == 4/*?*/)) && (fillStyleCount == 0xff)) { - fillStyleCount = readUI16(); - } - ret.fillStyles = new FILLSTYLE[fillStyleCount]; - for (int i = 0; i < fillStyleCount; i++) { - ret.fillStyles[i] = readFILLSTYLE(shapeNum); - } - return ret; - } + /** + * Reads one FOCALGRADIENT value from the stream + * + * @return FOCALGRADIENT value + * @throws IOException + */ + public FOCALGRADIENT readFOCALGRADIENT(int shapeNum) throws IOException { + FOCALGRADIENT ret = new FOCALGRADIENT(); + ret.spreadMode = (int) readUB(2); + ret.interPolationMode = (int) readUB(2); + int numGradients = (int) readUB(4); + ret.gradientRecords = new GRADRECORD[numGradients]; + for (int i = 0; i < numGradients; i++) { + ret.gradientRecords[i] = readGRADRECORD(shapeNum); + } + ret.focalPoint = readFIXED8(); + return ret; + } - /** - * Reads one LINESTYLE value from the stream - * - * @return LINESTYLE value - * @throws IOException - */ - public LINESTYLE readLINESTYLE(int shapeNum) throws IOException { - LINESTYLE ret = new LINESTYLE(); - ret.width = readUI16(); - if ((shapeNum == 1) || (shapeNum == 2)) { - ret.color = readRGB(); - } - if (shapeNum == 3) { - ret.colorA = readRGBA(); - } - return ret; - } - - /** - * Reads one LINESTYLE2 value from the stream - * - * @return LINESTYLE2 value - * @throws IOException - */ - public LINESTYLE2 readLINESTYLE2(int shapeNum) throws IOException { - LINESTYLE2 ret = new LINESTYLE2(); - ret.width = readUI16(); - ret.startCapStyle = (int) readUB(2); - ret.joinStyle = (int) readUB(2); - ret.hasFillFlag = (int) readUB(1) == 1; - ret.noHScaleFlag = (int) readUB(1) == 1; - ret.noVScaleFlag = (int) readUB(1) == 1; - ret.pixelHintingFlag = (int) readUB(1) == 1; - readUB(5);//reserved - ret.noClose = (int) readUB(1) == 1; - ret.endCapStyle = (int) readUB(2); - if (ret.joinStyle == LINESTYLE2.MITER_JOIN) { - ret.miterLimitFactor = readUI16(); - } - if (!ret.hasFillFlag) { - ret.color = readRGBA(); - } else { - ret.fillType = readFILLSTYLE(shapeNum); - } - return ret; - } - - /** - * Reads one LINESTYLEARRAY value from the stream - * - * @return LINESTYLEARRAY value - * @throws IOException - */ - public LINESTYLEARRAY readLINESTYLEARRAY(int shapeNum) throws IOException { - LINESTYLEARRAY ret = new LINESTYLEARRAY(); - int lineStyleCount = readUI8(); - if (lineStyleCount == 0xff) { - lineStyleCount = readUI16(); - } - if ((shapeNum == 1 || shapeNum == 2 || shapeNum == 3)) { - ret.lineStyles = new LINESTYLE[lineStyleCount]; - for (int i = 0; i < lineStyleCount; i++) { - ret.lineStyles[i] = readLINESTYLE(shapeNum); - } - } else if (shapeNum == 4) { - ret.lineStyles2 = new LINESTYLE2[lineStyleCount]; - for (int i = 0; i < lineStyleCount; i++) { - ret.lineStyles2[i] = readLINESTYLE2(shapeNum); - } - } - return ret; - } - - /** - * Reads one SHAPERECORD value from the stream - * - * @return SHAPERECORD value - * @throws IOException - */ - public SHAPERECORD readSHAPERECORD(int fillBits, int lineBits, int shapeNum) throws IOException { - SHAPERECORD ret; - int typeFlag = (int) readUB(1); - if (typeFlag == 0) { - boolean stateNewStyles = readUB(1) == 1; - boolean stateLineStyle = readUB(1) == 1; - boolean stateFillStyle1 = readUB(1) == 1; - boolean stateFillStyle0 = readUB(1) == 1; - boolean stateMoveTo = readUB(1) == 1; - if ((!stateNewStyles) && (!stateLineStyle) && (!stateFillStyle1) && (!stateFillStyle0) && (!stateMoveTo)) { - ret = new EndShapeRecord(); - } else { - StyleChangeRecord scr = new StyleChangeRecord(); - scr.stateNewStyles = stateNewStyles; - scr.stateLineStyle = stateLineStyle; - scr.stateFillStyle0 = stateFillStyle0; - scr.stateFillStyle1 = stateFillStyle1; - scr.stateMoveTo = stateMoveTo; - if (stateMoveTo) { - scr.moveBits = (int) readUB(5); - scr.moveDeltaX = (int) readSB(scr.moveBits); - scr.moveDeltaY = (int) readSB(scr.moveBits); + /** + * Reads one FILLSTYLE value from the stream + * + * @return FILLSTYLE value + * @throws IOException + */ + public FILLSTYLE readFILLSTYLE(int shapeNum) throws IOException { + FILLSTYLE ret = new FILLSTYLE(); + ret.fillStyleType = readUI8(); + if (ret.fillStyleType == FILLSTYLE.SOLID) { + if (shapeNum >= 3) { + ret.colorA = readRGBA(); + } else { + ret.color = readRGB(); } - if (stateFillStyle0) { - scr.fillStyle0 = (int) readUB(fillBits); + } + if ((ret.fillStyleType == FILLSTYLE.LINEAR_GRADIENT) + || (ret.fillStyleType == FILLSTYLE.RADIAL_GRADIENT) + || (ret.fillStyleType == FILLSTYLE.FOCAL_RADIAL_GRADIENT)) { + ret.gradientMatrix = readMatrix(); + } + if ((ret.fillStyleType == FILLSTYLE.LINEAR_GRADIENT) + || (ret.fillStyleType == FILLSTYLE.RADIAL_GRADIENT)) { + ret.gradient = readGRADIENT(shapeNum); + } + if (ret.fillStyleType == FILLSTYLE.FOCAL_RADIAL_GRADIENT) { + ret.focalGradient = readFOCALGRADIENT(shapeNum); + } + + if ((ret.fillStyleType == FILLSTYLE.REPEATING_BITMAP) + || (ret.fillStyleType == FILLSTYLE.CLIPPED_BITMAP) + || (ret.fillStyleType == FILLSTYLE.NON_SMOOTHED_REPEATING_BITMAP) + || (ret.fillStyleType == FILLSTYLE.NON_SMOOTHED_CLIPPED_BITMAP)) { + ret.bitmapId = readUI16(); + ret.bitmapMatrix = readMatrix(); + } + return ret; + } + + /** + * Reads one FILLSTYLEARRAY value from the stream + * + * @return FILLSTYLEARRAY value + * @throws IOException + */ + public FILLSTYLEARRAY readFILLSTYLEARRAY(int shapeNum) throws IOException { + + FILLSTYLEARRAY ret = new FILLSTYLEARRAY(); + int fillStyleCount = readUI8(); + if (((shapeNum == 2) || (shapeNum == 3) || (shapeNum == 4/*?*/)) && (fillStyleCount == 0xff)) { + fillStyleCount = readUI16(); + } + ret.fillStyles = new FILLSTYLE[fillStyleCount]; + for (int i = 0; i < fillStyleCount; i++) { + ret.fillStyles[i] = readFILLSTYLE(shapeNum); + } + return ret; + } + + /** + * Reads one LINESTYLE value from the stream + * + * @return LINESTYLE value + * @throws IOException + */ + public LINESTYLE readLINESTYLE(int shapeNum) throws IOException { + LINESTYLE ret = new LINESTYLE(); + ret.width = readUI16(); + if ((shapeNum == 1) || (shapeNum == 2)) { + ret.color = readRGB(); + } + if (shapeNum == 3) { + ret.colorA = readRGBA(); + } + return ret; + } + + /** + * Reads one LINESTYLE2 value from the stream + * + * @return LINESTYLE2 value + * @throws IOException + */ + public LINESTYLE2 readLINESTYLE2(int shapeNum) throws IOException { + LINESTYLE2 ret = new LINESTYLE2(); + ret.width = readUI16(); + ret.startCapStyle = (int) readUB(2); + ret.joinStyle = (int) readUB(2); + ret.hasFillFlag = (int) readUB(1) == 1; + ret.noHScaleFlag = (int) readUB(1) == 1; + ret.noVScaleFlag = (int) readUB(1) == 1; + ret.pixelHintingFlag = (int) readUB(1) == 1; + readUB(5);//reserved + ret.noClose = (int) readUB(1) == 1; + ret.endCapStyle = (int) readUB(2); + if (ret.joinStyle == LINESTYLE2.MITER_JOIN) { + ret.miterLimitFactor = readUI16(); + } + if (!ret.hasFillFlag) { + ret.color = readRGBA(); + } else { + ret.fillType = readFILLSTYLE(shapeNum); + } + return ret; + } + + /** + * Reads one LINESTYLEARRAY value from the stream + * + * @return LINESTYLEARRAY value + * @throws IOException + */ + public LINESTYLEARRAY readLINESTYLEARRAY(int shapeNum) throws IOException { + LINESTYLEARRAY ret = new LINESTYLEARRAY(); + int lineStyleCount = readUI8(); + if (lineStyleCount == 0xff) { + lineStyleCount = readUI16(); + } + if ((shapeNum == 1 || shapeNum == 2 || shapeNum == 3)) { + ret.lineStyles = new LINESTYLE[lineStyleCount]; + for (int i = 0; i < lineStyleCount; i++) { + ret.lineStyles[i] = readLINESTYLE(shapeNum); } - if (stateFillStyle1) { - scr.fillStyle1 = (int) readUB(fillBits); + } else if (shapeNum == 4) { + ret.lineStyles2 = new LINESTYLE2[lineStyleCount]; + for (int i = 0; i < lineStyleCount; i++) { + ret.lineStyles2[i] = readLINESTYLE2(shapeNum); } - if (stateLineStyle) { - scr.lineStyle = (int) readUB(lineBits); + } + return ret; + } + + /** + * Reads one SHAPERECORD value from the stream + * + * @return SHAPERECORD value + * @throws IOException + */ + public SHAPERECORD readSHAPERECORD(int fillBits, int lineBits, int shapeNum) throws IOException { + SHAPERECORD ret; + int typeFlag = (int) readUB(1); + if (typeFlag == 0) { + boolean stateNewStyles = readUB(1) == 1; + boolean stateLineStyle = readUB(1) == 1; + boolean stateFillStyle1 = readUB(1) == 1; + boolean stateFillStyle0 = readUB(1) == 1; + boolean stateMoveTo = readUB(1) == 1; + if ((!stateNewStyles) && (!stateLineStyle) && (!stateFillStyle1) && (!stateFillStyle0) && (!stateMoveTo)) { + ret = new EndShapeRecord(); + } else { + StyleChangeRecord scr = new StyleChangeRecord(); + scr.stateNewStyles = stateNewStyles; + scr.stateLineStyle = stateLineStyle; + scr.stateFillStyle0 = stateFillStyle0; + scr.stateFillStyle1 = stateFillStyle1; + scr.stateMoveTo = stateMoveTo; + if (stateMoveTo) { + scr.moveBits = (int) readUB(5); + scr.moveDeltaX = (int) readSB(scr.moveBits); + scr.moveDeltaY = (int) readSB(scr.moveBits); + } + if (stateFillStyle0) { + scr.fillStyle0 = (int) readUB(fillBits); + } + if (stateFillStyle1) { + scr.fillStyle1 = (int) readUB(fillBits); + } + if (stateLineStyle) { + scr.lineStyle = (int) readUB(lineBits); + } + if (stateNewStyles) { + scr.fillStyles = readFILLSTYLEARRAY(shapeNum); + scr.lineStyles = readLINESTYLEARRAY(shapeNum); + scr.numFillBits = (int) readUB(4); + scr.numLineBits = (int) readUB(4); + } + ret = scr; } - if (stateNewStyles) { - scr.fillStyles = readFILLSTYLEARRAY(shapeNum); - scr.lineStyles = readLINESTYLEARRAY(shapeNum); - scr.numFillBits = (int) readUB(4); - scr.numLineBits = (int) readUB(4); + } else {//typeFlag==1 + int straightFlag = (int) readUB(1); + if (straightFlag == 1) { + StraightEdgeRecord ser = new StraightEdgeRecord(); + ser.numBits = (int) readUB(4); + ser.generalLineFlag = readUB(1) == 1; + if (!ser.generalLineFlag) { + ser.vertLineFlag = readUB(1) == 1; + } + if (ser.generalLineFlag || (!ser.vertLineFlag)) { + ser.deltaX = (int) readSB(ser.numBits + 2); + } + if (ser.generalLineFlag || (ser.vertLineFlag)) { + ser.deltaY = (int) readSB(ser.numBits + 2); + } + ret = ser; + } else { + CurvedEdgeRecord cer = new CurvedEdgeRecord(); + cer.numBits = (int) readUB(4); + cer.controlDeltaX = (int) readSB(cer.numBits + 2); + cer.controlDeltaY = (int) readSB(cer.numBits + 2); + cer.anchorDeltaX = (int) readSB(cer.numBits + 2); + cer.anchorDeltaY = (int) readSB(cer.numBits + 2); + ret = cer; } - ret = scr; - } - } else {//typeFlag==1 - int straightFlag = (int) readUB(1); - if (straightFlag == 1) { - StraightEdgeRecord ser = new StraightEdgeRecord(); - ser.numBits = (int) readUB(4); - ser.generalLineFlag = readUB(1) == 1; - if (!ser.generalLineFlag) { - ser.vertLineFlag = readUB(1) == 1; + } + return ret; + } + + /** + * Reads one SHAPE value from the stream + * + * @return SHAPE value + * @throws IOException + */ + public SHAPE readSHAPE(int shapeNum) throws IOException { + SHAPE ret = new SHAPE(); + ret.numFillBits = (int) readUB(4); + ret.numLineBits = (int) readUB(4); + ret.shapeRecords = readSHAPERECORDS(shapeNum, ret.numFillBits, ret.numLineBits); + return ret; + } + + /** + * Reads one SHAPEWITHSTYLE value from the stream + * + * @return SHAPEWITHSTYLE value + * @throws IOException + */ + public SHAPEWITHSTYLE readSHAPEWITHSTYLE(int shapeNum) throws IOException { + SHAPEWITHSTYLE ret = new SHAPEWITHSTYLE(); + ret.fillStyles = readFILLSTYLEARRAY(shapeNum); + ret.lineStyles = readLINESTYLEARRAY(shapeNum); + ret.numFillBits = (int) readUB(4); + ret.numLineBits = (int) readUB(4); + ret.shapeRecords = readSHAPERECORDS(shapeNum, ret.numFillBits, ret.numLineBits); + return ret; + } + + /** + * Reads list of SHAPERECORDs from the stream + * + * @return SHAPERECORDs array + * @throws IOException + */ + public List readSHAPERECORDS(int shapeNum, int fillBits, int lineBits) throws IOException { + List ret = new ArrayList(); + SHAPERECORD rec; + do { + rec = readSHAPERECORD(fillBits, lineBits, shapeNum); + if (rec instanceof StyleChangeRecord) { + if (((StyleChangeRecord) rec).stateNewStyles) { + fillBits = ((StyleChangeRecord) rec).numFillBits; + lineBits = ((StyleChangeRecord) rec).numLineBits; + } } - if (ser.generalLineFlag || (!ser.vertLineFlag)) { - ser.deltaX = (int) readSB(ser.numBits + 2); + ret.add(rec); + } while (!(rec instanceof EndShapeRecord)); + alignByte(); + return ret; + } + + /** + * Reads one SOUNDINFO value from the stream + * + * @return SOUNDINFO value + * @throws IOException + */ + public SOUNDINFO readSOUNDINFO() throws IOException { + SOUNDINFO ret = new SOUNDINFO(); + readUB(2); + ret.syncStop = readUB(1) == 1; + ret.syncNoMultiple = readUB(1) == 1; + ret.hasEnvelope = readUB(1) == 1; + ret.hasLoops = readUB(1) == 1; + ret.hasOutPoint = readUB(1) == 1; + ret.hasInPoint = readUB(1) == 1; + if (ret.hasInPoint) { + ret.inPoint = readUI32(); + } + if (ret.hasOutPoint) { + ret.outPoint = readUI32(); + } + if (ret.hasLoops) { + ret.loopCount = readUI16(); + } + if (ret.hasEnvelope) { + int envPoints = readUI8(); + ret.envelopeRecords = new SOUNDENVELOPE[envPoints]; + for (int i = 0; i < envPoints; i++) { + ret.envelopeRecords[i] = readSOUNDENVELOPE(); } - if (ser.generalLineFlag || (ser.vertLineFlag)) { - ser.deltaY = (int) readSB(ser.numBits + 2); + } + return ret; + } + + /** + * Reads one SOUNDENVELOPE value from the stream + * + * @return SOUNDENVELOPE value + * @throws IOException + */ + public SOUNDENVELOPE readSOUNDENVELOPE() throws IOException { + SOUNDENVELOPE ret = new SOUNDENVELOPE(); + ret.pos44 = readUI32(); + ret.leftLevel = readUI16(); + ret.rightLevel = readUI16(); + return ret; + } + + /** + * Reads one GLYPHENTRY value from the stream + * + * @return GLYPHENTRY value + * @throws IOException + */ + public GLYPHENTRY readGLYPHENTRY(int glyphBits, int advanceBits) throws IOException { + GLYPHENTRY ret = new GLYPHENTRY(); + ret.glyphIndex = (int) readUB(glyphBits); + ret.glyphAdvance = (int) readUB(advanceBits); + return ret; + } + + /** + * Reads one TEXTRECORD value from the stream + * + * @return TEXTRECORD value + * @throws IOException + */ + public TEXTRECORD readTEXTRECORD(boolean inDefineText2, int glyphBits, int advanceBits) throws IOException { + TEXTRECORD ret = new TEXTRECORD(); + int first = (int) readUB(1); //always 1 + readUB(3); //always 0 + ret.styleFlagsHasFont = readUB(1) == 1; + ret.styleFlagsHasColor = readUB(1) == 1; + ret.styleFlagsHasYOffset = readUB(1) == 1; + ret.styleFlagsHasXOffset = readUB(1) == 1; + if ((!ret.styleFlagsHasFont) && (!ret.styleFlagsHasColor) && (!ret.styleFlagsHasYOffset) && (!ret.styleFlagsHasXOffset) && (first == 0)) { //final text record + return null; + } + if (ret.styleFlagsHasFont) { + ret.fontId = readUI16(); + } + if (ret.styleFlagsHasColor) { + if (inDefineText2) { + ret.textColorA = readRGBA(); + } else { + ret.textColor = readRGB(); } - ret = ser; - } else { - CurvedEdgeRecord cer = new CurvedEdgeRecord(); - cer.numBits = (int) readUB(4); - cer.controlDeltaX = (int) readSB(cer.numBits + 2); - cer.controlDeltaY = (int) readSB(cer.numBits + 2); - cer.anchorDeltaX = (int) readSB(cer.numBits + 2); - cer.anchorDeltaY = (int) readSB(cer.numBits + 2); - ret = cer; - } - } - return ret; - } + } + if (ret.styleFlagsHasXOffset) { + ret.xOffset = readSI16(); + } + if (ret.styleFlagsHasYOffset) { + ret.yOffset = readSI16(); + } + if (ret.styleFlagsHasFont) { + ret.textHeight = readUI16(); + } + int glyphCount = readUI8(); + ret.glyphEntries = new GLYPHENTRY[glyphCount]; + for (int i = 0; i < glyphCount; i++) { + ret.glyphEntries[i] = readGLYPHENTRY(glyphBits, advanceBits); + } + alignByte(); + return ret; + } - /** - * Reads one SHAPE value from the stream - * - * @return SHAPE value - * @throws IOException - */ - public SHAPE readSHAPE(int shapeNum) throws IOException { - SHAPE ret = new SHAPE(); - ret.numFillBits = (int) readUB(4); - ret.numLineBits = (int) readUB(4); - ret.shapeRecords = readSHAPERECORDS(shapeNum, ret.numFillBits, ret.numLineBits); - return ret; - } + /** + * Reads one MORPHGRADRECORD value from the stream + * + * @return MORPHGRADRECORD value + * @throws IOException + */ + public MORPHGRADRECORD readMORPHGRADRECORD() throws IOException { + MORPHGRADRECORD ret = new MORPHGRADRECORD(); + ret.startRatio = readUI8(); + ret.startColor = readRGBA(); + ret.endRatio = readUI8(); + ret.endColor = readRGBA(); + return ret; + } - /** - * Reads one SHAPEWITHSTYLE value from the stream - * - * @return SHAPEWITHSTYLE value - * @throws IOException - */ - public SHAPEWITHSTYLE readSHAPEWITHSTYLE(int shapeNum) throws IOException { - SHAPEWITHSTYLE ret = new SHAPEWITHSTYLE(); - ret.fillStyles = readFILLSTYLEARRAY(shapeNum); - ret.lineStyles = readLINESTYLEARRAY(shapeNum); - ret.numFillBits = (int) readUB(4); - ret.numLineBits = (int) readUB(4); - ret.shapeRecords = readSHAPERECORDS(shapeNum, ret.numFillBits, ret.numLineBits); - return ret; - } + /** + * Reads one MORPHGRADIENT value from the stream + * + * @return MORPHGRADIENT value + * @throws IOException + */ + public MORPHGRADIENT readMORPHGRADIENT() throws IOException { + MORPHGRADIENT ret = new MORPHGRADIENT(); + int numGradients = (int) readUI8(); + ret.gradientRecords = new MORPHGRADRECORD[numGradients]; + for (int i = 0; i < numGradients; i++) { + ret.gradientRecords[i] = readMORPHGRADRECORD(); + } + return ret; + } - /** - * Reads list of SHAPERECORDs from the stream - * - * @return SHAPERECORDs array - * @throws IOException - */ - public List readSHAPERECORDS(int shapeNum, int fillBits, int lineBits) throws IOException { - List ret = new ArrayList(); - SHAPERECORD rec; - do { - rec = readSHAPERECORD(fillBits, lineBits, shapeNum); - if (rec instanceof StyleChangeRecord) { - if (((StyleChangeRecord) rec).stateNewStyles) { - fillBits = ((StyleChangeRecord) rec).numFillBits; - lineBits = ((StyleChangeRecord) rec).numLineBits; + /** + * Reads one MORPHFILLSTYLE value from the stream + * + * @return MORPHFILLSTYLE value + * @throws IOException + */ + public MORPHFILLSTYLE readMORPHFILLSTYLE() throws IOException { + MORPHFILLSTYLE ret = new MORPHFILLSTYLE(); + ret.fillStyleType = readUI8(); + if (ret.fillStyleType == MORPHFILLSTYLE.SOLID) { + ret.startColor = readRGBA(); + ret.endColor = readRGBA(); + } + if ((ret.fillStyleType == MORPHFILLSTYLE.LINEAR_GRADIENT) + || (ret.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)) { + ret.startGradientMatrix = readMatrix(); + ret.endGradientMatrix = readMatrix(); + } + if ((ret.fillStyleType == MORPHFILLSTYLE.LINEAR_GRADIENT) + || (ret.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)) { + ret.gradient = readMORPHGRADIENT(); + } + + if ((ret.fillStyleType == MORPHFILLSTYLE.REPEATING_BITMAP) + || (ret.fillStyleType == MORPHFILLSTYLE.CLIPPED_BITMAP) + || (ret.fillStyleType == MORPHFILLSTYLE.NON_SMOOTHED_REPEATING_BITMAP) + || (ret.fillStyleType == MORPHFILLSTYLE.NON_SMOOTHED_CLIPPED_BITMAP)) { + ret.bitmapId = readUI16(); + ret.startBitmapMatrix = readMatrix(); + ret.endBitmapMatrix = readMatrix(); + } + return ret; + } + + /** + * Reads one MORPHFILLSTYLEARRAY value from the stream + * + * @return MORPHFILLSTYLEARRAY value + * @throws IOException + */ + public MORPHFILLSTYLEARRAY readMORPHFILLSTYLEARRAY() throws IOException { + + MORPHFILLSTYLEARRAY ret = new MORPHFILLSTYLEARRAY(); + int fillStyleCount = readUI8(); + if (fillStyleCount == 0xff) { + fillStyleCount = readUI16(); + } + ret.fillStyles = new MORPHFILLSTYLE[fillStyleCount]; + for (int i = 0; i < fillStyleCount; i++) { + ret.fillStyles[i] = readMORPHFILLSTYLE(); + } + return ret; + } + + /** + * Reads one MORPHLINESTYLE value from the stream + * + * @return MORPHLINESTYLE value + * @throws IOException + */ + public MORPHLINESTYLE readMORPHLINESTYLE() throws IOException { + MORPHLINESTYLE ret = new MORPHLINESTYLE(); + ret.startWidth = readUI16(); + ret.endWidth = readUI16(); + ret.startColor = readRGBA(); + ret.endColor = readRGBA(); + return ret; + } + + /** + * Reads one MORPHLINESTYLE2 value from the stream + * + * @return MORPHLINESTYLE2 value + * @throws IOException + */ + public MORPHLINESTYLE2 readMORPHLINESTYLE2() throws IOException { + MORPHLINESTYLE2 ret = new MORPHLINESTYLE2(); + ret.startWidth = readUI16(); + ret.endWidth = readUI16(); + ret.startCapStyle = (int) readUB(2); + ret.joinStyle = (int) readUB(2); + ret.hasFillFlag = (int) readUB(1) == 1; + ret.noHScaleFlag = (int) readUB(1) == 1; + ret.noVScaleFlag = (int) readUB(1) == 1; + ret.pixelHintingFlag = (int) readUB(1) == 1; + readUB(5);//reserved + ret.noClose = (int) readUB(1) == 1; + ret.endCapStyle = (int) readUB(2); + if (ret.joinStyle == LINESTYLE2.MITER_JOIN) { + ret.miterLimitFactor = readUI16(); + } + if (!ret.hasFillFlag) { + ret.startColor = readRGBA(); + ret.endColor = readRGBA(); + } else { + ret.fillType = readMORPHFILLSTYLE(); + } + return ret; + } + + /** + * Reads one MORPHLINESTYLEARRAY value from the stream + * + * @return MORPHLINESTYLEARRAY value + * @throws IOException + */ + public MORPHLINESTYLEARRAY readMORPHLINESTYLEARRAY(int morphShapeNum) throws IOException { + MORPHLINESTYLEARRAY ret = new MORPHLINESTYLEARRAY(); + int lineStyleCount = readUI8(); + if (lineStyleCount == 0xff) { + lineStyleCount = readUI16(); + } + if (morphShapeNum == 1) { + ret.lineStyles = new MORPHLINESTYLE[lineStyleCount]; + for (int i = 0; i < lineStyleCount; i++) { + ret.lineStyles[i] = readMORPHLINESTYLE(); } - } - ret.add(rec); - } while (!(rec instanceof EndShapeRecord)); - alignByte(); - return ret; - } - - /** - * Reads one SOUNDINFO value from the stream - * - * @return SOUNDINFO value - * @throws IOException - */ - public SOUNDINFO readSOUNDINFO() throws IOException { - SOUNDINFO ret = new SOUNDINFO(); - readUB(2); - ret.syncStop = readUB(1) == 1; - ret.syncNoMultiple = readUB(1) == 1; - ret.hasEnvelope = readUB(1) == 1; - ret.hasLoops = readUB(1) == 1; - ret.hasOutPoint = readUB(1) == 1; - ret.hasInPoint = readUB(1) == 1; - if (ret.hasInPoint) { - ret.inPoint = readUI32(); - } - if (ret.hasOutPoint) { - ret.outPoint = readUI32(); - } - if (ret.hasLoops) { - ret.loopCount = readUI16(); - } - if (ret.hasEnvelope) { - int envPoints = readUI8(); - ret.envelopeRecords = new SOUNDENVELOPE[envPoints]; - for (int i = 0; i < envPoints; i++) { - ret.envelopeRecords[i] = readSOUNDENVELOPE(); - } - } - return ret; - } - - /** - * Reads one SOUNDENVELOPE value from the stream - * - * @return SOUNDENVELOPE value - * @throws IOException - */ - public SOUNDENVELOPE readSOUNDENVELOPE() throws IOException { - SOUNDENVELOPE ret = new SOUNDENVELOPE(); - ret.pos44 = readUI32(); - ret.leftLevel = readUI16(); - ret.rightLevel = readUI16(); - return ret; - } - - /** - * Reads one GLYPHENTRY value from the stream - * - * @return GLYPHENTRY value - * @throws IOException - */ - public GLYPHENTRY readGLYPHENTRY(int glyphBits, int advanceBits) throws IOException { - GLYPHENTRY ret = new GLYPHENTRY(); - ret.glyphIndex = (int) readUB(glyphBits); - ret.glyphAdvance = (int) readUB(advanceBits); - return ret; - } - - /** - * Reads one TEXTRECORD value from the stream - * - * @return TEXTRECORD value - * @throws IOException - */ - public TEXTRECORD readTEXTRECORD(boolean inDefineText2, int glyphBits, int advanceBits) throws IOException { - TEXTRECORD ret = new TEXTRECORD(); - int first = (int) readUB(1); //always 1 - readUB(3); //always 0 - ret.styleFlagsHasFont = readUB(1) == 1; - ret.styleFlagsHasColor = readUB(1) == 1; - ret.styleFlagsHasYOffset = readUB(1) == 1; - ret.styleFlagsHasXOffset = readUB(1) == 1; - if ((!ret.styleFlagsHasFont) && (!ret.styleFlagsHasColor) && (!ret.styleFlagsHasYOffset) && (!ret.styleFlagsHasXOffset) && (first == 0)) { //final text record - return null; - } - if (ret.styleFlagsHasFont) { - ret.fontId = readUI16(); - } - if (ret.styleFlagsHasColor) { - if (inDefineText2) { - ret.textColorA = readRGBA(); - } else { - ret.textColor = readRGB(); - } - } - if (ret.styleFlagsHasXOffset) { - ret.xOffset = readSI16(); - } - if (ret.styleFlagsHasYOffset) { - ret.yOffset = readSI16(); - } - if (ret.styleFlagsHasFont) { - ret.textHeight = readUI16(); - } - int glyphCount = readUI8(); - ret.glyphEntries = new GLYPHENTRY[glyphCount]; - for (int i = 0; i < glyphCount; i++) { - ret.glyphEntries[i] = readGLYPHENTRY(glyphBits, advanceBits); - } - alignByte(); - return ret; - } - - /** - * Reads one MORPHGRADRECORD value from the stream - * - * @return MORPHGRADRECORD value - * @throws IOException - */ - public MORPHGRADRECORD readMORPHGRADRECORD() throws IOException { - MORPHGRADRECORD ret = new MORPHGRADRECORD(); - ret.startRatio = readUI8(); - ret.startColor = readRGBA(); - ret.endRatio = readUI8(); - ret.endColor = readRGBA(); - return ret; - } - - /** - * Reads one MORPHGRADIENT value from the stream - * - * @return MORPHGRADIENT value - * @throws IOException - */ - public MORPHGRADIENT readMORPHGRADIENT() throws IOException { - MORPHGRADIENT ret = new MORPHGRADIENT(); - int numGradients = (int) readUI8(); - ret.gradientRecords = new MORPHGRADRECORD[numGradients]; - for (int i = 0; i < numGradients; i++) { - ret.gradientRecords[i] = readMORPHGRADRECORD(); - } - return ret; - } - - /** - * Reads one MORPHFILLSTYLE value from the stream - * - * @return MORPHFILLSTYLE value - * @throws IOException - */ - public MORPHFILLSTYLE readMORPHFILLSTYLE() throws IOException { - MORPHFILLSTYLE ret = new MORPHFILLSTYLE(); - ret.fillStyleType = readUI8(); - if (ret.fillStyleType == MORPHFILLSTYLE.SOLID) { - ret.startColor = readRGBA(); - ret.endColor = readRGBA(); - } - if ((ret.fillStyleType == MORPHFILLSTYLE.LINEAR_GRADIENT) - || (ret.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)) { - ret.startGradientMatrix = readMatrix(); - ret.endGradientMatrix = readMatrix(); - } - if ((ret.fillStyleType == MORPHFILLSTYLE.LINEAR_GRADIENT) - || (ret.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)) { - ret.gradient = readMORPHGRADIENT(); - } - - if ((ret.fillStyleType == MORPHFILLSTYLE.REPEATING_BITMAP) - || (ret.fillStyleType == MORPHFILLSTYLE.CLIPPED_BITMAP) - || (ret.fillStyleType == MORPHFILLSTYLE.NON_SMOOTHED_REPEATING_BITMAP) - || (ret.fillStyleType == MORPHFILLSTYLE.NON_SMOOTHED_CLIPPED_BITMAP)) { - ret.bitmapId = readUI16(); - ret.startBitmapMatrix = readMatrix(); - ret.endBitmapMatrix = readMatrix(); - } - return ret; - } - - /** - * Reads one MORPHFILLSTYLEARRAY value from the stream - * - * @return MORPHFILLSTYLEARRAY value - * @throws IOException - */ - public MORPHFILLSTYLEARRAY readMORPHFILLSTYLEARRAY() throws IOException { - - MORPHFILLSTYLEARRAY ret = new MORPHFILLSTYLEARRAY(); - int fillStyleCount = readUI8(); - if (fillStyleCount == 0xff) { - fillStyleCount = readUI16(); - } - ret.fillStyles = new MORPHFILLSTYLE[fillStyleCount]; - for (int i = 0; i < fillStyleCount; i++) { - ret.fillStyles[i] = readMORPHFILLSTYLE(); - } - return ret; - } - - /** - * Reads one MORPHLINESTYLE value from the stream - * - * @return MORPHLINESTYLE value - * @throws IOException - */ - public MORPHLINESTYLE readMORPHLINESTYLE() throws IOException { - MORPHLINESTYLE ret = new MORPHLINESTYLE(); - ret.startWidth = readUI16(); - ret.endWidth = readUI16(); - ret.startColor = readRGBA(); - ret.endColor = readRGBA(); - return ret; - } - - /** - * Reads one MORPHLINESTYLE2 value from the stream - * - * @return MORPHLINESTYLE2 value - * @throws IOException - */ - public MORPHLINESTYLE2 readMORPHLINESTYLE2() throws IOException { - MORPHLINESTYLE2 ret = new MORPHLINESTYLE2(); - ret.startWidth = readUI16(); - ret.endWidth = readUI16(); - ret.startCapStyle = (int) readUB(2); - ret.joinStyle = (int) readUB(2); - ret.hasFillFlag = (int) readUB(1) == 1; - ret.noHScaleFlag = (int) readUB(1) == 1; - ret.noVScaleFlag = (int) readUB(1) == 1; - ret.pixelHintingFlag = (int) readUB(1) == 1; - readUB(5);//reserved - ret.noClose = (int) readUB(1) == 1; - ret.endCapStyle = (int) readUB(2); - if (ret.joinStyle == LINESTYLE2.MITER_JOIN) { - ret.miterLimitFactor = readUI16(); - } - if (!ret.hasFillFlag) { - ret.startColor = readRGBA(); - ret.endColor = readRGBA(); - } else { - ret.fillType = readMORPHFILLSTYLE(); - } - return ret; - } - - /** - * Reads one MORPHLINESTYLEARRAY value from the stream - * - * @return MORPHLINESTYLEARRAY value - * @throws IOException - */ - public MORPHLINESTYLEARRAY readMORPHLINESTYLEARRAY(int morphShapeNum) throws IOException { - MORPHLINESTYLEARRAY ret = new MORPHLINESTYLEARRAY(); - int lineStyleCount = readUI8(); - if (lineStyleCount == 0xff) { - lineStyleCount = readUI16(); - } - if (morphShapeNum == 1) { - ret.lineStyles = new MORPHLINESTYLE[lineStyleCount]; - for (int i = 0; i < lineStyleCount; i++) { - ret.lineStyles[i] = readMORPHLINESTYLE(); - } - } else if (morphShapeNum == 2) { - ret.lineStyles2 = new MORPHLINESTYLE2[lineStyleCount]; - for (int i = 0; i < lineStyleCount; i++) { - ret.lineStyles2[i] = readMORPHLINESTYLE2(); - } - } - return ret; - } - - /** - * Reads one KERNINGRECORD value from the stream - * - * @return KERNINGRECORD value - * @throws IOException - */ - public KERNINGRECORD readKERNINGRECORD(boolean fontFlagsWideCodes) throws IOException { - KERNINGRECORD ret = new KERNINGRECORD(); - if (fontFlagsWideCodes) { - ret.fontKerningCode1 = readUI16(); - ret.fontKerningCode2 = readUI16(); - } else { - ret.fontKerningCode1 = readUI8(); - ret.fontKerningCode2 = readUI8(); - } - ret.fontKerningAdjustment = readSI16(); - return ret; - } - - /** - * Reads one LANGCODE value from the stream - * - * @return LANGCODE value - * @throws IOException - */ - public LANGCODE readLANGCODE() throws IOException { - LANGCODE ret = new LANGCODE(); - ret.languageCode = readUI8(); - return ret; - } - - /** - * Reads one ZONERECORD value from the stream - * - * @return ZONERECORD value - * @throws IOException - */ - public ZONERECORD readZONERECORD() throws IOException { - ZONERECORD ret = new ZONERECORD(); - int numZoneData = readUI8(); - ret.zonedata = new ZONEDATA[numZoneData]; - for (int i = 0; i < numZoneData; i++) { - ret.zonedata[i] = readZONEDATA(); - } - readUB(6); - ret.zoneMaskX = readUB(1) == 1; - ret.zoneMaskY = readUB(1) == 1; - return ret; - } - - /** - * Reads one ZONEDATA value from the stream - * - * @return ZONEDATA value - * @throws IOException - */ - public ZONEDATA readZONEDATA() throws IOException { - ZONEDATA ret = new ZONEDATA(); - ret.alignmentCoordinate = readUI16(); - ret.range = readUI16(); - return ret; - } - - /** - * Reads one PIX15 value from the stream - * - * @return PIX15 value - * @throws IOException - */ - public PIX15 readPIX15() throws IOException { - PIX15 ret = new PIX15(); - readUB(1); - ret.red = (int) readUB(5); - ret.green = (int) readUB(5); - ret.blue = (int) readUB(5); - return ret; - } - - /** - * Reads one PIX24 value from the stream - * - * @return PIX24 value - * @throws IOException - */ - public PIX24 readPIX24() throws IOException { - PIX24 ret = new PIX24(); - readUI8(); - ret.red = readUI8(); - ret.green = readUI8(); - ret.blue = readUI8(); - return ret; - } - - /** - * Reads one COLORMAPDATA value from the stream - * - * @return COLORMAPDATA value - * @throws IOException - */ - public COLORMAPDATA readCOLORMAPDATA(int colorTableSize, int bitmapWidth, int bitmapHeight) throws IOException { - COLORMAPDATA ret = new COLORMAPDATA(); - ret.colorTableRGB = new RGB[colorTableSize + 1]; - for (int i = 0; i < colorTableSize + 1; i++) { - ret.colorTableRGB[i] = readRGB(); - } - int dataLen = 0; - for (int y = 0; y < bitmapHeight; y++) { - int x = 0; - for (; x < bitmapWidth; x++) { - dataLen++; - } - while ((x % 4) != 0) { - dataLen++; - x++; - } - } - ret.colorMapPixelData = readBytes(dataLen); - return ret; - } - - /** - * Reads one BITMAPDATA value from the stream - * - * @return COLORMAPDATA value - * @throws IOException - */ - public BITMAPDATA readBITMAPDATA(int bitmapFormat, int bitmapWidth, int bitmapHeight) throws IOException { - BITMAPDATA ret = new BITMAPDATA(); - List pix15 = new ArrayList(); - List pix24 = new ArrayList(); - int dataLen = 0; - for (int y = 0; y < bitmapHeight; y++) { - int x = 0; - for (; x < bitmapWidth; x++) { - if (bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) { - dataLen += 2; - pix15.add(readPIX15()); + } else if (morphShapeNum == 2) { + ret.lineStyles2 = new MORPHLINESTYLE2[lineStyleCount]; + for (int i = 0; i < lineStyleCount; i++) { + ret.lineStyles2[i] = readMORPHLINESTYLE2(); } - if (bitmapFormat == DefineBitsLosslessTag.FORMAT_24BIT_RGB) { - dataLen += 4; - pix24.add(readPIX24()); + } + return ret; + } + + /** + * Reads one KERNINGRECORD value from the stream + * + * @return KERNINGRECORD value + * @throws IOException + */ + public KERNINGRECORD readKERNINGRECORD(boolean fontFlagsWideCodes) throws IOException { + KERNINGRECORD ret = new KERNINGRECORD(); + if (fontFlagsWideCodes) { + ret.fontKerningCode1 = readUI16(); + ret.fontKerningCode2 = readUI16(); + } else { + ret.fontKerningCode1 = readUI8(); + ret.fontKerningCode2 = readUI8(); + } + ret.fontKerningAdjustment = readSI16(); + return ret; + } + + /** + * Reads one LANGCODE value from the stream + * + * @return LANGCODE value + * @throws IOException + */ + public LANGCODE readLANGCODE() throws IOException { + LANGCODE ret = new LANGCODE(); + ret.languageCode = readUI8(); + return ret; + } + + /** + * Reads one ZONERECORD value from the stream + * + * @return ZONERECORD value + * @throws IOException + */ + public ZONERECORD readZONERECORD() throws IOException { + ZONERECORD ret = new ZONERECORD(); + int numZoneData = readUI8(); + ret.zonedata = new ZONEDATA[numZoneData]; + for (int i = 0; i < numZoneData; i++) { + ret.zonedata[i] = readZONEDATA(); + } + readUB(6); + ret.zoneMaskX = readUB(1) == 1; + ret.zoneMaskY = readUB(1) == 1; + return ret; + } + + /** + * Reads one ZONEDATA value from the stream + * + * @return ZONEDATA value + * @throws IOException + */ + public ZONEDATA readZONEDATA() throws IOException { + ZONEDATA ret = new ZONEDATA(); + ret.alignmentCoordinate = readUI16(); + ret.range = readUI16(); + return ret; + } + + /** + * Reads one PIX15 value from the stream + * + * @return PIX15 value + * @throws IOException + */ + public PIX15 readPIX15() throws IOException { + PIX15 ret = new PIX15(); + readUB(1); + ret.red = (int) readUB(5); + ret.green = (int) readUB(5); + ret.blue = (int) readUB(5); + return ret; + } + + /** + * Reads one PIX24 value from the stream + * + * @return PIX24 value + * @throws IOException + */ + public PIX24 readPIX24() throws IOException { + PIX24 ret = new PIX24(); + readUI8(); + ret.red = readUI8(); + ret.green = readUI8(); + ret.blue = readUI8(); + return ret; + } + + /** + * Reads one COLORMAPDATA value from the stream + * + * @return COLORMAPDATA value + * @throws IOException + */ + public COLORMAPDATA readCOLORMAPDATA(int colorTableSize, int bitmapWidth, int bitmapHeight) throws IOException { + COLORMAPDATA ret = new COLORMAPDATA(); + ret.colorTableRGB = new RGB[colorTableSize + 1]; + for (int i = 0; i < colorTableSize + 1; i++) { + ret.colorTableRGB[i] = readRGB(); + } + int dataLen = 0; + for (int y = 0; y < bitmapHeight; y++) { + int x = 0; + for (; x < bitmapWidth; x++) { + dataLen++; } - } - while ((dataLen % 4) != 0) { - dataLen++; - readUI8(); - } - } - if (bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) { - ret.bitmapPixelDataPix15 = pix15.toArray(new PIX15[pix15.size()]); - } else if (bitmapFormat == DefineBitsLosslessTag.FORMAT_24BIT_RGB) { - ret.bitmapPixelDataPix24 = pix24.toArray(new PIX24[pix24.size()]); - } - return ret; - } + while ((x % 4) != 0) { + dataLen++; + x++; + } + } + ret.colorMapPixelData = readBytes(dataLen); + return ret; + } - /** - * Reads one BITMAPDATA value from the stream - * - * @return COLORMAPDATA value - * @throws IOException - */ - public ALPHABITMAPDATA readALPHABITMAPDATA(int bitmapFormat, int bitmapWidth, int bitmapHeight) throws IOException { - ALPHABITMAPDATA ret = new ALPHABITMAPDATA(); - ret.bitmapPixelData = new ARGB[bitmapWidth * bitmapHeight]; - for (int y = 0; y < bitmapHeight; y++) { - for (int x = 0; x < bitmapWidth; x++) { - ret.bitmapPixelData[y * bitmapWidth + x] = readARGB(); - } - } - return ret; - } + /** + * Reads one BITMAPDATA value from the stream + * + * @return COLORMAPDATA value + * @throws IOException + */ + public BITMAPDATA readBITMAPDATA(int bitmapFormat, int bitmapWidth, int bitmapHeight) throws IOException { + BITMAPDATA ret = new BITMAPDATA(); + List pix15 = new ArrayList(); + List pix24 = new ArrayList(); + int dataLen = 0; + for (int y = 0; y < bitmapHeight; y++) { + int x = 0; + for (; x < bitmapWidth; x++) { + if (bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) { + dataLen += 2; + pix15.add(readPIX15()); + } + if (bitmapFormat == DefineBitsLosslessTag.FORMAT_24BIT_RGB) { + dataLen += 4; + pix24.add(readPIX24()); + } + } + while ((dataLen % 4) != 0) { + dataLen++; + readUI8(); + } + } + if (bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) { + ret.bitmapPixelDataPix15 = pix15.toArray(new PIX15[pix15.size()]); + } else if (bitmapFormat == DefineBitsLosslessTag.FORMAT_24BIT_RGB) { + ret.bitmapPixelDataPix24 = pix24.toArray(new PIX24[pix24.size()]); + } + return ret; + } - /** - * Reads one ALPHACOLORMAPDATA value from the stream - * - * @return ALPHACOLORMAPDATA value - * @throws IOException - */ - public ALPHACOLORMAPDATA readALPHACOLORMAPDATA(int colorTableSize, int bitmapWidth, int bitmapHeight) throws IOException { - ALPHACOLORMAPDATA ret = new ALPHACOLORMAPDATA(); - ret.colorTableRGB = new RGBA[colorTableSize + 1]; - for (int i = 0; i < colorTableSize + 1; i++) { - ret.colorTableRGB[i] = readRGBA(); - } - int dataLen = 0; - for (int y = 0; y < bitmapHeight; y++) { - int x = 0; - for (; x < bitmapWidth; x++) { - dataLen++; - } - while ((x % 4) != 0) { - dataLen++; - x++; - } - } - ret.colorMapPixelData = readBytes(dataLen); - return ret; - } + /** + * Reads one BITMAPDATA value from the stream + * + * @return COLORMAPDATA value + * @throws IOException + */ + public ALPHABITMAPDATA readALPHABITMAPDATA(int bitmapFormat, int bitmapWidth, int bitmapHeight) throws IOException { + ALPHABITMAPDATA ret = new ALPHABITMAPDATA(); + ret.bitmapPixelData = new ARGB[bitmapWidth * bitmapHeight]; + for (int y = 0; y < bitmapHeight; y++) { + for (int x = 0; x < bitmapWidth; x++) { + ret.bitmapPixelData[y * bitmapWidth + x] = readARGB(); + } + } + return ret; + } - @Override - public int available() throws IOException { - return is.available(); - } + /** + * Reads one ALPHACOLORMAPDATA value from the stream + * + * @return ALPHACOLORMAPDATA value + * @throws IOException + */ + public ALPHACOLORMAPDATA readALPHACOLORMAPDATA(int colorTableSize, int bitmapWidth, int bitmapHeight) throws IOException { + ALPHACOLORMAPDATA ret = new ALPHACOLORMAPDATA(); + ret.colorTableRGB = new RGBA[colorTableSize + 1]; + for (int i = 0; i < colorTableSize + 1; i++) { + ret.colorTableRGB[i] = readRGBA(); + } + int dataLen = 0; + for (int y = 0; y < bitmapHeight; y++) { + int x = 0; + for (; x < bitmapWidth; x++) { + dataLen++; + } + while ((x % 4) != 0) { + dataLen++; + x++; + } + } + ret.colorMapPixelData = readBytes(dataLen); + return ret; + } + + @Override + public int available() throws IOException { + return is.available(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/SWFOutputStream.java b/trunk/src/com/jpexs/decompiler/flash/SWFOutputStream.java index 0b5a721fb..47d6d836f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/SWFOutputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/SWFOutputStream.java @@ -44,1547 +44,1547 @@ import java.util.List; */ public class SWFOutputStream extends OutputStream { - private OutputStream os; - private int version; - private long pos = 0; - private int bitPos = 0; - private int tempByte = 0; + private OutputStream os; + private int version; + private long pos = 0; + private int bitPos = 0; + private int tempByte = 0; - public long getPos() { - return pos; - } + public long getPos() { + return pos; + } - /** - * Constructor - * - * @param os OutputStream for writing data - * @param version Version of SWF - */ - public SWFOutputStream(OutputStream os, int version) { - this.version = version; - this.os = os; - } + /** + * Constructor + * + * @param os OutputStream for writing data + * @param version Version of SWF + */ + public SWFOutputStream(OutputStream os, int version) { + this.version = version; + this.os = os; + } - /** - * Writes byte to the stream - * - * @param b byte to write - * @throws IOException - */ - @Override - public void write(int b) throws IOException { - alignByte(); - os.write(b); - pos++; - } + /** + * Writes byte to the stream + * + * @param b byte to write + * @throws IOException + */ + @Override + public void write(int b) throws IOException { + alignByte(); + os.write(b); + pos++; + } - private void alignByte() throws IOException { - if (bitPos > 0) { - bitPos = 0; - write(tempByte); - tempByte = 0; - } - } - - /** - * Writes UI8 (Unsigned 8bit integer) value to the stream - * - * @param val UI8 value to write - * @throws IOException - */ - public void writeUI8(int val) throws IOException { - write(val); - } - - /** - * Writes String value to the stream - * - * @param value String value - * @throws IOException - */ - public void writeString(String value) throws IOException { - write(value.getBytes("utf8")); - write(0); - } - - /** - * Writes UI32 (Unsigned 32bit integer) value to the stream - * - * @param value UI32 value - * @throws IOException - */ - public void writeUI32(long value) throws IOException { - write((int) (value & 0xff)); - write((int) ((value >> 8) & 0xff)); - write((int) ((value >> 16) & 0xff)); - write((int) ((value >> 24) & 0xff)); - } - - /** - * Writes UI16 (Unsigned 16bit integer) value to the stream - * - * @param value UI16 value - * @throws IOException - */ - public void writeUI16(int value) throws IOException { - write((int) (value & 0xff)); - write((int) ((value >> 8) & 0xff)); - } - - /** - * Writes SI32 (Signed 32bit integer) value to the stream - * - * @param value SI32 value - * @throws IOException - */ - public void writeSI32(long value) throws IOException { - writeUI32(value); - } - - /** - * Writes SI16 (Signed 16bit integer) value to the stream - * - * @param value SI16 value - * @throws IOException - */ - public void writeSI16(int value) throws IOException { - writeUI16(value); - } - - /** - * Writes SI8 (Signed 8bit integer) value to the stream - * - * @param value SI8 value - * @throws IOException - */ - public void writeSI8(int value) throws IOException { - writeUI8(value); - } - - /** - * Writes FIXED (Fixed point 16.16) value to the stream - * - * @param value FIXED value - * @throws IOException - */ - public void writeFIXED(double value) throws IOException { - long valueLong = (long) (value * (1 << 16)); - int beforePoint = (int) valueLong >> 16; - - int afterPoint = (int) valueLong % (1 << 16); - writeUI16(afterPoint); - writeUI16(beforePoint); - } - - /** - * Writes FIXED8 (Fixed point 8.8) value to the stream - * - * @param value FIXED8 value - * @throws IOException - */ - public void writeFIXED8(float value) throws IOException { - int beforePoint = (int) getIntPart(value); - int afterPoint = (int) getIntPart((value + (value < 0 ? beforePoint : -beforePoint)) * 256); - writeUI8(afterPoint); - writeUI8(beforePoint); - } - - private void writeLong(long value) throws IOException { - byte writeBuffer[] = new byte[8]; - writeBuffer[3] = (byte) (value >>> 56); - writeBuffer[2] = (byte) (value >>> 48); - writeBuffer[1] = (byte) (value >>> 40); - writeBuffer[0] = (byte) (value >>> 32); - writeBuffer[7] = (byte) (value >>> 24); - writeBuffer[6] = (byte) (value >>> 16); - writeBuffer[5] = (byte) (value >>> 8); - writeBuffer[4] = (byte) (value); - write(writeBuffer); - } - - /** - * Writes DOUBLE (double precision floating point value) value to the stream - * - * @param value DOUBLE value - * @throws IOException - */ - public void writeDOUBLE(double value) throws IOException { - writeLong(Double.doubleToLongBits(value)); - } - - /** - * Writes FLOAT (single precision floating point value) value to the stream - * - * @param value FLOAT value - * @throws IOException - */ - public void writeFLOAT(float value) throws IOException { - writeUI32(Float.floatToIntBits(value)); - } - - /** - * Writes FLOAT16 (16bit floating point value) value to the stream - * - * @param value FLOAT16 value - * @throws IOException - */ - public void writeFLOAT16(float value) throws IOException { - int bits = Float.floatToRawIntBits(value); - int sign = bits >> 31; - int exponent = (bits >> 22) & 0xff; - int mantisa = bits & 0x3FFFFF; - mantisa = mantisa >> 13; - writeUI16((sign << 15) + (exponent << 10) + mantisa); - } - - /** - * Writes EncodedU32 (Encoded unsigned 32bit value) value to the stream - * - * @param value U32 value - * @throws IOException - */ - public void writeEncodedU32(long value) throws IOException { - boolean loop = true; - value = value & 0xFFFFFFFF; - do { - int ret = (int) (value & 0x7F); - if (value < 0x80) { - loop = false; - } - if (value > 0x7F) { - ret += 0x80; - } - write(ret); - value = value >> 7; - } while (loop); - } - - /** - * Flushes data to underlying stream - * - * @throws IOException - */ - @Override - public void flush() throws IOException { - if (bitPos > 0) { - bitPos = 0; - write(tempByte); - tempByte = 0; - } - os.flush(); - } - - /** - * Closes the stream - * - * @throws IOException - */ - @Override - public void close() throws IOException { - flush(); - os.close(); - } - - /** - * Writes UB[nBits] (Unsigned-bit value) value to the stream - * - * @param nBits Number of bits which represent value - * @param value Unsigned value to write - * @throws IOException - */ - public void writeUB(int nBits, long value) throws IOException { - for (int bit = 0; bit < nBits; bit++) { - int nb = (int) ((value >> (nBits - 1 - bit)) & 1); - tempByte += nb * (1 << (7 - bitPos)); - bitPos++; - if (bitPos == 8) { + private void alignByte() throws IOException { + if (bitPos > 0) { bitPos = 0; write(tempByte); tempByte = 0; - } - } - } + } + } - /** - * Writes SB[nBits] (Signed-bit value) value to the stream - * - * @param nBits Number of bits which represent value - * @param value Signed value to write - * @throws IOException - */ - public void writeSB(int nBits, long value) throws IOException { - long tmp = value & 0x7FFFFFFF; + /** + * Writes UI8 (Unsigned 8bit integer) value to the stream + * + * @param val UI8 value to write + * @throws IOException + */ + public void writeUI8(int val) throws IOException { + write(val); + } - if (value < 0) { - tmp = tmp | (1L << (nBits - 1)); - } - writeUB(nBits, value); - } + /** + * Writes String value to the stream + * + * @param value String value + * @throws IOException + */ + public void writeString(String value) throws IOException { + write(value.getBytes("utf8")); + write(0); + } - /** - * Writes FB[nBits] (Signed fixed-point bit value) value to the stream - * - * @param nBits Number of bits which represent value - * @param value Double value to write - * @throws IOException - */ - public void writeFB(int nBits, double value) throws IOException { - if (nBits == 0) { - return; - } - long longVal = (long) (value * (1 << 16)); - writeSB(nBits, longVal); - } + /** + * Writes UI32 (Unsigned 32bit integer) value to the stream + * + * @param value UI32 value + * @throws IOException + */ + public void writeUI32(long value) throws IOException { + write((int) (value & 0xff)); + write((int) ((value >> 8) & 0xff)); + write((int) ((value >> 16) & 0xff)); + write((int) ((value >> 24) & 0xff)); + } - /** - * Writes RECT value to the stream - * - * @param value RECT value - * @throws IOException - */ - public void writeRECT(RECT value) throws IOException { - int nBits = 0; - nBits = enlargeBitCountS(nBits, value.Xmin); - nBits = enlargeBitCountS(nBits, value.Xmax); - nBits = enlargeBitCountS(nBits, value.Ymin); - nBits = enlargeBitCountS(nBits, value.Ymax); - writeUB(5, nBits); - writeSB(nBits, value.Xmin); - writeSB(nBits, value.Xmax); - writeSB(nBits, value.Ymin); - writeSB(nBits, value.Ymax); - alignByte(); - } + /** + * Writes UI16 (Unsigned 16bit integer) value to the stream + * + * @param value UI16 value + * @throws IOException + */ + public void writeUI16(int value) throws IOException { + write((int) (value & 0xff)); + write((int) ((value >> 8) & 0xff)); + } - /** - * Writes list of Tag values to the stream - * - * @param tags List of tag values - * @throws IOException - */ - public void writeTags(List tags) throws IOException { - for (Tag tag : tags) { - //try { - writeTag(tag); - /*} catch (NotSameException nse) { - throw new RuntimeException("error in tag "+tag+" at pos "+Helper.formatHex((int)tag.getPos(), 8), nse); - }*/ - //NotSameException must be processed in order to catch it elsewhere - } - } + /** + * Writes SI32 (Signed 32bit integer) value to the stream + * + * @param value SI32 value + * @throws IOException + */ + public void writeSI32(long value) throws IOException { + writeUI32(value); + } - public static byte[] getTagHeader(Tag tag, byte data[], int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try { + /** + * Writes SI16 (Signed 16bit integer) value to the stream + * + * @param value SI16 value + * @throws IOException + */ + public void writeSI16(int value) throws IOException { + writeUI16(value); + } - SWFOutputStream sos = new SWFOutputStream(baos, version); - int tagLength = data.length; - int tagID = tag.getId(); - int tagIDLength = (tagID << 6); - if ((tagLength < 0x3f) && (!tag.forceWriteAsLong)) { - tagIDLength += tagLength; - sos.writeUI16(tagIDLength); - } else { - tagIDLength += 0x3f; - sos.writeUI16(tagIDLength); - sos.writeSI32(tagLength); - } - } catch (IOException iex) { - } - return baos.toByteArray(); - } + /** + * Writes SI8 (Signed 8bit integer) value to the stream + * + * @param value SI8 value + * @throws IOException + */ + public void writeSI8(int value) throws IOException { + writeUI8(value); + } - /** - * Writes Tag value to the stream - * - * @param tag Tag value - * @throws IOException - */ - public void writeTag(Tag tag) throws IOException { - byte data[] = tag.getData(version); - write(getTagHeader(tag, data, version)); - write(data); - } + /** + * Writes FIXED (Fixed point 16.16) value to the stream + * + * @param value FIXED value + * @throws IOException + */ + public void writeFIXED(double value) throws IOException { + long valueLong = (long) (value * (1 << 16)); + int beforePoint = (int) valueLong >> 16; - /** - * Calculates number of bits needed for representing unsigned value - * - * @param v Unsigned value - * @return Number of bits - */ - public static int getNeededBitsU(int value) { - value = Math.abs(value); - long x = 1; - int nBits; + int afterPoint = (int) valueLong % (1 << 16); + writeUI16(afterPoint); + writeUI16(beforePoint); + } - for (nBits = 1; nBits <= 64; nBits++) { - x <<= 1; - if (x > value) { - break; - } - } - return nBits; - } + /** + * Writes FIXED8 (Fixed point 8.8) value to the stream + * + * @param value FIXED8 value + * @throws IOException + */ + public void writeFIXED8(float value) throws IOException { + int beforePoint = (int) getIntPart(value); + int afterPoint = (int) getIntPart((value + (value < 0 ? beforePoint : -beforePoint)) * 256); + writeUI8(afterPoint); + writeUI8(beforePoint); + } - /** - * Calculates number of bits needed for representing signed value - * - * @param v Signed value - * @return Number of bits - */ - public static int getNeededBitsS(int v) { - if (v == 0) { - //return 0; - } - int counter = 32; - int mask = 0x80000000; - final int val = (v < 0) ? -v : v; - while (((val & mask) == 0) && (counter > 0)) { - mask >>>= 1; - counter -= 1; - } - return counter + 1; - } + private void writeLong(long value) throws IOException { + byte writeBuffer[] = new byte[8]; + writeBuffer[3] = (byte) (value >>> 56); + writeBuffer[2] = (byte) (value >>> 48); + writeBuffer[1] = (byte) (value >>> 40); + writeBuffer[0] = (byte) (value >>> 32); + writeBuffer[7] = (byte) (value >>> 24); + writeBuffer[6] = (byte) (value >>> 16); + writeBuffer[5] = (byte) (value >>> 8); + writeBuffer[4] = (byte) (value); + write(writeBuffer); + } - private static long getIntPart(double value) { - if (value < 0) { - return (long) Math.ceil(value); - } - return (long) Math.floor(value); - } + /** + * Writes DOUBLE (double precision floating point value) value to the stream + * + * @param value DOUBLE value + * @throws IOException + */ + public void writeDOUBLE(double value) throws IOException { + writeLong(Double.doubleToLongBits(value)); + } - private static double getFloatPart(double value) { - if (value < 0) { - return value - getIntPart(value); - } - return value + getIntPart(value); - } + /** + * Writes FLOAT (single precision floating point value) value to the stream + * + * @param value FLOAT value + * @throws IOException + */ + public void writeFLOAT(float value) throws IOException { + writeUI32(Float.floatToIntBits(value)); + } - public static int unsignedSize(final int value) { + /** + * Writes FLOAT16 (16bit floating point value) value to the stream + * + * @param value FLOAT16 value + * @throws IOException + */ + public void writeFLOAT16(float value) throws IOException { + int bits = Float.floatToRawIntBits(value); + int sign = bits >> 31; + int exponent = (bits >> 22) & 0xff; + int mantisa = bits & 0x3FFFFF; + mantisa = mantisa >> 13; + writeUI16((sign << 15) + (exponent << 10) + mantisa); + } - final int val = (value < 0) ? -value - 1 : value; - int counter = 32; - int mask = 0x80000000; + /** + * Writes EncodedU32 (Encoded unsigned 32bit value) value to the stream + * + * @param value U32 value + * @throws IOException + */ + public void writeEncodedU32(long value) throws IOException { + boolean loop = true; + value = value & 0xFFFFFFFF; + do { + int ret = (int) (value & 0x7F); + if (value < 0x80) { + loop = false; + } + if (value > 0x7F) { + ret += 0x80; + } + write(ret); + value = value >> 7; + } while (loop); + } - while (((val & mask) == 0) && (counter > 0)) { - mask >>>= 1; - counter -= 1; - } - return counter; - } + /** + * Flushes data to underlying stream + * + * @throws IOException + */ + @Override + public void flush() throws IOException { + if (bitPos > 0) { + bitPos = 0; + write(tempByte); + tempByte = 0; + } + os.flush(); + } - /** - * Calculates number of bits needed for representing fixed-point value - * - * @param value Fixed-point value - * @return Number of bits - */ - public static int getNeededBitsF(float value) { - //0.26213074 16bits - //0.5 17bits - //1.3476715 18bits - int k = (int) value; - return getNeededBitsS(k) + 16; - } + /** + * Closes the stream + * + * @throws IOException + */ + @Override + public void close() throws IOException { + flush(); + os.close(); + } - private int enlargeBitCountU(int currentBitCount, int value) { - int neededNew = getNeededBitsU(value); - if (neededNew > currentBitCount) { - return neededNew; - } - return currentBitCount; - } + /** + * Writes UB[nBits] (Unsigned-bit value) value to the stream + * + * @param nBits Number of bits which represent value + * @param value Unsigned value to write + * @throws IOException + */ + public void writeUB(int nBits, long value) throws IOException { + for (int bit = 0; bit < nBits; bit++) { + int nb = (int) ((value >> (nBits - 1 - bit)) & 1); + tempByte += nb * (1 << (7 - bitPos)); + bitPos++; + if (bitPos == 8) { + bitPos = 0; + write(tempByte); + tempByte = 0; + } + } + } - private int enlargeBitCountS(int currentBitCount, int value) { - int neededNew = getNeededBitsS(value); - if (neededNew > currentBitCount) { - return neededNew; - } - return currentBitCount; - } + /** + * Writes SB[nBits] (Signed-bit value) value to the stream + * + * @param nBits Number of bits which represent value + * @param value Signed value to write + * @throws IOException + */ + public void writeSB(int nBits, long value) throws IOException { + long tmp = value & 0x7FFFFFFF; - private int enlargeBitCountF(int currentBitCount, float value) { - int neededNew = getNeededBitsF(value); - if (neededNew > currentBitCount) { - return neededNew; - } - return currentBitCount; - } + if (value < 0) { + tmp = tmp | (1L << (nBits - 1)); + } + writeUB(nBits, value); + } - /** - * Writes MATRIX value to the stream - * - * @param value MATRIX value - * @throws IOException - */ - public void writeMatrix(MATRIX value) throws IOException { - writeUB(1, value.hasScale ? 1 : 0); - if (value.hasScale) { - int nBits = 0; - nBits = enlargeBitCountS(nBits, value.scaleX); - nBits = enlargeBitCountS(nBits, value.scaleY); - writeUB(5, nBits); - writeSB(nBits, value.scaleX); - writeSB(nBits, value.scaleY); - } - writeUB(1, value.hasRotate ? 1 : 0); - if (value.hasRotate) { - int nBits = 0; - nBits = enlargeBitCountS(nBits, value.rotateSkew0); - nBits = enlargeBitCountS(nBits, value.rotateSkew1); - writeUB(5, nBits); - writeSB(nBits, value.rotateSkew0); - writeSB(nBits, value.rotateSkew1); - } - int NTranslateBits = 0; - NTranslateBits = enlargeBitCountS(NTranslateBits, value.translateX); - NTranslateBits = enlargeBitCountS(NTranslateBits, value.translateY); + /** + * Writes FB[nBits] (Signed fixed-point bit value) value to the stream + * + * @param nBits Number of bits which represent value + * @param value Double value to write + * @throws IOException + */ + public void writeFB(int nBits, double value) throws IOException { + if (nBits == 0) { + return; + } + long longVal = (long) (value * (1 << 16)); + writeSB(nBits, longVal); + } - writeUB(5, NTranslateBits); + /** + * Writes RECT value to the stream + * + * @param value RECT value + * @throws IOException + */ + public void writeRECT(RECT value) throws IOException { + int nBits = 0; + nBits = enlargeBitCountS(nBits, value.Xmin); + nBits = enlargeBitCountS(nBits, value.Xmax); + nBits = enlargeBitCountS(nBits, value.Ymin); + nBits = enlargeBitCountS(nBits, value.Ymax); + writeUB(5, nBits); + writeSB(nBits, value.Xmin); + writeSB(nBits, value.Xmax); + writeSB(nBits, value.Ymin); + writeSB(nBits, value.Ymax); + alignByte(); + } - writeSB(NTranslateBits, value.translateX); - writeSB(NTranslateBits, value.translateY); - alignByte(); + /** + * Writes list of Tag values to the stream + * + * @param tags List of tag values + * @throws IOException + */ + public void writeTags(List tags) throws IOException { + for (Tag tag : tags) { + //try { + writeTag(tag); + /*} catch (NotSameException nse) { + throw new RuntimeException("error in tag "+tag+" at pos "+Helper.formatHex((int)tag.getPos(), 8), nse); + }*/ + //NotSameException must be processed in order to catch it elsewhere + } + } - } + public static byte[] getTagHeader(Tag tag, byte data[], int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { - /** - * Writes CXFORM value to the stream - * - * @param value CXFORM value - * @throws IOException - */ - public void writeCXFORM(CXFORM value) throws IOException { - writeUB(1, value.hasAddTerms ? 1 : 0); - writeUB(1, value.hasMultTerms ? 1 : 0); - int Nbits = 1; - if (value.hasMultTerms) { - Nbits = enlargeBitCountS(Nbits, value.redMultTerm); - Nbits = enlargeBitCountS(Nbits, value.greenMultTerm); - Nbits = enlargeBitCountS(Nbits, value.blueMultTerm); - } - if (value.hasAddTerms) { - Nbits = enlargeBitCountS(Nbits, value.redAddTerm); - Nbits = enlargeBitCountS(Nbits, value.greenAddTerm); - Nbits = enlargeBitCountS(Nbits, value.blueAddTerm); - } - writeUB(4, Nbits); - if (value.hasMultTerms) { - writeSB(Nbits, value.redMultTerm); - writeSB(Nbits, value.greenMultTerm); - writeSB(Nbits, value.blueMultTerm); - } - if (value.hasAddTerms) { - writeSB(Nbits, value.redAddTerm); - writeSB(Nbits, value.greenAddTerm); - writeSB(Nbits, value.blueAddTerm); - } - alignByte(); - } + SWFOutputStream sos = new SWFOutputStream(baos, version); + int tagLength = data.length; + int tagID = tag.getId(); + int tagIDLength = (tagID << 6); + if ((tagLength < 0x3f) && (!tag.forceWriteAsLong)) { + tagIDLength += tagLength; + sos.writeUI16(tagIDLength); + } else { + tagIDLength += 0x3f; + sos.writeUI16(tagIDLength); + sos.writeSI32(tagLength); + } + } catch (IOException iex) { + } + return baos.toByteArray(); + } - /** - * Writes CXFORMWITHALPHA value to the stream - * - * @param value CXFORMWITHALPHA value - * @throws IOException - */ - public void writeCXFORMWITHALPHA(CXFORMWITHALPHA value) throws IOException { - writeUB(1, value.hasAddTerms ? 1 : 0); - writeUB(1, value.hasMultTerms ? 1 : 0); - int Nbits = 1; - if (value.hasMultTerms) { - Nbits = enlargeBitCountS(Nbits, value.redMultTerm); - Nbits = enlargeBitCountS(Nbits, value.greenMultTerm); - Nbits = enlargeBitCountS(Nbits, value.blueMultTerm); - Nbits = enlargeBitCountS(Nbits, value.alphaMultTerm); - } - if (value.hasAddTerms) { - Nbits = enlargeBitCountS(Nbits, value.redAddTerm); - Nbits = enlargeBitCountS(Nbits, value.greenAddTerm); - Nbits = enlargeBitCountS(Nbits, value.blueAddTerm); - Nbits = enlargeBitCountS(Nbits, value.alphaAddTerm); - } - writeUB(4, Nbits); - if (value.hasMultTerms) { - writeSB(Nbits, value.redMultTerm); - writeSB(Nbits, value.greenMultTerm); - writeSB(Nbits, value.blueMultTerm); - writeSB(Nbits, value.alphaMultTerm); - } - if (value.hasAddTerms) { - writeSB(Nbits, value.redAddTerm); - writeSB(Nbits, value.greenAddTerm); - writeSB(Nbits, value.blueAddTerm); - writeSB(Nbits, value.alphaAddTerm); - } - alignByte(); - } + /** + * Writes Tag value to the stream + * + * @param tag Tag value + * @throws IOException + */ + public void writeTag(Tag tag) throws IOException { + byte data[] = tag.getData(version); + write(getTagHeader(tag, data, version)); + write(data); + } - /** - * Writes CLIPEVENTFLAGS value to the stream - * - * @param value CLIPEVENTFLAGS value - * @throws IOException - */ - public void writeCLIPEVENTFLAGS(CLIPEVENTFLAGS value) throws IOException { - writeUB(1, value.clipEventKeyUp ? 1 : 0); - writeUB(1, value.clipEventKeyDown ? 1 : 0); - writeUB(1, value.clipEventMouseUp ? 1 : 0); - writeUB(1, value.clipEventMouseDown ? 1 : 0); - writeUB(1, value.clipEventMouseMove ? 1 : 0); - writeUB(1, value.clipEventUnload ? 1 : 0); - writeUB(1, value.clipEventEnterFrame ? 1 : 0); - writeUB(1, value.clipEventLoad ? 1 : 0); - writeUB(1, value.clipEventDragOver ? 1 : 0); - writeUB(1, value.clipEventRollOut ? 1 : 0); - writeUB(1, value.clipEventRollOver ? 1 : 0); - writeUB(1, value.clipEventReleaseOutside ? 1 : 0); - writeUB(1, value.clipEventRelease ? 1 : 0); - writeUB(1, value.clipEventPress ? 1 : 0); - writeUB(1, value.clipEventInitialize ? 1 : 0); - writeUB(1, value.clipEventData ? 1 : 0); - if (version >= 6) { - writeUB(5, 0); - writeUB(1, value.clipEventConstruct ? 1 : 0); - writeUB(1, value.clipEventKeyPress ? 1 : 0); - writeUB(1, value.clipEventDragOut ? 1 : 0); - writeUB(8, 0); - } - } + /** + * Calculates number of bits needed for representing unsigned value + * + * @param v Unsigned value + * @return Number of bits + */ + public static int getNeededBitsU(int value) { + value = Math.abs(value); + long x = 1; + int nBits; - /** - * Writes CLIPACTIONRECORD value to the stream - * - * @param value CLIPACTIONRECORD value - * @throws IOException - */ - public void writeCLIPACTIONRECORD(CLIPACTIONRECORD value) throws IOException { - writeCLIPEVENTFLAGS(value.eventFlags); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); + for (nBits = 1; nBits <= 64; nBits++) { + x <<= 1; + if (x > value) { + break; + } + } + return nBits; + } - if (value.eventFlags.clipEventKeyPress) { - sos.writeUI8(value.keyCode); - } - sos.write(value.actionBytes); - //sos.write(Action.actionsToBytes(value.actions, true, version)); - sos.close(); - byte data[] = baos.toByteArray(); - writeUI32(data.length); //actionRecordSize - write(data); - } + /** + * Calculates number of bits needed for representing signed value + * + * @param v Signed value + * @return Number of bits + */ + public static int getNeededBitsS(int v) { + if (v == 0) { + //return 0; + } + int counter = 32; + int mask = 0x80000000; + final int val = (v < 0) ? -v : v; + while (((val & mask) == 0) && (counter > 0)) { + mask >>>= 1; + counter -= 1; + } + return counter + 1; + } - /** - * Writes CLIPACTIONS value to the stream - * - * @param value CLIPACTIONS value - * @throws IOException - */ - public void writeCLIPACTIONS(CLIPACTIONS value) throws IOException { - writeUI16(0);//reserved - writeCLIPEVENTFLAGS(value.allEventFlags); - for (CLIPACTIONRECORD car : value.clipActionRecords) { - writeCLIPACTIONRECORD(car); - } - if (version <= 5) { - writeUI16(0); - } else { - writeUI32(0); - } - } + private static long getIntPart(double value) { + if (value < 0) { + return (long) Math.ceil(value); + } + return (long) Math.floor(value); + } - /** - * Writes COLORMATRIXFILTER value to the stream - * - * @param value COLORMATRIXFILTER value - * @throws IOException - */ - public void writeCOLORMATRIXFILTER(COLORMATRIXFILTER value) throws IOException { - for (int i = 0; i < 20; i++) { - writeFLOAT(value.matrix[i]); - } - } + private static double getFloatPart(double value) { + if (value < 0) { + return value - getIntPart(value); + } + return value + getIntPart(value); + } - /** - * Writes RGBA value to the stream - * - * @param value RGBA value - * @throws IOException - */ - public void writeRGBA(RGBA value) throws IOException { - writeUI8(value.red); - writeUI8(value.green); - writeUI8(value.blue); - writeUI8(value.alpha); - } + public static int unsignedSize(final int value) { - /** - * Writes RGB value to the stream - * - * @param value RGB value - * @throws IOException - */ - public void writeRGB(RGB value) throws IOException { - writeUI8(value.red); - writeUI8(value.green); - writeUI8(value.blue); - } + final int val = (value < 0) ? -value - 1 : value; + int counter = 32; + int mask = 0x80000000; - /** - * Writes CONVOLUTIONFILTER value to the stream - * - * @param value CONVOLUTIONFILTER value - * @throws IOException - */ - public void writeCONVOLUTIONFILTER(CONVOLUTIONFILTER value) throws IOException { - writeUI8(value.matrixX); - writeUI8(value.matrixY); - writeFLOAT(value.divisor); - writeFLOAT(value.bias); - for (int x = 0; x < value.matrixX; x++) { - for (int y = 0; y < value.matrixY; y++) { - writeFLOAT(value.matrix[x][y]); - } - } - writeRGBA(value.defaultColor); - writeUB(6, 0); //reserved - writeUB(1, value.clamp ? 1 : 0); - writeUB(1, value.preserveAlpha ? 1 : 0); - } + while (((val & mask) == 0) && (counter > 0)) { + mask >>>= 1; + counter -= 1; + } + return counter; + } - /** - * Writes BLURFILTER value to the stream - * - * @param value BLURFILTER value - * @throws IOException - */ - public void writeBLURFILTER(BLURFILTER value) throws IOException { - writeFIXED(value.blurX); - writeFIXED(value.blurY); - writeUB(5, value.passes); - writeUB(3, 0);//reserved - } + /** + * Calculates number of bits needed for representing fixed-point value + * + * @param value Fixed-point value + * @return Number of bits + */ + public static int getNeededBitsF(float value) { + //0.26213074 16bits + //0.5 17bits + //1.3476715 18bits + int k = (int) value; + return getNeededBitsS(k) + 16; + } - /** - * Writes DROPSHADOWFILTER value to the stream - * - * @param value DROPSHADOWFILTER value - * @throws IOException - */ - public void writeDROPSHADOWFILTER(DROPSHADOWFILTER value) throws IOException { - writeRGBA(value.dropShadowColor); - writeFIXED(value.blurX); - writeFIXED(value.blurY); - writeFIXED(value.angle); - writeFIXED(value.distance); - writeFIXED8(value.strength); - writeUB(1, value.innerShadow ? 1 : 0); - writeUB(1, value.knockout ? 1 : 0); - writeUB(1, value.compositeSource ? 1 : 0); - writeUB(5, value.passes); - } + private int enlargeBitCountU(int currentBitCount, int value) { + int neededNew = getNeededBitsU(value); + if (neededNew > currentBitCount) { + return neededNew; + } + return currentBitCount; + } - /** - * Writes GLOWFILTER value to the stream - * - * @param value GLOWFILTER value - * @throws IOException - */ - public void writeGLOWFILTER(GLOWFILTER value) throws IOException { - writeRGBA(value.glowColor); - writeFIXED(value.blurX); - writeFIXED(value.blurY); - writeFIXED8(value.strength); - writeUB(1, value.innerGlow ? 1 : 0); - writeUB(1, value.knockout ? 1 : 0); - writeUB(1, value.compositeSource ? 1 : 0); - writeUB(5, value.passes); - } + private int enlargeBitCountS(int currentBitCount, int value) { + int neededNew = getNeededBitsS(value); + if (neededNew > currentBitCount) { + return neededNew; + } + return currentBitCount; + } - /** - * Writes BEVELFILTER value to the stream - * - * @param value BEVELFILTER value - * @throws IOException - */ - public void writeBEVELFILTER(BEVELFILTER value) throws IOException { - writeRGBA(value.shadowColor); - writeRGBA(value.highlightColor); - writeFIXED(value.blurX); - writeFIXED(value.blurY); - writeFIXED(value.angle); - writeFIXED(value.distance); - writeFIXED8(value.strength); - writeUB(1, value.innerShadow ? 1 : 0); - writeUB(1, value.knockout ? 1 : 0); - writeUB(1, value.compositeSource ? 1 : 0); - writeUB(1, value.onTop ? 1 : 0); - writeUB(4, value.passes); - } + private int enlargeBitCountF(int currentBitCount, float value) { + int neededNew = getNeededBitsF(value); + if (neededNew > currentBitCount) { + return neededNew; + } + return currentBitCount; + } - /** - * Writes GRADIENTGLOWFILTER value to the stream - * - * @param value GRADIENTGLOWFILTER value - * @throws IOException - */ - public void writeGRADIENTGLOWFILTER(GRADIENTGLOWFILTER value) throws IOException { - writeUI8(value.gradientColors.length); - for (int i = 0; i < value.gradientColors.length; i++) { - writeRGBA(value.gradientColors[i]); - } - for (int i = 0; i < value.gradientColors.length; i++) { - writeUI8(value.gradientRatio[i]); - } - writeFIXED(value.blurX); - writeFIXED(value.blurY); - writeFIXED(value.angle); - writeFIXED(value.distance); - writeFIXED8(value.strength); - writeUB(1, value.innerShadow ? 1 : 0); - writeUB(1, value.knockout ? 1 : 0); - writeUB(1, value.compositeSource ? 1 : 0); - writeUB(1, value.onTop ? 1 : 0); - writeUB(4, value.passes); - } + /** + * Writes MATRIX value to the stream + * + * @param value MATRIX value + * @throws IOException + */ + public void writeMatrix(MATRIX value) throws IOException { + writeUB(1, value.hasScale ? 1 : 0); + if (value.hasScale) { + int nBits = 0; + nBits = enlargeBitCountS(nBits, value.scaleX); + nBits = enlargeBitCountS(nBits, value.scaleY); + writeUB(5, nBits); + writeSB(nBits, value.scaleX); + writeSB(nBits, value.scaleY); + } + writeUB(1, value.hasRotate ? 1 : 0); + if (value.hasRotate) { + int nBits = 0; + nBits = enlargeBitCountS(nBits, value.rotateSkew0); + nBits = enlargeBitCountS(nBits, value.rotateSkew1); + writeUB(5, nBits); + writeSB(nBits, value.rotateSkew0); + writeSB(nBits, value.rotateSkew1); + } + int NTranslateBits = 0; + NTranslateBits = enlargeBitCountS(NTranslateBits, value.translateX); + NTranslateBits = enlargeBitCountS(NTranslateBits, value.translateY); - /** - * Writes GRADIENTBEVELFILTER value to the stream - * - * @param value GRADIENTBEVELFILTER value - * @throws IOException - */ - public void writeGRADIENTBEVELFILTER(GRADIENTBEVELFILTER value) throws IOException { - writeUI8(value.gradientColors.length); - for (int i = 0; i < value.gradientColors.length; i++) { - writeRGBA(value.gradientColors[i]); - } - for (int i = 0; i < value.gradientColors.length; i++) { - writeUI8(value.gradientRatio[i]); - } - writeFIXED(value.blurX); - writeFIXED(value.blurY); - writeFIXED(value.angle); - writeFIXED(value.distance); - writeFIXED8(value.strength); - writeUB(1, value.innerShadow ? 1 : 0); - writeUB(1, value.knockout ? 1 : 0); - writeUB(1, value.compositeSource ? 1 : 0); - writeUB(1, value.onTop ? 1 : 0); - writeUB(4, value.passes); - } + writeUB(5, NTranslateBits); - /** - * Writes list of FILTER values to the stream - * - * @param list List of FILTER values - * @throws IOException - */ - public void writeFILTERLIST(List list) throws IOException { - writeUI8(list.size()); - for (int i = 0; i < list.size(); i++) { - writeFILTER(list.get(i)); - } - } + writeSB(NTranslateBits, value.translateX); + writeSB(NTranslateBits, value.translateY); + alignByte(); - /** - * Writes FILTER value to the stream - * - * @param value FILTER value - * @throws IOException - */ - public void writeFILTER(FILTER value) throws IOException { - writeUI8(value.id); - switch (value.id) { - case 0: - writeDROPSHADOWFILTER((DROPSHADOWFILTER) value); - break; - case 1: - writeBLURFILTER((BLURFILTER) value); - break; - case 2: - writeGLOWFILTER((GLOWFILTER) value); - break; - case 3: - writeBEVELFILTER((BEVELFILTER) value); - break; - case 4: - writeGRADIENTGLOWFILTER((GRADIENTGLOWFILTER) value); - break; - case 5: - writeCONVOLUTIONFILTER((CONVOLUTIONFILTER) value); - break; - case 6: - writeCOLORMATRIXFILTER((COLORMATRIXFILTER) value); - break; - case 7: - writeGRADIENTBEVELFILTER((GRADIENTBEVELFILTER) value); - break; - } - } + } - /** - * Writes list of BUTTONRECORD values to the stream - * - * @param list List of BUTTONRECORD values - * @param inDefineButton2 Whether write inside of DefineButton2Tag or not - * @throws IOException - */ - public void writeBUTTONRECORDList(List list, boolean inDefineButton2) throws IOException { - for (BUTTONRECORD brec : list) { - writeBUTTONRECORD(brec, inDefineButton2); - } - writeUI8(0); - } + /** + * Writes CXFORM value to the stream + * + * @param value CXFORM value + * @throws IOException + */ + public void writeCXFORM(CXFORM value) throws IOException { + writeUB(1, value.hasAddTerms ? 1 : 0); + writeUB(1, value.hasMultTerms ? 1 : 0); + int Nbits = 1; + if (value.hasMultTerms) { + Nbits = enlargeBitCountS(Nbits, value.redMultTerm); + Nbits = enlargeBitCountS(Nbits, value.greenMultTerm); + Nbits = enlargeBitCountS(Nbits, value.blueMultTerm); + } + if (value.hasAddTerms) { + Nbits = enlargeBitCountS(Nbits, value.redAddTerm); + Nbits = enlargeBitCountS(Nbits, value.greenAddTerm); + Nbits = enlargeBitCountS(Nbits, value.blueAddTerm); + } + writeUB(4, Nbits); + if (value.hasMultTerms) { + writeSB(Nbits, value.redMultTerm); + writeSB(Nbits, value.greenMultTerm); + writeSB(Nbits, value.blueMultTerm); + } + if (value.hasAddTerms) { + writeSB(Nbits, value.redAddTerm); + writeSB(Nbits, value.greenAddTerm); + writeSB(Nbits, value.blueAddTerm); + } + alignByte(); + } - /** - * Writes BUTTONRECORD value to the stream - * - * @param value BUTTONRECORD value - * @param inDefineButton2 Whether write inside of DefineButton2Tag or not - * @throws IOException - */ - public void writeBUTTONRECORD(BUTTONRECORD value, boolean inDefineButton2) throws IOException { - writeUB(2, 0);//reserved - writeUB(1, value.buttonHasBlendMode ? 1 : 0); - writeUB(1, value.buttonHasFilterList ? 1 : 0); - writeUB(1, value.buttonStateHitTest ? 1 : 0); - writeUB(1, value.buttonStateDown ? 1 : 0); - writeUB(1, value.buttonStateOver ? 1 : 0); - writeUB(1, value.buttonStateUp ? 1 : 0); - writeUI16(value.characterId); - writeUI16(value.placeDepth); - writeMatrix(value.placeMatrix); - if (inDefineButton2) { - writeCXFORMWITHALPHA(value.colorTransform); - if (value.buttonHasFilterList) { - writeFILTERLIST(value.filterList); - } - if (value.buttonHasBlendMode) { - writeUI8(value.blendMode); - } - } - } + /** + * Writes CXFORMWITHALPHA value to the stream + * + * @param value CXFORMWITHALPHA value + * @throws IOException + */ + public void writeCXFORMWITHALPHA(CXFORMWITHALPHA value) throws IOException { + writeUB(1, value.hasAddTerms ? 1 : 0); + writeUB(1, value.hasMultTerms ? 1 : 0); + int Nbits = 1; + if (value.hasMultTerms) { + Nbits = enlargeBitCountS(Nbits, value.redMultTerm); + Nbits = enlargeBitCountS(Nbits, value.greenMultTerm); + Nbits = enlargeBitCountS(Nbits, value.blueMultTerm); + Nbits = enlargeBitCountS(Nbits, value.alphaMultTerm); + } + if (value.hasAddTerms) { + Nbits = enlargeBitCountS(Nbits, value.redAddTerm); + Nbits = enlargeBitCountS(Nbits, value.greenAddTerm); + Nbits = enlargeBitCountS(Nbits, value.blueAddTerm); + Nbits = enlargeBitCountS(Nbits, value.alphaAddTerm); + } + writeUB(4, Nbits); + if (value.hasMultTerms) { + writeSB(Nbits, value.redMultTerm); + writeSB(Nbits, value.greenMultTerm); + writeSB(Nbits, value.blueMultTerm); + writeSB(Nbits, value.alphaMultTerm); + } + if (value.hasAddTerms) { + writeSB(Nbits, value.redAddTerm); + writeSB(Nbits, value.greenAddTerm); + writeSB(Nbits, value.blueAddTerm); + writeSB(Nbits, value.alphaAddTerm); + } + alignByte(); + } - /** - * Writes list of BUTTONCONDACTION values to the stream - * - * @param list List of BUTTONCONDACTION values - * @throws IOException - */ - public void writeBUTTONCONDACTIONList(List list) throws IOException { - for (int i = 0; i < list.size(); i++) { - writeBUTTONCONDACTION(list.get(i), i == list.size() - 1); - } - } + /** + * Writes CLIPEVENTFLAGS value to the stream + * + * @param value CLIPEVENTFLAGS value + * @throws IOException + */ + public void writeCLIPEVENTFLAGS(CLIPEVENTFLAGS value) throws IOException { + writeUB(1, value.clipEventKeyUp ? 1 : 0); + writeUB(1, value.clipEventKeyDown ? 1 : 0); + writeUB(1, value.clipEventMouseUp ? 1 : 0); + writeUB(1, value.clipEventMouseDown ? 1 : 0); + writeUB(1, value.clipEventMouseMove ? 1 : 0); + writeUB(1, value.clipEventUnload ? 1 : 0); + writeUB(1, value.clipEventEnterFrame ? 1 : 0); + writeUB(1, value.clipEventLoad ? 1 : 0); + writeUB(1, value.clipEventDragOver ? 1 : 0); + writeUB(1, value.clipEventRollOut ? 1 : 0); + writeUB(1, value.clipEventRollOver ? 1 : 0); + writeUB(1, value.clipEventReleaseOutside ? 1 : 0); + writeUB(1, value.clipEventRelease ? 1 : 0); + writeUB(1, value.clipEventPress ? 1 : 0); + writeUB(1, value.clipEventInitialize ? 1 : 0); + writeUB(1, value.clipEventData ? 1 : 0); + if (version >= 6) { + writeUB(5, 0); + writeUB(1, value.clipEventConstruct ? 1 : 0); + writeUB(1, value.clipEventKeyPress ? 1 : 0); + writeUB(1, value.clipEventDragOut ? 1 : 0); + writeUB(8, 0); + } + } - /** - * Writes BUTTONCONDACTION value to the stream - * - * @param value BUTTONCONDACTION value - * @param isLast True if it is last on the list - * @throws IOException - */ - public void writeBUTTONCONDACTION(BUTTONCONDACTION value, boolean isLast) throws IOException { - BUTTONCONDACTION ret = new BUTTONCONDACTION(); + /** + * Writes CLIPACTIONRECORD value to the stream + * + * @param value CLIPACTIONRECORD value + * @throws IOException + */ + public void writeCLIPACTIONRECORD(CLIPACTIONRECORD value) throws IOException { + writeCLIPEVENTFLAGS(value.eventFlags); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - sos.writeUB(1, value.condIdleToOverDown ? 1 : 0); - sos.writeUB(1, value.condOutDownToIdle ? 1 : 0); - sos.writeUB(1, value.condOutDownToOverDown ? 1 : 0); - sos.writeUB(1, value.condOverDownToOutDown ? 1 : 0); - sos.writeUB(1, value.condOverDownToOverUp ? 1 : 0); - sos.writeUB(1, value.condOverUpToOverDown ? 1 : 0); - sos.writeUB(1, value.condOverUpToIddle ? 1 : 0); - sos.writeUB(1, value.condIdleToOverUp ? 1 : 0); - sos.writeUB(7, value.condKeyPress); - sos.writeUB(1, value.condOverDownToIddle ? 1 : 0); - sos.write(value.actionBytes); - //sos.write(Action.actionsToBytes(value.actions, true, version)); - sos.close(); - byte data[] = baos.toByteArray(); - if (isLast) { - writeUI16(0); - } else { - writeUI16(data.length + 2); - } - write(data); - } + if (value.eventFlags.clipEventKeyPress) { + sos.writeUI8(value.keyCode); + } + sos.write(value.actionBytes); + //sos.write(Action.actionsToBytes(value.actions, true, version)); + sos.close(); + byte data[] = baos.toByteArray(); + writeUI32(data.length); //actionRecordSize + write(data); + } - /** - * Writes FILLSTYLE value to the stream - * - * @param value FILLSTYLE value - * @throws IOException - */ - public void writeFILLSTYLE(FILLSTYLE value, int shapeNum) throws IOException { - writeUI8(value.fillStyleType); - if (value.fillStyleType == FILLSTYLE.SOLID) { - if (shapeNum >= 3) { - writeRGBA(value.colorA); - } else if (shapeNum == 1 || shapeNum == 2) { + /** + * Writes CLIPACTIONS value to the stream + * + * @param value CLIPACTIONS value + * @throws IOException + */ + public void writeCLIPACTIONS(CLIPACTIONS value) throws IOException { + writeUI16(0);//reserved + writeCLIPEVENTFLAGS(value.allEventFlags); + for (CLIPACTIONRECORD car : value.clipActionRecords) { + writeCLIPACTIONRECORD(car); + } + if (version <= 5) { + writeUI16(0); + } else { + writeUI32(0); + } + } + + /** + * Writes COLORMATRIXFILTER value to the stream + * + * @param value COLORMATRIXFILTER value + * @throws IOException + */ + public void writeCOLORMATRIXFILTER(COLORMATRIXFILTER value) throws IOException { + for (int i = 0; i < 20; i++) { + writeFLOAT(value.matrix[i]); + } + } + + /** + * Writes RGBA value to the stream + * + * @param value RGBA value + * @throws IOException + */ + public void writeRGBA(RGBA value) throws IOException { + writeUI8(value.red); + writeUI8(value.green); + writeUI8(value.blue); + writeUI8(value.alpha); + } + + /** + * Writes RGB value to the stream + * + * @param value RGB value + * @throws IOException + */ + public void writeRGB(RGB value) throws IOException { + writeUI8(value.red); + writeUI8(value.green); + writeUI8(value.blue); + } + + /** + * Writes CONVOLUTIONFILTER value to the stream + * + * @param value CONVOLUTIONFILTER value + * @throws IOException + */ + public void writeCONVOLUTIONFILTER(CONVOLUTIONFILTER value) throws IOException { + writeUI8(value.matrixX); + writeUI8(value.matrixY); + writeFLOAT(value.divisor); + writeFLOAT(value.bias); + for (int x = 0; x < value.matrixX; x++) { + for (int y = 0; y < value.matrixY; y++) { + writeFLOAT(value.matrix[x][y]); + } + } + writeRGBA(value.defaultColor); + writeUB(6, 0); //reserved + writeUB(1, value.clamp ? 1 : 0); + writeUB(1, value.preserveAlpha ? 1 : 0); + } + + /** + * Writes BLURFILTER value to the stream + * + * @param value BLURFILTER value + * @throws IOException + */ + public void writeBLURFILTER(BLURFILTER value) throws IOException { + writeFIXED(value.blurX); + writeFIXED(value.blurY); + writeUB(5, value.passes); + writeUB(3, 0);//reserved + } + + /** + * Writes DROPSHADOWFILTER value to the stream + * + * @param value DROPSHADOWFILTER value + * @throws IOException + */ + public void writeDROPSHADOWFILTER(DROPSHADOWFILTER value) throws IOException { + writeRGBA(value.dropShadowColor); + writeFIXED(value.blurX); + writeFIXED(value.blurY); + writeFIXED(value.angle); + writeFIXED(value.distance); + writeFIXED8(value.strength); + writeUB(1, value.innerShadow ? 1 : 0); + writeUB(1, value.knockout ? 1 : 0); + writeUB(1, value.compositeSource ? 1 : 0); + writeUB(5, value.passes); + } + + /** + * Writes GLOWFILTER value to the stream + * + * @param value GLOWFILTER value + * @throws IOException + */ + public void writeGLOWFILTER(GLOWFILTER value) throws IOException { + writeRGBA(value.glowColor); + writeFIXED(value.blurX); + writeFIXED(value.blurY); + writeFIXED8(value.strength); + writeUB(1, value.innerGlow ? 1 : 0); + writeUB(1, value.knockout ? 1 : 0); + writeUB(1, value.compositeSource ? 1 : 0); + writeUB(5, value.passes); + } + + /** + * Writes BEVELFILTER value to the stream + * + * @param value BEVELFILTER value + * @throws IOException + */ + public void writeBEVELFILTER(BEVELFILTER value) throws IOException { + writeRGBA(value.shadowColor); + writeRGBA(value.highlightColor); + writeFIXED(value.blurX); + writeFIXED(value.blurY); + writeFIXED(value.angle); + writeFIXED(value.distance); + writeFIXED8(value.strength); + writeUB(1, value.innerShadow ? 1 : 0); + writeUB(1, value.knockout ? 1 : 0); + writeUB(1, value.compositeSource ? 1 : 0); + writeUB(1, value.onTop ? 1 : 0); + writeUB(4, value.passes); + } + + /** + * Writes GRADIENTGLOWFILTER value to the stream + * + * @param value GRADIENTGLOWFILTER value + * @throws IOException + */ + public void writeGRADIENTGLOWFILTER(GRADIENTGLOWFILTER value) throws IOException { + writeUI8(value.gradientColors.length); + for (int i = 0; i < value.gradientColors.length; i++) { + writeRGBA(value.gradientColors[i]); + } + for (int i = 0; i < value.gradientColors.length; i++) { + writeUI8(value.gradientRatio[i]); + } + writeFIXED(value.blurX); + writeFIXED(value.blurY); + writeFIXED(value.angle); + writeFIXED(value.distance); + writeFIXED8(value.strength); + writeUB(1, value.innerShadow ? 1 : 0); + writeUB(1, value.knockout ? 1 : 0); + writeUB(1, value.compositeSource ? 1 : 0); + writeUB(1, value.onTop ? 1 : 0); + writeUB(4, value.passes); + } + + /** + * Writes GRADIENTBEVELFILTER value to the stream + * + * @param value GRADIENTBEVELFILTER value + * @throws IOException + */ + public void writeGRADIENTBEVELFILTER(GRADIENTBEVELFILTER value) throws IOException { + writeUI8(value.gradientColors.length); + for (int i = 0; i < value.gradientColors.length; i++) { + writeRGBA(value.gradientColors[i]); + } + for (int i = 0; i < value.gradientColors.length; i++) { + writeUI8(value.gradientRatio[i]); + } + writeFIXED(value.blurX); + writeFIXED(value.blurY); + writeFIXED(value.angle); + writeFIXED(value.distance); + writeFIXED8(value.strength); + writeUB(1, value.innerShadow ? 1 : 0); + writeUB(1, value.knockout ? 1 : 0); + writeUB(1, value.compositeSource ? 1 : 0); + writeUB(1, value.onTop ? 1 : 0); + writeUB(4, value.passes); + } + + /** + * Writes list of FILTER values to the stream + * + * @param list List of FILTER values + * @throws IOException + */ + public void writeFILTERLIST(List list) throws IOException { + writeUI8(list.size()); + for (int i = 0; i < list.size(); i++) { + writeFILTER(list.get(i)); + } + } + + /** + * Writes FILTER value to the stream + * + * @param value FILTER value + * @throws IOException + */ + public void writeFILTER(FILTER value) throws IOException { + writeUI8(value.id); + switch (value.id) { + case 0: + writeDROPSHADOWFILTER((DROPSHADOWFILTER) value); + break; + case 1: + writeBLURFILTER((BLURFILTER) value); + break; + case 2: + writeGLOWFILTER((GLOWFILTER) value); + break; + case 3: + writeBEVELFILTER((BEVELFILTER) value); + break; + case 4: + writeGRADIENTGLOWFILTER((GRADIENTGLOWFILTER) value); + break; + case 5: + writeCONVOLUTIONFILTER((CONVOLUTIONFILTER) value); + break; + case 6: + writeCOLORMATRIXFILTER((COLORMATRIXFILTER) value); + break; + case 7: + writeGRADIENTBEVELFILTER((GRADIENTBEVELFILTER) value); + break; + } + } + + /** + * Writes list of BUTTONRECORD values to the stream + * + * @param list List of BUTTONRECORD values + * @param inDefineButton2 Whether write inside of DefineButton2Tag or not + * @throws IOException + */ + public void writeBUTTONRECORDList(List list, boolean inDefineButton2) throws IOException { + for (BUTTONRECORD brec : list) { + writeBUTTONRECORD(brec, inDefineButton2); + } + writeUI8(0); + } + + /** + * Writes BUTTONRECORD value to the stream + * + * @param value BUTTONRECORD value + * @param inDefineButton2 Whether write inside of DefineButton2Tag or not + * @throws IOException + */ + public void writeBUTTONRECORD(BUTTONRECORD value, boolean inDefineButton2) throws IOException { + writeUB(2, 0);//reserved + writeUB(1, value.buttonHasBlendMode ? 1 : 0); + writeUB(1, value.buttonHasFilterList ? 1 : 0); + writeUB(1, value.buttonStateHitTest ? 1 : 0); + writeUB(1, value.buttonStateDown ? 1 : 0); + writeUB(1, value.buttonStateOver ? 1 : 0); + writeUB(1, value.buttonStateUp ? 1 : 0); + writeUI16(value.characterId); + writeUI16(value.placeDepth); + writeMatrix(value.placeMatrix); + if (inDefineButton2) { + writeCXFORMWITHALPHA(value.colorTransform); + if (value.buttonHasFilterList) { + writeFILTERLIST(value.filterList); + } + if (value.buttonHasBlendMode) { + writeUI8(value.blendMode); + } + } + } + + /** + * Writes list of BUTTONCONDACTION values to the stream + * + * @param list List of BUTTONCONDACTION values + * @throws IOException + */ + public void writeBUTTONCONDACTIONList(List list) throws IOException { + for (int i = 0; i < list.size(); i++) { + writeBUTTONCONDACTION(list.get(i), i == list.size() - 1); + } + } + + /** + * Writes BUTTONCONDACTION value to the stream + * + * @param value BUTTONCONDACTION value + * @param isLast True if it is last on the list + * @throws IOException + */ + public void writeBUTTONCONDACTION(BUTTONCONDACTION value, boolean isLast) throws IOException { + BUTTONCONDACTION ret = new BUTTONCONDACTION(); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + sos.writeUB(1, value.condIdleToOverDown ? 1 : 0); + sos.writeUB(1, value.condOutDownToIdle ? 1 : 0); + sos.writeUB(1, value.condOutDownToOverDown ? 1 : 0); + sos.writeUB(1, value.condOverDownToOutDown ? 1 : 0); + sos.writeUB(1, value.condOverDownToOverUp ? 1 : 0); + sos.writeUB(1, value.condOverUpToOverDown ? 1 : 0); + sos.writeUB(1, value.condOverUpToIddle ? 1 : 0); + sos.writeUB(1, value.condIdleToOverUp ? 1 : 0); + sos.writeUB(7, value.condKeyPress); + sos.writeUB(1, value.condOverDownToIddle ? 1 : 0); + sos.write(value.actionBytes); + //sos.write(Action.actionsToBytes(value.actions, true, version)); + sos.close(); + byte data[] = baos.toByteArray(); + if (isLast) { + writeUI16(0); + } else { + writeUI16(data.length + 2); + } + write(data); + } + + /** + * Writes FILLSTYLE value to the stream + * + * @param value FILLSTYLE value + * @throws IOException + */ + public void writeFILLSTYLE(FILLSTYLE value, int shapeNum) throws IOException { + writeUI8(value.fillStyleType); + if (value.fillStyleType == FILLSTYLE.SOLID) { + if (shapeNum >= 3) { + writeRGBA(value.colorA); + } else if (shapeNum == 1 || shapeNum == 2) { + writeRGB(value.color); + } + } + if ((value.fillStyleType == FILLSTYLE.LINEAR_GRADIENT) + || (value.fillStyleType == FILLSTYLE.RADIAL_GRADIENT) + || (value.fillStyleType == FILLSTYLE.FOCAL_RADIAL_GRADIENT)) { + writeMatrix(value.gradientMatrix); + } + if ((value.fillStyleType == FILLSTYLE.LINEAR_GRADIENT) + || (value.fillStyleType == FILLSTYLE.RADIAL_GRADIENT)) { + writeGRADIENT(value.gradient, shapeNum); + } + if (value.fillStyleType == FILLSTYLE.FOCAL_RADIAL_GRADIENT) { + writeFOCALGRADIENT(value.focalGradient, shapeNum); + } + + if ((value.fillStyleType == FILLSTYLE.REPEATING_BITMAP) + || (value.fillStyleType == FILLSTYLE.CLIPPED_BITMAP) + || (value.fillStyleType == FILLSTYLE.NON_SMOOTHED_REPEATING_BITMAP) + || (value.fillStyleType == FILLSTYLE.NON_SMOOTHED_CLIPPED_BITMAP)) { + writeUI16(value.bitmapId); + writeMatrix(value.bitmapMatrix); + } + } + + /** + * Writes FILLSTYLEARRAY value to the stream + * + * @param value FILLSTYLEARRAY value + * @throws IOException + */ + public void writeFILLSTYLEARRAY(FILLSTYLEARRAY value, int shapeNum) throws IOException { + int fillStyleCount = value.fillStyles.length; + if (shapeNum == 2 || shapeNum == 3) { + if (fillStyleCount >= 0xff) { + writeUI8(0xff); + writeUI16(fillStyleCount); + } else { + writeUI8(fillStyleCount); + } + } else { + writeUI8(fillStyleCount); + } + for (int i = 0; i < value.fillStyles.length; i++) { + writeFILLSTYLE(value.fillStyles[i], shapeNum); + } + } + + /** + * Writes FOCALGRADIENT value to the stream + * + * @param value FILLSTYLEARRAY value + * @throws IOException + */ + public void writeFOCALGRADIENT(FOCALGRADIENT value, int shapeNum) throws IOException { + writeUB(2, value.spreadMode); + writeUB(2, value.interPolationMode); + writeUB(4, value.gradientRecords.length); + for (int i = 0; i < value.gradientRecords.length; i++) { + writeGRADRECORD(value.gradientRecords[i], shapeNum); + } + writeFIXED8(value.focalPoint); + } + + /** + * Writes GRADIENT value to the stream + * + * @param value GRADIENT value + * @throws IOException + */ + public void writeGRADIENT(GRADIENT value, int shapeNum) throws IOException { + writeUB(2, value.spreadMode); + writeUB(2, value.interPolationMode); + writeUB(4, value.gradientRecords.length); + for (int i = 0; i < value.gradientRecords.length; i++) { + writeGRADRECORD(value.gradientRecords[i], shapeNum); + } + } + + /** + * Writes GRADRECORD value to the stream + * + * @param value GRADRECORD value + * @throws IOException + */ + public void writeGRADRECORD(GRADRECORD value, int shapeNum) throws IOException { + writeUI8(value.ratio); + if (shapeNum == 1 || shapeNum == 2) { writeRGB(value.color); - } - } - if ((value.fillStyleType == FILLSTYLE.LINEAR_GRADIENT) - || (value.fillStyleType == FILLSTYLE.RADIAL_GRADIENT) - || (value.fillStyleType == FILLSTYLE.FOCAL_RADIAL_GRADIENT)) { - writeMatrix(value.gradientMatrix); - } - if ((value.fillStyleType == FILLSTYLE.LINEAR_GRADIENT) - || (value.fillStyleType == FILLSTYLE.RADIAL_GRADIENT)) { - writeGRADIENT(value.gradient, shapeNum); - } - if (value.fillStyleType == FILLSTYLE.FOCAL_RADIAL_GRADIENT) { - writeFOCALGRADIENT(value.focalGradient, shapeNum); - } + } else if (shapeNum == 3) { + writeRGBA(value.colorA); + } + } - if ((value.fillStyleType == FILLSTYLE.REPEATING_BITMAP) - || (value.fillStyleType == FILLSTYLE.CLIPPED_BITMAP) - || (value.fillStyleType == FILLSTYLE.NON_SMOOTHED_REPEATING_BITMAP) - || (value.fillStyleType == FILLSTYLE.NON_SMOOTHED_CLIPPED_BITMAP)) { - writeUI16(value.bitmapId); - writeMatrix(value.bitmapMatrix); - } - } + /** + * Writes LINESTYLE value to the stream + * + * @param value LINESTYLE value + * @throws IOException + */ + public void writeLINESTYLE(LINESTYLE value, int shapeNum) throws IOException { + writeUI16(value.width); + if (shapeNum == 1 || shapeNum == 2) { + writeRGB(value.color); + } else if (shapeNum == 3) { + writeRGBA(value.colorA); + } + } - /** - * Writes FILLSTYLEARRAY value to the stream - * - * @param value FILLSTYLEARRAY value - * @throws IOException - */ - public void writeFILLSTYLEARRAY(FILLSTYLEARRAY value, int shapeNum) throws IOException { - int fillStyleCount = value.fillStyles.length; - if (shapeNum == 2 || shapeNum == 3) { - if (fillStyleCount >= 0xff) { + /** + * Writes LINESTYLE2 value to the stream + * + * @param value LINESTYLE2 value + * @throws IOException + */ + public void writeLINESTYLE2(LINESTYLE2 value, int shapeNum) throws IOException { + writeUI16(value.width); + writeUB(2, value.startCapStyle); + writeUB(2, value.joinStyle); + writeUB(1, value.hasFillFlag ? 1 : 0); + writeUB(1, value.noHScaleFlag ? 1 : 0); + writeUB(1, value.noVScaleFlag ? 1 : 0); + writeUB(1, value.pixelHintingFlag ? 1 : 0); + writeUB(5, 0);//reserved + writeUB(1, value.noClose ? 1 : 0); + writeUB(2, value.endCapStyle); + if (value.joinStyle == LINESTYLE2.MITER_JOIN) { + writeUI16(value.miterLimitFactor); + } + if (!value.hasFillFlag) { + writeRGBA(value.color); + } else { + writeFILLSTYLE(value.fillType, shapeNum); + } + } + + /** + * Writes LINESTYLEARRAY value to the stream + * + * @param value FILLSTYLEARRAY value + * @throws IOException + */ + public void writeLINESTYLEARRAY(LINESTYLEARRAY value, int shapeNum) throws IOException { + int lineStyleCount; + if (shapeNum == 1 || shapeNum == 2 || shapeNum == 3) { + lineStyleCount = value.lineStyles.length; + if (lineStyleCount >= 0xff) { + writeUI8(0xff); + writeUI16(lineStyleCount); + } else { + writeUI8(lineStyleCount); + } + for (int i = 0; i < lineStyleCount; i++) { + writeLINESTYLE(value.lineStyles[i], shapeNum); + } + } else if (shapeNum == 4) { + lineStyleCount = value.lineStyles2.length; + if (lineStyleCount >= 0xff) { + writeUI8(0xff); + writeUI16(lineStyleCount); + } else { + writeUI8(lineStyleCount); + } + for (int i = 0; i < lineStyleCount; i++) { + writeLINESTYLE2(value.lineStyles2[i], shapeNum); + } + } + } + + /** + * Writes SHAPE value to the stream + * + * @param value SHAPE value + * @throws IOException + */ + public void writeSHAPE(SHAPE value, int shapeNum) throws IOException { + writeUB(4, value.numFillBits); + writeUB(4, value.numLineBits); + writeSHAPERECORDS(value.shapeRecords, value.numFillBits, value.numLineBits, shapeNum); + } + + /** + * Writes SHAPEWITHSTYLE value to the stream + * + * @param value SHAPEWITHSTYLE value + * @throws IOException + */ + public void writeSHAPEWITHSTYLE(SHAPEWITHSTYLE value, int shapeNum) throws IOException { + writeFILLSTYLEARRAY(value.fillStyles, shapeNum); + writeLINESTYLEARRAY(value.lineStyles, shapeNum); + writeUB(4, value.numFillBits); + writeUB(4, value.numLineBits); + writeSHAPERECORDS(value.shapeRecords, value.numFillBits, value.numLineBits, shapeNum); + } + + /** + * Writes SHAPERECORDs value to the stream + * + * @param value SHAPERECORDS value + * @throws IOException + */ + public void writeSHAPERECORDS(List value, int fillBits, int lineBits, int shapeNum) throws IOException { + for (SHAPERECORD sh : value) { + if (sh instanceof CurvedEdgeRecord) { + CurvedEdgeRecord cer = (CurvedEdgeRecord) sh; + writeUB(1, 1); //typeFlag + writeUB(1, 0);//curvedEdge + writeUB(4, cer.numBits); + writeUB(cer.numBits + 2, cer.controlDeltaX); + writeUB(cer.numBits + 2, cer.controlDeltaY); + writeUB(cer.numBits + 2, cer.anchorDeltaX); + writeUB(cer.numBits + 2, cer.anchorDeltaY); + } else if (sh instanceof StraightEdgeRecord) { + StraightEdgeRecord ser = (StraightEdgeRecord) sh; + writeUB(1, 1); //typeFlag + writeUB(1, 1);//straightEdge + writeUB(4, ser.numBits); + writeUB(1, ser.generalLineFlag ? 1 : 0); + if (!ser.generalLineFlag) { + writeUB(1, ser.vertLineFlag ? 1 : 0); + } + if (ser.generalLineFlag || (!ser.vertLineFlag)) { + writeSB(ser.numBits + 2, ser.deltaX); + } + if (ser.generalLineFlag || ser.vertLineFlag) { + writeSB(ser.numBits + 2, ser.deltaY); + } + } else if (sh instanceof StyleChangeRecord) { + StyleChangeRecord scr = (StyleChangeRecord) sh; + writeUB(1, 0); //typeFlag + writeUB(1, scr.stateNewStyles ? 1 : 0); + writeUB(1, scr.stateLineStyle ? 1 : 0); + writeUB(1, scr.stateFillStyle1 ? 1 : 0); + writeUB(1, scr.stateFillStyle0 ? 1 : 0); + writeUB(1, scr.stateMoveTo ? 1 : 0); + if (scr.stateMoveTo) { + writeUB(5, scr.moveBits); + writeUB(scr.moveBits, scr.moveDeltaX); + writeUB(scr.moveBits, scr.moveDeltaY); + } + if (scr.stateFillStyle0) { + writeUB(fillBits, scr.fillStyle0); + } + if (scr.stateFillStyle1) { + writeUB(fillBits, scr.fillStyle1); + } + if (scr.stateLineStyle) { + writeUB(lineBits, scr.lineStyle); + } + if (scr.stateNewStyles) { + writeFILLSTYLEARRAY(scr.fillStyles, shapeNum); + writeLINESTYLEARRAY(scr.lineStyles, shapeNum); + writeUB(4, scr.numFillBits); + writeUB(4, scr.numLineBits); + } + + } else if (sh instanceof EndShapeRecord) { + writeUB(1, 0); //typeFlag + writeUB(5, 0); //end of shape flag + } + } + alignByte(); + } + + /** + * Writes SOUNDINFO value to the stream + * + * @param value SOUNDINFO value + * @throws IOException + */ + public void writeSOUNDINFO(SOUNDINFO value) throws IOException { + writeUB(2, 0);//reserved + writeUB(1, value.syncStop ? 1 : 0); + writeUB(1, value.syncNoMultiple ? 1 : 0); + writeUB(1, value.hasEnvelope ? 1 : 0); + writeUB(1, value.hasLoops ? 1 : 0); + writeUB(1, value.hasOutPoint ? 1 : 0); + writeUB(1, value.hasInPoint ? 1 : 0); + if (value.hasInPoint) { + writeUI32(value.inPoint); + } + if (value.hasOutPoint) { + writeUI32(value.outPoint); + } + if (value.hasLoops) { + writeUI16(value.loopCount); + } + if (value.hasEnvelope) { + writeUI8(value.envelopeRecords.length); + for (SOUNDENVELOPE env : value.envelopeRecords) { + writeSOUNDENVELOPE(env); + } + } + } + + /** + * Writes SOUNDENVELOPE value to the stream + * + * @param value SOUNDENVELOPE value + * @throws IOException + */ + public void writeSOUNDENVELOPE(SOUNDENVELOPE value) throws IOException { + writeUI32(value.pos44); + writeUI16(value.leftLevel); + writeUI16(value.rightLevel); + } + + /** + * Writes TEXTRECORD value to the stream + * + * @param value TEXTRECORD value + * @throws IOException + */ + public void writeTEXTRECORD(TEXTRECORD value, boolean inDefineText2, int glyphBits, int advanceBits) throws IOException { + writeUB(1, 1); + writeUB(3, 0); + writeUB(1, value.styleFlagsHasFont ? 1 : 0); + writeUB(1, value.styleFlagsHasColor ? 1 : 0); + writeUB(1, value.styleFlagsHasYOffset ? 1 : 0); + writeUB(1, value.styleFlagsHasXOffset ? 1 : 0); + if (value.styleFlagsHasFont) { + writeUI16(value.fontId); + } + if (value.styleFlagsHasColor) { + if (inDefineText2) { + writeRGBA(value.textColorA); + } else { + writeRGB(value.textColor); + } + } + if (value.styleFlagsHasXOffset) { + writeSI16(value.xOffset); + } + if (value.styleFlagsHasYOffset) { + writeSI16(value.yOffset); + } + if (value.styleFlagsHasFont) { + writeUI16(value.textHeight); + } + writeUI8(value.glyphEntries.length); + for (GLYPHENTRY ge : value.glyphEntries) { + writeGLYPHENTRY(ge, glyphBits, advanceBits); + } + alignByte(); + } + + /** + * Writes GLYPHENTRY value to the stream + * + * @param value GLYPHENTRY value + * @throws IOException + */ + public void writeGLYPHENTRY(GLYPHENTRY value, int glyphBits, int advanceBits) throws IOException { + writeUB(glyphBits, value.glyphIndex); + writeSB(advanceBits, value.glyphAdvance); + } + + /** + * Writes MORPHFILLSTYLE value to the stream + * + * @param value MORPHFILLSTYLE value + * @throws IOException + */ + public void writeMORPHFILLSTYLE(MORPHFILLSTYLE value, int shapeNum) throws IOException { + writeUI8(value.fillStyleType); + if (value.fillStyleType == MORPHFILLSTYLE.SOLID) { + writeRGBA(value.startColor); + writeRGBA(value.endColor); + } + if ((value.fillStyleType == MORPHFILLSTYLE.LINEAR_GRADIENT) + || (value.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)) { + writeMatrix(value.startGradientMatrix); + writeMatrix(value.endGradientMatrix); + } + if ((value.fillStyleType == MORPHFILLSTYLE.LINEAR_GRADIENT) + || (value.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)) { + writeMORPHGRADIENT(value.gradient, shapeNum); + } + + if ((value.fillStyleType == MORPHFILLSTYLE.REPEATING_BITMAP) + || (value.fillStyleType == MORPHFILLSTYLE.CLIPPED_BITMAP) + || (value.fillStyleType == MORPHFILLSTYLE.NON_SMOOTHED_REPEATING_BITMAP) + || (value.fillStyleType == MORPHFILLSTYLE.NON_SMOOTHED_CLIPPED_BITMAP)) { + writeUI16(value.bitmapId); + writeMatrix(value.startBitmapMatrix); + writeMatrix(value.endBitmapMatrix); + } + } + + /** + * WritesMORPH FILLSTYLEARRAY value to the stream + * + * @param value MORPHFILLSTYLEARRAY value + * @throws IOException + */ + public void writeMORPHFILLSTYLEARRAY(MORPHFILLSTYLEARRAY value, int morphShapeNum) throws IOException { + int fillStyleCount = value.fillStyles.length; + if (fillStyleCount >= 0xff) { writeUI8(0xff); writeUI16(fillStyleCount); - } else { + } else { writeUI8(fillStyleCount); - } - } else { - writeUI8(fillStyleCount); - } - for (int i = 0; i < value.fillStyles.length; i++) { - writeFILLSTYLE(value.fillStyles[i], shapeNum); - } - } + } + for (int i = 0; i < value.fillStyles.length; i++) { + writeMORPHFILLSTYLE(value.fillStyles[i], morphShapeNum); + } + } - /** - * Writes FOCALGRADIENT value to the stream - * - * @param value FILLSTYLEARRAY value - * @throws IOException - */ - public void writeFOCALGRADIENT(FOCALGRADIENT value, int shapeNum) throws IOException { - writeUB(2, value.spreadMode); - writeUB(2, value.interPolationMode); - writeUB(4, value.gradientRecords.length); - for (int i = 0; i < value.gradientRecords.length; i++) { - writeGRADRECORD(value.gradientRecords[i], shapeNum); - } - writeFIXED8(value.focalPoint); - } + /** + * Writes MORPHGRADIENT value to the stream + * + * @param value MORPHGRADIENT value + * @throws IOException + */ + public void writeMORPHGRADIENT(MORPHGRADIENT value, int shapeNum) throws IOException { + writeUB(4, value.gradientRecords.length); + for (int i = 0; i < value.gradientRecords.length; i++) { + writeMORPHGRADRECORD(value.gradientRecords[i]); + } + } - /** - * Writes GRADIENT value to the stream - * - * @param value GRADIENT value - * @throws IOException - */ - public void writeGRADIENT(GRADIENT value, int shapeNum) throws IOException { - writeUB(2, value.spreadMode); - writeUB(2, value.interPolationMode); - writeUB(4, value.gradientRecords.length); - for (int i = 0; i < value.gradientRecords.length; i++) { - writeGRADRECORD(value.gradientRecords[i], shapeNum); - } - } + /** + * Writes MORPHGRADRECORD value to the stream + * + * @param value MORPHGRADRECORD value + * @throws IOException + */ + public void writeMORPHGRADRECORD(MORPHGRADRECORD value) throws IOException { + writeUI8(value.startRatio); + writeRGBA(value.startColor); + writeUI8(value.endRatio); + writeRGBA(value.endColor); + } - /** - * Writes GRADRECORD value to the stream - * - * @param value GRADRECORD value - * @throws IOException - */ - public void writeGRADRECORD(GRADRECORD value, int shapeNum) throws IOException { - writeUI8(value.ratio); - if (shapeNum == 1 || shapeNum == 2) { - writeRGB(value.color); - } else if (shapeNum == 3) { - writeRGBA(value.colorA); - } - } + /** + * Writes MORPHLINESTYLE value to the stream + * + * @param value LINESTYLE value + * @throws IOException + */ + public void writeMORPHLINESTYLE(MORPHLINESTYLE value, int shapeNum) throws IOException { + writeUI16(value.startWidth); + writeUI16(value.endWidth); + writeRGBA(value.startColor); + writeRGBA(value.endColor); - /** - * Writes LINESTYLE value to the stream - * - * @param value LINESTYLE value - * @throws IOException - */ - public void writeLINESTYLE(LINESTYLE value, int shapeNum) throws IOException { - writeUI16(value.width); - if (shapeNum == 1 || shapeNum == 2) { - writeRGB(value.color); - } else if (shapeNum == 3) { - writeRGBA(value.colorA); - } - } + } - /** - * Writes LINESTYLE2 value to the stream - * - * @param value LINESTYLE2 value - * @throws IOException - */ - public void writeLINESTYLE2(LINESTYLE2 value, int shapeNum) throws IOException { - writeUI16(value.width); - writeUB(2, value.startCapStyle); - writeUB(2, value.joinStyle); - writeUB(1, value.hasFillFlag ? 1 : 0); - writeUB(1, value.noHScaleFlag ? 1 : 0); - writeUB(1, value.noVScaleFlag ? 1 : 0); - writeUB(1, value.pixelHintingFlag ? 1 : 0); - writeUB(5, 0);//reserved - writeUB(1, value.noClose ? 1 : 0); - writeUB(2, value.endCapStyle); - if (value.joinStyle == LINESTYLE2.MITER_JOIN) { - writeUI16(value.miterLimitFactor); - } - if (!value.hasFillFlag) { - writeRGBA(value.color); - } else { - writeFILLSTYLE(value.fillType, shapeNum); - } - } + /** + * Writes MORPHLINESTYLE2 value to the stream + * + * @param value MORPHLINESTYLE2 value + * @throws IOException + */ + public void writeMORPHLINESTYLE2(MORPHLINESTYLE2 value, int shapeNum) throws IOException { + writeUI16(value.startWidth); + writeUI16(value.endWidth); + writeUB(2, value.startCapStyle); + writeUB(2, value.joinStyle); + writeUB(1, value.hasFillFlag ? 1 : 0); + writeUB(1, value.noHScaleFlag ? 1 : 0); + writeUB(1, value.noVScaleFlag ? 1 : 0); + writeUB(1, value.pixelHintingFlag ? 1 : 0); + writeUB(5, 0);//reserved + writeUB(1, value.noClose ? 1 : 0); + writeUB(2, value.endCapStyle); + if (value.joinStyle == LINESTYLE2.MITER_JOIN) { + writeUI16(value.miterLimitFactor); + } + if (!value.hasFillFlag) { + writeRGBA(value.startColor); + writeRGBA(value.endColor); + } else { + writeMORPHFILLSTYLE(value.fillType, shapeNum); + } + } - /** - * Writes LINESTYLEARRAY value to the stream - * - * @param value FILLSTYLEARRAY value - * @throws IOException - */ - public void writeLINESTYLEARRAY(LINESTYLEARRAY value, int shapeNum) throws IOException { - int lineStyleCount; - if (shapeNum == 1 || shapeNum == 2 || shapeNum == 3) { - lineStyleCount = value.lineStyles.length; - if (lineStyleCount >= 0xff) { - writeUI8(0xff); - writeUI16(lineStyleCount); - } else { - writeUI8(lineStyleCount); - } - for (int i = 0; i < lineStyleCount; i++) { - writeLINESTYLE(value.lineStyles[i], shapeNum); - } - } else if (shapeNum == 4) { - lineStyleCount = value.lineStyles2.length; - if (lineStyleCount >= 0xff) { - writeUI8(0xff); - writeUI16(lineStyleCount); - } else { - writeUI8(lineStyleCount); - } - for (int i = 0; i < lineStyleCount; i++) { - writeLINESTYLE2(value.lineStyles2[i], shapeNum); - } - } - } - - /** - * Writes SHAPE value to the stream - * - * @param value SHAPE value - * @throws IOException - */ - public void writeSHAPE(SHAPE value, int shapeNum) throws IOException { - writeUB(4, value.numFillBits); - writeUB(4, value.numLineBits); - writeSHAPERECORDS(value.shapeRecords, value.numFillBits, value.numLineBits, shapeNum); - } - - /** - * Writes SHAPEWITHSTYLE value to the stream - * - * @param value SHAPEWITHSTYLE value - * @throws IOException - */ - public void writeSHAPEWITHSTYLE(SHAPEWITHSTYLE value, int shapeNum) throws IOException { - writeFILLSTYLEARRAY(value.fillStyles, shapeNum); - writeLINESTYLEARRAY(value.lineStyles, shapeNum); - writeUB(4, value.numFillBits); - writeUB(4, value.numLineBits); - writeSHAPERECORDS(value.shapeRecords, value.numFillBits, value.numLineBits, shapeNum); - } - - /** - * Writes SHAPERECORDs value to the stream - * - * @param value SHAPERECORDS value - * @throws IOException - */ - public void writeSHAPERECORDS(List value, int fillBits, int lineBits, int shapeNum) throws IOException { - for (SHAPERECORD sh : value) { - if (sh instanceof CurvedEdgeRecord) { - CurvedEdgeRecord cer = (CurvedEdgeRecord) sh; - writeUB(1, 1); //typeFlag - writeUB(1, 0);//curvedEdge - writeUB(4, cer.numBits); - writeUB(cer.numBits + 2, cer.controlDeltaX); - writeUB(cer.numBits + 2, cer.controlDeltaY); - writeUB(cer.numBits + 2, cer.anchorDeltaX); - writeUB(cer.numBits + 2, cer.anchorDeltaY); - } else if (sh instanceof StraightEdgeRecord) { - StraightEdgeRecord ser = (StraightEdgeRecord) sh; - writeUB(1, 1); //typeFlag - writeUB(1, 1);//straightEdge - writeUB(4, ser.numBits); - writeUB(1, ser.generalLineFlag ? 1 : 0); - if (!ser.generalLineFlag) { - writeUB(1, ser.vertLineFlag ? 1 : 0); + /** + * Writes MORPHLINESTYLEARRAY value to the stream + * + * @param value MORPHFILLSTYLEARRAY value + * @throws IOException + */ + public void writeMORPHLINESTYLEARRAY(MORPHLINESTYLEARRAY value, int morphShapeNum) throws IOException { + int lineStyleCount; + if (morphShapeNum == 1) { + lineStyleCount = value.lineStyles.length; + if (lineStyleCount >= 0xff) { + writeUI8(0xff); + writeUI16(lineStyleCount); + } else { + writeUI8(lineStyleCount); } - if (ser.generalLineFlag || (!ser.vertLineFlag)) { - writeSB(ser.numBits + 2, ser.deltaX); + for (int i = 0; i < lineStyleCount; i++) { + writeMORPHLINESTYLE(value.lineStyles[i], morphShapeNum); } - if (ser.generalLineFlag || ser.vertLineFlag) { - writeSB(ser.numBits + 2, ser.deltaY); + } else if (morphShapeNum == 2) { + lineStyleCount = value.lineStyles2.length; + if (lineStyleCount >= 0xff) { + writeUI8(0xff); + writeUI16(lineStyleCount); + } else { + writeUI8(lineStyleCount); } - } else if (sh instanceof StyleChangeRecord) { - StyleChangeRecord scr = (StyleChangeRecord) sh; - writeUB(1, 0); //typeFlag - writeUB(1, scr.stateNewStyles ? 1 : 0); - writeUB(1, scr.stateLineStyle ? 1 : 0); - writeUB(1, scr.stateFillStyle1 ? 1 : 0); - writeUB(1, scr.stateFillStyle0 ? 1 : 0); - writeUB(1, scr.stateMoveTo ? 1 : 0); - if (scr.stateMoveTo) { - writeUB(5, scr.moveBits); - writeUB(scr.moveBits, scr.moveDeltaX); - writeUB(scr.moveBits, scr.moveDeltaY); - } - if (scr.stateFillStyle0) { - writeUB(fillBits, scr.fillStyle0); - } - if (scr.stateFillStyle1) { - writeUB(fillBits, scr.fillStyle1); - } - if (scr.stateLineStyle) { - writeUB(lineBits, scr.lineStyle); - } - if (scr.stateNewStyles) { - writeFILLSTYLEARRAY(scr.fillStyles, shapeNum); - writeLINESTYLEARRAY(scr.lineStyles, shapeNum); - writeUB(4, scr.numFillBits); - writeUB(4, scr.numLineBits); + for (int i = 0; i < lineStyleCount; i++) { + writeMORPHLINESTYLE2(value.lineStyles2[i], morphShapeNum); } + } + } - } else if (sh instanceof EndShapeRecord) { - writeUB(1, 0); //typeFlag - writeUB(5, 0); //end of shape flag - } - } - alignByte(); - } + /** + * Writes KERNINGRECORD value to the stream + * + * @param value KERNINGRECORD value + * @throws IOException + */ + public void writeKERNINGRECORD(KERNINGRECORD value, boolean fontFlagsWideCodes) throws IOException { + if (fontFlagsWideCodes) { + writeUI16(value.fontKerningCode1); + writeUI16(value.fontKerningCode2); + } else { + writeUI8(value.fontKerningCode1); + writeUI8(value.fontKerningCode2); + } + writeSI16(value.fontKerningAdjustment); + } - /** - * Writes SOUNDINFO value to the stream - * - * @param value SOUNDINFO value - * @throws IOException - */ - public void writeSOUNDINFO(SOUNDINFO value) throws IOException { - writeUB(2, 0);//reserved - writeUB(1, value.syncStop ? 1 : 0); - writeUB(1, value.syncNoMultiple ? 1 : 0); - writeUB(1, value.hasEnvelope ? 1 : 0); - writeUB(1, value.hasLoops ? 1 : 0); - writeUB(1, value.hasOutPoint ? 1 : 0); - writeUB(1, value.hasInPoint ? 1 : 0); - if (value.hasInPoint) { - writeUI32(value.inPoint); - } - if (value.hasOutPoint) { - writeUI32(value.outPoint); - } - if (value.hasLoops) { - writeUI16(value.loopCount); - } - if (value.hasEnvelope) { - writeUI8(value.envelopeRecords.length); - for (SOUNDENVELOPE env : value.envelopeRecords) { - writeSOUNDENVELOPE(env); - } - } - } + /** + * Writes LANGCODE value to the stream + * + * @param value LANGCODE value + * @throws IOException + */ + public void writeLANGCODE(LANGCODE value) throws IOException { + writeUI8(value.languageCode); + } - /** - * Writes SOUNDENVELOPE value to the stream - * - * @param value SOUNDENVELOPE value - * @throws IOException - */ - public void writeSOUNDENVELOPE(SOUNDENVELOPE value) throws IOException { - writeUI32(value.pos44); - writeUI16(value.leftLevel); - writeUI16(value.rightLevel); - } + /** + * Writes ZONERECORD value to the stream + * + * @param value ZONERECORD value + * @throws IOException + */ + public void writeZONERECORD(ZONERECORD value) throws IOException { + writeUI8(value.zonedata.length); + for (int i = 0; i < value.zonedata.length; i++) { + writeZONEDATA(value.zonedata[i]); + } + writeUB(6, 0); + writeUB(1, value.zoneMaskX ? 1 : 0); + writeUB(1, value.zoneMaskY ? 1 : 0); + } - /** - * Writes TEXTRECORD value to the stream - * - * @param value TEXTRECORD value - * @throws IOException - */ - public void writeTEXTRECORD(TEXTRECORD value, boolean inDefineText2, int glyphBits, int advanceBits) throws IOException { - writeUB(1, 1); - writeUB(3, 0); - writeUB(1, value.styleFlagsHasFont ? 1 : 0); - writeUB(1, value.styleFlagsHasColor ? 1 : 0); - writeUB(1, value.styleFlagsHasYOffset ? 1 : 0); - writeUB(1, value.styleFlagsHasXOffset ? 1 : 0); - if (value.styleFlagsHasFont) { - writeUI16(value.fontId); - } - if (value.styleFlagsHasColor) { - if (inDefineText2) { - writeRGBA(value.textColorA); - } else { - writeRGB(value.textColor); - } - } - if (value.styleFlagsHasXOffset) { - writeSI16(value.xOffset); - } - if (value.styleFlagsHasYOffset) { - writeSI16(value.yOffset); - } - if (value.styleFlagsHasFont) { - writeUI16(value.textHeight); - } - writeUI8(value.glyphEntries.length); - for (GLYPHENTRY ge : value.glyphEntries) { - writeGLYPHENTRY(ge, glyphBits, advanceBits); - } - alignByte(); - } - - /** - * Writes GLYPHENTRY value to the stream - * - * @param value GLYPHENTRY value - * @throws IOException - */ - public void writeGLYPHENTRY(GLYPHENTRY value, int glyphBits, int advanceBits) throws IOException { - writeUB(glyphBits, value.glyphIndex); - writeSB(advanceBits, value.glyphAdvance); - } - - /** - * Writes MORPHFILLSTYLE value to the stream - * - * @param value MORPHFILLSTYLE value - * @throws IOException - */ - public void writeMORPHFILLSTYLE(MORPHFILLSTYLE value, int shapeNum) throws IOException { - writeUI8(value.fillStyleType); - if (value.fillStyleType == MORPHFILLSTYLE.SOLID) { - writeRGBA(value.startColor); - writeRGBA(value.endColor); - } - if ((value.fillStyleType == MORPHFILLSTYLE.LINEAR_GRADIENT) - || (value.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)) { - writeMatrix(value.startGradientMatrix); - writeMatrix(value.endGradientMatrix); - } - if ((value.fillStyleType == MORPHFILLSTYLE.LINEAR_GRADIENT) - || (value.fillStyleType == MORPHFILLSTYLE.RADIAL_GRADIENT)) { - writeMORPHGRADIENT(value.gradient, shapeNum); - } - - if ((value.fillStyleType == MORPHFILLSTYLE.REPEATING_BITMAP) - || (value.fillStyleType == MORPHFILLSTYLE.CLIPPED_BITMAP) - || (value.fillStyleType == MORPHFILLSTYLE.NON_SMOOTHED_REPEATING_BITMAP) - || (value.fillStyleType == MORPHFILLSTYLE.NON_SMOOTHED_CLIPPED_BITMAP)) { - writeUI16(value.bitmapId); - writeMatrix(value.startBitmapMatrix); - writeMatrix(value.endBitmapMatrix); - } - } - - /** - * WritesMORPH FILLSTYLEARRAY value to the stream - * - * @param value MORPHFILLSTYLEARRAY value - * @throws IOException - */ - public void writeMORPHFILLSTYLEARRAY(MORPHFILLSTYLEARRAY value, int morphShapeNum) throws IOException { - int fillStyleCount = value.fillStyles.length; - if (fillStyleCount >= 0xff) { - writeUI8(0xff); - writeUI16(fillStyleCount); - } else { - writeUI8(fillStyleCount); - } - for (int i = 0; i < value.fillStyles.length; i++) { - writeMORPHFILLSTYLE(value.fillStyles[i], morphShapeNum); - } - } - - /** - * Writes MORPHGRADIENT value to the stream - * - * @param value MORPHGRADIENT value - * @throws IOException - */ - public void writeMORPHGRADIENT(MORPHGRADIENT value, int shapeNum) throws IOException { - writeUB(4, value.gradientRecords.length); - for (int i = 0; i < value.gradientRecords.length; i++) { - writeMORPHGRADRECORD(value.gradientRecords[i]); - } - } - - /** - * Writes MORPHGRADRECORD value to the stream - * - * @param value MORPHGRADRECORD value - * @throws IOException - */ - public void writeMORPHGRADRECORD(MORPHGRADRECORD value) throws IOException { - writeUI8(value.startRatio); - writeRGBA(value.startColor); - writeUI8(value.endRatio); - writeRGBA(value.endColor); - } - - /** - * Writes MORPHLINESTYLE value to the stream - * - * @param value LINESTYLE value - * @throws IOException - */ - public void writeMORPHLINESTYLE(MORPHLINESTYLE value, int shapeNum) throws IOException { - writeUI16(value.startWidth); - writeUI16(value.endWidth); - writeRGBA(value.startColor); - writeRGBA(value.endColor); - - } - - /** - * Writes MORPHLINESTYLE2 value to the stream - * - * @param value MORPHLINESTYLE2 value - * @throws IOException - */ - public void writeMORPHLINESTYLE2(MORPHLINESTYLE2 value, int shapeNum) throws IOException { - writeUI16(value.startWidth); - writeUI16(value.endWidth); - writeUB(2, value.startCapStyle); - writeUB(2, value.joinStyle); - writeUB(1, value.hasFillFlag ? 1 : 0); - writeUB(1, value.noHScaleFlag ? 1 : 0); - writeUB(1, value.noVScaleFlag ? 1 : 0); - writeUB(1, value.pixelHintingFlag ? 1 : 0); - writeUB(5, 0);//reserved - writeUB(1, value.noClose ? 1 : 0); - writeUB(2, value.endCapStyle); - if (value.joinStyle == LINESTYLE2.MITER_JOIN) { - writeUI16(value.miterLimitFactor); - } - if (!value.hasFillFlag) { - writeRGBA(value.startColor); - writeRGBA(value.endColor); - } else { - writeMORPHFILLSTYLE(value.fillType, shapeNum); - } - } - - /** - * Writes MORPHLINESTYLEARRAY value to the stream - * - * @param value MORPHFILLSTYLEARRAY value - * @throws IOException - */ - public void writeMORPHLINESTYLEARRAY(MORPHLINESTYLEARRAY value, int morphShapeNum) throws IOException { - int lineStyleCount; - if (morphShapeNum == 1) { - lineStyleCount = value.lineStyles.length; - if (lineStyleCount >= 0xff) { - writeUI8(0xff); - writeUI16(lineStyleCount); - } else { - writeUI8(lineStyleCount); - } - for (int i = 0; i < lineStyleCount; i++) { - writeMORPHLINESTYLE(value.lineStyles[i], morphShapeNum); - } - } else if (morphShapeNum == 2) { - lineStyleCount = value.lineStyles2.length; - if (lineStyleCount >= 0xff) { - writeUI8(0xff); - writeUI16(lineStyleCount); - } else { - writeUI8(lineStyleCount); - } - for (int i = 0; i < lineStyleCount; i++) { - writeMORPHLINESTYLE2(value.lineStyles2[i], morphShapeNum); - } - } - } - - /** - * Writes KERNINGRECORD value to the stream - * - * @param value KERNINGRECORD value - * @throws IOException - */ - public void writeKERNINGRECORD(KERNINGRECORD value, boolean fontFlagsWideCodes) throws IOException { - if (fontFlagsWideCodes) { - writeUI16(value.fontKerningCode1); - writeUI16(value.fontKerningCode2); - } else { - writeUI8(value.fontKerningCode1); - writeUI8(value.fontKerningCode2); - } - writeSI16(value.fontKerningAdjustment); - } - - /** - * Writes LANGCODE value to the stream - * - * @param value LANGCODE value - * @throws IOException - */ - public void writeLANGCODE(LANGCODE value) throws IOException { - writeUI8(value.languageCode); - } - - /** - * Writes ZONERECORD value to the stream - * - * @param value ZONERECORD value - * @throws IOException - */ - public void writeZONERECORD(ZONERECORD value) throws IOException { - writeUI8(value.zonedata.length); - for (int i = 0; i < value.zonedata.length; i++) { - writeZONEDATA(value.zonedata[i]); - } - writeUB(6, 0); - writeUB(1, value.zoneMaskX ? 1 : 0); - writeUB(1, value.zoneMaskY ? 1 : 0); - } - - /** - * Writes ZONEDATA value to the stream - * - * @param value ZONEDATA value - * @throws IOException - */ - public void writeZONEDATA(ZONEDATA value) throws IOException { - writeUI16(value.alignmentCoordinate); - writeUI16(value.range); - } + /** + * Writes ZONEDATA value to the stream + * + * @param value ZONEDATA value + * @throws IOException + */ + public void writeZONEDATA(ZONEDATA value) throws IOException { + writeUI16(value.alignmentCoordinate); + writeUI16(value.range); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java index d4940f78c..ceaa21535 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ABC.java @@ -40,836 +40,836 @@ import java.util.regex.Pattern; public class ABC { - public int major_version = 0; - public int minor_version = 0; - public ConstantPool constants; - public MethodInfo method_info[]; - public MetadataInfo metadata_info[]; - public InstanceInfo instance_info[]; - public ClassInfo class_info[]; - public ScriptInfo script_info[]; - public MethodBody bodies[]; - private int bodyIdxFromMethodIdx[]; - public long stringOffsets[]; - public static String IDENT_STRING = " "; - public static final int MINORwithDECIMAL = 17; - protected HashSet listeners = new HashSet(); - private static Logger logger = Logger.getLogger(ABC.class.getName()); + public int major_version = 0; + public int minor_version = 0; + public ConstantPool constants; + public MethodInfo method_info[]; + public MetadataInfo metadata_info[]; + public InstanceInfo instance_info[]; + public ClassInfo class_info[]; + public ScriptInfo script_info[]; + public MethodBody bodies[]; + private int bodyIdxFromMethodIdx[]; + public long stringOffsets[]; + public static String IDENT_STRING = " "; + public static final int MINORwithDECIMAL = 17; + protected HashSet listeners = new HashSet(); + private static Logger logger = Logger.getLogger(ABC.class.getName()); - public void addEventListener(EventListener listener) { - listeners.add(listener); - } + public void addEventListener(EventListener listener) { + listeners.add(listener); + } - public void removeEventListener(EventListener listener) { - listeners.remove(listener); - } + public void removeEventListener(EventListener listener) { + listeners.remove(listener); + } - protected void informListeners(String event, Object data) { - for (EventListener listener : listeners) { - listener.handleEvent(event, data); - } - } + protected void informListeners(String event, Object data) { + for (EventListener listener : listeners) { + listener.handleEvent(event, data); + } + } - public int removeTraps() { - int rem = 0; - for (MethodBody body : bodies) { - rem += body.removeTraps(constants, this); - } - return rem; - } + public int removeTraps() { + int rem = 0; + for (MethodBody body : bodies) { + rem += body.removeTraps(constants, this); + } + return rem; + } - public int removeDeadCode() { - int rem = 0; - for (MethodBody body : bodies) { - rem += body.removeDeadCode(constants); - } - return rem; - } + public int removeDeadCode() { + int rem = 0; + for (MethodBody body : bodies) { + rem += body.removeDeadCode(constants); + } + return rem; + } - public void restoreControlFlow() { - for (MethodBody body : bodies) { - body.restoreControlFlow(constants); - } - } + public void restoreControlFlow() { + for (MethodBody body : bodies) { + body.restoreControlFlow(constants); + } + } - public int deobfuscateIdentifiers(HashMap namesMap) { - int ret = 0; - for (int i = 1; i < instance_info.length; i++) { - if (instance_info[i].name_index != 0) { - if (deobfuscateName(namesMap, constants.constant_multiname[instance_info[i].name_index].name_index, true)) { - ret++; + public int deobfuscateIdentifiers(HashMap namesMap) { + int ret = 0; + for (int i = 1; i < instance_info.length; i++) { + if (instance_info[i].name_index != 0) { + if (deobfuscateName(namesMap, constants.constant_multiname[instance_info[i].name_index].name_index, true)) { + ret++; + } } - } - if (instance_info[i].super_index != 0) { - if (deobfuscateName(namesMap, constants.constant_multiname[instance_info[i].super_index].name_index, true)) { - ret++; + if (instance_info[i].super_index != 0) { + if (deobfuscateName(namesMap, constants.constant_multiname[instance_info[i].super_index].name_index, true)) { + ret++; + } } - } - } - for (int i = 1; i < constants.constant_multiname.length; i++) { - if (deobfuscateName(namesMap, constants.constant_multiname[i].name_index, false)) { - ret++; - } - } - for (int i = 1; i < constants.constant_namespace.length; i++) { - if (deobfuscateNameSpace(namesMap, constants.constant_namespace[i].name_index)) { - ret++; - } - } - return ret; - } + } + for (int i = 1; i < constants.constant_multiname.length; i++) { + if (deobfuscateName(namesMap, constants.constant_multiname[i].name_index, false)) { + ret++; + } + } + for (int i = 1; i < constants.constant_namespace.length; i++) { + if (deobfuscateNameSpace(namesMap, constants.constant_namespace[i].name_index)) { + ret++; + } + } + return ret; + } - public ABC(InputStream is) throws IOException { - ABCInputStream ais = new ABCInputStream(is); - minor_version = ais.readU16(); - major_version = ais.readU16(); - logger.log(Level.FINE, "ABC minor_version: {0}, major_version: {1}", new Object[]{minor_version, major_version}); - constants = new ConstantPool(); - //constant integers - int constant_int_pool_count = ais.readU30(); - constants.constant_int = new long[constant_int_pool_count]; - for (int i = 1; i < constant_int_pool_count; i++) { //index 0 not used. Values 1..n-1 - constants.constant_int[i] = ais.readS32(); - } + public ABC(InputStream is) throws IOException { + ABCInputStream ais = new ABCInputStream(is); + minor_version = ais.readU16(); + major_version = ais.readU16(); + logger.log(Level.FINE, "ABC minor_version: {0}, major_version: {1}", new Object[]{minor_version, major_version}); + constants = new ConstantPool(); + //constant integers + int constant_int_pool_count = ais.readU30(); + constants.constant_int = new long[constant_int_pool_count]; + for (int i = 1; i < constant_int_pool_count; i++) { //index 0 not used. Values 1..n-1 + constants.constant_int[i] = ais.readS32(); + } - //constant unsigned integers - int constant_uint_pool_count = ais.readU30(); - constants.constant_uint = new long[constant_uint_pool_count]; - for (int i = 1; i < constant_uint_pool_count; i++) { //index 0 not used. Values 1..n-1 - constants.constant_uint[i] = ais.readU32(); - } + //constant unsigned integers + int constant_uint_pool_count = ais.readU30(); + constants.constant_uint = new long[constant_uint_pool_count]; + for (int i = 1; i < constant_uint_pool_count; i++) { //index 0 not used. Values 1..n-1 + constants.constant_uint[i] = ais.readU32(); + } - //constant double - int constant_double_pool_count = ais.readU30(); - constants.constant_double = new double[constant_double_pool_count]; - for (int i = 1; i < constant_double_pool_count; i++) { //index 0 not used. Values 1..n-1 - constants.constant_double[i] = ais.readDouble(); - } + //constant double + int constant_double_pool_count = ais.readU30(); + constants.constant_double = new double[constant_double_pool_count]; + for (int i = 1; i < constant_double_pool_count; i++) { //index 0 not used. Values 1..n-1 + constants.constant_double[i] = ais.readDouble(); + } - //constant decimal - if (minor_version >= MINORwithDECIMAL) { - int constant_decimal_pool_count = ais.readU30(); - constants.constant_decimal = new Decimal[constant_decimal_pool_count]; - for (int i = 1; i < constant_decimal_pool_count; i++) { //index 0 not used. Values 1..n-1 - constants.constant_decimal[i] = ais.readDecimal(); - } - } else { - constants.constant_decimal = new Decimal[0]; - } + //constant decimal + if (minor_version >= MINORwithDECIMAL) { + int constant_decimal_pool_count = ais.readU30(); + constants.constant_decimal = new Decimal[constant_decimal_pool_count]; + for (int i = 1; i < constant_decimal_pool_count; i++) { //index 0 not used. Values 1..n-1 + constants.constant_decimal[i] = ais.readDecimal(); + } + } else { + constants.constant_decimal = new Decimal[0]; + } - //constant string - int constant_string_pool_count = ais.readU30(); - constants.constant_string = new String[constant_string_pool_count]; - stringOffsets = new long[constant_string_pool_count]; - constants.constant_string[0] = ""; - for (int i = 1; i < constant_string_pool_count; i++) { //index 0 not used. Values 1..n-1 - long pos = ais.getPosition(); - constants.constant_string[i] = ais.readString(); - stringOffsets[i] = pos; - } + //constant string + int constant_string_pool_count = ais.readU30(); + constants.constant_string = new String[constant_string_pool_count]; + stringOffsets = new long[constant_string_pool_count]; + constants.constant_string[0] = ""; + for (int i = 1; i < constant_string_pool_count; i++) { //index 0 not used. Values 1..n-1 + long pos = ais.getPosition(); + constants.constant_string[i] = ais.readString(); + stringOffsets[i] = pos; + } - //constant namespace - int constant_namespace_pool_count = ais.readU30(); - constants.constant_namespace = new Namespace[constant_namespace_pool_count]; - for (int i = 1; i < constant_namespace_pool_count; i++) { //index 0 not used. Values 1..n-1 - constants.constant_namespace[i] = ais.readNamespace(); - } + //constant namespace + int constant_namespace_pool_count = ais.readU30(); + constants.constant_namespace = new Namespace[constant_namespace_pool_count]; + for (int i = 1; i < constant_namespace_pool_count; i++) { //index 0 not used. Values 1..n-1 + constants.constant_namespace[i] = ais.readNamespace(); + } - //constant namespace set - int constant_namespace_set_pool_count = ais.readU30(); - constants.constant_namespace_set = new NamespaceSet[constant_namespace_set_pool_count]; - for (int i = 1; i < constant_namespace_set_pool_count; i++) { //index 0 not used. Values 1..n-1 - constants.constant_namespace_set[i] = new NamespaceSet(); - int namespace_count = ais.readU30(); - constants.constant_namespace_set[i].namespaces = new int[namespace_count]; - for (int j = 0; j < namespace_count; j++) { - constants.constant_namespace_set[i].namespaces[j] = ais.readU30(); - } - } + //constant namespace set + int constant_namespace_set_pool_count = ais.readU30(); + constants.constant_namespace_set = new NamespaceSet[constant_namespace_set_pool_count]; + for (int i = 1; i < constant_namespace_set_pool_count; i++) { //index 0 not used. Values 1..n-1 + constants.constant_namespace_set[i] = new NamespaceSet(); + int namespace_count = ais.readU30(); + constants.constant_namespace_set[i].namespaces = new int[namespace_count]; + for (int j = 0; j < namespace_count; j++) { + constants.constant_namespace_set[i].namespaces[j] = ais.readU30(); + } + } - //constant multiname - int constant_multiname_pool_count = ais.readU30(); - constants.constant_multiname = new Multiname[constant_multiname_pool_count]; - for (int i = 1; i < constant_multiname_pool_count; i++) { //index 0 not used. Values 1..n-1 - constants.constant_multiname[i] = ais.readMultiname(); - } + //constant multiname + int constant_multiname_pool_count = ais.readU30(); + constants.constant_multiname = new Multiname[constant_multiname_pool_count]; + for (int i = 1; i < constant_multiname_pool_count; i++) { //index 0 not used. Values 1..n-1 + constants.constant_multiname[i] = ais.readMultiname(); + } - //method info - int methods_count = ais.readU30(); - method_info = new MethodInfo[methods_count]; - bodyIdxFromMethodIdx = new int[methods_count]; - for (int i = 0; i < methods_count; i++) { - method_info[i] = ais.readMethodInfo(); - bodyIdxFromMethodIdx[i] = -1; - } + //method info + int methods_count = ais.readU30(); + method_info = new MethodInfo[methods_count]; + bodyIdxFromMethodIdx = new int[methods_count]; + for (int i = 0; i < methods_count; i++) { + method_info[i] = ais.readMethodInfo(); + bodyIdxFromMethodIdx[i] = -1; + } - //metadata info - int metadata_count = ais.readU30(); - metadata_info = new MetadataInfo[metadata_count]; - for (int i = 0; i < metadata_count; i++) { - int name_index = ais.readU30(); - int values_count = ais.readU30(); - int keys[] = new int[values_count]; - for (int v = 0; v < values_count; v++) { - keys[v] = ais.readU30(); - } - int values[] = new int[values_count]; - for (int v = 0; v < values_count; v++) { - values[v] = ais.readU30(); - } - metadata_info[i] = new MetadataInfo(name_index, keys, values); - } + //metadata info + int metadata_count = ais.readU30(); + metadata_info = new MetadataInfo[metadata_count]; + for (int i = 0; i < metadata_count; i++) { + int name_index = ais.readU30(); + int values_count = ais.readU30(); + int keys[] = new int[values_count]; + for (int v = 0; v < values_count; v++) { + keys[v] = ais.readU30(); + } + int values[] = new int[values_count]; + for (int v = 0; v < values_count; v++) { + values[v] = ais.readU30(); + } + metadata_info[i] = new MetadataInfo(name_index, keys, values); + } - int class_count = ais.readU30(); - instance_info = new InstanceInfo[class_count]; - for (int i = 0; i < class_count; i++) { - instance_info[i] = ais.readInstanceInfo(); - } - class_info = new ClassInfo[class_count]; - for (int i = 0; i < class_count; i++) { - ClassInfo ci = new ClassInfo(); - ci.cinit_index = ais.readU30(); - ci.static_traits = ais.readTraits(); - class_info[i] = ci; - } - int script_count = ais.readU30(); - script_info = new ScriptInfo[script_count]; - for (int i = 0; i < script_count; i++) { - ScriptInfo si = new ScriptInfo(); - si.init_index = ais.readU30(); - si.traits = ais.readTraits(); - script_info[i] = si; - } + int class_count = ais.readU30(); + instance_info = new InstanceInfo[class_count]; + for (int i = 0; i < class_count; i++) { + instance_info[i] = ais.readInstanceInfo(); + } + class_info = new ClassInfo[class_count]; + for (int i = 0; i < class_count; i++) { + ClassInfo ci = new ClassInfo(); + ci.cinit_index = ais.readU30(); + ci.static_traits = ais.readTraits(); + class_info[i] = ci; + } + int script_count = ais.readU30(); + script_info = new ScriptInfo[script_count]; + for (int i = 0; i < script_count; i++) { + ScriptInfo si = new ScriptInfo(); + si.init_index = ais.readU30(); + si.traits = ais.readTraits(); + script_info[i] = si; + } - int bodies_count = ais.readU30(); - bodies = new MethodBody[bodies_count]; - for (int i = 0; i < bodies_count; i++) { - MethodBody mb = new MethodBody(); - mb.method_info = ais.readU30(); - mb.max_stack = ais.readU30(); - mb.max_regs = ais.readU30(); - mb.init_scope_depth = ais.readU30(); - mb.max_scope_depth = ais.readU30(); - int code_length = ais.readU30(); - mb.codeBytes = new byte[code_length]; - ais.read(mb.codeBytes); - try { - mb.code = new AVM2Code(new ByteArrayInputStream(mb.codeBytes)); - } catch (UnknownInstructionCode re) { - mb.code = new AVM2Code(); - Logger.getLogger(ABC.class.getName()).log(Level.SEVERE, null, re); - } - mb.code.compact(); - int ex_count = ais.readU30(); - mb.exceptions = new ABCException[ex_count]; - for (int j = 0; j < ex_count; j++) { - ABCException abce = new ABCException(); - abce.start = ais.readU30(); - abce.end = ais.readU30(); - abce.target = ais.readU30(); - abce.type_index = ais.readU30(); - abce.name_index = ais.readU30(); - mb.exceptions[j] = abce; - } - mb.traits = ais.readTraits(); - bodies[i] = mb; - method_info[mb.method_info].setBody(mb); - bodyIdxFromMethodIdx[mb.method_info] = i; - } - loadNamespaceMap(); - } + int bodies_count = ais.readU30(); + bodies = new MethodBody[bodies_count]; + for (int i = 0; i < bodies_count; i++) { + MethodBody mb = new MethodBody(); + mb.method_info = ais.readU30(); + mb.max_stack = ais.readU30(); + mb.max_regs = ais.readU30(); + mb.init_scope_depth = ais.readU30(); + mb.max_scope_depth = ais.readU30(); + int code_length = ais.readU30(); + mb.codeBytes = new byte[code_length]; + ais.read(mb.codeBytes); + try { + mb.code = new AVM2Code(new ByteArrayInputStream(mb.codeBytes)); + } catch (UnknownInstructionCode re) { + mb.code = new AVM2Code(); + Logger.getLogger(ABC.class.getName()).log(Level.SEVERE, null, re); + } + mb.code.compact(); + int ex_count = ais.readU30(); + mb.exceptions = new ABCException[ex_count]; + for (int j = 0; j < ex_count; j++) { + ABCException abce = new ABCException(); + abce.start = ais.readU30(); + abce.end = ais.readU30(); + abce.target = ais.readU30(); + abce.type_index = ais.readU30(); + abce.name_index = ais.readU30(); + mb.exceptions[j] = abce; + } + mb.traits = ais.readTraits(); + bodies[i] = mb; + method_info[mb.method_info].setBody(mb); + bodyIdxFromMethodIdx[mb.method_info] = i; + } + loadNamespaceMap(); + } - public void saveToStream(OutputStream os) throws IOException { - ABCOutputStream aos = new ABCOutputStream(os); - aos.writeU16(minor_version); - aos.writeU16(major_version); + public void saveToStream(OutputStream os) throws IOException { + ABCOutputStream aos = new ABCOutputStream(os); + aos.writeU16(minor_version); + aos.writeU16(major_version); - aos.writeU30(constants.constant_int.length); - for (int i = 1; i < constants.constant_int.length; i++) { - aos.writeS32(constants.constant_int[i]); - } - aos.writeU30(constants.constant_uint.length); - for (int i = 1; i < constants.constant_uint.length; i++) { - aos.writeU32(constants.constant_uint[i]); - } + aos.writeU30(constants.constant_int.length); + for (int i = 1; i < constants.constant_int.length; i++) { + aos.writeS32(constants.constant_int[i]); + } + aos.writeU30(constants.constant_uint.length); + for (int i = 1; i < constants.constant_uint.length; i++) { + aos.writeU32(constants.constant_uint[i]); + } - aos.writeU30(constants.constant_double.length); - for (int i = 1; i < constants.constant_double.length; i++) { - aos.writeDouble(constants.constant_double[i]); - } + aos.writeU30(constants.constant_double.length); + for (int i = 1; i < constants.constant_double.length; i++) { + aos.writeDouble(constants.constant_double[i]); + } - if (minor_version >= MINORwithDECIMAL) { - aos.writeU30(constants.constant_decimal.length); - for (int i = 1; i < constants.constant_decimal.length; i++) { - aos.writeDecimal(constants.constant_decimal[i]); - } - } + if (minor_version >= MINORwithDECIMAL) { + aos.writeU30(constants.constant_decimal.length); + for (int i = 1; i < constants.constant_decimal.length; i++) { + aos.writeDecimal(constants.constant_decimal[i]); + } + } - aos.writeU30(constants.constant_string.length); - for (int i = 1; i < constants.constant_string.length; i++) { - aos.writeString(constants.constant_string[i]); - } + aos.writeU30(constants.constant_string.length); + for (int i = 1; i < constants.constant_string.length; i++) { + aos.writeString(constants.constant_string[i]); + } - aos.writeU30(constants.constant_namespace.length); - for (int i = 1; i < constants.constant_namespace.length; i++) { - aos.writeNamespace(constants.constant_namespace[i]); - } + aos.writeU30(constants.constant_namespace.length); + for (int i = 1; i < constants.constant_namespace.length; i++) { + aos.writeNamespace(constants.constant_namespace[i]); + } - aos.writeU30(constants.constant_namespace_set.length); - for (int i = 1; i < constants.constant_namespace_set.length; i++) { - aos.writeU30(constants.constant_namespace_set[i].namespaces.length); - for (int j = 0; j < constants.constant_namespace_set[i].namespaces.length; j++) { - aos.writeU30(constants.constant_namespace_set[i].namespaces[j]); - } - } + aos.writeU30(constants.constant_namespace_set.length); + for (int i = 1; i < constants.constant_namespace_set.length; i++) { + aos.writeU30(constants.constant_namespace_set[i].namespaces.length); + for (int j = 0; j < constants.constant_namespace_set[i].namespaces.length; j++) { + aos.writeU30(constants.constant_namespace_set[i].namespaces[j]); + } + } - aos.writeU30(constants.constant_multiname.length); - for (int i = 1; i < constants.constant_multiname.length; i++) { - aos.writeMultiname(constants.constant_multiname[i]); - } + aos.writeU30(constants.constant_multiname.length); + for (int i = 1; i < constants.constant_multiname.length; i++) { + aos.writeMultiname(constants.constant_multiname[i]); + } - aos.writeU30(method_info.length); - for (int i = 0; i < method_info.length; i++) { - aos.writeMethodInfo(method_info[i]); - } + aos.writeU30(method_info.length); + for (int i = 0; i < method_info.length; i++) { + aos.writeMethodInfo(method_info[i]); + } - aos.writeU30(metadata_info.length); - for (int i = 0; i < metadata_info.length; i++) { - aos.writeU30(metadata_info[i].name_index); - aos.writeU30(metadata_info[i].values.length); - for (int j = 0; j < metadata_info[i].values.length; j++) { - aos.writeU30(metadata_info[i].keys[j]); - } - for (int j = 0; j < metadata_info[i].values.length; j++) { - aos.writeU30(metadata_info[i].values[j]); - } - } + aos.writeU30(metadata_info.length); + for (int i = 0; i < metadata_info.length; i++) { + aos.writeU30(metadata_info[i].name_index); + aos.writeU30(metadata_info[i].values.length); + for (int j = 0; j < metadata_info[i].values.length; j++) { + aos.writeU30(metadata_info[i].keys[j]); + } + for (int j = 0; j < metadata_info[i].values.length; j++) { + aos.writeU30(metadata_info[i].values[j]); + } + } - aos.writeU30(class_info.length); - for (int i = 0; i < instance_info.length; i++) { - aos.writeInstanceInfo(instance_info[i]); - } - for (int i = 0; i < class_info.length; i++) { - aos.writeU30(class_info[i].cinit_index); - aos.writeTraits(class_info[i].static_traits); - } - aos.writeU30(script_info.length); - for (int i = 0; i < script_info.length; i++) { - aos.writeU30(script_info[i].init_index); - aos.writeTraits(script_info[i].traits); - } + aos.writeU30(class_info.length); + for (int i = 0; i < instance_info.length; i++) { + aos.writeInstanceInfo(instance_info[i]); + } + for (int i = 0; i < class_info.length; i++) { + aos.writeU30(class_info[i].cinit_index); + aos.writeTraits(class_info[i].static_traits); + } + aos.writeU30(script_info.length); + for (int i = 0; i < script_info.length; i++) { + aos.writeU30(script_info[i].init_index); + aos.writeTraits(script_info[i].traits); + } - aos.writeU30(bodies.length); - for (int i = 0; i < bodies.length; i++) { - aos.writeU30(bodies[i].method_info); - aos.writeU30(bodies[i].max_stack); - aos.writeU30(bodies[i].max_regs); - aos.writeU30(bodies[i].init_scope_depth); - aos.writeU30(bodies[i].max_scope_depth); - byte codeBytes[] = bodies[i].code.getBytes(); - aos.writeU30(codeBytes.length); - try { - aos.write(codeBytes); - } catch (NotSameException ex) { - System.out.println(bodies[i].code.toString(constants)); - System.exit(0); - return; - } - aos.writeU30(bodies[i].exceptions.length); - for (int j = 0; j < bodies[i].exceptions.length; j++) { - aos.writeU30(bodies[i].exceptions[j].start); - aos.writeU30(bodies[i].exceptions[j].end); - aos.writeU30(bodies[i].exceptions[j].target); - aos.writeU30(bodies[i].exceptions[j].type_index); - aos.writeU30(bodies[i].exceptions[j].name_index); - } - aos.writeTraits(bodies[i].traits); - } - } + aos.writeU30(bodies.length); + for (int i = 0; i < bodies.length; i++) { + aos.writeU30(bodies[i].method_info); + aos.writeU30(bodies[i].max_stack); + aos.writeU30(bodies[i].max_regs); + aos.writeU30(bodies[i].init_scope_depth); + aos.writeU30(bodies[i].max_scope_depth); + byte codeBytes[] = bodies[i].code.getBytes(); + aos.writeU30(codeBytes.length); + try { + aos.write(codeBytes); + } catch (NotSameException ex) { + System.out.println(bodies[i].code.toString(constants)); + System.exit(0); + return; + } + aos.writeU30(bodies[i].exceptions.length); + for (int j = 0; j < bodies[i].exceptions.length; j++) { + aos.writeU30(bodies[i].exceptions[j].start); + aos.writeU30(bodies[i].exceptions[j].end); + aos.writeU30(bodies[i].exceptions[j].target); + aos.writeU30(bodies[i].exceptions[j].type_index); + aos.writeU30(bodies[i].exceptions[j].name_index); + } + aos.writeTraits(bodies[i].traits); + } + } - public MethodBody findBody(int methodInfo) { - if (methodInfo < 0) { - return null; - } - return method_info[methodInfo].getBody(); - } + public MethodBody findBody(int methodInfo) { + if (methodInfo < 0) { + return null; + } + return method_info[methodInfo].getBody(); + } - public int findBodyIndex(int methodInfo) { - if (methodInfo == -1) { - return -1; - } - return bodyIdxFromMethodIdx[methodInfo]; - } + public int findBodyIndex(int methodInfo) { + if (methodInfo == -1) { + return -1; + } + return bodyIdxFromMethodIdx[methodInfo]; + } - public MethodBody findBodyByClassAndName(String className, String methodName) { - for (int i = 0; i < instance_info.length; i++) { - if (className.equals(constants.constant_multiname[instance_info[i].name_index].getName(constants, new ArrayList()))) { - for (Trait t : instance_info[i].instance_traits.traits) { - if (t instanceof TraitMethodGetterSetter) { - TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t; - if (methodName.equals(t2.getName(this).getName(constants, new ArrayList()))) { - for (MethodBody body : bodies) { - if (body.method_info == t2.method_info) { - return body; + public MethodBody findBodyByClassAndName(String className, String methodName) { + for (int i = 0; i < instance_info.length; i++) { + if (className.equals(constants.constant_multiname[instance_info[i].name_index].getName(constants, new ArrayList()))) { + for (Trait t : instance_info[i].instance_traits.traits) { + if (t instanceof TraitMethodGetterSetter) { + TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t; + if (methodName.equals(t2.getName(this).getName(constants, new ArrayList()))) { + for (MethodBody body : bodies) { + if (body.method_info == t2.method_info) { + return body; + } + } } - } - } - } + } + } + //break; } - //break; - } - } - for (int i = 0; i < class_info.length; i++) { - if (className.equals(constants.constant_multiname[instance_info[i].name_index].getName(constants, new ArrayList()))) { - for (Trait t : class_info[i].static_traits.traits) { - if (t instanceof TraitMethodGetterSetter) { - TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t; - if (methodName.equals(t2.getName(this).getName(constants, new ArrayList()))) { - for (MethodBody body : bodies) { - if (body.method_info == t2.method_info) { - return body; + } + for (int i = 0; i < class_info.length; i++) { + if (className.equals(constants.constant_multiname[instance_info[i].name_index].getName(constants, new ArrayList()))) { + for (Trait t : class_info[i].static_traits.traits) { + if (t instanceof TraitMethodGetterSetter) { + TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t; + if (methodName.equals(t2.getName(this).getName(constants, new ArrayList()))) { + for (MethodBody body : bodies) { + if (body.method_info == t2.method_info) { + return body; + } + } } - } - } - } + } + } + //break; } - //break; - } - } + } - return null; - } + return null; + } - public static String addTabs(String s, int tabs) { - String parts[] = s.split("\r\n"); - if (!s.contains("\r\n")) { - parts = s.split("\n"); - } - StringBuilder ret = new StringBuilder(); - for (int i = 0; i < parts.length; i++) { - for (int t = 0; t < tabs; t++) { - ret.append(IDENT_STRING); - } - ret.append(parts[i]); - if (i < parts.length - 1) { - ret.append("\r\n"); - } - } - return ret.toString(); - } - - public Trait findTraitByTraitId(int classIndex, int traitId) { - if (traitId < class_info[classIndex].static_traits.traits.length) { - return class_info[classIndex].static_traits.traits[traitId]; - } else if (traitId < class_info[classIndex].static_traits.traits.length + instance_info[classIndex].instance_traits.traits.length) { - traitId -= class_info[classIndex].static_traits.traits.length; - return instance_info[classIndex].instance_traits.traits[traitId]; - } else { - return null; //Can be class or instance initializer - } - } - - public int findMethodIdByTraitId(int classIndex, int traitId) { - if (traitId < class_info[classIndex].static_traits.traits.length) { - if (class_info[classIndex].static_traits.traits[traitId] instanceof TraitMethodGetterSetter) { - return ((TraitMethodGetterSetter) class_info[classIndex].static_traits.traits[traitId]).method_info; - } else { - return -1; - } - } else if (traitId < class_info[classIndex].static_traits.traits.length + instance_info[classIndex].instance_traits.traits.length) { - traitId -= class_info[classIndex].static_traits.traits.length; - if (instance_info[classIndex].instance_traits.traits[traitId] instanceof TraitMethodGetterSetter) { - return ((TraitMethodGetterSetter) instance_info[classIndex].instance_traits.traits[traitId]).method_info; - } else { - return -1; - } - } else { - traitId -= class_info[classIndex].static_traits.traits.length + instance_info[classIndex].instance_traits.traits.length; - if (traitId == 0) { - return instance_info[classIndex].iinit_index; - } else if (traitId == 1) { - return class_info[classIndex].cinit_index; - } else { - return -1; - } - } - } - /* Map from multiname index of namespace value to namespace name**/ - private HashMap namespaceMap; - - private void loadNamespaceMap() { - namespaceMap = new HashMap(); - for (ScriptInfo si : script_info) { - for (Trait t : si.traits.traits) { - if (t instanceof TraitSlotConst) { - TraitSlotConst s = ((TraitSlotConst) t); - if (s.isNamespace()) { - String key = constants.constant_namespace[s.value_index].getName(constants); - String val = constants.constant_multiname[s.name_index].getNameWithNamespace(constants); - namespaceMap.put(key, val); - } + public static String addTabs(String s, int tabs) { + String parts[] = s.split("\r\n"); + if (!s.contains("\r\n")) { + parts = s.split("\n"); + } + StringBuilder ret = new StringBuilder(); + for (int i = 0; i < parts.length; i++) { + for (int t = 0; t < tabs; t++) { + ret.append(IDENT_STRING); } - } - } - } + ret.append(parts[i]); + if (i < parts.length - 1) { + ret.append("\r\n"); + } + } + return ret.toString(); + } - public String builtInNs(String ns) { - if (ns.equals("http://www.adobe.com/2006/actionscript/flash/proxy")) { - return "flash.utils.flash_proxy"; - } - if (ns.equals("http://adobe.com/AS3/2006/builtin")) { - return "-"; - } - return null; - } + public Trait findTraitByTraitId(int classIndex, int traitId) { + if (traitId < class_info[classIndex].static_traits.traits.length) { + return class_info[classIndex].static_traits.traits[traitId]; + } else if (traitId < class_info[classIndex].static_traits.traits.length + instance_info[classIndex].instance_traits.traits.length) { + traitId -= class_info[classIndex].static_traits.traits.length; + return instance_info[classIndex].instance_traits.traits[traitId]; + } else { + return null; //Can be class or instance initializer + } + } - public String nsValueToName(String value) { - if (namespaceMap.containsKey(value)) { - return namespaceMap.get(value); - } else { - String ns = builtInNs(value); - if (ns == null) { - return ""; - } else { - return ns; - } - } - } - - public void export(String directory, boolean pcode, List abcList) throws IOException { - export(directory, pcode, abcList, ""); - } - - public void export(String directory, boolean pcode, List abcList, String abcStr) throws IOException { - for (int i = 0; i < script_info.length; i++) { - String path = script_info[i].getPath(this); - String packageName = path.substring(0, path.lastIndexOf(".")); - if (packageName.equals("")) { - path = path.substring(1); - } - String cnt = ""; - if (script_info.length > 1) { - cnt = "script " + (i + 1) + "/" + script_info.length + " "; - } - String exStr = "Exporting " + abcStr + cnt + path + " ..."; - informListeners("export", exStr); - script_info[i].export(this, abcList, directory, pcode); - } - } - - public void dump(OutputStream os) { - PrintStream output = new PrintStream(os); - constants.dump(output); - for (int i = 0; i < method_info.length; i++) { - output.println("MethodInfo[" + i + "]:" + method_info[i].toString(constants, new ArrayList())); - } - for (int i = 0; i < metadata_info.length; i++) { - output.println("MetadataInfo[" + i + "]:" + metadata_info[i].toString(constants)); - } - for (int i = 0; i < instance_info.length; i++) { - output.println("InstanceInfo[" + i + "]:" + instance_info[i].toString(this, new ArrayList())); - } - for (int i = 0; i < class_info.length; i++) { - output.println("ClassInfo[" + i + "]:" + class_info[i].toString(this, new ArrayList())); - } - for (int i = 0; i < script_info.length; i++) { - output.println("ScriptInfo[" + i + "]:" + script_info[i].toString(this, new ArrayList())); - } - for (int i = 0; i < bodies.length; i++) { - output.println("MethodBody[" + i + "]:"); //+ bodies[i].toString(this, constants, method_info)); - } - } - public static final String[] reservedWords = { - "as", "break", "case", "catch", "class", "const", "continue", "default", "delete", "do", "each", "else", - "extends", "false", "finally", "for", "function", "get", "if", "implements", "import", "in", "instanceof", - "interface", "internal", "is", "native", "new", "null", "override", "package", "private", "protected", "public", - "return", "set", "super", "switch", "this", "throw", "true", "try", "typeof", "use", "var", /*"void",*/ "while", - "with", "dynamic", "default", "final", "in"}; - public static final String validFirstCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; - public static final String validNextCharacters = validFirstCharacters + "0123456789"; - public static final String validNsCharacters = ".:$"; - public static final String fooCharacters = "bcdfghjklmnpqrstvwz"; - public static final String fooJoinCharacters = "aeiouy"; - private HashMap deobfuscated = new HashMap(); - private Random rnd = new Random(); - private final int DEFAULT_FOO_SIZE = 10; - - private String fooString(String orig, boolean firstUppercase, int rndSize) { - boolean exists; - String ret; - loopfoo: - do { - exists = false; - int len = 3 + rnd.nextInt(rndSize - 3); - ret = ""; - for (int i = 0; i < len; i++) { - String c = ""; - if ((i % 2) == 0) { - c = "" + fooCharacters.charAt(rnd.nextInt(fooCharacters.length())); + public int findMethodIdByTraitId(int classIndex, int traitId) { + if (traitId < class_info[classIndex].static_traits.traits.length) { + if (class_info[classIndex].static_traits.traits[traitId] instanceof TraitMethodGetterSetter) { + return ((TraitMethodGetterSetter) class_info[classIndex].static_traits.traits[traitId]).method_info; } else { - c = "" + fooJoinCharacters.charAt(rnd.nextInt(fooJoinCharacters.length())); + return -1; } - if (i == 0 && firstUppercase) { - c = c.toUpperCase(); - } - ret += c; - } - for (int i = 1; i < constants.constant_string.length; i++) { - if (constants.constant_string[i].equals(ret)) { - exists = true; - rndSize = rndSize + 1; - continue loopfoo; - } - } - if (isReserved(ret)) { - exists = true; - rndSize = rndSize + 1; - continue; - } - if (deobfuscated.containsValue(ret)) { - exists = true; - rndSize = rndSize + 1; - continue; - } - } while (exists); - deobfuscated.put(orig, ret); - return ret; - } - - private boolean isReserved(String s) { - for (String rw : reservedWords) { - if (rw.equals(s.trim())) { - return true; - } - } - return false; - } - - private boolean isValidNSPart(String s) { - boolean isValid = true; - if (isReserved(s)) { - isValid = false; - } - - if (isValid) { - for (int i = 0; i < s.length(); i++) { - if (s.charAt(i) > 127) { - isValid = false; - break; - } - } - } - if (isValid) { - Pattern pat = Pattern.compile("^([" + Pattern.quote(validFirstCharacters) + "]" + "[" + Pattern.quote(validFirstCharacters + validNextCharacters + validNsCharacters) + "]*)*$"); - if (!pat.matcher(s).matches()) { - isValid = false; - } - } - return isValid; - } - - public boolean deobfuscateNameSpace(HashMap namesMap, int strIndex) { - if (strIndex <= 0) { - return false; - } - String s = constants.constant_string[strIndex]; - boolean isValid = isValidNSPart(s); - if (!isValid) { - if (namesMap.containsKey(s)) { - constants.constant_string[strIndex] = namesMap.get(s); - } else { - String parts[] = null; - if (s.contains(".")) { - parts = s.split("\\."); + } else if (traitId < class_info[classIndex].static_traits.traits.length + instance_info[classIndex].instance_traits.traits.length) { + traitId -= class_info[classIndex].static_traits.traits.length; + if (instance_info[classIndex].instance_traits.traits[traitId] instanceof TraitMethodGetterSetter) { + return ((TraitMethodGetterSetter) instance_info[classIndex].instance_traits.traits[traitId]).method_info; } else { - parts = new String[]{s}; + return -1; } - String ret = ""; - for (int p = 0; p < parts.length; p++) { - if (p > 0) { - ret += "."; - } - if (!isValidNSPart(parts[p])) { - ret += fooString(constants.constant_string[strIndex], false, DEFAULT_FOO_SIZE); - } else { - ret += parts[p]; - } + } else { + traitId -= class_info[classIndex].static_traits.traits.length + instance_info[classIndex].instance_traits.traits.length; + if (traitId == 0) { + return instance_info[classIndex].iinit_index; + } else if (traitId == 1) { + return class_info[classIndex].cinit_index; + } else { + return -1; } - constants.constant_string[strIndex] = ret; - namesMap.put(s, constants.constant_string[strIndex]); - } - } - return !isValid; - } + } + } + /* Map from multiname index of namespace value to namespace name**/ + private HashMap namespaceMap; - public boolean deobfuscateName(HashMap namesMap, int strIndex, boolean firstUppercase) { - if (strIndex <= 0) { - return false; - } - String s = constants.constant_string[strIndex]; - boolean isValid = true; - if (isReserved(s)) { - isValid = false; - } - - if (isValid) { - for (int i = 0; i < s.length(); i++) { - if (s.charAt(i) > 127) { - isValid = false; - break; + private void loadNamespaceMap() { + namespaceMap = new HashMap(); + for (ScriptInfo si : script_info) { + for (Trait t : si.traits.traits) { + if (t instanceof TraitSlotConst) { + TraitSlotConst s = ((TraitSlotConst) t); + if (s.isNamespace()) { + String key = constants.constant_namespace[s.value_index].getName(constants); + String val = constants.constant_multiname[s.name_index].getNameWithNamespace(constants); + namespaceMap.put(key, val); + } + } } - } - } + } + } - if (isValid) { - Pattern pat = Pattern.compile("^[" + Pattern.quote(validFirstCharacters) + "]" + "[" + Pattern.quote(validFirstCharacters + validNextCharacters) + "]*$"); - if (!pat.matcher(s).matches()) { + public String builtInNs(String ns) { + if (ns.equals("http://www.adobe.com/2006/actionscript/flash/proxy")) { + return "flash.utils.flash_proxy"; + } + if (ns.equals("http://adobe.com/AS3/2006/builtin")) { + return "-"; + } + return null; + } + + public String nsValueToName(String value) { + if (namespaceMap.containsKey(value)) { + return namespaceMap.get(value); + } else { + String ns = builtInNs(value); + if (ns == null) { + return ""; + } else { + return ns; + } + } + } + + public void export(String directory, boolean pcode, List abcList) throws IOException { + export(directory, pcode, abcList, ""); + } + + public void export(String directory, boolean pcode, List abcList, String abcStr) throws IOException { + for (int i = 0; i < script_info.length; i++) { + String path = script_info[i].getPath(this); + String packageName = path.substring(0, path.lastIndexOf(".")); + if (packageName.equals("")) { + path = path.substring(1); + } + String cnt = ""; + if (script_info.length > 1) { + cnt = "script " + (i + 1) + "/" + script_info.length + " "; + } + String exStr = "Exporting " + abcStr + cnt + path + " ..."; + informListeners("export", exStr); + script_info[i].export(this, abcList, directory, pcode); + } + } + + public void dump(OutputStream os) { + PrintStream output = new PrintStream(os); + constants.dump(output); + for (int i = 0; i < method_info.length; i++) { + output.println("MethodInfo[" + i + "]:" + method_info[i].toString(constants, new ArrayList())); + } + for (int i = 0; i < metadata_info.length; i++) { + output.println("MetadataInfo[" + i + "]:" + metadata_info[i].toString(constants)); + } + for (int i = 0; i < instance_info.length; i++) { + output.println("InstanceInfo[" + i + "]:" + instance_info[i].toString(this, new ArrayList())); + } + for (int i = 0; i < class_info.length; i++) { + output.println("ClassInfo[" + i + "]:" + class_info[i].toString(this, new ArrayList())); + } + for (int i = 0; i < script_info.length; i++) { + output.println("ScriptInfo[" + i + "]:" + script_info[i].toString(this, new ArrayList())); + } + for (int i = 0; i < bodies.length; i++) { + output.println("MethodBody[" + i + "]:"); //+ bodies[i].toString(this, constants, method_info)); + } + } + public static final String[] reservedWords = { + "as", "break", "case", "catch", "class", "const", "continue", "default", "delete", "do", "each", "else", + "extends", "false", "finally", "for", "function", "get", "if", "implements", "import", "in", "instanceof", + "interface", "internal", "is", "native", "new", "null", "override", "package", "private", "protected", "public", + "return", "set", "super", "switch", "this", "throw", "true", "try", "typeof", "use", "var", /*"void",*/ "while", + "with", "dynamic", "default", "final", "in"}; + public static final String validFirstCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"; + public static final String validNextCharacters = validFirstCharacters + "0123456789"; + public static final String validNsCharacters = ".:$"; + public static final String fooCharacters = "bcdfghjklmnpqrstvwz"; + public static final String fooJoinCharacters = "aeiouy"; + private HashMap deobfuscated = new HashMap(); + private Random rnd = new Random(); + private final int DEFAULT_FOO_SIZE = 10; + + private String fooString(String orig, boolean firstUppercase, int rndSize) { + boolean exists; + String ret; + loopfoo: + do { + exists = false; + int len = 3 + rnd.nextInt(rndSize - 3); + ret = ""; + for (int i = 0; i < len; i++) { + String c = ""; + if ((i % 2) == 0) { + c = "" + fooCharacters.charAt(rnd.nextInt(fooCharacters.length())); + } else { + c = "" + fooJoinCharacters.charAt(rnd.nextInt(fooJoinCharacters.length())); + } + if (i == 0 && firstUppercase) { + c = c.toUpperCase(); + } + ret += c; + } + for (int i = 1; i < constants.constant_string.length; i++) { + if (constants.constant_string[i].equals(ret)) { + exists = true; + rndSize = rndSize + 1; + continue loopfoo; + } + } + if (isReserved(ret)) { + exists = true; + rndSize = rndSize + 1; + continue; + } + if (deobfuscated.containsValue(ret)) { + exists = true; + rndSize = rndSize + 1; + continue; + } + } while (exists); + deobfuscated.put(orig, ret); + return ret; + } + + private boolean isReserved(String s) { + for (String rw : reservedWords) { + if (rw.equals(s.trim())) { + return true; + } + } + return false; + } + + private boolean isValidNSPart(String s) { + boolean isValid = true; + if (isReserved(s)) { isValid = false; - } - } + } - if (!isValid) { - if (namesMap.containsKey(s)) { - constants.constant_string[strIndex] = namesMap.get(s); - } else { - constants.constant_string[strIndex] = fooString(constants.constant_string[strIndex], firstUppercase, DEFAULT_FOO_SIZE); - namesMap.put(s, constants.constant_string[strIndex]); - } - } - return !isValid; - } + if (isValid) { + for (int i = 0; i < s.length(); i++) { + if (s.charAt(i) > 127) { + isValid = false; + break; + } + } + } + if (isValid) { + Pattern pat = Pattern.compile("^([" + Pattern.quote(validFirstCharacters) + "]" + "[" + Pattern.quote(validFirstCharacters + validNextCharacters + validNsCharacters) + "]*)*$"); + if (!pat.matcher(s).matches()) { + isValid = false; + } + } + return isValid; + } - private void checkMultinameUsedInMethod(int multinameIndex, int methodInfo, List ret, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { - for (int p = 0; p < method_info[methodInfo].param_types.length; p++) { - if (method_info[methodInfo].param_types[p] == multinameIndex) { - ret.add(new MethodParamsMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex)); - break; - } - } - if (method_info[methodInfo].ret_type == multinameIndex) { - ret.add(new MethodReturnTypeMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex)); - } - MethodBody body = findBody(methodInfo); - if (body != null) { - findMultinameUsageInTraits(body.traits, multinameIndex, isStatic, classIndex, ret, traitIndex); - for (ABCException e : body.exceptions) { - if ((e.name_index == multinameIndex) || (e.type_index == multinameIndex)) { - ret.add(new MethodBodyMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex)); - return; + public boolean deobfuscateNameSpace(HashMap namesMap, int strIndex) { + if (strIndex <= 0) { + return false; + } + String s = constants.constant_string[strIndex]; + boolean isValid = isValidNSPart(s); + if (!isValid) { + if (namesMap.containsKey(s)) { + constants.constant_string[strIndex] = namesMap.get(s); + } else { + String parts[] = null; + if (s.contains(".")) { + parts = s.split("\\."); + } else { + parts = new String[]{s}; + } + String ret = ""; + for (int p = 0; p < parts.length; p++) { + if (p > 0) { + ret += "."; + } + if (!isValidNSPart(parts[p])) { + ret += fooString(constants.constant_string[strIndex], false, DEFAULT_FOO_SIZE); + } else { + ret += parts[p]; + } + } + constants.constant_string[strIndex] = ret; + namesMap.put(s, constants.constant_string[strIndex]); } - } - for (AVM2Instruction ins : body.code.code) { - for (int o = 0; o < ins.definition.operands.length; o++) { - if (ins.definition.operands[o] == AVM2Code.DAT_MULTINAME_INDEX) { - if (ins.operands[o] == multinameIndex) { - ret.add(new MethodBodyMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex)); - return; - } - } - } - } - } - } + } + return !isValid; + } - private void findMultinameUsageInTraits(Traits traits, int multinameIndex, boolean isStatic, int classIndex, List ret, int parentTraitIndex) { - for (int t = 0; t < traits.traits.length; t++) { - if (traits.traits[t] instanceof TraitSlotConst) { - TraitSlotConst tsc = (TraitSlotConst) traits.traits[t]; - if (tsc.name_index == multinameIndex) { - ret.add(new ConstVarNameMultinameUsage(multinameIndex, classIndex, t, isStatic, traits, parentTraitIndex)); - } - if (tsc.type_index == multinameIndex) { - ret.add(new ConstVarTypeMultinameUsage(multinameIndex, classIndex, t, isStatic, traits, parentTraitIndex)); - } - } - if (traits.traits[t] instanceof TraitMethodGetterSetter) { - TraitMethodGetterSetter tmgs = (TraitMethodGetterSetter) traits.traits[t]; - if (tmgs.name_index == multinameIndex) { - ret.add(new MethodNameMultinameUsage(multinameIndex, classIndex, t, isStatic, false, traits, parentTraitIndex)); - } - checkMultinameUsedInMethod(multinameIndex, tmgs.method_info, ret, classIndex, t, isStatic, false, traits, parentTraitIndex); - } - } - } + public boolean deobfuscateName(HashMap namesMap, int strIndex, boolean firstUppercase) { + if (strIndex <= 0) { + return false; + } + String s = constants.constant_string[strIndex]; + boolean isValid = true; + if (isReserved(s)) { + isValid = false; + } - public List findMultinameUsage(int multinameIndex) { - List ret = new ArrayList(); - if (multinameIndex == 0) { - return ret; - } - for (int c = 0; c < instance_info.length; c++) { - if (instance_info[c].name_index == multinameIndex) { - ret.add(new ClassNameMultinameUsage(multinameIndex, c)); - } - if (instance_info[c].super_index == multinameIndex) { - ret.add(new ExtendsMultinameUsage(multinameIndex, c)); - } - for (int i = 0; i < instance_info[c].interfaces.length; i++) { - if (instance_info[c].interfaces[i] == multinameIndex) { - ret.add(new ImplementsMultinameUsage(multinameIndex, c)); + if (isValid) { + for (int i = 0; i < s.length(); i++) { + if (s.charAt(i) > 127) { + isValid = false; + break; + } } - } - checkMultinameUsedInMethod(multinameIndex, instance_info[c].iinit_index, ret, c, 0, false, true, null, -1); - checkMultinameUsedInMethod(multinameIndex, class_info[c].cinit_index, ret, c, 0, true, true, null, -1); - findMultinameUsageInTraits(instance_info[c].instance_traits, multinameIndex, false, c, ret, -1); - findMultinameUsageInTraits(class_info[c].static_traits, multinameIndex, true, c, ret, -1); - } - loopm: - for (int m = 1; m < constants.constant_multiname.length; m++) { - if (constants.constant_multiname[m].kind == Multiname.TYPENAME) { - if (constants.constant_multiname[m].qname_index == multinameIndex) { - ret.add(new TypeNameMultinameUsage(m)); - continue; + } + + if (isValid) { + Pattern pat = Pattern.compile("^[" + Pattern.quote(validFirstCharacters) + "]" + "[" + Pattern.quote(validFirstCharacters + validNextCharacters) + "]*$"); + if (!pat.matcher(s).matches()) { + isValid = false; } - for (int mp : constants.constant_multiname[m].params) { - if (mp == multinameIndex) { - ret.add(new TypeNameMultinameUsage(m)); - continue loopm; - } + } + + if (!isValid) { + if (namesMap.containsKey(s)) { + constants.constant_string[strIndex] = namesMap.get(s); + } else { + constants.constant_string[strIndex] = fooString(constants.constant_string[strIndex], firstUppercase, DEFAULT_FOO_SIZE); + namesMap.put(s, constants.constant_string[strIndex]); } - } - } - return ret; - } + } + return !isValid; + } - public void autoFillAllBodyParams() { - for (int i = 0; i < bodies.length; i++) { - bodies[i].autoFillStats(this); - } - } - - public int findMethodBodyByName(int classId, String methodName) { - if (classId > -1) { - for (Trait t : instance_info[classId].instance_traits.traits) { - if (t instanceof TraitMethodGetterSetter) { - if (t.getName(this).getName(constants, new ArrayList()).equals(methodName)) { - return findBodyIndex(((TraitMethodGetterSetter) t).method_info); - } + private void checkMultinameUsedInMethod(int multinameIndex, int methodInfo, List ret, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { + for (int p = 0; p < method_info[methodInfo].param_types.length; p++) { + if (method_info[methodInfo].param_types[p] == multinameIndex) { + ret.add(new MethodParamsMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex)); + break; } - } - } - return -1; - } + } + if (method_info[methodInfo].ret_type == multinameIndex) { + ret.add(new MethodReturnTypeMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex)); + } + MethodBody body = findBody(methodInfo); + if (body != null) { + findMultinameUsageInTraits(body.traits, multinameIndex, isStatic, classIndex, ret, traitIndex); + for (ABCException e : body.exceptions) { + if ((e.name_index == multinameIndex) || (e.type_index == multinameIndex)) { + ret.add(new MethodBodyMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex)); + return; + } + } + for (AVM2Instruction ins : body.code.code) { + for (int o = 0; o < ins.definition.operands.length; o++) { + if (ins.definition.operands[o] == AVM2Code.DAT_MULTINAME_INDEX) { + if (ins.operands[o] == multinameIndex) { + ret.add(new MethodBodyMultinameUsage(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex)); + return; + } + } + } + } + } + } - public int findMethodBodyByName(String className, String methodName) { - int classId = findClassByName(className); - return findMethodBodyByName(classId, methodName); - } + private void findMultinameUsageInTraits(Traits traits, int multinameIndex, boolean isStatic, int classIndex, List ret, int parentTraitIndex) { + for (int t = 0; t < traits.traits.length; t++) { + if (traits.traits[t] instanceof TraitSlotConst) { + TraitSlotConst tsc = (TraitSlotConst) traits.traits[t]; + if (tsc.name_index == multinameIndex) { + ret.add(new ConstVarNameMultinameUsage(multinameIndex, classIndex, t, isStatic, traits, parentTraitIndex)); + } + if (tsc.type_index == multinameIndex) { + ret.add(new ConstVarTypeMultinameUsage(multinameIndex, classIndex, t, isStatic, traits, parentTraitIndex)); + } + } + if (traits.traits[t] instanceof TraitMethodGetterSetter) { + TraitMethodGetterSetter tmgs = (TraitMethodGetterSetter) traits.traits[t]; + if (tmgs.name_index == multinameIndex) { + ret.add(new MethodNameMultinameUsage(multinameIndex, classIndex, t, isStatic, false, traits, parentTraitIndex)); + } + checkMultinameUsedInMethod(multinameIndex, tmgs.method_info, ret, classIndex, t, isStatic, false, traits, parentTraitIndex); + } + } + } - public int findClassByName(String name) { - for (int c = 0; c < instance_info.length; c++) { - String s = constants.constant_multiname[instance_info[c].name_index].getNameWithNamespace(constants); - if (name.equals(s)) { - return c; - } - } - return -1; - } + public List findMultinameUsage(int multinameIndex) { + List ret = new ArrayList(); + if (multinameIndex == 0) { + return ret; + } + for (int c = 0; c < instance_info.length; c++) { + if (instance_info[c].name_index == multinameIndex) { + ret.add(new ClassNameMultinameUsage(multinameIndex, c)); + } + if (instance_info[c].super_index == multinameIndex) { + ret.add(new ExtendsMultinameUsage(multinameIndex, c)); + } + for (int i = 0; i < instance_info[c].interfaces.length; i++) { + if (instance_info[c].interfaces[i] == multinameIndex) { + ret.add(new ImplementsMultinameUsage(multinameIndex, c)); + } + } + checkMultinameUsedInMethod(multinameIndex, instance_info[c].iinit_index, ret, c, 0, false, true, null, -1); + checkMultinameUsedInMethod(multinameIndex, class_info[c].cinit_index, ret, c, 0, true, true, null, -1); + findMultinameUsageInTraits(instance_info[c].instance_traits, multinameIndex, false, c, ret, -1); + findMultinameUsageInTraits(class_info[c].static_traits, multinameIndex, true, c, ret, -1); + } + loopm: + for (int m = 1; m < constants.constant_multiname.length; m++) { + if (constants.constant_multiname[m].kind == Multiname.TYPENAME) { + if (constants.constant_multiname[m].qname_index == multinameIndex) { + ret.add(new TypeNameMultinameUsage(m)); + continue; + } + for (int mp : constants.constant_multiname[m].params) { + if (mp == multinameIndex) { + ret.add(new TypeNameMultinameUsage(m)); + continue loopm; + } + } + } + } + return ret; + } + + public void autoFillAllBodyParams() { + for (int i = 0; i < bodies.length; i++) { + bodies[i].autoFillStats(this); + } + } + + public int findMethodBodyByName(int classId, String methodName) { + if (classId > -1) { + for (Trait t : instance_info[classId].instance_traits.traits) { + if (t instanceof TraitMethodGetterSetter) { + if (t.getName(this).getName(constants, new ArrayList()).equals(methodName)) { + return findBodyIndex(((TraitMethodGetterSetter) t).method_info); + } + } + } + } + return -1; + } + + public int findMethodBodyByName(String className, String methodName) { + int classId = findClassByName(className); + return findMethodBodyByName(classId, methodName); + } + + public int findClassByName(String name) { + for (int c = 0; c < instance_info.length; c++) { + String s = constants.constant_multiname[instance_info[c].name_index].getNameWithNamespace(constants); + if (name.equals(s)) { + return c; + } + } + return -1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ABCInputStream.java b/trunk/src/com/jpexs/decompiler/flash/abc/ABCInputStream.java index 21de85312..76aa45551 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ABCInputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ABCInputStream.java @@ -26,352 +26,354 @@ import java.util.List; public class ABCInputStream extends InputStream { - private static final int CLASS_PROTECTED_NS = 8; - private static final int ATTR_METADATA = 4; - private InputStream is; - private long bytesRead = 0; - private ByteArrayOutputStream bufferOs = null; - public static boolean DEBUG_READ = false; + private static final int CLASS_PROTECTED_NS = 8; + private static final int ATTR_METADATA = 4; + private InputStream is; + private long bytesRead = 0; + private ByteArrayOutputStream bufferOs = null; + public static boolean DEBUG_READ = false; - public void startBuffer() { - bufferOs = new ByteArrayOutputStream(); - } + public void startBuffer() { + bufferOs = new ByteArrayOutputStream(); + } - public byte[] stopBuffer() { - if (bufferOs == null) { - return new byte[0]; - } - byte ret[] = bufferOs.toByteArray(); - bufferOs = null; - return ret; - } + public byte[] stopBuffer() { + if (bufferOs == null) { + return new byte[0]; + } + byte ret[] = bufferOs.toByteArray(); + bufferOs = null; + return ret; + } - public ABCInputStream(InputStream is) { - this.is = is; - } + public ABCInputStream(InputStream is) { + this.is = is; + } - @Override - public int read() throws IOException { - bytesRead++; - int i = is.read(); - if (DEBUG_READ) { - System.out.println("Read:0x" + Integer.toHexString(i)); - } - if (bufferOs != null) { - if (i != -1) { - bufferOs.write(i); - } - } - return i; - } + @Override + public int read() throws IOException { + bytesRead++; + int i = is.read(); + if (DEBUG_READ) { + System.out.println("Read:0x" + Integer.toHexString(i)); + } + if (bufferOs != null) { + if (i != -1) { + bufferOs.write(i); + } + } + return i; + } - @Override - public int read(byte[] b) throws IOException { - int currBytesRead = is.read(b); - bytesRead += currBytesRead; - if (DEBUG_READ) { - StringBuilder sb = new StringBuilder("Read["); - sb.append(currBytesRead); - sb.append('/'); - sb.append(b.length); - sb.append("]: "); - for (int jj = 0; jj < currBytesRead; jj++) { - sb.append("0x"); - sb.append(Integer.toHexString(b[jj])); - sb.append(' '); - } - System.out.println(sb.toString()); - } - if (bufferOs != null) { - if (currBytesRead > 0) { - bufferOs.write(b, 0, currBytesRead); - } - } - return currBytesRead; - } + @Override + public int read(byte[] b) throws IOException { + int currBytesRead = is.read(b); + bytesRead += currBytesRead; + if (DEBUG_READ) { + StringBuilder sb = new StringBuilder("Read["); + sb.append(currBytesRead); + sb.append('/'); + sb.append(b.length); + sb.append("]: "); + for (int jj = 0; jj < currBytesRead; jj++) { + sb.append("0x"); + sb.append(Integer.toHexString(b[jj])); + sb.append(' '); + } + System.out.println(sb.toString()); + } + if (bufferOs != null) { + if (currBytesRead > 0) { + bufferOs.write(b, 0, currBytesRead); + } + } + return currBytesRead; + } - ; + ; public int readU8() throws IOException { - return read(); - } + return read(); + } - public int readU32() throws IOException { - int i; - int ret = 0; - int bytePos = 0; - int byteCount = 0; - boolean nextByte; - do { - i = read(); - nextByte = (i >> 7) == 1; - i = i & 0x7f; - ret = ret + (i << bytePos); - byteCount++; - bytePos += 7; - } while (nextByte); - return ret; - } + public int readU32() throws IOException { + int i; + int ret = 0; + int bytePos = 0; + int byteCount = 0; + boolean nextByte; + do { + i = read(); + nextByte = (i >> 7) == 1; + i = i & 0x7f; + ret = ret + (i << bytePos); + byteCount++; + bytePos += 7; + } while (nextByte); + return ret; + } - public int readU30() throws IOException { - return readU32(); - } + public int readU30() throws IOException { + return readU32(); + } - public int readS24() throws IOException { - int ret = (read()) + (read() << 8) + (read() << 16); + public int readS24() throws IOException { + int ret = (read()) + (read() << 8) + (read() << 16); - if ((ret >> 23) == 1) { - ret = ret | 0xff000000; - } + if ((ret >> 23) == 1) { + ret = ret | 0xff000000; + } - return ret; - } + return ret; + } - public int readU16() throws IOException { - return (read()) + (read() << 8); - } + public int readU16() throws IOException { + return (read()) + (read() << 8); + } - public long readS32() throws IOException { - int i; - long ret = 0; - int bytePos = 0; - int byteCount = 0; - boolean nextByte; - do { - i = read(); - nextByte = (i >> 7) == 1; - i = i & 0x7f; - ret = ret + (i << bytePos); - byteCount++; - bytePos += 7; - if (bytePos == 35) { - if ((ret >> 31) == 1) { - ret = -(ret & 0x7fffffff); + public long readS32() throws IOException { + int i; + long ret = 0; + int bytePos = 0; + int byteCount = 0; + boolean nextByte; + do { + i = read(); + nextByte = (i >> 7) == 1; + i = i & 0x7f; + ret = ret + (i << bytePos); + byteCount++; + bytePos += 7; + if (bytePos == 35) { + if ((ret >> 31) == 1) { + ret = -(ret & 0x7fffffff); + } + break; } - break; - } - } while (nextByte); - return ret; - } + } while (nextByte); + return ret; + } - @Override - public int available() throws IOException { - return is.available(); - } + @Override + public int available() throws IOException { + return is.available(); + } - public final long readLong() throws IOException { - byte readBuffer[] = safeRead(8); - return (((long) readBuffer[7] << 56) - + ((long) (readBuffer[6] & 255) << 48) - + ((long) (readBuffer[5] & 255) << 40) - + ((long) (readBuffer[4] & 255) << 32) - + ((long) (readBuffer[3] & 255) << 24) - + ((readBuffer[2] & 255) << 16) - + ((readBuffer[1] & 255) << 8) - + ((readBuffer[0] & 255))); - } + public final long readLong() throws IOException { + byte readBuffer[] = safeRead(8); + return (((long) readBuffer[7] << 56) + + ((long) (readBuffer[6] & 255) << 48) + + ((long) (readBuffer[5] & 255) << 40) + + ((long) (readBuffer[4] & 255) << 32) + + ((long) (readBuffer[3] & 255) << 24) + + ((readBuffer[2] & 255) << 16) + + ((readBuffer[1] & 255) << 8) + + ((readBuffer[0] & 255))); + } - public double readDouble() throws IOException { - long el = readLong(); - double ret = Double.longBitsToDouble(el); - return ret; - } + public double readDouble() throws IOException { + long el = readLong(); + double ret = Double.longBitsToDouble(el); + return ret; + } - private byte[] safeRead(int count) throws IOException { - byte ret[] = new byte[count]; - for (int i = 0; i < count; i++) { - ret[i] = (byte) read(); - } - return ret; - } + private byte[] safeRead(int count) throws IOException { + byte ret[] = new byte[count]; + for (int i = 0; i < count; i++) { + ret[i] = (byte) read(); + } + return ret; + } - public Namespace readNamespace() throws IOException { - int kind = read(); - int name_index = 0; - for (int k = 0; k < Namespace.nameSpaceKinds.length; k++) { - if (Namespace.nameSpaceKinds[k] == kind) { + public Namespace readNamespace() throws IOException { + int kind = read(); + int name_index = 0; + for (int k = 0; k < Namespace.nameSpaceKinds.length; k++) { + if (Namespace.nameSpaceKinds[k] == kind) { + name_index = readU30(); + break; + } + } + return new Namespace(kind, name_index); + } + + public Multiname readMultiname() throws IOException { + int kind = readU8(); + int namespace_index = -1; + int name_index = -1; + int namespace_set_index = -1; + int qname_index = -1; + List params = new ArrayList(); + + if ((kind == 7) || (kind == 0xd)) { // CONSTANT_QName and CONSTANT_QNameA. + namespace_index = readU30(); name_index = readU30(); - break; - } - } - return new Namespace(kind, name_index); - } - - public Multiname readMultiname() throws IOException { - int kind = readU8(); - int namespace_index = -1; - int name_index = -1; - int namespace_set_index = -1; - int qname_index = -1; - List params = new ArrayList(); - - if ((kind == 7) || (kind == 0xd)) { // CONSTANT_QName and CONSTANT_QNameA. - namespace_index = readU30(); - name_index = readU30(); - } else if ((kind == 0xf) || (kind == 0x10)) { //CONSTANT_RTQName and CONSTANT_RTQNameA - name_index = readU30(); - } else if ((kind == 0x11) || (kind == 0x12))//kind==0x11,0x12 nothing CONSTANT_RTQNameL and CONSTANT_RTQNameLA. - { - } else if ((kind == 9) || (kind == 0xe)) { // CONSTANT_Multiname and CONSTANT_MultinameA. - name_index = readU30(); - namespace_set_index = readU30(); - } else if ((kind == 0x1B) || (kind == 0x1C)) { //CONSTANT_MultinameL and CONSTANT_MultinameLA - namespace_set_index = readU30(); - } else if (kind == 0x1D) { - //Constant_TypeName - qname_index = readU30(); //Multiname index!!! - int paramsLength = readU30(); - for (int i = 0; i < paramsLength; i++) { - params.add(readU30()); //multiname indices! - } - } else { - System.err.println("Unknown kind of Multiname:0x" + Integer.toHexString(kind)); - System.exit(1); - } - - return new Multiname(kind, name_index, namespace_index, namespace_set_index, qname_index, params); - } - - public MethodInfo readMethodInfo() throws IOException { - int param_count = readU30(); - int ret_type = readU30(); - int param_types[] = new int[param_count]; - for (int i = 0; i < param_count; i++) { - param_types[i] = readU30(); - } - int name_index = readU30(); - int flags = read(); - - //// 1=need_arguments, 2=need_activation, 4=need_rest 8=has_optional (16=ignore_rest, 32=explicit,) 64=setsdxns, 128=has_paramnames - - ValueKind optional[] = new ValueKind[0]; - if ((flags & 8) == 8) { //if has_optional - int optional_count = readU30(); - optional = new ValueKind[optional_count]; - for (int i = 0; i < optional_count; i++) { - optional[i] = new ValueKind(readU30(), read()); - } - } - - int param_names[] = new int[param_count]; - if ((flags & 128) == 128) { //if has_paramnames - for (int i = 0; i < param_count; i++) { - param_names[i] = readU30(); - } - } - return new MethodInfo(param_types, ret_type, name_index, flags, optional, param_names); - } - - public Trait readTrait() throws IOException { - long pos = getPosition(); - startBuffer(); - int name_index = readU30(); - int kind = read(); - int kindType = 0xf & kind; - int kindFlags = kind >> 4; - Trait trait; - - switch (kindType) { - case 0: //slot - case 6: //const - TraitSlotConst t1 = new TraitSlotConst(); - t1.slot_id = readU30(); - t1.type_index = readU30(); - t1.value_index = readU30(); - if (t1.value_index != 0) { - t1.value_kind = read(); + } else if ((kind == 0xf) || (kind == 0x10)) { //CONSTANT_RTQName and CONSTANT_RTQNameA + name_index = readU30(); + } else if ((kind == 0x11) || (kind == 0x12))//kind==0x11,0x12 nothing CONSTANT_RTQNameL and CONSTANT_RTQNameLA. + { + } else if ((kind == 9) || (kind == 0xe)) { // CONSTANT_Multiname and CONSTANT_MultinameA. + name_index = readU30(); + namespace_set_index = readU30(); + } else if ((kind == 0x1B) || (kind == 0x1C)) { //CONSTANT_MultinameL and CONSTANT_MultinameLA + namespace_set_index = readU30(); + } else if (kind == 0x1D) { + //Constant_TypeName + qname_index = readU30(); //Multiname index!!! + int paramsLength = readU30(); + for (int i = 0; i < paramsLength; i++) { + params.add(readU30()); //multiname indices! } - trait = t1; - break; - case 1: //method - case 2: //getter - case 3: //setter - TraitMethodGetterSetter t2 = new TraitMethodGetterSetter(); - t2.disp_id = readU30(); - t2.method_info = readU30(); - trait = t2; - break; - case 4: //class - TraitClass t3 = new TraitClass(); - t3.slot_id = readU30(); - t3.class_info = readU30(); - trait = t3; - break; - case 5: //function - TraitFunction t4 = new TraitFunction(); - t4.slot_index = readU30(); - t4.method_info = readU30(); - trait = t4; - break; - default: - throw new IOException("Unknown trait kind:" + kind); - } - trait.fileOffset = pos; - trait.kindType = kindType; - trait.kindFlags = kindFlags; - trait.name_index = name_index; - if ((kindFlags & ATTR_METADATA) != 0) { - int metadata_count = readU30(); - trait.metadata = new int[metadata_count]; - for (int i = 0; i < metadata_count; i++) { - trait.metadata[i] = readU30(); - } - } - trait.bytes = stopBuffer(); - return trait; - } + } else { + System.err.println("Unknown kind of Multiname:0x" + Integer.toHexString(kind)); + System.exit(1); + } - public Traits readTraits() throws IOException { - int count = readU30(); - Traits traits = new Traits(); - traits.traits = new Trait[count]; - for (int i = 0; i < count; i++) { - traits.traits[i] = readTrait(); - } - return traits; - } + return new Multiname(kind, name_index, namespace_index, namespace_set_index, qname_index, params); + } - public byte[] readBytes(int count) throws IOException { - byte ret[] = new byte[count]; - for (int i = 0; i < count; i++) { - ret[i] = (byte) read(); - } - return ret; - } + public MethodInfo readMethodInfo() throws IOException { + int param_count = readU30(); + int ret_type = readU30(); + int param_types[] = new int[param_count]; + for (int i = 0; i < param_count; i++) { + param_types[i] = readU30(); + } + int name_index = readU30(); + int flags = read(); - public Decimal readDecimal() throws IOException { - byte data[] = readBytes(16); - return new Decimal(data); - } + //// 1=need_arguments, 2=need_activation, 4=need_rest 8=has_optional (16=ignore_rest, 32=explicit,) 64=setsdxns, 128=has_paramnames - public InstanceInfo readInstanceInfo() throws IOException { - InstanceInfo ret = new InstanceInfo(); - ret.name_index = readU30(); - ret.super_index = readU30(); - ret.flags = read(); - if ((ret.flags & CLASS_PROTECTED_NS) != 0) { - ret.protectedNS = readU30(); - } - int interfaces_count = readU30(); - ret.interfaces = new int[interfaces_count]; - for (int i = 0; i < interfaces_count; i++) { - ret.interfaces[i] = readU30(); - } - ret.iinit_index = readU30(); - ret.instance_traits = readTraits(); - return ret; - } + ValueKind optional[] = new ValueKind[0]; + if ((flags & 8) == 8) { //if has_optional + int optional_count = readU30(); + optional = new ValueKind[optional_count]; + for (int i = 0; i < optional_count; i++) { + optional[i] = new ValueKind(readU30(), read()); + } + } - public String readString() throws IOException { - int length = readU30(); - return new String(safeRead(length), "utf8"); - } + int param_names[] = new int[param_count]; + if ((flags & 128) == 128) { //if has_paramnames + for (int i = 0; i < param_count; i++) { + param_names[i] = readU30(); + } + } + return new MethodInfo(param_types, ret_type, name_index, flags, optional, param_names); + } + + public Trait readTrait() throws IOException { + long pos = getPosition(); + startBuffer(); + int name_index = readU30(); + int kind = read(); + int kindType = 0xf & kind; + int kindFlags = kind >> 4; + Trait trait; + + switch (kindType) { + case 0: //slot + case 6: //const + TraitSlotConst t1 = new TraitSlotConst(); + t1.slot_id = readU30(); + t1.type_index = readU30(); + t1.value_index = readU30(); + if (t1.value_index != 0) { + t1.value_kind = read(); + } + trait = t1; + break; + case 1: //method + case 2: //getter + case 3: //setter + TraitMethodGetterSetter t2 = new TraitMethodGetterSetter(); + t2.disp_id = readU30(); + t2.method_info = readU30(); + trait = t2; + break; + case 4: //class + TraitClass t3 = new TraitClass(); + t3.slot_id = readU30(); + t3.class_info = readU30(); + trait = t3; + break; + case 5: //function + TraitFunction t4 = new TraitFunction(); + t4.slot_index = readU30(); + t4.method_info = readU30(); + trait = t4; + break; + default: + throw new IOException("Unknown trait kind:" + kind); + } + trait.fileOffset = pos; + trait.kindType = kindType; + trait.kindFlags = kindFlags; + trait.name_index = name_index; + if ((kindFlags & ATTR_METADATA) != 0) { + int metadata_count = readU30(); + trait.metadata = new int[metadata_count]; + for (int i = 0; i < metadata_count; i++) { + trait.metadata[i] = readU30(); + } + } + trait.bytes = stopBuffer(); + return trait; + } + + public Traits readTraits() throws IOException { + int count = readU30(); + Traits traits = new Traits(); + traits.traits = new Trait[count]; + for (int i = 0; i < count; i++) { + traits.traits[i] = readTrait(); + } + return traits; + } + + public byte[] readBytes(int count) throws IOException { + byte ret[] = new byte[count]; + for (int i = 0; i < count; i++) { + ret[i] = (byte) read(); + } + return ret; + } + + public Decimal readDecimal() throws IOException { + byte data[] = readBytes(16); + return new Decimal(data); + } + + public InstanceInfo readInstanceInfo() throws IOException { + InstanceInfo ret = new InstanceInfo(); + ret.name_index = readU30(); + ret.super_index = readU30(); + ret.flags = read(); + if ((ret.flags & CLASS_PROTECTED_NS) != 0) { + ret.protectedNS = readU30(); + } + int interfaces_count = readU30(); + ret.interfaces = new int[interfaces_count]; + for (int i = 0; i < interfaces_count; i++) { + ret.interfaces[i] = readU30(); + } + ret.iinit_index = readU30(); + ret.instance_traits = readTraits(); + return ret; + } + + public String readString() throws IOException { + int length = readU30(); + byte b[] = safeRead(length); + String r = new String(b, "UTF-8"); + return r; + } - /*public void markStart(){ - bytesRead=0; - }*/ - public long getPosition() { - return bytesRead; - } + /*public void markStart(){ + bytesRead=0; + }*/ + public long getPosition() { + return bytesRead; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/ABCOutputStream.java b/trunk/src/com/jpexs/decompiler/flash/abc/ABCOutputStream.java index c0c46c160..dbbfc7b1e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/ABCOutputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/ABCOutputStream.java @@ -23,249 +23,249 @@ import java.io.OutputStream; public class ABCOutputStream extends OutputStream { - private OutputStream os; + private OutputStream os; - public ABCOutputStream(OutputStream os) { - this.os = os; - } + public ABCOutputStream(OutputStream os) { + this.os = os; + } - @Override - public void write(int b) throws IOException { - os.write(b); - } + @Override + public void write(int b) throws IOException { + os.write(b); + } - public void writeU30(long value) throws IOException { - writeS32(value); - /*boolean loop = true; - boolean underZero=value<0; + public void writeU30(long value) throws IOException { + writeS32(value); + /*boolean loop = true; + boolean underZero=value<0; - if(underZero){ - value = value & 0xFFFFFFFF; - }else{ - value = value & 0x7FFFFFFF; - } - do { - int ret = (int) (value & 0x7F); - if (value < 0x80) { - loop = false; - } - if (value > 0x7F) { - ret += 0x80; - } - write(ret); - value = value >> 7; - } while (loop); - */ - } - - public void writeU32(long value) throws IOException { - boolean loop = true; - value = value & 0xFFFFFFFF; - do { + if(underZero){ + value = value & 0xFFFFFFFF; + }else{ + value = value & 0x7FFFFFFF; + } + do { int ret = (int) (value & 0x7F); if (value < 0x80) { - loop = false; + loop = false; } if (value > 0x7F) { - ret += 0x80; + ret += 0x80; } write(ret); value = value >> 7; - } while (loop); - } + } while (loop); + */ + } - public void writeS24(long value) throws IOException { - int ret = (int) (value & 0xff); - write(ret); - value = value >> 8; - ret = (int) (value & 0xff); - write(ret); - value = value >> 8; - ret = (int) (value & 0xff); - write(ret); - } - - public void writeS32(long value) throws IOException { - boolean belowZero = value < 0; - /*if (belowZero) { - value = -value; - }*/ - int bitcount = 0; - boolean loop = true; - //value = value & 0xFFFFFFFF; - do { - bitcount += 7; - int ret = (int) (value & 0x7F); - if (value < 0x80) { - if (belowZero) { //&& bitcount < 35 - ret += 0x80; - } else { - loop = false; + public void writeU32(long value) throws IOException { + boolean loop = true; + value = value & 0xFFFFFFFF; + do { + int ret = (int) (value & 0x7F); + if (value < 0x80) { + loop = false; } - } else { - ret += 0x80; - } + if (value > 0x7F) { + ret += 0x80; + } + write(ret); + value = value >> 7; + } while (loop); + } - if (bitcount == 35) { - ret = ret & 0xf; - } - write(ret); - if (bitcount == 35) { - break; - } - value = value >> 7; - } while (loop); - } + public void writeS24(long value) throws IOException { + int ret = (int) (value & 0xff); + write(ret); + value = value >> 8; + ret = (int) (value & 0xff); + write(ret); + value = value >> 8; + ret = (int) (value & 0xff); + write(ret); + } - public void writeLong(long value) throws IOException { - byte writeBuffer[] = new byte[8]; - writeBuffer[7] = (byte) (value >>> 56); - writeBuffer[6] = (byte) (value >>> 48); - writeBuffer[5] = (byte) (value >>> 40); - writeBuffer[4] = (byte) (value >>> 32); - writeBuffer[3] = (byte) (value >>> 24); - writeBuffer[2] = (byte) (value >>> 16); - writeBuffer[1] = (byte) (value >>> 8); - writeBuffer[0] = (byte) (value); - write(writeBuffer); - } + public void writeS32(long value) throws IOException { + boolean belowZero = value < 0; + /*if (belowZero) { + value = -value; + }*/ + int bitcount = 0; + boolean loop = true; + //value = value & 0xFFFFFFFF; + do { + bitcount += 7; + int ret = (int) (value & 0x7F); + if (value < 0x80) { + if (belowZero) { //&& bitcount < 35 + ret += 0x80; + } else { + loop = false; + } + } else { + ret += 0x80; + } - public void writeDouble(double value) throws IOException { - writeLong(Double.doubleToLongBits(value)); - } + if (bitcount == 35) { + ret = ret & 0xf; + } + write(ret); + if (bitcount == 35) { + break; + } + value = value >> 7; + } while (loop); + } - public void writeU8(int value) throws IOException { - write(value); - } + public void writeLong(long value) throws IOException { + byte writeBuffer[] = new byte[8]; + writeBuffer[7] = (byte) (value >>> 56); + writeBuffer[6] = (byte) (value >>> 48); + writeBuffer[5] = (byte) (value >>> 40); + writeBuffer[4] = (byte) (value >>> 32); + writeBuffer[3] = (byte) (value >>> 24); + writeBuffer[2] = (byte) (value >>> 16); + writeBuffer[1] = (byte) (value >>> 8); + writeBuffer[0] = (byte) (value); + write(writeBuffer); + } - public void writeU16(int value) throws IOException { - write(value & 0xff); - write((value >> 8) & 0xff); - } + public void writeDouble(double value) throws IOException { + writeLong(Double.doubleToLongBits(value)); + } - public void writeString(String s) throws IOException { - byte sbytes[] = s.getBytes("utf8"); - writeU30(sbytes.length); - write(sbytes); - } + public void writeU8(int value) throws IOException { + write(value); + } - public void writeNamespace(Namespace ns) throws IOException { - write(ns.kind); - for (int k = 0; k < Namespace.nameSpaceKinds.length; k++) { - if (Namespace.nameSpaceKinds[k] == ns.kind) { - writeU30(ns.name_index); - break; - } - } - } + public void writeU16(int value) throws IOException { + write(value & 0xff); + write((value >> 8) & 0xff); + } - public void writeMultiname(Multiname m) throws IOException { - writeU8(m.kind); - if ((m.kind == 7) || (m.kind == 0xd)) { // CONSTANT_QName and CONSTANT_QNameA. - writeU30(m.namespace_index); - writeU30(m.name_index); - } - if ((m.kind == 9) || (m.kind == 0xe)) { // CONSTANT_Multiname and CONSTANT_MultinameA. - writeU30(m.name_index); - writeU30(m.namespace_set_index); - } - if ((m.kind == 0xf) || (m.kind == 0x10)) { //CONSTANT_RTQName and CONSTANT_RTQNameA - writeU30(m.name_index); - } - if ((m.kind == 0x1B) || (m.kind == 0x1C)) { //CONSTANT_MultinameL and CONSTANT_MultinameLA - writeU30(m.namespace_set_index); - } - if (m.kind == 0x1D) { - writeU30(m.qname_index); - writeU30(m.params.size()); - for (int i = 0; i < m.params.size(); i++) { - writeU30(m.params.get(i)); - } - } - //kind==0x11,0x12 nothing CONSTANT_RTQNameL and CONSTANT_RTQNameLA. - } + public void writeString(String s) throws IOException { + byte sbytes[] = s.getBytes("UTF-8"); + writeU30(sbytes.length); + write(sbytes); + } - public void writeMethodInfo(MethodInfo mi) throws IOException { - writeU30(mi.param_types.length); - writeU30(mi.ret_type); - for (int i = 0; i < mi.param_types.length; i++) { - writeU30(mi.param_types[i]); - } - writeU30(mi.name_index); - write(mi.flags); - if ((mi.flags & 8) == 8) { - writeU30(mi.optional.length); - for (int i = 0; i < mi.optional.length; i++) { - writeU30(mi.optional[i].value_index); - write(mi.optional[i].value_kind); - } - } + public void writeNamespace(Namespace ns) throws IOException { + write(ns.kind); + for (int k = 0; k < Namespace.nameSpaceKinds.length; k++) { + if (Namespace.nameSpaceKinds[k] == ns.kind) { + writeU30(ns.name_index); + break; + } + } + } - if ((mi.flags & 128) == 128) { //if has_paramnames - for (int i = 0; i < mi.paramNames.length; i++) { - writeU30(mi.paramNames[i]); - } - } - } + public void writeMultiname(Multiname m) throws IOException { + writeU8(m.kind); + if ((m.kind == 7) || (m.kind == 0xd)) { // CONSTANT_QName and CONSTANT_QNameA. + writeU30(m.namespace_index); + writeU30(m.name_index); + } + if ((m.kind == 9) || (m.kind == 0xe)) { // CONSTANT_Multiname and CONSTANT_MultinameA. + writeU30(m.name_index); + writeU30(m.namespace_set_index); + } + if ((m.kind == 0xf) || (m.kind == 0x10)) { //CONSTANT_RTQName and CONSTANT_RTQNameA + writeU30(m.name_index); + } + if ((m.kind == 0x1B) || (m.kind == 0x1C)) { //CONSTANT_MultinameL and CONSTANT_MultinameLA + writeU30(m.namespace_set_index); + } + if (m.kind == 0x1D) { + writeU30(m.qname_index); + writeU30(m.params.size()); + for (int i = 0; i < m.params.size(); i++) { + writeU30(m.params.get(i)); + } + } + //kind==0x11,0x12 nothing CONSTANT_RTQNameL and CONSTANT_RTQNameLA. + } - public void writeTrait(Trait t) throws IOException { - writeU30(t.name_index); - write((t.kindFlags << 4) + t.kindType); - if (t instanceof TraitSlotConst) { - TraitSlotConst t1 = (TraitSlotConst) t; - writeU30(t1.slot_id); - writeU30(t1.type_index); - writeU30(t1.value_index); - if (t1.value_index != 0) { - write(t1.value_kind); - } - } - if (t instanceof TraitMethodGetterSetter) { - TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t; - writeU30(t2.disp_id); - writeU30(t2.method_info); - } - if (t instanceof TraitClass) { - TraitClass t3 = (TraitClass) t; - writeU30(t3.slot_id); - writeU30(t3.class_info); - } - if (t instanceof TraitFunction) { - TraitFunction t4 = (TraitFunction) t; - writeU30(t4.slot_index); - writeU30(t4.method_info); - } - if ((t.kindFlags & 4) == 4) { - writeU30(t.metadata.length); - for (int i = 0; i < t.metadata.length; i++) { - writeU30(t.metadata[i]); - } - } - } + public void writeMethodInfo(MethodInfo mi) throws IOException { + writeU30(mi.param_types.length); + writeU30(mi.ret_type); + for (int i = 0; i < mi.param_types.length; i++) { + writeU30(mi.param_types[i]); + } + writeU30(mi.name_index); + write(mi.flags); + if ((mi.flags & 8) == 8) { + writeU30(mi.optional.length); + for (int i = 0; i < mi.optional.length; i++) { + writeU30(mi.optional[i].value_index); + write(mi.optional[i].value_kind); + } + } - public void writeTraits(Traits t) throws IOException { - writeU30(t.traits.length); - for (int i = 0; i < t.traits.length; i++) { - writeTrait(t.traits[i]); - } - } + if ((mi.flags & 128) == 128) { //if has_paramnames + for (int i = 0; i < mi.paramNames.length; i++) { + writeU30(mi.paramNames[i]); + } + } + } - public void writeInstanceInfo(InstanceInfo ii) throws IOException { - writeU30(ii.name_index); - writeU30(ii.super_index); - write(ii.flags); - if ((ii.flags & 8) == 8) { - writeU30(ii.protectedNS); - } - writeU30(ii.interfaces.length); - for (int i = 0; i < ii.interfaces.length; i++) { - writeU30(ii.interfaces[i]); - } - writeU30(ii.iinit_index); - writeTraits(ii.instance_traits); - } + public void writeTrait(Trait t) throws IOException { + writeU30(t.name_index); + write((t.kindFlags << 4) + t.kindType); + if (t instanceof TraitSlotConst) { + TraitSlotConst t1 = (TraitSlotConst) t; + writeU30(t1.slot_id); + writeU30(t1.type_index); + writeU30(t1.value_index); + if (t1.value_index != 0) { + write(t1.value_kind); + } + } + if (t instanceof TraitMethodGetterSetter) { + TraitMethodGetterSetter t2 = (TraitMethodGetterSetter) t; + writeU30(t2.disp_id); + writeU30(t2.method_info); + } + if (t instanceof TraitClass) { + TraitClass t3 = (TraitClass) t; + writeU30(t3.slot_id); + writeU30(t3.class_info); + } + if (t instanceof TraitFunction) { + TraitFunction t4 = (TraitFunction) t; + writeU30(t4.slot_index); + writeU30(t4.method_info); + } + if ((t.kindFlags & 4) == 4) { + writeU30(t.metadata.length); + for (int i = 0; i < t.metadata.length; i++) { + writeU30(t.metadata[i]); + } + } + } - public void writeDecimal(Decimal value) throws IOException { - write(value.data); - } + public void writeTraits(Traits t) throws IOException { + writeU30(t.traits.length); + for (int i = 0; i < t.traits.length; i++) { + writeTrait(t.traits[i]); + } + } + + public void writeInstanceInfo(InstanceInfo ii) throws IOException { + writeU30(ii.name_index); + writeU30(ii.super_index); + write(ii.flags); + if ((ii.flags & 8) == 8) { + writeU30(ii.protectedNS); + } + writeU30(ii.interfaces.length); + for (int i = 0; i < ii.interfaces.length; i++) { + writeU30(ii.interfaces[i]); + } + writeU30(ii.iinit_index); + writeTraits(ii.instance_traits); + } + + public void writeDecimal(Decimal value) throws IOException { + write(value.data); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/CopyOutputStream.java b/trunk/src/com/jpexs/decompiler/flash/abc/CopyOutputStream.java index 458853a52..6827d0c90 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/CopyOutputStream.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/CopyOutputStream.java @@ -22,52 +22,52 @@ import java.io.OutputStream; public class CopyOutputStream extends OutputStream { - private OutputStream os; - private InputStream is; - private long pos = 0; - private int TEMPSIZE = 5; - private int temp[] = new int[TEMPSIZE]; - private int tempPos = 0; - public int ignoreFirst = 0; + private OutputStream os; + private InputStream is; + private long pos = 0; + private int TEMPSIZE = 5; + private int temp[] = new int[TEMPSIZE]; + private int tempPos = 0; + public int ignoreFirst = 0; - public CopyOutputStream(OutputStream os, InputStream is) { - this.os = os; - this.is = is; - } + public CopyOutputStream(OutputStream os, InputStream is) { + this.os = os; + this.is = is; + } - @Override - public void write(int b) throws IOException { - temp[tempPos] = b; - tempPos = (tempPos + 1) % TEMPSIZE; + @Override + public void write(int b) throws IOException { + temp[tempPos] = b; + tempPos = (tempPos + 1) % TEMPSIZE; - pos++; - int r = is.read(); - if ((b & 0xff) != r) { - if (ignoreFirst <= 0) { - os.flush(); + pos++; + int r = is.read(); + if ((b & 0xff) != r) { + if (ignoreFirst <= 0) { + os.flush(); - boolean output = true; + boolean output = true; - if (output) { - System.out.println("Position: " + pos); - System.out.print("Last written:"); - for (int i = 0; i < TEMPSIZE; i++) { - System.out.print("" + Integer.toHexString(temp[(tempPos + i) % TEMPSIZE]) + " "); - } - System.out.println(""); - System.out.println("More expected:"); - for (int i = 0; i < TEMPSIZE; i++) { - System.out.println("" + Integer.toHexString(is.read())); - } + if (output) { + System.out.println("Position: " + pos); + System.out.print("Last written:"); + for (int i = 0; i < TEMPSIZE; i++) { + System.out.print("" + Integer.toHexString(temp[(tempPos + i) % TEMPSIZE]) + " "); + } + System.out.println(""); + System.out.println("More expected:"); + for (int i = 0; i < TEMPSIZE; i++) { + System.out.println("" + Integer.toHexString(is.read())); + } - System.out.println(""); - System.out.println(Integer.toHexString(r) + " expected but " + Integer.toHexString(b) + " found"); + System.out.println(""); + System.out.println(Integer.toHexString(r) + " expected but " + Integer.toHexString(b) + " found"); + } + throw new NotSameException(pos); + } else { + ignoreFirst--; } - throw new NotSameException(pos); - } else { - ignoreFirst--; - } - } - os.write(b); - } + } + os.write(b); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/NotSameException.java b/trunk/src/com/jpexs/decompiler/flash/abc/NotSameException.java index 919413780..d4243e92e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/NotSameException.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/NotSameException.java @@ -20,7 +20,7 @@ import com.jpexs.decompiler.flash.helpers.Helper; public class NotSameException extends RuntimeException { - public NotSameException(long pos) { - super("Streams are not the same at pos " + Helper.formatHex((int) pos, 8)); - } + public NotSameException(long pos) { + super("Streams are not the same at pos " + Helper.formatHex((int) pos, 8)); + } } 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 f02ad6187..b097900f5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -62,2422 +62,2422 @@ import java.util.logging.Logger; public class AVM2Code implements Serializable { - private static final boolean DEBUG_MODE = false; - public static int toSourceLimit = -1; - public ArrayList code = new ArrayList(); - public static boolean DEBUG_REWRITE = false; - public static final int OPT_U30 = 0x100; - public static final int OPT_U8 = 0x200; - public static final int OPT_S24 = 0x300; - public static final int OPT_CASE_OFFSETS = 0x400; - public static final int OPT_BYTE = 0x500; - public static final int DAT_MULTINAME_INDEX = OPT_U30 + 0x01; - public static final int DAT_ARG_COUNT = OPT_U30 + 0x02; - public static final int DAT_METHOD_INDEX = OPT_U30 + 0x03; - public static final int DAT_STRING_INDEX = OPT_U30 + 0x04; - public static final int DAT_DEBUG_TYPE = OPT_U8 + 0x05; - public static final int DAT_REGISTER_INDEX = OPT_U8 + 0x06; - public static final int DAT_LINENUM = OPT_U30 + 0x07; - public static final int DAT_LOCAL_REG_INDEX = OPT_U30 + 0x08; - public static final int DAT_SLOT_INDEX = OPT_U30 + 0x09; - public static final int DAT_SLOT_SCOPE_INDEX = OPT_U30 + 0x0A; - public static final int DAT_OFFSET = OPT_S24 + 0x0B; - public static final int DAT_EXCEPTION_INDEX = OPT_U30 + 0x0C; - public static final int DAT_CLASS_INDEX = OPT_U30 + 0x0D; - public static final int DAT_INT_INDEX = OPT_U30 + 0x0E; - public static final int DAT_UINT_INDEX = OPT_U30 + 0x0F; - public static final int DAT_DOUBLE_INDEX = OPT_U30 + 0x10; - public static final int DAT_DECIMAL_INDEX = OPT_U30 + 0x11; - public static final int DAT_CASE_BASEOFFSET = OPT_S24 + 0x12; - public static InstructionDefinition instructionSet[] = new InstructionDefinition[]{ - new AddIns(), - new InstructionDefinition(0x9b, "add_d", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; //? - } - }, - new AddIIns(), - new InstructionDefinition(0xb5, "add_p", new int[]{AVM2Code.OPT_U30}), - new ApplyTypeIns(), - new AsTypeIns(), - new AsTypeLateIns(), - new BitAndIns(), - new BitNotIns(), - new BitOrIns(), - new BitXorIns(), - new InstructionDefinition(0x01, "bkpt", new int[]{}), - new InstructionDefinition(0xf2, "bkptline", new int[]{AVM2Code.OPT_U30}), - new CallIns(), - new InstructionDefinition(0x4d, "callinterface", new int[]{AVM2Code.OPT_U30}), - new CallMethodIns(), - new CallPropertyIns(), - new CallPropLexIns(), - new CallPropVoidIns(), - new CallStaticIns(), - new CallSuperIns(), - new InstructionDefinition(0x4b, "callsuperid", new int[]{}), - new CallSuperVoidIns(), - new CheckFilterIns(), - new CoerceIns(), - new CoerceAIns(), - new InstructionDefinition(0x81, "coerce_b", new int[]{}), //stack:-1+1 - new InstructionDefinition(0x84, "coerce_d", new int[]{}), //stack:-1+1 - new InstructionDefinition(0x83, "coerce_i", new int[]{}), //stack:-1+1 - new InstructionDefinition(0x89, "coerce_o", new int[]{}), //stack:-1+1 - new CoerceSIns(), - new InstructionDefinition(0x88, "coerce_u", new int[]{}), //stack:-1+1 - new InstructionDefinition(0x9a, "concat", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; //? - } - }, - new ConstructIns(), - new ConstructPropIns(), - new ConstructSuperIns(), - new ConvertBIns(), - new ConvertIIns(), - new ConvertDIns(), - new ConvertOIns(), - new ConvertUIns(), - new ConvertSIns(), - new InstructionDefinition(0x79, "convert_m", new int[]{}), //-1 +1 - new InstructionDefinition(0x7a, "convert_m_p", new int[]{AVM2Code.OPT_U30 /*param (?)*/}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - }, - new DebugIns(), - new DebugFileIns(), - new DebugLineIns(), - new DecLocalIns(), - new DecLocalIIns(), - new DecrementIns(), - new DecrementIIns(), - new InstructionDefinition(0x5b, "deldescendants", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - }, - new DeletePropertyIns(), - new InstructionDefinition(0x6b, "deletepropertylate", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - }, - new DivideIns(), - new InstructionDefinition(0xb8, "divide_p", new int[]{AVM2Code.OPT_U30}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; //? - } - }, - new DupIns(), - new DXNSIns(), - new DXNSLateIns(), - new EqualsIns(), - new EscXAttrIns(), - new EscXElemIns(), - new InstructionDefinition(0x5f, "finddef", new int[]{AVM2Code.DAT_MULTINAME_INDEX}), - /* //Duplicate OPCODE with deldescendants. Prefering deldescendants (found in FLEX compiler) - new InstructionDefinition(0x5b,"findpropglobalstrict",new int[]{AVM2Code.DAT_MULTINAME_INDEX}){ + private static final boolean DEBUG_MODE = false; + public static int toSourceLimit = -1; + public ArrayList code = new ArrayList(); + public static boolean DEBUG_REWRITE = false; + public static final int OPT_U30 = 0x100; + public static final int OPT_U8 = 0x200; + public static final int OPT_S24 = 0x300; + public static final int OPT_CASE_OFFSETS = 0x400; + public static final int OPT_BYTE = 0x500; + public static final int DAT_MULTINAME_INDEX = OPT_U30 + 0x01; + public static final int DAT_ARG_COUNT = OPT_U30 + 0x02; + public static final int DAT_METHOD_INDEX = OPT_U30 + 0x03; + public static final int DAT_STRING_INDEX = OPT_U30 + 0x04; + public static final int DAT_DEBUG_TYPE = OPT_U8 + 0x05; + public static final int DAT_REGISTER_INDEX = OPT_U8 + 0x06; + public static final int DAT_LINENUM = OPT_U30 + 0x07; + public static final int DAT_LOCAL_REG_INDEX = OPT_U30 + 0x08; + public static final int DAT_SLOT_INDEX = OPT_U30 + 0x09; + public static final int DAT_SLOT_SCOPE_INDEX = OPT_U30 + 0x0A; + public static final int DAT_OFFSET = OPT_S24 + 0x0B; + public static final int DAT_EXCEPTION_INDEX = OPT_U30 + 0x0C; + public static final int DAT_CLASS_INDEX = OPT_U30 + 0x0D; + public static final int DAT_INT_INDEX = OPT_U30 + 0x0E; + public static final int DAT_UINT_INDEX = OPT_U30 + 0x0F; + public static final int DAT_DOUBLE_INDEX = OPT_U30 + 0x10; + public static final int DAT_DECIMAL_INDEX = OPT_U30 + 0x11; + public static final int DAT_CASE_BASEOFFSET = OPT_S24 + 0x12; + public static InstructionDefinition instructionSet[] = new InstructionDefinition[]{ + new AddIns(), + new InstructionDefinition(0x9b, "add_d", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; //? + } + }, + new AddIIns(), + new InstructionDefinition(0xb5, "add_p", new int[]{AVM2Code.OPT_U30}), + new ApplyTypeIns(), + new AsTypeIns(), + new AsTypeLateIns(), + new BitAndIns(), + new BitNotIns(), + new BitOrIns(), + new BitXorIns(), + new InstructionDefinition(0x01, "bkpt", new int[]{}), + new InstructionDefinition(0xf2, "bkptline", new int[]{AVM2Code.OPT_U30}), + new CallIns(), + new InstructionDefinition(0x4d, "callinterface", new int[]{AVM2Code.OPT_U30}), + new CallMethodIns(), + new CallPropertyIns(), + new CallPropLexIns(), + new CallPropVoidIns(), + new CallStaticIns(), + new CallSuperIns(), + new InstructionDefinition(0x4b, "callsuperid", new int[]{}), + new CallSuperVoidIns(), + new CheckFilterIns(), + new CoerceIns(), + new CoerceAIns(), + new InstructionDefinition(0x81, "coerce_b", new int[]{}), //stack:-1+1 + new InstructionDefinition(0x84, "coerce_d", new int[]{}), //stack:-1+1 + new InstructionDefinition(0x83, "coerce_i", new int[]{}), //stack:-1+1 + new InstructionDefinition(0x89, "coerce_o", new int[]{}), //stack:-1+1 + new CoerceSIns(), + new InstructionDefinition(0x88, "coerce_u", new int[]{}), //stack:-1+1 + new InstructionDefinition(0x9a, "concat", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; //? + } + }, + new ConstructIns(), + new ConstructPropIns(), + new ConstructSuperIns(), + new ConvertBIns(), + new ConvertIIns(), + new ConvertDIns(), + new ConvertOIns(), + new ConvertUIns(), + new ConvertSIns(), + new InstructionDefinition(0x79, "convert_m", new int[]{}), //-1 +1 + new InstructionDefinition(0x7a, "convert_m_p", new int[]{AVM2Code.OPT_U30 /*param (?)*/}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new DebugIns(), + new DebugFileIns(), + new DebugLineIns(), + new DecLocalIns(), + new DecLocalIIns(), + new DecrementIns(), + new DecrementIIns(), + new InstructionDefinition(0x5b, "deldescendants", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new DeletePropertyIns(), + new InstructionDefinition(0x6b, "deletepropertylate", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new DivideIns(), + new InstructionDefinition(0xb8, "divide_p", new int[]{AVM2Code.OPT_U30}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; //? + } + }, + new DupIns(), + new DXNSIns(), + new DXNSLateIns(), + new EqualsIns(), + new EscXAttrIns(), + new EscXElemIns(), + new InstructionDefinition(0x5f, "finddef", new int[]{AVM2Code.DAT_MULTINAME_INDEX}), + /* //Duplicate OPCODE with deldescendants. Prefering deldescendants (found in FLEX compiler) + new InstructionDefinition(0x5b,"findpropglobalstrict",new int[]{AVM2Code.DAT_MULTINAME_INDEX}){ - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - },*/ - new InstructionDefinition(0x5c, "findpropglobal", new int[]{AVM2Code.DAT_MULTINAME_INDEX}) { @Override public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); + throw new UnsupportedOperationException(); } @Override public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - }, - new FindPropertyIns(), - new FindPropertyStrictIns(), - new GetDescendantsIns(), - new GetGlobalScopeIns(), - new GetGlobalSlotIns(), - new GetLexIns(), - new GetLocalIns(), - new GetLocal0Ins(), - new GetLocal1Ins(), - new GetLocal2Ins(), - new GetLocal3Ins(), - new InstructionDefinition(0x67, "getouterscope", new int[]{AVM2Code.DAT_MULTINAME_INDEX}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); + throw new UnsupportedOperationException(); } - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); + },*/ + new InstructionDefinition(0x5c, "findpropglobal", new int[]{AVM2Code.DAT_MULTINAME_INDEX}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new FindPropertyIns(), + new FindPropertyStrictIns(), + new GetDescendantsIns(), + new GetGlobalScopeIns(), + new GetGlobalSlotIns(), + new GetLexIns(), + new GetLocalIns(), + new GetLocal0Ins(), + new GetLocal1Ins(), + new GetLocal2Ins(), + new GetLocal3Ins(), + new InstructionDefinition(0x67, "getouterscope", new int[]{AVM2Code.DAT_MULTINAME_INDEX}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new GetPropertyIns(), + new GetScopeObjectIns(), + new GetSlotIns(), + new GetSuperIns(), + new GreaterEqualsIns(), + new GreaterThanIns(), + new HasNextIns(), + new HasNext2Ins(), + new IfEqIns(), + new IfFalseIns(), + new IfGeIns(), + new IfGtIns(), + new IfLeIns(), + new IfLtIns(), + new IfNGeIns(), + new IfNGtIns(), + new IfNLeIns(), + new IfNLtIns(), + new IfNeIns(), + new IfStrictEqIns(), + new IfStrictNeIns(), + new IfTrueIns(), + new InIns(), + new IncLocalIns(), + new IncLocalIIns(), + new IncrementIns(), + new IncrementIIns(), + new InstructionDefinition(0x9c, "increment_p", new int[]{AVM2Code.OPT_U30 /*param*/}), + new InstructionDefinition(0x9d, "inclocal_p", new int[]{AVM2Code.OPT_U30 /*param*/, AVM2Code.DAT_REGISTER_INDEX}), + new InstructionDefinition(0x9e, "decrement_p", new int[]{AVM2Code.OPT_U30 /*param*/}), + new InstructionDefinition(0x9f, "declocal_p", new int[]{AVM2Code.OPT_U30 /*param*/, AVM2Code.DAT_REGISTER_INDEX}), + new InitPropertyIns(), + new InstanceOfIns(), + new IsTypeIns(), + new IsTypeLateIns(), + new JumpIns(), + new KillIns(), + new LabelIns(), + new LessEqualsIns(), + new LessThanIns(), + new LookupSwitchIns(), + new LShiftIns(), + new ModuloIns(), + new InstructionDefinition(0xb9, "modulo_p", new int[]{AVM2Code.OPT_U30}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; //? + } + }, + new MultiplyIns(), + new MultiplyIIns(), + new InstructionDefinition(0xb7, "multiply_p", new int[]{AVM2Code.OPT_U30}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; //? + } + }, + new NegateIns(), + new NegateIIns(), + new InstructionDefinition(0x8f, "negate_p", new int[]{AVM2Code.OPT_U30 /* param */}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new NewActivationIns(), + new NewArrayIns(), + new NewCatchIns(), + new NewClassIns(), + new NewFunctionIns(), + new NewObjectIns(), + new NextNameIns(), + new NextValueIns(), + new NopIns(), + new NotIns(), + new PopIns(), + new PopScopeIns(), + new PushByteIns(), + new InstructionDefinition(0x22, "pushconstant", new int[]{AVM2Code.DAT_STRING_INDEX}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; //? + } + }, + new InstructionDefinition(0x33, "pushdecimal", new int[]{AVM2Code.DAT_DECIMAL_INDEX}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; //? + } + }, + new InstructionDefinition(0x34, "pushdnan", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; //? + } + }, + new PushDoubleIns(), + new PushFalseIns(), + new PushIntIns(), + new PushNamespaceIns(), + new PushNanIns(), + new PushNullIns(), + new PushScopeIns(), + new PushShortIns(), + new PushStringIns(), + new PushTrueIns(), + new PushUIntIns(), + new PushUndefinedIns(), + new PushWithIns(), + new ReturnValueIns(), + new ReturnVoidIns(), + new RShiftIns(), + new SetLocalIns(), + new SetLocal0Ins(), + new SetLocal1Ins(), + new SetLocal2Ins(), + new SetLocal3Ins(), + new SetGlobalSlotIns(), + new SetPropertyIns(), + new InstructionDefinition(0x69, "setpropertylate", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new SetSlotIns(), + new SetSuperIns(), + new StrictEqualsIns(), + new SubtractIns(), + new SubtractIIns(), + new InstructionDefinition(0xb6, "subtract_p", new int[]{AVM2Code.OPT_U30}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new SwapIns(), + new ThrowIns(), + new InstructionDefinition(0xf3, "timestamp", new int[]{}), + new TypeOfIns(), + new URShiftIns(), + new InstructionDefinition(0x35, "li8", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x36, "li16", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x37, "li32", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x38, "lf32", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x39, "lf64", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x3A, "si8", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x3B, "si16", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x3C, "si32", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x3D, "sf32", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x3E, "sf64", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x50, "sxi1", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x51, "sxi8", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + }, + new InstructionDefinition(0x52, "sxi16", new int[]{}) { + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + throw new UnsupportedOperationException(); + } + } + }; + //endoflist + public static InstructionDefinition instructionSetByCode[] = buildInstructionSetByCode(); + public boolean hideTemporaryRegisters = true; + + private static InstructionDefinition[] buildInstructionSetByCode() { + InstructionDefinition result[] = new InstructionDefinition[256]; + for (InstructionDefinition id : instructionSet) { + if (result[id.instructionCode] != null) { + System.out.println("Warning: Duplicate OPCODE for instruction " + result[id.instructionCode] + " " + id); + } + result[id.instructionCode] = id; + } + return result; + } + public static final String IDENTOPEN = "/*IDENTOPEN*/"; + public static final String IDENTCLOSE = "/*IDENTCLOSE*/"; + + public AVM2Code() { + } + + public Object execute(HashMap arguments, ConstantPool constants) { + int pos = 0; + LocalDataArea lda = new LocalDataArea(); + lda.localRegisters = arguments; + try { + while (true) { + AVM2Instruction ins = code.get(pos); + if (ins.definition instanceof JumpIns) { + pos = adr2pos((Long) ins.getParamsAsList(constants).get(0)); + continue; + } + if (ins.definition instanceof IfFalseIns) { + Boolean b = (Boolean) lda.operandStack.pop(); + if (b == false) { + pos = adr2pos((Long) ins.getParamsAsList(constants).get(0)); + } else { + pos++; + } + continue; + } + if (ins.definition instanceof IfTrueIns) { + Boolean b = (Boolean) lda.operandStack.pop(); + if (b == true) { + pos = adr2pos((Long) ins.getParamsAsList(constants).get(0)); + } else { + pos++; + } + continue; + } + if (ins.definition instanceof ReturnValueIns) { + return lda.operandStack.pop(); + } + if (ins.definition instanceof ReturnVoidIns) { + return null; + } + ins.definition.execute(lda, constants, ins.getParamsAsList(constants)); + pos++; + } + } catch (ConvertException e) { + } + return null; + } + + public AVM2Code(InputStream is) throws IOException { + ABCInputStream ais = new ABCInputStream(is); + while (ais.available() > 0) { + long startOffset = ais.getPosition(); + ais.startBuffer(); + int instructionCode = ais.read(); + InstructionDefinition instr = instructionSetByCode[instructionCode]; + if (instr != null) { + int actualOperands[]; + if (instructionCode == 0x1b) { //switch + int firstOperand = ais.readS24(); + int case_count = ais.readU30(); + actualOperands = new int[case_count + 3]; + actualOperands[0] = firstOperand; + actualOperands[1] = case_count; + for (int c = 0; c < case_count + 1; c++) { + actualOperands[2 + c] = ais.readS24(); + } + } else { + actualOperands = new int[instr.operands.length]; + for (int op = 0; op < instr.operands.length; op++) { + switch (instr.operands[op] & 0xff00) { + case OPT_U30: + actualOperands[op] = ais.readU30(); + break; + case OPT_U8: + actualOperands[op] = ais.read(); + break; + case OPT_BYTE: + actualOperands[op] = (byte) ais.read(); + break; + case OPT_S24: + actualOperands[op] = ais.readS24(); + break; + } + } + } + + code.add(new AVM2Instruction(startOffset, instr, actualOperands, ais.stopBuffer())); + } else { + throw new UnknownInstructionCode(instructionCode); + } + } + } + + public void compact() { + code.trimToSize(); + } + + public byte[] getBytes() { + return getBytes(null); + } + + public byte[] getBytes(byte origBytes[]) { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + + OutputStream cos; + if ((origBytes != null) && (DEBUG_REWRITE)) { + ByteArrayInputStream origis = new ByteArrayInputStream(origBytes); + cos = new CopyOutputStream(bos, origis); + } else { + cos = bos; + } + try { + for (AVM2Instruction instruction : code) { + cos.write(instruction.getBytes()); + } + } catch (IOException ex) { + } + return bos.toByteArray(); + } + + @Override + public String toString() { + String s = ""; + for (AVM2Instruction instruction : code) { + s += instruction.toString() + "\r\n"; + } + return s; + } + + public String toString(ConstantPool constants) { + String s = ""; + int i = 0; + for (AVM2Instruction instruction : code) { + s += Helper.formatAddress(i) + " " + instruction.toString(constants, new ArrayList()) + "\r\n"; + i++; + } + return s; + } + + private static String popStack(Stack stack) { + for (int i = stack.size() - 1; i >= 0; i--) { + String s = stack.get(i); + if (!s.startsWith("//")) { + stack.remove(i); + return s; + } + } + return null; + } + + public String toASMSource(ConstantPool constants, MethodBody body, boolean hex) { + return toASMSource(constants, body, new ArrayList(), hex); + } + + public String toASMSource(ConstantPool constants, MethodBody body, List outputMap, boolean hex) { + invalidateCache(); + StringBuffer ret = new StringBuffer(); + String t = ""; + for (int e = 0; e < body.exceptions.length; e++) { + ret.append("exception " + e + " m[" + body.exceptions[e].name_index + "]\"" + Helper.escapeString(body.exceptions[e].getVarName(constants, new ArrayList())) + "\" " + + "m[" + body.exceptions[e].type_index + "]\"" + Helper.escapeString(body.exceptions[e].getTypeName(constants, new ArrayList())) + "\"\n"); + } + List offsets = new ArrayList(); + for (AVM2Instruction ins : code) { + offsets.addAll(ins.getOffsets()); + } + for (AVM2Instruction ins : code) { + if (ins.replaceWith != null) { + for (Object o : ins.replaceWith) { + if (o instanceof ControlFlowTag) { + ControlFlowTag cft = (ControlFlowTag) o; + if (cft.name.equals("appendjump")) { + offsets.add((long) pos2adr(cft.value)); + } + } + } + } + } + long ofs = 0; + int ip = 0; + int largeLimit = 20000; + boolean markOffsets = code.size() <= largeLimit; + for (AVM2Instruction ins : code) { + if (hex) { + ret.append(""); + ret.append(Helper.bytesToHexString(ins.getBytes())); + ret.append("\n"); + } + if (ins.labelname != null) { + ret.append(ins.labelname + ":"); + } else if (offsets.contains(ofs)) { + ret.append("ofs" + Helper.formatAddress(ofs) + ":"); + } + for (int e = 0; e < body.exceptions.length; e++) { + if (body.exceptions[e].start == ofs) { + ret.append("exceptionstart " + e + ":"); + } + if (body.exceptions[e].end == ofs) { + ret.append("exceptionend " + e + ":"); + } + if (body.exceptions[e].target == ofs) { + ret.append("exceptiontarget " + e + ":"); + } + } + if (ins.replaceWith != null) { + for (Object o : ins.replaceWith) { + if (o instanceof Integer) { + AVM2Instruction ins2 = code.get((Integer) o); + if (ins2.isIgnored()) { + continue; + } + t = Highlighting.hilighOffset("", ins2.mappedOffset > -1 ? ins2.mappedOffset : ofs) + ins2.toStringNoAddress(constants, new ArrayList()) + " ;copy from " + Helper.formatAddress(pos2adr((Integer) o)) + "\n"; + ret.append(t); + outputMap.add((Integer) o); + } else if (o instanceof ControlFlowTag) { + ControlFlowTag cft = (ControlFlowTag) o; + if (cft.name.equals("appendjump")) { + t = "jump ofs" + Helper.formatAddress(pos2adr(cft.value)) + "\n"; + ret.append(t); + outputMap.add(-1); + } + if (cft.name.equals("mark")) { + ret.append("ofs" + Helper.formatAddress(pos2adr(cft.value)) + ":"); + } + } + } + } else { + if (!ins.isIgnored()) { + t = ins.toStringNoAddress(constants, new ArrayList()); + if (ins.changeJumpTo > -1) { + t = ins.definition.instructionName + " ofs" + Helper.formatAddress(pos2adr(ins.changeJumpTo)); + } + if (markOffsets) { + t = Highlighting.hilighOffset("", ins.mappedOffset > -1 ? ins.mappedOffset : ofs) + t + "\n"; + } else { + t = t + "\n"; + } + ret.append(t); + outputMap.add(ip); + } + } + ofs += ins.getBytes().length; + ip++; + } + String r = ret.toString(); + return r; + } + private boolean cacheActual = false; + private List posCache; + + private void buildCache() { + posCache = new ArrayList(); + long a = 0; + for (int i = 0; i < code.size(); i++) { + posCache.add(a); + a += code.get(i).getBytes().length; + } + posCache.add(a); + cacheActual = true; + } + + public int adr2pos(long address) throws ConvertException { + if (!cacheActual) { + buildCache(); + } + int ret = posCache.indexOf(address); + if (ret == -1) { + throw new ConvertException("Bad jump try conver ofs" + Helper.formatAddress(address) + " ", -1); + } + return ret; + } + + public int pos2adr(int pos) { + if (!cacheActual) { + buildCache(); + } + return posCache.get(pos).intValue(); + } + + public void invalidateCache() { + cacheActual = false; + } + + private static String innerStackToString(List stack) { + String ret = ""; + for (int d = 0; d < stack.size(); d++) { + Object o = stack.get(d); + ret += o.toString(); + if (d < stack.size() - 1) { + if (!ret.endsWith("\r\n")) { + ret += "\r\n"; + } + } + } + return ret; + } + + private class Loop { + + public int loopContinue; + public int loopBreak; + public int continueCount = 0; + public int breakCount = 0; + + public Loop(int loopContinue, int loopBreak) { + this.loopContinue = loopContinue; + this.loopBreak = loopBreak; + } + } + private List loopList; + private List unknownJumps; + private List finallyJumps; + private List parsedExceptions; + private List ignoredIns; + + private String stripBrackets(String s) { + if (s.startsWith("(") && (s.endsWith(")"))) { + s = s.substring(1, s.length() - 1); + } + return s; + } + + private int checkCatches(ABC abc, ConstantPool constants, MethodInfo method_info[], Stack stack, Stack scopeStack, List output, MethodBody body, int ip) throws ConvertException { + /*int newip = ip; + loope: + for (int e = 0; e < body.exceptions.length; e++) { + if (pos2adr(ip) == body.exceptions[e].end) { + for (int f = 0; f < e; f++) { + if (body.exceptions[e].startServer == body.exceptions[f].startServer) { + if (body.exceptions[e].end == body.exceptions[f].end) { + continue loope; } - }, - new GetPropertyIns(), - new GetScopeObjectIns(), - new GetSlotIns(), - new GetSuperIns(), - new GreaterEqualsIns(), - new GreaterThanIns(), - new HasNextIns(), - new HasNext2Ins(), - new IfEqIns(), - new IfFalseIns(), - new IfGeIns(), - new IfGtIns(), - new IfLeIns(), - new IfLtIns(), - new IfNGeIns(), - new IfNGtIns(), - new IfNLeIns(), - new IfNLtIns(), - new IfNeIns(), - new IfStrictEqIns(), - new IfStrictNeIns(), - new IfTrueIns(), - new InIns(), - new IncLocalIns(), - new IncLocalIIns(), - new IncrementIns(), - new IncrementIIns(), - new InstructionDefinition(0x9c, "increment_p", new int[]{AVM2Code.OPT_U30 /*param*/}), - new InstructionDefinition(0x9d, "inclocal_p", new int[]{AVM2Code.OPT_U30 /*param*/, AVM2Code.DAT_REGISTER_INDEX}), - new InstructionDefinition(0x9e, "decrement_p", new int[]{AVM2Code.OPT_U30 /*param*/}), - new InstructionDefinition(0x9f, "declocal_p", new int[]{AVM2Code.OPT_U30 /*param*/, AVM2Code.DAT_REGISTER_INDEX}), - new InitPropertyIns(), - new InstanceOfIns(), - new IsTypeIns(), - new IsTypeLateIns(), - new JumpIns(), - new KillIns(), - new LabelIns(), - new LessEqualsIns(), - new LessThanIns(), - new LookupSwitchIns(), - new LShiftIns(), - new ModuloIns(), - new InstructionDefinition(0xb9, "modulo_p", new int[]{AVM2Code.OPT_U30}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; //? } - }, - new MultiplyIns(), - new MultiplyIIns(), - new InstructionDefinition(0xb7, "multiply_p", new int[]{AVM2Code.OPT_U30}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; //? } - }, - new NegateIns(), - new NegateIIns(), - new InstructionDefinition(0x8f, "negate_p", new int[]{AVM2Code.OPT_U30 /* param */}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); + output.add("}"); + if (!(code.get(ip).definition instanceof JumpIns)) { + throw new ConvertException("No jump to skip catches"); + } + int addrAfterCatches = pos2adr(ip + 1) + code.get(ip).operands[0]; + int posAfterCatches = adr2pos(addrAfterCatches); + for (int g = 0; g < body.exceptions.length; g++) { + if (body.exceptions[e].startServer == body.exceptions[g].startServer) { + if (body.exceptions[e].end == body.exceptions[g].end) { + if (body.exceptions[g].isFinally()) { + output.add("finally"); + } else { + output.add("catch(" + body.exceptions[g].getVarName(constants) + ":" + body.exceptions[g].getTypeName(constants) + ")"); + } + output.add("{"); + + if (body.exceptions[g].isFinally()) { + int jumppos = adr2pos(body.exceptions[g].target) - 1; + AVM2Instruction jumpIns = code.get(jumppos); + if (!(jumpIns.definition instanceof JumpIns)) { + throw new ConvertException("No jump in finally block"); + } + int nextAddr = pos2adr(jumppos + 1) + jumpIns.operands[0]; + int nextins = adr2pos(nextAddr); + int pos = nextins; + Integer uj = new Integer(nextins); + if (unknownJumps.contains(uj)) { + unknownJumps.remove(uj); + } + int endpos = 0; + do { + if (code.get(pos).definition instanceof LookupSwitchIns) { + if (code.get(pos).operands[0] == 0) { + if (adr2pos(pos2adr(pos) + code.get(pos).operands[2]) < pos) { + endpos = pos - 1; + newip = endpos + 1; + break; + } + } + } + pos++; + } while (pos < code.size()); + output.addAll(toSource(stack, scopeStack, abc, constants, method_info, body, nextins, endpos).output); + } else { + + int pos = adr2pos(body.exceptions[g].target); + int endpos = posAfterCatches - 1; + for (int p = pos; p < posAfterCatches; p++) { + if (code.get(p).definition instanceof JumpIns) { + int nextAddr = pos2adr(p + 1) + code.get(p).operands[0]; + int nextPos = adr2pos(nextAddr); + if (nextPos == posAfterCatches) { + endpos = p - 1; + break; + } + } + } + Stack cstack = new Stack(); + cstack.push("catched " + body.exceptions[g].getVarName(constants)); + List outcatch = toSource(cstack, new Stack(), abc, constants, method_info, body, pos, endpos).output; + output.addAll(outcatch); + newip = endpos + 1; + } + output.add("}"); + } + } + } + } + } + return newip;*/ + return ip; + } + boolean isCatched = false; + + public boolean isKilled(int regName, int start, int end) { + for (int k = start; k <= end; k++) { + if (code.get(k).definition instanceof KillIns) { + if (code.get(k).operands[0] == regName) { + return true; + } + } + } + return false; + } + private int toSourceCount = 0; + + private int ipOfType(int from, boolean up, Class search, Class skipped, int start, int end) { + if (up) { + for (int i = from; i >= start; i--) { + if (search.isInstance(code.get(i).definition)) { + return i; + } else if ((skipped != null) && skipped.isInstance(code.get(i).definition)) { + //skipped + } else { + return -1; + } + } + } else { + for (int i = from; i <= end; i++) { + if (search.isInstance(code.get(i).definition)) { + return i; + } else if ((skipped != null) && skipped.isInstance(code.get(i).definition)) { + //skipped + } else { + return -1; + } + } + + } + return -1; + } + + public HashMap getLocalRegNamesFromDebug(ABC abc) { + HashMap localRegNames = new HashMap(); + for (AVM2Instruction ins : code) { + if (ins.definition instanceof DebugIns) { + if (ins.operands[0] == 1) { + localRegNames.put(ins.operands[2] + 1, abc.constants.constant_string[ins.operands[1]]); + } + } + } + return localRegNames; + } + + public List clearTemporaryRegisters(List output) { + for (int i = 0; i < output.size(); i++) { + if (output.get(i) instanceof SetLocalTreeItem) { + if (isKilled(((SetLocalTreeItem) output.get(i)).regIndex, 0, code.size() - 1)) { + output.remove(i); + i--; + } + } else if (output.get(i) instanceof WithTreeItem) { + clearTemporaryRegisters(((WithTreeItem) output.get(i)).items); + } + } + return output; + } + + public int fixIPAfterDebugLine(int ip) { + if (ip >= code.size()) { + return code.size() - 1; + } + if (code.get(ip).definition instanceof DebugLineIns) { + return ip + 1; + } + return ip; + } + + public int fixAddrAfterDebugLine(int addr) throws ConvertException { + return pos2adr(fixIPAfterDebugLine(adr2pos(addr))); + } + + public ConvertOutput toSourceOutput(boolean processJumps, boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, int start, int end, HashMap localRegNames, List fullyQualifiedNames, boolean visited[]) throws ConvertException { + boolean debugMode = DEBUG_MODE; + if (debugMode) { + System.out.println("OPEN SubSource:" + start + "-" + end + " " + code.get(start).toString() + " to " + code.get(end).toString()); + } + if (visited == null) { + visited = new boolean[code.size()]; + } + //if(true) return ""; + toSourceCount++; + if (toSourceLimit > 0) { + if (toSourceCount > toSourceLimit) { + throw new ConvertException("Limit of subs(" + toSourceLimit + ") was reached", start); + } + } + List output = new ArrayList(); + String ret = ""; + int ip = start; + try { + int addr; + iploop: + while (ip <= end) { + + if (ignoredIns.contains(ip)) { + ip++; + continue; + } + boolean processTry = processJumps; + addr = pos2adr(ip); + int ipfix = fixIPAfterDebugLine(ip); + int addrfix = pos2adr(ipfix); + int maxend = -1; + if (processTry) { + List catchedExceptions = new ArrayList(); + for (int e = 0; e < body.exceptions.length; e++) { + if (addrfix == fixAddrAfterDebugLine(body.exceptions[e].start)) { + if (!body.exceptions[e].isFinally()) { + if ((fixAddrAfterDebugLine(body.exceptions[e].end) > maxend) && (!parsedExceptions.contains(body.exceptions[e]))) { + catchedExceptions.clear(); + maxend = fixAddrAfterDebugLine(body.exceptions[e].end); + catchedExceptions.add(body.exceptions[e]); + } else if (fixAddrAfterDebugLine(body.exceptions[e].end) == maxend) { + catchedExceptions.add(body.exceptions[e]); + } + } + } + } + if (catchedExceptions.size() > 0) { + ip = ipfix; + addr = addrfix; + parsedExceptions.addAll(catchedExceptions); + int endpos = adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(0).end)); + + + List> catchedCommands = new ArrayList>(); + if (code.get(endpos).definition instanceof JumpIns) { + int afterCatchAddr = pos2adr(endpos + 1) + code.get(endpos).operands[0]; + int afterCatchPos = adr2pos(afterCatchAddr); + Collections.sort(catchedExceptions, new Comparator() { + @Override + public int compare(ABCException o1, ABCException o2) { + try { + return fixAddrAfterDebugLine(o1.target) - fixAddrAfterDebugLine(o2.target); + } catch (ConvertException ex) { + return 0; + } + } + }); + + + List finallyCommands = new ArrayList(); + int returnPos = afterCatchPos; + for (int e = 0; e < body.exceptions.length; e++) { + if (body.exceptions[e].isFinally()) { + if (addr == fixAddrAfterDebugLine(body.exceptions[e].start)) { + if (afterCatchPos + 1 == adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end))) { + AVM2Instruction jmpIns = code.get(adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end))); + if (jmpIns.definition instanceof JumpIns) { + int finStart = adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]); + finallyJumps.add(finStart); + if (unknownJumps.contains(finStart)) { + unknownJumps.remove((Integer) finStart); + } + for (int f = finStart; f <= end; f++) { + if (code.get(f).definition instanceof LookupSwitchIns) { + AVM2Instruction swins = code.get(f); + if (swins.operands.length >= 3) { + if (swins.operands[0] == swins.getBytes().length) { + if (adr2pos(pos2adr(f) + swins.operands[2]) < finStart) { + finallyCommands = toSourceOutput(processJumps, isStatic, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, finStart, f - 1, localRegNames, fullyQualifiedNames, visited).output; + returnPos = f + 1; + break; + } + } + } + } + } + + break; + } + } + } + } + } + + for (int e = 0; e < catchedExceptions.size(); e++) { + int eendpos; + if (e < catchedExceptions.size() - 1) { + eendpos = adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(e + 1).target)) - 2; + } else { + eendpos = afterCatchPos - 1; + } + Stack substack = new Stack(); + substack.add(new ExceptionTreeItem(catchedExceptions.get(e))); + catchedCommands.add(toSourceOutput(processJumps, isStatic, classIndex, localRegs, substack, new Stack(), abc, constants, method_info, body, adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(e).target)), eendpos, localRegNames, fullyQualifiedNames, visited).output); + } + + List tryCommands = toSourceOutput(processJumps, isStatic, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip, endpos - 1, localRegNames, fullyQualifiedNames, visited).output; + + + output.add(new TryTreeItem(tryCommands, catchedExceptions, catchedCommands, finallyCommands)); + ip = returnPos; + addr = pos2adr(ip); + } + + } + } + + if (ip > end) { + break; + } + + if (unknownJumps.contains(ip)) { + unknownJumps.remove(new Integer(ip)); + throw new UnknownJumpException(stack, ip, output); + } + if (visited[ip]) { + Logger.getLogger(AVM2Code.class.getName()).warning("Code already visited, ofs:" + Helper.formatAddress(pos2adr(ip)) + ", ip:" + ip); + break; + } + visited[ip] = true; + AVM2Instruction ins = code.get(ip); + if (debugMode) { + System.out.println("translating ip " + ip + " ins " + ins.toString() + " stack:" + Highlighting.stripHilights(stack.toString()) + " scopeStack:" + Highlighting.stripHilights(scopeStack.toString())); + } + if (ins.definition instanceof NewFunctionIns) { + if (ip + 1 <= end) { + if (code.get(ip + 1).definition instanceof PopIns) { + ip += 2; + continue; + } + } + } + if ((ip + 8 < code.size())) { //return in finally clause + if (ins.definition instanceof SetLocalTypeIns) { + if (code.get(ip + 1).definition instanceof PushByteIns) { + AVM2Instruction jmp = code.get(ip + 2); + if (jmp.definition instanceof JumpIns) { + if (jmp.operands[0] == 0) { + if (code.get(ip + 3).definition instanceof LabelIns) { + if (code.get(ip + 4).definition instanceof PopIns) { + if (code.get(ip + 5).definition instanceof LabelIns) { + AVM2Instruction gl = code.get(ip + 6); + if (gl.definition instanceof GetLocalTypeIns) { + if (((GetLocalTypeIns) gl.definition).getRegisterId(gl) == ((SetLocalTypeIns) ins.definition).getRegisterId(ins)) { + AVM2Instruction ki = code.get(ip + 7); + if (ki.definition instanceof KillIns) { + if (ki.operands[0] == ((SetLocalTypeIns) ins.definition).getRegisterId(ins)) { + if (code.get(ip + 8).definition instanceof ReturnValueIns) { + ip = ip + 8; + continue; + } + } + } + } + } + } + } + } + } + } + } + } + } + + /*if ((ip + 2 < code.size()) && (ins.definition instanceof NewCatchIns)) { //Filling local register in catch clause + if (code.get(ip + 1).definition instanceof DupIns) { + if (code.get(ip + 2).definition instanceof SetLocalTypeIns) { + ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames); + ip += 3; + continue; + } + } + }*/ + if ((ins.definition instanceof GetLocalTypeIns) && (!output.isEmpty()) && (output.get(output.size() - 1) instanceof SetLocalTreeItem) && (((SetLocalTreeItem) output.get(output.size() - 1)).regIndex == ((GetLocalTypeIns) ins.definition).getRegisterId(ins)) && isKilled(((SetLocalTreeItem) output.get(output.size() - 1)).regIndex, start, end)) { + SetLocalTreeItem slt = (SetLocalTreeItem) output.remove(output.size() - 1); + stack.push(slt.getValue()); + ip++; + } else if ((ins.definition instanceof SetLocalTypeIns) && (ip + 1 <= end) && (isKilled(((SetLocalTypeIns) ins.definition).getRegisterId(ins), ip, end))) { //set_local_x,get_local_x..kill x + AVM2Instruction insAfter = code.get(ip + 1); + if ((insAfter.definition instanceof GetLocalTypeIns) && (((GetLocalTypeIns) insAfter.definition).getRegisterId(insAfter) == ((SetLocalTypeIns) ins.definition).getRegisterId(ins))) { + GraphTargetItem before = stack.peek(); + ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames); + stack.push(before); + ip += 2; + continue iploop; + } else { + ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames); + ip++; + continue iploop; + } + } else if (ins.definition instanceof DupIns) { + int nextPos; + do { + AVM2Instruction insAfter = code.get(ip + 1); + AVM2Instruction insBefore = ins; + if (ip - 1 >= start) { + insBefore = code.get(ip - 1); + } + if (insAfter.definition instanceof ConvertBIns) { //SWF compiled with debug contain convert_b + ip++; + addr = pos2adr(ip); + insAfter = code.get(ip + 1); + } + + boolean isAnd; + if (processJumps && (insAfter.definition instanceof IfFalseIns)) { + //stack.add("(" + stack.pop() + ")&&"); + isAnd = true; + } else if (processJumps && (insAfter.definition instanceof IfTrueIns)) { + //stack.add("(" + stack.pop() + ")||"); + isAnd = false; + } else if (insAfter.definition instanceof SetLocalTypeIns) { + //chained assignments + int reg = (((SetLocalTypeIns) insAfter.definition).getRegisterId(insAfter)); + for (int t = ip + 1; t <= end - 1; t++) { + if (code.get(t).definition instanceof KillIns) { + if (code.get(t).operands[0] == reg) { + break; + } + } + if (code.get(t).definition instanceof GetLocalTypeIns) { + if (((GetLocalTypeIns) code.get(t).definition).getRegisterId(code.get(t)) == reg) { + if (code.get(t + 1).definition instanceof KillIns) { + if (code.get(t + 1).operands[0] == reg) { + ConvertOutput assignment = toSourceOutput(processJumps, isStatic, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip + 2, t - 1, localRegNames, fullyQualifiedNames, visited); + stack.push(assignment.output.remove(assignment.output.size() - 1)); + ip = t + 2; + continue iploop; + } + } + } + } + } + if (!isKilled(reg, 0, end)) { + for (int i = ip; i >= start; i--) { + if (code.get(i).definition instanceof DupIns) { + GraphTargetItem v = stack.pop(); + stack.push(new LocalRegTreeItem(ins, reg, v)); + stack.push(v); + } else { + break; + } + } + } else { + ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames); + } + ip++; + break; + //} + + } else { + ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames); + ip++; + break; + //throw new ConvertException("Unknown pattern after DUP:" + insComparsion.toString()); + } + } while (ins.definition instanceof DupIns); + } else if ((ins.definition instanceof ReturnValueIns) || (ins.definition instanceof ReturnVoidIns) || (ins.definition instanceof ThrowIns)) { + ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames); + ip = end + 1; + break; + } else if (ins.definition instanceof NewFunctionIns) { + String functionName = ""; + if ((ip >= start + 2) && (ip <= end - 4)) { + AVM2Instruction prev2 = code.get(ip - 2); + if (prev2.definition instanceof NewObjectIns) { + if (prev2.operands[0] == 0) { + if (code.get(ip - 1).definition instanceof PushWithIns) { + boolean hasDup = false; + int plus = 0; + if (code.get(ip + 1).definition instanceof DupIns) { + hasDup = true; + plus = 1; + } + AVM2Instruction psco = code.get(ip + 1 + plus); + if (psco.definition instanceof GetScopeObjectIns) { + if (psco.operands[0] == scopeStack.size() - 1) { + if (code.get(ip + plus + 2).definition instanceof SwapIns) { + if (code.get(ip + plus + 4).definition instanceof PopScopeIns) { + if (code.get(ip + plus + 3).definition instanceof SetPropertyIns) { + functionName = abc.constants.constant_multiname[code.get(ip + plus + 3).operands[0]].getName(constants, fullyQualifiedNames); + scopeStack.pop();//with + output.remove(output.size() - 1); //with + ip = ip + plus + 4; //+1 below + } + } + } + } + } + } + } + } + } + //What to do when hasDup is false? + ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames); + NewFunctionTreeItem nft = (NewFunctionTreeItem) stack.peek(); + nft.functionName = functionName; + ip++; + } else { + ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames); + + ip++; + addr = pos2adr(ip); + } + + } + if (debugMode) { + System.out.println("CLOSE SubSource:" + start + "-" + end + " " + code.get(start).toString() + " to " + code.get(end).toString()); + } + /*if (hideTemporaryRegisters) { + clearTemporaryRegisters(output); + }*/ + return new ConvertOutput(stack, output); + } catch (ConvertException cex) { + throw cex; + } + } + + public String tabString(int len) { + String ret = ""; + for (int i = 0; i < len; i++) { + ret += ABC.IDENT_STRING; + } + return ret; + } + + public String toSource(String path, boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, HashMap localRegNames, Stack scopeStack, boolean isStaticInitializer, List fullyQualifiedNames, Traits initTraits) { + return toSource(path, isStatic, classIndex, abc, constants, method_info, body, false, localRegNames, scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits); + } + + public int getRegisterCount() { + int maxRegister = -1; + for (AVM2Instruction ins : code) { + int regId = -1; + if (ins.definition instanceof SetLocalTypeIns) { + regId = ((SetLocalTypeIns) ins.definition).getRegisterId(ins); + } + if (ins.definition instanceof GetLocalTypeIns) { + regId = ((GetLocalTypeIns) ins.definition).getRegisterId(ins); + } + if (regId > maxRegister) { + maxRegister = regId; + } + } + return maxRegister + 1; + } + + public HashMap getLocalRegTypes(ConstantPool constants, List fullyQualifiedNames) { + HashMap ret = new HashMap(); + AVM2Instruction prev = null; + for (AVM2Instruction ins : code) { + if (ins.definition instanceof SetLocalTypeIns) { + if (prev != null) { + if (prev.definition instanceof CoerceOrConvertTypeIns) { + ret.put(((SetLocalTypeIns) ins.definition).getRegisterId(ins), ((CoerceOrConvertTypeIns) prev.definition).getTargetType(constants, prev, fullyQualifiedNames)); + } + } + } + prev = ins; + } + return ret; + } + + private class Slot { + + public GraphTargetItem scope; + public Multiname multiname; + + public Slot(GraphTargetItem scope, Multiname multiname) { + this.scope = scope; + this.multiname = multiname; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof Slot) { + return (((Slot) obj).scope.getThroughRegister() == scope.getThroughRegister()) + && (((Slot) obj).multiname == multiname); + } + return false; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 59 * hash + (this.scope != null ? this.scope.hashCode() : 0); + hash = 59 * hash + (this.multiname != null ? this.multiname.hashCode() : 0); + return hash; + } + } + + public void initToSource() { + toSourceCount = 0; + loopList = new ArrayList(); + unknownJumps = new ArrayList(); + finallyJumps = new ArrayList(); + parsedExceptions = new ArrayList(); + ignoredIns = new ArrayList(); + } + + public String toSource(String path, boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, boolean hilighted, HashMap localRegNames, Stack scopeStack, boolean isStaticInitializer, List fullyQualifiedNames, Traits initTraits) { + initToSource(); + List list; + String s; + HashMap localRegs = new HashMap(); + + int regCount = getRegisterCount(); + int paramCount; + if (body.method_info != -1) { + MethodInfo mi = method_info[body.method_info]; + paramCount = mi.param_types.length; + if (mi.flagNeed_rest()) { + paramCount++; + } + } + + //try { + + try { + list = AVM2Graph.translateViaGraph(path, this, abc, body, isStatic, classIndex, localRegs, scopeStack, localRegNames, fullyQualifiedNames); + } catch (Exception ex2) { + Logger.getLogger(AVM2Code.class.getName()).log(Level.SEVERE, "Decompilation error in " + path, ex2); + return "/*\r\n * Decompilation error\r\n * Code may be obfuscated\r\n * Error Message: " + ex2.getMessage() + "\r\n */"; + } + /*try{ + list=toSourceOutput(true,isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, 0, code.size() - 1, localRegNames, fullyQualifiedNames, null).output; + }catch(Exception ex){ + + }*/ + if (initTraits != null) { + for (int i = 0; i < list.size(); i++) { + GraphTargetItem ti = list.get(i); + if ((ti instanceof InitPropertyTreeItem) || (ti instanceof SetPropertyTreeItem)) { + int multinameIndex = 0; + GraphTargetItem value = null; + if (ti instanceof InitPropertyTreeItem) { + multinameIndex = ((InitPropertyTreeItem) ti).propertyName.multinameIndex; + value = ((InitPropertyTreeItem) ti).value; + } + if (ti instanceof SetPropertyTreeItem) { + multinameIndex = ((SetPropertyTreeItem) ti).propertyName.multinameIndex; + value = ((SetPropertyTreeItem) ti).value; + } + for (Trait t : initTraits.traits) { + if (t.name_index == multinameIndex) { + if ((t instanceof TraitSlotConst)) { + if (((TraitSlotConst) t).isConst() || isStaticInitializer) { + ((TraitSlotConst) t).assignedValue = value; + list.remove(i); + i--; + continue; + } + break; + } + } + } + } else { + //In obfuscated code, SetLocal instructions comes first + //break; + } + } + } + if (isStaticInitializer) { + List newList = new ArrayList(); + for (GraphTargetItem ti : list) { + if (!(ti instanceof ReturnVoidTreeItem)) { + if (!(ti instanceof InitPropertyTreeItem)) { + if (!(ti instanceof SetPropertyTreeItem)) { + newList.add(ti); + } + } + } + } + list = newList; + if (list.isEmpty()) { + return ""; + } + } + //Declarations + boolean declaredRegisters[] = new boolean[regCount]; + for (int b = 0; b < declaredRegisters.length; b++) { + declaredRegisters[b] = false; + } + List declaredSlots = new ArrayList(); + for (int i = 0; i < list.size(); i++) { + GraphTargetItem ti = list.get(i); + if (ti instanceof SetLocalTreeItem) { + int reg = ((SetLocalTreeItem) ti).regIndex; + if (!declaredRegisters[reg]) { + list.set(i, new DeclarationTreeItem(ti)); + declaredRegisters[reg] = true; + } + } + if (ti instanceof SetSlotTreeItem) { + SetSlotTreeItem ssti = (SetSlotTreeItem) ti; + Slot sl = new Slot(ssti.scope, ssti.slotName); + if (!declaredSlots.contains(sl)) { + String type = "*"; + for (int t = 0; t < body.traits.traits.length; t++) { + if (body.traits.traits[t].getName(abc) == sl.multiname) { + if (body.traits.traits[t] instanceof TraitSlotConst) { + type = ((TraitSlotConst) body.traits.traits[t]).getType(constants, fullyQualifiedNames); + } + } + } + list.set(i, new DeclarationTreeItem(ti, type)); + declaredSlots.add(sl); + } + } + } + + s = Graph.graphToString(list, constants, localRegNames, fullyQualifiedNames); + if (!hilighted) { + return Highlighting.stripHilights(s); + } + + return s; + } + + public void removeInstruction(int pos, MethodBody body) { + if ((pos < 0) || (pos >= code.size())) { + throw new IndexOutOfBoundsException(); + } + int byteCount = code.get(pos).getBytes().length; + long remOffset = code.get(pos).offset; + for (int i = pos + 1; i < code.size(); i++) { + code.get(i).offset -= byteCount; + } + + for (ABCException ex : body.exceptions) { + if (ex.start > remOffset) { + ex.start -= byteCount; + } + if (ex.end > remOffset) { + ex.end -= byteCount; + } + if (ex.target > remOffset) { + ex.target -= byteCount; + } + } + + + for (int i = 0; i < pos; i++) { + if (code.get(i).definition instanceof LookupSwitchIns) { + long target = code.get(i).offset + code.get(i).operands[0]; + if (target > remOffset) { + code.get(i).operands[0] -= byteCount; + } + for (int k = 2; k < code.get(i).operands.length; k++) { + target = code.get(i).offset + code.get(i).operands[k]; + if (target > remOffset) { + code.get(i).operands[k] -= byteCount; + } + } + } else { + for (int j = 0; j < code.get(i).definition.operands.length; j++) { + if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { + long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; + if (target > remOffset) { + code.get(i).operands[j] -= byteCount; + } + } + } + } + } + for (int i = pos + 1; i < code.size(); i++) { + if (code.get(i).definition instanceof LookupSwitchIns) { + long target = code.get(i).offset + code.get(i).operands[0]; + if (target < remOffset) { + code.get(i).operands[0] += byteCount; + } + for (int k = 2; k < code.get(i).operands.length; k++) { + target = code.get(i).offset + code.get(i).operands[k]; + if (target < remOffset) { + code.get(i).operands[k] += byteCount; + } + } + } else { + for (int j = 0; j < code.get(i).definition.operands.length; j++) { + if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { + long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; + if (target < remOffset) { + code.get(i).operands[j] += byteCount; + } + } + } + } + } + + code.remove(pos); + invalidateCache(); + } + + public void insertInstruction(int pos, AVM2Instruction instruction) { + if (pos < 0) { + pos = 0; + } + if (pos > code.size()) { + pos = code.size(); + } + int byteCount = instruction.getBytes().length; + if (pos == code.size()) { + instruction.offset = code.get(pos - 1).offset + code.get(pos - 1).getBytes().length; + } else { + instruction.offset = code.get(pos).offset; + } + + for (int i = 0; i < pos; i++) { + for (int j = 0; j < code.get(i).definition.operands.length; j++) { + if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { + long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; + if (target >= instruction.offset) { + code.get(i).operands[j] += byteCount; + } + } + } + } + for (int i = pos; i < code.size(); i++) { + for (int j = 0; j < code.get(i).definition.operands.length; j++) { + if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { + long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; + if (target < instruction.offset) { + code.get(i).operands[j] -= byteCount; + } + } + } + } + + for (int i = pos + 1; i < code.size(); i++) { + code.get(i).offset += byteCount; + } + code.add(pos, instruction); + } + + public int removeTraps(ConstantPool constants, MethodBody body, ABC abc) { + + removeDeadCode(constants, body); + /* boolean isSecure = true; + try { + if (code.size() > 4) { + AVM2Instruction first = code.get(0); + AVM2Instruction second = code.get(1); + boolean firstValue = false; + boolean secondValue = false; + if (first.definition instanceof PushFalseIns) { + firstValue = false; + } else if (first.definition instanceof PushTrueIns) { + firstValue = true; + } else { + isSecure = false; + } + if (isSecure) { + if (second.definition instanceof PushFalseIns) { + secondValue = false; + } else if (second.definition instanceof PushTrueIns) { + secondValue = true; + } else { + isSecure = false; + } + if (isSecure) { + int pos = 2; + AVM2Instruction third = code.get(pos); + if (third.definition instanceof SwapIns) { + pos++; + boolean dup = firstValue; + firstValue = secondValue; + secondValue = dup; + third.ignored = true; + } + while (third.definition instanceof JumpIns) { + pos = adr2pos(pos2adr(pos) + third.getBytes().length + third.operands[0]); + third = code.get(pos); + } + AVM2Instruction firstSet = code.get(pos); + while (firstSet.definition instanceof JumpIns) { + pos = adr2pos(pos2adr(pos) + firstSet.getBytes().length + firstSet.operands[0]); + firstSet = code.get(pos); + } + pos++; + AVM2Instruction secondSet = code.get(pos); + while (secondSet.definition instanceof JumpIns) { + pos = adr2pos(pos2adr(pos) + secondSet.getBytes().length + secondSet.operands[0]); + secondSet = code.get(pos); + } + int trueIndex = -1; + int falseIndex = -1; + if (firstSet.definition instanceof SetLocalTypeIns) { + if (secondValue == true) { + trueIndex = ((SetLocalTypeIns) firstSet.definition).getRegisterId(firstSet); + } + if (secondValue == false) { + falseIndex = ((SetLocalTypeIns) firstSet.definition).getRegisterId(firstSet); + } + } else { + isSecure = false; + } + if (isSecure) { + if (secondSet.definition instanceof SetLocalTypeIns) { + if (firstValue == true) { + trueIndex = ((SetLocalTypeIns) secondSet.definition).getRegisterId(secondSet); + } + if (firstValue == false) { + falseIndex = ((SetLocalTypeIns) secondSet.definition).getRegisterId(secondSet); + } + secondSet.ignored = true; + firstSet.ignored = true; + first.ignored = true; + second.ignored = true; + boolean found; + do { + found = false; + for (int ip = 0; ip < code.size(); ip++) { + if (code.get(ip).ignored) { + continue; + } + if (code.get(ip).definition instanceof GetLocalTypeIns) { + int regIndex = ((GetLocalTypeIns) code.get(ip).definition).getRegisterId(code.get(ip)); + if ((regIndex == trueIndex) || (regIndex == falseIndex)) { + found = true; + Stack myStack = new Stack(); + do { + AVM2Instruction ins = code.get(ip); + if (ins.definition instanceof GetLocalTypeIns) { + regIndex = ((GetLocalTypeIns) ins.definition).getRegisterId(ins); + if (regIndex == trueIndex) { + myStack.push(true); + } + if (regIndex == falseIndex) { + myStack.push(false); + } + ip++; + ins.ignored = true; + } else if (ins.definition instanceof DupIns) { + Boolean b = myStack.pop(); + myStack.push(b); + myStack.push(b); + ins.ignored = true; + ip++; + } else if (ins.definition instanceof PopIns) { + myStack.pop(); + ins.ignored = true; + ip++; + } else if (ins.definition instanceof IfTrueIns) { + boolean val = myStack.pop(); + if (val) { + code.get(ip).definition = new JumpIns(); + ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); + } else { + code.get(ip).ignored = true; + ip++; + } + } else if (ins.definition instanceof IfFalseIns) { + boolean val = myStack.pop(); + if (!val) { + code.get(ip).definition = new JumpIns(); + ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); + } else { + code.get(ip).ignored = true; + ip++; + } + } else if (ins.definition instanceof JumpIns) { + ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); + } else { + ip++; } - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - }, - new NewActivationIns(), - new NewArrayIns(), - new NewCatchIns(), - new NewClassIns(), - new NewFunctionIns(), - new NewObjectIns(), - new NextNameIns(), - new NextValueIns(), - new NopIns(), - new NotIns(), - new PopIns(), - new PopScopeIns(), - new PushByteIns(), - new InstructionDefinition(0x22, "pushconstant", new int[]{AVM2Code.DAT_STRING_INDEX}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; //? - } - }, - new InstructionDefinition(0x33, "pushdecimal", new int[]{AVM2Code.DAT_DECIMAL_INDEX}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; //? - } - }, - new InstructionDefinition(0x34, "pushdnan", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; //? - } - }, - new PushDoubleIns(), - new PushFalseIns(), - new PushIntIns(), - new PushNamespaceIns(), - new PushNanIns(), - new PushNullIns(), - new PushScopeIns(), - new PushShortIns(), - new PushStringIns(), - new PushTrueIns(), - new PushUIntIns(), - new PushUndefinedIns(), - new PushWithIns(), - new ReturnValueIns(), - new ReturnVoidIns(), - new RShiftIns(), - new SetLocalIns(), - new SetLocal0Ins(), - new SetLocal1Ins(), - new SetLocal2Ins(), - new SetLocal3Ins(), - new SetGlobalSlotIns(), - new SetPropertyIns(), - new InstructionDefinition(0x69, "setpropertylate", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); + } while (myStack.size() > 0 && ip < code.size()); + + break; } - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); } - }, - new SetSlotIns(), - new SetSuperIns(), - new StrictEqualsIns(), - new SubtractIns(), - new SubtractIIns(), - new InstructionDefinition(0xb6, "subtract_p", new int[]{AVM2Code.OPT_U30}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); + } + } while (found); + removeIgnored(constants, body); + removeDeadCode(constants, body); + } else { + //isSecure = false; + } } - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); } - }, - new SwapIns(), - new ThrowIns(), - new InstructionDefinition(0xf3, "timestamp", new int[]{}), - new TypeOfIns(), - new URShiftIns(), - new InstructionDefinition(0x35, "li8", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); } + } + } catch (ConvertException cex) { + } + int ret = isSecure ? 1 : 0; + ret += visitCodeTrap(body, new int[code.size()]);*/ - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - }, - new InstructionDefinition(0x36, "li16", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } + //definition.translate((Boolean) localData.get(0), (Integer) localData.get(1), + //(HashMap) localData.get(2), stack, + //(Stack) localData.get(3), (ConstantPool) localData.get(4), this, + //(MethodInfo[]) localData.get(5), output, + //(MethodBody) localData.get(6), (ABC) localData.get(7), + //(HashMap) localData.get(8), (List) localData.get(8)); - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - }, - new InstructionDefinition(0x37, "li32", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } + List localData = new ArrayList(); + localData.add((Boolean) false); //isStatic + localData.add((Integer) 0); //classIndex + localData.add(new HashMap()); + localData.add(new Stack()); + localData.add(abc.constants); + localData.add(abc.method_info); + localData.add(body); + localData.add(abc); + localData.add(new HashMap()); //localRegNames + localData.add(new ArrayList()); //fullyQualifiedNames + localData.add(new ArrayList()); + localData.add(new ArrayList()); + localData.add(new ArrayList()); + int ret = 0; + ret += removeTraps(localData, new AVM2GraphSource(this, false, 0, new HashMap(), new Stack(), abc, body, new HashMap(), new ArrayList()), 0); + removeIgnored(constants, body); + removeDeadCode(constants, body); - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - }, - new InstructionDefinition(0x38, "lf32", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } + return ret; + } - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - }, - new InstructionDefinition(0x39, "lf64", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } + private void handleRegister(CodeStats stats, int reg) { + if (reg + 1 > stats.maxlocal) { + stats.maxlocal = reg + 1; + } + } - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - }, - new InstructionDefinition(0x3A, "si8", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - }, - new InstructionDefinition(0x3B, "si16", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - }, - new InstructionDefinition(0x3C, "si32", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - }, - new InstructionDefinition(0x3D, "sf32", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - }, - new InstructionDefinition(0x3E, "sf64", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - }, - new InstructionDefinition(0x50, "sxi1", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - }, - new InstructionDefinition(0x51, "sxi8", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - }, - new InstructionDefinition(0x52, "sxi16", new int[]{}) { - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - throw new UnsupportedOperationException(); - } - } - }; - //endoflist - public static InstructionDefinition instructionSetByCode[] = buildInstructionSetByCode(); - public boolean hideTemporaryRegisters = true; - - private static InstructionDefinition[] buildInstructionSetByCode() { - InstructionDefinition result[] = new InstructionDefinition[256]; - for (InstructionDefinition id : instructionSet) { - if (result[id.instructionCode] != null) { - System.out.println("Warning: Duplicate OPCODE for instruction " + result[id.instructionCode] + " " + id); - } - result[id.instructionCode] = id; - } - return result; - } - public static final String IDENTOPEN = "/*IDENTOPEN*/"; - public static final String IDENTCLOSE = "/*IDENTCLOSE*/"; - - public AVM2Code() { - } - - public Object execute(HashMap arguments, ConstantPool constants) { - int pos = 0; - LocalDataArea lda = new LocalDataArea(); - lda.localRegisters = arguments; - try { - while (true) { + private boolean walkCode(CodeStats stats, int pos, int stack, int scope, ABC abc) { + while (pos < code.size()) { + if (stats.instructionStats[pos].seen) { + //check stack mismatch here + return true; + } + stats.instructionStats[pos].seen = true; + stats.instructionStats[pos].stackpos = stack; + stats.instructionStats[pos].scopepos = scope; AVM2Instruction ins = code.get(pos); - if (ins.definition instanceof JumpIns) { - pos = adr2pos((Long) ins.getParamsAsList(constants).get(0)); - continue; + stack += ins.definition.getStackDelta(ins, abc); + scope += ins.definition.getScopeStackDelta(ins, abc); + if (stack > stats.maxstack) { + stats.maxstack = stack; } - if (ins.definition instanceof IfFalseIns) { - Boolean b = (Boolean) lda.operandStack.pop(); - if (b == false) { - pos = adr2pos((Long) ins.getParamsAsList(constants).get(0)); - } else { - pos++; - } - continue; + if (scope > stats.maxscope) { + stats.maxscope = scope; } - if (ins.definition instanceof IfTrueIns) { - Boolean b = (Boolean) lda.operandStack.pop(); - if (b == true) { - pos = adr2pos((Long) ins.getParamsAsList(constants).get(0)); - } else { - pos++; - } - continue; + if ((ins.definition instanceof DXNSIns) || (ins.definition instanceof DXNSLateIns)) { + stats.has_set_dxns = true; + } + if (ins.definition instanceof NewActivationIns) { + stats.has_activation = true; + } + if (ins.definition instanceof SetLocalTypeIns) { + handleRegister(stats, ((SetLocalTypeIns) ins.definition).getRegisterId(ins)); + } else { + for (int i = 0; i < ins.definition.operands.length; i++) { + if (ins.definition.operands[i] == DAT_REGISTER_INDEX) { + handleRegister(stats, ins.operands[i]); + } + } } if (ins.definition instanceof ReturnValueIns) { - return lda.operandStack.pop(); + //check stack=1 + return true; } if (ins.definition instanceof ReturnVoidIns) { - return null; + //check stack=0 + return true; + } + if (ins.definition instanceof JumpIns) { + try { + pos = adr2pos(pos2adr(pos) + ins.getBytes().length + ins.operands[0]); + continue; + } catch (ConvertException ex) { + return false; + } + } else if (ins.definition instanceof IfTypeIns) { + try { + int newpos = adr2pos(pos2adr(pos) + ins.getBytes().length + ins.operands[0]); + walkCode(stats, newpos, stack, scope, abc); + } catch (ConvertException ex) { + return false; + } + } + if (ins.definition instanceof LookupSwitchIns) { + for (int i = 0; i < ins.operands.length; i++) { + try { + int newpos = adr2pos(pos2adr(pos) + ins.operands[i]); + if (!walkCode(stats, newpos, stack, scope, abc)) { + return false; + } + } catch (ConvertException ex) { + return false; + } + } } - ins.definition.execute(lda, constants, ins.getParamsAsList(constants)); pos++; - } - } catch (ConvertException e) { - } - return null; - } - - public AVM2Code(InputStream is) throws IOException { - ABCInputStream ais = new ABCInputStream(is); - while (ais.available() > 0) { - long startOffset = ais.getPosition(); - ais.startBuffer(); - int instructionCode = ais.read(); - InstructionDefinition instr = instructionSetByCode[instructionCode]; - if (instr != null) { - int actualOperands[]; - if (instructionCode == 0x1b) { //switch - int firstOperand = ais.readS24(); - int case_count = ais.readU30(); - actualOperands = new int[case_count + 3]; - actualOperands[0] = firstOperand; - actualOperands[1] = case_count; - for (int c = 0; c < case_count + 1; c++) { - actualOperands[2 + c] = ais.readS24(); - } - } else { - actualOperands = new int[instr.operands.length]; - for (int op = 0; op < instr.operands.length; op++) { - switch (instr.operands[op] & 0xff00) { - case OPT_U30: - actualOperands[op] = ais.readU30(); - break; - case OPT_U8: - actualOperands[op] = ais.read(); - break; - case OPT_BYTE: - actualOperands[op] = (byte) ais.read(); - break; - case OPT_S24: - actualOperands[op] = ais.readS24(); - break; - } - } - } - - code.add(new AVM2Instruction(startOffset, instr, actualOperands, ais.stopBuffer())); - } else { - throw new UnknownInstructionCode(instructionCode); - } - } - } - - public void compact() { - code.trimToSize(); - } - - public byte[] getBytes() { - return getBytes(null); - } - - public byte[] getBytes(byte origBytes[]) { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - - OutputStream cos; - if ((origBytes != null) && (DEBUG_REWRITE)) { - ByteArrayInputStream origis = new ByteArrayInputStream(origBytes); - cos = new CopyOutputStream(bos, origis); - } else { - cos = bos; - } - try { - for (AVM2Instruction instruction : code) { - cos.write(instruction.getBytes()); - } - } catch (IOException ex) { - } - return bos.toByteArray(); - } - - @Override - public String toString() { - String s = ""; - for (AVM2Instruction instruction : code) { - s += instruction.toString() + "\r\n"; - } - return s; - } - - public String toString(ConstantPool constants) { - String s = ""; - int i = 0; - for (AVM2Instruction instruction : code) { - s += Helper.formatAddress(i) + " " + instruction.toString(constants, new ArrayList()) + "\r\n"; - i++; - } - return s; - } - - private static String popStack(Stack stack) { - for (int i = stack.size() - 1; i >= 0; i--) { - String s = stack.get(i); - if (!s.startsWith("//")) { - stack.remove(i); - return s; - } - } - return null; - } - - public String toASMSource(ConstantPool constants, MethodBody body, boolean hex) { - return toASMSource(constants, body, new ArrayList(), hex); - } - - public String toASMSource(ConstantPool constants, MethodBody body, List outputMap, boolean hex) { - invalidateCache(); - StringBuffer ret = new StringBuffer(); - String t = ""; - for (int e = 0; e < body.exceptions.length; e++) { - ret.append("exception " + e + " m[" + body.exceptions[e].name_index + "]\"" + Helper.escapeString(body.exceptions[e].getVarName(constants, new ArrayList())) + "\" " - + "m[" + body.exceptions[e].type_index + "]\"" + Helper.escapeString(body.exceptions[e].getTypeName(constants, new ArrayList())) + "\"\n"); - } - List offsets = new ArrayList(); - for (AVM2Instruction ins : code) { - offsets.addAll(ins.getOffsets()); - } - for (AVM2Instruction ins : code) { - if (ins.replaceWith != null) { - for (Object o : ins.replaceWith) { - if (o instanceof ControlFlowTag) { - ControlFlowTag cft = (ControlFlowTag) o; - if (cft.name.equals("appendjump")) { - offsets.add((long) pos2adr(cft.value)); - } - } - } - } - } - long ofs = 0; - int ip = 0; - int largeLimit = 20000; - boolean markOffsets = code.size() <= largeLimit; - for (AVM2Instruction ins : code) { - if (hex) { - ret.append(""); - ret.append(Helper.bytesToHexString(ins.getBytes())); - ret.append("\n"); - } - if (ins.labelname != null) { - ret.append(ins.labelname + ":"); - } else if (offsets.contains(ofs)) { - ret.append("ofs" + Helper.formatAddress(ofs) + ":"); - } - for (int e = 0; e < body.exceptions.length; e++) { - if (body.exceptions[e].start == ofs) { - ret.append("exceptionstart " + e + ":"); - } - if (body.exceptions[e].end == ofs) { - ret.append("exceptionend " + e + ":"); - } - if (body.exceptions[e].target == ofs) { - ret.append("exceptiontarget " + e + ":"); - } - } - if (ins.replaceWith != null) { - for (Object o : ins.replaceWith) { - if (o instanceof Integer) { - AVM2Instruction ins2 = code.get((Integer) o); - if (ins2.isIgnored()) { - continue; - } - t = Highlighting.hilighOffset("", ins2.mappedOffset > -1 ? ins2.mappedOffset : ofs) + ins2.toStringNoAddress(constants, new ArrayList()) + " ;copy from " + Helper.formatAddress(pos2adr((Integer) o)) + "\n"; - ret.append(t); - outputMap.add((Integer) o); - } else if (o instanceof ControlFlowTag) { - ControlFlowTag cft = (ControlFlowTag) o; - if (cft.name.equals("appendjump")) { - t = "jump ofs" + Helper.formatAddress(pos2adr(cft.value)) + "\n"; - ret.append(t); - outputMap.add(-1); - } - if (cft.name.equals("mark")) { - ret.append("ofs" + Helper.formatAddress(pos2adr(cft.value)) + ":"); - } - } - } - } else { - if (!ins.isIgnored()) { - t = ins.toStringNoAddress(constants, new ArrayList()); - if (ins.changeJumpTo > -1) { - t = ins.definition.instructionName + " ofs" + Helper.formatAddress(pos2adr(ins.changeJumpTo)); - } - if (markOffsets) { - t = Highlighting.hilighOffset("", ins.mappedOffset > -1 ? ins.mappedOffset : ofs) + t + "\n"; - } else { - t = t + "\n"; - } - ret.append(t); - outputMap.add(ip); - } - } - ofs += ins.getBytes().length; - ip++; - } - String r = ret.toString(); - return r; - } - private boolean cacheActual = false; - private List posCache; - - private void buildCache() { - posCache = new ArrayList(); - long a = 0; - for (int i = 0; i < code.size(); i++) { - posCache.add(a); - a += code.get(i).getBytes().length; - } - posCache.add(a); - cacheActual = true; - } - - public int adr2pos(long address) throws ConvertException { - if (!cacheActual) { - buildCache(); - } - int ret = posCache.indexOf(address); - if (ret == -1) { - throw new ConvertException("Bad jump try conver ofs" + Helper.formatAddress(address) + " ", -1); - } - return ret; - } - - public int pos2adr(int pos) { - if (!cacheActual) { - buildCache(); - } - return posCache.get(pos).intValue(); - } - - public void invalidateCache() { - cacheActual = false; - } - - private static String innerStackToString(List stack) { - String ret = ""; - for (int d = 0; d < stack.size(); d++) { - Object o = stack.get(d); - ret += o.toString(); - if (d < stack.size() - 1) { - if (!ret.endsWith("\r\n")) { - ret += "\r\n"; - } - } - } - return ret; - } - - private class Loop { - - public int loopContinue; - public int loopBreak; - public int continueCount = 0; - public int breakCount = 0; - - public Loop(int loopContinue, int loopBreak) { - this.loopContinue = loopContinue; - this.loopBreak = loopBreak; - } - } - private List loopList; - private List unknownJumps; - private List finallyJumps; - private List parsedExceptions; - private List ignoredIns; - - private String stripBrackets(String s) { - if (s.startsWith("(") && (s.endsWith(")"))) { - s = s.substring(1, s.length() - 1); - } - return s; - } - - private int checkCatches(ABC abc, ConstantPool constants, MethodInfo method_info[], Stack stack, Stack scopeStack, List output, MethodBody body, int ip) throws ConvertException { - /*int newip = ip; - loope: - for (int e = 0; e < body.exceptions.length; e++) { - if (pos2adr(ip) == body.exceptions[e].end) { - for (int f = 0; f < e; f++) { - if (body.exceptions[e].startServer == body.exceptions[f].startServer) { - if (body.exceptions[e].end == body.exceptions[f].end) { - continue loope; - } - } - } - output.add("}"); - if (!(code.get(ip).definition instanceof JumpIns)) { - throw new ConvertException("No jump to skip catches"); - } - int addrAfterCatches = pos2adr(ip + 1) + code.get(ip).operands[0]; - int posAfterCatches = adr2pos(addrAfterCatches); - for (int g = 0; g < body.exceptions.length; g++) { - if (body.exceptions[e].startServer == body.exceptions[g].startServer) { - if (body.exceptions[e].end == body.exceptions[g].end) { - if (body.exceptions[g].isFinally()) { - output.add("finally"); - } else { - output.add("catch(" + body.exceptions[g].getVarName(constants) + ":" + body.exceptions[g].getTypeName(constants) + ")"); - } - output.add("{"); - - if (body.exceptions[g].isFinally()) { - int jumppos = adr2pos(body.exceptions[g].target) - 1; - AVM2Instruction jumpIns = code.get(jumppos); - if (!(jumpIns.definition instanceof JumpIns)) { - throw new ConvertException("No jump in finally block"); - } - int nextAddr = pos2adr(jumppos + 1) + jumpIns.operands[0]; - int nextins = adr2pos(nextAddr); - int pos = nextins; - Integer uj = new Integer(nextins); - if (unknownJumps.contains(uj)) { - unknownJumps.remove(uj); - } - int endpos = 0; - do { - if (code.get(pos).definition instanceof LookupSwitchIns) { - if (code.get(pos).operands[0] == 0) { - if (adr2pos(pos2adr(pos) + code.get(pos).operands[2]) < pos) { - endpos = pos - 1; - newip = endpos + 1; - break; - } - } - } - pos++; - } while (pos < code.size()); - output.addAll(toSource(stack, scopeStack, abc, constants, method_info, body, nextins, endpos).output); - } else { - - int pos = adr2pos(body.exceptions[g].target); - int endpos = posAfterCatches - 1; - for (int p = pos; p < posAfterCatches; p++) { - if (code.get(p).definition instanceof JumpIns) { - int nextAddr = pos2adr(p + 1) + code.get(p).operands[0]; - int nextPos = adr2pos(nextAddr); - if (nextPos == posAfterCatches) { - endpos = p - 1; - break; - } - } - } - Stack cstack = new Stack(); - cstack.push("catched " + body.exceptions[g].getVarName(constants)); - List outcatch = toSource(cstack, new Stack(), abc, constants, method_info, body, pos, endpos).output; - output.addAll(outcatch); - newip = endpos + 1; - } - output.add("}"); - } - } - } - } - } - return newip;*/ - return ip; - } - boolean isCatched = false; - - public boolean isKilled(int regName, int start, int end) { - for (int k = start; k <= end; k++) { - if (code.get(k).definition instanceof KillIns) { - if (code.get(k).operands[0] == regName) { - return true; - } - } - } - return false; - } - private int toSourceCount = 0; - - private int ipOfType(int from, boolean up, Class search, Class skipped, int start, int end) { - if (up) { - for (int i = from; i >= start; i--) { - if (search.isInstance(code.get(i).definition)) { - return i; - } else if ((skipped != null) && skipped.isInstance(code.get(i).definition)) { - //skipped - } else { - return -1; - } - } - } else { - for (int i = from; i <= end; i++) { - if (search.isInstance(code.get(i).definition)) { - return i; - } else if ((skipped != null) && skipped.isInstance(code.get(i).definition)) { - //skipped - } else { - return -1; - } - } - - } - return -1; - } - - public HashMap getLocalRegNamesFromDebug(ABC abc) { - HashMap localRegNames = new HashMap(); - for (AVM2Instruction ins : code) { - if (ins.definition instanceof DebugIns) { - if (ins.operands[0] == 1) { - localRegNames.put(ins.operands[2] + 1, abc.constants.constant_string[ins.operands[1]]); - } - } - } - return localRegNames; - } - - public List clearTemporaryRegisters(List output) { - for (int i = 0; i < output.size(); i++) { - if (output.get(i) instanceof SetLocalTreeItem) { - if (isKilled(((SetLocalTreeItem) output.get(i)).regIndex, 0, code.size() - 1)) { - output.remove(i); - i--; - } - } else if (output.get(i) instanceof WithTreeItem) { - clearTemporaryRegisters(((WithTreeItem) output.get(i)).items); - } - } - return output; - } - - public int fixIPAfterDebugLine(int ip) { - if (ip >= code.size()) { - return code.size() - 1; - } - if (code.get(ip).definition instanceof DebugLineIns) { - return ip + 1; - } - return ip; - } - - public int fixAddrAfterDebugLine(int addr) throws ConvertException { - return pos2adr(fixIPAfterDebugLine(adr2pos(addr))); - } - - public ConvertOutput toSourceOutput(boolean processJumps, boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, int start, int end, HashMap localRegNames, List fullyQualifiedNames, boolean visited[]) throws ConvertException { - boolean debugMode = DEBUG_MODE; - if (debugMode) { - System.out.println("OPEN SubSource:" + start + "-" + end + " " + code.get(start).toString() + " to " + code.get(end).toString()); - } - if (visited == null) { - visited = new boolean[code.size()]; - } - //if(true) return ""; - toSourceCount++; - if (toSourceLimit > 0) { - if (toSourceCount > toSourceLimit) { - throw new ConvertException("Limit of subs(" + toSourceLimit + ") was reached", start); - } - } - List output = new ArrayList(); - String ret = ""; - int ip = start; - try { - int addr; - iploop: - while (ip <= end) { - - if (ignoredIns.contains(ip)) { - ip++; - continue; - } - boolean processTry = processJumps; - addr = pos2adr(ip); - int ipfix = fixIPAfterDebugLine(ip); - int addrfix = pos2adr(ipfix); - int maxend = -1; - if (processTry) { - List catchedExceptions = new ArrayList(); - for (int e = 0; e < body.exceptions.length; e++) { - if (addrfix == fixAddrAfterDebugLine(body.exceptions[e].start)) { - if (!body.exceptions[e].isFinally()) { - if ((fixAddrAfterDebugLine(body.exceptions[e].end) > maxend) && (!parsedExceptions.contains(body.exceptions[e]))) { - catchedExceptions.clear(); - maxend = fixAddrAfterDebugLine(body.exceptions[e].end); - catchedExceptions.add(body.exceptions[e]); - } else if (fixAddrAfterDebugLine(body.exceptions[e].end) == maxend) { - catchedExceptions.add(body.exceptions[e]); - } - } - } - } - if (catchedExceptions.size() > 0) { - ip = ipfix; - addr = addrfix; - parsedExceptions.addAll(catchedExceptions); - int endpos = adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(0).end)); - - - List> catchedCommands = new ArrayList>(); - if (code.get(endpos).definition instanceof JumpIns) { - int afterCatchAddr = pos2adr(endpos + 1) + code.get(endpos).operands[0]; - int afterCatchPos = adr2pos(afterCatchAddr); - Collections.sort(catchedExceptions, new Comparator() { - @Override - public int compare(ABCException o1, ABCException o2) { - try { - return fixAddrAfterDebugLine(o1.target) - fixAddrAfterDebugLine(o2.target); - } catch (ConvertException ex) { - return 0; - } - } - }); - - - List finallyCommands = new ArrayList(); - int returnPos = afterCatchPos; - for (int e = 0; e < body.exceptions.length; e++) { - if (body.exceptions[e].isFinally()) { - if (addr == fixAddrAfterDebugLine(body.exceptions[e].start)) { - if (afterCatchPos + 1 == adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end))) { - AVM2Instruction jmpIns = code.get(adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end))); - if (jmpIns.definition instanceof JumpIns) { - int finStart = adr2pos(fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]); - finallyJumps.add(finStart); - if (unknownJumps.contains(finStart)) { - unknownJumps.remove((Integer) finStart); - } - for (int f = finStart; f <= end; f++) { - if (code.get(f).definition instanceof LookupSwitchIns) { - AVM2Instruction swins = code.get(f); - if (swins.operands.length >= 3) { - if (swins.operands[0] == swins.getBytes().length) { - if (adr2pos(pos2adr(f) + swins.operands[2]) < finStart) { - finallyCommands = toSourceOutput(processJumps, isStatic, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, finStart, f - 1, localRegNames, fullyQualifiedNames, visited).output; - returnPos = f + 1; - break; - } - } - } - } - } - - break; - } - } - } - } - } - - for (int e = 0; e < catchedExceptions.size(); e++) { - int eendpos; - if (e < catchedExceptions.size() - 1) { - eendpos = adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(e + 1).target)) - 2; - } else { - eendpos = afterCatchPos - 1; - } - Stack substack = new Stack(); - substack.add(new ExceptionTreeItem(catchedExceptions.get(e))); - catchedCommands.add(toSourceOutput(processJumps, isStatic, classIndex, localRegs, substack, new Stack(), abc, constants, method_info, body, adr2pos(fixAddrAfterDebugLine(catchedExceptions.get(e).target)), eendpos, localRegNames, fullyQualifiedNames, visited).output); - } - - List tryCommands = toSourceOutput(processJumps, isStatic, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip, endpos - 1, localRegNames, fullyQualifiedNames, visited).output; - - - output.add(new TryTreeItem(tryCommands, catchedExceptions, catchedCommands, finallyCommands)); - ip = returnPos; - addr = pos2adr(ip); - } - - } - } - - if (ip > end) { - break; - } - - if (unknownJumps.contains(ip)) { - unknownJumps.remove(new Integer(ip)); - throw new UnknownJumpException(stack, ip, output); - } - if (visited[ip]) { - Logger.getLogger(AVM2Code.class.getName()).warning("Code already visited, ofs:" + Helper.formatAddress(pos2adr(ip)) + ", ip:" + ip); - break; - } - visited[ip] = true; - AVM2Instruction ins = code.get(ip); - if(debugMode){ - System.out.println("translating ip "+ip+" ins "+ins.toString()+" stack:"+Highlighting.stripHilights(stack.toString())+" scopeStack:"+Highlighting.stripHilights(scopeStack.toString())); - } - if(ins.definition instanceof NewFunctionIns){ - if(ip+1<=end){ - if(code.get(ip+1).definition instanceof PopIns){ - ip+=2; - continue; - } - } - } - if ((ip + 8 < code.size())) { //return in finally clause - if (ins.definition instanceof SetLocalTypeIns) { - if (code.get(ip + 1).definition instanceof PushByteIns) { - AVM2Instruction jmp = code.get(ip + 2); - if (jmp.definition instanceof JumpIns) { - if (jmp.operands[0] == 0) { - if (code.get(ip + 3).definition instanceof LabelIns) { - if (code.get(ip + 4).definition instanceof PopIns) { - if (code.get(ip + 5).definition instanceof LabelIns) { - AVM2Instruction gl = code.get(ip + 6); - if (gl.definition instanceof GetLocalTypeIns) { - if (((GetLocalTypeIns) gl.definition).getRegisterId(gl) == ((SetLocalTypeIns) ins.definition).getRegisterId(ins)) { - AVM2Instruction ki = code.get(ip + 7); - if (ki.definition instanceof KillIns) { - if (ki.operands[0] == ((SetLocalTypeIns) ins.definition).getRegisterId(ins)) { - if (code.get(ip + 8).definition instanceof ReturnValueIns) { - ip = ip + 8; - continue; - } - } - } - } - } - } - } - } - } - } - } - } - } - - /*if ((ip + 2 < code.size()) && (ins.definition instanceof NewCatchIns)) { //Filling local register in catch clause - if (code.get(ip + 1).definition instanceof DupIns) { - if (code.get(ip + 2).definition instanceof SetLocalTypeIns) { - ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames); - ip += 3; - continue; - } - } - }*/ - if ((ins.definition instanceof GetLocalTypeIns) && (!output.isEmpty()) && (output.get(output.size() - 1) instanceof SetLocalTreeItem) && (((SetLocalTreeItem) output.get(output.size() - 1)).regIndex == ((GetLocalTypeIns) ins.definition).getRegisterId(ins)) && isKilled(((SetLocalTreeItem) output.get(output.size() - 1)).regIndex, start, end)) { - SetLocalTreeItem slt = (SetLocalTreeItem) output.remove(output.size() - 1); - stack.push(slt.getValue()); - ip++; - } else if ((ins.definition instanceof SetLocalTypeIns) && (ip + 1 <= end) && (isKilled(((SetLocalTypeIns) ins.definition).getRegisterId(ins), ip, end))) { //set_local_x,get_local_x..kill x - AVM2Instruction insAfter = code.get(ip + 1); - if ((insAfter.definition instanceof GetLocalTypeIns) && (((GetLocalTypeIns) insAfter.definition).getRegisterId(insAfter) == ((SetLocalTypeIns) ins.definition).getRegisterId(ins))) { - GraphTargetItem before = stack.peek(); - ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames); - stack.push(before); - ip += 2; - continue iploop; - } else { - ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames); - ip++; - continue iploop; - } - } else if (ins.definition instanceof DupIns) { - int nextPos; - do { - AVM2Instruction insAfter = code.get(ip + 1); - AVM2Instruction insBefore = ins; - if (ip - 1 >= start) { - insBefore = code.get(ip - 1); - } - if (insAfter.definition instanceof ConvertBIns) { //SWF compiled with debug contain convert_b - ip++; - addr = pos2adr(ip); - insAfter = code.get(ip + 1); - } - - boolean isAnd; - if (processJumps && (insAfter.definition instanceof IfFalseIns)) { - //stack.add("(" + stack.pop() + ")&&"); - isAnd = true; - } else if (processJumps && (insAfter.definition instanceof IfTrueIns)) { - //stack.add("(" + stack.pop() + ")||"); - isAnd = false; - } else if (insAfter.definition instanceof SetLocalTypeIns) { - //chained assignments - int reg = (((SetLocalTypeIns) insAfter.definition).getRegisterId(insAfter)); - for (int t = ip + 1; t <= end - 1; t++) { - if (code.get(t).definition instanceof KillIns) { - if (code.get(t).operands[0] == reg) { - break; - } - } - if (code.get(t).definition instanceof GetLocalTypeIns) { - if (((GetLocalTypeIns) code.get(t).definition).getRegisterId(code.get(t)) == reg) { - if (code.get(t + 1).definition instanceof KillIns) { - if (code.get(t + 1).operands[0] == reg) { - ConvertOutput assignment = toSourceOutput(processJumps, isStatic, classIndex, localRegs, stack, scopeStack, abc, constants, method_info, body, ip + 2, t - 1, localRegNames, fullyQualifiedNames, visited); - stack.push(assignment.output.remove(assignment.output.size() - 1)); - ip = t + 2; - continue iploop; - } - } - } - } - } - if (!isKilled(reg, 0, end)) { - for (int i = ip; i >= start; i--) { - if (code.get(i).definition instanceof DupIns) { - GraphTargetItem v = stack.pop(); - stack.push(new LocalRegTreeItem(ins, reg, v)); - stack.push(v); - } else { - break; - } - } - } else { - ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames); - } - ip++; - break; - //} - - } else { - ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames); - ip++; - break; - //throw new ConvertException("Unknown pattern after DUP:" + insComparsion.toString()); - } - } while (ins.definition instanceof DupIns); - } else if ((ins.definition instanceof ReturnValueIns) || (ins.definition instanceof ReturnVoidIns) || (ins.definition instanceof ThrowIns)) { - ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames); - ip = end + 1; - break; - } else if (ins.definition instanceof NewFunctionIns) { - String functionName = ""; - if ((ip >= start + 2) && (ip <= end - 4)) { - AVM2Instruction prev2 = code.get(ip - 2); - if (prev2.definition instanceof NewObjectIns) { - if (prev2.operands[0] == 0) { - if (code.get(ip - 1).definition instanceof PushWithIns) { - boolean hasDup = false; - int plus = 0; - if (code.get(ip + 1).definition instanceof DupIns) { - hasDup = true; - plus = 1; - } - AVM2Instruction psco = code.get(ip + 1 + plus); - if (psco.definition instanceof GetScopeObjectIns) { - if (psco.operands[0] == scopeStack.size() - 1) { - if (code.get(ip + plus + 2).definition instanceof SwapIns) { - if (code.get(ip + plus + 4).definition instanceof PopScopeIns) { - if (code.get(ip + plus + 3).definition instanceof SetPropertyIns) { - functionName = abc.constants.constant_multiname[code.get(ip + plus + 3).operands[0]].getName(constants, fullyQualifiedNames); - scopeStack.pop();//with - output.remove(output.size() - 1); //with - ip = ip + plus + 4; //+1 below - } - } - } - } - } - } - } - } - } - //What to do when hasDup is false? - ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames); - NewFunctionTreeItem nft = (NewFunctionTreeItem) stack.peek(); - nft.functionName = functionName; - ip++; - } else { - ins.definition.translate(isStatic, classIndex, localRegs, stack, scopeStack, constants, ins, method_info, output, body, abc, localRegNames, fullyQualifiedNames); - - ip++; - addr = pos2adr(ip); - } - - } - if (debugMode) { - System.out.println("CLOSE SubSource:" + start + "-" + end + " " + code.get(start).toString() + " to " + code.get(end).toString()); - } - /*if (hideTemporaryRegisters) { - clearTemporaryRegisters(output); - }*/ - return new ConvertOutput(stack, output); - } catch (ConvertException cex) { - throw cex; - } - } - - public String tabString(int len) { - String ret = ""; - for (int i = 0; i < len; i++) { - ret += ABC.IDENT_STRING; - } - return ret; - } - - public String toSource(String path, boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, HashMap localRegNames, Stack scopeStack, boolean isStaticInitializer, List fullyQualifiedNames, Traits initTraits) { - return toSource(path, isStatic, classIndex, abc, constants, method_info, body, false, localRegNames, scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits); - } - - public int getRegisterCount() { - int maxRegister = -1; - for (AVM2Instruction ins : code) { - int regId = -1; - if (ins.definition instanceof SetLocalTypeIns) { - regId = ((SetLocalTypeIns) ins.definition).getRegisterId(ins); - } - if (ins.definition instanceof GetLocalTypeIns) { - regId = ((GetLocalTypeIns) ins.definition).getRegisterId(ins); - } - if (regId > maxRegister) { - maxRegister = regId; - } - } - return maxRegister + 1; - } - - public HashMap getLocalRegTypes(ConstantPool constants, List fullyQualifiedNames) { - HashMap ret = new HashMap(); - AVM2Instruction prev = null; - for (AVM2Instruction ins : code) { - if (ins.definition instanceof SetLocalTypeIns) { - if (prev != null) { - if (prev.definition instanceof CoerceOrConvertTypeIns) { - ret.put(((SetLocalTypeIns) ins.definition).getRegisterId(ins), ((CoerceOrConvertTypeIns) prev.definition).getTargetType(constants, prev, fullyQualifiedNames)); - } - } - } - prev = ins; - } - return ret; - } - - private class Slot { - - public GraphTargetItem scope; - public Multiname multiname; - - public Slot(GraphTargetItem scope, Multiname multiname) { - this.scope = scope; - this.multiname = multiname; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof Slot) { - return (((Slot) obj).scope.getThroughRegister() == scope.getThroughRegister()) - && (((Slot) obj).multiname == multiname); - } - return false; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 59 * hash + (this.scope != null ? this.scope.hashCode() : 0); - hash = 59 * hash + (this.multiname != null ? this.multiname.hashCode() : 0); - return hash; - } - } - - public void initToSource() { - toSourceCount = 0; - loopList = new ArrayList(); - unknownJumps = new ArrayList(); - finallyJumps = new ArrayList(); - parsedExceptions = new ArrayList(); - ignoredIns = new ArrayList(); - } - - public String toSource(String path, boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], MethodBody body, boolean hilighted, HashMap localRegNames, Stack scopeStack, boolean isStaticInitializer, List fullyQualifiedNames, Traits initTraits) { - initToSource(); - List list; - String s; - HashMap localRegs = new HashMap(); - - int regCount = getRegisterCount(); - int paramCount; - if (body.method_info != -1) { - MethodInfo mi = method_info[body.method_info]; - paramCount = mi.param_types.length; - if (mi.flagNeed_rest()) { - paramCount++; - } - } - - //try { - - try { - list = AVM2Graph.translateViaGraph(path, this, abc, body, isStatic, classIndex, localRegs, scopeStack, localRegNames, fullyQualifiedNames); - } catch (Exception ex2) { - Logger.getLogger(AVM2Code.class.getName()).log(Level.SEVERE, "Decompilation error in " + path, ex2); - return "/*\r\n * Decompilation error\r\n * Code may be obfuscated\r\n * Error Message: " + ex2.getMessage() + "\r\n */"; - } - /*try{ - list=toSourceOutput(true,isStatic, classIndex, localRegs, new Stack(), scopeStack, abc, constants, method_info, body, 0, code.size() - 1, localRegNames, fullyQualifiedNames, null).output; - }catch(Exception ex){ - - }*/ - if (initTraits != null) { - for (int i = 0; i < list.size(); i++) { - GraphTargetItem ti = list.get(i); - if ((ti instanceof InitPropertyTreeItem) || (ti instanceof SetPropertyTreeItem)) { - int multinameIndex = 0; - GraphTargetItem value = null; - if (ti instanceof InitPropertyTreeItem) { - multinameIndex = ((InitPropertyTreeItem) ti).propertyName.multinameIndex; - value = ((InitPropertyTreeItem) ti).value; - } - if (ti instanceof SetPropertyTreeItem) { - multinameIndex = ((SetPropertyTreeItem) ti).propertyName.multinameIndex; - value = ((SetPropertyTreeItem) ti).value; - } - for (Trait t : initTraits.traits) { - if (t.name_index == multinameIndex) { - if ((t instanceof TraitSlotConst)) { - if (((TraitSlotConst) t).isConst() || isStaticInitializer) { - ((TraitSlotConst) t).assignedValue = value; - list.remove(i); - i--; - continue; - } - break; - } - } - } - } else { - //In obfuscated code, SetLocal instructions comes first - //break; - } - } - } - if (isStaticInitializer) { - List newList = new ArrayList(); - for (GraphTargetItem ti : list) { - if (!(ti instanceof ReturnVoidTreeItem)) { - if (!(ti instanceof InitPropertyTreeItem)) { - if (!(ti instanceof SetPropertyTreeItem)) { - newList.add(ti); - } - } - } - } - list = newList; - if (list.isEmpty()) { - return ""; - } - } - //Declarations - boolean declaredRegisters[] = new boolean[regCount]; - for (int b = 0; b < declaredRegisters.length; b++) { - declaredRegisters[b] = false; - } - List declaredSlots = new ArrayList(); - for (int i = 0; i < list.size(); i++) { - GraphTargetItem ti = list.get(i); - if (ti instanceof SetLocalTreeItem) { - int reg = ((SetLocalTreeItem) ti).regIndex; - if (!declaredRegisters[reg]) { - list.set(i, new DeclarationTreeItem(ti)); - declaredRegisters[reg] = true; - } - } - if (ti instanceof SetSlotTreeItem) { - SetSlotTreeItem ssti = (SetSlotTreeItem) ti; - Slot sl = new Slot(ssti.scope, ssti.slotName); - if (!declaredSlots.contains(sl)) { - String type = "*"; - for (int t = 0; t < body.traits.traits.length; t++) { - if (body.traits.traits[t].getName(abc) == sl.multiname) { - if (body.traits.traits[t] instanceof TraitSlotConst) { - type = ((TraitSlotConst) body.traits.traits[t]).getType(constants, fullyQualifiedNames); - } - } - } - list.set(i, new DeclarationTreeItem(ti, type)); - declaredSlots.add(sl); - } - } - } - - s = Graph.graphToString(list, constants, localRegNames, fullyQualifiedNames); - if (!hilighted) { - return Highlighting.stripHilights(s); - } - - return s; - } - - public void removeInstruction(int pos, MethodBody body) { - if ((pos < 0) || (pos >= code.size())) { - throw new IndexOutOfBoundsException(); - } - int byteCount = code.get(pos).getBytes().length; - long remOffset = code.get(pos).offset; - for (int i = pos + 1; i < code.size(); i++) { - code.get(i).offset -= byteCount; - } - - for (ABCException ex : body.exceptions) { - if (ex.start > remOffset) { - ex.start -= byteCount; - } - if (ex.end > remOffset) { - ex.end -= byteCount; - } - if (ex.target > remOffset) { - ex.target -= byteCount; - } - } - - - for (int i = 0; i < pos; i++) { - if (code.get(i).definition instanceof LookupSwitchIns) { - long target = code.get(i).offset + code.get(i).operands[0]; - if (target > remOffset) { - code.get(i).operands[0] -= byteCount; - } - for (int k = 2; k < code.get(i).operands.length; k++) { - target = code.get(i).offset + code.get(i).operands[k]; - if (target > remOffset) { - code.get(i).operands[k] -= byteCount; - } - } - } else { - for (int j = 0; j < code.get(i).definition.operands.length; j++) { - if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { - long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; - if (target > remOffset) { - code.get(i).operands[j] -= byteCount; - } - } - } - } - } - for (int i = pos + 1; i < code.size(); i++) { - if (code.get(i).definition instanceof LookupSwitchIns) { - long target = code.get(i).offset + code.get(i).operands[0]; - if (target < remOffset) { - code.get(i).operands[0] += byteCount; - } - for (int k = 2; k < code.get(i).operands.length; k++) { - target = code.get(i).offset + code.get(i).operands[k]; - if (target < remOffset) { - code.get(i).operands[k] += byteCount; - } - } - } else { - for (int j = 0; j < code.get(i).definition.operands.length; j++) { - if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { - long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; - if (target < remOffset) { - code.get(i).operands[j] += byteCount; - } - } - } - } - } - - code.remove(pos); - invalidateCache(); - } - - public void insertInstruction(int pos, AVM2Instruction instruction) { - if (pos < 0) { - pos = 0; - } - if (pos > code.size()) { - pos = code.size(); - } - int byteCount = instruction.getBytes().length; - if (pos == code.size()) { - instruction.offset = code.get(pos - 1).offset + code.get(pos - 1).getBytes().length; - } else { - instruction.offset = code.get(pos).offset; - } - - for (int i = 0; i < pos; i++) { - for (int j = 0; j < code.get(i).definition.operands.length; j++) { - if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { - long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; - if (target >= instruction.offset) { - code.get(i).operands[j] += byteCount; - } - } - } - } - for (int i = pos; i < code.size(); i++) { - for (int j = 0; j < code.get(i).definition.operands.length; j++) { - if (code.get(i).definition.operands[j] == AVM2Code.DAT_OFFSET) { - long target = code.get(i).offset + code.get(i).getBytes().length + code.get(i).operands[j]; - if (target < instruction.offset) { - code.get(i).operands[j] -= byteCount; - } - } - } - } - - for (int i = pos + 1; i < code.size(); i++) { - code.get(i).offset += byteCount; - } - code.add(pos, instruction); - } - - public int removeTraps(ConstantPool constants, MethodBody body, ABC abc) { - - removeDeadCode(constants, body); - /* boolean isSecure = true; - try { - if (code.size() > 4) { - AVM2Instruction first = code.get(0); - AVM2Instruction second = code.get(1); - boolean firstValue = false; - boolean secondValue = false; - if (first.definition instanceof PushFalseIns) { - firstValue = false; - } else if (first.definition instanceof PushTrueIns) { - firstValue = true; - } else { - isSecure = false; - } - if (isSecure) { - if (second.definition instanceof PushFalseIns) { - secondValue = false; - } else if (second.definition instanceof PushTrueIns) { - secondValue = true; - } else { - isSecure = false; - } - if (isSecure) { - int pos = 2; - AVM2Instruction third = code.get(pos); - if (third.definition instanceof SwapIns) { - pos++; - boolean dup = firstValue; - firstValue = secondValue; - secondValue = dup; - third.ignored = true; - } - while (third.definition instanceof JumpIns) { - pos = adr2pos(pos2adr(pos) + third.getBytes().length + third.operands[0]); - third = code.get(pos); - } - AVM2Instruction firstSet = code.get(pos); - while (firstSet.definition instanceof JumpIns) { - pos = adr2pos(pos2adr(pos) + firstSet.getBytes().length + firstSet.operands[0]); - firstSet = code.get(pos); - } - pos++; - AVM2Instruction secondSet = code.get(pos); - while (secondSet.definition instanceof JumpIns) { - pos = adr2pos(pos2adr(pos) + secondSet.getBytes().length + secondSet.operands[0]); - secondSet = code.get(pos); - } - int trueIndex = -1; - int falseIndex = -1; - if (firstSet.definition instanceof SetLocalTypeIns) { - if (secondValue == true) { - trueIndex = ((SetLocalTypeIns) firstSet.definition).getRegisterId(firstSet); - } - if (secondValue == false) { - falseIndex = ((SetLocalTypeIns) firstSet.definition).getRegisterId(firstSet); - } - } else { - isSecure = false; - } - if (isSecure) { - if (secondSet.definition instanceof SetLocalTypeIns) { - if (firstValue == true) { - trueIndex = ((SetLocalTypeIns) secondSet.definition).getRegisterId(secondSet); - } - if (firstValue == false) { - falseIndex = ((SetLocalTypeIns) secondSet.definition).getRegisterId(secondSet); - } - secondSet.ignored = true; - firstSet.ignored = true; - first.ignored = true; - second.ignored = true; - boolean found; - do { - found = false; - for (int ip = 0; ip < code.size(); ip++) { - if (code.get(ip).ignored) { - continue; - } - if (code.get(ip).definition instanceof GetLocalTypeIns) { - int regIndex = ((GetLocalTypeIns) code.get(ip).definition).getRegisterId(code.get(ip)); - if ((regIndex == trueIndex) || (regIndex == falseIndex)) { - found = true; - Stack myStack = new Stack(); - do { - AVM2Instruction ins = code.get(ip); - if (ins.definition instanceof GetLocalTypeIns) { - regIndex = ((GetLocalTypeIns) ins.definition).getRegisterId(ins); - if (regIndex == trueIndex) { - myStack.push(true); - } - if (regIndex == falseIndex) { - myStack.push(false); - } - ip++; - ins.ignored = true; - } else if (ins.definition instanceof DupIns) { - Boolean b = myStack.pop(); - myStack.push(b); - myStack.push(b); - ins.ignored = true; - ip++; - } else if (ins.definition instanceof PopIns) { - myStack.pop(); - ins.ignored = true; - ip++; - } else if (ins.definition instanceof IfTrueIns) { - boolean val = myStack.pop(); - if (val) { - code.get(ip).definition = new JumpIns(); - ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); - } else { - code.get(ip).ignored = true; - ip++; - } - } else if (ins.definition instanceof IfFalseIns) { - boolean val = myStack.pop(); - if (!val) { - code.get(ip).definition = new JumpIns(); - ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); - } else { - code.get(ip).ignored = true; - ip++; - } - } else if (ins.definition instanceof JumpIns) { - ip = adr2pos(pos2adr(ip + 1) + code.get(ip).operands[0]); - } else { - ip++; - } - - } while (myStack.size() > 0 && ip < code.size()); - - break; - } - - } - } - } while (found); - removeIgnored(constants, body); - removeDeadCode(constants, body); - } else { - //isSecure = false; - } - } - - } - } - } - } catch (ConvertException cex) { - } - int ret = isSecure ? 1 : 0; - ret += visitCodeTrap(body, new int[code.size()]);*/ - - //definition.translate((Boolean) localData.get(0), (Integer) localData.get(1), - //(HashMap) localData.get(2), stack, - //(Stack) localData.get(3), (ConstantPool) localData.get(4), this, - //(MethodInfo[]) localData.get(5), output, - //(MethodBody) localData.get(6), (ABC) localData.get(7), - //(HashMap) localData.get(8), (List) localData.get(8)); - - List localData = new ArrayList(); - localData.add((Boolean) false); //isStatic - localData.add((Integer) 0); //classIndex - localData.add(new HashMap()); - localData.add(new Stack()); - localData.add(abc.constants); - localData.add(abc.method_info); - localData.add(body); - localData.add(abc); - localData.add(new HashMap()); //localRegNames - localData.add(new ArrayList()); //fullyQualifiedNames - localData.add(new ArrayList()); - localData.add(new ArrayList()); - localData.add(new ArrayList()); - int ret = 0; - ret += removeTraps(localData, new AVM2GraphSource(this, false, 0, new HashMap(), new Stack(), abc, body, new HashMap(), new ArrayList()), 0); - removeIgnored(constants, body); - removeDeadCode(constants, body); - - return ret; - } - - private void handleRegister(CodeStats stats, int reg) { - if (reg + 1 > stats.maxlocal) { - stats.maxlocal = reg + 1; - } - } - - private boolean walkCode(CodeStats stats, int pos, int stack, int scope, ABC abc) { - while (pos < code.size()) { - if (stats.instructionStats[pos].seen) { - //check stack mismatch here - return true; - } - stats.instructionStats[pos].seen = true; - stats.instructionStats[pos].stackpos = stack; - stats.instructionStats[pos].scopepos = scope; - AVM2Instruction ins = code.get(pos); - stack += ins.definition.getStackDelta(ins, abc); - scope += ins.definition.getScopeStackDelta(ins, abc); - if (stack > stats.maxstack) { - stats.maxstack = stack; - } - if (scope > stats.maxscope) { - stats.maxscope = scope; - } - if ((ins.definition instanceof DXNSIns) || (ins.definition instanceof DXNSLateIns)) { - stats.has_set_dxns = true; - } - if (ins.definition instanceof NewActivationIns) { - stats.has_activation = true; - } - if (ins.definition instanceof SetLocalTypeIns) { - handleRegister(stats, ((SetLocalTypeIns) ins.definition).getRegisterId(ins)); - } else { - for (int i = 0; i < ins.definition.operands.length; i++) { - if (ins.definition.operands[i] == DAT_REGISTER_INDEX) { - handleRegister(stats, ins.operands[i]); - } - } - } - if (ins.definition instanceof ReturnValueIns) { - //check stack=1 - return true; - } - if (ins.definition instanceof ReturnVoidIns) { - //check stack=0 - return true; - } - if (ins.definition instanceof JumpIns) { - try { - pos = adr2pos(pos2adr(pos) + ins.getBytes().length + ins.operands[0]); - continue; - } catch (ConvertException ex) { - return false; - } - } else if (ins.definition instanceof IfTypeIns) { - try { - int newpos = adr2pos(pos2adr(pos) + ins.getBytes().length + ins.operands[0]); - walkCode(stats, newpos, stack, scope, abc); - } catch (ConvertException ex) { - return false; - } - } - if (ins.definition instanceof LookupSwitchIns) { - for (int i = 0; i < ins.operands.length; i++) { - try { - int newpos = adr2pos(pos2adr(pos) + ins.operands[i]); - if (!walkCode(stats, newpos, stack, scope, abc)) { - return false; - } - } catch (ConvertException ex) { - return false; - } - } - } - pos++; - } - return true; - } - - public CodeStats getStats(ABC abc, MethodBody body) { - CodeStats stats = new CodeStats(this); - if (!walkCode(stats, 0, 0, 0, abc)) { - return null; - } - for (ABCException ex : body.exceptions) { - try { - int exStart = adr2pos(ex.start); - if (!walkCode(stats, adr2pos(ex.target), stats.instructionStats[exStart].stackpos, stats.instructionStats[exStart].scopepos, abc)) { - return null; - } - } catch (ConvertException ex1) { - } - } - return stats; - } - - private void visitCode(int ip, int lastIp, HashMap> refs) { - while (ip < code.size()) { - refs.get(ip).add(lastIp); - lastIp = ip; - if (refs.get(ip).size() > 1) { - break; - } - AVM2Instruction ins = code.get(ip); - if (ins.definition instanceof ThrowIns) { - break; - } - if (ins.definition instanceof ReturnValueIns) { - break; - } - if (ins.definition instanceof ReturnVoidIns) { - break; - } - if (ins.definition instanceof LookupSwitchIns) { - try { - for (int i = 2; i < ins.operands.length; i++) { - visitCode(adr2pos(pos2adr(ip) + ins.operands[i]), ip, refs); - } - ip = adr2pos(pos2adr(ip) + ins.operands[0]); - continue; - } catch (ConvertException ex) { - } - } - if (ins.definition instanceof JumpIns) { - try { - ip = adr2pos(pos2adr(ip) + ins.getBytes().length + ins.operands[0]); - continue; - } catch (ConvertException ex) { - Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); - } - } else if (ins.definition instanceof IfTypeIns) { - try { - visitCode(adr2pos(pos2adr(ip) + ins.getBytes().length + ins.operands[0]), ip, refs); - } catch (ConvertException ex) { - Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); - } - } - ip++; - }; - } - - public HashMap> visitCode(MethodBody body) { - HashMap> refs = new HashMap>(); - for (int i = 0; i < code.size(); i++) { - refs.put(i, new ArrayList()); - } - visitCode(0, 0, refs); - int pos = 0; - for (ABCException e : body.exceptions) { - pos++; - try { - visitCode(adr2pos(e.start), -pos, refs); - visitCode(adr2pos(e.target), -pos, refs); - visitCode(adr2pos(e.end), -pos, refs); - } catch (ConvertException ex) { - Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); - } - } - return refs; - } - - private int visitCodeTrap(int ip, int visited[], AVM2Instruction prev, AVM2Instruction prev2) { - int ret = 0; - while (ip < visited.length) { - visited[ip]++; - if (visited[ip] > 1) { - break; - } - AVM2Instruction ins = code.get(ip); - if (ins.definition instanceof ThrowIns) { - break; - } - if (ins.definition instanceof ReturnValueIns) { - break; - } - if (ins.definition instanceof ReturnVoidIns) { - break; - } - if (ins.definition instanceof LookupSwitchIns) { - try { - for (int i = 2; i < ins.operands.length; i++) { - ret += visitCodeTrap(adr2pos(pos2adr(ip) + ins.operands[i]), visited, prev, prev2); - } - ip = adr2pos(pos2adr(ip) + ins.operands[0]); - prev2 = prev; - prev = ins; - continue; - } catch (ConvertException ex) { - } - } - if (ins.definition instanceof JumpIns) { - try { - ip = adr2pos(pos2adr(ip) + ins.getBytes().length + ins.operands[0]); - prev2 = prev; - prev = ins; - continue; - } catch (ConvertException ex) { - Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); - } - } else if (ins.definition instanceof IfTypeIns) { - if ((prev != null) && (prev2 != null)) { - if ((prev.definition instanceof PushByteIns) && (prev2.definition instanceof PushByteIns)) { - if (ins.definition instanceof IfEqIns) { - prev.ignored = true; - prev2.ignored = true; - if (prev.operands[0] == prev2.operands[0]) { - ins.definition = new JumpIns(); - visited[ip]--; - } else { - ins.ignored = true; - ip++; - } - ret++; - continue; - } - if (ins.definition instanceof IfNeIns) { - prev.ignored = true; - prev2.ignored = true; - if (prev.operands[0] != prev2.operands[0]) { - ins.definition = new JumpIns(); - visited[ip]--; - } else { - ins.ignored = true; - ip++; - } - ret++; - continue; - } - } - } - if ((prev != null) && ins.definition instanceof IfTrueIns) { - if (prev.definition instanceof PushTrueIns) { - prev.ignored = true; - ins.definition = new JumpIns(); - visited[ip]--; - ret++; - continue; - } else if (prev.definition instanceof PushFalseIns) { - prev.ignored = true; - ins.ignored = true; - ret++; - ip++; - continue; - } - } - if ((prev != null) && ins.definition instanceof IfFalseIns) { - if (prev.definition instanceof PushFalseIns) { - prev.ignored = true; - ins.definition = new JumpIns(); - visited[ip]--; - ret++; - continue; - } else if (prev.definition instanceof PushTrueIns) { - prev.ignored = true; - ins.ignored = true; - ret++; - ip++; - continue; - } - } - try { - ret += visitCodeTrap(adr2pos(pos2adr(ip) + ins.getBytes().length + ins.operands[0]), visited, prev, prev2); - } catch (ConvertException ex) { - Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); - } - } - ip++; - prev2 = prev; - prev = ins; - }; - return ret; - } - - private int visitCodeTrap(MethodBody body, int visited[]) { - int ret = 0; - for (int i = 0; i < visited.length; i++) { - visited[i] = 0; - } - ret += visitCodeTrap(0, visited, null, null); - for (ABCException e : body.exceptions) { - try { - ret += visitCodeTrap(adr2pos(e.start), visited, null, null); - ret += visitCodeTrap(adr2pos(e.target), visited, null, null); - ret += visitCodeTrap(adr2pos(e.end), visited, null, null); - } catch (ConvertException ex) { - Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); - } - } - return ret; - } - - private static class ControlFlowTag { - - public String name; - public int value; - - public ControlFlowTag(String name, int value) { - this.name = name; - this.value = value; - } - } - - public void restoreControlFlow(int ip, HashMap> refs, int visited2[], HashMap appended) throws ConvertException { - List buf = new ArrayList(); - boolean cont = false; - int continueip = 0; - AVM2Instruction prev = null; - for (; ip < code.size(); ip++) { - AVM2Instruction ins = code.get(ip); - - if ((refs.containsKey(ip) && refs.get(ip).size() > 1) || (visited2[ip] > 0)) { - if (cont) { - buf.add(new ControlFlowTag("appendjump", ip)); - } - cont = false; - if (visited2[ip] > 0) { - break; - } - } - visited2[ip]++; - if (ins.definition instanceof LookupSwitchIns) { - - if (cont) { - buf.add(new ControlFlowTag("appendjump", ip)); - } - cont = false; - restoreControlFlow(adr2pos(pos2adr(ip) + ins.operands[0]), refs, visited2, appended); - for (int i = 2; i < ins.operands.length; i++) { - restoreControlFlow(adr2pos(pos2adr(ip) + ins.operands[i]), refs, visited2, appended); - } - break; - } - if (ins.definition instanceof JumpIns) { - int newip = adr2pos(pos2adr(ip + 1) + ins.operands[0]); - - boolean allJumpsOrIfs = true; - for (int ref : refs.get(ip)) { - if (ref < 0) { - continue; - } - if (!(code.get(ref).definition instanceof JumpIns)) { - if (!(code.get(ref).definition instanceof IfTypeIns)) { - allJumpsOrIfs = false; - break; - } else { - if (adr2pos(pos2adr(ref + 1) + code.get(ref).operands[0]) != ip) { - allJumpsOrIfs = false; - break; - } - } - } - } - if (allJumpsOrIfs) { - for (int ref : refs.get(ip)) { - if (ref < 0) { - continue; - } - code.get(ref).changeJumpTo = newip; - } - } - if ((newip < code.size()) && (refs.containsKey(newip) && refs.get(newip).size() == 1)) { - if (!cont) { - continueip = ip; - buf = new ArrayList(); - appended.put(continueip, buf); - } - cont = true; - } else { - if (cont) { - buf.add(new ControlFlowTag("appendjump", newip)); - } - cont = false; - } - ip = newip - 1; - } else if (ins.definition instanceof IfTypeIns) { - int newip = adr2pos(pos2adr(ip + 1) + ins.operands[0]); - if (cont) { - buf.add(new ControlFlowTag("appendjump", ip)); - } - cont = false; - restoreControlFlow(newip, refs, visited2, appended); - } else if ((ins.definition instanceof ReturnVoidIns) || (ins.definition instanceof ReturnValueIns) || (ins.definition instanceof ThrowIns)) { - if (cont) { - buf.add(ip); - } - break; - } else if (cont) { - buf.add(ip); - } - prev = ins; - } - - } - - private void restoreControlFlowPass(ConstantPool constants, MethodBody body, boolean secondpass) { - try { - HashMap> refs; - int visited2[] = new int[code.size()]; - refs = visitCode(body); - HashMap appended = new HashMap(); - /*if (secondpass) { - restoreControlFlow(code.size() - 1, refs, visited2, appended); - } else*/ { - restoreControlFlow(0, refs, visited2, appended); - for (ABCException e : body.exceptions) { - try { - restoreControlFlow(adr2pos(e.start), refs, visited2, appended); - restoreControlFlow(adr2pos(e.target), refs, visited2, appended); - restoreControlFlow(adr2pos(e.end), refs, visited2, appended); - } catch (ConvertException ex) { - Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); - } - } - } - for (int ip : appended.keySet()) { - code.get(ip).replaceWith = appended.get(ip); - } - } catch (ConvertException cex) { - cex.printStackTrace(); - } - invalidateCache(); - try { - List outputMap = new ArrayList(); - String src = Highlighting.stripHilights(toASMSource(constants, body, outputMap, false)); - - AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(src.getBytes()), constants, null, body); - for (int i = 0; i < acode.code.size(); i++) { - if (outputMap.size() > i) { - int tpos = outputMap.get(i); - if (tpos == -1) { - } else if (code.get(tpos).mappedOffset >= 0) { - acode.code.get(i).mappedOffset = code.get(tpos).mappedOffset; - } else { - acode.code.get(i).mappedOffset = pos2adr(tpos); - } - - } - } - this.code = acode.code; - } catch (IOException ex) { - Logger.getLogger(AVM2Code.class.getName()).log(Level.SEVERE, null, ex); - } catch (ParseException ex) { - Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); - } - invalidateCache(); - removeDeadCode(constants, body); - } - - public void restoreControlFlow(ConstantPool constants, MethodBody body) { - restoreControlFlowPass(constants, body, false); - //restoreControlFlowPass(constants, body, true); - } - - /*private void removeIgnored(MethodBody body) { - for (int rem = code.size() - 1; rem >= 0; rem--) { - if (code.get(rem).ignored) { - removeInstruction(rem, body); + } + return true; } - } - }*/ - public void removeIgnored(ConstantPool constants, MethodBody body) { - try { - List outputMap = new ArrayList(); - String src = toASMSource(constants, body, outputMap, false); - AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(src.getBytes()), constants, body); - for (int i = 0; i < acode.code.size(); i++) { - if (outputMap.size() > i) { - int tpos = outputMap.get(i); - if (tpos == -1) { - } else if (code.get(tpos).mappedOffset >= 0) { - acode.code.get(i).mappedOffset = code.get(tpos).mappedOffset; - } else { - acode.code.get(i).mappedOffset = pos2adr(tpos); - } + + public CodeStats getStats(ABC abc, MethodBody body) { + CodeStats stats = new CodeStats(this); + if (!walkCode(stats, 0, 0, 0, abc)) { + return null; + } + for (ABCException ex : body.exceptions) { + try { + int exStart = adr2pos(ex.start); + if (!walkCode(stats, adr2pos(ex.target), stats.instructionStats[exStart].stackpos, stats.instructionStats[exStart].scopepos, abc)) { + return null; + } + } catch (ConvertException ex1) { } - } - this.code = acode.code; - } catch (Exception ex) { - } - invalidateCache(); - } + } + return stats; + } - public int removeDeadCode(ConstantPool constants, MethodBody body) { - HashMap> refs = visitCode(body); - - int cnt = 0; - for (int i = code.size() - 1; i >= 0; i--) { - if (refs.get(i).isEmpty()) { - code.get(i).ignored = true; - //removeInstruction(i, body); - cnt++; - } - } - - removeIgnored(constants, body); - for (int i = code.size() - 1; i >= 0; i--) { - AVM2Instruction ins = code.get(i); - if (ins.definition instanceof JumpIns) { - if (ins.operands[0] == 0) { - code.get(i).ignored = true; - //removeInstruction(i, body); - cnt++; + private void visitCode(int ip, int lastIp, HashMap> refs) { + while (ip < code.size()) { + refs.get(ip).add(lastIp); + lastIp = ip; + if (refs.get(ip).size() > 1) { + break; } - } - } - removeIgnored(constants, body); - return cnt; - } + AVM2Instruction ins = code.get(ip); + if (ins.definition instanceof ThrowIns) { + break; + } + if (ins.definition instanceof ReturnValueIns) { + break; + } + if (ins.definition instanceof ReturnVoidIns) { + break; + } + if (ins.definition instanceof LookupSwitchIns) { + try { + for (int i = 2; i < ins.operands.length; i++) { + visitCode(adr2pos(pos2adr(ip) + ins.operands[i]), ip, refs); + } + ip = adr2pos(pos2adr(ip) + ins.operands[0]); + continue; + } catch (ConvertException ex) { + } + } + if (ins.definition instanceof JumpIns) { + try { + ip = adr2pos(pos2adr(ip) + ins.getBytes().length + ins.operands[0]); + continue; + } catch (ConvertException ex) { + Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); + } + } else if (ins.definition instanceof IfTypeIns) { + try { + visitCode(adr2pos(pos2adr(ip) + ins.getBytes().length + ins.operands[0]), ip, refs); + } catch (ConvertException ex) { + Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); + } + } + ip++; + }; + } - public void markMappedOffsets() { - int ofs = 0; - for (int i = 0; i < code.size(); i++) { - code.get(i).mappedOffset = ofs; - ofs += code.get(i).getBytes().length; - } - } + public HashMap> visitCode(MethodBody body) { + HashMap> refs = new HashMap>(); + for (int i = 0; i < code.size(); i++) { + refs.put(i, new ArrayList()); + } + visitCode(0, 0, refs); + int pos = 0; + for (ABCException e : body.exceptions) { + pos++; + try { + visitCode(adr2pos(e.start), -pos, refs); + visitCode(adr2pos(e.target), -pos, refs); + visitCode(adr2pos(e.end), -pos, refs); + } catch (ConvertException ex) { + Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); + } + } + return refs; + } - public AVM2Code deepCopy() { - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos); - oos.writeObject(this); - oos.flush(); - oos.close(); - ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); - AVM2Code copy = (AVM2Code) ois.readObject(); - ois.close(); - return copy; - } catch (Exception ex) { - ex.printStackTrace(); - return null; - } - } + private int visitCodeTrap(int ip, int visited[], AVM2Instruction prev, AVM2Instruction prev2) { + int ret = 0; + while (ip < visited.length) { + visited[ip]++; + if (visited[ip] > 1) { + break; + } + AVM2Instruction ins = code.get(ip); + if (ins.definition instanceof ThrowIns) { + break; + } + if (ins.definition instanceof ReturnValueIns) { + break; + } + if (ins.definition instanceof ReturnVoidIns) { + break; + } + if (ins.definition instanceof LookupSwitchIns) { + try { + for (int i = 2; i < ins.operands.length; i++) { + ret += visitCodeTrap(adr2pos(pos2adr(ip) + ins.operands[i]), visited, prev, prev2); + } + ip = adr2pos(pos2adr(ip) + ins.operands[0]); + prev2 = prev; + prev = ins; + continue; + } catch (ConvertException ex) { + } + } + if (ins.definition instanceof JumpIns) { + try { + ip = adr2pos(pos2adr(ip) + ins.getBytes().length + ins.operands[0]); + prev2 = prev; + prev = ins; + continue; + } catch (ConvertException ex) { + Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); + } + } else if (ins.definition instanceof IfTypeIns) { + if ((prev != null) && (prev2 != null)) { + if ((prev.definition instanceof PushByteIns) && (prev2.definition instanceof PushByteIns)) { + if (ins.definition instanceof IfEqIns) { + prev.ignored = true; + prev2.ignored = true; + if (prev.operands[0] == prev2.operands[0]) { + ins.definition = new JumpIns(); + visited[ip]--; + } else { + ins.ignored = true; + ip++; + } + ret++; + continue; + } + if (ins.definition instanceof IfNeIns) { + prev.ignored = true; + prev2.ignored = true; + if (prev.operands[0] != prev2.operands[0]) { + ins.definition = new JumpIns(); + visited[ip]--; + } else { + ins.ignored = true; + ip++; + } + ret++; + continue; + } + } + } + if ((prev != null) && ins.definition instanceof IfTrueIns) { + if (prev.definition instanceof PushTrueIns) { + prev.ignored = true; + ins.definition = new JumpIns(); + visited[ip]--; + ret++; + continue; + } else if (prev.definition instanceof PushFalseIns) { + prev.ignored = true; + ins.ignored = true; + ret++; + ip++; + continue; + } + } + if ((prev != null) && ins.definition instanceof IfFalseIns) { + if (prev.definition instanceof PushFalseIns) { + prev.ignored = true; + ins.definition = new JumpIns(); + visited[ip]--; + ret++; + continue; + } else if (prev.definition instanceof PushTrueIns) { + prev.ignored = true; + ins.ignored = true; + ret++; + ip++; + continue; + } + } + try { + ret += visitCodeTrap(adr2pos(pos2adr(ip) + ins.getBytes().length + ins.operands[0]), visited, prev, prev2); + } catch (ConvertException ex) { + Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); + } + } + ip++; + prev2 = prev; + prev = ins; + }; + return ret; + } - private static int removeTraps(List localData, Stack stack, List output, AVM2GraphSource code, int ip, int lastIp, List visited) { - boolean debugMode = false; - int ret = 0; - while ((ip > -1) && ip < code.size()) { - if (visited.contains(ip)) { - break; - } - visited.add(ip); - lastIp = ip; - GraphSourceItem ins = code.get(ip); - if (debugMode) { - System.out.println("Visit " + ip + ": " + ins + " stack:" + Highlighting.stripHilights(stack.toString())); - } - if ((ins instanceof AVM2Instruction) && (((AVM2Instruction) ins).definition instanceof NewFunctionIns)) { - stack.push(new BooleanTreeItem(null, true)); - } else { - ins.translate(localData, stack, output); - } - if (ins.isExit()) { - break; - } + private int visitCodeTrap(MethodBody body, int visited[]) { + int ret = 0; + for (int i = 0; i < visited.length; i++) { + visited[i] = 0; + } + ret += visitCodeTrap(0, visited, null, null); + for (ABCException e : body.exceptions) { + try { + ret += visitCodeTrap(adr2pos(e.start), visited, null, null); + ret += visitCodeTrap(adr2pos(e.target), visited, null, null); + ret += visitCodeTrap(adr2pos(e.end), visited, null, null); + } catch (ConvertException ex) { + Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); + } + } + return ret; + } - if (ins.isBranch() || ins.isJump()) { - List branches = ins.getBranches(code); - if ((ins instanceof AVM2Instruction)&&((AVM2Instruction)ins).definition instanceof IfTypeIns - && (!(((AVM2Instruction)ins).definition instanceof JumpIns)) && (!stack.isEmpty()) && (stack.peek().isCompileTime())) { - boolean condition = stack.peek().toBoolean(); - if (debugMode) { - if (condition) { - System.out.println("JUMP"); - } else { - System.out.println("SKIP"); - } - } - if (condition) { - ((AVM2Instruction) ins).definition = new JumpIns(); - } else { - ins.setIgnored(true); - } - GraphTargetItem tar = stack.pop(); - for (GraphSourceItemPos pos : tar.getNeededSources()) { - if(pos.item!=ins){ - pos.item.setIgnored(true); - } - } + private static class ControlFlowTag { - ret += removeTraps(localData, stack, output, code, condition ? branches.get(0) : branches.get(1), ip, visited); + public String name; + public int value; + + public ControlFlowTag(String name, int value) { + this.name = name; + this.value = value; + } + } + + public void restoreControlFlow(int ip, HashMap> refs, int visited2[], HashMap appended) throws ConvertException { + List buf = new ArrayList(); + boolean cont = false; + int continueip = 0; + AVM2Instruction prev = null; + for (; ip < code.size(); ip++) { + AVM2Instruction ins = code.get(ip); + + if ((refs.containsKey(ip) && refs.get(ip).size() > 1) || (visited2[ip] > 0)) { + if (cont) { + buf.add(new ControlFlowTag("appendjump", ip)); + } + cont = false; + if (visited2[ip] > 0) { + break; + } + } + visited2[ip]++; + if (ins.definition instanceof LookupSwitchIns) { + + if (cont) { + buf.add(new ControlFlowTag("appendjump", ip)); + } + cont = false; + restoreControlFlow(adr2pos(pos2adr(ip) + ins.operands[0]), refs, visited2, appended); + for (int i = 2; i < ins.operands.length; i++) { + restoreControlFlow(adr2pos(pos2adr(ip) + ins.operands[i]), refs, visited2, appended); + } + break; + } + if (ins.definition instanceof JumpIns) { + int newip = adr2pos(pos2adr(ip + 1) + ins.operands[0]); + + boolean allJumpsOrIfs = true; + for (int ref : refs.get(ip)) { + if (ref < 0) { + continue; + } + if (!(code.get(ref).definition instanceof JumpIns)) { + if (!(code.get(ref).definition instanceof IfTypeIns)) { + allJumpsOrIfs = false; + break; + } else { + if (adr2pos(pos2adr(ref + 1) + code.get(ref).operands[0]) != ip) { + allJumpsOrIfs = false; + break; + } + } + } + } + if (allJumpsOrIfs) { + for (int ref : refs.get(ip)) { + if (ref < 0) { + continue; + } + code.get(ref).changeJumpTo = newip; + } + } + if ((newip < code.size()) && (refs.containsKey(newip) && refs.get(newip).size() == 1)) { + if (!cont) { + continueip = ip; + buf = new ArrayList(); + appended.put(continueip, buf); + } + cont = true; + } else { + if (cont) { + buf.add(new ControlFlowTag("appendjump", newip)); + } + cont = false; + } + ip = newip - 1; + } else if (ins.definition instanceof IfTypeIns) { + int newip = adr2pos(pos2adr(ip + 1) + ins.operands[0]); + if (cont) { + buf.add(new ControlFlowTag("appendjump", ip)); + } + cont = false; + restoreControlFlow(newip, refs, visited2, appended); + } else if ((ins.definition instanceof ReturnVoidIns) || (ins.definition instanceof ReturnValueIns) || (ins.definition instanceof ThrowIns)) { + if (cont) { + buf.add(ip); + } + break; + } else if (cont) { + buf.add(ip); + } + prev = ins; + } + + } + + private void restoreControlFlowPass(ConstantPool constants, MethodBody body, boolean secondpass) { + try { + HashMap> refs; + int visited2[] = new int[code.size()]; + refs = visitCode(body); + HashMap appended = new HashMap(); + /*if (secondpass) { + restoreControlFlow(code.size() - 1, refs, visited2, appended); + } else*/ { + restoreControlFlow(0, refs, visited2, appended); + for (ABCException e : body.exceptions) { + try { + restoreControlFlow(adr2pos(e.start), refs, visited2, appended); + restoreControlFlow(adr2pos(e.target), refs, visited2, appended); + restoreControlFlow(adr2pos(e.end), refs, visited2, appended); + } catch (ConvertException ex) { + Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); + } + } + } + for (int ip : appended.keySet()) { + code.get(ip).replaceWith = appended.get(ip); + } + } catch (ConvertException cex) { + cex.printStackTrace(); + } + invalidateCache(); + try { + List outputMap = new ArrayList(); + String src = Highlighting.stripHilights(toASMSource(constants, body, outputMap, false)); + + AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(src.getBytes("UTF-8")), constants, null, body); + for (int i = 0; i < acode.code.size(); i++) { + if (outputMap.size() > i) { + int tpos = outputMap.get(i); + if (tpos == -1) { + } else if (code.get(tpos).mappedOffset >= 0) { + acode.code.get(i).mappedOffset = code.get(tpos).mappedOffset; + } else { + acode.code.get(i).mappedOffset = pos2adr(tpos); + } + + } + } + this.code = acode.code; + } catch (IOException ex) { + Logger.getLogger(AVM2Code.class.getName()).log(Level.SEVERE, null, ex); + } catch (ParseException ex) { + Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); + } + invalidateCache(); + removeDeadCode(constants, body); + } + + public void restoreControlFlow(ConstantPool constants, MethodBody body) { + restoreControlFlowPass(constants, body, false); + //restoreControlFlowPass(constants, body, true); + } + + /*private void removeIgnored(MethodBody body) { + for (int rem = code.size() - 1; rem >= 0; rem--) { + if (code.get(rem).ignored) { + removeInstruction(rem, body); + } + } + }*/ + public void removeIgnored(ConstantPool constants, MethodBody body) { + try { + List outputMap = new ArrayList(); + String src = toASMSource(constants, body, outputMap, false); + AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(src.getBytes("UTF-8")), constants, body); + for (int i = 0; i < acode.code.size(); i++) { + if (outputMap.size() > i) { + int tpos = outputMap.get(i); + if (tpos == -1) { + } else if (code.get(tpos).mappedOffset >= 0) { + acode.code.get(i).mappedOffset = code.get(tpos).mappedOffset; + } else { + acode.code.get(i).mappedOffset = pos2adr(tpos); + } + } + } + this.code = acode.code; + } catch (Exception ex) { + } + invalidateCache(); + } + + public int removeDeadCode(ConstantPool constants, MethodBody body) { + HashMap> refs = visitCode(body); + + int cnt = 0; + for (int i = code.size() - 1; i >= 0; i--) { + if (refs.get(i).isEmpty()) { + code.get(i).ignored = true; + //removeInstruction(i, body); + cnt++; + } + } + + removeIgnored(constants, body); + for (int i = code.size() - 1; i >= 0; i--) { + AVM2Instruction ins = code.get(i); + if (ins.definition instanceof JumpIns) { + if (ins.operands[0] == 0) { + code.get(i).ignored = true; + //removeInstruction(i, body); + cnt++; + } + } + } + removeIgnored(constants, body); + return cnt; + } + + public void markMappedOffsets() { + int ofs = 0; + for (int i = 0; i < code.size(); i++) { + code.get(i).mappedOffset = ofs; + ofs += code.get(i).getBytes().length; + } + } + + public AVM2Code deepCopy() { + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(this); + oos.flush(); + oos.close(); + ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); + AVM2Code copy = (AVM2Code) ois.readObject(); + ois.close(); + return copy; + } catch (Exception ex) { + ex.printStackTrace(); + return null; + } + } + + private static int removeTraps(List localData, Stack stack, List output, AVM2GraphSource code, int ip, int lastIp, List visited) { + boolean debugMode = false; + int ret = 0; + while ((ip > -1) && ip < code.size()) { + if (visited.contains(ip)) { + break; + } + visited.add(ip); + lastIp = ip; + GraphSourceItem ins = code.get(ip); + if (debugMode) { + System.out.println("Visit " + ip + ": " + ins + " stack:" + Highlighting.stripHilights(stack.toString())); + } + if ((ins instanceof AVM2Instruction) && (((AVM2Instruction) ins).definition instanceof NewFunctionIns)) { + stack.push(new BooleanTreeItem(null, true)); } else { - if (ins.isBranch()) { - stack.pop(); - } - - for (int b : branches) { - Stack brStack = (Stack) stack.clone(); - if (b >= 0) { - ret += removeTraps(localData, brStack, output, code, b, ip, visited); - } else { - if (debugMode) { - System.out.println("Negative branch:" + b); - } - } - } + ins.translate(localData, stack, output); + } + if (ins.isExit()) { + break; } - break; - } - ip++; - }; - if (ip < 0) { - System.out.println("Visited Negative: " + ip); - } - return ret; - } - public static int removeTraps(List localData, AVM2GraphSource code, int addr) { - return removeTraps(localData, new Stack(), new ArrayList(), code, code.adr2pos(addr), 0, new ArrayList()); - } + if (ins.isBranch() || ins.isJump()) { + List branches = ins.getBranches(code); + if ((ins instanceof AVM2Instruction) && ((AVM2Instruction) ins).definition instanceof IfTypeIns + && (!(((AVM2Instruction) ins).definition instanceof JumpIns)) && (!stack.isEmpty()) && (stack.peek().isCompileTime())) { + boolean condition = stack.peek().toBoolean(); + if (debugMode) { + if (condition) { + System.out.println("JUMP"); + } else { + System.out.println("SKIP"); + } + } + if (condition) { + ((AVM2Instruction) ins).definition = new JumpIns(); + } else { + ins.setIgnored(true); + } + GraphTargetItem tar = stack.pop(); + for (GraphSourceItemPos pos : tar.getNeededSources()) { + if (pos.item != ins) { + pos.item.setIgnored(true); + } + } + + ret += removeTraps(localData, stack, output, code, condition ? branches.get(0) : branches.get(1), ip, visited); + } else { + if (ins.isBranch()) { + stack.pop(); + } + + for (int b : branches) { + Stack brStack = (Stack) stack.clone(); + if (b >= 0) { + ret += removeTraps(localData, brStack, output, code, b, ip, visited); + } else { + if (debugMode) { + System.out.println("Negative branch:" + b); + } + } + } + } + break; + } + ip++; + }; + if (ip < 0) { + System.out.println("Visited Negative: " + ip); + } + return ret; + } + + public static int removeTraps(List localData, AVM2GraphSource code, int addr) { + return removeTraps(localData, new Stack(), new ArrayList(), code, code.adr2pos(addr), 0, new ArrayList()); + } } 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 665729c18..121656abb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/CodeStats.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/CodeStats.java @@ -25,32 +25,32 @@ import java.util.List; */ public class CodeStats { - public int maxstack = 0; - public int maxscope = 0; - public int maxlocal = 0; - public boolean has_set_dxns = false; - public boolean has_activation = false; - public InstructionStats instructionStats[]; + public int maxstack = 0; + public int maxscope = 0; + public int maxlocal = 0; + public boolean has_set_dxns = false; + public boolean has_activation = false; + public InstructionStats instructionStats[]; - public String toString(ABC abc, List fullyQualifiedNames) { - String ret = "Stats: maxstack=" + maxstack + ", maxscope=" + maxscope + ", maxlocal=" + maxlocal + "\r\n"; - int i = 0; - int ms = 0; - for (InstructionStats stats : instructionStats) { - int deltastack = stats.ins.definition.getStackDelta(stats.ins, abc); - if (stats.stackpos > ms) { - ms = stats.stackpos; - } - ret += "" + i + ":" + stats.stackpos + (deltastack >= 0 ? "+" + deltastack : deltastack) + "," + stats.scopepos + " " + stats.ins.toString(abc.constants, fullyQualifiedNames) + "\r\n"; - i++; - } - return ret; - } + public String toString(ABC abc, List fullyQualifiedNames) { + String ret = "Stats: maxstack=" + maxstack + ", maxscope=" + maxscope + ", maxlocal=" + maxlocal + "\r\n"; + int i = 0; + int ms = 0; + for (InstructionStats stats : instructionStats) { + int deltastack = stats.ins.definition.getStackDelta(stats.ins, abc); + if (stats.stackpos > ms) { + ms = stats.stackpos; + } + ret += "" + i + ":" + stats.stackpos + (deltastack >= 0 ? "+" + deltastack : deltastack) + "," + stats.scopepos + " " + stats.ins.toString(abc.constants, fullyQualifiedNames) + "\r\n"; + i++; + } + return ret; + } - public CodeStats(AVM2Code code) { - instructionStats = new InstructionStats[code.code.size()]; - for (int i = 0; i < code.code.size(); i++) { - instructionStats[i] = new InstructionStats(code.code.get(i)); - } - } + public CodeStats(AVM2Code code) { + instructionStats = new InstructionStats[code.code.size()]; + for (int i = 0; i < code.code.size(); i++) { + instructionStats[i] = new InstructionStats(code.code.get(i)); + } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/ConstantPool.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/ConstantPool.java index 9392103b5..48f166021 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/ConstantPool.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/ConstantPool.java @@ -27,132 +27,132 @@ import java.util.Arrays; public class ConstantPool { - public long constant_int[]; - public long constant_uint[]; - public double constant_double[]; - /* Only for some minor versions */ - public Decimal constant_decimal[]; - public String constant_string[]; - public Namespace constant_namespace[]; - public NamespaceSet constant_namespace_set[]; - public Multiname constant_multiname[]; + public long constant_int[]; + public long constant_uint[]; + public double constant_double[]; + /* Only for some minor versions */ + public Decimal constant_decimal[]; + public String constant_string[]; + public Namespace constant_namespace[]; + public NamespaceSet constant_namespace_set[]; + public Multiname constant_multiname[]; - public int addInt(long value) { - constant_int = Arrays.copyOf(constant_int, constant_int.length + 1); - constant_int[constant_int.length - 1] = value; - return constant_int.length - 1; - } + public int addInt(long value) { + constant_int = Arrays.copyOf(constant_int, constant_int.length + 1); + constant_int[constant_int.length - 1] = value; + return constant_int.length - 1; + } - public int addUInt(long value) { - constant_uint = Arrays.copyOf(constant_uint, constant_uint.length + 1); - constant_uint[constant_uint.length - 1] = value; - return constant_uint.length - 1; - } + public int addUInt(long value) { + constant_uint = Arrays.copyOf(constant_uint, constant_uint.length + 1); + constant_uint[constant_uint.length - 1] = value; + return constant_uint.length - 1; + } - public int addDouble(double value) { - constant_double = Arrays.copyOf(constant_double, constant_double.length + 1); - constant_double[constant_double.length - 1] = value; - return constant_double.length - 1; - } + public int addDouble(double value) { + constant_double = Arrays.copyOf(constant_double, constant_double.length + 1); + constant_double[constant_double.length - 1] = value; + return constant_double.length - 1; + } - public int addString(String value) { - constant_string = Arrays.copyOf(constant_string, constant_string.length + 1); - constant_string[constant_string.length - 1] = value; - return constant_string.length - 1; - } + public int addString(String value) { + constant_string = Arrays.copyOf(constant_string, constant_string.length + 1); + constant_string[constant_string.length - 1] = value; + return constant_string.length - 1; + } - public int getIntId(long value) { - for (int i = 1; i < constant_int.length; i++) { - if (constant_int[i] == value) { - return i; - } - } - return 0; - } + public int getIntId(long value) { + for (int i = 1; i < constant_int.length; i++) { + if (constant_int[i] == value) { + return i; + } + } + return 0; + } - public int getUIntId(long value) { - for (int i = 1; i < constant_uint.length; i++) { - if (constant_uint[i] == value) { - return i; - } - } - return 0; - } + public int getUIntId(long value) { + for (int i = 1; i < constant_uint.length; i++) { + if (constant_uint[i] == value) { + return i; + } + } + return 0; + } - public int getDoubleId(double value) { - for (int i = 1; i < constant_double.length; i++) { - if (constant_double[i] == value) { - return i; - } - } - return 0; - } + public int getDoubleId(double value) { + for (int i = 1; i < constant_double.length; i++) { + if (constant_double[i] == value) { + return i; + } + } + return 0; + } - public int getStringId(String s) { - for (int i = 1; i < constant_string.length; i++) { - if (constant_string[i].equals(s)) { - return i; - } - } - return 0; - } + public int getStringId(String s) { + for (int i = 1; i < constant_string.length; i++) { + if (constant_string[i].equals(s)) { + return i; + } + } + return 0; + } - public int forceGetStringId(String val) { - int id = getStringId(val); - if (id == 0) { - id = addString(val); - } - return id; - } + public int forceGetStringId(String val) { + int id = getStringId(val); + if (id == 0) { + id = addString(val); + } + return id; + } - public int forceGetIntId(long val) { - int id = getIntId(val); - if (id == 0) { - id = addInt(val); - } - return id; - } + public int forceGetIntId(long val) { + int id = getIntId(val); + if (id == 0) { + id = addInt(val); + } + return id; + } - public int forceGetUIntId(long val) { - int id = getUIntId(val); - if (id == 0) { - id = addUInt(val); - } - return id; - } + public int forceGetUIntId(long val) { + int id = getUIntId(val); + if (id == 0) { + id = addUInt(val); + } + return id; + } - public int forceGetDoubleId(double val) { - int id = getDoubleId(val); - if (id == 0) { - id = addDouble(val); - } - return id; - } + public int forceGetDoubleId(double val) { + int id = getDoubleId(val); + if (id == 0) { + id = addDouble(val); + } + return id; + } - public void dump(OutputStream os) { - PrintStream output = new PrintStream(os); - String s = ""; - for (int i = 1; i < constant_int.length; i++) { - output.println("INT[" + i + "]=" + constant_int[i]); - } - for (int i = 1; i < constant_uint.length; i++) { - output.println("UINT[" + i + "]=" + constant_uint[i]); - } - for (int i = 1; i < constant_double.length; i++) { - output.println("Double[" + i + "]=" + constant_double[i]); - } - for (int i = 1; i < constant_string.length; i++) { - output.println("String[" + i + "]=" + constant_string[i]); - } - for (int i = 1; i < constant_namespace.length; i++) { - output.println("Namespace[" + i + "]=" + constant_namespace[i].toString(this)); - } - for (int i = 1; i < constant_namespace_set.length; i++) { - output.println("NamespaceSet[" + i + "]=" + constant_namespace_set[i].toString(this)); - } + public void dump(OutputStream os) { + PrintStream output = new PrintStream(os); + String s = ""; + for (int i = 1; i < constant_int.length; i++) { + output.println("INT[" + i + "]=" + constant_int[i]); + } + for (int i = 1; i < constant_uint.length; i++) { + output.println("UINT[" + i + "]=" + constant_uint[i]); + } + for (int i = 1; i < constant_double.length; i++) { + output.println("Double[" + i + "]=" + constant_double[i]); + } + for (int i = 1; i < constant_string.length; i++) { + output.println("String[" + i + "]=" + constant_string[i]); + } + for (int i = 1; i < constant_namespace.length; i++) { + output.println("Namespace[" + i + "]=" + constant_namespace[i].toString(this)); + } + for (int i = 1; i < constant_namespace_set.length; i++) { + output.println("NamespaceSet[" + i + "]=" + constant_namespace_set[i].toString(this)); + } - for (int i = 1; i < constant_multiname.length; i++) { - output.println("Multiname[" + i + "]=" + constant_multiname[i].toString(this, new ArrayList())); - } - } + for (int i = 1; i < constant_multiname.length; i++) { + output.println("Multiname[" + i + "]=" + constant_multiname[i].toString(this, new ArrayList())); + } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/ConvertException.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/ConvertException.java index 15c06a2a8..a62029502 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/ConvertException.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/ConvertException.java @@ -18,10 +18,10 @@ package com.jpexs.decompiler.flash.abc.avm2; public class ConvertException extends RuntimeException { - public int line; + public int line; - public ConvertException(String s, int line) { - super(s + " on line " + line); - this.line = line; - } + public ConvertException(String s, int line) { + super(s + " on line " + line); + this.line = line; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/ConvertOutput.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/ConvertOutput.java index b3016cf49..846c57c08 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/ConvertOutput.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/ConvertOutput.java @@ -26,11 +26,11 @@ import java.util.Stack; */ public class ConvertOutput { - public Stack stack; - public List output; + public Stack stack; + public List output; - public ConvertOutput(Stack stack, List output) { - this.stack = stack; - this.output = output; - } + public ConvertOutput(Stack stack, List output) { + this.stack = stack; + this.output = output; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/InstructionStats.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/InstructionStats.java index a22868e26..e8a200e20 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/InstructionStats.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/InstructionStats.java @@ -24,12 +24,12 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; */ public class InstructionStats { - public boolean seen = false; - public int stackpos = 0; - public int scopepos = 0; - public AVM2Instruction ins; + public boolean seen = false; + public int stackpos = 0; + public int scopepos = 0; + public AVM2Instruction ins; - public InstructionStats(AVM2Instruction ins) { - this.ins = ins; - } + public InstructionStats(AVM2Instruction ins) { + this.ins = ins; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/InvalidInstructionArguments.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/InvalidInstructionArguments.java index 07bce8826..fbb89b1e2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/InvalidInstructionArguments.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/InvalidInstructionArguments.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2; public class InvalidInstructionArguments extends RuntimeException { - public InvalidInstructionArguments() { - super("Invalid method arguments"); - } + public InvalidInstructionArguments() { + super("Invalid method arguments"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/LocalDataArea.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/LocalDataArea.java index b9ca45ac2..917d8710e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/LocalDataArea.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/LocalDataArea.java @@ -21,7 +21,7 @@ import java.util.Stack; public class LocalDataArea { - public Stack operandStack = new Stack(); - public Stack scopeStack = new Stack(); - public HashMap localRegisters = new HashMap(); + public Stack operandStack = new Stack(); + public Stack scopeStack = new Stack(); + public HashMap localRegisters = new HashMap(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/UnknownInstructionCode.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/UnknownInstructionCode.java index 58d33aac3..ac4c2a320 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/UnknownInstructionCode.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/UnknownInstructionCode.java @@ -18,10 +18,10 @@ package com.jpexs.decompiler.flash.abc.avm2; public class UnknownInstructionCode extends RuntimeException { - public int code; + public int code; - public UnknownInstructionCode(int code) { - super("Unknown instruction code: 0x" + Integer.toHexString(code)); - this.code = code; - } + public UnknownInstructionCode(int code) { + super("Unknown instruction code: 0x" + Integer.toHexString(code)); + this.code = code; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/UnknownJumpException.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/UnknownJumpException.java index 38990002f..0e83a2d51 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/UnknownJumpException.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/UnknownJumpException.java @@ -22,18 +22,18 @@ import java.util.Stack; public class UnknownJumpException extends RuntimeException { - public Stack stack; - public int ip; - public List output; + public Stack stack; + public int ip; + public List output; - public UnknownJumpException(Stack stack, int ip, List output) { - this.stack = stack; - this.ip = ip; - this.output = output; - } + public UnknownJumpException(Stack stack, int ip, List output) { + this.stack = stack; + this.ip = ip; + this.output = output; + } - @Override - public String toString() { - return "Unknown jump to " + ip; - } + @Override + public String toString() { + return "Unknown jump to " + ip; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java index 4e593ab9a..807c08bde 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2Graph.java @@ -66,1507 +66,1505 @@ import java.util.Stack; */ public class AVM2Graph extends Graph { - private AVM2Code code; - private ABC abc; - private MethodBody body; - - public AVM2Graph(AVM2Code code, ABC abc, MethodBody body, boolean isStatic, int classIndex, HashMap localRegs, Stack scopeStack, HashMap localRegNames, List fullyQualifiedNames) { - super(new AVM2GraphSource(code, isStatic, classIndex, localRegs, scopeStack, abc, body, localRegNames, fullyQualifiedNames), body.getExceptionEntries()); - this.code = code; - this.abc = abc; - this.body = body; - /*heads = makeGraph(code, new ArrayList(), body); - this.code = code; - this.abc = abc; - this.body = body; - for (GraphPart head : heads) { - fixGraph(head); - makeMulti(head, new ArrayList()); - }*/ - - } - public static final int DATA_ISSTATIC = 0; - public static final int DATA_CLASSINDEX = 1; - public static final int DATA_LOCALREGS = 2; - public static final int DATA_SCOPESTACK = 3; - public static final int DATA_CONSTANTS = 4; - public static final int DATA_METHOD_INFO = 5; - public static final int DATA_BODY = 6; - public static final int DATA_ABC = 7; - public static final int DATA_LOCALREGNAMES = 8; - public static final int DATA_FQN = 9; - public static final int DATA_PARSEDEXCEPTIONS = 10; - public static final int DATA_FINALLYJUMPS = 11; - public static final int DATA_IGNOREDSWITCHES = 12; - - public static List translateViaGraph(String path, AVM2Code code, ABC abc, MethodBody body, boolean isStatic, int classIndex, HashMap localRegs, Stack scopeStack, HashMap localRegNames, List fullyQualifiedNames) { - AVM2Graph g = new AVM2Graph(code, abc, body, isStatic, classIndex, localRegs, scopeStack, localRegNames, fullyQualifiedNames); - List allParts = new ArrayList(); - for (GraphPart head : g.heads) { - populateParts(head, allParts); - } - List localData = new ArrayList(); - localData.add((Boolean) isStatic); - localData.add((Integer) classIndex); - localData.add(localRegs); - localData.add(scopeStack); - localData.add(abc.constants); - localData.add(abc.method_info); - localData.add(body); - localData.add(abc); - localData.add(localRegNames); - localData.add(fullyQualifiedNames); - localData.add(new ArrayList()); - localData.add(new ArrayList()); - localData.add(new ArrayList()); - return g.translate(localData); - } - /* - public GraphPart getNextNoJump(GraphPart part) { - while (code.code.get(part.start).definition instanceof JumpIns) { - part = part.getSubParts().get(0).nextParts.get(0); - } - return part; - } - - public static List translateViaGraph(String path, AVM2Code code, ABC abc, MethodBody body) { - AVM2Graph g = new AVM2Graph(code, abc, body); - List allParts = new ArrayList(); - for (GraphPart head : g.heads) { - populateParts(head, allParts); - } - return g.printGraph(path, new Stack(), new Stack(), allParts, new ArrayList(), new ArrayList(), 0, null, g.heads.get(0), null, new ArrayList(), new HashMap(), body, new ArrayList()); - } - - private List getLoopsContinues(List loops) { - List ret = new ArrayList(); - for (Loop l : loops) { - if (l.loopContinue != null) { - ret.add(l.loopContinue); - } - } - return ret; - } - - private TreeItem checkLoop(GraphPart part, GraphPart stopPart, List loops) { - if (part == stopPart) { - return null; - } - for (Loop l : loops) { - if (l.loopContinue == part) { - return (new ContinueTreeItem(null, l.id)); - } - if (l.loopBreak == part) { - return (new BreakTreeItem(null, l.id)); - } - } - return null; - } - private boolean doDecompile = true; - - private void checkContinueAtTheEnd(List commands, Loop loop) { - if (!commands.isEmpty()) { - if (commands.get(commands.size() - 1) instanceof ContinueTreeItem) { - if (((ContinueTreeItem) commands.get(commands.size() - 1)).loopPos == loop.id) { - commands.remove(commands.size() - 1); - } - } - } - } - - private List printGraph(String methodPath, Stack stack, Stack scopeStack, List allParts, List parsedExceptions, List finallyJumps, int level, GraphPart parent, GraphPart part, GraphPart stopPart, List loops, HashMap localRegs, MethodBody body, List ignoredSwitches) { - List ret = new ArrayList(); - boolean debugMode = false; - - try { - if (!doDecompile) { - ret.add(new CommentTreeItem(null, "not decompiled")); - return ret; - } - - if (debugMode) { - System.err.println("PART " + part); - } - - if (part == stopPart) { - return ret; - } - if (part.ignored) { - return ret; - } - List fqn = new ArrayList(); - HashMap lrn = new HashMap(); - List output = new ArrayList(); - boolean isSwitch = false; - try { - code.initToSource(); - List parts = new ArrayList(); - if (part instanceof GraphPartMulti) { - parts = ((GraphPartMulti) part).parts; - } else { - parts.add(part); - } - boolean isIf = false; - int end = part.end; - for (GraphPart p : parts) { - end = p.end; - int start = p.start; - isIf = false; - if (code.code.get(end).definition instanceof JumpIns) { - end--; - } else if (code.code.get(end).definition instanceof IfTypeIns) { - end--; - isIf = true; - } else if (code.code.get(end).definition instanceof LookupSwitchIns) { - isSwitch = true; - end--; - } - ConvertOutput co = code.toSourceOutput(false, false, 0, localRegs, stack, scopeStack, abc, abc.constants, abc.method_info, body, start, end, lrn, fqn, new boolean[code.code.size()]); - output.addAll(co.output); - - } - if (isIf) { - AVM2Instruction ins = code.code.get(end + 1); - if ((stack.size() >= 2) && (ins.definition instanceof IfFalseIns) && (stack.get(stack.size() - 1) == stack.get(stack.size() - 2))) { - ret.addAll(output); - - GraphPart sp0 = getNextNoJump(part.nextParts.get(0)); - GraphPart sp1 = getNextNoJump(part.nextParts.get(1)); - boolean reversed = false; - List loopContinues = getLoopsContinues(loops); - loopContinues.add(part); - if (sp1.leadsTo(sp0, loopContinues)) { - } else if (sp0.leadsTo(sp1, loopContinues)) { - reversed = true; - } - GraphPart next = reversed ? sp0 : sp1; - TreeItem ti; - if ((ti = checkLoop(next, stopPart, loops)) != null) { - ret.add(ti); - } else { - printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, parent, next, reversed ? sp1 : sp0, loops, localRegs, body, ignoredSwitches); - TreeItem second = stack.pop(); - TreeItem first = stack.pop(); - if (!reversed) { - AndTreeItem a = new AndTreeItem(ins, first, second); - stack.push(a); - a.firstPart = part; - if (second instanceof AndTreeItem) { - a.firstPart = ((AndTreeItem) second).firstPart; - } - if (second instanceof OrTreeItem) { - a.firstPart = ((AndTreeItem) second).firstPart; - } - } else { - OrTreeItem o = new OrTreeItem(ins, first, second); - stack.push(o); - o.firstPart = part; - if (second instanceof OrTreeItem) { - o.firstPart = ((OrTreeItem) second).firstPart; - } - if (second instanceof OrTreeItem) { - o.firstPart = ((OrTreeItem) second).firstPart; - } - } - next = reversed ? sp1 : sp0; - if ((ti = checkLoop(next, stopPart, loops)) != null) { - ret.add(ti); - } else { - ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, parent, next, stopPart, loops, localRegs, body, ignoredSwitches)); - } - } - return ret; - } else if ((stack.size() >= 2) && (ins.definition instanceof IfTrueIns) && (stack.get(stack.size() - 1) == stack.get(stack.size() - 2))) { - ret.addAll(output); - GraphPart sp0 = getNextNoJump(part.nextParts.get(0)); - GraphPart sp1 = getNextNoJump(part.nextParts.get(1)); - boolean reversed = false; - List loopContinues = getLoopsContinues(loops); - loopContinues.add(part); - if (sp1.leadsTo(sp0, loopContinues)) { - } else if (sp0.leadsTo(sp1, loopContinues)) { - reversed = true; - } - GraphPart next = reversed ? sp0 : sp1; - TreeItem ti; - if ((ti = checkLoop(next, stopPart, loops)) != null) { - ret.add(ti); - } else { - printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, parent, next, reversed ? sp1 : sp0, loops, localRegs, body, ignoredSwitches); - TreeItem second = stack.pop(); - TreeItem first = stack.pop(); - if (reversed) { - AndTreeItem a = new AndTreeItem(ins, first, second); - stack.push(a); - a.firstPart = part; - if (second instanceof AndTreeItem) { - a.firstPart = ((AndTreeItem) second).firstPart; - } - if (second instanceof OrTreeItem) { - a.firstPart = ((AndTreeItem) second).firstPart; - } - } else { - OrTreeItem o = new OrTreeItem(ins, first, second); - stack.push(o); - o.firstPart = part; - if (second instanceof OrTreeItem) { - o.firstPart = ((OrTreeItem) second).firstPart; - } - if (second instanceof OrTreeItem) { - o.firstPart = ((OrTreeItem) second).firstPart; - } - } - - next = reversed ? sp1 : sp0; - if ((ti = checkLoop(next, stopPart, loops)) != null) { - ret.add(ti); - } else { - ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, parent, next, stopPart, loops, localRegs, body, ignoredSwitches)); - } - } - - return ret; - } else if ((((ins.definition instanceof IfStrictNeIns)) && ((part.nextParts.get(1).getHeight() == 2) && (code.code.get(part.nextParts.get(1).start).definition instanceof PushByteIns) && (code.code.get(part.nextParts.get(1).nextParts.get(0).end).definition instanceof LookupSwitchIns))) - || (((ins.definition instanceof IfStrictEqIns)) && ((part.nextParts.get(0).getHeight() == 2) && (code.code.get(part.nextParts.get(0).start).definition instanceof PushByteIns) && (code.code.get(part.nextParts.get(0).nextParts.get(0).end).definition instanceof LookupSwitchIns)))) { - ret.addAll(output); - boolean reversed = false; - if (ins.definition instanceof IfStrictEqIns) { - reversed = true; - } - TreeItem switchedObject = null; - if (!output.isEmpty()) { - if (output.get(output.size() - 1) instanceof SetLocalTreeItem) { - switchedObject = ((SetLocalTreeItem) output.get(output.size() - 1)).value; - } - } - if (switchedObject == null) { - switchedObject = new NullTreeItem(null); - } - HashMap caseValuesMap = new HashMap(); - - stack.pop(); - caseValuesMap.put(code.code.get(part.nextParts.get(reversed ? 0 : 1).start).operands[0], stack.pop()); - - GraphPart switchLoc = part.nextParts.get(reversed ? 0 : 1).nextParts.get(0); - - - while ((code.code.get(part.nextParts.get(reversed ? 1 : 0).end).definition instanceof IfStrictNeIns) - || (code.code.get(part.nextParts.get(reversed ? 1 : 0).end).definition instanceof IfStrictEqIns)) { - part = part.nextParts.get(reversed ? 1 : 0); - List ps = part.getSubParts(); - for (GraphPart p : ps) { - code.toSourceOutput(false, false, 0, localRegs, stack, scopeStack, abc, abc.constants, abc.method_info, body, p.start, p.end - 1, lrn, fqn, new boolean[code.code.size()]); - } - stack.pop(); - if (code.code.get(part.end).definition instanceof IfStrictNeIns) { - reversed = false; - } else { - reversed = true; - } - caseValuesMap.put(code.code.get(part.nextParts.get(reversed ? 0 : 1).start).operands[0], stack.pop()); - - } - boolean hasDefault = false; - GraphPart dp = part.nextParts.get(reversed ? 1 : 0); - while (code.code.get(dp.start).definition instanceof JumpIns) { - if (dp instanceof GraphPartMulti) { - dp = ((GraphPartMulti) dp).parts.get(0); - } - dp = dp.nextParts.get(0); - } - if (code.code.get(dp.start).definition instanceof PushByteIns) { - hasDefault = true; - } - List caseValues = new ArrayList(); - for (int i = 0; i < switchLoc.nextParts.size() - 1; i++) { - if (caseValuesMap.containsKey(i)) { - caseValues.add(caseValuesMap.get(i)); - } else { - continue; - } - } - - List> caseCommands = new ArrayList>(); - GraphPart next = null; - - List loopContinues = getLoopsContinues(loops); - - next = switchLoc.getNextPartPath(loopContinues); - if (next == null) { - next = switchLoc.getNextSuperPartPath(loopContinues); - } - - TreeItem ti = checkLoop(next, stopPart, loops); - Loop currentLoop = new Loop(null, next); - loops.add(currentLoop); - //switchLoc.getNextPartPath(new ArrayList()); - List valuesMapping = new ArrayList(); - List caseBodies = new ArrayList(); - for (int i = 0; i < caseValues.size(); i++) { - GraphPart cur = switchLoc.nextParts.get(1 + i); - if (!caseBodies.contains(cur)) { - caseBodies.add(cur); - } - valuesMapping.add(caseBodies.indexOf(cur)); - } - - List defaultCommands = new ArrayList(); - GraphPart defaultPart = null; - if (hasDefault) { - defaultPart = switchLoc.nextParts.get(switchLoc.nextParts.size() - 1); - defaultCommands = printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, switchLoc, defaultPart, next, loops, localRegs, body, ignoredSwitches); - } - - List ignored = new ArrayList(); - for (Loop l : loops) { - ignored.add(l.loopContinue); - } - - for (int i = 0; i < caseBodies.size(); i++) { - List cc = new ArrayList(); - GraphPart nextCase = null; - nextCase = next; - if (next != null) { - if (i < caseBodies.size() - 1) { - if (!caseBodies.get(i).leadsTo(caseBodies.get(i + 1), ignored)) { - cc.add(new BreakTreeItem(null, next.start)); - } else { - nextCase = caseBodies.get(i + 1); - } - } else if (hasDefault) { - if (!caseBodies.get(i).leadsTo(defaultPart, ignored)) { - cc.add(new BreakTreeItem(null, next.start)); - } else { - nextCase = defaultPart; - } - } - } - cc.addAll(0, printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, switchLoc, caseBodies.get(i), nextCase, loops, localRegs, body, ignoredSwitches)); - caseCommands.add(cc); - } - - SwitchTreeItem sti = new SwitchTreeItem(null, next == null ? -1 : next.start, switchedObject, caseValues, caseCommands, defaultCommands, valuesMapping); - ret.add(sti); - loops.remove(currentLoop); - if (next != null) { - if (ti != null) { - ret.add(ti); - } else { - ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, null, next, stopPart, loops, localRegs, body, ignoredSwitches)); - } - } - return ret; - } else { - try { - ins.definition.translate(false, 0, new HashMap(), stack, new Stack(), abc.constants, ins, abc.method_info, output, body, abc, lrn, fqn); - } catch (Exception ex) { - System.err.println("ip:" + (end + 1)); - ex.printStackTrace(); - } - } - //((IfTypeIns)ins.definition).translateInverted(new HashMap(), co.stack, ins); - } - } catch (ConvertException ex) { - Logger.getLogger(AVM2Graph.class.getName()).log(Level.SEVERE, null, ex); - } - - int ip = part.start; - int addr = code.fixAddrAfterDebugLine(code.pos2adr(part.start)); - int maxend = -1; - List catchedExceptions = new ArrayList(); - for (int e = 0; e < body.exceptions.length; e++) { - if (addr == code.fixAddrAfterDebugLine(body.exceptions[e].start)) { - if (!body.exceptions[e].isFinally()) { - if (((body.exceptions[e].end) > maxend) && (!parsedExceptions.contains(body.exceptions[e]))) { - catchedExceptions.clear(); - maxend = code.fixAddrAfterDebugLine(body.exceptions[e].end); - catchedExceptions.add(body.exceptions[e]); - } else if (code.fixAddrAfterDebugLine(body.exceptions[e].end) == maxend) { - catchedExceptions.add(body.exceptions[e]); - } - } - } - } - if (catchedExceptions.size() > 0) { - parsedExceptions.addAll(catchedExceptions); - int endpos = code.adr2pos(code.fixAddrAfterDebugLine(catchedExceptions.get(0).end)); - int endposStartBlock = code.adr2pos(catchedExceptions.get(0).end); - - - List> catchedCommands = new ArrayList>(); - if (code.code.get(endpos).definition instanceof JumpIns) { - int afterCatchAddr = code.pos2adr(endpos + 1) + code.code.get(endpos).operands[0]; - int afterCatchPos = code.adr2pos(afterCatchAddr); - Collections.sort(catchedExceptions, new Comparator() { - public int compare(ABCException o1, ABCException o2) { - try { - return code.fixAddrAfterDebugLine(o1.target) - code.fixAddrAfterDebugLine(o2.target); - } catch (ConvertException ex) { - return 0; - } - } - }); - - - List finallyCommands = new ArrayList(); - int returnPos = afterCatchPos; - for (int e = 0; e < body.exceptions.length; e++) { - if (body.exceptions[e].isFinally()) { - if (addr == code.fixAddrAfterDebugLine(body.exceptions[e].start)) { - if (afterCatchPos + 1 == code.adr2pos(code.fixAddrAfterDebugLine(body.exceptions[e].end))) { - AVM2Instruction jmpIns = code.code.get(code.adr2pos(code.fixAddrAfterDebugLine(body.exceptions[e].end))); - if (jmpIns.definition instanceof JumpIns) { - int finStart = code.adr2pos(code.fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]); - finallyJumps.add(finStart); - for (int f = finStart; f < code.code.size(); f++) { - if (code.code.get(f).definition instanceof LookupSwitchIns) { - AVM2Instruction swins = code.code.get(f); - if (swins.operands.length >= 3) { - if (swins.operands[0] == swins.getBytes().length) { - if (code.adr2pos(code.pos2adr(f) + swins.operands[2]) < finStart) { - GraphPart fpart = null; - for (GraphPart p : allParts) { - if (p.start == finStart) { - fpart = p; - break; - } - } - stack.push(new ExceptionTreeItem(body.exceptions[e])); - GraphPart fepart = null; - for (GraphPart p : allParts) { - if (p.start == f + 1) { - fepart = p; - break; - } - } - //code.code.get(f).ignored = true; - ignoredSwitches.add(f); - finallyCommands = printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, parent, fpart, fepart, loops, localRegs, body, ignoredSwitches); - returnPos = f + 1; - break; - } - } - } - } - } - - break; - } - } - } - } - } - - for (int e = 0; e < catchedExceptions.size(); e++) { - int eendpos; - if (e < catchedExceptions.size() - 1) { - eendpos = code.adr2pos(code.fixAddrAfterDebugLine(catchedExceptions.get(e + 1).target)) - 2; - } else { - eendpos = afterCatchPos - 1; - } - Stack substack = new Stack(); - substack.add(new ExceptionTreeItem(catchedExceptions.get(e))); - - GraphPart npart = null; - int findpos = code.adr2pos(code.fixAddrAfterDebugLine(catchedExceptions.get(e).target)); - for (GraphPart p : allParts) { - if (p.start == findpos) { - npart = p; - break; - } - } - - GraphPart nepart = null; - for (GraphPart p : allParts) { - if (p.start == eendpos + 1) { - nepart = p; - break; - } - } - stack.add(new ExceptionTreeItem(catchedExceptions.get(e))); - catchedCommands.add(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, parent, npart, nepart, loops, localRegs, body, ignoredSwitches)); - } - - GraphPart nepart = null; - - for (GraphPart p : allParts) { - if (p.start == endposStartBlock) { - nepart = p; - break; - } - } - List tryCommands = printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, parent, part, nepart, loops, localRegs, body, ignoredSwitches); - - output.clear(); - output.add(new TryTreeItem(tryCommands, catchedExceptions, catchedCommands, finallyCommands)); - ip = returnPos; - addr = code.pos2adr(ip); - } - - } - - if (ip != part.start) { - part = null; - for (GraphPart p : allParts) { - List ps = p.getSubParts(); - for (GraphPart p2 : ps) { - if (p2.start == ip) { - part = p2; - break; - } - } - } - ret.addAll(output); - TreeItem lop = checkLoop(part, stopPart, loops); - if (lop == null) { - ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, null, part, stopPart, loops, localRegs, body, ignoredSwitches)); - } else { - ret.add(lop); - } - return ret; - } - - List loopContinues = new ArrayList(); - for (Loop l : loops) { - if (l.loopContinue != null) { - loopContinues.add(l.loopContinue); - } - } - boolean loop = false; - boolean reversed = false; - boolean whileTrue = false; - Loop whileTrueLoop = null; - if ((!part.nextParts.isEmpty()) && part.nextParts.get(0).leadsTo(part, loopContinues)) { - if ((part.nextParts.size() > 1) && part.nextParts.get(1).leadsTo(part, loopContinues)) { - if (output.isEmpty()) { - whileTrueLoop = new Loop(part, null); - loops.add(whileTrueLoop); - whileTrue = true; - } else { - loop = true;//doWhile - } - - } else { - loop = true; - } - } else if ((part.nextParts.size() > 1) && part.nextParts.get(1).leadsTo(part, loopContinues)) { - loop = true; - reversed = true; - } - if (((part.nextParts.size() == 2) || ((part.nextParts.size() == 1) && loop)) && (!isSwitch)) { - - boolean doWhile = loop; - if (loop && output.isEmpty()) { - doWhile = false; - } - Loop currentLoop = new Loop(part, null); - if (loop) { - loops.add(currentLoop); - } - - loopContinues = new ArrayList(); - for (Loop l : loops) { - if (l.loopContinue != null) { - loopContinues.add(l.loopContinue); - } - } - - if ((part.nextParts.size() > 1) && (!doWhile)) { - currentLoop.loopBreak = part.nextParts.get(reversed ? 0 : 1); - } - - TreeItem expr = null; - if ((code.code.get(part.end).definition instanceof JumpIns) || (!(code.code.get(part.end).definition instanceof IfTypeIns))) { - expr = new BooleanTreeItem(null, true); - } else { - if (!stack.isEmpty()) { - expr = stack.pop(); - } - } - if (loop) { - if (expr instanceof AndTreeItem) { - currentLoop.loopContinue = ((AndTreeItem) expr).firstPart; - } - if (expr instanceof OrTreeItem) { - currentLoop.loopContinue = ((OrTreeItem) expr).firstPart; - } - } - - if (doWhile) { - //ret.add(new DoWhileTreeItem(null, currentLoop.id, part.start, output, expr)); - } else { - ret.addAll(output); - } - GraphPart loopBodyStart = null; - GraphPart next = part.getNextPartPath(loopContinues); - if (reversed && (expr instanceof LogicalOp)) { - expr = ((LogicalOp) expr).invert(); - } - List retx = ret; - if ((!loop) || (doWhile && (part.nextParts.size() > 1))) { - if (doWhile) { - retx = output; - - } - int stackSizeBefore = stack.size(); - Stack trueStack = (Stack) stack.clone(); - Stack falseStack = (Stack) stack.clone(); - TreeItem lopTrue = checkLoop(part.nextParts.get(1), stopPart, loops); - TreeItem lopFalse = null; - if (next != part.nextParts.get(0)) { - lopFalse = checkLoop(part.nextParts.get(0), stopPart, loops); - } - List onTrue = new ArrayList(); - if (lopTrue != null) { - onTrue.add(lopTrue); - } else { - if (debugMode) { - System.err.println("ONTRUE: (inside " + part + ")"); - } - onTrue = printGraph(methodPath, trueStack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, part.nextParts.get(1), next == null ? stopPart : next, loops, localRegs, body, ignoredSwitches); - if (debugMode) { - System.err.println("/ONTRUE (inside " + part + ")"); - } - } - List onFalse = new ArrayList(); - if (lopFalse != null) { - onFalse.add(lopFalse); - } else { - if (debugMode) { - System.err.println("ONFALSE: (inside " + part + ")"); - } - onFalse = (((next == part.nextParts.get(0)) || (part.nextParts.get(0).path.equals(part.path) || part.nextParts.get(0).path.length() < part.path.length())) ? new ArrayList() : printGraph(methodPath, falseStack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, part.nextParts.get(0), next == null ? stopPart : next, loops, localRegs, body, ignoredSwitches)); - if (debugMode) { - System.err.println("/ONFALSE (inside " + part + ")"); - } - } - - if (onTrue.isEmpty() && onFalse.isEmpty() && (trueStack.size() > stackSizeBefore) && (falseStack.size() > stackSizeBefore)) { - stack.push(new TernarOpTreeItem(null, expr, trueStack.pop(), falseStack.pop())); - } else { - List retw = retx; - if (whileTrue) { - retw = new ArrayList(); - retw.add(new IfTreeItem(null, expr, onTrue, onFalse)); - retx.add(new WhileTreeItem(null, whileTrueLoop.id, whileTrueLoop.loopContinue.start, new BooleanTreeItem(null, true), retw)); - } else { - retx.add(new IfTreeItem(null, expr, onTrue, onFalse)); - } - - //Same continues in onTrue and onFalse gets continue on parent level - if ((!onTrue.isEmpty()) && (!onFalse.isEmpty())) { - if (onTrue.get(onTrue.size() - 1) instanceof ContinueTreeItem) { - if (onFalse.get(onFalse.size() - 1) instanceof ContinueTreeItem) { - if (((ContinueTreeItem) onTrue.get(onTrue.size() - 1)).loopPos == ((ContinueTreeItem) onFalse.get(onFalse.size() - 1)).loopPos) { - onTrue.remove(onTrue.size() - 1); - retw.add(onFalse.remove(onFalse.size() - 1)); - } - } - } - } - - if ((!onTrue.isEmpty()) && (!onFalse.isEmpty())) { - if (onTrue.get(onTrue.size() - 1) instanceof ReturnValueTreeItem || onTrue.get(onTrue.size() - 1) instanceof ReturnVoidTreeItem) { - if (onFalse.get(onFalse.size() - 1) instanceof ContinueTreeItem) { - retw.add(onFalse.remove(onFalse.size() - 1)); - } - } - } - - if ((!onTrue.isEmpty()) && (!onFalse.isEmpty())) { - if (onFalse.get(onFalse.size() - 1) instanceof ReturnValueTreeItem || onFalse.get(onFalse.size() - 1) instanceof ReturnVoidTreeItem) { - if (onTrue.get(onTrue.size() - 1) instanceof ContinueTreeItem) { - retw.add(onTrue.remove(onTrue.size() - 1)); - } - } - } - if (whileTrue) { - checkContinueAtTheEnd(retw, whileTrueLoop); - } - } - if (doWhile) { - loopBodyStart = next; - } - } - if (loop) { // && (!doWhile)) { - List loopBody = null; - List finalCommands = null; - GraphPart finalPart = null; - boolean isFor = false; - try { - loopBody = printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, loopBodyStart != null ? loopBodyStart : part.nextParts.get(reversed ? 1 : 0), stopPart, loops, localRegs, body, ignoredSwitches); - checkContinueAtTheEnd(loopBody, currentLoop); - } catch (ForException fex) { - loopBody = fex.output; - finalCommands = fex.finalOutput; - if (!finalCommands.isEmpty()) { - finalCommands.remove(finalCommands.size() - 1); //remove continue - } - finalPart = fex.continuePart; - isFor = true; - for (Object o : finalPart.forContinues) { - if (o instanceof ContinueTreeItem) { - ((ContinueTreeItem) o).loopPos = currentLoop.id; - } - } - } - if (isFor) { - ret.add(new ForTreeItem(null, currentLoop.id, finalPart.start, new ArrayList(), expr, finalCommands, loopBody)); - } else if ((expr instanceof HasNextTreeItem) && ((HasNextTreeItem) expr).collection.getNotCoerced().getThroughRegister() instanceof FilteredCheckTreeItem) { - TreeItem gti = ((HasNextTreeItem) expr).collection.getNotCoerced().getThroughRegister(); - boolean found = false; - if ((loopBody.size() == 3) || (loopBody.size() == 4)) { - TreeItem ft = loopBody.get(0); - if (ft instanceof WithTreeItem) { - ft = loopBody.get(1); - if (ft instanceof IfTreeItem) { - IfTreeItem ift = (IfTreeItem) ft; - if (ift.onTrue.size() > 0) { - ft = ift.onTrue.get(0); - if (ft instanceof SetPropertyTreeItem) { - SetPropertyTreeItem spt = (SetPropertyTreeItem) ft; - if (spt.object instanceof LocalRegTreeItem) { - int regIndex = ((LocalRegTreeItem) spt.object).regIndex; - HasNextTreeItem iti = (HasNextTreeItem) expr; - localRegs.put(regIndex, new FilterTreeItem(null, iti.collection.getThroughRegister(), ift.expression)); - } - } - } - } - } - } - } else if ((expr instanceof HasNextTreeItem) && (!loopBody.isEmpty()) && (loopBody.get(0) instanceof SetTypeTreeItem) && (((SetTypeTreeItem) loopBody.get(0)).getValue().getNotCoerced() instanceof NextValueTreeItem)) { - TreeItem obj = ((SetTypeTreeItem) loopBody.get(0)).getObject(); - loopBody.remove(0); - ret.add(new ForEachInTreeItem(null, currentLoop.id, part.start, new InTreeItem(expr.instruction, obj, ((HasNextTreeItem) expr).collection), loopBody)); - } else if ((expr instanceof HasNextTreeItem) && (!loopBody.isEmpty()) && (loopBody.get(0) instanceof SetTypeTreeItem) && (((SetTypeTreeItem) loopBody.get(0)).getValue().getNotCoerced() instanceof NextNameTreeItem)) { - TreeItem obj = ((SetTypeTreeItem) loopBody.get(0)).getObject(); - loopBody.remove(0); - ret.add(new ForInTreeItem(null, currentLoop.id, part.start, new InTreeItem(expr.instruction, obj, ((HasNextTreeItem) expr).collection), loopBody)); - } else { - if (doWhile) { - if (stack.isEmpty()) { - expr = new BooleanTreeItem(null, true); - } else { - expr = stack.pop(); - } - loopBody.addAll(0, output); - checkContinueAtTheEnd(loopBody, currentLoop); - - List addIf = new ArrayList(); - if ((!loopBody.isEmpty()) && (loopBody.get(loopBody.size() - 1) instanceof IfTreeItem)) { - IfTreeItem ift = (IfTreeItem) loopBody.get(loopBody.size() - 1); - if (ift.onFalse.isEmpty()) { - expr = ift.expression; - addIf = ift.onTrue; - loopBody.remove(loopBody.size() - 1); - } - } - ret.add(new DoWhileTreeItem(null, currentLoop.id, part.start, loopBody, expr)); - ret.addAll(addIf); - - } else { - ret.add(new WhileTreeItem(null, currentLoop.id, part.start, expr, loopBody)); - } - } - } - if ((!doWhile) && (!whileTrue) && loop && (part.nextParts.size() > 1)) { - loops.remove(currentLoop); //remove loop so no break shows up - //ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level, part, part.nextParts.get(reversed ? 0 : 1), stopPart, loops, localRegs, body, ignoredSwitches)); - next = part.nextParts.get(reversed ? 0 : 1); - } - if (doWhile) { - next = null; - } - if (next != null) { - boolean finallyJump = false; - for (int f : finallyJumps) { - if (next.start == f) { - finallyJump = true; - break; - } - } - if (!finallyJump) { - TreeItem ti = checkLoop(next, stopPart, loops); - if (ti != null) { - ret.add(ti); - } else { - if (debugMode) { - System.err.println("NEXT: (inside " + part + ")"); - } - ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level, part, next, stopPart, loops, localRegs, body, ignoredSwitches)); - if (debugMode) { - System.err.println("/NEXT: (inside " + part + ")"); - } - } - } - } - } else { - ret.addAll(output); - } - onepart: - if (part.nextParts.size() == 1 && (!loop)) { - if (part.end - part.start > 4) { - if (code.code.get(part.end).definition instanceof PopIns) { - if (code.code.get(part.end - 1).definition instanceof LabelIns) { - if (code.code.get(part.end - 2).definition instanceof PushByteIns) { - - //if (code.code.get(part.end - 3).definition instanceof SetLocalTypeIns) { - if (part.nextParts.size() == 1) { - GraphPart sec = part.nextParts.get(0); - - if (code.code.get(sec.end).definition instanceof ReturnValueIns) { - if (sec.end - sec.start >= 3) { - if (code.code.get(sec.end - 1).definition instanceof KillIns) { - if (code.code.get(sec.end - 2).definition instanceof GetLocalTypeIns) { - if (!output.isEmpty()) { - if (output.get(output.size() - 1) instanceof SetLocalTreeItem) { - sec.ignored = true; - ret.add(new ReturnValueTreeItem(code.code.get(sec.end), ((SetLocalTreeItem) output.get(output.size() - 1)).value)); - break onepart; - } - } - } - } - } - - } else if (code.code.get(sec.end).definition instanceof ReturnVoidIns) { - ret.add(new ReturnVoidTreeItem(code.code.get(sec.end))); - break onepart; - } - //} - } - } - } - } - } - - for (int f : finallyJumps) { - if (part.nextParts.get(0).start == f) { - if ((!output.isEmpty()) && (output.get(output.size() - 1) instanceof SetLocalTreeItem)) { - ret.add(new ReturnValueTreeItem(null, ((SetLocalTreeItem) output.get(output.size() - 1)).value)); - } else { - ret.add(new ReturnVoidTreeItem(null)); - } - - break onepart; - } - } - - GraphPart p = part.nextParts.get(0); - TreeItem lop = checkLoop(p, stopPart, loops); - if (lop == null) { - if (p.path.length() == part.path.length()) { - ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, p, stopPart, loops, localRegs, body, ignoredSwitches)); - } else { - if ((p != stopPart) && (p.refs.size() > 1)) { - ContinueTreeItem cti = new ContinueTreeItem(null, -1); - //p.forContinues.add(cti); - ret.add(new CommentTreeItem(null, "Unknown jump to part " + p)); - ret.add(cti); - } - } - } else { - ret.add(lop); - } - //} - //ret += (strOfChars(level, TAB) + "continue;\r\n"); - //} - } - if (isSwitch && (!ignoredSwitches.contains(part.end))) { - //ret.add(new CommentTreeItem(code.code.get(part.end), "Switch not supported")); - TreeItem switchedObject = stack.pop(); - List caseValues = new ArrayList(); - List valueMappings = new ArrayList(); - List> caseCommands = new ArrayList>(); - - GraphPart next = part.getNextPartPath(loopContinues); - int breakPos = -1; - if (next != null) { - breakPos = next.start; - } - List defaultCommands = printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, part.nextParts.get(0), stopPart, loops, localRegs, body, ignoredSwitches); - - for (int i = 0; i < part.nextParts.size() - 1; i++) { - caseValues.add(new IntegerValueTreeItem(null, (Long) (long) i)); - valueMappings.add(i); - GraphPart nextCase = next; - List caseBody = new ArrayList(); - if (i < part.nextParts.size() - 1 - 1) { - if (!part.nextParts.get(1 + i).leadsTo(part.nextParts.get(1 + i + 1), new ArrayList())) { - caseBody.add(new BreakTreeItem(null, breakPos)); - } else { - nextCase = part.nextParts.get(1 + i + 1); - } - } else if (!part.nextParts.get(1 + i).leadsTo(part.nextParts.get(0), new ArrayList())) { - caseBody.add(new BreakTreeItem(null, breakPos)); - } else { - nextCase = part.nextParts.get(0); - } - caseBody.addAll(0, printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, part.nextParts.get(1 + i), nextCase, loops, localRegs, body, ignoredSwitches)); - caseCommands.add(caseBody); - } - - SwitchTreeItem swt = new SwitchTreeItem(null, breakPos, switchedObject, caseValues, caseCommands, defaultCommands, valueMappings); - ret.add(swt); - - if (next != null) { - TreeItem lopNext = checkLoop(next, stopPart, loops); - if (lopNext != null) { - ret.add(lopNext); - } else { - ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, next, stopPart, loops, localRegs, body, ignoredSwitches)); - } - } - - } - - } catch (ForException fex) { - ret.addAll(fex.output); - fex.output = ret; - throw fex; - } - code.clearTemporaryRegisters(ret); - if (!part.forContinues.isEmpty()) { - throw new ForException(new ArrayList(), ret, part); - } - return ret; - } - - private List makeGraph(AVM2Code code, List allBlocks, MethodBody body) { - HashMap> refs = code.visitCode(body); - List ret = new ArrayList(); - boolean visited[] = new boolean[code.code.size()]; - ret.add(makeGraph(null, "0", code, 0, 0, allBlocks, refs, visited)); - for (ABCException ex : body.exceptions) { - GraphPart e1 = new GraphPart(-1, -1); - e1.path = "e"; - GraphPart e2 = new GraphPart(-1, -1); - e2.path = "e"; - GraphPart e3 = new GraphPart(-1, -1); - e3.path = "e"; - makeGraph(e1, "e", code, code.adr2pos(ex.start), code.adr2pos(ex.start), allBlocks, refs, visited); - makeGraph(e2, "e", code, code.adr2pos(ex.end), code.adr2pos(ex.end), allBlocks, refs, visited); - ret.add(makeGraph(e3, "e", code, code.adr2pos(ex.target), code.adr2pos(ex.target), allBlocks, refs, visited)); - } - return ret; - } - - private GraphPart makeGraph(GraphPart parent, String path, AVM2Code code, int startip, int lastIp, List allBlocks, HashMap> refs, boolean visited2[]) { - - int ip = startip; - for (GraphPart p : allBlocks) { - if (p.start == ip) { - p.refs.add(parent); - return p; - } - } - GraphPart g; - GraphPart ret = new GraphPart(ip, -1); - ret.path = path; - GraphPart part = ret; - while (ip < code.code.size()) { - if (visited2[ip] || ((ip != startip) && (refs.get(ip).size() > 1))) { - part.end = lastIp; - GraphPart found = null; - for (GraphPart p : allBlocks) { - if (p.start == ip) { - found = p; - break; - } - } - - allBlocks.add(part); - - if (found != null) { - part.nextParts.add(found); - found.refs.add(part); - break; - } else { - GraphPart gp = new GraphPart(ip, -1); - gp.path = path; - part.nextParts.add(gp); - gp.refs.add(part); - part = gp; - } - } - lastIp = ip; - AVM2Instruction ins = code.code.get(ip); - if ((ins.definition instanceof ThrowIns) || (ins.definition instanceof ReturnValueIns) || (ins.definition instanceof ReturnVoidIns)) { - part.end = ip; - allBlocks.add(part); - break; - } - if (ins.definition instanceof LookupSwitchIns) { - part.end = ip; - allBlocks.add(part); - try { - part.nextParts.add(g = makeGraph(part, path + "0", code, code.adr2pos(code.pos2adr(ip) + ins.operands[0]), ip, allBlocks, refs, visited2)); - g.refs.add(part); - for (int i = 2; i < ins.operands.length; i++) { - part.nextParts.add(g = makeGraph(part, path + (i - 1), code, code.adr2pos(code.pos2adr(ip) + ins.operands[i]), ip, allBlocks, refs, visited2)); - g.refs.add(part); - } - break; - } catch (ConvertException ex) { - } - } - if (ins.definition instanceof JumpIns) { - try { - part.end = ip; - allBlocks.add(part); - ip = code.adr2pos(code.pos2adr(ip) + ins.getBytes().length + ins.operands[0]); - part.nextParts.add(g = makeGraph(part, path, code, ip, lastIp, allBlocks, refs, visited2)); - g.refs.add(part); - break; - } catch (ConvertException ex) { - Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); - } - } else if (ins.definition instanceof IfTypeIns) { - part.end = ip; - allBlocks.add(part); - try { - part.nextParts.add(g = makeGraph(part, path + "0", code, code.adr2pos(code.pos2adr(ip) + ins.getBytes().length + ins.operands[0]), ip, allBlocks, refs, visited2)); - g.refs.add(part); - part.nextParts.add(g = makeGraph(part, path + "1", code, ip + 1, ip, allBlocks, refs, visited2)); - g.refs.add(part); - - } catch (ConvertException ex) { - Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); - } - break; - } - ip++; - }; - return ret; - }*/ - - @Override - protected List check(GraphSource srcCode, List localData, List allParts, Stack stack, GraphPart parent, GraphPart part, GraphPart stopPart, List loops, List output, HashMap> forFinalCommands) { - List ret = null; - - - - List parsedExceptions = (List) localData.get(DATA_PARSEDEXCEPTIONS); - List finallyJumps = (List) localData.get(DATA_FINALLYJUMPS); - List ignoredSwitches = (List) localData.get(DATA_IGNOREDSWITCHES); - int ip = part.start; - int addr = code.fixAddrAfterDebugLine(code.pos2adr(part.start)); - int maxend = -1; - List catchedExceptions = new ArrayList(); - for (int e = 0; e < body.exceptions.length; e++) { - if (addr == code.fixAddrAfterDebugLine(body.exceptions[e].start)) { - if (!body.exceptions[e].isFinally()) { - if (((body.exceptions[e].end) > maxend) && (!parsedExceptions.contains(body.exceptions[e]))) { - catchedExceptions.clear(); - maxend = code.fixAddrAfterDebugLine(body.exceptions[e].end); - catchedExceptions.add(body.exceptions[e]); - } else if (code.fixAddrAfterDebugLine(body.exceptions[e].end) == maxend) { - catchedExceptions.add(body.exceptions[e]); - } + private AVM2Code code; + private ABC abc; + private MethodBody body; + + public AVM2Graph(AVM2Code code, ABC abc, MethodBody body, boolean isStatic, int classIndex, HashMap localRegs, Stack scopeStack, HashMap localRegNames, List fullyQualifiedNames) { + super(new AVM2GraphSource(code, isStatic, classIndex, localRegs, scopeStack, abc, body, localRegNames, fullyQualifiedNames), body.getExceptionEntries()); + this.code = code; + this.abc = abc; + this.body = body; + /*heads = makeGraph(code, new ArrayList(), body); + this.code = code; + this.abc = abc; + this.body = body; + for (GraphPart head : heads) { + fixGraph(head); + makeMulti(head, new ArrayList()); + }*/ + + } + public static final int DATA_ISSTATIC = 0; + public static final int DATA_CLASSINDEX = 1; + public static final int DATA_LOCALREGS = 2; + public static final int DATA_SCOPESTACK = 3; + public static final int DATA_CONSTANTS = 4; + public static final int DATA_METHOD_INFO = 5; + public static final int DATA_BODY = 6; + public static final int DATA_ABC = 7; + public static final int DATA_LOCALREGNAMES = 8; + public static final int DATA_FQN = 9; + public static final int DATA_PARSEDEXCEPTIONS = 10; + public static final int DATA_FINALLYJUMPS = 11; + public static final int DATA_IGNOREDSWITCHES = 12; + + public static List translateViaGraph(String path, AVM2Code code, ABC abc, MethodBody body, boolean isStatic, int classIndex, HashMap localRegs, Stack scopeStack, HashMap localRegNames, List fullyQualifiedNames) { + AVM2Graph g = new AVM2Graph(code, abc, body, isStatic, classIndex, localRegs, scopeStack, localRegNames, fullyQualifiedNames); + List allParts = new ArrayList(); + for (GraphPart head : g.heads) { + populateParts(head, allParts); + } + List localData = new ArrayList(); + localData.add((Boolean) isStatic); + localData.add((Integer) classIndex); + localData.add(localRegs); + localData.add(scopeStack); + localData.add(abc.constants); + localData.add(abc.method_info); + localData.add(body); + localData.add(abc); + localData.add(localRegNames); + localData.add(fullyQualifiedNames); + localData.add(new ArrayList()); + localData.add(new ArrayList()); + localData.add(new ArrayList()); + return g.translate(localData); + } + /* + public GraphPart getNextNoJump(GraphPart part) { + while (code.code.get(part.start).definition instanceof JumpIns) { + part = part.getSubParts().get(0).nextParts.get(0); + } + return part; + } + + public static List translateViaGraph(String path, AVM2Code code, ABC abc, MethodBody body) { + AVM2Graph g = new AVM2Graph(code, abc, body); + List allParts = new ArrayList(); + for (GraphPart head : g.heads) { + populateParts(head, allParts); + } + return g.printGraph(path, new Stack(), new Stack(), allParts, new ArrayList(), new ArrayList(), 0, null, g.heads.get(0), null, new ArrayList(), new HashMap(), body, new ArrayList()); + } + + private List getLoopsContinues(List loops) { + List ret = new ArrayList(); + for (Loop l : loops) { + if (l.loopContinue != null) { + ret.add(l.loopContinue); + } + } + return ret; + } + + private TreeItem checkLoop(GraphPart part, GraphPart stopPart, List loops) { + if (part == stopPart) { + return null; + } + for (Loop l : loops) { + if (l.loopContinue == part) { + return (new ContinueTreeItem(null, l.id)); + } + if (l.loopBreak == part) { + return (new BreakTreeItem(null, l.id)); + } + } + return null; + } + private boolean doDecompile = true; + + private void checkContinueAtTheEnd(List commands, Loop loop) { + if (!commands.isEmpty()) { + if (commands.get(commands.size() - 1) instanceof ContinueTreeItem) { + if (((ContinueTreeItem) commands.get(commands.size() - 1)).loopPos == loop.id) { + commands.remove(commands.size() - 1); + } + } + } + } + + private List printGraph(String methodPath, Stack stack, Stack scopeStack, List allParts, List parsedExceptions, List finallyJumps, int level, GraphPart parent, GraphPart part, GraphPart stopPart, List loops, HashMap localRegs, MethodBody body, List ignoredSwitches) { + List ret = new ArrayList(); + boolean debugMode = false; + + try { + if (!doDecompile) { + ret.add(new CommentTreeItem(null, "not decompiled")); + return ret; + } + + if (debugMode) { + System.err.println("PART " + part); + } + + if (part == stopPart) { + return ret; + } + if (part.ignored) { + return ret; + } + List fqn = new ArrayList(); + HashMap lrn = new HashMap(); + List output = new ArrayList(); + boolean isSwitch = false; + try { + code.initToSource(); + List parts = new ArrayList(); + if (part instanceof GraphPartMulti) { + parts = ((GraphPartMulti) part).parts; + } else { + parts.add(part); + } + boolean isIf = false; + int end = part.end; + for (GraphPart p : parts) { + end = p.end; + int start = p.start; + isIf = false; + if (code.code.get(end).definition instanceof JumpIns) { + end--; + } else if (code.code.get(end).definition instanceof IfTypeIns) { + end--; + isIf = true; + } else if (code.code.get(end).definition instanceof LookupSwitchIns) { + isSwitch = true; + end--; + } + ConvertOutput co = code.toSourceOutput(false, false, 0, localRegs, stack, scopeStack, abc, abc.constants, abc.method_info, body, start, end, lrn, fqn, new boolean[code.code.size()]); + output.addAll(co.output); + + } + if (isIf) { + AVM2Instruction ins = code.code.get(end + 1); + if ((stack.size() >= 2) && (ins.definition instanceof IfFalseIns) && (stack.get(stack.size() - 1) == stack.get(stack.size() - 2))) { + ret.addAll(output); + + GraphPart sp0 = getNextNoJump(part.nextParts.get(0)); + GraphPart sp1 = getNextNoJump(part.nextParts.get(1)); + boolean reversed = false; + List loopContinues = getLoopsContinues(loops); + loopContinues.add(part); + if (sp1.leadsTo(sp0, loopContinues)) { + } else if (sp0.leadsTo(sp1, loopContinues)) { + reversed = true; + } + GraphPart next = reversed ? sp0 : sp1; + TreeItem ti; + if ((ti = checkLoop(next, stopPart, loops)) != null) { + ret.add(ti); + } else { + printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, parent, next, reversed ? sp1 : sp0, loops, localRegs, body, ignoredSwitches); + TreeItem second = stack.pop(); + TreeItem first = stack.pop(); + if (!reversed) { + AndTreeItem a = new AndTreeItem(ins, first, second); + stack.push(a); + a.firstPart = part; + if (second instanceof AndTreeItem) { + a.firstPart = ((AndTreeItem) second).firstPart; + } + if (second instanceof OrTreeItem) { + a.firstPart = ((AndTreeItem) second).firstPart; + } + } else { + OrTreeItem o = new OrTreeItem(ins, first, second); + stack.push(o); + o.firstPart = part; + if (second instanceof OrTreeItem) { + o.firstPart = ((OrTreeItem) second).firstPart; + } + if (second instanceof OrTreeItem) { + o.firstPart = ((OrTreeItem) second).firstPart; + } + } + next = reversed ? sp1 : sp0; + if ((ti = checkLoop(next, stopPart, loops)) != null) { + ret.add(ti); + } else { + ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, parent, next, stopPart, loops, localRegs, body, ignoredSwitches)); + } + } + return ret; + } else if ((stack.size() >= 2) && (ins.definition instanceof IfTrueIns) && (stack.get(stack.size() - 1) == stack.get(stack.size() - 2))) { + ret.addAll(output); + GraphPart sp0 = getNextNoJump(part.nextParts.get(0)); + GraphPart sp1 = getNextNoJump(part.nextParts.get(1)); + boolean reversed = false; + List loopContinues = getLoopsContinues(loops); + loopContinues.add(part); + if (sp1.leadsTo(sp0, loopContinues)) { + } else if (sp0.leadsTo(sp1, loopContinues)) { + reversed = true; + } + GraphPart next = reversed ? sp0 : sp1; + TreeItem ti; + if ((ti = checkLoop(next, stopPart, loops)) != null) { + ret.add(ti); + } else { + printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, parent, next, reversed ? sp1 : sp0, loops, localRegs, body, ignoredSwitches); + TreeItem second = stack.pop(); + TreeItem first = stack.pop(); + if (reversed) { + AndTreeItem a = new AndTreeItem(ins, first, second); + stack.push(a); + a.firstPart = part; + if (second instanceof AndTreeItem) { + a.firstPart = ((AndTreeItem) second).firstPart; + } + if (second instanceof OrTreeItem) { + a.firstPart = ((AndTreeItem) second).firstPart; + } + } else { + OrTreeItem o = new OrTreeItem(ins, first, second); + stack.push(o); + o.firstPart = part; + if (second instanceof OrTreeItem) { + o.firstPart = ((OrTreeItem) second).firstPart; + } + if (second instanceof OrTreeItem) { + o.firstPart = ((OrTreeItem) second).firstPart; + } + } + + next = reversed ? sp1 : sp0; + if ((ti = checkLoop(next, stopPart, loops)) != null) { + ret.add(ti); + } else { + ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, parent, next, stopPart, loops, localRegs, body, ignoredSwitches)); + } + } + + return ret; + } else if ((((ins.definition instanceof IfStrictNeIns)) && ((part.nextParts.get(1).getHeight() == 2) && (code.code.get(part.nextParts.get(1).start).definition instanceof PushByteIns) && (code.code.get(part.nextParts.get(1).nextParts.get(0).end).definition instanceof LookupSwitchIns))) + || (((ins.definition instanceof IfStrictEqIns)) && ((part.nextParts.get(0).getHeight() == 2) && (code.code.get(part.nextParts.get(0).start).definition instanceof PushByteIns) && (code.code.get(part.nextParts.get(0).nextParts.get(0).end).definition instanceof LookupSwitchIns)))) { + ret.addAll(output); + boolean reversed = false; + if (ins.definition instanceof IfStrictEqIns) { + reversed = true; + } + TreeItem switchedObject = null; + if (!output.isEmpty()) { + if (output.get(output.size() - 1) instanceof SetLocalTreeItem) { + switchedObject = ((SetLocalTreeItem) output.get(output.size() - 1)).value; + } + } + if (switchedObject == null) { + switchedObject = new NullTreeItem(null); + } + HashMap caseValuesMap = new HashMap(); + + stack.pop(); + caseValuesMap.put(code.code.get(part.nextParts.get(reversed ? 0 : 1).start).operands[0], stack.pop()); + + GraphPart switchLoc = part.nextParts.get(reversed ? 0 : 1).nextParts.get(0); + + + while ((code.code.get(part.nextParts.get(reversed ? 1 : 0).end).definition instanceof IfStrictNeIns) + || (code.code.get(part.nextParts.get(reversed ? 1 : 0).end).definition instanceof IfStrictEqIns)) { + part = part.nextParts.get(reversed ? 1 : 0); + List ps = part.getSubParts(); + for (GraphPart p : ps) { + code.toSourceOutput(false, false, 0, localRegs, stack, scopeStack, abc, abc.constants, abc.method_info, body, p.start, p.end - 1, lrn, fqn, new boolean[code.code.size()]); + } + stack.pop(); + if (code.code.get(part.end).definition instanceof IfStrictNeIns) { + reversed = false; + } else { + reversed = true; + } + caseValuesMap.put(code.code.get(part.nextParts.get(reversed ? 0 : 1).start).operands[0], stack.pop()); + + } + boolean hasDefault = false; + GraphPart dp = part.nextParts.get(reversed ? 1 : 0); + while (code.code.get(dp.start).definition instanceof JumpIns) { + if (dp instanceof GraphPartMulti) { + dp = ((GraphPartMulti) dp).parts.get(0); + } + dp = dp.nextParts.get(0); + } + if (code.code.get(dp.start).definition instanceof PushByteIns) { + hasDefault = true; + } + List caseValues = new ArrayList(); + for (int i = 0; i < switchLoc.nextParts.size() - 1; i++) { + if (caseValuesMap.containsKey(i)) { + caseValues.add(caseValuesMap.get(i)); + } else { + continue; + } + } + + List> caseCommands = new ArrayList>(); + GraphPart next = null; + + List loopContinues = getLoopsContinues(loops); + + next = switchLoc.getNextPartPath(loopContinues); + if (next == null) { + next = switchLoc.getNextSuperPartPath(loopContinues); + } + + TreeItem ti = checkLoop(next, stopPart, loops); + Loop currentLoop = new Loop(null, next); + loops.add(currentLoop); + //switchLoc.getNextPartPath(new ArrayList()); + List valuesMapping = new ArrayList(); + List caseBodies = new ArrayList(); + for (int i = 0; i < caseValues.size(); i++) { + GraphPart cur = switchLoc.nextParts.get(1 + i); + if (!caseBodies.contains(cur)) { + caseBodies.add(cur); + } + valuesMapping.add(caseBodies.indexOf(cur)); + } + + List defaultCommands = new ArrayList(); + GraphPart defaultPart = null; + if (hasDefault) { + defaultPart = switchLoc.nextParts.get(switchLoc.nextParts.size() - 1); + defaultCommands = printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, switchLoc, defaultPart, next, loops, localRegs, body, ignoredSwitches); + } + + List ignored = new ArrayList(); + for (Loop l : loops) { + ignored.add(l.loopContinue); + } + + for (int i = 0; i < caseBodies.size(); i++) { + List cc = new ArrayList(); + GraphPart nextCase = null; + nextCase = next; + if (next != null) { + if (i < caseBodies.size() - 1) { + if (!caseBodies.get(i).leadsTo(caseBodies.get(i + 1), ignored)) { + cc.add(new BreakTreeItem(null, next.start)); + } else { + nextCase = caseBodies.get(i + 1); + } + } else if (hasDefault) { + if (!caseBodies.get(i).leadsTo(defaultPart, ignored)) { + cc.add(new BreakTreeItem(null, next.start)); + } else { + nextCase = defaultPart; + } + } + } + cc.addAll(0, printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, switchLoc, caseBodies.get(i), nextCase, loops, localRegs, body, ignoredSwitches)); + caseCommands.add(cc); + } + + SwitchTreeItem sti = new SwitchTreeItem(null, next == null ? -1 : next.start, switchedObject, caseValues, caseCommands, defaultCommands, valuesMapping); + ret.add(sti); + loops.remove(currentLoop); + if (next != null) { + if (ti != null) { + ret.add(ti); + } else { + ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, null, next, stopPart, loops, localRegs, body, ignoredSwitches)); + } + } + return ret; + } else { + try { + ins.definition.translate(false, 0, new HashMap(), stack, new Stack(), abc.constants, ins, abc.method_info, output, body, abc, lrn, fqn); + } catch (Exception ex) { + System.err.println("ip:" + (end + 1)); + ex.printStackTrace(); + } + } + //((IfTypeIns)ins.definition).translateInverted(new HashMap(), co.stack, ins); + } + } catch (ConvertException ex) { + Logger.getLogger(AVM2Graph.class.getName()).log(Level.SEVERE, null, ex); + } + + int ip = part.start; + int addr = code.fixAddrAfterDebugLine(code.pos2adr(part.start)); + int maxend = -1; + List catchedExceptions = new ArrayList(); + for (int e = 0; e < body.exceptions.length; e++) { + if (addr == code.fixAddrAfterDebugLine(body.exceptions[e].start)) { + if (!body.exceptions[e].isFinally()) { + if (((body.exceptions[e].end) > maxend) && (!parsedExceptions.contains(body.exceptions[e]))) { + catchedExceptions.clear(); + maxend = code.fixAddrAfterDebugLine(body.exceptions[e].end); + catchedExceptions.add(body.exceptions[e]); + } else if (code.fixAddrAfterDebugLine(body.exceptions[e].end) == maxend) { + catchedExceptions.add(body.exceptions[e]); + } + } + } + } + if (catchedExceptions.size() > 0) { + parsedExceptions.addAll(catchedExceptions); + int endpos = code.adr2pos(code.fixAddrAfterDebugLine(catchedExceptions.get(0).end)); + int endposStartBlock = code.adr2pos(catchedExceptions.get(0).end); + + + List> catchedCommands = new ArrayList>(); + if (code.code.get(endpos).definition instanceof JumpIns) { + int afterCatchAddr = code.pos2adr(endpos + 1) + code.code.get(endpos).operands[0]; + int afterCatchPos = code.adr2pos(afterCatchAddr); + Collections.sort(catchedExceptions, new Comparator() { + public int compare(ABCException o1, ABCException o2) { + try { + return code.fixAddrAfterDebugLine(o1.target) - code.fixAddrAfterDebugLine(o2.target); + } catch (ConvertException ex) { + return 0; + } + } + }); + + + List finallyCommands = new ArrayList(); + int returnPos = afterCatchPos; + for (int e = 0; e < body.exceptions.length; e++) { + if (body.exceptions[e].isFinally()) { + if (addr == code.fixAddrAfterDebugLine(body.exceptions[e].start)) { + if (afterCatchPos + 1 == code.adr2pos(code.fixAddrAfterDebugLine(body.exceptions[e].end))) { + AVM2Instruction jmpIns = code.code.get(code.adr2pos(code.fixAddrAfterDebugLine(body.exceptions[e].end))); + if (jmpIns.definition instanceof JumpIns) { + int finStart = code.adr2pos(code.fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]); + finallyJumps.add(finStart); + for (int f = finStart; f < code.code.size(); f++) { + if (code.code.get(f).definition instanceof LookupSwitchIns) { + AVM2Instruction swins = code.code.get(f); + if (swins.operands.length >= 3) { + if (swins.operands[0] == swins.getBytes().length) { + if (code.adr2pos(code.pos2adr(f) + swins.operands[2]) < finStart) { + GraphPart fpart = null; + for (GraphPart p : allParts) { + if (p.start == finStart) { + fpart = p; + break; + } + } + stack.push(new ExceptionTreeItem(body.exceptions[e])); + GraphPart fepart = null; + for (GraphPart p : allParts) { + if (p.start == f + 1) { + fepart = p; + break; + } + } + //code.code.get(f).ignored = true; + ignoredSwitches.add(f); + finallyCommands = printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, parent, fpart, fepart, loops, localRegs, body, ignoredSwitches); + returnPos = f + 1; + break; + } + } + } + } + } + + break; + } + } + } + } + } + + for (int e = 0; e < catchedExceptions.size(); e++) { + int eendpos; + if (e < catchedExceptions.size() - 1) { + eendpos = code.adr2pos(code.fixAddrAfterDebugLine(catchedExceptions.get(e + 1).target)) - 2; + } else { + eendpos = afterCatchPos - 1; + } + Stack substack = new Stack(); + substack.add(new ExceptionTreeItem(catchedExceptions.get(e))); + + GraphPart npart = null; + int findpos = code.adr2pos(code.fixAddrAfterDebugLine(catchedExceptions.get(e).target)); + for (GraphPart p : allParts) { + if (p.start == findpos) { + npart = p; + break; + } + } + + GraphPart nepart = null; + for (GraphPart p : allParts) { + if (p.start == eendpos + 1) { + nepart = p; + break; + } + } + stack.add(new ExceptionTreeItem(catchedExceptions.get(e))); + catchedCommands.add(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, parent, npart, nepart, loops, localRegs, body, ignoredSwitches)); + } + + GraphPart nepart = null; + + for (GraphPart p : allParts) { + if (p.start == endposStartBlock) { + nepart = p; + break; + } + } + List tryCommands = printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, parent, part, nepart, loops, localRegs, body, ignoredSwitches); + + output.clear(); + output.add(new TryTreeItem(tryCommands, catchedExceptions, catchedCommands, finallyCommands)); + ip = returnPos; + addr = code.pos2adr(ip); + } + + } + + if (ip != part.start) { + part = null; + for (GraphPart p : allParts) { + List ps = p.getSubParts(); + for (GraphPart p2 : ps) { + if (p2.start == ip) { + part = p2; + break; + } + } + } + ret.addAll(output); + TreeItem lop = checkLoop(part, stopPart, loops); + if (lop == null) { + ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, null, part, stopPart, loops, localRegs, body, ignoredSwitches)); + } else { + ret.add(lop); + } + return ret; + } + + List loopContinues = new ArrayList(); + for (Loop l : loops) { + if (l.loopContinue != null) { + loopContinues.add(l.loopContinue); + } + } + boolean loop = false; + boolean reversed = false; + boolean whileTrue = false; + Loop whileTrueLoop = null; + if ((!part.nextParts.isEmpty()) && part.nextParts.get(0).leadsTo(part, loopContinues)) { + if ((part.nextParts.size() > 1) && part.nextParts.get(1).leadsTo(part, loopContinues)) { + if (output.isEmpty()) { + whileTrueLoop = new Loop(part, null); + loops.add(whileTrueLoop); + whileTrue = true; + } else { + loop = true;//doWhile + } + + } else { + loop = true; + } + } else if ((part.nextParts.size() > 1) && part.nextParts.get(1).leadsTo(part, loopContinues)) { + loop = true; + reversed = true; + } + if (((part.nextParts.size() == 2) || ((part.nextParts.size() == 1) && loop)) && (!isSwitch)) { + + boolean doWhile = loop; + if (loop && output.isEmpty()) { + doWhile = false; + } + Loop currentLoop = new Loop(part, null); + if (loop) { + loops.add(currentLoop); + } + + loopContinues = new ArrayList(); + for (Loop l : loops) { + if (l.loopContinue != null) { + loopContinues.add(l.loopContinue); + } + } + + if ((part.nextParts.size() > 1) && (!doWhile)) { + currentLoop.loopBreak = part.nextParts.get(reversed ? 0 : 1); + } + + TreeItem expr = null; + if ((code.code.get(part.end).definition instanceof JumpIns) || (!(code.code.get(part.end).definition instanceof IfTypeIns))) { + expr = new BooleanTreeItem(null, true); + } else { + if (!stack.isEmpty()) { + expr = stack.pop(); + } + } + if (loop) { + if (expr instanceof AndTreeItem) { + currentLoop.loopContinue = ((AndTreeItem) expr).firstPart; + } + if (expr instanceof OrTreeItem) { + currentLoop.loopContinue = ((OrTreeItem) expr).firstPart; + } + } + + if (doWhile) { + //ret.add(new DoWhileTreeItem(null, currentLoop.id, part.start, output, expr)); + } else { + ret.addAll(output); + } + GraphPart loopBodyStart = null; + GraphPart next = part.getNextPartPath(loopContinues); + if (reversed && (expr instanceof LogicalOp)) { + expr = ((LogicalOp) expr).invert(); + } + List retx = ret; + if ((!loop) || (doWhile && (part.nextParts.size() > 1))) { + if (doWhile) { + retx = output; + + } + int stackSizeBefore = stack.size(); + Stack trueStack = (Stack) stack.clone(); + Stack falseStack = (Stack) stack.clone(); + TreeItem lopTrue = checkLoop(part.nextParts.get(1), stopPart, loops); + TreeItem lopFalse = null; + if (next != part.nextParts.get(0)) { + lopFalse = checkLoop(part.nextParts.get(0), stopPart, loops); + } + List onTrue = new ArrayList(); + if (lopTrue != null) { + onTrue.add(lopTrue); + } else { + if (debugMode) { + System.err.println("ONTRUE: (inside " + part + ")"); + } + onTrue = printGraph(methodPath, trueStack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, part.nextParts.get(1), next == null ? stopPart : next, loops, localRegs, body, ignoredSwitches); + if (debugMode) { + System.err.println("/ONTRUE (inside " + part + ")"); + } + } + List onFalse = new ArrayList(); + if (lopFalse != null) { + onFalse.add(lopFalse); + } else { + if (debugMode) { + System.err.println("ONFALSE: (inside " + part + ")"); + } + onFalse = (((next == part.nextParts.get(0)) || (part.nextParts.get(0).path.equals(part.path) || part.nextParts.get(0).path.length() < part.path.length())) ? new ArrayList() : printGraph(methodPath, falseStack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, part.nextParts.get(0), next == null ? stopPart : next, loops, localRegs, body, ignoredSwitches)); + if (debugMode) { + System.err.println("/ONFALSE (inside " + part + ")"); + } + } + + if (onTrue.isEmpty() && onFalse.isEmpty() && (trueStack.size() > stackSizeBefore) && (falseStack.size() > stackSizeBefore)) { + stack.push(new TernarOpTreeItem(null, expr, trueStack.pop(), falseStack.pop())); + } else { + List retw = retx; + if (whileTrue) { + retw = new ArrayList(); + retw.add(new IfTreeItem(null, expr, onTrue, onFalse)); + retx.add(new WhileTreeItem(null, whileTrueLoop.id, whileTrueLoop.loopContinue.start, new BooleanTreeItem(null, true), retw)); + } else { + retx.add(new IfTreeItem(null, expr, onTrue, onFalse)); + } + + //Same continues in onTrue and onFalse gets continue on parent level + if ((!onTrue.isEmpty()) && (!onFalse.isEmpty())) { + if (onTrue.get(onTrue.size() - 1) instanceof ContinueTreeItem) { + if (onFalse.get(onFalse.size() - 1) instanceof ContinueTreeItem) { + if (((ContinueTreeItem) onTrue.get(onTrue.size() - 1)).loopPos == ((ContinueTreeItem) onFalse.get(onFalse.size() - 1)).loopPos) { + onTrue.remove(onTrue.size() - 1); + retw.add(onFalse.remove(onFalse.size() - 1)); + } + } + } + } + + if ((!onTrue.isEmpty()) && (!onFalse.isEmpty())) { + if (onTrue.get(onTrue.size() - 1) instanceof ReturnValueTreeItem || onTrue.get(onTrue.size() - 1) instanceof ReturnVoidTreeItem) { + if (onFalse.get(onFalse.size() - 1) instanceof ContinueTreeItem) { + retw.add(onFalse.remove(onFalse.size() - 1)); + } + } + } + + if ((!onTrue.isEmpty()) && (!onFalse.isEmpty())) { + if (onFalse.get(onFalse.size() - 1) instanceof ReturnValueTreeItem || onFalse.get(onFalse.size() - 1) instanceof ReturnVoidTreeItem) { + if (onTrue.get(onTrue.size() - 1) instanceof ContinueTreeItem) { + retw.add(onTrue.remove(onTrue.size() - 1)); + } + } + } + if (whileTrue) { + checkContinueAtTheEnd(retw, whileTrueLoop); + } + } + if (doWhile) { + loopBodyStart = next; + } + } + if (loop) { // && (!doWhile)) { + List loopBody = null; + List finalCommands = null; + GraphPart finalPart = null; + boolean isFor = false; + try { + loopBody = printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, loopBodyStart != null ? loopBodyStart : part.nextParts.get(reversed ? 1 : 0), stopPart, loops, localRegs, body, ignoredSwitches); + checkContinueAtTheEnd(loopBody, currentLoop); + } catch (ForException fex) { + loopBody = fex.output; + finalCommands = fex.finalOutput; + if (!finalCommands.isEmpty()) { + finalCommands.remove(finalCommands.size() - 1); //remove continue + } + finalPart = fex.continuePart; + isFor = true; + for (Object o : finalPart.forContinues) { + if (o instanceof ContinueTreeItem) { + ((ContinueTreeItem) o).loopPos = currentLoop.id; + } + } + } + if (isFor) { + ret.add(new ForTreeItem(null, currentLoop.id, finalPart.start, new ArrayList(), expr, finalCommands, loopBody)); + } else if ((expr instanceof HasNextTreeItem) && ((HasNextTreeItem) expr).collection.getNotCoerced().getThroughRegister() instanceof FilteredCheckTreeItem) { + TreeItem gti = ((HasNextTreeItem) expr).collection.getNotCoerced().getThroughRegister(); + boolean found = false; + if ((loopBody.size() == 3) || (loopBody.size() == 4)) { + TreeItem ft = loopBody.get(0); + if (ft instanceof WithTreeItem) { + ft = loopBody.get(1); + if (ft instanceof IfTreeItem) { + IfTreeItem ift = (IfTreeItem) ft; + if (ift.onTrue.size() > 0) { + ft = ift.onTrue.get(0); + if (ft instanceof SetPropertyTreeItem) { + SetPropertyTreeItem spt = (SetPropertyTreeItem) ft; + if (spt.object instanceof LocalRegTreeItem) { + int regIndex = ((LocalRegTreeItem) spt.object).regIndex; + HasNextTreeItem iti = (HasNextTreeItem) expr; + localRegs.put(regIndex, new FilterTreeItem(null, iti.collection.getThroughRegister(), ift.expression)); + } + } + } + } + } + } + } else if ((expr instanceof HasNextTreeItem) && (!loopBody.isEmpty()) && (loopBody.get(0) instanceof SetTypeTreeItem) && (((SetTypeTreeItem) loopBody.get(0)).getValue().getNotCoerced() instanceof NextValueTreeItem)) { + TreeItem obj = ((SetTypeTreeItem) loopBody.get(0)).getObject(); + loopBody.remove(0); + ret.add(new ForEachInTreeItem(null, currentLoop.id, part.start, new InTreeItem(expr.instruction, obj, ((HasNextTreeItem) expr).collection), loopBody)); + } else if ((expr instanceof HasNextTreeItem) && (!loopBody.isEmpty()) && (loopBody.get(0) instanceof SetTypeTreeItem) && (((SetTypeTreeItem) loopBody.get(0)).getValue().getNotCoerced() instanceof NextNameTreeItem)) { + TreeItem obj = ((SetTypeTreeItem) loopBody.get(0)).getObject(); + loopBody.remove(0); + ret.add(new ForInTreeItem(null, currentLoop.id, part.start, new InTreeItem(expr.instruction, obj, ((HasNextTreeItem) expr).collection), loopBody)); + } else { + if (doWhile) { + if (stack.isEmpty()) { + expr = new BooleanTreeItem(null, true); + } else { + expr = stack.pop(); + } + loopBody.addAll(0, output); + checkContinueAtTheEnd(loopBody, currentLoop); + + List addIf = new ArrayList(); + if ((!loopBody.isEmpty()) && (loopBody.get(loopBody.size() - 1) instanceof IfTreeItem)) { + IfTreeItem ift = (IfTreeItem) loopBody.get(loopBody.size() - 1); + if (ift.onFalse.isEmpty()) { + expr = ift.expression; + addIf = ift.onTrue; + loopBody.remove(loopBody.size() - 1); + } + } + ret.add(new DoWhileTreeItem(null, currentLoop.id, part.start, loopBody, expr)); + ret.addAll(addIf); + + } else { + ret.add(new WhileTreeItem(null, currentLoop.id, part.start, expr, loopBody)); + } + } + } + if ((!doWhile) && (!whileTrue) && loop && (part.nextParts.size() > 1)) { + loops.remove(currentLoop); //remove loop so no break shows up + //ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level, part, part.nextParts.get(reversed ? 0 : 1), stopPart, loops, localRegs, body, ignoredSwitches)); + next = part.nextParts.get(reversed ? 0 : 1); + } + if (doWhile) { + next = null; + } + if (next != null) { + boolean finallyJump = false; + for (int f : finallyJumps) { + if (next.start == f) { + finallyJump = true; + break; + } + } + if (!finallyJump) { + TreeItem ti = checkLoop(next, stopPart, loops); + if (ti != null) { + ret.add(ti); + } else { + if (debugMode) { + System.err.println("NEXT: (inside " + part + ")"); + } + ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level, part, next, stopPart, loops, localRegs, body, ignoredSwitches)); + if (debugMode) { + System.err.println("/NEXT: (inside " + part + ")"); + } + } + } + } + } else { + ret.addAll(output); + } + onepart: + if (part.nextParts.size() == 1 && (!loop)) { + if (part.end - part.start > 4) { + if (code.code.get(part.end).definition instanceof PopIns) { + if (code.code.get(part.end - 1).definition instanceof LabelIns) { + if (code.code.get(part.end - 2).definition instanceof PushByteIns) { + + //if (code.code.get(part.end - 3).definition instanceof SetLocalTypeIns) { + if (part.nextParts.size() == 1) { + GraphPart sec = part.nextParts.get(0); + + if (code.code.get(sec.end).definition instanceof ReturnValueIns) { + if (sec.end - sec.start >= 3) { + if (code.code.get(sec.end - 1).definition instanceof KillIns) { + if (code.code.get(sec.end - 2).definition instanceof GetLocalTypeIns) { + if (!output.isEmpty()) { + if (output.get(output.size() - 1) instanceof SetLocalTreeItem) { + sec.ignored = true; + ret.add(new ReturnValueTreeItem(code.code.get(sec.end), ((SetLocalTreeItem) output.get(output.size() - 1)).value)); + break onepart; + } + } + } + } + } + + } else if (code.code.get(sec.end).definition instanceof ReturnVoidIns) { + ret.add(new ReturnVoidTreeItem(code.code.get(sec.end))); + break onepart; + } + //} + } + } + } + } + } + + for (int f : finallyJumps) { + if (part.nextParts.get(0).start == f) { + if ((!output.isEmpty()) && (output.get(output.size() - 1) instanceof SetLocalTreeItem)) { + ret.add(new ReturnValueTreeItem(null, ((SetLocalTreeItem) output.get(output.size() - 1)).value)); + } else { + ret.add(new ReturnVoidTreeItem(null)); + } + + break onepart; + } + } + + GraphPart p = part.nextParts.get(0); + TreeItem lop = checkLoop(p, stopPart, loops); + if (lop == null) { + if (p.path.length() == part.path.length()) { + ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, p, stopPart, loops, localRegs, body, ignoredSwitches)); + } else { + if ((p != stopPart) && (p.refs.size() > 1)) { + ContinueTreeItem cti = new ContinueTreeItem(null, -1); + //p.forContinues.add(cti); + ret.add(new CommentTreeItem(null, "Unknown jump to part " + p)); + ret.add(cti); + } + } + } else { + ret.add(lop); + } + //} + //ret += (strOfChars(level, TAB) + "continue;\r\n"); + //} + } + if (isSwitch && (!ignoredSwitches.contains(part.end))) { + //ret.add(new CommentTreeItem(code.code.get(part.end), "Switch not supported")); + TreeItem switchedObject = stack.pop(); + List caseValues = new ArrayList(); + List valueMappings = new ArrayList(); + List> caseCommands = new ArrayList>(); + + GraphPart next = part.getNextPartPath(loopContinues); + int breakPos = -1; + if (next != null) { + breakPos = next.start; + } + List defaultCommands = printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, part.nextParts.get(0), stopPart, loops, localRegs, body, ignoredSwitches); + + for (int i = 0; i < part.nextParts.size() - 1; i++) { + caseValues.add(new IntegerValueTreeItem(null, (Long) (long) i)); + valueMappings.add(i); + GraphPart nextCase = next; + List caseBody = new ArrayList(); + if (i < part.nextParts.size() - 1 - 1) { + if (!part.nextParts.get(1 + i).leadsTo(part.nextParts.get(1 + i + 1), new ArrayList())) { + caseBody.add(new BreakTreeItem(null, breakPos)); + } else { + nextCase = part.nextParts.get(1 + i + 1); + } + } else if (!part.nextParts.get(1 + i).leadsTo(part.nextParts.get(0), new ArrayList())) { + caseBody.add(new BreakTreeItem(null, breakPos)); + } else { + nextCase = part.nextParts.get(0); + } + caseBody.addAll(0, printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, part.nextParts.get(1 + i), nextCase, loops, localRegs, body, ignoredSwitches)); + caseCommands.add(caseBody); + } + + SwitchTreeItem swt = new SwitchTreeItem(null, breakPos, switchedObject, caseValues, caseCommands, defaultCommands, valueMappings); + ret.add(swt); + + if (next != null) { + TreeItem lopNext = checkLoop(next, stopPart, loops); + if (lopNext != null) { + ret.add(lopNext); + } else { + ret.addAll(printGraph(methodPath, stack, scopeStack, allParts, parsedExceptions, finallyJumps, level + 1, part, next, stopPart, loops, localRegs, body, ignoredSwitches)); + } + } + + } + + } catch (ForException fex) { + ret.addAll(fex.output); + fex.output = ret; + throw fex; + } + code.clearTemporaryRegisters(ret); + if (!part.forContinues.isEmpty()) { + throw new ForException(new ArrayList(), ret, part); + } + return ret; + } + + private List makeGraph(AVM2Code code, List allBlocks, MethodBody body) { + HashMap> refs = code.visitCode(body); + List ret = new ArrayList(); + boolean visited[] = new boolean[code.code.size()]; + ret.add(makeGraph(null, "0", code, 0, 0, allBlocks, refs, visited)); + for (ABCException ex : body.exceptions) { + GraphPart e1 = new GraphPart(-1, -1); + e1.path = "e"; + GraphPart e2 = new GraphPart(-1, -1); + e2.path = "e"; + GraphPart e3 = new GraphPart(-1, -1); + e3.path = "e"; + makeGraph(e1, "e", code, code.adr2pos(ex.start), code.adr2pos(ex.start), allBlocks, refs, visited); + makeGraph(e2, "e", code, code.adr2pos(ex.end), code.adr2pos(ex.end), allBlocks, refs, visited); + ret.add(makeGraph(e3, "e", code, code.adr2pos(ex.target), code.adr2pos(ex.target), allBlocks, refs, visited)); + } + return ret; + } + + private GraphPart makeGraph(GraphPart parent, String path, AVM2Code code, int startip, int lastIp, List allBlocks, HashMap> refs, boolean visited2[]) { + + int ip = startip; + for (GraphPart p : allBlocks) { + if (p.start == ip) { + p.refs.add(parent); + return p; + } + } + GraphPart g; + GraphPart ret = new GraphPart(ip, -1); + ret.path = path; + GraphPart part = ret; + while (ip < code.code.size()) { + if (visited2[ip] || ((ip != startip) && (refs.get(ip).size() > 1))) { + part.end = lastIp; + GraphPart found = null; + for (GraphPart p : allBlocks) { + if (p.start == ip) { + found = p; + break; + } + } + + allBlocks.add(part); + + if (found != null) { + part.nextParts.add(found); + found.refs.add(part); + break; + } else { + GraphPart gp = new GraphPart(ip, -1); + gp.path = path; + part.nextParts.add(gp); + gp.refs.add(part); + part = gp; + } + } + lastIp = ip; + AVM2Instruction ins = code.code.get(ip); + if ((ins.definition instanceof ThrowIns) || (ins.definition instanceof ReturnValueIns) || (ins.definition instanceof ReturnVoidIns)) { + part.end = ip; + allBlocks.add(part); + break; + } + if (ins.definition instanceof LookupSwitchIns) { + part.end = ip; + allBlocks.add(part); + try { + part.nextParts.add(g = makeGraph(part, path + "0", code, code.adr2pos(code.pos2adr(ip) + ins.operands[0]), ip, allBlocks, refs, visited2)); + g.refs.add(part); + for (int i = 2; i < ins.operands.length; i++) { + part.nextParts.add(g = makeGraph(part, path + (i - 1), code, code.adr2pos(code.pos2adr(ip) + ins.operands[i]), ip, allBlocks, refs, visited2)); + g.refs.add(part); + } + break; + } catch (ConvertException ex) { + } + } + if (ins.definition instanceof JumpIns) { + try { + part.end = ip; + allBlocks.add(part); + ip = code.adr2pos(code.pos2adr(ip) + ins.getBytes().length + ins.operands[0]); + part.nextParts.add(g = makeGraph(part, path, code, ip, lastIp, allBlocks, refs, visited2)); + g.refs.add(part); + break; + } catch (ConvertException ex) { + Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); + } + } else if (ins.definition instanceof IfTypeIns) { + part.end = ip; + allBlocks.add(part); + try { + part.nextParts.add(g = makeGraph(part, path + "0", code, code.adr2pos(code.pos2adr(ip) + ins.getBytes().length + ins.operands[0]), ip, allBlocks, refs, visited2)); + g.refs.add(part); + part.nextParts.add(g = makeGraph(part, path + "1", code, ip + 1, ip, allBlocks, refs, visited2)); + g.refs.add(part); + + } catch (ConvertException ex) { + Logger.getLogger(AVM2Code.class.getName()).log(Level.FINE, null, ex); + } + break; + } + ip++; + }; + return ret; + }*/ + + @Override + protected List check(GraphSource srcCode, List localData, List allParts, Stack stack, GraphPart parent, GraphPart part, GraphPart stopPart, List loops, List output, HashMap> forFinalCommands) { + List ret = null; + + + + List parsedExceptions = (List) localData.get(DATA_PARSEDEXCEPTIONS); + List finallyJumps = (List) localData.get(DATA_FINALLYJUMPS); + List ignoredSwitches = (List) localData.get(DATA_IGNOREDSWITCHES); + int ip = part.start; + int addr = code.fixAddrAfterDebugLine(code.pos2adr(part.start)); + int maxend = -1; + List catchedExceptions = new ArrayList(); + for (int e = 0; e < body.exceptions.length; e++) { + if (addr == code.fixAddrAfterDebugLine(body.exceptions[e].start)) { + if (!body.exceptions[e].isFinally()) { + if (((body.exceptions[e].end) > maxend) && (!parsedExceptions.contains(body.exceptions[e]))) { + catchedExceptions.clear(); + maxend = code.fixAddrAfterDebugLine(body.exceptions[e].end); + catchedExceptions.add(body.exceptions[e]); + } else if (code.fixAddrAfterDebugLine(body.exceptions[e].end) == maxend) { + catchedExceptions.add(body.exceptions[e]); + } + } } - } - } - if (catchedExceptions.size() > 0) { - parsedExceptions.addAll(catchedExceptions); - int endpos = code.adr2pos(code.fixAddrAfterDebugLine(catchedExceptions.get(0).end)); - int endposStartBlock = code.adr2pos(catchedExceptions.get(0).end); + } + if (catchedExceptions.size() > 0) { + parsedExceptions.addAll(catchedExceptions); + int endpos = code.adr2pos(code.fixAddrAfterDebugLine(catchedExceptions.get(0).end)); + int endposStartBlock = code.adr2pos(catchedExceptions.get(0).end); - List> catchedCommands = new ArrayList>(); - if (code.code.get(endpos).definition instanceof JumpIns) { - int afterCatchAddr = code.pos2adr(endpos + 1) + code.code.get(endpos).operands[0]; - int afterCatchPos = code.adr2pos(afterCatchAddr); - Collections.sort(catchedExceptions, new Comparator() { - @Override - public int compare(ABCException o1, ABCException o2) { - return code.fixAddrAfterDebugLine(o1.target) - code.fixAddrAfterDebugLine(o2.target); - } - }); + List> catchedCommands = new ArrayList>(); + if (code.code.get(endpos).definition instanceof JumpIns) { + int afterCatchAddr = code.pos2adr(endpos + 1) + code.code.get(endpos).operands[0]; + int afterCatchPos = code.adr2pos(afterCatchAddr); + Collections.sort(catchedExceptions, new Comparator() { + @Override + public int compare(ABCException o1, ABCException o2) { + return code.fixAddrAfterDebugLine(o1.target) - code.fixAddrAfterDebugLine(o2.target); + } + }); - List finallyCommands = new ArrayList(); - int returnPos = afterCatchPos; - for (int e = 0; e < body.exceptions.length; e++) { - if (body.exceptions[e].isFinally()) { - if (addr == code.fixAddrAfterDebugLine(body.exceptions[e].start)) { - if (afterCatchPos + 1 == code.adr2pos(code.fixAddrAfterDebugLine(body.exceptions[e].end))) { - AVM2Instruction jmpIns = code.code.get(code.adr2pos(code.fixAddrAfterDebugLine(body.exceptions[e].end))); - if (jmpIns.definition instanceof JumpIns) { - int finStart = code.adr2pos(code.fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]); + List finallyCommands = new ArrayList(); + int returnPos = afterCatchPos; + for (int e = 0; e < body.exceptions.length; e++) { + if (body.exceptions[e].isFinally()) { + if (addr == code.fixAddrAfterDebugLine(body.exceptions[e].start)) { + if (afterCatchPos + 1 == code.adr2pos(code.fixAddrAfterDebugLine(body.exceptions[e].end))) { + AVM2Instruction jmpIns = code.code.get(code.adr2pos(code.fixAddrAfterDebugLine(body.exceptions[e].end))); + if (jmpIns.definition instanceof JumpIns) { + int finStart = code.adr2pos(code.fixAddrAfterDebugLine(body.exceptions[e].end) + jmpIns.getBytes().length + jmpIns.operands[0]); - boolean switchFound = false; - GraphPart fpart = null; - for (GraphPart p : allParts) { - if (p.start == finStart) { - fpart = p; - break; - } - } - for (int f = finStart; f < code.code.size(); f++) { - if (code.code.get(f).definition instanceof LookupSwitchIns) { - AVM2Instruction swins = code.code.get(f); - if (swins.operands.length >= 3) { - if (swins.operands[0] == swins.getBytes().length) { - if (code.adr2pos(code.pos2adr(f) + swins.operands[2]) < finStart) { - stack.push(new ExceptionTreeItem(body.exceptions[e])); - GraphPart fepart = null; - for (GraphPart p : allParts) { - if (p.start == f + 1) { - fepart = p; - break; - } - } - //code.code.get(f).ignored = true; - ignoredSwitches.add(f); - finallyCommands = printGraph(localData, stack, allParts, parent, fpart, fepart, loops, forFinalCommands); - returnPos = f + 1; - break; - } + boolean switchFound = false; + GraphPart fpart = null; + for (GraphPart p : allParts) { + if (p.start == finStart) { + fpart = p; + break; + } } - } - } - } - if (!switchFound) { - finallyCommands = printGraph(localData, stack, allParts, parent, fpart, null, loops, forFinalCommands); - } - finallyJumps.add(finStart); - break; + for (int f = finStart; f < code.code.size(); f++) { + if (code.code.get(f).definition instanceof LookupSwitchIns) { + AVM2Instruction swins = code.code.get(f); + if (swins.operands.length >= 3) { + if (swins.operands[0] == swins.getBytes().length) { + if (code.adr2pos(code.pos2adr(f) + swins.operands[2]) < finStart) { + stack.push(new ExceptionTreeItem(body.exceptions[e])); + GraphPart fepart = null; + for (GraphPart p : allParts) { + if (p.start == f + 1) { + fepart = p; + break; + } + } + //code.code.get(f).ignored = true; + ignoredSwitches.add(f); + finallyCommands = printGraph(localData, stack, allParts, parent, fpart, fepart, loops, forFinalCommands); + returnPos = f + 1; + break; + } + } + } + } + } + if (!switchFound) { + finallyCommands = printGraph(localData, stack, allParts, parent, fpart, null, loops, forFinalCommands); + } + finallyJumps.add(finStart); + break; + } + } } - } - } - } + } + } + + for (int e = 0; e < catchedExceptions.size(); e++) { + int eendpos; + if (e < catchedExceptions.size() - 1) { + eendpos = code.adr2pos(code.fixAddrAfterDebugLine(catchedExceptions.get(e + 1).target)) - 2; + } else { + eendpos = afterCatchPos - 1; + } + + GraphPart npart = null; + int findpos = code.adr2pos(catchedExceptions.get(e).target); + for (GraphPart p : allParts) { + if (p.start == findpos) { + npart = p; + break; + } + } + + GraphPart nepart = null; + for (GraphPart p : allParts) { + if (p.start == eendpos + 1) { + nepart = p; + break; + } + } + stack.add(new ExceptionTreeItem(catchedExceptions.get(e))); + List localData2 = new ArrayList(); + localData2.addAll(localData); + localData2.set(DATA_SCOPESTACK, new Stack()); + catchedCommands.add(printGraph(localData2, stack, allParts, parent, npart, nepart, loops, forFinalCommands)); + } + + GraphPart nepart = null; + + for (GraphPart p : allParts) { + if (p.start == endposStartBlock) { + nepart = p; + break; + } + } + List tryCommands = printGraph(localData, stack, allParts, parent, part, nepart, loops, forFinalCommands); + + output.clear(); + output.add(new TryTreeItem(tryCommands, catchedExceptions, catchedCommands, finallyCommands)); + ip = returnPos; } - for (int e = 0; e < catchedExceptions.size(); e++) { - int eendpos; - if (e < catchedExceptions.size() - 1) { - eendpos = code.adr2pos(code.fixAddrAfterDebugLine(catchedExceptions.get(e + 1).target)) - 2; - } else { - eendpos = afterCatchPos - 1; - } - - GraphPart npart = null; - int findpos = code.adr2pos(catchedExceptions.get(e).target); - for (GraphPart p : allParts) { - if (p.start == findpos) { - npart = p; - break; - } - } - - GraphPart nepart = null; - for (GraphPart p : allParts) { - if (p.start == eendpos + 1) { - nepart = p; - break; - } - } - stack.add(new ExceptionTreeItem(catchedExceptions.get(e))); - List localData2 = new ArrayList(); - localData2.addAll(localData); - localData2.set(DATA_SCOPESTACK, new Stack()); - catchedCommands.add(printGraph(localData2, stack, allParts, parent, npart, nepart, loops, forFinalCommands)); - } - - GraphPart nepart = null; + } + if (ip != part.start) { + part = null; for (GraphPart p : allParts) { - if (p.start == endposStartBlock) { - nepart = p; - break; - } + List ps = p.getSubParts(); + for (GraphPart p2 : ps) { + if (p2.start == ip) { + part = p2; + break; + } + } } - List tryCommands = printGraph(localData, stack, allParts, parent, part, nepart, loops, forFinalCommands); - - output.clear(); - output.add(new TryTreeItem(tryCommands, catchedExceptions, catchedCommands, finallyCommands)); - ip = returnPos; - } - - } - - if (ip != part.start) { - part = null; - for (GraphPart p : allParts) { - List ps = p.getSubParts(); - for (GraphPart p2 : ps) { - if (p2.start == ip) { - part = p2; - break; - } + ret = new ArrayList(); + ret.addAll(output); + GraphTargetItem lop = checkLoop(part, stopPart, loops); + if (lop == null) { + ret.addAll(printGraph(localData, stack, allParts, null, part, stopPart, loops, forFinalCommands)); + } else { + ret.add(lop); } - } - ret = new ArrayList(); - ret.addAll(output); - GraphTargetItem lop = checkLoop(part, stopPart, loops); - if (lop == null) { - ret.addAll(printGraph(localData, stack, allParts, null, part, stopPart, loops, forFinalCommands)); - } else { - ret.add(lop); - } - return ret; - } + return ret; + } - if (part.nextParts.isEmpty()) { - if (code.code.get(part.end).definition instanceof ReturnValueIns) { //returns in finally clause - if (part.getHeight() >= 3) { - if (code.code.get(part.getPosAt(part.getHeight() - 2)).definition instanceof KillIns) { - if (code.code.get(part.getPosAt(part.getHeight() - 3)).definition instanceof GetLocalTypeIns) { - if (output.size() >= 2) { - if (output.get(output.size() - 2) instanceof SetLocalTreeItem) { - ret = new ArrayList(); - ret.addAll(output); - ret.remove(ret.size() - 1); - ret.add(new ReturnValueTreeItem(code.code.get(part.end), ((SetLocalTreeItem) output.get(output.size() - 2)).value)); - return ret; + if (part.nextParts.isEmpty()) { + if (code.code.get(part.end).definition instanceof ReturnValueIns) { //returns in finally clause + if (part.getHeight() >= 3) { + if (code.code.get(part.getPosAt(part.getHeight() - 2)).definition instanceof KillIns) { + if (code.code.get(part.getPosAt(part.getHeight() - 3)).definition instanceof GetLocalTypeIns) { + if (output.size() >= 2) { + if (output.get(output.size() - 2) instanceof SetLocalTreeItem) { + ret = new ArrayList(); + ret.addAll(output); + ret.remove(ret.size() - 1); + ret.add(new ReturnValueTreeItem(code.code.get(part.end), ((SetLocalTreeItem) output.get(output.size() - 2)).value)); + return ret; + } + } } - } - } - } + } + } } - } - } - if (code.code.get(part.end).definition instanceof LookupSwitchIns) { - ret = new ArrayList(); - ret.addAll(output); - return ret; - } + } + if (code.code.get(part.end).definition instanceof LookupSwitchIns) { + ret = new ArrayList(); + ret.addAll(output); + return ret; + } - if (((part.nextParts.size() == 2) - && (!stack.isEmpty()) - && (stack.peek() instanceof StrictEqTreeItem) - && (part.nextParts.get(0).getHeight() >= 2) - && (code.code.get(code.fixIPAfterDebugLine(part.nextParts.get(0).start)).definition instanceof PushIntegerTypeIns) - && (code.code.get(part.nextParts.get(0).nextParts.get(0).end).definition instanceof LookupSwitchIns)) - || ((part.nextParts.size() == 2) - && (!stack.isEmpty()) - && (stack.peek() instanceof StrictNeqTreeItem) - && (part.nextParts.get(1).getHeight() >= 2) - && (code.code.get(code.fixIPAfterDebugLine(part.nextParts.get(1).start)).definition instanceof PushIntegerTypeIns) - && (code.code.get(part.nextParts.get(1).nextParts.get(0).end).definition instanceof LookupSwitchIns))) { - ret = new ArrayList(); - ret.addAll(output); - boolean reversed = false; - if (stack.peek() instanceof StrictEqTreeItem) { - reversed = true; - } - GraphTargetItem switchedObject = null; - if (!output.isEmpty()) { - if (output.get(output.size() - 1) instanceof SetLocalTreeItem) { - switchedObject = ((SetLocalTreeItem) output.get(output.size() - 1)).value; + if (((part.nextParts.size() == 2) + && (!stack.isEmpty()) + && (stack.peek() instanceof StrictEqTreeItem) + && (part.nextParts.get(0).getHeight() >= 2) + && (code.code.get(code.fixIPAfterDebugLine(part.nextParts.get(0).start)).definition instanceof PushIntegerTypeIns) + && (code.code.get(part.nextParts.get(0).nextParts.get(0).end).definition instanceof LookupSwitchIns)) + || ((part.nextParts.size() == 2) + && (!stack.isEmpty()) + && (stack.peek() instanceof StrictNeqTreeItem) + && (part.nextParts.get(1).getHeight() >= 2) + && (code.code.get(code.fixIPAfterDebugLine(part.nextParts.get(1).start)).definition instanceof PushIntegerTypeIns) + && (code.code.get(part.nextParts.get(1).nextParts.get(0).end).definition instanceof LookupSwitchIns))) { + ret = new ArrayList(); + ret.addAll(output); + boolean reversed = false; + if (stack.peek() instanceof StrictEqTreeItem) { + reversed = true; } - } - if (switchedObject == null) { - switchedObject = new NullTreeItem(null); - } - HashMap caseValuesMap = new HashMap(); + GraphTargetItem switchedObject = null; + if (!output.isEmpty()) { + if (output.get(output.size() - 1) instanceof SetLocalTreeItem) { + switchedObject = ((SetLocalTreeItem) output.get(output.size() - 1)).value; + } + } + if (switchedObject == null) { + switchedObject = new NullTreeItem(null); + } + HashMap caseValuesMap = new HashMap(); - GraphTargetItem tar = stack.pop(); - if (tar instanceof StrictEqTreeItem) { - tar = ((StrictEqTreeItem) tar).leftSide; - } - if (tar instanceof StrictNeqTreeItem) { - tar = ((StrictNeqTreeItem) tar).leftSide; - } - caseValuesMap.put(code.code.get(part.nextParts.get(reversed ? 0 : 1).start).operands[0], tar); - - GraphPart switchLoc = part.nextParts.get(reversed ? 0 : 1).nextParts.get(0); - - - while ((code.code.get(part.nextParts.get(reversed ? 1 : 0).end).definition instanceof IfStrictNeIns) - || (code.code.get(part.nextParts.get(reversed ? 1 : 0).end).definition instanceof IfStrictEqIns)) { - part = part.nextParts.get(reversed ? 1 : 0); - translatePart(localData, part, stack); - tar = stack.pop(); + GraphTargetItem tar = stack.pop(); if (tar instanceof StrictEqTreeItem) { - tar = ((StrictEqTreeItem) tar).leftSide; + tar = ((StrictEqTreeItem) tar).leftSide; } if (tar instanceof StrictNeqTreeItem) { - tar = ((StrictNeqTreeItem) tar).leftSide; + tar = ((StrictNeqTreeItem) tar).leftSide; } - if (code.code.get(part.end).definition instanceof IfStrictNeIns) { - reversed = false; - } else { - reversed = true; + caseValuesMap.put(code.code.get(part.nextParts.get(reversed ? 0 : 1).start).operands[0], tar); + + GraphPart switchLoc = part.nextParts.get(reversed ? 0 : 1).nextParts.get(0); + + + while ((code.code.get(part.nextParts.get(reversed ? 1 : 0).end).definition instanceof IfStrictNeIns) + || (code.code.get(part.nextParts.get(reversed ? 1 : 0).end).definition instanceof IfStrictEqIns)) { + part = part.nextParts.get(reversed ? 1 : 0); + translatePart(localData, part, stack); + tar = stack.pop(); + if (tar instanceof StrictEqTreeItem) { + tar = ((StrictEqTreeItem) tar).leftSide; + } + if (tar instanceof StrictNeqTreeItem) { + tar = ((StrictNeqTreeItem) tar).leftSide; + } + if (code.code.get(part.end).definition instanceof IfStrictNeIns) { + reversed = false; + } else { + reversed = true; + } + caseValuesMap.put(code.code.get(code.fixIPAfterDebugLine(part.nextParts.get(reversed ? 0 : 1).start)).operands[0], tar); + } - caseValuesMap.put(code.code.get(code.fixIPAfterDebugLine(part.nextParts.get(reversed ? 0 : 1).start)).operands[0], tar); - - } - boolean hasDefault = false; - GraphPart dp = part.nextParts.get(reversed ? 1 : 0); - while (code.code.get(dp.start).definition instanceof JumpIns) { - if (dp instanceof GraphPartMulti) { - dp = ((GraphPartMulti) dp).parts.get(0); + boolean hasDefault = false; + GraphPart dp = part.nextParts.get(reversed ? 1 : 0); + while (code.code.get(dp.start).definition instanceof JumpIns) { + if (dp instanceof GraphPartMulti) { + dp = ((GraphPartMulti) dp).parts.get(0); + } + dp = dp.nextParts.get(0); } - dp = dp.nextParts.get(0); - } - if (code.code.get(dp.start).definition instanceof PushIntegerTypeIns) { - hasDefault = true; - } - List caseValues = new ArrayList(); - for (int i = 0; i < switchLoc.nextParts.size() - 1; i++) { - if (caseValuesMap.containsKey(i)) { - caseValues.add(caseValuesMap.get(i)); - } else { - continue; + if (code.code.get(dp.start).definition instanceof PushIntegerTypeIns) { + hasDefault = true; } - } - - List> caseCommands = new ArrayList>(); - GraphPart next = null; - - List loopContinues = getLoopsContinues(loops); - - next = switchLoc.getNextPartPath(loopContinues); - if (next == null) { - next = switchLoc.getNextSuperPartPath(loopContinues); - } - - GraphTargetItem ti = checkLoop(next, stopPart, loops); - Loop currentLoop = new Loop(loops.size(), null, next); - loops.add(currentLoop); - //switchLoc.getNextPartPath(new ArrayList()); - List valuesMapping = new ArrayList(); - List caseBodies = new ArrayList(); - for (int i = 0; i < caseValues.size(); i++) { - GraphPart cur = switchLoc.nextParts.get(1 + i); - if (!caseBodies.contains(cur)) { - caseBodies.add(cur); + List caseValues = new ArrayList(); + for (int i = 0; i < switchLoc.nextParts.size() - 1; i++) { + if (caseValuesMap.containsKey(i)) { + caseValues.add(caseValuesMap.get(i)); + } else { + continue; + } } - valuesMapping.add(caseBodies.indexOf(cur)); - } - List defaultCommands = new ArrayList(); - GraphPart defaultPart = null; - if (hasDefault) { - defaultPart = switchLoc.nextParts.get(switchLoc.nextParts.size() - 1); - defaultCommands = printGraph(localData, stack, allParts, switchLoc, defaultPart, next, loops, forFinalCommands); - } + List> caseCommands = new ArrayList>(); + GraphPart next = null; - List ignored = new ArrayList(); - for (Loop l : loops) { - ignored.add(l.loopContinue); - } + List loopContinues = getLoopsContinues(loops); - for (int i = 0; i < caseBodies.size(); i++) { - List cc = new ArrayList(); - GraphPart nextCase = null; - nextCase = next; + next = switchLoc.getNextPartPath(loopContinues); + if (next == null) { + next = switchLoc.getNextSuperPartPath(loopContinues); + } + + GraphTargetItem ti = checkLoop(next, stopPart, loops); + Loop currentLoop = new Loop(loops.size(), null, next); + loops.add(currentLoop); + //switchLoc.getNextPartPath(new ArrayList()); + List valuesMapping = new ArrayList(); + List caseBodies = new ArrayList(); + for (int i = 0; i < caseValues.size(); i++) { + GraphPart cur = switchLoc.nextParts.get(1 + i); + if (!caseBodies.contains(cur)) { + caseBodies.add(cur); + } + valuesMapping.add(caseBodies.indexOf(cur)); + } + + List defaultCommands = new ArrayList(); + GraphPart defaultPart = null; + if (hasDefault) { + defaultPart = switchLoc.nextParts.get(switchLoc.nextParts.size() - 1); + defaultCommands = printGraph(localData, stack, allParts, switchLoc, defaultPart, next, loops, forFinalCommands); + } + + List ignored = new ArrayList(); + for (Loop l : loops) { + ignored.add(l.loopContinue); + } + + for (int i = 0; i < caseBodies.size(); i++) { + List cc = new ArrayList(); + GraphPart nextCase = null; + nextCase = next; + if (next != null) { + if (i < caseBodies.size() - 1) { + if (!caseBodies.get(i).leadsTo(srcCode, caseBodies.get(i + 1), ignored)) { + cc.add(new BreakItem(null, currentLoop.id)); + } else { + nextCase = caseBodies.get(i + 1); + } + } else if (hasDefault) { + if (!caseBodies.get(i).leadsTo(srcCode, defaultPart, ignored)) { + cc.add(new BreakItem(null, currentLoop.id)); + } else { + nextCase = defaultPart; + } + } + } + cc.addAll(0, printGraph(localData, stack, allParts, switchLoc, caseBodies.get(i), nextCase, loops, forFinalCommands)); + caseCommands.add(cc); + } + + SwitchItem sti = new SwitchItem(null, currentLoop, switchedObject, caseValues, caseCommands, defaultCommands, valuesMapping); + ret.add(sti); + loops.remove(currentLoop); if (next != null) { - if (i < caseBodies.size() - 1) { - if (!caseBodies.get(i).leadsTo(srcCode, caseBodies.get(i + 1), ignored)) { - cc.add(new BreakItem(null, currentLoop.id)); - } else { - nextCase = caseBodies.get(i + 1); - } - } else if (hasDefault) { - if (!caseBodies.get(i).leadsTo(srcCode, defaultPart, ignored)) { - cc.add(new BreakItem(null, currentLoop.id)); - } else { - nextCase = defaultPart; - } - } + if (ti != null) { + ret.add(ti); + } else { + ret.addAll(printGraph(localData, stack, allParts, null, next, stopPart, loops, forFinalCommands)); + } } - cc.addAll(0, printGraph(localData, stack, allParts, switchLoc, caseBodies.get(i), nextCase, loops, forFinalCommands)); - caseCommands.add(cc); - } + } + return ret; + } - SwitchItem sti = new SwitchItem(null, currentLoop, switchedObject, caseValues, caseCommands, defaultCommands, valuesMapping); - ret.add(sti); - loops.remove(currentLoop); - if (next != null) { - if (ti != null) { - ret.add(ti); - } else { - ret.addAll(printGraph(localData, stack, allParts, null, next, stopPart, loops, forFinalCommands)); + @Override + protected GraphPart checkPart(List localData, GraphPart next) { + List finallyJumps = (List) localData.get(DATA_FINALLYJUMPS); + for (int f : finallyJumps) { + if (next.start == f) { + return null; } - } - } - return ret; - } + } + return next; + } - @Override - protected GraphPart checkPart(List localData, GraphPart next) { - List finallyJumps = (List) localData.get(DATA_FINALLYJUMPS); - for (int f : finallyJumps) { - if (next.start == f) { - return null; - } - } - return next; - } - - @Override - protected void finalProcess(List list, int level) { - if (level == 0) { - if (!list.isEmpty()) { - if (list.get(list.size() - 1) instanceof ReturnVoidTreeItem) { - list.remove(list.size() - 1); + @Override + protected void finalProcess(List list, int level) { + if (level == 0) { + if (!list.isEmpty()) { + if (list.get(list.size() - 1) instanceof ReturnVoidTreeItem) { + list.remove(list.size() - 1); + } } - } - } - for (int i = 0; i < list.size(); i++) { - if (list.get(i) instanceof WhileItem) { - WhileItem w = (WhileItem) list.get(i); - if (w.expression instanceof HasNextTreeItem) { - if (!w.commands.isEmpty()) { - if (w.commands.get(0) instanceof SetTypeTreeItem) { - SetTypeTreeItem sti = (SetTypeTreeItem) w.commands.remove(0); - GraphTargetItem gti = sti.getValue().getNotCoerced(); - if (gti instanceof NextValueTreeItem) { - list.set(i, new ForEachInTreeItem(w.src, w.loop, new InTreeItem(null, sti.getObject(), ((HasNextTreeItem) w.expression).collection), w.commands)); - } else if (gti instanceof NextNameTreeItem) { - list.set(i, new ForInTreeItem(w.src, w.loop, new InTreeItem(null, sti.getObject(), ((HasNextTreeItem) w.expression).collection), w.commands)); - } - } - } + } + for (int i = 0; i < list.size(); i++) { + if (list.get(i) instanceof WhileItem) { + WhileItem w = (WhileItem) list.get(i); + if (w.expression instanceof HasNextTreeItem) { + if (!w.commands.isEmpty()) { + if (w.commands.get(0) instanceof SetTypeTreeItem) { + SetTypeTreeItem sti = (SetTypeTreeItem) w.commands.remove(0); + GraphTargetItem gti = sti.getValue().getNotCoerced(); + if (gti instanceof NextValueTreeItem) { + list.set(i, new ForEachInTreeItem(w.src, w.loop, new InTreeItem(null, sti.getObject(), ((HasNextTreeItem) w.expression).collection), w.commands)); + } else if (gti instanceof NextNameTreeItem) { + list.set(i, new ForInTreeItem(w.src, w.loop, new InTreeItem(null, sti.getObject(), ((HasNextTreeItem) w.expression).collection), w.commands)); + } + } + } + } } - } - } + } - List ret = code.clearTemporaryRegisters(list); - if (ret != list) { - list.clear(); - list.addAll(ret); - } - for (int i = 0; i < list.size(); i++) { - if (list.get(i) instanceof SetTypeTreeItem) { - if (((SetTypeTreeItem) list.get(i)).getValue() instanceof ExceptionTreeItem) { - list.remove(i); - i--; + List ret = code.clearTemporaryRegisters(list); + if (ret != list) { + list.clear(); + list.addAll(ret); + } + for (int i = 0; i < list.size(); i++) { + if (list.get(i) instanceof SetTypeTreeItem) { + if (((SetTypeTreeItem) list.get(i)).getValue() instanceof ExceptionTreeItem) { + list.remove(i); + i--; + } } - } - } - } + } + } - @Override - protected boolean isEmpty(List output) { - if (super.isEmpty(output)) { - return true; - } - for (GraphTargetItem i : output) { - if (i instanceof SetLocalTreeItem) { - if (code.isKilled(((SetLocalTreeItem) i).regIndex, 0, code.code.size() - 1)) { - continue; + @Override + protected boolean isEmpty(List output) { + if (super.isEmpty(output)) { + return true; + } + for (GraphTargetItem i : output) { + if (i instanceof SetLocalTreeItem) { + if (code.isKilled(((SetLocalTreeItem) i).regIndex, 0, code.code.size() - 1)) { + continue; + } } - } - return false; - } - return true; - } + return false; + } + return true; + } - @Override - public List prepareBranchLocalData(List localData) { - List ret=new ArrayList(); - ret.addAll(localData); - Stack scopeStack=(Stack)ret.get(DATA_SCOPESTACK); - Stack copyScopeStack=new Stack(); - copyScopeStack.addAll(scopeStack); - ret.set(DATA_SCOPESTACK, copyScopeStack); - return ret; - } - - + @Override + public List prepareBranchLocalData(List localData) { + List ret = new ArrayList(); + ret.addAll(localData); + Stack scopeStack = (Stack) ret.get(DATA_SCOPESTACK); + Stack copyScopeStack = new Stack(); + copyScopeStack.addAll(scopeStack); + ret.set(DATA_SCOPESTACK, copyScopeStack); + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2GraphSource.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2GraphSource.java index 3d9447139..79825a0d4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2GraphSource.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/graph/AVM2GraphSource.java @@ -18,58 +18,58 @@ import java.util.Stack; */ public class AVM2GraphSource extends GraphSource { - private AVM2Code code; - boolean isStatic; - int classIndex; - HashMap localRegs; - Stack scopeStack; - ABC abc; - MethodBody body; - HashMap localRegNames; - List fullyQualifiedNames; + private AVM2Code code; + boolean isStatic; + int classIndex; + HashMap localRegs; + Stack scopeStack; + ABC abc; + MethodBody body; + HashMap localRegNames; + List fullyQualifiedNames; - public AVM2GraphSource(AVM2Code code, boolean isStatic, int classIndex, HashMap localRegs, Stack scopeStack, ABC abc, MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { - this.code = code; - this.isStatic = isStatic; - this.classIndex = classIndex; - this.localRegs = localRegs; - this.scopeStack = scopeStack; - this.abc = abc; - this.body = body; - this.localRegNames = localRegNames; - this.fullyQualifiedNames = fullyQualifiedNames; - } + public AVM2GraphSource(AVM2Code code, boolean isStatic, int classIndex, HashMap localRegs, Stack scopeStack, ABC abc, MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { + this.code = code; + this.isStatic = isStatic; + this.classIndex = classIndex; + this.localRegs = localRegs; + this.scopeStack = scopeStack; + this.abc = abc; + this.body = body; + this.localRegNames = localRegNames; + this.fullyQualifiedNames = fullyQualifiedNames; + } - @Override - public int size() { - return code.code.size(); - } + @Override + public int size() { + return code.code.size(); + } - @Override - public GraphSourceItem get(int pos) { - return code.code.get(pos); - } + @Override + public GraphSourceItem get(int pos) { + return code.code.get(pos); + } - @Override - public boolean isEmpty() { - return code.code.isEmpty(); - } + @Override + public boolean isEmpty() { + return code.code.isEmpty(); + } - @Override - public List translatePart(List localData, Stack stack, int start, int end) { - List ret = new ArrayList(); - ConvertOutput co = code.toSourceOutput(false, isStatic, classIndex, localRegs, stack, (Stack) localData.get(AVM2Graph.DATA_SCOPESTACK), abc, abc.constants, abc.method_info, body, start, end, localRegNames, fullyQualifiedNames, new boolean[size()]); - ret.addAll(co.output); - return ret; - } + @Override + public List translatePart(List localData, Stack stack, int start, int end) { + List ret = new ArrayList(); + ConvertOutput co = code.toSourceOutput(false, isStatic, classIndex, localRegs, stack, (Stack) localData.get(AVM2Graph.DATA_SCOPESTACK), abc, abc.constants, abc.method_info, body, start, end, localRegNames, fullyQualifiedNames, new boolean[size()]); + ret.addAll(co.output); + return ret; + } - @Override - public int adr2pos(long adr) { - return code.adr2pos(adr); - } + @Override + public int adr2pos(long adr) { + return code.adr2pos(adr); + } - @Override - public long pos2adr(int pos) { - return code.pos2adr(pos); - } + @Override + public long pos2adr(int pos) { + return code.pos2adr(pos); + } } 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 d7463499a..d7c53778f 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 @@ -41,257 +41,257 @@ import java.util.Stack; public class AVM2Instruction implements Serializable, GraphSourceItem { - public InstructionDefinition definition; - public int operands[]; - public long offset; - public byte bytes[]; - public String comment; - public boolean ignored = false; - public String labelname; - public long mappedOffset = -1; - public int changeJumpTo = -1; + public InstructionDefinition definition; + public int operands[]; + public long offset; + public byte bytes[]; + public String comment; + public boolean ignored = false; + public String labelname; + public long mappedOffset = -1; + public int changeJumpTo = -1; - public AVM2Instruction(long offset, InstructionDefinition definition, int[] operands, byte bytes[]) { - this.definition = definition; - this.operands = operands; - this.offset = offset; - this.bytes = bytes; - } + public AVM2Instruction(long offset, InstructionDefinition definition, int[] operands, byte bytes[]) { + this.definition = definition; + this.operands = operands; + this.offset = offset; + this.bytes = bytes; + } - public byte[] getBytes() { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try { - ABCOutputStream aos = new ABCOutputStream(bos); - aos.write(definition.instructionCode); - for (int i = 0; i < definition.operands.length; i++) { - int opt = definition.operands[i] & 0xff00; - switch (opt) { - case AVM2Code.OPT_S24: - aos.writeS24(operands[i]); - break; - case AVM2Code.OPT_U30: - aos.writeU30(operands[i]); - break; - case AVM2Code.OPT_U8: - aos.writeU8(operands[i]); - break; - case AVM2Code.OPT_BYTE: - aos.writeU8(0xff & operands[i]); - break; - case AVM2Code.OPT_CASE_OFFSETS: + public byte[] getBytes() { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + try { + ABCOutputStream aos = new ABCOutputStream(bos); + aos.write(definition.instructionCode); + for (int i = 0; i < definition.operands.length; i++) { + int opt = definition.operands[i] & 0xff00; + switch (opt) { + case AVM2Code.OPT_S24: + aos.writeS24(operands[i]); + break; + case AVM2Code.OPT_U30: + aos.writeU30(operands[i]); + break; + case AVM2Code.OPT_U8: + aos.writeU8(operands[i]); + break; + case AVM2Code.OPT_BYTE: + aos.writeU8(0xff & operands[i]); + break; + case AVM2Code.OPT_CASE_OFFSETS: - aos.writeU30(operands[i]); //case count - for (int j = i + 1; j < operands.length; j++) { - aos.writeS24(operands[j]); - } - break; + aos.writeU30(operands[i]); //case count + for (int j = i + 1; j < operands.length; j++) { + aos.writeS24(operands[j]); + } + break; + } } - } - } catch (IOException ex) { - //ignored - } - return bos.toByteArray(); - } + } catch (IOException ex) { + //ignored + } + return bos.toByteArray(); + } - @Override - public String toString() { - String s = definition.instructionName; - for (int i = 0; i < operands.length; i++) { - s += " " + operands[i]; - } - return s; - } + @Override + public String toString() { + String s = definition.instructionName; + for (int i = 0; i < operands.length; i++) { + s += " " + operands[i]; + } + return s; + } - public List getOffsets() { - List ret = new ArrayList(); - String s = ""; - for (int i = 0; i < definition.operands.length; i++) { - switch (definition.operands[i]) { - case AVM2Code.DAT_OFFSET: - ret.add(offset + operands[i] + getBytes().length); - break; - case AVM2Code.DAT_CASE_BASEOFFSET: - ret.add(offset + operands[i]); - break; - case AVM2Code.OPT_CASE_OFFSETS: - for (int j = i + 1; j < operands.length; j++) { - ret.add(offset + operands[j]); - } - break; - } + public List getOffsets() { + List ret = new ArrayList(); + String s = ""; + for (int i = 0; i < definition.operands.length; i++) { + switch (definition.operands[i]) { + case AVM2Code.DAT_OFFSET: + ret.add(offset + operands[i] + getBytes().length); + break; + case AVM2Code.DAT_CASE_BASEOFFSET: + ret.add(offset + operands[i]); + break; + case AVM2Code.OPT_CASE_OFFSETS: + for (int j = i + 1; j < operands.length; j++) { + ret.add(offset + operands[j]); + } + break; + } - } - return ret; - } + } + return ret; + } - public List getParamsAsList(ConstantPool constants) { - List s = new ArrayList(); - for (int i = 0; i < definition.operands.length; i++) { - switch (definition.operands[i]) { - case AVM2Code.DAT_MULTINAME_INDEX: - s.add(constants.constant_multiname[operands[i]]); - break; - case AVM2Code.DAT_STRING_INDEX: - s.add(constants.constant_string[operands[i]]); - break; - case AVM2Code.DAT_INT_INDEX: - s.add(new Long(constants.constant_int[operands[i]])); - break; - case AVM2Code.DAT_UINT_INDEX: - s.add(new Long(constants.constant_uint[operands[i]])); - break; - case AVM2Code.DAT_DOUBLE_INDEX: - s.add(new Double(constants.constant_double[operands[i]])); - break; - case AVM2Code.DAT_OFFSET: - s.add(new Long(offset + operands[i] + getBytes().length)); - break; - case AVM2Code.DAT_CASE_BASEOFFSET: - s.add(new Long(offset + operands[i])); - break; - case AVM2Code.OPT_CASE_OFFSETS: - s.add(new Long(operands[i])); - for (int j = i + 1; j < operands.length; j++) { - s.add(new Long(offset + operands[j])); - } - break; - default: - s.add(new Long(operands[i])); - } + public List getParamsAsList(ConstantPool constants) { + List s = new ArrayList(); + for (int i = 0; i < definition.operands.length; i++) { + switch (definition.operands[i]) { + case AVM2Code.DAT_MULTINAME_INDEX: + s.add(constants.constant_multiname[operands[i]]); + break; + case AVM2Code.DAT_STRING_INDEX: + s.add(constants.constant_string[operands[i]]); + break; + case AVM2Code.DAT_INT_INDEX: + s.add(new Long(constants.constant_int[operands[i]])); + break; + case AVM2Code.DAT_UINT_INDEX: + s.add(new Long(constants.constant_uint[operands[i]])); + break; + case AVM2Code.DAT_DOUBLE_INDEX: + s.add(new Double(constants.constant_double[operands[i]])); + break; + case AVM2Code.DAT_OFFSET: + s.add(new Long(offset + operands[i] + getBytes().length)); + break; + case AVM2Code.DAT_CASE_BASEOFFSET: + s.add(new Long(offset + operands[i])); + break; + case AVM2Code.OPT_CASE_OFFSETS: + s.add(new Long(operands[i])); + for (int j = i + 1; j < operands.length; j++) { + s.add(new Long(offset + operands[j])); + } + break; + default: + s.add(new Long(operands[i])); + } - } - return s; - } + } + return s; + } - public String getParams(ConstantPool constants, List fullyQualifiedNames) { - String s = ""; - for (int i = 0; i < definition.operands.length; i++) { - switch (definition.operands[i]) { - case AVM2Code.DAT_MULTINAME_INDEX: - s += " m[" + operands[i] + "]\"" + Helper.escapeString(constants.constant_multiname[operands[i]].toString(constants, fullyQualifiedNames)) + "\""; - break; - case AVM2Code.DAT_STRING_INDEX: - s += " \"" + Helper.escapeString(constants.constant_string[operands[i]]) + "\""; - break; - case AVM2Code.DAT_INT_INDEX: - s += " " + constants.constant_int[operands[i]] + ""; - break; - case AVM2Code.DAT_UINT_INDEX: - s += " " + constants.constant_uint[operands[i]] + ""; - break; - case AVM2Code.DAT_DOUBLE_INDEX: - s += " " + constants.constant_double[operands[i]] + ""; - break; - case AVM2Code.DAT_OFFSET: - s += " "; - if (operands[i] > 0) { - //s += "+"; - }//operands[i] - s += "ofs" + Helper.formatAddress(offset + operands[i] + getBytes().length) + ""; - break; - case AVM2Code.DAT_CASE_BASEOFFSET: - s += " "; - if (operands[i] > 0) { - //s += "+"; - }//operands[i] - s += "ofs" + Helper.formatAddress(offset + operands[i]) + ""; - break; - case AVM2Code.OPT_CASE_OFFSETS: - s += " " + operands[i]; - for (int j = i + 1; j < operands.length; j++) { - s += " "; - if (operands[j] > 0) { - //s += "+"; - }//operands[j] - s += "ofs" + Helper.formatAddress(offset + operands[j]) + ""; - } - break; - default: - s += " " + operands[i]; - } + public String getParams(ConstantPool constants, List fullyQualifiedNames) { + String s = ""; + for (int i = 0; i < definition.operands.length; i++) { + switch (definition.operands[i]) { + case AVM2Code.DAT_MULTINAME_INDEX: + s += " m[" + operands[i] + "]\"" + Helper.escapeString(constants.constant_multiname[operands[i]].toString(constants, fullyQualifiedNames)) + "\""; + break; + case AVM2Code.DAT_STRING_INDEX: + s += " \"" + Helper.escapeString(constants.constant_string[operands[i]]) + "\""; + break; + case AVM2Code.DAT_INT_INDEX: + s += " " + constants.constant_int[operands[i]] + ""; + break; + case AVM2Code.DAT_UINT_INDEX: + s += " " + constants.constant_uint[operands[i]] + ""; + break; + case AVM2Code.DAT_DOUBLE_INDEX: + s += " " + constants.constant_double[operands[i]] + ""; + break; + case AVM2Code.DAT_OFFSET: + s += " "; + if (operands[i] > 0) { + //s += "+"; + }//operands[i] + s += "ofs" + Helper.formatAddress(offset + operands[i] + getBytes().length) + ""; + break; + case AVM2Code.DAT_CASE_BASEOFFSET: + s += " "; + if (operands[i] > 0) { + //s += "+"; + }//operands[i] + s += "ofs" + Helper.formatAddress(offset + operands[i]) + ""; + break; + case AVM2Code.OPT_CASE_OFFSETS: + s += " " + operands[i]; + for (int j = i + 1; j < operands.length; j++) { + s += " "; + if (operands[j] > 0) { + //s += "+"; + }//operands[j] + s += "ofs" + Helper.formatAddress(offset + operands[j]) + ""; + } + break; + default: + s += " " + operands[i]; + } - } - return s; - } + } + return s; + } - public String getComment() { - if (ignored) { - return " ;ignored"; - } - if ((comment == null) || comment.equals("")) { - return ""; - } - return " ;" + comment; - } + public String getComment() { + if (ignored) { + return " ;ignored"; + } + if ((comment == null) || comment.equals("")) { + return ""; + } + return " ;" + comment; + } - @Override - public boolean isIgnored() { - return ignored; - } + @Override + public boolean isIgnored() { + return ignored; + } - public String toString(ConstantPool constants, List fullyQualifiedNames) { - String s = Helper.formatAddress(offset) + " " + Helper.padSpaceRight(Helper.byteArrToString(getBytes()), 30) + definition.instructionName; - s += getParams(constants, fullyQualifiedNames) + getComment(); - return s; - } + public String toString(ConstantPool constants, List fullyQualifiedNames) { + String s = Helper.formatAddress(offset) + " " + Helper.padSpaceRight(Helper.byteArrToString(getBytes()), 30) + definition.instructionName; + s += getParams(constants, fullyQualifiedNames) + getComment(); + return s; + } - public String toStringNoAddress(ConstantPool constants, List fullyQualifiedNames) { - String s = definition.instructionName; - s += getParams(constants, fullyQualifiedNames) + getComment(); - return s; - } - public List replaceWith; + public String toStringNoAddress(ConstantPool constants, List fullyQualifiedNames) { + String s = definition.instructionName; + s += getParams(constants, fullyQualifiedNames) + getComment(); + return s; + } + public List replaceWith; - @Override - public void translate(List localData, Stack stack, List output) { - definition.translate((Boolean) localData.get(0), (Integer) localData.get(1), (HashMap) localData.get(2), stack, (Stack) localData.get(3), (ConstantPool) localData.get(4), this, (MethodInfo[]) localData.get(5), output, (MethodBody) localData.get(6), (ABC) localData.get(7), (HashMap) localData.get(8), (List) localData.get(9)); - } + @Override + public void translate(List localData, Stack stack, List output) { + definition.translate((Boolean) localData.get(0), (Integer) localData.get(1), (HashMap) localData.get(2), stack, (Stack) localData.get(3), (ConstantPool) localData.get(4), this, (MethodInfo[]) localData.get(5), output, (MethodBody) localData.get(6), (ABC) localData.get(7), (HashMap) localData.get(8), (List) localData.get(9)); + } - @Override - public boolean isJump() { - return (definition instanceof JumpIns); - } + @Override + public boolean isJump() { + return (definition instanceof JumpIns); + } - @Override - public boolean isBranch() { - return (definition instanceof IfTypeIns) || (definition instanceof LookupSwitchIns); - } + @Override + public boolean isBranch() { + return (definition instanceof IfTypeIns) || (definition instanceof LookupSwitchIns); + } - @Override - public boolean isExit() { - return (definition instanceof ReturnValueIns) || (definition instanceof ReturnVoidIns) || (definition instanceof ThrowIns); - } + @Override + public boolean isExit() { + return (definition instanceof ReturnValueIns) || (definition instanceof ReturnVoidIns) || (definition instanceof ThrowIns); + } - @Override - public long getOffset() { - return mappedOffset > -1 ? mappedOffset : offset; - } + @Override + public long getOffset() { + return mappedOffset > -1 ? mappedOffset : offset; + } - @Override - public List getBranches(GraphSource code) { - List ret = new ArrayList(); - if (definition instanceof IfTypeIns) { - ret.add(code.adr2pos(offset + getBytes().length + operands[0])); - if (!(definition instanceof JumpIns)) { - ret.add(code.adr2pos(offset + getBytes().length)); - } - } - if (definition instanceof LookupSwitchIns) { - ret.add(code.adr2pos(offset + operands[0])); - for (int k = 2; k < operands.length; k++) { - ret.add(code.adr2pos(offset + operands[k])); - } - } - return ret; - } + @Override + public List getBranches(GraphSource code) { + List ret = new ArrayList(); + if (definition instanceof IfTypeIns) { + ret.add(code.adr2pos(offset + getBytes().length + operands[0])); + if (!(definition instanceof JumpIns)) { + ret.add(code.adr2pos(offset + getBytes().length)); + } + } + if (definition instanceof LookupSwitchIns) { + ret.add(code.adr2pos(offset + operands[0])); + for (int k = 2; k < operands.length; k++) { + ret.add(code.adr2pos(offset + operands[k])); + } + } + return ret; + } - @Override - public boolean ignoredLoops() { - return false; - } + @Override + public boolean ignoredLoops() { + return false; + } - @Override - public void setIgnored(boolean ignored) { - this.ignored = ignored; - } + @Override + public void setIgnored(boolean ignored) { + this.ignored = ignored; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/IfTypeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/IfTypeIns.java index 77bf8944f..4fb1266df 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/IfTypeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/IfTypeIns.java @@ -21,5 +21,5 @@ import java.util.Stack; public interface IfTypeIns { - public abstract void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins); + public abstract void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins); } 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 f9abc21df..a2a186a26 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 @@ -32,93 +32,93 @@ import java.util.Stack; public class InstructionDefinition implements Serializable { - protected String hilighOffset(String text, long offset) { - return Highlighting.hilighOffset(text, offset); - } - public int operands[]; - public String instructionName = ""; - public int instructionCode = 0; + protected String hilighOffset(String text, long offset) { + return Highlighting.hilighOffset(text, offset); + } + public int operands[]; + public String instructionName = ""; + public int instructionCode = 0; - public InstructionDefinition(int instructionCode, String instructionName, int operands[]) { - this.instructionCode = instructionCode; - this.instructionName = instructionName; - this.operands = operands; - } + public InstructionDefinition(int instructionCode, String instructionName, int operands[]) { + this.instructionCode = instructionCode; + this.instructionName = instructionName; + this.operands = operands; + } - @Override - public String toString() { - String s = instructionName; - for (int i = 0; i < operands.length; i++) { - if ((operands[i] & 0xff00) == AVM2Code.OPT_U30) { - s += " U30"; - } - if ((operands[i] & 0xff00) == AVM2Code.OPT_U8) { - s += " U8"; - } - if ((operands[i] & 0xff00) == AVM2Code.OPT_BYTE) { - s += " BYTE"; - } - if ((operands[i] & 0xff00) == AVM2Code.OPT_S24) { - s += " S24"; - } - if ((operands[i] & 0xff00) == AVM2Code.OPT_CASE_OFFSETS) { - s += " U30 S24,[S24]..."; - } - } - return s; - } + @Override + public String toString() { + String s = instructionName; + for (int i = 0; i < operands.length; i++) { + if ((operands[i] & 0xff00) == AVM2Code.OPT_U30) { + s += " U30"; + } + if ((operands[i] & 0xff00) == AVM2Code.OPT_U8) { + s += " U8"; + } + if ((operands[i] & 0xff00) == AVM2Code.OPT_BYTE) { + s += " BYTE"; + } + if ((operands[i] & 0xff00) == AVM2Code.OPT_S24) { + s += " S24"; + } + if ((operands[i] & 0xff00) == AVM2Code.OPT_CASE_OFFSETS) { + s += " U30 S24,[S24]..."; + } + } + return s; + } - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - throw new UnsupportedOperationException("Instruction " + instructionName + " not implemented"); - } + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + throw new UnsupportedOperationException("Instruction " + instructionName + " not implemented"); + } - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - } + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + } - protected FullMultinameTreeItem resolveMultiname(Stack stack, ConstantPool constants, int multinameIndex, AVM2Instruction ins) { - GraphTargetItem ns = null; - GraphTargetItem name = null; - if (constants.constant_multiname[multinameIndex].needsName()) { - name = (GraphTargetItem) stack.pop(); - } - if (constants.constant_multiname[multinameIndex].needsNs()) { - ns = (GraphTargetItem) stack.pop(); - } - return new FullMultinameTreeItem(ins, multinameIndex, name, ns); - } + protected FullMultinameTreeItem resolveMultiname(Stack stack, ConstantPool constants, int multinameIndex, AVM2Instruction ins) { + GraphTargetItem ns = null; + GraphTargetItem name = null; + if (constants.constant_multiname[multinameIndex].needsName()) { + name = (GraphTargetItem) stack.pop(); + } + if (constants.constant_multiname[multinameIndex].needsNs()) { + ns = (GraphTargetItem) stack.pop(); + } + return new FullMultinameTreeItem(ins, multinameIndex, name, ns); + } - protected int resolvedCount(ConstantPool constants, int multinameIndex) { - int pos = 0; - if (constants.constant_multiname[multinameIndex].needsNs()) { - pos++; - } - if (constants.constant_multiname[multinameIndex].needsName()) { - pos++; - } - return pos; + protected int resolvedCount(ConstantPool constants, int multinameIndex) { + int pos = 0; + if (constants.constant_multiname[multinameIndex].needsNs()) { + pos++; + } + if (constants.constant_multiname[multinameIndex].needsName()) { + pos++; + } + return pos; - } + } - protected String resolveMultinameNoPop(int pos, Stack stack, ConstantPool constants, int multinameIndex, AVM2Instruction ins, List fullyQualifiedNames) { - String ns = ""; - String name; - if (constants.constant_multiname[multinameIndex].needsNs()) { - ns = "[" + stack.get(pos) + "]"; - pos++; - } - if (constants.constant_multiname[multinameIndex].needsName()) { - name = stack.get(pos).toString(); - } else { - name = hilighOffset(constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames), ins.offset); - } - return name + ns; - } + protected String resolveMultinameNoPop(int pos, Stack stack, ConstantPool constants, int multinameIndex, AVM2Instruction ins, List fullyQualifiedNames) { + String ns = ""; + String name; + if (constants.constant_multiname[multinameIndex].needsNs()) { + ns = "[" + stack.get(pos) + "]"; + pos++; + } + if (constants.constant_multiname[multinameIndex].needsName()) { + name = stack.get(pos).toString(); + } else { + name = hilighOffset(constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames), ins.offset); + } + return name + ns; + } - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 0; - } + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 0; - } + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/SetTypeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/SetTypeIns.java index 090ad83b4..d6d787294 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/SetTypeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/SetTypeIns.java @@ -24,5 +24,5 @@ import java.util.Stack; public interface SetTypeIns { - public abstract String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, HashMap localRegNames, List fullyQualifiedNames); + public abstract String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, HashMap localRegNames, List fullyQualifiedNames); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/TagInstruction.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/TagInstruction.java index 00c358658..d6942ac6a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/TagInstruction.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/TagInstruction.java @@ -22,7 +22,7 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions; */ public class TagInstruction extends InstructionDefinition { - public TagInstruction(String tagName) { - super(-1, tagName, new int[0]); - } + public TagInstruction(String tagName) { + super(-1, tagName, new int[0]); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java index 603dc24ff..3cb85b85b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java @@ -28,20 +28,20 @@ import java.util.Stack; public class AddIIns extends AddIns { - public AddIIns() { - instructionName = "add_i"; - instructionCode = 0xc5; - } + public AddIIns() { + instructionName = "add_i"; + instructionCode = 0xc5; + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new AddTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new AddTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java index fc2ad22c7..7c7179534 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java @@ -30,41 +30,41 @@ import java.util.Stack; public class AddIns extends InstructionDefinition { - public AddIns() { - super(0xa0, "add", new int[]{}); - } + public AddIns() { + super(0xa0, "add", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object o1 = lda.operandStack.pop(); - Object o2 = lda.operandStack.pop(); - if ((o1 instanceof Long) && ((o2 instanceof Long))) { - Long ret = new Long(((Long) o1).longValue() + ((Long) o2).longValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { - Double ret = new Double(((Double) o1).doubleValue() + ((Double) o2).doubleValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Long) && ((o2 instanceof Double))) { - Double ret = new Double(((Long) o1).longValue() + ((Double) o2).doubleValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Double) && ((o2 instanceof Long))) { - Double ret = new Double(((Double) o1).doubleValue() + ((Long) o2).longValue()); - lda.operandStack.push(ret); - } else { - String s = o1.toString() + o2.toString(); - lda.operandStack.push(s); - } - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object o1 = lda.operandStack.pop(); + Object o2 = lda.operandStack.pop(); + if ((o1 instanceof Long) && ((o2 instanceof Long))) { + Long ret = new Long(((Long) o1).longValue() + ((Long) o2).longValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { + Double ret = new Double(((Double) o1).doubleValue() + ((Double) o2).doubleValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Long) && ((o2 instanceof Double))) { + Double ret = new Double(((Long) o1).longValue() + ((Double) o2).doubleValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Double) && ((o2 instanceof Long))) { + Double ret = new Double(((Double) o1).doubleValue() + ((Long) o2).longValue()); + lda.operandStack.push(ret); + } else { + String s = o1.toString() + o2.toString(); + lda.operandStack.push(s); + } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new AddTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new AddTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java index 6792ecb8c..bcff4ecd3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java @@ -30,35 +30,35 @@ import java.util.Stack; public class DecrementIIns extends InstructionDefinition { - public DecrementIIns() { - super(0xc1, "decrement_i", new int[]{}); - } + public DecrementIIns() { + super(0xc1, "decrement_i", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object obj = lda.operandStack.pop(); - if (obj instanceof Long) { - Long obj2 = ((Long) obj).longValue() - 1; - lda.operandStack.push(obj2); - } else if (obj instanceof Double) { - Double obj2 = ((Double) obj).doubleValue() - 1; - lda.operandStack.push(obj2); - } - if (obj instanceof String) { - Double obj2 = Double.parseDouble((String) obj) - 1; - lda.operandStack.push(obj2); - } else { - throw new RuntimeException("Cannot decrement local register"); - } - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object obj = lda.operandStack.pop(); + if (obj instanceof Long) { + Long obj2 = ((Long) obj).longValue() - 1; + lda.operandStack.push(obj2); + } else if (obj instanceof Double) { + Double obj2 = ((Double) obj).doubleValue() - 1; + lda.operandStack.push(obj2); + } + if (obj instanceof String) { + Double obj2 = Double.parseDouble((String) obj) - 1; + lda.operandStack.push(obj2); + } else { + throw new RuntimeException("Cannot decrement local register"); + } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new DecrementTreeItem(ins, (GraphTargetItem) stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new DecrementTreeItem(ins, (GraphTargetItem) stack.pop())); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java index 0bf9362c7..9db7a272c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java @@ -30,35 +30,35 @@ import java.util.Stack; public class DecrementIns extends InstructionDefinition { - public DecrementIns() { - super(0x93, "decrement", new int[]{}); - } + public DecrementIns() { + super(0x93, "decrement", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object obj = lda.operandStack.pop(); - if (obj instanceof Long) { - Long obj2 = ((Long) obj).longValue() - 1; - lda.operandStack.push(obj2); - } else if (obj instanceof Double) { - Double obj2 = ((Double) obj).doubleValue() - 1; - lda.operandStack.push(obj2); - } - if (obj instanceof String) { - Double obj2 = Double.parseDouble((String) obj) - 1; - lda.operandStack.push(obj2); - } else { - throw new RuntimeException("Cannot decrement local register"); - } - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object obj = lda.operandStack.pop(); + if (obj instanceof Long) { + Long obj2 = ((Long) obj).longValue() - 1; + lda.operandStack.push(obj2); + } else if (obj instanceof Double) { + Double obj2 = ((Double) obj).doubleValue() - 1; + lda.operandStack.push(obj2); + } + if (obj instanceof String) { + Double obj2 = Double.parseDouble((String) obj) - 1; + lda.operandStack.push(obj2); + } else { + throw new RuntimeException("Cannot decrement local register"); + } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new DecrementTreeItem(ins, (GraphTargetItem) stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new DecrementTreeItem(ins, (GraphTargetItem) stack.pop())); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DivideIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DivideIns.java index 4438fcd00..13c882cd1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DivideIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DivideIns.java @@ -30,40 +30,40 @@ import java.util.Stack; public class DivideIns extends InstructionDefinition { - public DivideIns() { - super(0xa3, "divide", new int[]{}); - } + public DivideIns() { + super(0xa3, "divide", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object o2 = lda.operandStack.pop(); - Object o1 = lda.operandStack.pop(); - if ((o1 instanceof Long) && ((o2 instanceof Long))) { - Long ret = new Long(((Long) o1).longValue() / ((Long) o2).longValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { - Double ret = new Double(((Double) o1).doubleValue() / ((Double) o2).doubleValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Long) && ((o2 instanceof Double))) { - Double ret = new Double(((Long) o1).longValue() / ((Double) o2).doubleValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Double) && ((o2 instanceof Long))) { - Double ret = new Double(((Double) o1).doubleValue() / ((Long) o2).longValue()); - lda.operandStack.push(ret); - } else { - throw new RuntimeException("Cannot divide"); - } - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object o2 = lda.operandStack.pop(); + Object o1 = lda.operandStack.pop(); + if ((o1 instanceof Long) && ((o2 instanceof Long))) { + Long ret = new Long(((Long) o1).longValue() / ((Long) o2).longValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { + Double ret = new Double(((Double) o1).doubleValue() / ((Double) o2).doubleValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Long) && ((o2 instanceof Double))) { + Double ret = new Double(((Long) o1).longValue() / ((Double) o2).doubleValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Double) && ((o2 instanceof Long))) { + Double ret = new Double(((Double) o1).doubleValue() / ((Long) o2).longValue()); + lda.operandStack.push(ret); + } else { + throw new RuntimeException("Cannot divide"); + } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new DivideTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new DivideTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIIns.java index 2ef0632dc..e015626e7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIIns.java @@ -29,17 +29,17 @@ import java.util.Stack; public class IncrementIIns extends InstructionDefinition { - public IncrementIIns() { - super(0xc0, "increment_i", new int[]{}); - } + public IncrementIIns() { + super(0xc0, "increment_i", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new IncrementTreeItem(ins, (GraphTargetItem) stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new IncrementTreeItem(ins, (GraphTargetItem) stack.pop())); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIns.java index ae1d43374..1d74811a8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIns.java @@ -29,17 +29,17 @@ import java.util.Stack; public class IncrementIns extends InstructionDefinition { - public IncrementIns() { - super(0x91, "increment", new int[]{}); - } + public IncrementIns() { + super(0x91, "increment", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new IncrementTreeItem(ins, (GraphTargetItem) stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new IncrementTreeItem(ins, (GraphTargetItem) stack.pop())); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/ModuloIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/ModuloIns.java index 827bb350e..a07a08a42 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/ModuloIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/ModuloIns.java @@ -30,32 +30,32 @@ import java.util.Stack; public class ModuloIns extends InstructionDefinition { - public ModuloIns() { - super(0xa4, "modulo", new int[]{}); - } + public ModuloIns() { + super(0xa4, "modulo", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object o1 = lda.operandStack.pop(); - Object o2 = lda.operandStack.pop(); + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object o1 = lda.operandStack.pop(); + Object o2 = lda.operandStack.pop(); - if ((o1 instanceof Long) && ((o2 instanceof Long))) { - Long ret = new Long(((Long) o2).longValue() % ((Long) o1).longValue()); - lda.operandStack.push(ret); - } else { - throw new RuntimeException("Cannot modulo"); - } - } + if ((o1 instanceof Long) && ((o2 instanceof Long))) { + Long ret = new Long(((Long) o2).longValue() % ((Long) o1).longValue()); + lda.operandStack.push(ret); + } else { + throw new RuntimeException("Cannot modulo"); + } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new ModuloTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new ModuloTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIIns.java index 82bdebb98..de3f72116 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIIns.java @@ -29,19 +29,19 @@ import java.util.Stack; public class MultiplyIIns extends InstructionDefinition { - public MultiplyIIns() { - super(0xc7, "multiply_i", new int[]{}); - } + public MultiplyIIns() { + super(0xc7, "multiply_i", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new MultiplyTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new MultiplyTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIns.java index 66cc65f64..dfc71ae00 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIns.java @@ -30,40 +30,40 @@ import java.util.Stack; public class MultiplyIns extends InstructionDefinition { - public MultiplyIns() { - super(0xa2, "multiply", new int[]{}); - } + public MultiplyIns() { + super(0xa2, "multiply", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object o1 = lda.operandStack.pop(); - Object o2 = lda.operandStack.pop(); - if ((o1 instanceof Long) && ((o2 instanceof Long))) { - Long ret = new Long(((Long) o1).longValue() * ((Long) o2).longValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { - Double ret = new Double(((Double) o1).doubleValue() * ((Double) o2).doubleValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Long) && ((o2 instanceof Double))) { - Double ret = new Double(((Long) o1).longValue() * ((Double) o2).doubleValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Double) && ((o2 instanceof Long))) { - Double ret = new Double(((Double) o1).doubleValue() * ((Long) o2).longValue()); - lda.operandStack.push(ret); - } else { - throw new RuntimeException("Cannot multiply"); - } - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object o1 = lda.operandStack.pop(); + Object o2 = lda.operandStack.pop(); + if ((o1 instanceof Long) && ((o2 instanceof Long))) { + Long ret = new Long(((Long) o1).longValue() * ((Long) o2).longValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { + Double ret = new Double(((Double) o1).doubleValue() * ((Double) o2).doubleValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Long) && ((o2 instanceof Double))) { + Double ret = new Double(((Long) o1).longValue() * ((Double) o2).doubleValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Double) && ((o2 instanceof Long))) { + Double ret = new Double(((Double) o1).doubleValue() * ((Long) o2).longValue()); + lda.operandStack.push(ret); + } else { + throw new RuntimeException("Cannot multiply"); + } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new MultiplyTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new MultiplyTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIIns.java index 19e74cacc..ac0f90959 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIIns.java @@ -29,18 +29,18 @@ import java.util.Stack; public class NegateIIns extends InstructionDefinition { - public NegateIIns() { - super(0xc4, "negate_i", new int[]{}); - } + public NegateIIns() { + super(0xc4, "negate_i", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v = (GraphTargetItem) stack.pop(); - stack.push(new NegTreeItem(ins, v)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v = (GraphTargetItem) stack.pop(); + stack.push(new NegTreeItem(ins, v)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIns.java index bd147368e..486db1eb6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIns.java @@ -29,18 +29,18 @@ import java.util.Stack; public class NegateIns extends InstructionDefinition { - public NegateIns() { - super(0x90, "negate", new int[]{}); - } + public NegateIns() { + super(0x90, "negate", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v = (GraphTargetItem) stack.pop(); - stack.push(new NegTreeItem(ins, v)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v = (GraphTargetItem) stack.pop(); + stack.push(new NegTreeItem(ins, v)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NotIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NotIns.java index 2092f1e12..97651f973 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NotIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NotIns.java @@ -29,18 +29,18 @@ import java.util.Stack; public class NotIns extends InstructionDefinition { - public NotIns() { - super(0x96, "not", new int[]{}); - } + public NotIns() { + super(0x96, "not", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v = (GraphTargetItem) stack.pop(); - stack.push(new NotItem(ins, v)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v = (GraphTargetItem) stack.pop(); + stack.push(new NotItem(ins, v)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIIns.java index 08afa27be..57105066e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIIns.java @@ -29,19 +29,19 @@ import java.util.Stack; public class SubtractIIns extends InstructionDefinition { - public SubtractIIns() { - super(0xc6, "subtract_i", new int[]{}); - } + public SubtractIIns() { + super(0xc6, "subtract_i", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new SubtractTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new SubtractTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIns.java index 4aee49f89..60ab40d55 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIns.java @@ -29,19 +29,19 @@ import java.util.Stack; public class SubtractIns extends InstructionDefinition { - public SubtractIns() { - super(0xa1, "subtract", new int[]{}); - } + public SubtractIns() { + super(0xa1, "subtract", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new SubtractTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new SubtractTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitAndIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitAndIns.java index e3f287c71..02b61c769 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitAndIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitAndIns.java @@ -30,27 +30,27 @@ import java.util.Stack; public class BitAndIns extends InstructionDefinition { - public BitAndIns() { - super(0xa8, "bitand", new int[]{}); - } + public BitAndIns() { + super(0xa8, "bitand", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Long value2 = (Long) lda.operandStack.pop(); - Long value1 = (Long) lda.operandStack.pop(); - Long value3 = value1 & value2; - lda.operandStack.push(value3); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Long value2 = (Long) lda.operandStack.pop(); + Long value1 = (Long) lda.operandStack.pop(); + Long value3 = value1 & value2; + lda.operandStack.push(value3); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new BitAndTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new BitAndTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java index 1a3a1e285..b3edae276 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java @@ -30,25 +30,25 @@ import java.util.Stack; public class BitNotIns extends InstructionDefinition { - public BitNotIns() { - super(0x97, "bitnot", new int[]{}); - } + public BitNotIns() { + super(0x97, "bitnot", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Long value = (Long) lda.operandStack.pop(); - Long ret = new Long(-value.longValue()); - lda.operandStack.push(ret); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Long value = (Long) lda.operandStack.pop(); + Long ret = new Long(-value.longValue()); + lda.operandStack.push(ret); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v = (GraphTargetItem) stack.pop(); - stack.push(new BitNotTreeItem(ins, v)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v = (GraphTargetItem) stack.pop(); + stack.push(new BitNotTreeItem(ins, v)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitOrIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitOrIns.java index d16a93e4a..e9a651816 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitOrIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitOrIns.java @@ -30,27 +30,27 @@ import java.util.Stack; public class BitOrIns extends InstructionDefinition { - public BitOrIns() { - super(0xa9, "bitor", new int[]{}); - } + public BitOrIns() { + super(0xa9, "bitor", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Long value2 = (Long) lda.operandStack.pop(); - Long value1 = (Long) lda.operandStack.pop(); - Long value3 = value1 | value2; - lda.operandStack.push(value3); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Long value2 = (Long) lda.operandStack.pop(); + Long value1 = (Long) lda.operandStack.pop(); + Long value3 = value1 | value2; + lda.operandStack.push(value3); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new BitOrTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new BitOrTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitXorIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitXorIns.java index 7ee8b2379..71e66406e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitXorIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitXorIns.java @@ -30,27 +30,27 @@ import java.util.Stack; public class BitXorIns extends InstructionDefinition { - public BitXorIns() { - super(0xaa, "bitxor", new int[]{}); - } + public BitXorIns() { + super(0xaa, "bitxor", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Long value2 = (Long) lda.operandStack.pop(); - Long value1 = (Long) lda.operandStack.pop(); - Long value3 = value1 ^ value2; - lda.operandStack.push(value3); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Long value2 = (Long) lda.operandStack.pop(); + Long value1 = (Long) lda.operandStack.pop(); + Long value3 = value1 ^ value2; + lda.operandStack.push(value3); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new BitXorTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new BitXorTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/LShiftIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/LShiftIns.java index 7f37e85d7..9ea767573 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/LShiftIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/LShiftIns.java @@ -29,19 +29,19 @@ import java.util.Stack; public class LShiftIns extends InstructionDefinition { - public LShiftIns() { - super(0xa5, "lshift", new int[]{}); - } + public LShiftIns() { + super(0xa5, "lshift", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LShiftTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new LShiftTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/RShiftIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/RShiftIns.java index 4334bf555..8cf524747 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/RShiftIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/RShiftIns.java @@ -29,19 +29,19 @@ import java.util.Stack; public class RShiftIns extends InstructionDefinition { - public RShiftIns() { - super(0xa6, "rshift", new int[]{}); - } + public RShiftIns() { + super(0xa6, "rshift", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new RShiftTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new RShiftTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/URShiftIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/URShiftIns.java index 69642937c..0a9b11e17 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/URShiftIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/URShiftIns.java @@ -29,19 +29,19 @@ import java.util.Stack; public class URShiftIns extends InstructionDefinition { - public URShiftIns() { - super(0xa7, "urshift", new int[]{}); - } + public URShiftIns() { + super(0xa7, "urshift", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new URShiftTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new URShiftTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/EqualsIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/EqualsIns.java index 3d20df5f4..69767e3b5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/EqualsIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/EqualsIns.java @@ -30,27 +30,27 @@ import java.util.Stack; public class EqualsIns extends InstructionDefinition { - public EqualsIns() { - super(0xab, "equals", new int[]{}); - } + public EqualsIns() { + super(0xab, "equals", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object obj1 = lda.operandStack.pop(); - Object obj2 = lda.operandStack.pop(); - Boolean res = obj1.equals(obj2); - lda.operandStack.push(res); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object obj1 = lda.operandStack.pop(); + Object obj2 = lda.operandStack.pop(); + Boolean res = obj1.equals(obj2); + lda.operandStack.push(res); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new EqTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new EqTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/GreaterEqualsIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/GreaterEqualsIns.java index dd73ebda1..528af9539 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/GreaterEqualsIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/GreaterEqualsIns.java @@ -29,19 +29,19 @@ import java.util.Stack; public class GreaterEqualsIns extends InstructionDefinition { - public GreaterEqualsIns() { - super(0xb0, "greaterequals", new int[]{}); - } + public GreaterEqualsIns() { + super(0xb0, "greaterequals", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new GeTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new GeTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/GreaterThanIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/GreaterThanIns.java index 0d5caa228..19cb4de40 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/GreaterThanIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/GreaterThanIns.java @@ -29,19 +29,19 @@ import java.util.Stack; public class GreaterThanIns extends InstructionDefinition { - public GreaterThanIns() { - super(0xaf, "greaterthan", new int[]{}); - } + public GreaterThanIns() { + super(0xaf, "greaterthan", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LtTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new LtTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/LessEqualsIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/LessEqualsIns.java index 4c287a79d..b517d5902 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/LessEqualsIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/LessEqualsIns.java @@ -29,19 +29,19 @@ import java.util.Stack; public class LessEqualsIns extends InstructionDefinition { - public LessEqualsIns() { - super(0xae, "lessequals", new int[]{}); - } + public LessEqualsIns() { + super(0xae, "lessequals", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LeTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new LeTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/LessThanIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/LessThanIns.java index 146aa6f3f..846e47d44 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/LessThanIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/LessThanIns.java @@ -29,19 +29,19 @@ import java.util.Stack; public class LessThanIns extends InstructionDefinition { - public LessThanIns() { - super(0xad, "lessthan", new int[]{}); - } + public LessThanIns() { + super(0xad, "lessthan", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new GtTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new GtTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/StrictEqualsIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/StrictEqualsIns.java index a2e570aff..555177cb4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/StrictEqualsIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparsion/StrictEqualsIns.java @@ -29,19 +29,19 @@ import java.util.Stack; public class StrictEqualsIns extends InstructionDefinition { - public StrictEqualsIns() { - super(0xac, "strictequals", new int[]{}); - } + public StrictEqualsIns() { + super(0xac, "strictequals", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new StrictEqTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new StrictEqTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java index 5f12be8fc..7b95fdebc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java @@ -41,78 +41,78 @@ import java.util.Stack; public class ConstructIns extends InstructionDefinition { - public ConstructIns() { - super(0x42, "construct", new int[]{AVM2Code.DAT_ARG_COUNT}); - } + public ConstructIns() { + super(0x42, "construct", new int[]{AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - /*int argCount = (int) ((Long) arguments.get(0)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - Object obj = lda.operandStack.pop();*/ - throw new RuntimeException("Cannot call constructor"); - //call construct property of obj - //push new instance - } - - public static boolean walkXML(GraphTargetItem item, List list) { - boolean ret = true; - if (item instanceof StringTreeItem) { - list.add(item); - } else if (item instanceof AddTreeItem) { - ret = ret && walkXML(((AddTreeItem) item).leftSide, list); - ret = ret && walkXML(((AddTreeItem) item).rightSide, list); - } else if ((item instanceof EscapeXElemTreeItem) || (item instanceof EscapeXAttrTreeItem)) { - list.add(item); - } else { - return false; - } - return ret; - } - - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int argCount = ins.operands[0]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (GraphTargetItem) stack.pop()); - } - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - - FullMultinameTreeItem xmlMult = null; - boolean isXML = false; - if (obj instanceof GetPropertyTreeItem) { - GetPropertyTreeItem gpt = (GetPropertyTreeItem) obj; - if (gpt.object instanceof FindPropertyTreeItem) { - FindPropertyTreeItem fpt = (FindPropertyTreeItem) gpt.object; - xmlMult = fpt.propertyName; - isXML = xmlMult.isXML(constants, localRegNames, fullyQualifiedNames) && xmlMult.isXML(constants, localRegNames, fullyQualifiedNames); + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + /*int argCount = (int) ((Long) arguments.get(0)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); } - } - if (obj instanceof GetLexTreeItem) { - GetLexTreeItem glt = (GetLexTreeItem) obj; - isXML = glt.propertyName.getName(constants, fullyQualifiedNames).equals("XML"); - } + Object obj = lda.operandStack.pop();*/ + throw new RuntimeException("Cannot call constructor"); + //call construct property of obj + //push new instance + } - if (isXML) { - if (args.size() == 1) { - GraphTargetItem arg = args.get(0); - List xmlLines = new ArrayList(); - if (walkXML(arg, xmlLines)) { - stack.push(new XMLTreeItem(ins, xmlLines)); - return; + public static boolean walkXML(GraphTargetItem item, List list) { + boolean ret = true; + if (item instanceof StringTreeItem) { + list.add(item); + } else if (item instanceof AddTreeItem) { + ret = ret && walkXML(((AddTreeItem) item).leftSide, list); + ret = ret && walkXML(((AddTreeItem) item).rightSide, list); + } else if ((item instanceof EscapeXElemTreeItem) || (item instanceof EscapeXAttrTreeItem)) { + list.add(item); + } else { + return false; + } + return ret; + } + + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int argCount = ins.operands[0]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (GraphTargetItem) stack.pop()); + } + GraphTargetItem obj = (GraphTargetItem) stack.pop(); + + FullMultinameTreeItem xmlMult = null; + boolean isXML = false; + if (obj instanceof GetPropertyTreeItem) { + GetPropertyTreeItem gpt = (GetPropertyTreeItem) obj; + if (gpt.object instanceof FindPropertyTreeItem) { + FindPropertyTreeItem fpt = (FindPropertyTreeItem) gpt.object; + xmlMult = fpt.propertyName; + isXML = xmlMult.isXML(constants, localRegNames, fullyQualifiedNames) && xmlMult.isXML(constants, localRegNames, fullyQualifiedNames); } - } - } + } + if (obj instanceof GetLexTreeItem) { + GetLexTreeItem glt = (GetLexTreeItem) obj; + isXML = glt.propertyName.getName(constants, fullyQualifiedNames).equals("XML"); + } - stack.push(new ConstructTreeItem(ins, obj, args)); - } + if (isXML) { + if (args.size() == 1) { + GraphTargetItem arg = args.get(0); + List xmlLines = new ArrayList(); + if (walkXML(arg, xmlLines)) { + stack.push(new XMLTreeItem(ins, xmlLines)); + return; + } + } + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -ins.operands[0] - 1 + 1; - } + stack.push(new ConstructTreeItem(ins, obj, args)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -ins.operands[0] - 1 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructPropIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructPropIns.java index c1a9b37f1..0ea4ef96f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructPropIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructPropIns.java @@ -34,60 +34,60 @@ import java.util.Stack; public class ConstructPropIns extends InstructionDefinition { - public ConstructPropIns() { - super(0x4a, "constructprop", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); - } + public ConstructPropIns() { + super(0x4a, "constructprop", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - /*int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); - int argCount = (int) ((Long) arguments.get(1)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - }*/ - //if multiname[multinameIndex] is runtime - //pop(name) pop(ns) - throw new RuntimeException("Cannot construct property"); - //create property - //push new instance - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + /*int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); + int argCount = (int) ((Long) arguments.get(1)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + }*/ + //if multiname[multinameIndex] is runtime + //pop(name) pop(ns) + throw new RuntimeException("Cannot construct property"); + //create property + //push new instance + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - int argCount = ins.operands[1]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (GraphTargetItem) stack.pop()); - } - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (GraphTargetItem) stack.pop()); + } + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem obj = (GraphTargetItem) stack.pop(); - if (multiname.isXML(constants, localRegNames, fullyQualifiedNames)) { - if (args.size() == 1) { - GraphTargetItem arg = args.get(0); - List xmlLines = new ArrayList(); - if (ConstructIns.walkXML(arg, xmlLines)) { - stack.push(new XMLTreeItem(ins, xmlLines)); - return; + if (multiname.isXML(constants, localRegNames, fullyQualifiedNames)) { + if (args.size() == 1) { + GraphTargetItem arg = args.get(0); + List xmlLines = new ArrayList(); + if (ConstructIns.walkXML(arg, xmlLines)) { + stack.push(new XMLTreeItem(ins, xmlLines)); + return; + } } - } - } + } - stack.push(new ConstructPropTreeItem(ins, obj, multiname, args)); - } + stack.push(new ConstructPropTreeItem(ins, obj, multiname, args)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -ins.operands[1] - 1 + 1; - int multinameIndex = ins.operands[0]; - if (abc.constants.constant_multiname[multinameIndex].needsName()) { - ret--; - } - if (abc.constants.constant_multiname[multinameIndex].needsNs()) { - ret--; - } - return ret; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -ins.operands[1] - 1 + 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { + ret--; + } + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { + ret--; + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructSuperIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructSuperIns.java index 5c3400a6d..59de83ba6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructSuperIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructSuperIns.java @@ -32,36 +32,36 @@ import java.util.Stack; public class ConstructSuperIns extends InstructionDefinition { - public ConstructSuperIns() { - super(0x49, "constructsuper", new int[]{AVM2Code.DAT_ARG_COUNT}); - } + public ConstructSuperIns() { + super(0x49, "constructsuper", new int[]{AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - /*int argCount = (int) ((Long) arguments.get(0)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - Object obj = lda.operandStack.pop();*/ - throw new RuntimeException("Cannot call super constructor"); - //call construct property of obj - //do not push anything - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + /*int argCount = (int) ((Long) arguments.get(0)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + Object obj = lda.operandStack.pop();*/ + throw new RuntimeException("Cannot call super constructor"); + //call construct property of obj + //do not push anything + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int argCount = ins.operands[0]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (GraphTargetItem) stack.pop()); - } - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - output.add(new ConstructSuperTreeItem(ins, obj, args)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int argCount = ins.operands[0]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (GraphTargetItem) stack.pop()); + } + GraphTargetItem obj = (GraphTargetItem) stack.pop(); + output.add(new ConstructSuperTreeItem(ins, obj, args)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -ins.operands[0] - 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -ins.operands[0] - 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewActivationIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewActivationIns.java index 1a2202739..5ae249966 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewActivationIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewActivationIns.java @@ -29,17 +29,17 @@ import java.util.Stack; public class NewActivationIns extends InstructionDefinition { - public NewActivationIns() { - super(0x57, "newactivation", new int[]{}); - } + public NewActivationIns() { + super(0x57, "newactivation", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new NewActivationTreeItem(ins)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new NewActivationTreeItem(ins)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewArrayIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewArrayIns.java index 9d7da8459..340aad014 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewArrayIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewArrayIns.java @@ -31,22 +31,22 @@ import java.util.Stack; public class NewArrayIns extends InstructionDefinition { - public NewArrayIns() { - super(0x56, "newarray", new int[]{AVM2Code.DAT_ARG_COUNT}); - } + public NewArrayIns() { + super(0x56, "newarray", new int[]{AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int argCount = ins.operands[0]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (GraphTargetItem) stack.pop()); - } - stack.push(new NewArrayTreeItem(ins, args)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int argCount = ins.operands[0]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (GraphTargetItem) stack.pop()); + } + stack.push(new NewArrayTreeItem(ins, args)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -ins.operands[0] + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -ins.operands[0] + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewCatchIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewCatchIns.java index fa9d1fce7..44062b433 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewCatchIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewCatchIns.java @@ -30,18 +30,18 @@ import java.util.Stack; public class NewCatchIns extends InstructionDefinition { - public NewCatchIns() { - super(0x5a, "newcatch", new int[]{AVM2Code.DAT_EXCEPTION_INDEX}); - } + public NewCatchIns() { + super(0x5a, "newcatch", new int[]{AVM2Code.DAT_EXCEPTION_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int exInfo = ins.operands[0]; - stack.push(new ExceptionTreeItem(body.exceptions[exInfo])); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int exInfo = ins.operands[0]; + stack.push(new ExceptionTreeItem(body.exceptions[exInfo])); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java index 143f4a947..8d7c70054 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java @@ -31,19 +31,19 @@ import java.util.Stack; public class NewClassIns extends InstructionDefinition { - public NewClassIns() { - super(0x58, "newclass", new int[]{AVM2Code.DAT_CLASS_INDEX}); - } + public NewClassIns() { + super(0x58, "newclass", new int[]{AVM2Code.DAT_CLASS_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int clsIndex = ins.operands[0]; - String baseType = stack.pop().toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); - stack.push(new UnparsedTreeItem(ins, "new " + abc.constants.constant_multiname[abc.instance_info[clsIndex].name_index].getName(constants, fullyQualifiedNames) + ".class extends " + baseType)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int clsIndex = ins.operands[0]; + String baseType = stack.pop().toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); + stack.push(new UnparsedTreeItem(ins, "new " + abc.constants.constant_multiname[abc.instance_info[clsIndex].name_index].getName(constants, fullyQualifiedNames) + ".class extends " + baseType)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java index a791e5e4f..b27d094c5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java @@ -34,30 +34,30 @@ import java.util.logging.Logger; public class NewFunctionIns extends InstructionDefinition { - public NewFunctionIns() { - super(0x40, "newfunction", new int[]{AVM2Code.DAT_METHOD_INDEX}); - } + public NewFunctionIns() { + super(0x40, "newfunction", new int[]{AVM2Code.DAT_METHOD_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int methodIndex = ins.operands[0]; - MethodBody mybody = abc.findBody(methodIndex); - String bodyStr = ""; - String paramStr = ""; - if (mybody != null) { - try{ - bodyStr = Highlighting.hilighMethodEnd() + mybody.toString("", false, isStatic, classIndex, abc, constants, method_info, new Stack()/*scopeStack*/, false, true, fullyQualifiedNames, null) + Highlighting.hilighMethodBegin(body.method_info); - }catch(Exception ex){ - Logger.getLogger(NewFunctionIns.class.getName()).log(Level.SEVERE, "error during newfunction", ex); - } - paramStr = method_info[methodIndex].getParamStr(constants, mybody, abc, fullyQualifiedNames); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int methodIndex = ins.operands[0]; + MethodBody mybody = abc.findBody(methodIndex); + String bodyStr = ""; + String paramStr = ""; + if (mybody != null) { + try { + bodyStr = Highlighting.hilighMethodEnd() + mybody.toString("", false, isStatic, classIndex, abc, constants, method_info, new Stack()/*scopeStack*/, false, true, fullyQualifiedNames, null) + Highlighting.hilighMethodBegin(body.method_info); + } catch (Exception ex) { + Logger.getLogger(NewFunctionIns.class.getName()).log(Level.SEVERE, "error during newfunction", ex); + } + paramStr = method_info[methodIndex].getParamStr(constants, mybody, abc, fullyQualifiedNames); + } - stack.push(new NewFunctionTreeItem(ins, "", paramStr, method_info[methodIndex].getReturnTypeStr(constants, fullyQualifiedNames), bodyStr)); - } + stack.push(new NewFunctionTreeItem(ins, "", paramStr, method_info[methodIndex].getReturnTypeStr(constants, fullyQualifiedNames), bodyStr)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewObjectIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewObjectIns.java index 7f5d9b1db..efcf471b8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewObjectIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewObjectIns.java @@ -32,24 +32,24 @@ import java.util.Stack; public class NewObjectIns extends InstructionDefinition { - public NewObjectIns() { - super(0x55, "newobject", new int[]{AVM2Code.DAT_ARG_COUNT}); - } + public NewObjectIns() { + super(0x55, "newobject", new int[]{AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int argCount = ins.operands[0]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - GraphTargetItem value = (GraphTargetItem) stack.pop(); - GraphTargetItem name = (GraphTargetItem) stack.pop(); - args.add(0, new NameValuePair(name, value)); - } - stack.push(new NewObjectTreeItem(ins, args)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int argCount = ins.operands[0]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + GraphTargetItem value = (GraphTargetItem) stack.pop(); + GraphTargetItem name = (GraphTargetItem) stack.pop(); + args.add(0, new NameValuePair(name, value)); + } + stack.push(new NewObjectTreeItem(ins, args)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -ins.operands[0] * 2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -ins.operands[0] * 2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/debug/DebugFileIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/debug/DebugFileIns.java index d611675dd..cbea5cd0b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/debug/DebugFileIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/debug/DebugFileIns.java @@ -21,7 +21,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class DebugFileIns extends InstructionDefinition { - public DebugFileIns() { - super(0xf1, "debugfile", new int[]{AVM2Code.DAT_STRING_INDEX}); - } + public DebugFileIns() { + super(0xf1, "debugfile", new int[]{AVM2Code.DAT_STRING_INDEX}); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/debug/DebugIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/debug/DebugIns.java index 5160a5c41..7fe167cef 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/debug/DebugIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/debug/DebugIns.java @@ -21,7 +21,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class DebugIns extends InstructionDefinition { - public DebugIns() { - super(0xef, "debug", new int[]{AVM2Code.DAT_DEBUG_TYPE, AVM2Code.DAT_STRING_INDEX, AVM2Code.DAT_REGISTER_INDEX, AVM2Code.OPT_U30}); - } + public DebugIns() { + super(0xef, "debug", new int[]{AVM2Code.DAT_DEBUG_TYPE, AVM2Code.DAT_STRING_INDEX, AVM2Code.DAT_REGISTER_INDEX, AVM2Code.OPT_U30}); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/debug/DebugLineIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/debug/DebugLineIns.java index 51700344b..9cd8bb683 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/debug/DebugLineIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/debug/DebugLineIns.java @@ -21,7 +21,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class DebugLineIns extends InstructionDefinition { - public DebugLineIns() { - super(0xf0, "debugline", new int[]{AVM2Code.DAT_LINENUM}); - } + public DebugLineIns() { + super(0xf0, "debugline", new int[]{AVM2Code.DAT_LINENUM}); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallIns.java index 2c7d16acc..30ddc7bca 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallIns.java @@ -32,37 +32,37 @@ import java.util.Stack; public class CallIns extends InstructionDefinition { - public CallIns() { - super(0x41, "call", new int[]{AVM2Code.DAT_ARG_COUNT}); - } + public CallIns() { + super(0x41, "call", new int[]{AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - /*int argCount = (int) ((Long) arguments.get(0)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - Object receiver = lda.operandStack.pop(); - Object function = lda.operandStack.pop();*/ - throw new RuntimeException("Call to unknown function"); - //push(result) - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + /*int argCount = (int) ((Long) arguments.get(0)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + Object receiver = lda.operandStack.pop(); + Object function = lda.operandStack.pop();*/ + throw new RuntimeException("Call to unknown function"); + //push(result) + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int argCount = ins.operands[0]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (GraphTargetItem) stack.pop()); - } - GraphTargetItem receiver = (GraphTargetItem) stack.pop(); - GraphTargetItem function = (GraphTargetItem) stack.pop(); - stack.push(new CallTreeItem(ins, receiver, function, args)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int argCount = ins.operands[0]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (GraphTargetItem) stack.pop()); + } + GraphTargetItem receiver = (GraphTargetItem) stack.pop(); + GraphTargetItem function = (GraphTargetItem) stack.pop(); + stack.push(new CallTreeItem(ins, receiver, function, args)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1 - ins.operands[0]; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1 - ins.operands[0]; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallMethodIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallMethodIns.java index 445f5095c..1349813ab 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallMethodIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallMethodIns.java @@ -32,38 +32,38 @@ import java.util.Stack; public class CallMethodIns extends InstructionDefinition { - public CallMethodIns() { - super(0x43, "callmethod", new int[]{AVM2Code.DAT_METHOD_INDEX, AVM2Code.DAT_ARG_COUNT}); - } + public CallMethodIns() { + super(0x43, "callmethod", new int[]{AVM2Code.DAT_METHOD_INDEX, AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - /*int methodIndex = (int) ((Long) arguments.get(0)).longValue(); //index of object's method - int argCount = (int) ((Long) arguments.get(1)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - Object receiver = lda.operandStack.pop();*/ - throw new RuntimeException("Call to unknown method"); - //push(result) - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + /*int methodIndex = (int) ((Long) arguments.get(0)).longValue(); //index of object's method + int argCount = (int) ((Long) arguments.get(1)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + Object receiver = lda.operandStack.pop();*/ + throw new RuntimeException("Call to unknown method"); + //push(result) + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int methodIndex = ins.operands[0]; - int argCount = ins.operands[1]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (GraphTargetItem) stack.pop()); - } - GraphTargetItem receiver = (GraphTargetItem) stack.pop(); - String methodName = method_info[methodIndex].getName(constants); - stack.push(new CallMethodTreeItem(ins, receiver, methodName, args)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int methodIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (GraphTargetItem) stack.pop()); + } + GraphTargetItem receiver = (GraphTargetItem) stack.pop(); + String methodName = method_info[methodIndex].getName(constants); + stack.push(new CallMethodTreeItem(ins, receiver, methodName, args)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1 - ins.operands[1]; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1 - ins.operands[1]; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java index 6864c920f..915642bc9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java @@ -30,35 +30,35 @@ import java.util.Stack; public class CallPropLexIns extends CallPropertyIns { - public CallPropLexIns() { - instructionName = "callproplex"; - instructionCode = 0x4c; - } + public CallPropLexIns() { + instructionName = "callproplex"; + instructionCode = 0x4c; + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - int argCount = ins.operands[1]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (GraphTargetItem) stack.pop()); - } - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem receiver = (GraphTargetItem) stack.pop(); + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (GraphTargetItem) stack.pop()); + } + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem receiver = (GraphTargetItem) stack.pop(); - stack.push(new CallPropertyTreeItem(ins, false, receiver, multiname, args)); - } + stack.push(new CallPropertyTreeItem(ins, false, receiver, multiname, args)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -ins.operands[1] - 1 + 1; - int multinameIndex = ins.operands[0]; - if (abc.constants.constant_multiname[multinameIndex].needsName()) { - ret--; - } - if (abc.constants.constant_multiname[multinameIndex].needsNs()) { - ret--; - } - return ret; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -ins.operands[1] - 1 + 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { + ret--; + } + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { + ret--; + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java index 87f0e8190..2274bdbdf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java @@ -33,52 +33,52 @@ import java.util.Stack; public class CallPropVoidIns extends InstructionDefinition { - public CallPropVoidIns() { - super(0x4f, "callpropvoid", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); - } + public CallPropVoidIns() { + super(0x4f, "callpropvoid", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - //same as callproperty + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + //same as callproperty /* - int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); - int argCount = (int) ((Long) arguments.get(1)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - //if multiname[multinameIndex] is runtime - //pop(name) pop(ns) - Object obj = lda.operandStack.pop();*/ - throw new RuntimeException("Call to unknown property"); - //do not push anything - } + int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); + int argCount = (int) ((Long) arguments.get(1)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + //if multiname[multinameIndex] is runtime + //pop(name) pop(ns) + Object obj = lda.operandStack.pop();*/ + throw new RuntimeException("Call to unknown property"); + //do not push anything + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - int argCount = ins.operands[1]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (GraphTargetItem) stack.pop()); - } - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (GraphTargetItem) stack.pop()); + } + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem receiver = (GraphTargetItem) stack.pop(); + GraphTargetItem receiver = (GraphTargetItem) stack.pop(); - output.add(new CallPropertyTreeItem(ins, true, receiver, multiname, args)); - } + output.add(new CallPropertyTreeItem(ins, true, receiver, multiname, args)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -ins.operands[1] - 1; - int multinameIndex = ins.operands[0]; - if (abc.constants.constant_multiname[multinameIndex].needsName()) { - ret--; - } - if (abc.constants.constant_multiname[multinameIndex].needsNs()) { - ret--; - } - return ret; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -ins.operands[1] - 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { + ret--; + } + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { + ret--; + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java index aa1bd35e5..02ead3c62 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java @@ -33,50 +33,50 @@ import java.util.Stack; public class CallPropertyIns extends InstructionDefinition { - public CallPropertyIns() { - super(0x46, "callproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); - } + public CallPropertyIns() { + super(0x46, "callproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - /*int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); - int argCount = (int) ((Long) arguments.get(1)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - //if multiname[multinameIndex] is runtime - //pop(name) pop(ns) - Object obj = lda.operandStack.pop();*/ - throw new RuntimeException("Call to unknown property"); - //push(result) - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + /*int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); + int argCount = (int) ((Long) arguments.get(1)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + //if multiname[multinameIndex] is runtime + //pop(name) pop(ns) + Object obj = lda.operandStack.pop();*/ + throw new RuntimeException("Call to unknown property"); + //push(result) + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - int argCount = ins.operands[1]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (GraphTargetItem) stack.pop()); - } - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (GraphTargetItem) stack.pop()); + } + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem receiver = (GraphTargetItem) stack.pop(); + GraphTargetItem receiver = (GraphTargetItem) stack.pop(); - stack.push(new CallPropertyTreeItem(ins, false, receiver, multiname, args)); - } + stack.push(new CallPropertyTreeItem(ins, false, receiver, multiname, args)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -ins.operands[1] - 1 + 1; - int multinameIndex = ins.operands[0]; - if (abc.constants.constant_multiname[multinameIndex].needsName()) { - ret--; - } - if (abc.constants.constant_multiname[multinameIndex].needsNs()) { - ret--; - } - return ret; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -ins.operands[1] - 1 + 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { + ret--; + } + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { + ret--; + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallStaticIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallStaticIns.java index e0866878c..c1fda0146 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallStaticIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallStaticIns.java @@ -32,38 +32,38 @@ import java.util.Stack; public class CallStaticIns extends InstructionDefinition { - public CallStaticIns() { - super(0x44, "callstatic", new int[]{AVM2Code.DAT_METHOD_INDEX, AVM2Code.DAT_ARG_COUNT}); - } + public CallStaticIns() { + super(0x44, "callstatic", new int[]{AVM2Code.DAT_METHOD_INDEX, AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - /*int methodIndex = (int) ((Long) arguments.get(0)).longValue(); //index of method_info - int argCount = (int) ((Long) arguments.get(1)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - Object receiver = lda.operandStack.pop();*/ - throw new RuntimeException("Call to unknown static method"); - //push(result) - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + /*int methodIndex = (int) ((Long) arguments.get(0)).longValue(); //index of method_info + int argCount = (int) ((Long) arguments.get(1)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + Object receiver = lda.operandStack.pop();*/ + throw new RuntimeException("Call to unknown static method"); + //push(result) + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int methodIndex = ins.operands[0]; - int argCount = ins.operands[1]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (GraphTargetItem) stack.pop()); - } - GraphTargetItem receiver = (GraphTargetItem) stack.pop(); - String methodName = method_info[methodIndex].getName(constants); - stack.push(new CallStaticTreeItem(ins, receiver, methodName, args)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int methodIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (GraphTargetItem) stack.pop()); + } + GraphTargetItem receiver = (GraphTargetItem) stack.pop(); + String methodName = method_info[methodIndex].getName(constants); + stack.push(new CallStaticTreeItem(ins, receiver, methodName, args)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1 - ins.operands[1]; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1 - ins.operands[1]; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperIns.java index b136adfe7..d5d461b28 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperIns.java @@ -33,49 +33,49 @@ import java.util.Stack; public class CallSuperIns extends InstructionDefinition { - public CallSuperIns() { - super(0x45, "callsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); - } + public CallSuperIns() { + super(0x45, "callsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - /*int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); - int argCount = (int) ((Long) arguments.get(1)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - //if multiname[multinameIndex] is runtime - //pop(name) pop(ns) - Object receiver = lda.operandStack.pop();*/ - throw new RuntimeException("Call to unknown super method"); - //push(result) - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + /*int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); + int argCount = (int) ((Long) arguments.get(1)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + //if multiname[multinameIndex] is runtime + //pop(name) pop(ns) + Object receiver = lda.operandStack.pop();*/ + throw new RuntimeException("Call to unknown super method"); + //push(result) + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - int argCount = ins.operands[1]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (GraphTargetItem) stack.pop()); - } - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem receiver = (GraphTargetItem) stack.pop(); + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (GraphTargetItem) stack.pop()); + } + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem receiver = (GraphTargetItem) stack.pop(); - stack.push(new CallSuperTreeItem(ins, false, receiver, multiname, args)); - } + stack.push(new CallSuperTreeItem(ins, false, receiver, multiname, args)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -ins.operands[1] - 1 + 1; - int multinameIndex = ins.operands[0]; - if (abc.constants.constant_multiname[multinameIndex].needsName()) { - ret--; - } - if (abc.constants.constant_multiname[multinameIndex].needsNs()) { - ret--; - } - return ret; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -ins.operands[1] - 1 + 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { + ret--; + } + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { + ret--; + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperVoidIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperVoidIns.java index 08493196a..44d415602 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperVoidIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperVoidIns.java @@ -33,50 +33,50 @@ import java.util.Stack; public class CallSuperVoidIns extends InstructionDefinition { - public CallSuperVoidIns() { - super(0x4e, "callsupervoid", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); - } + public CallSuperVoidIns() { + super(0x4e, "callsupervoid", new int[]{AVM2Code.DAT_MULTINAME_INDEX, AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - /*int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); - int argCount = (int) ((Long) arguments.get(1)).longValue(); - List passArguments = new ArrayList(); - for (int i = argCount - 1; i >= 0; i--) { - passArguments.set(i, lda.operandStack.pop()); - } - //if multiname[multinameIndex] is runtime - //pop(name) pop(ns) - Object receiver = lda.operandStack.pop();*/ - throw new RuntimeException("Call to unknown super method"); - //do not push anything - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + /*int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); + int argCount = (int) ((Long) arguments.get(1)).longValue(); + List passArguments = new ArrayList(); + for (int i = argCount - 1; i >= 0; i--) { + passArguments.set(i, lda.operandStack.pop()); + } + //if multiname[multinameIndex] is runtime + //pop(name) pop(ns) + Object receiver = lda.operandStack.pop();*/ + throw new RuntimeException("Call to unknown super method"); + //do not push anything + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - int argCount = ins.operands[1]; - List args = new ArrayList(); - for (int a = 0; a < argCount; a++) { - args.add(0, (GraphTargetItem) stack.pop()); - } - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem receiver = (GraphTargetItem) stack.pop(); + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList(); + for (int a = 0; a < argCount; a++) { + args.add(0, (GraphTargetItem) stack.pop()); + } + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem receiver = (GraphTargetItem) stack.pop(); - output.add(new CallSuperTreeItem(ins, true, receiver, multiname, args)); + output.add(new CallSuperTreeItem(ins, true, receiver, multiname, args)); - } + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -ins.operands[1] - 1; - int multinameIndex = ins.operands[0]; - if (abc.constants.constant_multiname[multinameIndex].needsName()) { - ret--; - } - if (abc.constants.constant_multiname[multinameIndex].needsNs()) { - ret--; - } - return ret; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -ins.operands[1] - 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { + ret--; + } + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { + ret--; + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfEqIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfEqIns.java index 48bad6810..e018cddeb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfEqIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfEqIns.java @@ -32,26 +32,26 @@ import java.util.Stack; public class IfEqIns extends InstructionDefinition implements IfTypeIns { - public IfEqIns() { - super(0x13, "ifeq", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfEqIns() { + super(0x13, "ifeq", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new EqTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new EqTreeItem(ins, v1, v2)); + } - @Override - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new NeqTreeItem(ins, v1, v2)); - } + @Override + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new NeqTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfFalseIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfFalseIns.java index fb7e2f219..f1b5aa837 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfFalseIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfFalseIns.java @@ -31,24 +31,24 @@ import java.util.Stack; public class IfFalseIns extends InstructionDefinition implements IfTypeIns { - public IfFalseIns() { - super(0x12, "iffalse", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfFalseIns() { + super(0x12, "iffalse", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new NotItem(ins, v1)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new NotItem(ins, v1)); + } - @Override - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - //String v1 = stack.pop().toString(); - //stack.push("(" + v1 + ")"); - } + @Override + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + //String v1 = stack.pop().toString(); + //stack.push("(" + v1 + ")"); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGeIns.java index c4c7712ba..fc03565a5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGeIns.java @@ -32,26 +32,26 @@ import java.util.Stack; public class IfGeIns extends InstructionDefinition implements IfTypeIns { - public IfGeIns() { - super(0x18, "ifge", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfGeIns() { + super(0x18, "ifge", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new GeTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new GeTreeItem(ins, v1, v2)); + } - @Override - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LtTreeItem(ins, v1, v2)); - } + @Override + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new LtTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGtIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGtIns.java index c79002be9..572713025 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGtIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGtIns.java @@ -32,26 +32,26 @@ import java.util.Stack; public class IfGtIns extends InstructionDefinition implements IfTypeIns { - public IfGtIns() { - super(0x17, "ifgt", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfGtIns() { + super(0x17, "ifgt", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new GtTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new GtTreeItem(ins, v1, v2)); + } - @Override - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LeTreeItem(ins, v1, v2)); - } + @Override + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new LeTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLeIns.java index 2a196ce86..8c09df927 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLeIns.java @@ -32,26 +32,26 @@ import java.util.Stack; public class IfLeIns extends InstructionDefinition implements IfTypeIns { - public IfLeIns() { - super(0x16, "ifle", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfLeIns() { + super(0x16, "ifle", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LeTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new LeTreeItem(ins, v1, v2)); + } - @Override - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new GtTreeItem(ins, v1, v2)); - } + @Override + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new GtTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLtIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLtIns.java index c23be8432..cc674e02c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLtIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLtIns.java @@ -32,26 +32,26 @@ import java.util.Stack; public class IfLtIns extends InstructionDefinition implements IfTypeIns { - public IfLtIns() { - super(0x15, "iflt", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfLtIns() { + super(0x15, "iflt", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LtTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new LtTreeItem(ins, v1, v2)); + } - @Override - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new GeTreeItem(ins, v1, v2)); - } + @Override + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new GeTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGeIns.java index ac42c7d6c..76b00f32c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGeIns.java @@ -32,26 +32,26 @@ import java.util.Stack; public class IfNGeIns extends InstructionDefinition implements IfTypeIns { - public IfNGeIns() { - super(0x0f, "ifnge", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfNGeIns() { + super(0x0f, "ifnge", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LtTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new LtTreeItem(ins, v1, v2)); + } - @Override - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new GeTreeItem(ins, v1, v2)); - } + @Override + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new GeTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGtIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGtIns.java index 67db57043..d9ca4edf0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGtIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGtIns.java @@ -32,26 +32,26 @@ import java.util.Stack; public class IfNGtIns extends InstructionDefinition implements IfTypeIns { - public IfNGtIns() { - super(0x0e, "ifngt", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfNGtIns() { + super(0x0e, "ifngt", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LeTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new LeTreeItem(ins, v1, v2)); + } - @Override - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new GtTreeItem(ins, v1, v2)); - } + @Override + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new GtTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLeIns.java index 898c8f384..1e0b35e22 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLeIns.java @@ -32,26 +32,26 @@ import java.util.Stack; public class IfNLeIns extends InstructionDefinition implements IfTypeIns { - public IfNLeIns() { - super(0x0d, "ifnle", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfNLeIns() { + super(0x0d, "ifnle", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new GtTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new GtTreeItem(ins, v1, v2)); + } - @Override - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LeTreeItem(ins, v1, v2)); - } + @Override + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new LeTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLtIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLtIns.java index e157fd1d3..85bdf14fb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLtIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLtIns.java @@ -32,26 +32,26 @@ import java.util.Stack; public class IfNLtIns extends InstructionDefinition implements IfTypeIns { - public IfNLtIns() { - super(0x0c, "ifnlt", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfNLtIns() { + super(0x0c, "ifnlt", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new GeTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new GeTreeItem(ins, v1, v2)); + } - @Override - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LtTreeItem(ins, v1, v2)); - } + @Override + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new LtTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNeIns.java index b1fcee1f7..37e1f5214 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNeIns.java @@ -32,26 +32,26 @@ import java.util.Stack; public class IfNeIns extends InstructionDefinition implements IfTypeIns { - public IfNeIns() { - super(0x14, "ifne", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfNeIns() { + super(0x14, "ifne", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new NeqTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new NeqTreeItem(ins, v1, v2)); + } - @Override - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new EqTreeItem(ins, v1, v2)); - } + @Override + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new EqTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictEqIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictEqIns.java index 45885bdbb..a15705012 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictEqIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictEqIns.java @@ -32,26 +32,26 @@ import java.util.Stack; public class IfStrictEqIns extends InstructionDefinition implements IfTypeIns { - public IfStrictEqIns() { - super(0x19, "ifstricteq", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfStrictEqIns() { + super(0x19, "ifstricteq", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new StrictEqTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new StrictEqTreeItem(ins, v1, v2)); + } - @Override - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new StrictNeqTreeItem(ins, v1, v2)); - } + @Override + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new StrictNeqTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictNeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictNeIns.java index 91460557a..f0541962b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictNeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictNeIns.java @@ -32,26 +32,26 @@ import java.util.Stack; public class IfStrictNeIns extends InstructionDefinition implements IfTypeIns { - public IfStrictNeIns() { - super(0x1A, "ifstrictne", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfStrictNeIns() { + super(0x1A, "ifstrictne", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new StrictNeqTreeItem(ins, v1, v2)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new StrictNeqTreeItem(ins, v1, v2)); + } - @Override - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new StrictEqTreeItem(ins, v1, v2)); - } + @Override + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = (GraphTargetItem) stack.pop(); + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new StrictEqTreeItem(ins, v1, v2)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfTrueIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfTrueIns.java index e9cdb5e2e..9c254850c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfTrueIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfTrueIns.java @@ -31,24 +31,24 @@ import java.util.Stack; public class IfTrueIns extends InstructionDefinition implements IfTypeIns { - public IfTrueIns() { - super(0x11, "iftrue", new int[]{AVM2Code.DAT_OFFSET}); - } + public IfTrueIns() { + super(0x11, "iftrue", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - //String v1 = stack.pop().toString(); - //stack.push("(" + v1 + ")"); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + //String v1 = stack.pop().toString(); + //stack.push("(" + v1 + ")"); + } - @Override - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new NotItem(ins, v1)); - } + @Override + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v1 = (GraphTargetItem) stack.pop(); + stack.push(new NotItem(ins, v1)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/JumpIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/JumpIns.java index 015223cd4..6a17f11d7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/JumpIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/JumpIns.java @@ -30,16 +30,16 @@ import java.util.Stack; public class JumpIns extends InstructionDefinition implements IfTypeIns { - public JumpIns() { - super(0x10, "jump", new int[]{AVM2Code.DAT_OFFSET}); - } + public JumpIns() { + super(0x10, "jump", new int[]{AVM2Code.DAT_OFFSET}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new BooleanTreeItem(ins, Boolean.TRUE));// + ins.operands[0]); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new BooleanTreeItem(ins, Boolean.TRUE));// + ins.operands[0]); + } - @Override - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - } + @Override + public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/LookupSwitchIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/LookupSwitchIns.java index b1d402dc7..e815f3d04 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/LookupSwitchIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/LookupSwitchIns.java @@ -29,19 +29,19 @@ import java.util.Stack; public class LookupSwitchIns extends InstructionDefinition { - public LookupSwitchIns() { - super(0x1b, "lookupswitch", new int[]{AVM2Code.DAT_CASE_BASEOFFSET, AVM2Code.OPT_CASE_OFFSETS}); - } + public LookupSwitchIns() { + super(0x1b, "lookupswitch", new int[]{AVM2Code.DAT_CASE_BASEOFFSET, AVM2Code.OPT_CASE_OFFSETS}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int defaultOffset = ins.operands[0]; - int caseCount = ins.operands[1]; - //stack.push("switch(...)"); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int defaultOffset = ins.operands[0]; + int caseCount = ins.operands[1]; + //stack.push("switch(...)"); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java index 89091ccfa..cf31379cb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java @@ -30,32 +30,32 @@ import java.util.Stack; public class DecLocalIIns extends InstructionDefinition { - public DecLocalIIns() { - super(0xc3, "declocal_i", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); - } + public DecLocalIIns() { + super(0xc3, "declocal_i", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int locRegIndex = (int) ((Long) arguments.get(0)).longValue(); - Object obj = lda.localRegisters.get(locRegIndex); - if (obj instanceof Long) { - Long obj2 = ((Long) obj).longValue() - 1; - lda.localRegisters.put(locRegIndex, obj2); - } else if (obj instanceof Double) { - Double obj2 = ((Double) obj).doubleValue() - 1; - lda.localRegisters.put(locRegIndex, obj2); - } - if (obj instanceof String) { - Double obj2 = Double.parseDouble((String) obj) - 1; - lda.localRegisters.put(locRegIndex, obj2); - } else { - throw new RuntimeException("Cannot decrement local register"); - } - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int locRegIndex = (int) ((Long) arguments.get(0)).longValue(); + Object obj = lda.localRegisters.get(locRegIndex); + if (obj instanceof Long) { + Long obj2 = ((Long) obj).longValue() - 1; + lda.localRegisters.put(locRegIndex, obj2); + } else if (obj instanceof Double) { + Double obj2 = ((Double) obj).doubleValue() - 1; + lda.localRegisters.put(locRegIndex, obj2); + } + if (obj instanceof String) { + Double obj2 = Double.parseDouble((String) obj) - 1; + lda.localRegisters.put(locRegIndex, obj2); + } else { + throw new RuntimeException("Cannot decrement local register"); + } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int regIndex = ins.operands[0]; - output.add(new DecLocalTreeItem(ins, regIndex)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int regIndex = ins.operands[0]; + output.add(new DecLocalTreeItem(ins, regIndex)); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java index e69fc2b55..69e24c80b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java @@ -30,32 +30,32 @@ import java.util.Stack; public class DecLocalIns extends InstructionDefinition { - public DecLocalIns() { - super(0x94, "declocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); - } + public DecLocalIns() { + super(0x94, "declocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int locRegIndex = (int) ((Long) arguments.get(0)).longValue(); - Object obj = lda.localRegisters.get(locRegIndex); - if (obj instanceof Long) { - Long obj2 = ((Long) obj).longValue() - 1; - lda.localRegisters.put(locRegIndex, obj2); - } else if (obj instanceof Double) { - Double obj2 = ((Double) obj).doubleValue() - 1; - lda.localRegisters.put(locRegIndex, obj2); - } - if (obj instanceof String) { - Double obj2 = Double.parseDouble((String) obj) - 1; - lda.localRegisters.put(locRegIndex, obj2); - } else { - throw new RuntimeException("Cannot decrement local register"); - } - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int locRegIndex = (int) ((Long) arguments.get(0)).longValue(); + Object obj = lda.localRegisters.get(locRegIndex); + if (obj instanceof Long) { + Long obj2 = ((Long) obj).longValue() - 1; + lda.localRegisters.put(locRegIndex, obj2); + } else if (obj instanceof Double) { + Double obj2 = ((Double) obj).doubleValue() - 1; + lda.localRegisters.put(locRegIndex, obj2); + } + if (obj instanceof String) { + Double obj2 = Double.parseDouble((String) obj) - 1; + lda.localRegisters.put(locRegIndex, obj2); + } else { + throw new RuntimeException("Cannot decrement local register"); + } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int regIndex = ins.operands[0]; - output.add(new DecLocalTreeItem(ins, regIndex)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int regIndex = ins.operands[0]; + output.add(new DecLocalTreeItem(ins, regIndex)); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java index 9479b6ccd..aafc9ffce 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java @@ -31,31 +31,31 @@ import java.util.Stack; public class GetLocal0Ins extends InstructionDefinition implements GetLocalTypeIns { - public GetLocal0Ins() { - super(0xd0, "getlocal_0", new int[]{}); - } + public GetLocal0Ins() { + super(0xd0, "getlocal_0", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(lda.localRegisters.get(0)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(lda.localRegisters.get(0)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - if (isStatic) { - stack.push(new ClassTreeItem(abc.instance_info[classIndex].getName(constants))); - } else { - stack.push(new ThisTreeItem(abc.instance_info[classIndex].getName(constants))); - } - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + if (isStatic) { + stack.push(new ClassTreeItem(abc.instance_info[classIndex].getName(constants))); + } else { + stack.push(new ThisTreeItem(abc.instance_info[classIndex].getName(constants))); + } + } - @Override - public int getRegisterId(AVM2Instruction par0) { - return 0; - } + @Override + public int getRegisterId(AVM2Instruction par0) { + return 0; + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal1Ins.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal1Ins.java index 0f2512cf7..399789617 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal1Ins.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal1Ins.java @@ -30,27 +30,27 @@ import java.util.Stack; public class GetLocal1Ins extends InstructionDefinition implements GetLocalTypeIns { - public GetLocal1Ins() { - super(0xd1, "getlocal_1", new int[]{}); - } + public GetLocal1Ins() { + super(0xd1, "getlocal_1", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(lda.localRegisters.get(1)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(lda.localRegisters.get(1)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new LocalRegTreeItem(ins, 1, localRegs.get(1))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new LocalRegTreeItem(ins, 1, localRegs.get(1))); + } - @Override - public int getRegisterId(AVM2Instruction par0) { - return 1; - } + @Override + public int getRegisterId(AVM2Instruction par0) { + return 1; + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal2Ins.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal2Ins.java index 165cd82cd..6550e0961 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal2Ins.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal2Ins.java @@ -30,27 +30,27 @@ import java.util.Stack; public class GetLocal2Ins extends InstructionDefinition implements GetLocalTypeIns { - public GetLocal2Ins() { - super(0xd2, "getlocal_2", new int[]{}); - } + public GetLocal2Ins() { + super(0xd2, "getlocal_2", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(lda.localRegisters.get(2)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(lda.localRegisters.get(2)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new LocalRegTreeItem(ins, 2, localRegs.get(2))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new LocalRegTreeItem(ins, 2, localRegs.get(2))); + } - @Override - public int getRegisterId(AVM2Instruction par0) { - return 2; - } + @Override + public int getRegisterId(AVM2Instruction par0) { + return 2; + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal3Ins.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal3Ins.java index 4aa3102c2..a6fcf4674 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal3Ins.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal3Ins.java @@ -30,27 +30,27 @@ import java.util.Stack; public class GetLocal3Ins extends InstructionDefinition implements GetLocalTypeIns { - public GetLocal3Ins() { - super(0xd3, "getlocal_3", new int[]{}); - } + public GetLocal3Ins() { + super(0xd3, "getlocal_3", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(lda.localRegisters.get(3)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(lda.localRegisters.get(3)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new LocalRegTreeItem(ins, 3, localRegs.get(3))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new LocalRegTreeItem(ins, 3, localRegs.get(3))); + } - @Override - public int getRegisterId(AVM2Instruction par0) { - return 3; - } + @Override + public int getRegisterId(AVM2Instruction par0) { + return 3; + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalIns.java index 2ed934b6b..f1578eb64 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalIns.java @@ -31,28 +31,28 @@ import java.util.Stack; public class GetLocalIns extends InstructionDefinition implements GetLocalTypeIns { - public GetLocalIns() { - super(0x62, "getlocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); - } + public GetLocalIns() { + super(0x62, "getlocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(lda.localRegisters.get((int) (long) (Long) arguments.get(0))); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(lda.localRegisters.get((int) (long) (Long) arguments.get(0))); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int regIndex = ins.operands[0]; - stack.push(new LocalRegTreeItem(ins, regIndex, localRegs.get(regIndex))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int regIndex = ins.operands[0]; + stack.push(new LocalRegTreeItem(ins, regIndex, localRegs.get(regIndex))); + } - @Override - public int getRegisterId(AVM2Instruction ins) { - return ins.operands[0]; - } + @Override + public int getRegisterId(AVM2Instruction ins) { + return ins.operands[0]; + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java index fc1bf28ec..d29ce21b4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java @@ -20,5 +20,5 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; public interface GetLocalTypeIns { - public abstract int getRegisterId(AVM2Instruction ins); + public abstract int getRegisterId(AVM2Instruction ins); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java index a71c3950c..70529a422 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java @@ -29,13 +29,13 @@ import java.util.Stack; public class IncLocalIIns extends InstructionDefinition { - public IncLocalIIns() { - super(0xc2, "inclocal_i", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); - } + public IncLocalIIns() { + super(0xc2, "inclocal_i", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int regIndex = ins.operands[0]; - output.add(new IncLocalTreeItem(ins, regIndex)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int regIndex = ins.operands[0]; + output.add(new IncLocalTreeItem(ins, regIndex)); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java index 74bf3b78d..4a784fb10 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java @@ -29,13 +29,13 @@ import java.util.Stack; public class IncLocalIns extends InstructionDefinition { - public IncLocalIns() { - super(0x92, "inclocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); - } + public IncLocalIns() { + super(0x92, "inclocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int regIndex = ins.operands[0]; - output.add(new IncLocalTreeItem(ins, regIndex)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int regIndex = ins.operands[0]; + output.add(new IncLocalTreeItem(ins, regIndex)); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/KillIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/KillIns.java index 18616d756..23735bc40 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/KillIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/KillIns.java @@ -28,12 +28,12 @@ import java.util.Stack; public class KillIns extends InstructionDefinition { - public KillIns() { - super(0x08, "kill", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); - } + public KillIns() { + super(0x08, "kill", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - //kill local register - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + //kill local register + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocal0Ins.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocal0Ins.java index 753f3e1c6..c79017b4e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocal0Ins.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocal0Ins.java @@ -20,12 +20,12 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; public class SetLocal0Ins extends SetLocalTypeIns { - public SetLocal0Ins() { - super(0xd4, "setlocal_0", new int[]{}); - } + public SetLocal0Ins() { + super(0xd4, "setlocal_0", new int[]{}); + } - @Override - public int getRegisterId(AVM2Instruction ins) { - return 0; - } + @Override + public int getRegisterId(AVM2Instruction ins) { + return 0; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocal1Ins.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocal1Ins.java index 218769e20..331071d4b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocal1Ins.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocal1Ins.java @@ -20,12 +20,12 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; public class SetLocal1Ins extends SetLocalTypeIns { - public SetLocal1Ins() { - super(0xd5, "setlocal_1", new int[]{}); - } + public SetLocal1Ins() { + super(0xd5, "setlocal_1", new int[]{}); + } - @Override - public int getRegisterId(AVM2Instruction ins) { - return 1; - } + @Override + public int getRegisterId(AVM2Instruction ins) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocal2Ins.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocal2Ins.java index 1019e353d..b49a2036c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocal2Ins.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocal2Ins.java @@ -20,12 +20,12 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; public class SetLocal2Ins extends SetLocalTypeIns { - public SetLocal2Ins() { - super(0xd6, "setlocal_2", new int[]{}); - } + public SetLocal2Ins() { + super(0xd6, "setlocal_2", new int[]{}); + } - @Override - public int getRegisterId(AVM2Instruction ins) { - return 2; - } + @Override + public int getRegisterId(AVM2Instruction ins) { + return 2; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocal3Ins.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocal3Ins.java index 02a268e3b..2234fdc98 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocal3Ins.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocal3Ins.java @@ -20,12 +20,12 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; public class SetLocal3Ins extends SetLocalTypeIns { - public SetLocal3Ins() { - super(0xd7, "setlocal_3", new int[]{}); - } + public SetLocal3Ins() { + super(0xd7, "setlocal_3", new int[]{}); + } - @Override - public int getRegisterId(AVM2Instruction ins) { - return 3; - } + @Override + public int getRegisterId(AVM2Instruction ins) { + return 3; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalIns.java index 812750356..eb9254bd5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalIns.java @@ -21,12 +21,12 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; public class SetLocalIns extends SetLocalTypeIns { - public SetLocalIns() { - super(0x63, "setlocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); - } + public SetLocalIns() { + super(0x63, "setlocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); + } - @Override - public int getRegisterId(AVM2Instruction ins) { - return ins.operands[0]; - } + @Override + public int getRegisterId(AVM2Instruction ins) { + return ins.operands[0]; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java index e65188d70..05b51f1ad 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java @@ -40,81 +40,81 @@ import java.util.Stack; public abstract class SetLocalTypeIns extends InstructionDefinition implements SetTypeIns { - public SetLocalTypeIns(int instructionCode, String instructionName, int[] operands) { - super(instructionCode, instructionName, operands); - } + public SetLocalTypeIns(int instructionCode, String instructionName, int[] operands) { + super(instructionCode, instructionName, operands); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int regId = getRegisterId(ins); - GraphTargetItem value = (GraphTargetItem) stack.pop(); - localRegs.put(regId, value); - if (value instanceof NewActivationTreeItem) { - return; - } - if (value instanceof FindPropertyTreeItem) { - return; - } - if (value.getNotCoerced() instanceof IncrementTreeItem) { - GraphTargetItem inside = ((IncrementTreeItem) value.getNotCoerced()).object.getNotCoerced(); - if (inside instanceof LocalRegTreeItem) { - if (((LocalRegTreeItem) inside).regIndex == regId) { - if (stack.size() > 0) { - GraphTargetItem top = stack.peek().getNotCoerced(); - if (top == inside) { - stack.pop(); - stack.push(new PostIncrementTreeItem(ins, inside)); - } else if ((top instanceof IncrementTreeItem) && (((IncrementTreeItem) top).object == inside)) { - stack.pop(); - stack.push(new PreIncrementTreeItem(ins, inside)); - } else { - output.add(new PostIncrementTreeItem(ins, inside)); - } - } else { - output.add(new PostIncrementTreeItem(ins, inside)); - } - return; + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int regId = getRegisterId(ins); + GraphTargetItem value = (GraphTargetItem) stack.pop(); + localRegs.put(regId, value); + if (value instanceof NewActivationTreeItem) { + return; + } + if (value instanceof FindPropertyTreeItem) { + return; + } + if (value.getNotCoerced() instanceof IncrementTreeItem) { + GraphTargetItem inside = ((IncrementTreeItem) value.getNotCoerced()).object.getNotCoerced(); + if (inside instanceof LocalRegTreeItem) { + if (((LocalRegTreeItem) inside).regIndex == regId) { + if (stack.size() > 0) { + GraphTargetItem top = stack.peek().getNotCoerced(); + if (top == inside) { + stack.pop(); + stack.push(new PostIncrementTreeItem(ins, inside)); + } else if ((top instanceof IncrementTreeItem) && (((IncrementTreeItem) top).object == inside)) { + stack.pop(); + stack.push(new PreIncrementTreeItem(ins, inside)); + } else { + output.add(new PostIncrementTreeItem(ins, inside)); + } + } else { + output.add(new PostIncrementTreeItem(ins, inside)); + } + return; + } } - } - } + } - if (value.getNotCoerced() instanceof DecrementTreeItem) { - GraphTargetItem inside = ((DecrementTreeItem) value.getNotCoerced()).object.getNotCoerced(); - if (inside instanceof LocalRegTreeItem) { - if (((LocalRegTreeItem) inside).regIndex == regId) { - if (stack.size() > 0) { - GraphTargetItem top = stack.peek().getNotCoerced(); - if (top == inside) { - stack.pop(); - stack.push(new PostDecrementTreeItem(ins, inside)); - } else if ((top instanceof DecrementTreeItem) && (((DecrementTreeItem) top).object == inside)) { - stack.pop(); - stack.push(new PreDecrementTreeItem(ins, inside)); - } else { - output.add(new PostDecrementTreeItem(ins, inside)); - } - } else { - output.add(new PostDecrementTreeItem(ins, inside)); - } - return; + if (value.getNotCoerced() instanceof DecrementTreeItem) { + GraphTargetItem inside = ((DecrementTreeItem) value.getNotCoerced()).object.getNotCoerced(); + if (inside instanceof LocalRegTreeItem) { + if (((LocalRegTreeItem) inside).regIndex == regId) { + if (stack.size() > 0) { + GraphTargetItem top = stack.peek().getNotCoerced(); + if (top == inside) { + stack.pop(); + stack.push(new PostDecrementTreeItem(ins, inside)); + } else if ((top instanceof DecrementTreeItem) && (((DecrementTreeItem) top).object == inside)) { + stack.pop(); + stack.push(new PreDecrementTreeItem(ins, inside)); + } else { + output.add(new PostDecrementTreeItem(ins, inside)); + } + } else { + output.add(new PostDecrementTreeItem(ins, inside)); + } + return; + } } - } - } + } - //if(val.startsWith("catchscope ")) return; - //if(val.startsWith("newactivation()")) return; - output.add(new SetLocalTreeItem(ins, regId, value)); - } + //if(val.startsWith("catchscope ")) return; + //if(val.startsWith("newactivation()")) return; + output.add(new SetLocalTreeItem(ins, regId, value)); + } - @Override - public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { - return TreeItem.localRegName(localRegNames, getRegisterId(ins)); - } + @Override + public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { + return TreeItem.localRegName(localRegNames, getRegisterId(ins)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } - public abstract int getRegisterId(AVM2Instruction ins); + public abstract int getRegisterId(AVM2Instruction ins); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java index e2e902cca..48048b4ce 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java @@ -33,40 +33,40 @@ import java.util.Stack; public class DeletePropertyIns extends InstructionDefinition { - public DeletePropertyIns() { - super(0x6a, "deleteproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public DeletePropertyIns() { + super(0x6a, "deleteproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int multiIndex = (int) ((Long) arguments.get(0)).longValue(); - //if multiname[multinameIndex] is runtime - //pop(name) pop(ns) - Object obj = lda.operandStack.pop(); - //push true if removed - throw new RuntimeException("Cannot remove property"); + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int multiIndex = (int) ((Long) arguments.get(0)).longValue(); + //if multiname[multinameIndex] is runtime + //pop(name) pop(ns) + Object obj = lda.operandStack.pop(); + //push true if removed + throw new RuntimeException("Cannot remove property"); - } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - stack.add(new BooleanTreeItem(ins, Boolean.TRUE));//property successfully deleted - output.add(new DeletePropertyTreeItem(ins, obj, multiname)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem obj = (GraphTargetItem) stack.pop(); + stack.add(new BooleanTreeItem(ins, Boolean.TRUE));//property successfully deleted + output.add(new DeletePropertyTreeItem(ins, obj, multiname)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -1 + 1; - int multinameIndex = ins.operands[0]; - if (abc.constants.constant_multiname[multinameIndex].needsName()) { - ret--; - } - if (abc.constants.constant_multiname[multinameIndex].needsNs()) { - ret--; - } - return ret; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -1 + 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { + ret--; + } + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { + ret--; + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyIns.java index 0ad91cc63..631ad2b37 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyIns.java @@ -32,36 +32,36 @@ import java.util.Stack; public class FindPropertyIns extends InstructionDefinition { - public FindPropertyIns() { - super(0x5e, "findproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public FindPropertyIns() { + super(0x5e, "findproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int multiIndex = (int) ((Long) arguments.get(0)).longValue(); - //if is runtime - //pop(name), pop(ns) - throw new RuntimeException("Cannot find property"); + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int multiIndex = (int) ((Long) arguments.get(0)).longValue(); + //if is runtime + //pop(name), pop(ns) + throw new RuntimeException("Cannot find property"); - } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - stack.push(new FindPropertyTreeItem(ins, multiname)); //resolve right object - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + stack.push(new FindPropertyTreeItem(ins, multiname)); //resolve right object + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = 1; - int multinameIndex = ins.operands[0]; - if (abc.constants.constant_multiname[multinameIndex].needsName()) { - ret--; - } - if (abc.constants.constant_multiname[multinameIndex].needsNs()) { - ret--; - } - return ret; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { + ret--; + } + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { + ret--; + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyStrictIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyStrictIns.java index 520361582..55aab7338 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyStrictIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyStrictIns.java @@ -32,35 +32,35 @@ import java.util.Stack; public class FindPropertyStrictIns extends InstructionDefinition { - public FindPropertyStrictIns() { - super(0x5d, "findpropstrict", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public FindPropertyStrictIns() { + super(0x5d, "findpropstrict", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int multiIndex = (int) ((Long) arguments.get(0)).longValue(); - //if is runtime - //pop(name), pop(ns) - throw new RuntimeException("Cannot find property"); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int multiIndex = (int) ((Long) arguments.get(0)).longValue(); + //if is runtime + //pop(name), pop(ns) + throw new RuntimeException("Cannot find property"); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - stack.push(new FindPropertyTreeItem(ins, multiname)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + stack.push(new FindPropertyTreeItem(ins, multiname)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = 1; - int multinameIndex = ins.operands[0]; - if (abc.constants.constant_multiname[multinameIndex].needsName()) { - ret--; - } - if (abc.constants.constant_multiname[multinameIndex].needsNs()) { - ret--; - } - return ret; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { + ret--; + } + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { + ret--; + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java index d92972fd9..484eac447 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java @@ -32,37 +32,37 @@ import java.util.Stack; public class GetDescendantsIns extends InstructionDefinition { - public GetDescendantsIns() { - super(0x59, "getdescentants", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public GetDescendantsIns() { + super(0x59, "getdescentants", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int multiIndex = (int) ((Long) arguments.get(0)).longValue(); - //if is runtime - //pop(name), pop(ns) - Object obj = lda.operandStack.pop(); - throw new RuntimeException("getdescentants not working"); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int multiIndex = (int) ((Long) arguments.get(0)).longValue(); + //if is runtime + //pop(name), pop(ns) + Object obj = lda.operandStack.pop(); + throw new RuntimeException("getdescentants not working"); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - stack.push(new GetDescendantsTreeItem(ins, obj, multiname)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem obj = (GraphTargetItem) stack.pop(); + stack.push(new GetDescendantsTreeItem(ins, obj, multiname)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -1 + 1; - int multinameIndex = ins.operands[0]; - if (abc.constants.constant_multiname[multinameIndex].needsName()) { - ret--; - } - if (abc.constants.constant_multiname[multinameIndex].needsNs()) { - ret--; - } - return ret; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -1 + 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { + ret--; + } + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { + ret--; + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java index 534103e3a..1977d2427 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java @@ -30,26 +30,26 @@ import java.util.Stack; public class GetGlobalScopeIns extends InstructionDefinition { - public GetGlobalScopeIns() { - super(0x64, "getglobalscope", new int[]{}); - } + public GetGlobalScopeIns() { + super(0x64, "getglobalscope", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - throw new RuntimeException("getglobalscope not working"); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + throw new RuntimeException("getglobalscope not working"); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - if (scopeStack.isEmpty()) { - stack.push(new ClassTreeItem(abc.instance_info[classIndex].getName(constants))); - return; - } - stack.push(scopeStack.get(0)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + if (scopeStack.isEmpty()) { + stack.push(new ClassTreeItem(abc.instance_info[classIndex].getName(constants))); + return; + } + stack.push(scopeStack.get(0)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java index b736918ca..e00f17922 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java @@ -33,33 +33,33 @@ import java.util.Stack; public class GetGlobalSlotIns extends InstructionDefinition { - public GetGlobalSlotIns() { - super(0x6e, "getglobalslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); - } + public GetGlobalSlotIns() { + super(0x6e, "getglobalslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int slotIndex = ins.operands[0]; - GraphTargetItem obj = (GraphTargetItem) scopeStack.get(0); //scope - Multiname slotname = null; - if (obj instanceof ExceptionTreeItem) { - slotname = constants.constant_multiname[((ExceptionTreeItem) obj).exception.name_index]; - } else { + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int slotIndex = ins.operands[0]; + GraphTargetItem obj = (GraphTargetItem) scopeStack.get(0); //scope + Multiname slotname = null; + if (obj instanceof ExceptionTreeItem) { + slotname = constants.constant_multiname[((ExceptionTreeItem) obj).exception.name_index]; + } else { + + for (int t = 0; t < body.traits.traits.length; t++) { + if (body.traits.traits[t] instanceof TraitSlotConst) { + if (((TraitSlotConst) body.traits.traits[t]).slot_id == slotIndex) { + slotname = body.traits.traits[t].getName(abc); + } + } - for (int t = 0; t < body.traits.traits.length; t++) { - if (body.traits.traits[t] instanceof TraitSlotConst) { - if (((TraitSlotConst) body.traits.traits[t]).slot_id == slotIndex) { - slotname = body.traits.traits[t].getName(abc); - } } + } + stack.push(new GetSlotTreeItem(ins, obj, slotname)); + } - } - } - stack.push(new GetSlotTreeItem(ins, obj, slotname)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java index 7373df112..26b56b054 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java @@ -31,19 +31,19 @@ import java.util.Stack; public class GetLexIns extends InstructionDefinition { - public GetLexIns() { - super(0x60, "getlex", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public GetLexIns() { + super(0x60, "getlex", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - Multiname multiname = constants.constant_multiname[multinameIndex]; - stack.push(new GetLexTreeItem(ins, multiname)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + Multiname multiname = constants.constant_multiname[multinameIndex]; + stack.push(new GetLexTreeItem(ins, multiname)); + } - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 1; //multiname may not be runtime - } + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 1; //multiname may not be runtime + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java index b60144368..e9d489006 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java @@ -31,28 +31,28 @@ import java.util.Stack; public class GetPropertyIns extends InstructionDefinition { - public GetPropertyIns() { - super(0x66, "getproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public GetPropertyIns() { + super(0x66, "getproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - stack.push(new GetPropertyTreeItem(ins, obj, multiname)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem obj = (GraphTargetItem) stack.pop(); + stack.push(new GetPropertyTreeItem(ins, obj, multiname)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -1 + 1; - int multinameIndex = ins.operands[0]; - if (abc.constants.constant_multiname[multinameIndex].needsName()) { - ret--; - } - if (abc.constants.constant_multiname[multinameIndex].needsNs()) { - ret--; - } - return ret; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -1 + 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { + ret--; + } + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { + ret--; + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetScopeObjectIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetScopeObjectIns.java index 06b200e7d..fe3ff345c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetScopeObjectIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetScopeObjectIns.java @@ -29,18 +29,18 @@ import java.util.Stack; public class GetScopeObjectIns extends InstructionDefinition { - public GetScopeObjectIns() { - super(0x65, "getscopeobject", new int[]{AVM2Code.DAT_SLOT_SCOPE_INDEX}); - } + public GetScopeObjectIns() { + super(0x65, "getscopeobject", new int[]{AVM2Code.DAT_SLOT_SCOPE_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int index = ins.operands[0]; - stack.push(scopeStack.get(index)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int index = ins.operands[0]; + stack.push(scopeStack.get(index)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java index d0178c384..5c624e256 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java @@ -35,37 +35,37 @@ import java.util.Stack; public class GetSlotIns extends InstructionDefinition { - public GetSlotIns() { - super(0x6c, "getslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); - } + public GetSlotIns() { + super(0x6c, "getslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); + } + + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int slotIndex = ins.operands[0]; + GraphTargetItem obj = (GraphTargetItem) stack.pop(); //scope + obj = obj.getThroughRegister(); + Multiname slotname = null; + if (obj instanceof ExceptionTreeItem) { + slotname = constants.constant_multiname[((ExceptionTreeItem) obj).exception.name_index]; + } else if (obj instanceof ClassTreeItem) { + slotname = ((ClassTreeItem) obj).className; + } else if (obj instanceof ThisTreeItem) { + slotname = ((ThisTreeItem) obj).className; + } else { + for (int t = 0; t < body.traits.traits.length; t++) { + if (body.traits.traits[t] instanceof TraitSlotConst) { + if (((TraitSlotConst) body.traits.traits[t]).slot_id == slotIndex) { + slotname = body.traits.traits[t].getName(abc); + } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int slotIndex = ins.operands[0]; - GraphTargetItem obj = (GraphTargetItem) stack.pop(); //scope - obj = obj.getThroughRegister(); - Multiname slotname = null; - if (obj instanceof ExceptionTreeItem) { - slotname = constants.constant_multiname[((ExceptionTreeItem) obj).exception.name_index]; - } else if (obj instanceof ClassTreeItem) { - slotname = ((ClassTreeItem) obj).className; - } else if (obj instanceof ThisTreeItem) { - slotname = ((ThisTreeItem) obj).className; - } else { - for (int t = 0; t < body.traits.traits.length; t++) { - if (body.traits.traits[t] instanceof TraitSlotConst) { - if (((TraitSlotConst) body.traits.traits[t]).slot_id == slotIndex) { - slotname = body.traits.traits[t].getName(abc); - } } + } + stack.push(new GetSlotTreeItem(ins, obj, slotname)); + } - } - } - stack.push(new GetSlotTreeItem(ins, obj, slotname)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSuperIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSuperIns.java index 6b441a7bf..65b51019c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSuperIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSuperIns.java @@ -31,28 +31,28 @@ import java.util.Stack; public class GetSuperIns extends InstructionDefinition { - public GetSuperIns() { - super(0x04, "getsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public GetSuperIns() { + super(0x04, "getsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - stack.push(new GetSuperTreeItem(ins, obj, multiname)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem obj = (GraphTargetItem) stack.pop(); + stack.push(new GetSuperTreeItem(ins, obj, multiname)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -1 + 1; - int multinameIndex = ins.operands[0]; - if (abc.constants.constant_multiname[multinameIndex].needsName()) { - ret--; - } - if (abc.constants.constant_multiname[multinameIndex].needsNs()) { - ret--; - } - return ret; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -1 + 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { + ret--; + } + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { + ret--; + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNext2Ins.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNext2Ins.java index 252f2479d..c9673b763 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNext2Ins.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNext2Ins.java @@ -30,15 +30,15 @@ import java.util.Stack; public class HasNext2Ins extends InstructionDefinition { - public HasNext2Ins() { - super(0x32, "hasnext2", new int[]{AVM2Code.OPT_U8, AVM2Code.OPT_U8}); - } + public HasNext2Ins() { + super(0x32, "hasnext2", new int[]{AVM2Code.OPT_U8, AVM2Code.OPT_U8}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int objectReg = ins.operands[0]; - int indexReg = ins.operands[1]; - //stack.push("_loc_" + objectReg + ".hasNext(cnt=_loc_" + indexReg + ")"); - stack.push(new HasNextTreeItem(ins, new LocalRegTreeItem(ins, indexReg, localRegs.get(indexReg)), localRegs.get(objectReg))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int objectReg = ins.operands[0]; + int indexReg = ins.operands[1]; + //stack.push("_loc_" + objectReg + ".hasNext(cnt=_loc_" + indexReg + ")"); + stack.push(new HasNextTreeItem(ins, new LocalRegTreeItem(ins, indexReg, localRegs.get(indexReg)), localRegs.get(objectReg))); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNextIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNextIns.java index a7970f884..3514defee 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNextIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNextIns.java @@ -29,20 +29,20 @@ import java.util.Stack; public class HasNextIns extends InstructionDefinition { - public HasNextIns() { - super(0x1f, "hasnext", new int[]{}); - } + public HasNextIns() { + super(0x1f, "hasnext", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem curIndex = (GraphTargetItem) stack.pop(); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - stack.push(new HasNextTreeItem(ins, curIndex, obj)); + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem curIndex = (GraphTargetItem) stack.pop(); + GraphTargetItem obj = (GraphTargetItem) stack.pop(); + stack.push(new HasNextTreeItem(ins, curIndex, obj)); - } + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InIns.java index 8285d743a..264a2b8ab 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InIns.java @@ -29,19 +29,19 @@ import java.util.Stack; public class InIns extends InstructionDefinition { - public InIns() { - super(0xb4, "in", new int[]{}); - } + public InIns() { + super(0xb4, "in", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - GraphTargetItem name = (GraphTargetItem) stack.pop(); - stack.push(new InTreeItem(ins, name, obj)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem obj = (GraphTargetItem) stack.pop(); + GraphTargetItem name = (GraphTargetItem) stack.pop(); + stack.push(new InTreeItem(ins, name, obj)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java index f4e0184b5..84c4e0133 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java @@ -31,30 +31,30 @@ import java.util.Stack; public class InitPropertyIns extends InstructionDefinition { - public InitPropertyIns() { - super(0x68, "initproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public InitPropertyIns() { + super(0x68, "initproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; - GraphTargetItem val = (GraphTargetItem) stack.pop(); - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - output.add(new InitPropertyTreeItem(ins, obj, multiname, val)); - } + GraphTargetItem val = (GraphTargetItem) stack.pop(); + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem obj = (GraphTargetItem) stack.pop(); + output.add(new InitPropertyTreeItem(ins, obj, multiname, val)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -2; - int multinameIndex = ins.operands[0]; - if (abc.constants.constant_multiname[multinameIndex].needsName()) { - ret--; - } - if (abc.constants.constant_multiname[multinameIndex].needsNs()) { - ret--; - } - return ret; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -2; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { + ret--; + } + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { + ret--; + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/LabelIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/LabelIns.java index c599f1d5c..7a712dcfb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/LabelIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/LabelIns.java @@ -21,7 +21,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class LabelIns extends InstructionDefinition { //this can be target of branch - public LabelIns() { - super(0x09, "label", new int[]{}); - } + public LabelIns() { + super(0x09, "label", new int[]{}); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextNameIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextNameIns.java index 06d8eef2a..21335ac56 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextNameIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextNameIns.java @@ -29,19 +29,19 @@ import java.util.Stack; public class NextNameIns extends InstructionDefinition { - public NextNameIns() { - super(0x1e, "nextname", new int[]{}); - } + public NextNameIns() { + super(0x1e, "nextname", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem index = stack.pop(); - GraphTargetItem obj = stack.pop(); - stack.push(new NextNameTreeItem(ins, index, obj)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem index = stack.pop(); + GraphTargetItem obj = stack.pop(); + stack.push(new NextNameTreeItem(ins, index, obj)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextValueIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextValueIns.java index c6b49cd10..b6e3ca1c4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextValueIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextValueIns.java @@ -29,19 +29,19 @@ import java.util.Stack; public class NextValueIns extends InstructionDefinition { - public NextValueIns() { - super(0x23, "nextvalue", new int[]{}); - } + public NextValueIns() { + super(0x23, "nextvalue", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem index = stack.pop(); - GraphTargetItem obj = stack.pop(); - stack.push(new NextValueTreeItem(ins, index, obj)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem index = stack.pop(); + GraphTargetItem obj = stack.pop(); + stack.push(new NextValueTreeItem(ins, index, obj)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NopIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NopIns.java index 9f5a94dd9..62a29768e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NopIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NopIns.java @@ -20,7 +20,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class NopIns extends InstructionDefinition { - public NopIns() { - super(0x02, "nop", new int[]{}); - } + public NopIns() { + super(0x02, "nop", new int[]{}); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnValueIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnValueIns.java index e65ba46fa..ee67d6647 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnValueIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnValueIns.java @@ -29,17 +29,17 @@ import java.util.Stack; public class ReturnValueIns extends InstructionDefinition { - public ReturnValueIns() { - super(0x48, "returnvalue", new int[]{}); - } + public ReturnValueIns() { + super(0x48, "returnvalue", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - output.add(new ReturnValueTreeItem(ins, (GraphTargetItem) stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + output.add(new ReturnValueTreeItem(ins, (GraphTargetItem) stack.pop())); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnVoidIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnVoidIns.java index 4e2682b2a..39705bb3a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnVoidIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnVoidIns.java @@ -28,12 +28,12 @@ import java.util.Stack; public class ReturnVoidIns extends InstructionDefinition { - public ReturnVoidIns() { - super(0x47, "returnvoid", new int[]{}); - } + public ReturnVoidIns() { + super(0x47, "returnvoid", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - output.add(new ReturnVoidTreeItem(ins)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + output.add(new ReturnVoidTreeItem(ins)); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetGlobalSlotIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetGlobalSlotIns.java index 592aa192d..f5be6726e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetGlobalSlotIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetGlobalSlotIns.java @@ -32,22 +32,22 @@ import java.util.Stack; public class SetGlobalSlotIns extends InstructionDefinition implements SetTypeIns { - public SetGlobalSlotIns() { - super(0x6f, "setglobalslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); - } + public SetGlobalSlotIns() { + super(0x6f, "setglobalslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - output.add(new SetGlobalSlotTreeItem(ins, ins.operands[0], (GraphTargetItem) stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + output.add(new SetGlobalSlotTreeItem(ins, ins.operands[0], (GraphTargetItem) stack.pop())); + } - @Override - public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { - return "globalslot" + ins.operands[0]; - } + @Override + public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { + return "globalslot" + ins.operands[0]; + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java index 036b72ee2..77cf6d8f6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java @@ -41,99 +41,99 @@ import java.util.Stack; public class SetPropertyIns extends InstructionDefinition implements SetTypeIns { - public SetPropertyIns() { - super(0x61, "setproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public SetPropertyIns() { + super(0x61, "setproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - GraphTargetItem value = (GraphTargetItem) stack.pop(); - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - if (value.getThroughRegister() instanceof IncrementTreeItem) { - GraphTargetItem inside = ((IncrementTreeItem) value.getThroughRegister()).object.getThroughRegister().getNotCoerced(); - if (inside instanceof GetPropertyTreeItem) { - GetPropertyTreeItem insideProp = ((GetPropertyTreeItem) inside); - if (insideProp.propertyName.compareSame(multiname)) { - GraphTargetItem insideObj = obj; - if (insideObj instanceof LocalRegTreeItem) { - insideObj = ((LocalRegTreeItem) insideObj).computedValue; - } - if (insideProp.object == insideObj) { - if (stack.size() > 0) { - GraphTargetItem top = stack.peek().getNotCoerced(); - if (top == insideProp) { - stack.pop(); - stack.push(new PostIncrementTreeItem(ins, insideProp)); - } else if ((top instanceof IncrementTreeItem) && (((IncrementTreeItem) top).object == inside)) { - stack.pop(); - stack.push(new PreIncrementTreeItem(ins, insideProp)); - } else { - output.add(new PostIncrementTreeItem(ins, insideProp)); - } - } else { - output.add(new PostIncrementTreeItem(ins, insideProp)); - } - return; - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + GraphTargetItem value = (GraphTargetItem) stack.pop(); + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem obj = (GraphTargetItem) stack.pop(); + if (value.getThroughRegister() instanceof IncrementTreeItem) { + GraphTargetItem inside = ((IncrementTreeItem) value.getThroughRegister()).object.getThroughRegister().getNotCoerced(); + if (inside instanceof GetPropertyTreeItem) { + GetPropertyTreeItem insideProp = ((GetPropertyTreeItem) inside); + if (insideProp.propertyName.compareSame(multiname)) { + GraphTargetItem insideObj = obj; + if (insideObj instanceof LocalRegTreeItem) { + insideObj = ((LocalRegTreeItem) insideObj).computedValue; + } + if (insideProp.object == insideObj) { + if (stack.size() > 0) { + GraphTargetItem top = stack.peek().getNotCoerced(); + if (top == insideProp) { + stack.pop(); + stack.push(new PostIncrementTreeItem(ins, insideProp)); + } else if ((top instanceof IncrementTreeItem) && (((IncrementTreeItem) top).object == inside)) { + stack.pop(); + stack.push(new PreIncrementTreeItem(ins, insideProp)); + } else { + output.add(new PostIncrementTreeItem(ins, insideProp)); + } + } else { + output.add(new PostIncrementTreeItem(ins, insideProp)); + } + return; + } + } } - } - } + } - if (value.getThroughRegister() instanceof DecrementTreeItem) { - GraphTargetItem inside = ((DecrementTreeItem) value.getThroughRegister()).object.getThroughRegister().getNotCoerced(); - if (inside instanceof GetPropertyTreeItem) { - GetPropertyTreeItem insideProp = ((GetPropertyTreeItem) inside); - if (insideProp.propertyName.compareSame(multiname)) { - GraphTargetItem insideObj = obj; - if (insideObj instanceof LocalRegTreeItem) { - insideObj = ((LocalRegTreeItem) insideObj).computedValue; - } - if (insideProp.object == insideObj) { - if (stack.size() > 0) { - GraphTargetItem top = stack.peek().getNotCoerced(); - if (top == insideProp) { - stack.pop(); - stack.push(new PostDecrementTreeItem(ins, insideProp)); - } else if ((top instanceof DecrementTreeItem) && (((DecrementTreeItem) top).object == inside)) { - stack.pop(); - stack.push(new PreDecrementTreeItem(ins, insideProp)); - } else { - output.add(new PostDecrementTreeItem(ins, insideProp)); - } - } else { - output.add(new PostDecrementTreeItem(ins, insideProp)); - } - return; - } + if (value.getThroughRegister() instanceof DecrementTreeItem) { + GraphTargetItem inside = ((DecrementTreeItem) value.getThroughRegister()).object.getThroughRegister().getNotCoerced(); + if (inside instanceof GetPropertyTreeItem) { + GetPropertyTreeItem insideProp = ((GetPropertyTreeItem) inside); + if (insideProp.propertyName.compareSame(multiname)) { + GraphTargetItem insideObj = obj; + if (insideObj instanceof LocalRegTreeItem) { + insideObj = ((LocalRegTreeItem) insideObj).computedValue; + } + if (insideProp.object == insideObj) { + if (stack.size() > 0) { + GraphTargetItem top = stack.peek().getNotCoerced(); + if (top == insideProp) { + stack.pop(); + stack.push(new PostDecrementTreeItem(ins, insideProp)); + } else if ((top instanceof DecrementTreeItem) && (((DecrementTreeItem) top).object == inside)) { + stack.pop(); + stack.push(new PreDecrementTreeItem(ins, insideProp)); + } else { + output.add(new PostDecrementTreeItem(ins, insideProp)); + } + } else { + output.add(new PostDecrementTreeItem(ins, insideProp)); + } + return; + } + } } - } - } - output.add(new SetPropertyTreeItem(ins, obj, multiname, value)); - } + } + output.add(new SetPropertyTreeItem(ins, obj, multiname, value)); + } - @Override - public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - String multiname = resolveMultinameNoPop(0, stack, abc.constants, multinameIndex, ins, fullyQualifiedNames); - GraphTargetItem obj = stack.get(1 + resolvedCount(abc.constants, multinameIndex)); //pod vrcholem - if ((!obj.toString().equals(""))) { - multiname = "." + multiname; - } - return obj + multiname; - } + @Override + public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + String multiname = resolveMultinameNoPop(0, stack, abc.constants, multinameIndex, ins, fullyQualifiedNames); + GraphTargetItem obj = stack.get(1 + resolvedCount(abc.constants, multinameIndex)); //pod vrcholem + if ((!obj.toString().equals(""))) { + multiname = "." + multiname; + } + return obj + multiname; + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -2; - int multinameIndex = ins.operands[0]; - if (abc.constants.constant_multiname[multinameIndex].needsName()) { - ret--; - } - if (abc.constants.constant_multiname[multinameIndex].needsNs()) { - ret--; - } - return ret; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -2; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { + ret--; + } + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { + ret--; + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java index 43d155662..232221757 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java @@ -45,115 +45,115 @@ import java.util.Stack; public class SetSlotIns extends InstructionDefinition implements SetTypeIns { - public SetSlotIns() { - super(0x6d, "setslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); - } + public SetSlotIns() { + super(0x6d, "setslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int slotIndex = ins.operands[0]; - GraphTargetItem value = (GraphTargetItem) stack.pop(); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); //scopeId - obj = obj.getThroughRegister(); - Multiname slotname = null; - if (obj instanceof NewActivationTreeItem) { - ((NewActivationTreeItem) obj).slots.put(slotIndex, value); - } - if (obj instanceof ExceptionTreeItem) { - slotname = constants.constant_multiname[((ExceptionTreeItem) obj).exception.name_index]; - } else if (obj instanceof ClassTreeItem) { - slotname = ((ClassTreeItem) obj).className; - } else if (obj instanceof ThisTreeItem) { - slotname = ((ThisTreeItem) obj).className; - } else { - //if(value.startsWith("catched ")) return; - for (int t = 0; t < body.traits.traits.length; t++) { + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int slotIndex = ins.operands[0]; + GraphTargetItem value = (GraphTargetItem) stack.pop(); + GraphTargetItem obj = (GraphTargetItem) stack.pop(); //scopeId + obj = obj.getThroughRegister(); + Multiname slotname = null; + if (obj instanceof NewActivationTreeItem) { + ((NewActivationTreeItem) obj).slots.put(slotIndex, value); + } + if (obj instanceof ExceptionTreeItem) { + slotname = constants.constant_multiname[((ExceptionTreeItem) obj).exception.name_index]; + } else if (obj instanceof ClassTreeItem) { + slotname = ((ClassTreeItem) obj).className; + } else if (obj instanceof ThisTreeItem) { + slotname = ((ThisTreeItem) obj).className; + } else { + //if(value.startsWith("catched ")) return; + for (int t = 0; t < body.traits.traits.length; t++) { + if (body.traits.traits[t] instanceof TraitSlotConst) { + if (((TraitSlotConst) body.traits.traits[t]).slot_id == slotIndex) { + slotname = body.traits.traits[t].getName(abc); + } + } + + } + } + + if (slotname != null) { + if (localRegNames.containsValue(slotname.getName(constants, fullyQualifiedNames))) { + return; + }; + } + + if (value.getNotCoerced() instanceof IncrementTreeItem) { + GraphTargetItem inside = ((IncrementTreeItem) value.getNotCoerced()).object.getThroughRegister().getNotCoerced(); + if (inside instanceof GetSlotTreeItem) { + GetSlotTreeItem slotItem = (GetSlotTreeItem) inside; + if ((slotItem.scope.getThroughRegister() == obj.getThroughRegister()) + && (slotItem.slotName == slotname)) { + if (stack.size() > 0) { + GraphTargetItem top = stack.peek().getNotCoerced(); + if (top == inside) { + stack.pop(); + stack.push(new PostIncrementTreeItem(ins, inside)); + } else if ((top instanceof IncrementTreeItem) && (((IncrementTreeItem) top).object == inside)) { + stack.pop(); + stack.push(new PreIncrementTreeItem(ins, inside)); + } else { + output.add(new PostIncrementTreeItem(ins, inside)); + } + } else { + output.add(new PostIncrementTreeItem(ins, inside)); + } + return; + } + } + } + + if (value.getNotCoerced() instanceof DecrementTreeItem) { + GraphTargetItem inside = ((DecrementTreeItem) value.getNotCoerced()).object.getThroughRegister().getNotCoerced(); + if (inside instanceof GetSlotTreeItem) { + GetSlotTreeItem slotItem = (GetSlotTreeItem) inside; + if ((slotItem.scope.getThroughRegister() == obj.getThroughRegister()) + && (slotItem.slotName == slotname)) { + if (stack.size() > 0) { + GraphTargetItem top = stack.peek().getNotCoerced(); + if (top == inside) { + stack.pop(); + stack.push(new PostDecrementTreeItem(ins, inside)); + } else if ((top instanceof DecrementTreeItem) && (((DecrementTreeItem) top).object == inside)) { + stack.pop(); + stack.push(new PreDecrementTreeItem(ins, inside)); + } else { + output.add(new PostDecrementTreeItem(ins, inside)); + } + } else { + output.add(new PostDecrementTreeItem(ins, inside)); + } + return; + } + } + } + + output.add(new SetSlotTreeItem(ins, obj, slotname, value)); + } + + @Override + public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { + int slotIndex = ins.operands[0]; + ////String obj = stack.get(1); + String slotname = ""; + for (int t = 0; t < body.traits.traits.length; t++) { if (body.traits.traits[t] instanceof TraitSlotConst) { - if (((TraitSlotConst) body.traits.traits[t]).slot_id == slotIndex) { - slotname = body.traits.traits[t].getName(abc); - } + if (((TraitSlotConst) body.traits.traits[t]).slot_id == slotIndex) { + slotname = body.traits.traits[t].getName(abc).getName(abc.constants, fullyQualifiedNames); + } } - } - } + } + return slotname; + } - if (slotname != null) { - if (localRegNames.containsValue(slotname.getName(constants, fullyQualifiedNames))) { - return; - }; - } - - if (value.getNotCoerced() instanceof IncrementTreeItem) { - GraphTargetItem inside = ((IncrementTreeItem) value.getNotCoerced()).object.getThroughRegister().getNotCoerced(); - if (inside instanceof GetSlotTreeItem) { - GetSlotTreeItem slotItem = (GetSlotTreeItem) inside; - if ((slotItem.scope.getThroughRegister() == obj.getThroughRegister()) - && (slotItem.slotName == slotname)) { - if (stack.size() > 0) { - GraphTargetItem top = stack.peek().getNotCoerced(); - if (top == inside) { - stack.pop(); - stack.push(new PostIncrementTreeItem(ins, inside)); - } else if ((top instanceof IncrementTreeItem) && (((IncrementTreeItem) top).object == inside)) { - stack.pop(); - stack.push(new PreIncrementTreeItem(ins, inside)); - } else { - output.add(new PostIncrementTreeItem(ins, inside)); - } - } else { - output.add(new PostIncrementTreeItem(ins, inside)); - } - return; - } - } - } - - if (value.getNotCoerced() instanceof DecrementTreeItem) { - GraphTargetItem inside = ((DecrementTreeItem) value.getNotCoerced()).object.getThroughRegister().getNotCoerced(); - if (inside instanceof GetSlotTreeItem) { - GetSlotTreeItem slotItem = (GetSlotTreeItem) inside; - if ((slotItem.scope.getThroughRegister() == obj.getThroughRegister()) - && (slotItem.slotName == slotname)) { - if (stack.size() > 0) { - GraphTargetItem top = stack.peek().getNotCoerced(); - if (top == inside) { - stack.pop(); - stack.push(new PostDecrementTreeItem(ins, inside)); - } else if ((top instanceof DecrementTreeItem) && (((DecrementTreeItem) top).object == inside)) { - stack.pop(); - stack.push(new PreDecrementTreeItem(ins, inside)); - } else { - output.add(new PostDecrementTreeItem(ins, inside)); - } - } else { - output.add(new PostDecrementTreeItem(ins, inside)); - } - return; - } - } - } - - output.add(new SetSlotTreeItem(ins, obj, slotname, value)); - } - - @Override - public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { - int slotIndex = ins.operands[0]; - ////String obj = stack.get(1); - String slotname = ""; - for (int t = 0; t < body.traits.traits.length; t++) { - if (body.traits.traits[t] instanceof TraitSlotConst) { - if (((TraitSlotConst) body.traits.traits[t]).slot_id == slotIndex) { - slotname = body.traits.traits[t].getName(abc).getName(abc.constants, fullyQualifiedNames); - } - } - - } - return slotname; - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java index 0696061b6..45aee124b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java @@ -33,38 +33,38 @@ import java.util.Stack; public class SetSuperIns extends InstructionDefinition implements SetTypeIns { - public SetSuperIns() { - super(0x05, "setsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public SetSuperIns() { + super(0x05, "setsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; - GraphTargetItem value = (GraphTargetItem) stack.pop(); - FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - output.add(new SetSuperTreeItem(ins, value, obj, multiname)); - } + GraphTargetItem value = (GraphTargetItem) stack.pop(); + FullMultinameTreeItem multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem obj = (GraphTargetItem) stack.pop(); + output.add(new SetSuperTreeItem(ins, value, obj, multiname)); + } - @Override - public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - String multiname = resolveMultinameNoPop(1, stack, abc.constants, multinameIndex, ins, fullyQualifiedNames); - String obj = stack.get(1 + resolvedCount(abc.constants, multinameIndex)).toString(abc.constants, localRegNames, fullyQualifiedNames); - return obj + ".super." + multiname; - } + @Override + public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + String multiname = resolveMultinameNoPop(1, stack, abc.constants, multinameIndex, ins, fullyQualifiedNames); + String obj = stack.get(1 + resolvedCount(abc.constants, multinameIndex)).toString(abc.constants, localRegNames, fullyQualifiedNames); + return obj + ".super." + multiname; + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -2; - int multinameIndex = ins.operands[0]; - if (abc.constants.constant_multiname[multinameIndex].needsName()) { - ret--; - } - if (abc.constants.constant_multiname[multinameIndex].needsNs()) { - ret--; - } - return ret; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -2; + int multinameIndex = ins.operands[0]; + if (abc.constants.constant_multiname[multinameIndex].needsName()) { + ret--; + } + if (abc.constants.constant_multiname[multinameIndex].needsNs()) { + ret--; + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ThrowIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ThrowIns.java index d669f62e2..9c82881e8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ThrowIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ThrowIns.java @@ -30,17 +30,17 @@ import java.util.Stack; public class ThrowIns extends InstructionDefinition { - public ThrowIns() { - super(0x03, "throw", new int[]{}); - } + public ThrowIns() { + super(0x03, "throw", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - output.add(new ThrowTreeItem(ins, (GraphTargetItem) stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + output.add(new ThrowTreeItem(ins, (GraphTargetItem) stack.pop())); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/DupIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/DupIns.java index 1926ff754..39beb714b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/DupIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/DupIns.java @@ -22,7 +22,6 @@ import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.flash.graph.GraphSourceItem; import com.jpexs.decompiler.flash.graph.GraphSourceItemPos; import com.jpexs.decompiler.flash.graph.GraphTargetItem; import java.util.HashMap; @@ -31,28 +30,28 @@ import java.util.Stack; public class DupIns extends InstructionDefinition { - public DupIns() { - super(0x2a, "dup", new int[]{}); - } + public DupIns() { + super(0x2a, "dup", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object obj = lda.operandStack.pop(); - lda.operandStack.push(obj); - lda.operandStack.push(obj); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object obj = lda.operandStack.pop(); + lda.operandStack.push(obj); + lda.operandStack.push(obj); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem v = stack.pop(); - stack.push(v); - stack.push(v); - v.moreSrc.add(new GraphSourceItemPos(ins, 0)); + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem v = stack.pop(); + stack.push(v); + stack.push(v); + v.moreSrc.add(new GraphSourceItemPos(ins, 0)); - } + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 2; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 2; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopIns.java index 023341bec..189d5aae8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopIns.java @@ -31,37 +31,37 @@ import java.util.Stack; public class PopIns extends InstructionDefinition { - public PopIns() { - super(0x29, "pop", new int[]{}); - } + public PopIns() { + super(0x29, "pop", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.pop(); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.pop(); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - if (stack.size() > 0) { - GraphTargetItem top = stack.pop(); - if (top instanceof CallPropertyTreeItem) { - output.add(top); - } else if (top instanceof CallSuperTreeItem) { - output.add(top); - } else if (top instanceof CallStaticTreeItem) { - output.add(top); - } else if (top instanceof CallMethodTreeItem) { - output.add(top); - } else if (top instanceof CallTreeItem) { - output.add(top); - } else if (top instanceof AssignmentTreeItem) { - output.add(top); - } - } - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + if (stack.size() > 0) { + GraphTargetItem top = stack.pop(); + if (top instanceof CallPropertyTreeItem) { + output.add(top); + } else if (top instanceof CallSuperTreeItem) { + output.add(top); + } else if (top instanceof CallStaticTreeItem) { + output.add(top); + } else if (top instanceof CallMethodTreeItem) { + output.add(top); + } else if (top instanceof CallTreeItem) { + output.add(top); + } else if (top instanceof AssignmentTreeItem) { + output.add(top); + } + } + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopScopeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopScopeIns.java index 337566ad8..08aac4ddc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopScopeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopScopeIns.java @@ -32,26 +32,26 @@ import java.util.Stack; public class PopScopeIns extends InstructionDefinition { - public PopScopeIns() { - super(0x1d, "popscope", new int[]{}); - } + public PopScopeIns() { + super(0x1d, "popscope", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.scopeStack.pop(); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.scopeStack.pop(); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem scope = (GraphTargetItem) scopeStack.pop(); - if (scope instanceof WithObjectTreeItem) { - scope = ((WithObjectTreeItem) scope).scope; - output.add(new WithEndTreeItem(ins, scope)); - } - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem scope = (GraphTargetItem) scopeStack.pop(); + if (scope instanceof WithObjectTreeItem) { + scope = ((WithObjectTreeItem) scope).scope; + output.add(new WithEndTreeItem(ins, scope)); + } + } - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushByteIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushByteIns.java index 5ec6b9f87..719bfa962 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushByteIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushByteIns.java @@ -31,22 +31,22 @@ import java.util.Stack; public class PushByteIns extends InstructionDefinition implements PushIntegerTypeIns { - public PushByteIns() { - super(0x24, "pushbyte", new int[]{AVM2Code.OPT_BYTE}); - } + public PushByteIns() { + super(0x24, "pushbyte", new int[]{AVM2Code.OPT_BYTE}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(arguments.get(0)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(arguments.get(0)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new IntegerValueTreeItem(ins, new Long(ins.operands[0]))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new IntegerValueTreeItem(ins, new Long(ins.operands[0]))); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushDoubleIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushDoubleIns.java index ef9712834..c152e677c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushDoubleIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushDoubleIns.java @@ -31,22 +31,22 @@ import java.util.Stack; public class PushDoubleIns extends InstructionDefinition { - public PushDoubleIns() { - super(0x2f, "pushdouble", new int[]{AVM2Code.DAT_DOUBLE_INDEX}); - } + public PushDoubleIns() { + super(0x2f, "pushdouble", new int[]{AVM2Code.DAT_DOUBLE_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(arguments.get(0)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(arguments.get(0)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new FloatValueTreeItem(ins, constants.constant_double[ins.operands[0]])); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new FloatValueTreeItem(ins, constants.constant_double[ins.operands[0]])); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushFalseIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushFalseIns.java index f3c1ff6ff..8776fadbd 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushFalseIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushFalseIns.java @@ -30,22 +30,22 @@ import java.util.Stack; public class PushFalseIns extends InstructionDefinition { - public PushFalseIns() { - super(0x27, "pushfalse", new int[]{}); - } + public PushFalseIns() { + super(0x27, "pushfalse", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(Boolean.FALSE); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(Boolean.FALSE); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new BooleanTreeItem(ins, Boolean.FALSE)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new BooleanTreeItem(ins, Boolean.FALSE)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushIntIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushIntIns.java index eb7c2a07b..dd50dbfab 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushIntIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushIntIns.java @@ -31,22 +31,22 @@ import java.util.Stack; public class PushIntIns extends InstructionDefinition implements PushIntegerTypeIns { - public PushIntIns() { - super(0x2d, "pushint", new int[]{AVM2Code.DAT_INT_INDEX}); - } + public PushIntIns() { + super(0x2d, "pushint", new int[]{AVM2Code.DAT_INT_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(arguments.get(0)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(arguments.get(0)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new IntegerValueTreeItem(ins, constants.constant_int[ins.operands[0]])); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new IntegerValueTreeItem(ins, constants.constant_int[ins.operands[0]])); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNamespaceIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNamespaceIns.java index a438899a6..ef563c952 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNamespaceIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNamespaceIns.java @@ -31,17 +31,17 @@ import java.util.Stack; public class PushNamespaceIns extends InstructionDefinition { - public PushNamespaceIns() { - super(0x31, "pushnamespace", new int[]{AVM2Code.OPT_U30}); - } + public PushNamespaceIns() { + super(0x31, "pushnamespace", new int[]{AVM2Code.OPT_U30}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new NameSpaceTreeItem(ins, ins.operands[0])); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new NameSpaceTreeItem(ins, ins.operands[0])); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNanIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNanIns.java index b9ff30b12..efcbd17bf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNanIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNanIns.java @@ -29,17 +29,17 @@ import java.util.Stack; public class PushNanIns extends InstructionDefinition { - public PushNanIns() { - super(0x28, "pushnan", new int[]{}); - } + public PushNanIns() { + super(0x28, "pushnan", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new NanTreeItem(ins)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new NanTreeItem(ins)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNullIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNullIns.java index 490706ace..bf782667a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNullIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNullIns.java @@ -29,17 +29,17 @@ import java.util.Stack; public class PushNullIns extends InstructionDefinition { - public PushNullIns() { - super(0x20, "pushnull", new int[]{}); - } + public PushNullIns() { + super(0x20, "pushnull", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new NullTreeItem(ins)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new NullTreeItem(ins)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushScopeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushScopeIns.java index 50adea0e9..cfad3d2c3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushScopeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushScopeIns.java @@ -29,27 +29,27 @@ import java.util.Stack; public class PushScopeIns extends InstructionDefinition { - public PushScopeIns() { - super(0x30, "pushscope", new int[]{}); - } + public PushScopeIns() { + super(0x30, "pushscope", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.scopeStack.push(lda.operandStack.pop()); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.scopeStack.push(lda.operandStack.pop()); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - scopeStack.push(stack.pop()); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + scopeStack.push(stack.pop()); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushShortIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushShortIns.java index 8d2415afc..22270cda2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushShortIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushShortIns.java @@ -31,22 +31,22 @@ import java.util.Stack; public class PushShortIns extends InstructionDefinition implements PushIntegerTypeIns { - public PushShortIns() { - super(0x25, "pushshort", new int[]{AVM2Code.OPT_U30}); - } + public PushShortIns() { + super(0x25, "pushshort", new int[]{AVM2Code.OPT_U30}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(arguments.get(0)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(arguments.get(0)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new IntegerValueTreeItem(ins, new Long(ins.operands[0]))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new IntegerValueTreeItem(ins, new Long(ins.operands[0]))); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushStringIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushStringIns.java index 44590fb5c..3072a0934 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushStringIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushStringIns.java @@ -31,22 +31,22 @@ import java.util.Stack; public class PushStringIns extends InstructionDefinition { - public PushStringIns() { - super(0x2c, "pushstring", new int[]{AVM2Code.DAT_STRING_INDEX}); - } + public PushStringIns() { + super(0x2c, "pushstring", new int[]{AVM2Code.DAT_STRING_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(arguments.get(0)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(arguments.get(0)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new StringTreeItem(ins, constants.constant_string[ins.operands[0]])); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new StringTreeItem(ins, constants.constant_string[ins.operands[0]])); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushTrueIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushTrueIns.java index 75d6785ab..13c91200f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushTrueIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushTrueIns.java @@ -30,22 +30,22 @@ import java.util.Stack; public class PushTrueIns extends InstructionDefinition { - public PushTrueIns() { - super(0x26, "pushtrue", new int[]{}); - } + public PushTrueIns() { + super(0x26, "pushtrue", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(Boolean.TRUE); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(Boolean.TRUE); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new BooleanTreeItem(ins, Boolean.TRUE)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new BooleanTreeItem(ins, Boolean.TRUE)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUIntIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUIntIns.java index 13e243cd9..666753e37 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUIntIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUIntIns.java @@ -31,22 +31,22 @@ import java.util.Stack; public class PushUIntIns extends InstructionDefinition implements PushIntegerTypeIns { - public PushUIntIns() { - super(0x2e, "pushuint", new int[]{AVM2Code.DAT_UINT_INDEX}); - } + public PushUIntIns() { + super(0x2e, "pushuint", new int[]{AVM2Code.DAT_UINT_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.operandStack.push(arguments.get(0)); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.operandStack.push(arguments.get(0)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new IntegerValueTreeItem(ins, constants.constant_uint[ins.operands[0]])); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new IntegerValueTreeItem(ins, constants.constant_uint[ins.operands[0]])); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUndefinedIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUndefinedIns.java index dcbee896c..2bf795804 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUndefinedIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUndefinedIns.java @@ -29,17 +29,17 @@ import java.util.Stack; public class PushUndefinedIns extends InstructionDefinition { - public PushUndefinedIns() { - super(0x21, "pushundefined", new int[]{}); - } + public PushUndefinedIns() { + super(0x21, "pushundefined", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new UndefinedTreeItem(ins)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new UndefinedTreeItem(ins)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushWithIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushWithIns.java index 554e1faa4..f2ebf9b2a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushWithIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushWithIns.java @@ -31,25 +31,25 @@ import java.util.Stack; public class PushWithIns extends InstructionDefinition { - public PushWithIns() { - super(0x1c, "pushwith", new int[]{}); - } + public PushWithIns() { + super(0x1c, "pushwith", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem w = (GraphTargetItem) stack.pop(); - WithObjectTreeItem wot = new WithObjectTreeItem(ins, w); - scopeStack.push(wot); - output.add(new WithTreeItem(ins, w)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem w = (GraphTargetItem) stack.pop(); + WithObjectTreeItem wot = new WithObjectTreeItem(ins, w); + scopeStack.push(wot); + output.add(new WithTreeItem(ins, w)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/SwapIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/SwapIns.java index bf640f2df..49546a52c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/SwapIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/SwapIns.java @@ -31,31 +31,31 @@ import java.util.Stack; public class SwapIns extends InstructionDefinition { - public SwapIns() { - super(0x2b, "swap", new int[]{}); - } + public SwapIns() { + super(0x2b, "swap", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object obj1 = lda.operandStack.pop(); - Object obj2 = lda.operandStack.pop(); - lda.operandStack.push(obj1); - lda.operandStack.push(obj2); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object obj1 = lda.operandStack.pop(); + Object obj2 = lda.operandStack.pop(); + lda.operandStack.push(obj1); + lda.operandStack.push(obj2); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem o1 = stack.pop(); - GraphTargetItem o2 = stack.pop(); - stack.push(o1); - stack.push(o2); - o1.moreSrc.add(new GraphSourceItemPos(ins, 0)); - o2.moreSrc.add(new GraphSourceItemPos(ins, 0)); - } + GraphTargetItem o1 = stack.pop(); + GraphTargetItem o2 = stack.pop(); + stack.push(o1); + stack.push(o2); + o1.moreSrc.add(new GraphSourceItemPos(ins, 0)); + o2.moreSrc.add(new GraphSourceItemPos(ins, 0)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 2; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 2; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ApplyTypeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ApplyTypeIns.java index 3c155d96a..f8beba483 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ApplyTypeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ApplyTypeIns.java @@ -29,33 +29,33 @@ import java.util.*; public class ApplyTypeIns extends InstructionDefinition { - public ApplyTypeIns() { - super(0x53, "applytype", new int[]{AVM2Code.DAT_ARG_COUNT}); - } + public ApplyTypeIns() { + super(0x53, "applytype", new int[]{AVM2Code.DAT_ARG_COUNT}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int argCount = (int) ((Long) arguments.get(0)).longValue(); - List params = new ArrayList(); - for (int i = 0; i < argCount; i++) { - params.add(lda.operandStack.pop()); - } - Collections.reverse(params); - //TODO: pop type and push type - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int argCount = (int) ((Long) arguments.get(0)).longValue(); + List params = new ArrayList(); + for (int i = 0; i < argCount; i++) { + params.add(lda.operandStack.pop()); + } + Collections.reverse(params); + //TODO: pop type and push type + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int argCount = ins.operands[0]; - List params = new ArrayList(); - for (int i = 0; i < argCount; i++) { - params.add(0, stack.pop()); - } - stack.push(new ApplyTypeTreeItem(ins, stack.pop(), params)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int argCount = ins.operands[0]; + List params = new ArrayList(); + for (int i = 0; i < argCount; i++) { + params.add(0, stack.pop()); + } + stack.push(new ApplyTypeTreeItem(ins, stack.pop(), params)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -ins.operands[0] + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -ins.operands[0] + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java index 61f0c7ab5..c4f86c518 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java @@ -32,29 +32,29 @@ import java.util.Stack; public class AsTypeIns extends InstructionDefinition { - public AsTypeIns() { - super(0x86, "astype", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public AsTypeIns() { + super(0x86, "astype", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Long typeIndex = (Long) arguments.get(0); - Object obj = lda.operandStack.pop(); - //if multiname[typeIndex]==obj - lda.operandStack.push(obj); - //else push null + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Long typeIndex = (Long) arguments.get(0); + Object obj = lda.operandStack.pop(); + //if multiname[typeIndex]==obj + lda.operandStack.push(obj); + //else push null - } + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem val = (GraphTargetItem) stack.pop(); + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem val = (GraphTargetItem) stack.pop(); - stack.push(new AsTypeTreeItem(ins, val, new FullMultinameTreeItem(ins, ins.operands[0]))); - } + stack.push(new AsTypeTreeItem(ins, val, new FullMultinameTreeItem(ins, ins.operands[0]))); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeLateIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeLateIns.java index 0ac0f0786..061582e7e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeLateIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeLateIns.java @@ -30,28 +30,28 @@ import java.util.Stack; public class AsTypeLateIns extends InstructionDefinition { - public AsTypeLateIns() { - super(0x87, "astypelate", new int[]{}); - } + public AsTypeLateIns() { + super(0x87, "astypelate", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object objClass = lda.operandStack.pop(); - Object obj = lda.operandStack.pop(); - //if obj.class=objClass - lda.operandStack.push(obj); - //else push null - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object objClass = lda.operandStack.pop(); + Object obj = lda.operandStack.pop(); + //if obj.class=objClass + lda.operandStack.push(obj); + //else push null + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem cls = (GraphTargetItem) stack.pop(); - GraphTargetItem val = (GraphTargetItem) stack.pop(); - stack.push(new AsTypeTreeItem(ins, val, cls)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem cls = (GraphTargetItem) stack.pop(); + GraphTargetItem val = (GraphTargetItem) stack.pop(); + stack.push(new AsTypeTreeItem(ins, val, cls)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java index f0879ca5c..15fce8fbb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java @@ -30,32 +30,32 @@ import java.util.Stack; public class CoerceAIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - public CoerceAIns() { - super(0x82, "coerce_a", new int[]{}); - } + public CoerceAIns() { + super(0x82, "coerce_a", new int[]{}); + } - public String getTargetType() { - return "*"; - } + public String getTargetType() { + return "*"; + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - //coerce any type - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + //coerce any type + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new CoerceTreeItem(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new CoerceTreeItem(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); - } + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } - @Override - public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return "*"; - } + @Override + public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { + return "*"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java index 07bb93c87..f0cd39a08 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java @@ -31,30 +31,30 @@ import java.util.Stack; public class CoerceIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - public CoerceIns() { - super(0x80, "coerce", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public CoerceIns() { + super(0x80, "coerce", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); - //push and pop coerced value to specified type - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int multinameIndex = (int) ((Long) arguments.get(0)).longValue(); + //push and pop coerced value to specified type + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - stack.push(new CoerceTreeItem(ins, (GraphTargetItem) stack.pop(), constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + stack.push(new CoerceTreeItem(ins, (GraphTargetItem) stack.pop(), constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames))); + } - @Override - public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - return constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames); - } + @Override + public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + return constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceOrConvertTypeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceOrConvertTypeIns.java index 73a5c71ad..092083d12 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceOrConvertTypeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceOrConvertTypeIns.java @@ -26,5 +26,5 @@ import java.util.List; */ public interface CoerceOrConvertTypeIns { - public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames); + public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java index ba86d75a1..511729291 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java @@ -30,28 +30,28 @@ import java.util.Stack; public class CoerceSIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - public CoerceSIns() { - super(0x85, "coerce_s", new int[]{}); - } + public CoerceSIns() { + super(0x85, "coerce_s", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object obj = lda.operandStack.pop(); - lda.operandStack.push(obj.toString()); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object obj = lda.operandStack.pop(); + lda.operandStack.push(obj.toString()); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new CoerceTreeItem(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new CoerceTreeItem(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } - @Override - public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return "String"; - } + @Override + public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { + return "String"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java index 783cd5674..da948bcbd 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java @@ -30,38 +30,38 @@ import java.util.Stack; public class ConvertBIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - public ConvertBIns() { - super(0x76, "convert_b", new int[]{}); - } + public ConvertBIns() { + super(0x76, "convert_b", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object value = lda.operandStack.pop(); - boolean bval; - if (value instanceof Boolean) { - bval = (Boolean) value; - } else if (value instanceof Long) { - bval = ((Long) value).longValue() != 0; - } else if (value instanceof String) { - bval = !((String) value).equals(""); - } else { - bval = true; - } - lda.operandStack.push((Boolean) bval); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object value = lda.operandStack.pop(); + boolean bval; + if (value instanceof Boolean) { + bval = (Boolean) value; + } else if (value instanceof Long) { + bval = ((Long) value).longValue() != 0; + } else if (value instanceof String) { + bval = !((String) value).equals(""); + } else { + bval = true; + } + lda.operandStack.push((Boolean) bval); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new ConvertTreeItem(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new ConvertTreeItem(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } - @Override - public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return "Boolean"; - } + @Override + public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { + return "Boolean"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java index 781eeeacf..3767c99e8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java @@ -30,46 +30,46 @@ import java.util.Stack; public class ConvertDIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - public ConvertDIns() { - super(0x75, "convert_d", new int[]{}); - } + public ConvertDIns() { + super(0x75, "convert_d", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object value = lda.operandStack.pop(); - double ret; - if (value == null) { - ret = 0; - } else if (value instanceof Boolean) { - if (((Boolean) value).booleanValue()) { - ret = 1; - } else { + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object value = lda.operandStack.pop(); + double ret; + if (value == null) { ret = 0; - } - } else if (value instanceof Long) { - ret = ((Long) value).longValue(); - } else if (value instanceof Double) { - ret = ((Double) value).doubleValue(); - } else if (value instanceof String) { - ret = Double.parseDouble((String) value); - } else { - ret = 1; //must call toPrimitive - } - lda.operandStack.push(new Double(ret)); - } + } else if (value instanceof Boolean) { + if (((Boolean) value).booleanValue()) { + ret = 1; + } else { + ret = 0; + } + } else if (value instanceof Long) { + ret = ((Long) value).longValue(); + } else if (value instanceof Double) { + ret = ((Double) value).doubleValue(); + } else if (value instanceof String) { + ret = Double.parseDouble((String) value); + } else { + ret = 1; //must call toPrimitive + } + lda.operandStack.push(new Double(ret)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new ConvertTreeItem(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new ConvertTreeItem(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } - @Override - public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return "Number"; - } + @Override + public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { + return "Number"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java index 4eb1b3941..25e80f2bc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java @@ -30,44 +30,44 @@ import java.util.Stack; public class ConvertIIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - public ConvertIIns() { - super(0x73, "convert_i", new int[]{}); - } + public ConvertIIns() { + super(0x73, "convert_i", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object value = lda.operandStack.pop(); - long ret; - if (value == null) { - ret = 0; - } else if (value instanceof Boolean) { - if (((Boolean) value).booleanValue()) { - ret = 1; - } else { + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object value = lda.operandStack.pop(); + long ret; + if (value == null) { ret = 0; - } - } else if (value instanceof Long) { - ret = ((Long) value).longValue(); - } else if (value instanceof String) { - ret = Long.parseLong((String) value); - } else { - ret = 1; //must call toPrimitive - } - lda.operandStack.push(new Long(ret)); - } + } else if (value instanceof Boolean) { + if (((Boolean) value).booleanValue()) { + ret = 1; + } else { + ret = 0; + } + } else if (value instanceof Long) { + ret = ((Long) value).longValue(); + } else if (value instanceof String) { + ret = Long.parseLong((String) value); + } else { + ret = 1; //must call toPrimitive + } + lda.operandStack.push(new Long(ret)); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new ConvertTreeItem(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new ConvertTreeItem(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } - @Override - public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return "int"; - } + @Override + public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { + return "int"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java index 5d288726d..343e5e3eb 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java @@ -30,27 +30,27 @@ import java.util.Stack; public class ConvertOIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - public ConvertOIns() { - super(0x77, "convert_o", new int[]{}); - } + public ConvertOIns() { + super(0x77, "convert_o", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - //throw if pop is not object - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + //throw if pop is not object + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new ConvertTreeItem(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new ConvertTreeItem(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } - @Override - public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return "Object"; - } + @Override + public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { + return "Object"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java index 9d0c10036..b11deb415 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java @@ -30,28 +30,28 @@ import java.util.Stack; public class ConvertSIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - public ConvertSIns() { - super(0x70, "convert_s", new int[]{}); - } + public ConvertSIns() { + super(0x70, "convert_s", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - Object obj = lda.operandStack.pop(); - lda.operandStack.push(obj.toString()); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + Object obj = lda.operandStack.pop(); + lda.operandStack.push(obj.toString()); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new ConvertTreeItem(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new ConvertTreeItem(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } - @Override - public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return "String"; - } + @Override + public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { + return "String"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java index e5c04737d..6cc88adae 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java @@ -30,27 +30,27 @@ import java.util.Stack; public class ConvertUIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - public ConvertUIns() { - super(0x74, "convert_u", new int[]{}); - } + public ConvertUIns() { + super(0x74, "convert_u", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - throw new UnsupportedOperationException("Cannot convert to uint "); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + throw new UnsupportedOperationException("Cannot convert to uint "); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new ConvertTreeItem(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new ConvertTreeItem(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } - @Override - public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return "uint"; - } + @Override + public String getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { + return "uint"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/InstanceOfIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/InstanceOfIns.java index 21c1fade6..d0813426c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/InstanceOfIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/InstanceOfIns.java @@ -29,19 +29,19 @@ import java.util.Stack; public class InstanceOfIns extends InstructionDefinition { - public InstanceOfIns() { - super(0xb1, "instanceof", new int[]{}); - } + public InstanceOfIns() { + super(0xb1, "instanceof", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem type = (GraphTargetItem) stack.pop(); - GraphTargetItem value = (GraphTargetItem) stack.pop(); - stack.push(new InstanceOfTreeItem(ins, value, type)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem type = (GraphTargetItem) stack.pop(); + GraphTargetItem value = (GraphTargetItem) stack.pop(); + stack.push(new InstanceOfTreeItem(ins, value, type)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java index 7800f7c92..8d9693c40 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java @@ -31,19 +31,19 @@ import java.util.Stack; public class IsTypeIns extends InstructionDefinition { - public IsTypeIns() { - super(0xb2, "istype", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } + public IsTypeIns() { + super(0xb2, "istype", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - int multinameIndex = ins.operands[0]; - GraphTargetItem value = (GraphTargetItem) stack.pop(); - stack.push(new IsTypeTreeItem(ins, value, new FullMultinameTreeItem(ins, multinameIndex))); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + int multinameIndex = ins.operands[0]; + GraphTargetItem value = (GraphTargetItem) stack.pop(); + stack.push(new IsTypeTreeItem(ins, value, new FullMultinameTreeItem(ins, multinameIndex))); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; //may not be runtime multiname - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; //may not be runtime multiname + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeLateIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeLateIns.java index e11ec89cb..afc4321f3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeLateIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeLateIns.java @@ -29,19 +29,19 @@ import java.util.Stack; public class IsTypeLateIns extends InstructionDefinition { - public IsTypeLateIns() { - super(0xb3, "istypelate", new int[]{}); - } + public IsTypeLateIns() { + super(0xb3, "istypelate", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem type = (GraphTargetItem) stack.pop(); - GraphTargetItem value = (GraphTargetItem) stack.pop(); - stack.push(new IsTypeTreeItem(ins, value, type)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem type = (GraphTargetItem) stack.pop(); + GraphTargetItem value = (GraphTargetItem) stack.pop(); + stack.push(new IsTypeTreeItem(ins, value, type)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/TypeOfIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/TypeOfIns.java index 6813162b0..826885989 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/TypeOfIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/TypeOfIns.java @@ -29,17 +29,17 @@ import java.util.Stack; public class TypeOfIns extends InstructionDefinition { - public TypeOfIns() { - super(0x95, "typeof", new int[]{}); - } + public TypeOfIns() { + super(0x95, "typeof", new int[]{}); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new TypeOfTreeItem(ins, (GraphTargetItem) stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new TypeOfTreeItem(ins, (GraphTargetItem) stack.pop())); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/CheckFilterIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/CheckFilterIns.java index 23a9cc4b5..bfa6008e2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/CheckFilterIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/CheckFilterIns.java @@ -30,23 +30,23 @@ import java.util.Stack; public class CheckFilterIns extends InstructionDefinition { - public CheckFilterIns() { - super(0x78, "checkfilter", new int[]{}); - } + public CheckFilterIns() { + super(0x78, "checkfilter", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - //if pop() is not XML|XMLList throw - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + //if pop() is not XML|XMLList throw + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem obj = stack.pop(); - stack.push(new FilteredCheckTreeItem(ins, obj)); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem obj = stack.pop(); + stack.push(new FilteredCheckTreeItem(ins, obj)); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSIns.java index 528a22a72..ba81bd88a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSIns.java @@ -33,20 +33,20 @@ import java.util.Stack; public class DXNSIns extends InstructionDefinition { - public DXNSIns() { - super(0x06, "dxns", new int[]{AVM2Code.DAT_STRING_INDEX}); - } + public DXNSIns() { + super(0x06, "dxns", new int[]{AVM2Code.DAT_STRING_INDEX}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - int strIndex = (int) ((Long) arguments.get(0)).longValue(); - String s = constants.constant_string[strIndex]; - System.out.println("Set default XML space " + s); + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + int strIndex = (int) ((Long) arguments.get(0)).longValue(); + String s = constants.constant_string[strIndex]; + System.out.println("Set default XML space " + s); - } + } - @Override - public void translate(boolean isStatic, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - output.add(new DefaultXMLNamespace(ins, new StringTreeItem(ins, constants.constant_string[ins.operands[0]]))); - } + @Override + public void translate(boolean isStatic, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + output.add(new DefaultXMLNamespace(ins, new StringTreeItem(ins, constants.constant_string[ins.operands[0]]))); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSLateIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSLateIns.java index 2a7651004..1d0a4cde2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSLateIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSLateIns.java @@ -30,25 +30,25 @@ import java.util.Stack; public class DXNSLateIns extends InstructionDefinition { - public DXNSLateIns() { - super(0x07, "dxnslate", new int[]{}); - } + public DXNSLateIns() { + super(0x07, "dxnslate", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - String s = lda.operandStack.pop().toString(); - System.out.println("Set default XML space " + s); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + String s = lda.operandStack.pop().toString(); + System.out.println("Set default XML space " + s); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - GraphTargetItem xmlns = stack.pop(); - output.add(new DefaultXMLNamespace(ins, xmlns)); + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + GraphTargetItem xmlns = stack.pop(); + output.add(new DefaultXMLNamespace(ins, xmlns)); - } + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXAttrIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXAttrIns.java index 50b20a5eb..8c4f6f449 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXAttrIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXAttrIns.java @@ -30,24 +30,24 @@ import java.util.Stack; public class EscXAttrIns extends InstructionDefinition { - public EscXAttrIns() { - super(0x72, "esc_xattr", new int[]{}); - } + public EscXAttrIns() { + super(0x72, "esc_xattr", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - String s = lda.operandStack.pop().toString(); - //escape - lda.operandStack.push(s); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + String s = lda.operandStack.pop().toString(); + //escape + lda.operandStack.push(s); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new EscapeXAttrTreeItem(ins, stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new EscapeXAttrTreeItem(ins, stack.pop())); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXElemIns.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXElemIns.java index 3b157cb8c..58c541ede 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXElemIns.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXElemIns.java @@ -30,24 +30,24 @@ import java.util.Stack; public class EscXElemIns extends InstructionDefinition { - public EscXElemIns() { - super(0x71, "esc_xelem", new int[]{}); - } + public EscXElemIns() { + super(0x71, "esc_xelem", new int[]{}); + } - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - String s = lda.operandStack.pop().toString(); - //escape - lda.operandStack.push(s); - } + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + String s = lda.operandStack.pop().toString(); + //escape + lda.operandStack.push(s); + } - @Override - public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { - stack.push(new EscapeXElemTreeItem(ins, stack.pop())); - } + @Override + public void translate(boolean isStatic, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, MethodInfo[] method_info, List output, com.jpexs.decompiler.flash.abc.types.MethodBody body, com.jpexs.decompiler.flash.abc.ABC abc, HashMap localRegNames, List fullyQualifiedNames) { + stack.push(new EscapeXElemTreeItem(ins, stack.pop())); + } - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } } 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 17eac25f1..86c45f087 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 @@ -24,298 +24,299 @@ import com.jpexs.decompiler.flash.abc.types.ABCException; import com.jpexs.decompiler.flash.abc.types.MethodBody; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class ASM3Parser { - private static class OffsetItem { + private static class OffsetItem { - public String label = ""; - public long insPosition; - public int insOperandIndex; + public String label = ""; + public long insPosition; + public int insOperandIndex; - public OffsetItem(String label, long insOffset, int insOperandIndex) { - this.label = label; - this.insPosition = insOffset; - this.insOperandIndex = insOperandIndex; - } - } + public OffsetItem(String label, long insOffset, int insOperandIndex) { + this.label = label; + this.insPosition = insOffset; + this.insOperandIndex = insOperandIndex; + } + } - private static class CaseOffsetItem extends OffsetItem { + private static class CaseOffsetItem extends OffsetItem { - public CaseOffsetItem(String label, long insOffset, int insOperandIndex) { - super(label, insOffset, insOperandIndex); - } - } + public CaseOffsetItem(String label, long insOffset, int insOperandIndex) { + super(label, insOffset, insOperandIndex); + } + } - private static class LabelItem { + private static class LabelItem { - public String label = ""; - public int offset; + public String label = ""; + public int offset; - public LabelItem(String label, int offset) { - this.label = label; - this.offset = offset; - } - } + public LabelItem(String label, int offset) { + this.label = label; + this.offset = offset; + } + } - public static AVM2Code parse(InputStream is, ConstantPool constants, MethodBody body) throws IOException, ParseException { - return parse(is, constants, null, body); - } + public static AVM2Code parse(InputStream is, ConstantPool constants, MethodBody body) throws IOException, ParseException { + return parse(is, constants, null, body); + } - private static int checkMultinameIndex(ConstantPool constants, int index, int line) throws ParseException { - if ((index < 0) || (index >= constants.constant_multiname.length)) { - throw new ParseException("Invalid multiname index", line); - } - return index; - } + private static int checkMultinameIndex(ConstantPool constants, int index, int line) throws ParseException { + if ((index < 0) || (index >= constants.constant_multiname.length)) { + throw new ParseException("Invalid multiname index", line); + } + return index; + } - public static AVM2Code parse(InputStream is, ConstantPool constants, MissingSymbolHandler missingHandler, MethodBody body) throws IOException, ParseException { - AVM2Code code = new AVM2Code(); + public static AVM2Code parse(InputStream is, ConstantPool constants, MissingSymbolHandler missingHandler, MethodBody body) throws IOException, ParseException { + AVM2Code code = new AVM2Code(); - List offsetItems = new ArrayList(); - List labelItems = new ArrayList(); - List exceptions = new ArrayList(); - List exceptionIndices = new ArrayList(); - int offset = 0; + List offsetItems = new ArrayList(); + List labelItems = new ArrayList(); + List exceptions = new ArrayList(); + List exceptionIndices = new ArrayList(); + int offset = 0; - Flasm3Lexer lexer = new Flasm3Lexer(is); + Flasm3Lexer lexer = new Flasm3Lexer(new InputStreamReader(is, "UTF-8")); - ParsedSymbol symb; - AVM2Instruction lastIns = null; - do { - symb = lexer.yylex(); - if (symb.type == ParsedSymbol.TYPE_EXCEPTION_START) { - int exIndex = (Integer) symb.value; - int listIndex = exceptionIndices.indexOf(exIndex); - if (listIndex == -1) { - throw new ParseException("Undefinex exception index", lexer.yyline()); + ParsedSymbol symb; + AVM2Instruction lastIns = null; + do { + symb = lexer.yylex(); + if (symb.type == ParsedSymbol.TYPE_EXCEPTION_START) { + int exIndex = (Integer) symb.value; + int listIndex = exceptionIndices.indexOf(exIndex); + if (listIndex == -1) { + throw new ParseException("Undefinex exception index", lexer.yyline()); + } + exceptions.get(listIndex).start = offset; + continue; } - exceptions.get(listIndex).start = offset; - continue; - } - if (symb.type == ParsedSymbol.TYPE_EXCEPTION_END) { - int exIndex = (Integer) symb.value; - int listIndex = exceptionIndices.indexOf(exIndex); - if (listIndex == -1) { - throw new ParseException("Undefinex exception index", lexer.yyline()); + if (symb.type == ParsedSymbol.TYPE_EXCEPTION_END) { + int exIndex = (Integer) symb.value; + int listIndex = exceptionIndices.indexOf(exIndex); + if (listIndex == -1) { + throw new ParseException("Undefinex exception index", lexer.yyline()); + } + exceptions.get(listIndex).end = offset; + continue; } - exceptions.get(listIndex).end = offset; - continue; - } - if (symb.type == ParsedSymbol.TYPE_EXCEPTION_TARGET) { - int exIndex = (Integer) symb.value; - int listIndex = exceptionIndices.indexOf(exIndex); - if (listIndex == -1) { - throw new ParseException("Undefinex exception index", lexer.yyline()); + if (symb.type == ParsedSymbol.TYPE_EXCEPTION_TARGET) { + int exIndex = (Integer) symb.value; + int listIndex = exceptionIndices.indexOf(exIndex); + if (listIndex == -1) { + throw new ParseException("Undefinex exception index", lexer.yyline()); + } + exceptions.get(listIndex).target = offset; + continue; } - exceptions.get(listIndex).target = offset; - continue; - } - if (symb.type == ParsedSymbol.TYPE_EOF) { - break; - } - if (symb.type == ParsedSymbol.TYPE_COMMENT) { - if (lastIns != null) { - lastIns.comment = (String) symb.value; + if (symb.type == ParsedSymbol.TYPE_EOF) { + break; } - continue; - } - if (symb.type == ParsedSymbol.TYPE_INSTRUCTION_NAME) { - if (((String) symb.value).toLowerCase().equals("exception")) { - ParsedSymbol exIndex = lexer.yylex(); - if (exIndex.type != ParsedSymbol.TYPE_INTEGER) { - throw new ParseException("Index expected", lexer.yyline()); - } - ParsedSymbol exName = lexer.yylex(); - if (exName.type != ParsedSymbol.TYPE_MULTINAME) { - throw new ParseException("Multiname expected", lexer.yyline()); - } - ParsedSymbol exType = lexer.yylex(); - if (exType.type != ParsedSymbol.TYPE_MULTINAME) { - throw new ParseException("Multiname expected", lexer.yyline()); - } - ABCException ex = new ABCException(); - - ex.name_index = checkMultinameIndex(constants, (int) (long) (Long) exName.value, lexer.yyline()); - ex.type_index = checkMultinameIndex(constants, (int) (long) (Long) exType.value, lexer.yyline()); - exceptions.add(ex); - exceptionIndices.add((int) (long) (Long) exIndex.value); - continue; + if (symb.type == ParsedSymbol.TYPE_COMMENT) { + if (lastIns != null) { + lastIns.comment = (String) symb.value; + } + continue; } - boolean insFound = false; - for (InstructionDefinition def : AVM2Code.instructionSet) { - if (def.instructionName.equals((String) symb.value)) { - insFound = true; - List operandsList = new ArrayList(); + if (symb.type == ParsedSymbol.TYPE_INSTRUCTION_NAME) { + if (((String) symb.value).toLowerCase().equals("exception")) { + ParsedSymbol exIndex = lexer.yylex(); + if (exIndex.type != ParsedSymbol.TYPE_INTEGER) { + throw new ParseException("Index expected", lexer.yyline()); + } + ParsedSymbol exName = lexer.yylex(); + if (exName.type != ParsedSymbol.TYPE_MULTINAME) { + throw new ParseException("Multiname expected", lexer.yyline()); + } + ParsedSymbol exType = lexer.yylex(); + if (exType.type != ParsedSymbol.TYPE_MULTINAME) { + throw new ParseException("Multiname expected", lexer.yyline()); + } + ABCException ex = new ABCException(); - for (int i = 0; i < def.operands.length; i++) { - ParsedSymbol parsedOperand = lexer.yylex(); - switch (def.operands[i]) { - case AVM2Code.DAT_MULTINAME_INDEX: - if (parsedOperand.type == ParsedSymbol.TYPE_MULTINAME) { - operandsList.add(checkMultinameIndex(constants, (int) (long) (Long) parsedOperand.value, lexer.yyline())); - } else { - throw new ParseException("Multiname expected", lexer.yyline()); - } - break; - case AVM2Code.DAT_STRING_INDEX: - if (parsedOperand.type == ParsedSymbol.TYPE_STRING) { - int sid = constants.getStringId((String) parsedOperand.value); - if (sid == 0) { - if ((missingHandler != null) && (missingHandler.missingString((String) parsedOperand.value))) { - sid = constants.addString((String) parsedOperand.value); - } else { - throw new ParseException("Unknown String", lexer.yyline()); - } - } - operandsList.add(sid); - } else { - throw new ParseException("String expected", lexer.yyline()); - } - break; - case AVM2Code.DAT_INT_INDEX: + ex.name_index = checkMultinameIndex(constants, (int) (long) (Long) exName.value, lexer.yyline()); + ex.type_index = checkMultinameIndex(constants, (int) (long) (Long) exType.value, lexer.yyline()); + exceptions.add(ex); + exceptionIndices.add((int) (long) (Long) exIndex.value); + continue; + } + boolean insFound = false; + for (InstructionDefinition def : AVM2Code.instructionSet) { + if (def.instructionName.equals((String) symb.value)) { + insFound = true; + List operandsList = new ArrayList(); - if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { - long intVal = (Long) parsedOperand.value; - int iid = constants.getIntId(intVal); - if (iid == 0) { - if ((missingHandler != null) && (missingHandler.missingInt(intVal))) { - iid = constants.addInt(intVal); - } else { - throw new ParseException("Unknown int", lexer.yyline()); - } - } - operandsList.add(iid); - } else { - throw new ParseException("Integer expected", lexer.yyline()); - } - break; - case AVM2Code.DAT_UINT_INDEX: - if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { - long intVal = (Long) parsedOperand.value; - int iid = constants.getUIntId(intVal); - if (iid == 0) { - if ((missingHandler != null) && (missingHandler.missingUInt(intVal))) { - iid = constants.addUInt(intVal); - } else { - throw new ParseException("Unknown uint", lexer.yyline()); - } - } - operandsList.add(iid); - } else { - throw new ParseException("Integer expected", lexer.yyline()); - } - break; - case AVM2Code.DAT_DOUBLE_INDEX: - if ((parsedOperand.type == ParsedSymbol.TYPE_INTEGER) || (parsedOperand.type == ParsedSymbol.TYPE_FLOAT)) { + for (int i = 0; i < def.operands.length; i++) { + ParsedSymbol parsedOperand = lexer.yylex(); + switch (def.operands[i]) { + case AVM2Code.DAT_MULTINAME_INDEX: + if (parsedOperand.type == ParsedSymbol.TYPE_MULTINAME) { + operandsList.add(checkMultinameIndex(constants, (int) (long) (Long) parsedOperand.value, lexer.yyline())); + } else { + throw new ParseException("Multiname expected", lexer.yyline()); + } + break; + case AVM2Code.DAT_STRING_INDEX: + if (parsedOperand.type == ParsedSymbol.TYPE_STRING) { + int sid = constants.getStringId((String) parsedOperand.value); + if (sid == 0) { + if ((missingHandler != null) && (missingHandler.missingString((String) parsedOperand.value))) { + sid = constants.addString((String) parsedOperand.value); + } else { + throw new ParseException("Unknown String", lexer.yyline()); + } + } + operandsList.add(sid); + } else { + throw new ParseException("String expected", lexer.yyline()); + } + break; + case AVM2Code.DAT_INT_INDEX: - double doubleVal = 0; - if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { - doubleVal = (Long) parsedOperand.value; - } - if (parsedOperand.type == ParsedSymbol.TYPE_FLOAT) { - doubleVal = (Double) parsedOperand.value; - } - int did = constants.getDoubleId(doubleVal); - if (did == 0) { - if ((missingHandler != null) && (missingHandler.missingDouble(doubleVal))) { - did = constants.addDouble(doubleVal); - } else { - throw new ParseException("Unknown double", lexer.yyline()); - } - } - operandsList.add(did); - } else { - throw new ParseException("Float value expected", lexer.yyline()); - } - break; - case AVM2Code.DAT_OFFSET: - if (parsedOperand.type == ParsedSymbol.TYPE_IDENTIFIER) { - offsetItems.add(new OffsetItem((String) parsedOperand.value, code.code.size(), i)); - operandsList.add(0); - } else { - throw new ParseException("Offset expected", lexer.yyline()); - } - break; - case AVM2Code.DAT_CASE_BASEOFFSET: - if (parsedOperand.type == ParsedSymbol.TYPE_IDENTIFIER) { - offsetItems.add(new CaseOffsetItem((String) parsedOperand.value, code.code.size(), i)); - operandsList.add(0); - } else { - throw new ParseException("Offset expected", lexer.yyline()); - } - break; - case AVM2Code.OPT_CASE_OFFSETS: + if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { + long intVal = (Long) parsedOperand.value; + int iid = constants.getIntId(intVal); + if (iid == 0) { + if ((missingHandler != null) && (missingHandler.missingInt(intVal))) { + iid = constants.addInt(intVal); + } else { + throw new ParseException("Unknown int", lexer.yyline()); + } + } + operandsList.add(iid); + } else { + throw new ParseException("Integer expected", lexer.yyline()); + } + break; + case AVM2Code.DAT_UINT_INDEX: + if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { + long intVal = (Long) parsedOperand.value; + int iid = constants.getUIntId(intVal); + if (iid == 0) { + if ((missingHandler != null) && (missingHandler.missingUInt(intVal))) { + iid = constants.addUInt(intVal); + } else { + throw new ParseException("Unknown uint", lexer.yyline()); + } + } + operandsList.add(iid); + } else { + throw new ParseException("Integer expected", lexer.yyline()); + } + break; + case AVM2Code.DAT_DOUBLE_INDEX: + if ((parsedOperand.type == ParsedSymbol.TYPE_INTEGER) || (parsedOperand.type == ParsedSymbol.TYPE_FLOAT)) { - if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { - int patCount = (int) (long) (Long) parsedOperand.value; - operandsList.add(patCount); + double doubleVal = 0; + if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { + doubleVal = (Long) parsedOperand.value; + } + if (parsedOperand.type == ParsedSymbol.TYPE_FLOAT) { + doubleVal = (Double) parsedOperand.value; + } + int did = constants.getDoubleId(doubleVal); + if (did == 0) { + if ((missingHandler != null) && (missingHandler.missingDouble(doubleVal))) { + did = constants.addDouble(doubleVal); + } else { + throw new ParseException("Unknown double", lexer.yyline()); + } + } + operandsList.add(did); + } else { + throw new ParseException("Float value expected", lexer.yyline()); + } + break; + case AVM2Code.DAT_OFFSET: + if (parsedOperand.type == ParsedSymbol.TYPE_IDENTIFIER) { + offsetItems.add(new OffsetItem((String) parsedOperand.value, code.code.size(), i)); + operandsList.add(0); + } else { + throw new ParseException("Offset expected", lexer.yyline()); + } + break; + case AVM2Code.DAT_CASE_BASEOFFSET: + if (parsedOperand.type == ParsedSymbol.TYPE_IDENTIFIER) { + offsetItems.add(new CaseOffsetItem((String) parsedOperand.value, code.code.size(), i)); + operandsList.add(0); + } else { + throw new ParseException("Offset expected", lexer.yyline()); + } + break; + case AVM2Code.OPT_CASE_OFFSETS: - for (int c = 0; c <= patCount; c++) { - parsedOperand = lexer.yylex(); - if (parsedOperand.type == ParsedSymbol.TYPE_IDENTIFIER) { - offsetItems.add(new CaseOffsetItem((String) parsedOperand.value, code.code.size(), i + (c + 1))); - operandsList.add(0); - } else { - throw new ParseException("Offset expected", lexer.yyline()); - } - } - } else { - throw new ParseException("Case count expected", lexer.yyline()); - } - break; - default: - if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { - operandsList.add((int) (long) (Long) parsedOperand.value); - } else { - throw new ParseException("Integer expected", lexer.yyline()); - } - } - } + if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { + int patCount = (int) (long) (Long) parsedOperand.value; + operandsList.add(patCount); - int operands[] = new int[operandsList.size()]; - for (int i = 0; i < operandsList.size(); i++) { - operands[i] = operandsList.get(i); - } - lastIns = new AVM2Instruction(offset, def, operands, new byte[0]); - code.code.add(lastIns); - offset += lastIns.getBytes().length; - break; - } + for (int c = 0; c <= patCount; c++) { + parsedOperand = lexer.yylex(); + if (parsedOperand.type == ParsedSymbol.TYPE_IDENTIFIER) { + offsetItems.add(new CaseOffsetItem((String) parsedOperand.value, code.code.size(), i + (c + 1))); + operandsList.add(0); + } else { + throw new ParseException("Offset expected", lexer.yyline()); + } + } + } else { + throw new ParseException("Case count expected", lexer.yyline()); + } + break; + default: + if (parsedOperand.type == ParsedSymbol.TYPE_INTEGER) { + operandsList.add((int) (long) (Long) parsedOperand.value); + } else { + throw new ParseException("Integer expected", lexer.yyline()); + } + } + } + + int operands[] = new int[operandsList.size()]; + for (int i = 0; i < operandsList.size(); i++) { + operands[i] = operandsList.get(i); + } + lastIns = new AVM2Instruction(offset, def, operands, new byte[0]); + code.code.add(lastIns); + offset += lastIns.getBytes().length; + break; + } + } + if (!insFound) { + throw new ParseException("Invalid instruction name:" + (String) symb.value, lexer.yyline()); + } + } else if (symb.type == ParsedSymbol.TYPE_LABEL) { + labelItems.add(new LabelItem((String) symb.value, offset)); + + } else { + throw new ParseException("Unexpected symbol", lexer.yyline()); } - if (!insFound) { - throw new ParseException("Invalid instruction name:" + (String) symb.value, lexer.yyline()); + } while (symb.type != ParsedSymbol.TYPE_EOF); + + code.compact(); + + for (OffsetItem oi : offsetItems) { + for (LabelItem li : labelItems) { + if (oi.label.equals(li.label)) { + AVM2Instruction ins = code.code.get((int) oi.insPosition); + int relOffset; + if (oi instanceof CaseOffsetItem) { + relOffset = li.offset - (int) ins.offset; + } else { + relOffset = li.offset - ((int) ins.offset + ins.getBytes().length); + } + ins.operands[oi.insOperandIndex] = relOffset; + } } - } else if (symb.type == ParsedSymbol.TYPE_LABEL) { - labelItems.add(new LabelItem((String) symb.value, offset)); - - } else { - throw new ParseException("Unexpected symbol", lexer.yyline()); - } - } while (symb.type != ParsedSymbol.TYPE_EOF); - - code.compact(); - - for (OffsetItem oi : offsetItems) { - for (LabelItem li : labelItems) { - if (oi.label.equals(li.label)) { - AVM2Instruction ins = code.code.get((int) oi.insPosition); - int relOffset; - if (oi instanceof CaseOffsetItem) { - relOffset = li.offset - (int) ins.offset; - } else { - relOffset = li.offset - ((int) ins.offset + ins.getBytes().length); - } - ins.operands[oi.insOperandIndex] = relOffset; - } - } - } - body.exceptions = new ABCException[exceptions.size()]; - for (int e = 0; e < exceptions.size(); e++) { - body.exceptions[e] = exceptions.get(e); - } - return code; - } + } + body.exceptions = new ABCException[exceptions.size()]; + for (int e = 0; e < exceptions.size(); e++) { + body.exceptions[e] = exceptions.get(e); + } + return code; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/Flasm3Lexer.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/Flasm3Lexer.java index bf640e3c4..9229c9bac 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/Flasm3Lexer.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/Flasm3Lexer.java @@ -23,952 +23,952 @@ package com.jpexs.decompiler.flash.abc.avm2.parser; */ public final class Flasm3Lexer { - /** - * This character denotes the end of file - */ - public static final int YYEOF = -1; - /** - * initial size of the lookahead buffer - */ - private static final int ZZ_BUFFERSIZE = 16384; - /** - * lexical states - */ - public static final int STRING = 2; - public static final int YYINITIAL = 0; - public static final int PARAMETERS = 4; - /** - * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l - * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l at the - * beginning of a line l is of the form l = 2*k, k a non negative integer - */ - private static final int ZZ_LEXSTATE[] = { - 0, 0, 1, 1, 2, 2 - }; - /** - * Translates characters to character classes - */ - private static final String ZZ_CMAP_PACKED = - "\11\12\1\4\1\2\1\0\1\4\1\1\16\12\4\0\1\40\1\0" - + "\1\43\1\0\1\11\2\0\1\46\3\0\1\23\1\0\1\17\1\20" - + "\1\0\1\16\3\47\4\24\2\7\1\15\1\3\5\0\4\11\1\21" - + "\25\11\1\6\1\25\1\10\1\0\1\14\1\0\1\36\1\44\1\27" - + "\1\41\1\22\1\45\1\42\1\13\1\32\3\13\1\5\1\34\1\33" - + "\1\30\1\13\1\37\1\35\1\31\3\13\1\26\2\13\4\0\41\12" - + "\2\0\4\11\4\0\1\11\2\0\1\12\7\0\1\11\4\0\1\11" - + "\5\0\27\11\1\0\37\11\1\0\u013f\11\31\0\162\11\4\0\14\11" - + "\16\0\5\11\11\0\1\11\21\0\130\12\5\0\23\12\12\0\1\11" - + "\13\0\1\11\1\0\3\11\1\0\1\11\1\0\24\11\1\0\54\11" - + "\1\0\46\11\1\0\5\11\4\0\202\11\1\0\4\12\3\0\105\11" - + "\1\0\46\11\2\0\2\11\6\0\20\11\41\0\46\11\2\0\1\11" - + "\7\0\47\11\11\0\21\12\1\0\27\12\1\0\3\12\1\0\1\12" - + "\1\0\2\12\1\0\1\12\13\0\33\11\5\0\3\11\15\0\4\12" - + "\14\0\6\12\13\0\32\11\5\0\13\11\16\12\7\0\12\12\4\0" - + "\2\11\1\12\143\11\1\0\1\11\10\12\1\0\6\12\2\11\2\12" - + "\1\0\4\12\2\11\12\12\3\11\2\0\1\11\17\0\1\12\1\11" - + "\1\12\36\11\33\12\2\0\3\11\60\0\46\11\13\12\1\11\u014f\0" - + "\3\12\66\11\2\0\1\12\1\11\20\12\2\0\1\11\4\12\3\0" - + "\12\11\2\12\2\0\12\12\21\0\3\12\1\0\10\11\2\0\2\11" - + "\2\0\26\11\1\0\7\11\1\0\1\11\3\0\4\11\2\0\1\12" - + "\1\11\7\12\2\0\2\12\2\0\3\12\11\0\1\12\4\0\2\11" - + "\1\0\3\11\2\12\2\0\12\12\4\11\15\0\3\12\1\0\6\11" - + "\4\0\2\11\2\0\26\11\1\0\7\11\1\0\2\11\1\0\2\11" - + "\1\0\2\11\2\0\1\12\1\0\5\12\4\0\2\12\2\0\3\12" - + "\13\0\4\11\1\0\1\11\7\0\14\12\3\11\14\0\3\12\1\0" - + "\11\11\1\0\3\11\1\0\26\11\1\0\7\11\1\0\2\11\1\0" - + "\5\11\2\0\1\12\1\11\10\12\1\0\3\12\1\0\3\12\2\0" - + "\1\11\17\0\2\11\2\12\2\0\12\12\1\0\1\11\17\0\3\12" - + "\1\0\10\11\2\0\2\11\2\0\26\11\1\0\7\11\1\0\2\11" - + "\1\0\5\11\2\0\1\12\1\11\6\12\3\0\2\12\2\0\3\12" - + "\10\0\2\12\4\0\2\11\1\0\3\11\4\0\12\12\1\0\1\11" - + "\20\0\1\12\1\11\1\0\6\11\3\0\3\11\1\0\4\11\3\0" - + "\2\11\1\0\1\11\1\0\2\11\3\0\2\11\3\0\3\11\3\0" - + "\10\11\1\0\3\11\4\0\5\12\3\0\3\12\1\0\4\12\11\0" - + "\1\12\17\0\11\12\11\0\1\11\7\0\3\12\1\0\10\11\1\0" - + "\3\11\1\0\27\11\1\0\12\11\1\0\5\11\4\0\7\12\1\0" - + "\3\12\1\0\4\12\7\0\2\12\11\0\2\11\4\0\12\12\22\0" - + "\2\12\1\0\10\11\1\0\3\11\1\0\27\11\1\0\12\11\1\0" - + "\5\11\2\0\1\12\1\11\7\12\1\0\3\12\1\0\4\12\7\0" - + "\2\12\7\0\1\11\1\0\2\11\4\0\12\12\22\0\2\12\1\0" - + "\10\11\1\0\3\11\1\0\27\11\1\0\20\11\4\0\6\12\2\0" - + "\3\12\1\0\4\12\11\0\1\12\10\0\2\11\4\0\12\12\22\0" - + "\2\12\1\0\22\11\3\0\30\11\1\0\11\11\1\0\1\11\2\0" - + "\7\11\3\0\1\12\4\0\6\12\1\0\1\12\1\0\10\12\22\0" - + "\2\12\15\0\60\11\1\12\2\11\7\12\4\0\10\11\10\12\1\0" - + "\12\12\47\0\2\11\1\0\1\11\2\0\2\11\1\0\1\11\2\0" - + "\1\11\6\0\4\11\1\0\7\11\1\0\3\11\1\0\1\11\1\0" - + "\1\11\2\0\2\11\1\0\4\11\1\12\2\11\6\12\1\0\2\12" - + "\1\11\2\0\5\11\1\0\1\11\1\0\6\12\2\0\12\12\2\0" - + "\2\11\42\0\1\11\27\0\2\12\6\0\12\12\13\0\1\12\1\0" - + "\1\12\1\0\1\12\4\0\2\12\10\11\1\0\42\11\6\0\24\12" - + "\1\0\2\12\4\11\4\0\10\12\1\0\44\12\11\0\1\12\71\0" - + "\42\11\1\0\5\11\1\0\2\11\1\0\7\12\3\0\4\12\6\0" - + "\12\12\6\0\6\11\4\12\106\0\46\11\12\0\51\11\7\0\132\11" - + "\5\0\104\11\5\0\122\11\6\0\7\11\1\0\77\11\1\0\1\11" - + "\1\0\4\11\2\0\7\11\1\0\1\11\1\0\4\11\2\0\47\11" - + "\1\0\1\11\1\0\4\11\2\0\37\11\1\0\1\11\1\0\4\11" - + "\2\0\7\11\1\0\1\11\1\0\4\11\2\0\7\11\1\0\7\11" - + "\1\0\27\11\1\0\37\11\1\0\1\11\1\0\4\11\2\0\7\11" - + "\1\0\47\11\1\0\23\11\16\0\11\12\56\0\125\11\14\0\u026c\11" - + "\2\0\10\11\12\0\32\11\5\0\113\11\3\0\3\11\17\0\15\11" - + "\1\0\4\11\3\12\13\0\22\11\3\12\13\0\22\11\2\12\14\0" - + "\15\11\1\0\3\11\1\0\2\12\14\0\64\11\40\12\3\0\1\11" - + "\3\0\2\11\1\12\2\0\12\12\41\0\3\12\2\0\12\12\6\0" - + "\130\11\10\0\51\11\1\12\126\0\35\11\3\0\14\12\4\0\14\12" - + "\12\0\12\12\36\11\2\0\5\11\u038b\0\154\11\224\0\234\11\4\0" - + "\132\11\6\0\26\11\2\0\6\11\2\0\46\11\2\0\6\11\2\0" - + "\10\11\1\0\1\11\1\0\1\11\1\0\1\11\1\0\37\11\2\0" - + "\65\11\1\0\7\11\1\0\1\11\3\0\3\11\1\0\7\11\3\0" - + "\4\11\2\0\6\11\4\0\15\11\5\0\3\11\1\0\7\11\17\0" - + "\4\12\32\0\5\12\20\0\2\11\23\0\1\11\13\0\4\12\6\0" - + "\6\12\1\0\1\11\15\0\1\11\40\0\22\11\36\0\15\12\4\0" - + "\1\12\3\0\6\12\27\0\1\11\4\0\1\11\2\0\12\11\1\0" - + "\1\11\3\0\5\11\6\0\1\11\1\0\1\11\1\0\1\11\1\0" - + "\4\11\1\0\3\11\1\0\7\11\3\0\3\11\5\0\5\11\26\0" - + "\44\11\u0e81\0\3\11\31\0\11\11\6\12\1\0\5\11\2\0\5\11" - + "\4\0\126\11\2\0\2\12\2\0\3\11\1\0\137\11\5\0\50\11" - + "\4\0\136\11\21\0\30\11\70\0\20\11\u0200\0\u19b6\11\112\0\u51a6\11" - + "\132\0\u048d\11\u0773\0\u2ba4\11\u215c\0\u012e\11\2\0\73\11\225\0\7\11" - + "\14\0\5\11\5\0\1\11\1\12\12\11\1\0\15\11\1\0\5\11" - + "\1\0\1\11\1\0\2\11\1\0\2\11\1\0\154\11\41\0\u016b\11" - + "\22\0\100\11\2\0\66\11\50\0\15\11\3\0\20\12\20\0\4\12" - + "\17\0\2\11\30\0\3\11\31\0\1\11\6\0\5\11\1\0\207\11" - + "\2\0\1\12\4\0\1\11\13\0\12\12\7\0\32\11\4\0\1\11" - + "\1\0\32\11\12\0\132\11\3\0\6\11\2\0\6\11\2\0\6\11" - + "\2\0\3\11\3\0\2\11\3\0\2\11\22\0\3\12\4\0"; - /** - * Translates characters to character classes - */ - private static final char[] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); - /** - * Translates DFA states to action switch labels. - */ - private static final int[] ZZ_ACTION = zzUnpackAction(); - private static final String ZZ_ACTION_PACKED_0 = - "\3\0\2\1\1\2\1\1\1\2\1\3\2\4\1\1" - + "\1\5\2\6\1\7\1\10\1\11\1\10\1\11\2\1" - + "\1\12\1\0\1\13\1\2\1\14\2\15\1\16\1\17" - + "\1\20\1\21\1\22\1\23\1\24\1\25\1\0\1\26" - + "\1\0\1\26\1\0\1\2\1\15\1\0\1\26\1\0" - + "\1\2\1\0\1\2\1\27\15\2\1\0\2\2\2\0" - + "\2\2\1\30\1\2\6\0\1\31\1\32"; + /** + * This character denotes the end of file + */ + public static final int YYEOF = -1; + /** + * initial size of the lookahead buffer + */ + private static final int ZZ_BUFFERSIZE = 16384; + /** + * lexical states + */ + public static final int STRING = 2; + public static final int YYINITIAL = 0; + public static final int PARAMETERS = 4; + /** + * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l + * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l at the + * beginning of a line l is of the form l = 2*k, k a non negative integer + */ + private static final int ZZ_LEXSTATE[] = { + 0, 0, 1, 1, 2, 2 + }; + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\12\1\4\1\2\1\0\1\4\1\1\16\12\4\0\1\40\1\0" + + "\1\43\1\0\1\11\2\0\1\46\3\0\1\23\1\0\1\17\1\20" + + "\1\0\1\16\3\47\4\24\2\7\1\15\1\3\5\0\4\11\1\21" + + "\25\11\1\6\1\25\1\10\1\0\1\14\1\0\1\36\1\44\1\27" + + "\1\41\1\22\1\45\1\42\1\13\1\32\3\13\1\5\1\34\1\33" + + "\1\30\1\13\1\37\1\35\1\31\3\13\1\26\2\13\4\0\41\12" + + "\2\0\4\11\4\0\1\11\2\0\1\12\7\0\1\11\4\0\1\11" + + "\5\0\27\11\1\0\37\11\1\0\u013f\11\31\0\162\11\4\0\14\11" + + "\16\0\5\11\11\0\1\11\21\0\130\12\5\0\23\12\12\0\1\11" + + "\13\0\1\11\1\0\3\11\1\0\1\11\1\0\24\11\1\0\54\11" + + "\1\0\46\11\1\0\5\11\4\0\202\11\1\0\4\12\3\0\105\11" + + "\1\0\46\11\2\0\2\11\6\0\20\11\41\0\46\11\2\0\1\11" + + "\7\0\47\11\11\0\21\12\1\0\27\12\1\0\3\12\1\0\1\12" + + "\1\0\2\12\1\0\1\12\13\0\33\11\5\0\3\11\15\0\4\12" + + "\14\0\6\12\13\0\32\11\5\0\13\11\16\12\7\0\12\12\4\0" + + "\2\11\1\12\143\11\1\0\1\11\10\12\1\0\6\12\2\11\2\12" + + "\1\0\4\12\2\11\12\12\3\11\2\0\1\11\17\0\1\12\1\11" + + "\1\12\36\11\33\12\2\0\3\11\60\0\46\11\13\12\1\11\u014f\0" + + "\3\12\66\11\2\0\1\12\1\11\20\12\2\0\1\11\4\12\3\0" + + "\12\11\2\12\2\0\12\12\21\0\3\12\1\0\10\11\2\0\2\11" + + "\2\0\26\11\1\0\7\11\1\0\1\11\3\0\4\11\2\0\1\12" + + "\1\11\7\12\2\0\2\12\2\0\3\12\11\0\1\12\4\0\2\11" + + "\1\0\3\11\2\12\2\0\12\12\4\11\15\0\3\12\1\0\6\11" + + "\4\0\2\11\2\0\26\11\1\0\7\11\1\0\2\11\1\0\2\11" + + "\1\0\2\11\2\0\1\12\1\0\5\12\4\0\2\12\2\0\3\12" + + "\13\0\4\11\1\0\1\11\7\0\14\12\3\11\14\0\3\12\1\0" + + "\11\11\1\0\3\11\1\0\26\11\1\0\7\11\1\0\2\11\1\0" + + "\5\11\2\0\1\12\1\11\10\12\1\0\3\12\1\0\3\12\2\0" + + "\1\11\17\0\2\11\2\12\2\0\12\12\1\0\1\11\17\0\3\12" + + "\1\0\10\11\2\0\2\11\2\0\26\11\1\0\7\11\1\0\2\11" + + "\1\0\5\11\2\0\1\12\1\11\6\12\3\0\2\12\2\0\3\12" + + "\10\0\2\12\4\0\2\11\1\0\3\11\4\0\12\12\1\0\1\11" + + "\20\0\1\12\1\11\1\0\6\11\3\0\3\11\1\0\4\11\3\0" + + "\2\11\1\0\1\11\1\0\2\11\3\0\2\11\3\0\3\11\3\0" + + "\10\11\1\0\3\11\4\0\5\12\3\0\3\12\1\0\4\12\11\0" + + "\1\12\17\0\11\12\11\0\1\11\7\0\3\12\1\0\10\11\1\0" + + "\3\11\1\0\27\11\1\0\12\11\1\0\5\11\4\0\7\12\1\0" + + "\3\12\1\0\4\12\7\0\2\12\11\0\2\11\4\0\12\12\22\0" + + "\2\12\1\0\10\11\1\0\3\11\1\0\27\11\1\0\12\11\1\0" + + "\5\11\2\0\1\12\1\11\7\12\1\0\3\12\1\0\4\12\7\0" + + "\2\12\7\0\1\11\1\0\2\11\4\0\12\12\22\0\2\12\1\0" + + "\10\11\1\0\3\11\1\0\27\11\1\0\20\11\4\0\6\12\2\0" + + "\3\12\1\0\4\12\11\0\1\12\10\0\2\11\4\0\12\12\22\0" + + "\2\12\1\0\22\11\3\0\30\11\1\0\11\11\1\0\1\11\2\0" + + "\7\11\3\0\1\12\4\0\6\12\1\0\1\12\1\0\10\12\22\0" + + "\2\12\15\0\60\11\1\12\2\11\7\12\4\0\10\11\10\12\1\0" + + "\12\12\47\0\2\11\1\0\1\11\2\0\2\11\1\0\1\11\2\0" + + "\1\11\6\0\4\11\1\0\7\11\1\0\3\11\1\0\1\11\1\0" + + "\1\11\2\0\2\11\1\0\4\11\1\12\2\11\6\12\1\0\2\12" + + "\1\11\2\0\5\11\1\0\1\11\1\0\6\12\2\0\12\12\2\0" + + "\2\11\42\0\1\11\27\0\2\12\6\0\12\12\13\0\1\12\1\0" + + "\1\12\1\0\1\12\4\0\2\12\10\11\1\0\42\11\6\0\24\12" + + "\1\0\2\12\4\11\4\0\10\12\1\0\44\12\11\0\1\12\71\0" + + "\42\11\1\0\5\11\1\0\2\11\1\0\7\12\3\0\4\12\6\0" + + "\12\12\6\0\6\11\4\12\106\0\46\11\12\0\51\11\7\0\132\11" + + "\5\0\104\11\5\0\122\11\6\0\7\11\1\0\77\11\1\0\1\11" + + "\1\0\4\11\2\0\7\11\1\0\1\11\1\0\4\11\2\0\47\11" + + "\1\0\1\11\1\0\4\11\2\0\37\11\1\0\1\11\1\0\4\11" + + "\2\0\7\11\1\0\1\11\1\0\4\11\2\0\7\11\1\0\7\11" + + "\1\0\27\11\1\0\37\11\1\0\1\11\1\0\4\11\2\0\7\11" + + "\1\0\47\11\1\0\23\11\16\0\11\12\56\0\125\11\14\0\u026c\11" + + "\2\0\10\11\12\0\32\11\5\0\113\11\3\0\3\11\17\0\15\11" + + "\1\0\4\11\3\12\13\0\22\11\3\12\13\0\22\11\2\12\14\0" + + "\15\11\1\0\3\11\1\0\2\12\14\0\64\11\40\12\3\0\1\11" + + "\3\0\2\11\1\12\2\0\12\12\41\0\3\12\2\0\12\12\6\0" + + "\130\11\10\0\51\11\1\12\126\0\35\11\3\0\14\12\4\0\14\12" + + "\12\0\12\12\36\11\2\0\5\11\u038b\0\154\11\224\0\234\11\4\0" + + "\132\11\6\0\26\11\2\0\6\11\2\0\46\11\2\0\6\11\2\0" + + "\10\11\1\0\1\11\1\0\1\11\1\0\1\11\1\0\37\11\2\0" + + "\65\11\1\0\7\11\1\0\1\11\3\0\3\11\1\0\7\11\3\0" + + "\4\11\2\0\6\11\4\0\15\11\5\0\3\11\1\0\7\11\17\0" + + "\4\12\32\0\5\12\20\0\2\11\23\0\1\11\13\0\4\12\6\0" + + "\6\12\1\0\1\11\15\0\1\11\40\0\22\11\36\0\15\12\4\0" + + "\1\12\3\0\6\12\27\0\1\11\4\0\1\11\2\0\12\11\1\0" + + "\1\11\3\0\5\11\6\0\1\11\1\0\1\11\1\0\1\11\1\0" + + "\4\11\1\0\3\11\1\0\7\11\3\0\3\11\5\0\5\11\26\0" + + "\44\11\u0e81\0\3\11\31\0\11\11\6\12\1\0\5\11\2\0\5\11" + + "\4\0\126\11\2\0\2\12\2\0\3\11\1\0\137\11\5\0\50\11" + + "\4\0\136\11\21\0\30\11\70\0\20\11\u0200\0\u19b6\11\112\0\u51a6\11" + + "\132\0\u048d\11\u0773\0\u2ba4\11\u215c\0\u012e\11\2\0\73\11\225\0\7\11" + + "\14\0\5\11\5\0\1\11\1\12\12\11\1\0\15\11\1\0\5\11" + + "\1\0\1\11\1\0\2\11\1\0\2\11\1\0\154\11\41\0\u016b\11" + + "\22\0\100\11\2\0\66\11\50\0\15\11\3\0\20\12\20\0\4\12" + + "\17\0\2\11\30\0\3\11\31\0\1\11\6\0\5\11\1\0\207\11" + + "\2\0\1\12\4\0\1\11\13\0\12\12\7\0\32\11\4\0\1\11" + + "\1\0\32\11\12\0\132\11\3\0\6\11\2\0\6\11\2\0\6\11" + + "\2\0\3\11\3\0\2\11\3\0\2\11\22\0\3\12\4\0"; + /** + * Translates characters to character classes + */ + private static final char[] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + /** + * Translates DFA states to action switch labels. + */ + private static final int[] ZZ_ACTION = zzUnpackAction(); + private static final String ZZ_ACTION_PACKED_0 = + "\3\0\2\1\1\2\1\1\1\2\1\3\2\4\1\1" + + "\1\5\2\6\1\7\1\10\1\11\1\10\1\11\2\1" + + "\1\12\1\0\1\13\1\2\1\14\2\15\1\16\1\17" + + "\1\20\1\21\1\22\1\23\1\24\1\25\1\0\1\26" + + "\1\0\1\26\1\0\1\2\1\15\1\0\1\26\1\0" + + "\1\2\1\0\1\2\1\27\15\2\1\0\2\2\2\0" + + "\2\2\1\30\1\2\6\0\1\31\1\32"; - private static int[] zzUnpackAction() { - int[] result = new int[81]; - int offset = 0; - offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); - return result; - } + private static int[] zzUnpackAction() { + int[] result = new int[81]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } - private static int zzUnpackAction(String packed, int offset, int[] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - do { - result[j++] = value; - } while (--count > 0); - } - return j; - } - /** - * Translates a state to a row index in the transition table - */ - private static final int[] ZZ_ROWMAP = zzUnpackRowMap(); - private static final String ZZ_ROWMAP_PACKED_0 = - "\0\0\0\50\0\120\0\170\0\240\0\310\0\360\0\u0118" - + "\0\u0140\0\u0168\0\170\0\u0190\0\170\0\u01b8\0\170\0\u01e0" - + "\0\u0208\0\u0230\0\u0258\0\u0280\0\u02a8\0\u02d0\0\170\0\360" - + "\0\170\0\u02f8\0\170\0\u0320\0\u0348\0\170\0\170\0\170" - + "\0\170\0\170\0\170\0\170\0\170\0\u0370\0\u0398\0\u03c0" - + "\0\u0280\0\u02d0\0\u03e8\0\170\0\u0410\0\u0438\0\u0438\0\u0460" - + "\0\u0488\0\u04b0\0\170\0\u04d8\0\u0500\0\u0528\0\u0550\0\u0578" - + "\0\u05a0\0\u05c8\0\u05f0\0\u0618\0\u0640\0\u0668\0\u0690\0\u06b8" - + "\0\u06e0\0\u0708\0\u0730\0\u0758\0\u0780\0\u07a8\0\u07d0\0\170" - + "\0\u07f8\0\u0820\0\u0848\0\u0870\0\u0898\0\u08c0\0\u08e8\0\170" - + "\0\170"; + private static int zzUnpackAction(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do { + result[j++] = value; + } while (--count > 0); + } + return j; + } + /** + * Translates a state to a row index in the transition table + */ + private static final int[] ZZ_ROWMAP = zzUnpackRowMap(); + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\50\0\120\0\170\0\240\0\310\0\360\0\u0118" + + "\0\u0140\0\u0168\0\170\0\u0190\0\170\0\u01b8\0\170\0\u01e0" + + "\0\u0208\0\u0230\0\u0258\0\u0280\0\u02a8\0\u02d0\0\170\0\360" + + "\0\170\0\u02f8\0\170\0\u0320\0\u0348\0\170\0\170\0\170" + + "\0\170\0\170\0\170\0\170\0\170\0\u0370\0\u0398\0\u03c0" + + "\0\u0280\0\u02d0\0\u03e8\0\170\0\u0410\0\u0438\0\u0438\0\u0460" + + "\0\u0488\0\u04b0\0\170\0\u04d8\0\u0500\0\u0528\0\u0550\0\u0578" + + "\0\u05a0\0\u05c8\0\u05f0\0\u0618\0\u0640\0\u0668\0\u0690\0\u06b8" + + "\0\u06e0\0\u0708\0\u0730\0\u0758\0\u0780\0\u07a8\0\u07d0\0\170" + + "\0\u07f8\0\u0820\0\u0848\0\u0870\0\u0898\0\u08c0\0\u08e8\0\170" + + "\0\170"; - private static int[] zzUnpackRowMap() { - int[] result = new int[81]; - int offset = 0; - offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); - return result; - } + private static int[] zzUnpackRowMap() { + int[] result = new int[81]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } - private static int zzUnpackRowMap(String packed, int offset, int[] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int high = packed.charAt(i++) << 16; - result[j++] = high | packed.charAt(i++); - } - return j; - } - /** - * The transition table of the DFA - */ - private static final int[] ZZ_TRANS = zzUnpackTrans(); - private static final String ZZ_TRANS_PACKED_0 = - "\4\4\1\5\1\6\3\4\1\7\1\4\1\6\1\7" - + "\4\4\1\7\1\10\3\4\12\6\1\5\2\6\1\4" - + "\2\6\2\4\1\11\1\12\1\13\22\11\1\14\15\11" - + "\1\15\4\11\1\4\1\16\1\17\1\20\1\4\1\21" - + "\1\4\1\22\1\4\1\23\1\4\2\23\1\4\1\24" - + "\1\25\1\26\2\23\1\4\1\22\1\4\12\23\1\4" - + "\2\23\1\27\2\23\1\4\1\22\54\0\1\5\33\0" - + "\1\5\14\0\1\6\1\0\1\6\1\0\2\30\2\6" - + "\1\31\1\6\2\0\1\30\1\6\1\0\1\6\1\0" - + "\12\6\1\0\2\6\1\0\2\6\1\0\1\6\5\0" - + "\1\30\1\0\1\30\1\0\4\30\1\31\1\30\2\0" - + "\2\30\1\0\1\30\1\0\12\30\1\0\2\30\1\0" - + "\2\30\1\0\1\30\5\0\1\6\1\0\1\6\1\0" - + "\2\30\2\6\1\31\1\6\2\0\1\30\1\6\1\0" - + "\1\6\1\0\1\32\11\6\1\0\2\6\1\0\2\6" - + "\1\0\1\6\1\11\2\0\22\11\1\0\15\11\1\0" - + "\4\11\2\0\1\13\45\0\2\33\1\0\13\33\1\34" - + "\5\33\1\35\1\36\3\33\1\37\2\33\1\40\2\33" - + "\1\41\3\33\1\42\1\43\1\44\1\45\1\34\2\0" - + "\1\17\45\0\1\20\2\0\45\20\5\0\1\23\1\46" - + "\1\23\1\0\4\23\1\0\1\23\2\0\2\23\1\0" - + "\1\23\1\0\12\23\1\0\2\23\1\0\2\23\1\0" - + "\1\23\7\0\1\22\6\0\1\22\1\0\1\47\2\50" - + "\1\0\1\22\22\0\1\22\5\0\1\23\1\0\1\23" - + "\1\0\4\23\1\0\1\23\2\0\2\23\1\0\1\23" - + "\1\0\12\23\1\0\2\23\1\0\2\23\1\0\1\23" - + "\7\0\1\51\6\0\1\51\1\0\1\47\2\50\1\0" - + "\1\51\22\0\1\51\7\0\1\22\6\0\1\51\1\0" - + "\1\52\3\0\1\22\22\0\1\22\7\0\1\47\6\0" - + "\1\47\5\0\1\47\22\0\1\47\5\0\1\6\1\0" - + "\1\6\1\0\2\30\2\6\1\31\1\6\2\0\1\30" - + "\1\6\1\0\1\6\1\0\1\6\1\53\10\6\1\0" - + "\2\6\1\0\2\6\1\0\1\6\16\0\1\35\5\0" - + "\1\35\22\0\1\35\16\0\1\54\5\0\1\54\22\0" - + "\1\54\7\0\1\55\6\0\1\55\5\0\1\55\22\0" - + "\1\55\7\0\1\47\6\0\1\47\2\0\2\50\1\0" - + "\1\47\22\0\1\47\7\0\1\56\6\0\1\56\1\57" - + "\3\0\1\57\1\56\22\0\1\56\5\0\1\6\1\0" - + "\1\6\1\0\2\30\2\6\1\31\1\6\2\0\1\30" - + "\1\60\1\0\1\6\1\0\12\6\1\0\2\6\1\0" - + "\2\6\1\0\1\6\7\0\1\55\1\61\5\0\1\55" - + "\5\0\1\55\22\0\1\55\7\0\1\56\6\0\1\56" - + "\5\0\1\56\22\0\1\56\5\0\1\6\1\0\1\6" - + "\1\0\2\30\2\6\1\31\1\6\2\0\1\30\1\6" - + "\1\0\1\6\1\0\2\6\1\62\7\6\1\0\2\6" - + "\1\0\2\6\1\0\1\6\43\0\1\63\11\0\1\6" - + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" - + "\1\30\1\6\1\0\1\6\1\0\3\6\1\64\6\6" - + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" - + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" - + "\1\30\1\6\1\0\1\6\1\0\4\6\1\65\5\6" - + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" - + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" - + "\1\30\1\6\1\0\1\6\1\0\5\6\1\66\4\6" - + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" - + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" - + "\1\30\1\6\1\0\1\6\1\0\6\6\1\67\3\6" - + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" - + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" - + "\1\30\1\70\1\0\1\6\1\0\3\6\1\71\3\6" - + "\1\72\2\6\1\0\2\6\1\0\2\6\1\0\1\6" - + "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31" - + "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\6\6" - + "\1\73\3\6\1\0\2\6\1\0\2\6\1\0\1\6" - + "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31" - + "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\10\6" - + "\1\74\1\6\1\0\2\6\1\0\2\6\1\0\1\6" - + "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31" - + "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\3\6" - + "\1\75\6\6\1\0\2\6\1\0\2\6\1\0\1\6" - + "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31" - + "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\12\6" - + "\1\0\1\76\1\6\1\0\2\6\1\0\1\6\5\0" - + "\1\6\1\0\1\6\1\0\2\30\2\6\1\31\1\6" - + "\2\0\1\30\1\6\1\0\1\6\1\0\11\6\1\77" - + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" - + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" - + "\1\30\1\6\1\0\1\6\1\0\10\6\1\100\1\6" - + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" - + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" - + "\1\30\1\6\1\0\1\6\1\0\12\6\1\101\2\6" - + "\1\0\2\6\1\0\1\6\5\0\1\6\1\0\1\6" - + "\1\0\2\30\2\6\1\31\1\6\2\0\1\30\1\6" - + "\1\0\1\6\1\0\12\6\1\0\1\6\1\102\1\0" - + "\2\6\1\0\1\6\5\0\1\6\1\0\1\6\1\0" - + "\2\30\2\6\1\31\1\6\2\0\1\30\1\6\1\0" - + "\1\6\1\0\11\6\1\103\1\0\2\6\1\0\2\6" - + "\1\0\1\6\7\0\1\104\6\0\1\105\5\0\1\104" - + "\22\0\1\104\5\0\1\6\1\0\1\6\1\0\2\30" - + "\2\6\1\31\1\6\2\0\1\30\1\106\1\0\1\6" - + "\1\0\12\6\1\0\2\6\1\0\2\6\1\0\1\6" - + "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31" - + "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\3\6" - + "\1\107\6\6\1\0\2\6\1\0\2\6\1\0\1\6" - + "\7\0\1\104\5\0\1\110\1\104\5\0\1\104\22\0" - + "\1\104\15\0\1\110\37\0\1\6\1\0\1\6\1\0" - + "\2\30\2\6\1\31\1\6\2\0\1\30\1\6\1\0" - + "\1\6\1\0\3\6\1\111\6\6\1\0\2\6\1\0" - + "\2\6\1\0\1\6\5\0\1\6\1\0\1\6\1\0" - + "\2\30\2\6\1\31\1\6\2\0\1\30\1\6\1\0" - + "\1\6\1\0\12\6\1\112\2\6\1\0\2\6\1\0" - + "\1\6\5\0\1\6\1\0\1\6\1\0\2\30\2\6" - + "\1\31\1\6\2\0\1\30\1\6\1\0\1\6\1\0" - + "\12\6\1\113\2\6\1\0\2\6\1\0\1\6\7\0" - + "\1\114\6\0\1\115\5\0\1\114\22\0\1\114\7\0" - + "\1\116\6\0\1\117\5\0\1\116\22\0\1\116\7\0" - + "\1\114\5\0\1\120\1\114\5\0\1\114\22\0\1\114" - + "\15\0\1\120\41\0\1\116\5\0\1\121\1\116\5\0" - + "\1\116\22\0\1\116\15\0\1\121\32\0"; + private static int zzUnpackRowMap(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + /** + * The transition table of the DFA + */ + private static final int[] ZZ_TRANS = zzUnpackTrans(); + private static final String ZZ_TRANS_PACKED_0 = + "\4\4\1\5\1\6\3\4\1\7\1\4\1\6\1\7" + + "\4\4\1\7\1\10\3\4\12\6\1\5\2\6\1\4" + + "\2\6\2\4\1\11\1\12\1\13\22\11\1\14\15\11" + + "\1\15\4\11\1\4\1\16\1\17\1\20\1\4\1\21" + + "\1\4\1\22\1\4\1\23\1\4\2\23\1\4\1\24" + + "\1\25\1\26\2\23\1\4\1\22\1\4\12\23\1\4" + + "\2\23\1\27\2\23\1\4\1\22\54\0\1\5\33\0" + + "\1\5\14\0\1\6\1\0\1\6\1\0\2\30\2\6" + + "\1\31\1\6\2\0\1\30\1\6\1\0\1\6\1\0" + + "\12\6\1\0\2\6\1\0\2\6\1\0\1\6\5\0" + + "\1\30\1\0\1\30\1\0\4\30\1\31\1\30\2\0" + + "\2\30\1\0\1\30\1\0\12\30\1\0\2\30\1\0" + + "\2\30\1\0\1\30\5\0\1\6\1\0\1\6\1\0" + + "\2\30\2\6\1\31\1\6\2\0\1\30\1\6\1\0" + + "\1\6\1\0\1\32\11\6\1\0\2\6\1\0\2\6" + + "\1\0\1\6\1\11\2\0\22\11\1\0\15\11\1\0" + + "\4\11\2\0\1\13\45\0\2\33\1\0\13\33\1\34" + + "\5\33\1\35\1\36\3\33\1\37\2\33\1\40\2\33" + + "\1\41\3\33\1\42\1\43\1\44\1\45\1\34\2\0" + + "\1\17\45\0\1\20\2\0\45\20\5\0\1\23\1\46" + + "\1\23\1\0\4\23\1\0\1\23\2\0\2\23\1\0" + + "\1\23\1\0\12\23\1\0\2\23\1\0\2\23\1\0" + + "\1\23\7\0\1\22\6\0\1\22\1\0\1\47\2\50" + + "\1\0\1\22\22\0\1\22\5\0\1\23\1\0\1\23" + + "\1\0\4\23\1\0\1\23\2\0\2\23\1\0\1\23" + + "\1\0\12\23\1\0\2\23\1\0\2\23\1\0\1\23" + + "\7\0\1\51\6\0\1\51\1\0\1\47\2\50\1\0" + + "\1\51\22\0\1\51\7\0\1\22\6\0\1\51\1\0" + + "\1\52\3\0\1\22\22\0\1\22\7\0\1\47\6\0" + + "\1\47\5\0\1\47\22\0\1\47\5\0\1\6\1\0" + + "\1\6\1\0\2\30\2\6\1\31\1\6\2\0\1\30" + + "\1\6\1\0\1\6\1\0\1\6\1\53\10\6\1\0" + + "\2\6\1\0\2\6\1\0\1\6\16\0\1\35\5\0" + + "\1\35\22\0\1\35\16\0\1\54\5\0\1\54\22\0" + + "\1\54\7\0\1\55\6\0\1\55\5\0\1\55\22\0" + + "\1\55\7\0\1\47\6\0\1\47\2\0\2\50\1\0" + + "\1\47\22\0\1\47\7\0\1\56\6\0\1\56\1\57" + + "\3\0\1\57\1\56\22\0\1\56\5\0\1\6\1\0" + + "\1\6\1\0\2\30\2\6\1\31\1\6\2\0\1\30" + + "\1\60\1\0\1\6\1\0\12\6\1\0\2\6\1\0" + + "\2\6\1\0\1\6\7\0\1\55\1\61\5\0\1\55" + + "\5\0\1\55\22\0\1\55\7\0\1\56\6\0\1\56" + + "\5\0\1\56\22\0\1\56\5\0\1\6\1\0\1\6" + + "\1\0\2\30\2\6\1\31\1\6\2\0\1\30\1\6" + + "\1\0\1\6\1\0\2\6\1\62\7\6\1\0\2\6" + + "\1\0\2\6\1\0\1\6\43\0\1\63\11\0\1\6" + + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" + + "\1\30\1\6\1\0\1\6\1\0\3\6\1\64\6\6" + + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" + + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" + + "\1\30\1\6\1\0\1\6\1\0\4\6\1\65\5\6" + + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" + + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" + + "\1\30\1\6\1\0\1\6\1\0\5\6\1\66\4\6" + + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" + + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" + + "\1\30\1\6\1\0\1\6\1\0\6\6\1\67\3\6" + + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" + + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" + + "\1\30\1\70\1\0\1\6\1\0\3\6\1\71\3\6" + + "\1\72\2\6\1\0\2\6\1\0\2\6\1\0\1\6" + + "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31" + + "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\6\6" + + "\1\73\3\6\1\0\2\6\1\0\2\6\1\0\1\6" + + "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31" + + "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\10\6" + + "\1\74\1\6\1\0\2\6\1\0\2\6\1\0\1\6" + + "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31" + + "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\3\6" + + "\1\75\6\6\1\0\2\6\1\0\2\6\1\0\1\6" + + "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31" + + "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\12\6" + + "\1\0\1\76\1\6\1\0\2\6\1\0\1\6\5\0" + + "\1\6\1\0\1\6\1\0\2\30\2\6\1\31\1\6" + + "\2\0\1\30\1\6\1\0\1\6\1\0\11\6\1\77" + + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" + + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" + + "\1\30\1\6\1\0\1\6\1\0\10\6\1\100\1\6" + + "\1\0\2\6\1\0\2\6\1\0\1\6\5\0\1\6" + + "\1\0\1\6\1\0\2\30\2\6\1\31\1\6\2\0" + + "\1\30\1\6\1\0\1\6\1\0\12\6\1\101\2\6" + + "\1\0\2\6\1\0\1\6\5\0\1\6\1\0\1\6" + + "\1\0\2\30\2\6\1\31\1\6\2\0\1\30\1\6" + + "\1\0\1\6\1\0\12\6\1\0\1\6\1\102\1\0" + + "\2\6\1\0\1\6\5\0\1\6\1\0\1\6\1\0" + + "\2\30\2\6\1\31\1\6\2\0\1\30\1\6\1\0" + + "\1\6\1\0\11\6\1\103\1\0\2\6\1\0\2\6" + + "\1\0\1\6\7\0\1\104\6\0\1\105\5\0\1\104" + + "\22\0\1\104\5\0\1\6\1\0\1\6\1\0\2\30" + + "\2\6\1\31\1\6\2\0\1\30\1\106\1\0\1\6" + + "\1\0\12\6\1\0\2\6\1\0\2\6\1\0\1\6" + + "\5\0\1\6\1\0\1\6\1\0\2\30\2\6\1\31" + + "\1\6\2\0\1\30\1\6\1\0\1\6\1\0\3\6" + + "\1\107\6\6\1\0\2\6\1\0\2\6\1\0\1\6" + + "\7\0\1\104\5\0\1\110\1\104\5\0\1\104\22\0" + + "\1\104\15\0\1\110\37\0\1\6\1\0\1\6\1\0" + + "\2\30\2\6\1\31\1\6\2\0\1\30\1\6\1\0" + + "\1\6\1\0\3\6\1\111\6\6\1\0\2\6\1\0" + + "\2\6\1\0\1\6\5\0\1\6\1\0\1\6\1\0" + + "\2\30\2\6\1\31\1\6\2\0\1\30\1\6\1\0" + + "\1\6\1\0\12\6\1\112\2\6\1\0\2\6\1\0" + + "\1\6\5\0\1\6\1\0\1\6\1\0\2\30\2\6" + + "\1\31\1\6\2\0\1\30\1\6\1\0\1\6\1\0" + + "\12\6\1\113\2\6\1\0\2\6\1\0\1\6\7\0" + + "\1\114\6\0\1\115\5\0\1\114\22\0\1\114\7\0" + + "\1\116\6\0\1\117\5\0\1\116\22\0\1\116\7\0" + + "\1\114\5\0\1\120\1\114\5\0\1\114\22\0\1\114" + + "\15\0\1\120\41\0\1\116\5\0\1\121\1\116\5\0" + + "\1\116\22\0\1\116\15\0\1\121\32\0"; - private static int[] zzUnpackTrans() { - int[] result = new int[2320]; - int offset = 0; - offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); - return result; - } + private static int[] zzUnpackTrans() { + int[] result = new int[2320]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } - private static int zzUnpackTrans(String packed, int offset, int[] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - value--; - do { - result[j++] = value; - } while (--count > 0); - } - return j; - } - /* error codes */ - private static final int ZZ_UNKNOWN_ERROR = 0; - private static final int ZZ_NO_MATCH = 1; - private static final int ZZ_PUSHBACK_2BIG = 2; + private static int zzUnpackTrans(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do { + result[j++] = value; + } while (--count > 0); + } + return j; + } + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; - /* error messages for the codes above */ - private static final String ZZ_ERROR_MSG[] = { - "Unkown internal scanner error", - "Error: could not match input", - "Error: pushback value was too large" - }; - /** - * ZZ_ATTRIBUTE[aState] contains the attributes of state - * aState - */ - private static final int[] ZZ_ATTRIBUTE = zzUnpackAttribute(); - private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\3\0\1\11\6\1\1\11\1\1\1\11\1\1\1\11" - + "\7\1\1\11\1\0\1\11\1\1\1\11\2\1\10\11" - + "\1\0\1\1\1\0\1\1\1\0\1\1\1\11\1\0" - + "\1\1\1\0\1\1\1\0\1\1\1\11\15\1\1\0" - + "\2\1\2\0\2\1\1\11\1\1\6\0\2\11"; + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state + * aState + */ + private static final int[] ZZ_ATTRIBUTE = zzUnpackAttribute(); + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\3\0\1\11\6\1\1\11\1\1\1\11\1\1\1\11" + + "\7\1\1\11\1\0\1\11\1\1\1\11\2\1\10\11" + + "\1\0\1\1\1\0\1\1\1\0\1\1\1\11\1\0" + + "\1\1\1\0\1\1\1\0\1\1\1\11\15\1\1\0" + + "\2\1\2\0\2\1\1\11\1\1\6\0\2\11"; - private static int[] zzUnpackAttribute() { - int[] result = new int[81]; - int offset = 0; - offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); - return result; - } + private static int[] zzUnpackAttribute() { + int[] result = new int[81]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } - private static int zzUnpackAttribute(String packed, int offset, int[] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - do { - result[j++] = value; - } while (--count > 0); - } - return j; - } - /** - * the input device - */ - private java.io.Reader zzReader; - /** - * the current state of the DFA - */ - private int zzState; - /** - * the current lexical state - */ - private int zzLexicalState = YYINITIAL; - /** - * this buffer contains the current text to be matched and is the source of - * the yytext() string - */ - private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; - /** - * the textposition at the last accepting state - */ - private int zzMarkedPos; - /** - * the current text position in the buffer - */ - private int zzCurrentPos; - /** - * startRead marks the beginning of the yytext() string in the buffer - */ - private int zzStartRead; - /** - * endRead marks the last character in the buffer, that has been read from - * input - */ - private int zzEndRead; - /** - * number of newlines encountered up to the start of the matched text - */ - private int yyline; - /** - * the number of characters up to the start of the matched text - */ - private int yychar; - /** - * the number of characters from the last newline up to the start of the - * matched text - */ - private int yycolumn; - /** - * zzAtBOL == true <=> the scanner is currently at the beginning of a line - */ - private boolean zzAtBOL = true; - /** - * zzAtEOF == true <=> the scanner is at the EOF - */ - private boolean zzAtEOF; - /** - * denotes if the user-EOF-code has already been executed - */ - private boolean zzEOFDone; + private static int zzUnpackAttribute(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do { + result[j++] = value; + } while (--count > 0); + } + return j; + } + /** + * the input device + */ + private java.io.Reader zzReader; + /** + * the current state of the DFA + */ + private int zzState; + /** + * the current lexical state + */ + private int zzLexicalState = YYINITIAL; + /** + * this buffer contains the current text to be matched and is the source of + * the yytext() string + */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + /** + * the textposition at the last accepting state + */ + private int zzMarkedPos; + /** + * the current text position in the buffer + */ + private int zzCurrentPos; + /** + * startRead marks the beginning of the yytext() string in the buffer + */ + private int zzStartRead; + /** + * endRead marks the last character in the buffer, that has been read from + * input + */ + private int zzEndRead; + /** + * number of newlines encountered up to the start of the matched text + */ + private int yyline; + /** + * the number of characters up to the start of the matched text + */ + private int yychar; + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + /** + * zzAtEOF == true <=> the scanner is at the EOF + */ + private boolean zzAtEOF; + /** + * denotes if the user-EOF-code has already been executed + */ + private boolean zzEOFDone; - /* user code: */ - StringBuffer string = new StringBuffer(); - boolean isMultiname = false; - long multinameId = 0; + /* user code: */ + StringBuffer string = new StringBuffer(); + boolean isMultiname = false; + long multinameId = 0; - /** - * Create an empty lexer, yyrset will be called later to reset and assign the - * reader - */ - public Flasm3Lexer() { - } + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public Flasm3Lexer() { + } - public int yychar() { - return yychar; - } + public int yychar() { + return yychar; + } - public int yyline() { - return yyline + 1; - } + public int yyline() { + return yyline + 1; + } - /** - * Creates a new scanner There is also a java.io.InputStream version of this - * constructor. - * - * @param in the java.io.Reader to read input from. - */ - public Flasm3Lexer(java.io.Reader in) { - this.zzReader = in; - } + /** + * Creates a new scanner There is also a java.io.InputStream version of this + * constructor. + * + * @param in the java.io.Reader to read input from. + */ + public Flasm3Lexer(java.io.Reader in) { + this.zzReader = in; + } - /** - * Creates a new scanner. There is also java.io.Reader version of this - * constructor. - * - * @param in the java.io.Inputstream to read input from. - */ - public Flasm3Lexer(java.io.InputStream in) { - this(new java.io.InputStreamReader(in)); - } + /** + * Creates a new scanner. There is also java.io.Reader version of this + * constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + public Flasm3Lexer(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); + } - /** - * Unpacks the compressed character translation table. - * - * @param packed the packed character translation table - * @return the unpacked character translation table - */ - private static char[] zzUnpackCMap(String packed) { - char[] map = new char[0x10000]; - int i = 0; /* index in packed string */ - int j = 0; /* index in unpacked array */ - while (i < 1738) { - int count = packed.charAt(i++); - char value = packed.charAt(i++); - do { - map[j++] = value; - } while (--count > 0); - } - return map; - } + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char[] zzUnpackCMap(String packed) { + char[] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 1738) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do { + map[j++] = value; + } while (--count > 0); + } + return map; + } - /** - * Refills the input buffer. - * - * @return false, iff there was new input. - * - * @exception java.io.IOException if any I/O-Error occurs - */ - private boolean zzRefill() throws java.io.IOException { + /** + * Refills the input buffer. + * + * @return false, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { - /* first: make room (if you can) */ - if (zzStartRead > 0) { - System.arraycopy(zzBuffer, zzStartRead, - zzBuffer, 0, - zzEndRead - zzStartRead); + /* first: make room (if you can) */ + if (zzStartRead > 0) { + System.arraycopy(zzBuffer, zzStartRead, + zzBuffer, 0, + zzEndRead - zzStartRead); - /* translate stored positions */ - zzEndRead -= zzStartRead; - zzCurrentPos -= zzStartRead; - zzMarkedPos -= zzStartRead; - zzStartRead = 0; - } + /* translate stored positions */ + zzEndRead -= zzStartRead; + zzCurrentPos -= zzStartRead; + zzMarkedPos -= zzStartRead; + zzStartRead = 0; + } - /* is the buffer big enough? */ - if (zzCurrentPos >= zzBuffer.length) { - /* if not: blow it up */ - char newBuffer[] = new char[zzCurrentPos * 2]; - System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); - zzBuffer = newBuffer; - } + /* is the buffer big enough? */ + if (zzCurrentPos >= zzBuffer.length) { + /* if not: blow it up */ + char newBuffer[] = new char[zzCurrentPos * 2]; + System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); + zzBuffer = newBuffer; + } - /* finally: fill the buffer with new input */ - int numRead = zzReader.read(zzBuffer, zzEndRead, - zzBuffer.length - zzEndRead); + /* finally: fill the buffer with new input */ + int numRead = zzReader.read(zzBuffer, zzEndRead, + zzBuffer.length - zzEndRead); - if (numRead > 0) { - zzEndRead += numRead; - return false; - } - // unlikely but not impossible: read 0 characters, but not at end of stream - if (numRead == 0) { - int c = zzReader.read(); - if (c == -1) { - return true; - } else { - zzBuffer[zzEndRead++] = (char) c; + if (numRead > 0) { + zzEndRead += numRead; return false; - } - } - - // numRead < 0 - return true; - } - - /** - * Closes the input stream. - */ - public final void yyclose() throws java.io.IOException { - zzAtEOF = true; /* indicate end of file */ - zzEndRead = zzStartRead; /* invalidate buffer */ - - if (zzReader != null) { - zzReader.close(); - } - } - - /** - * Resets the scanner to read from a new input stream. Does not close the old - * reader. - * - * All internal variables are reset, the old input stream cannot be - * reused (internal buffer is discarded and lost). Lexical state is set to - * ZZ_INITIAL. - * - * @param reader the new input stream - */ - public final void yyreset(java.io.Reader reader) { - zzReader = reader; - zzAtBOL = true; - zzAtEOF = false; - zzEOFDone = false; - zzEndRead = zzStartRead = 0; - zzCurrentPos = zzMarkedPos = 0; - yyline = yychar = yycolumn = 0; - zzLexicalState = YYINITIAL; - } - - /** - * Returns the current lexical state. - */ - public final int yystate() { - return zzLexicalState; - } - - /** - * Enters a new lexical state - * - * @param newState the new lexical state - */ - public final void yybegin(int newState) { - zzLexicalState = newState; - } - - /** - * Returns the text matched by the current regular expression. - */ - public final String yytext() { - return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead); - } - - /** - * Returns the character at position pos from the matched text. - * - * It is equivalent to yytext().charAt(pos), but faster - * - * @param pos the position of the character to fetch. A value from 0 to - * yylength()-1. - * - * @return the character at position pos - */ - public final char yycharat(int pos) { - return zzBuffer[zzStartRead + pos]; - } - - /** - * Returns the length of the matched text region. - */ - public final int yylength() { - return zzMarkedPos - zzStartRead; - } - - /** - * Reports an error that occured while scanning. - * - * In a wellformed scanner (no or only correct usage of yypushback(int) and a - * match-all fallback rule) this method will only be called with things that - * "Can't Possibly Happen". If this method is called, something is seriously - * wrong (e.g. a JFlex bug producing a faulty scanner etc.). - * - * Usual syntax/scanner level error handling should be done in error fallback - * rules. - * - * @param errorCode the code of the errormessage to display - */ - private void zzScanError(int errorCode) { - String message; - try { - message = ZZ_ERROR_MSG[errorCode]; - } catch (ArrayIndexOutOfBoundsException e) { - message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; - } - - throw new Error(message); - } - - /** - * Pushes the specified amount of characters back into the input stream. - * - * They will be read again by then next call of the scanning method - * - * @param number the number of characters to be read again. This number must - * not be greater than yylength()! - */ - public void yypushback(int number) { - if (number > yylength()) { - zzScanError(ZZ_PUSHBACK_2BIG); - } - - zzMarkedPos -= number; - } - - /** - * Resumes scanning until the next regular expression is matched, the end of - * input is encountered or an I/O-Error occurs. - * - * @return the next token - * @exception java.io.IOException if any I/O-Error occurs - */ - public ParsedSymbol yylex() throws java.io.IOException, ParseException { - int zzInput; - int zzAction; - - // cached fields: - int zzCurrentPosL; - int zzMarkedPosL; - int zzEndReadL = zzEndRead; - char[] zzBufferL = zzBuffer; - char[] zzCMapL = ZZ_CMAP; - - int[] zzTransL = ZZ_TRANS; - int[] zzRowMapL = ZZ_ROWMAP; - int[] zzAttrL = ZZ_ATTRIBUTE; - - while (true) { - zzMarkedPosL = zzMarkedPos; - - yychar += zzMarkedPosL - zzStartRead; - - boolean zzR = false; - for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL; - zzCurrentPosL++) { - switch (zzBufferL[zzCurrentPosL]) { - case '\u000B': - case '\u000C': - case '\u0085': - case '\u2028': - case '\u2029': - yyline++; - yycolumn = 0; - zzR = false; - break; - case '\r': - yyline++; - yycolumn = 0; - zzR = true; - break; - case '\n': - if (zzR) { - zzR = false; - } else { - yyline++; - yycolumn = 0; - } - break; - default: - zzR = false; - yycolumn++; - } - } - - if (zzR) { - // peek one character ahead if it is \n (if we have counted one line too much) - boolean zzPeek; - if (zzMarkedPosL < zzEndReadL) { - zzPeek = zzBufferL[zzMarkedPosL] == '\n'; - } else if (zzAtEOF) { - zzPeek = false; + } + // unlikely but not impossible: read 0 characters, but not at end of stream + if (numRead == 0) { + int c = zzReader.read(); + if (c == -1) { + return true; } else { - boolean eof = zzRefill(); - zzEndReadL = zzEndRead; - zzMarkedPosL = zzMarkedPos; - zzBufferL = zzBuffer; - if (eof) { - zzPeek = false; - } else { - zzPeek = zzBufferL[zzMarkedPosL] == '\n'; - } + zzBuffer[zzEndRead++] = (char) c; + return false; } - if (zzPeek) { - yyline--; + } + + // numRead < 0 + return true; + } + + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ + + if (zzReader != null) { + zzReader.close(); + } + } + + /** + * Resets the scanner to read from a new input stream. Does not close the + * old reader. + * + * All internal variables are reset, the old input stream cannot be + * reused (internal buffer is discarded and lost). Lexical state is set to + * ZZ_INITIAL. + * + * @param reader the new input stream + */ + public final void yyreset(java.io.Reader reader) { + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + zzEOFDone = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = 0; + yyline = yychar = yycolumn = 0; + zzLexicalState = YYINITIAL; + } + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead); + } + + /** + * Returns the character at position pos from the matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. A value from 0 to + * yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead + pos]; + } + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos - zzStartRead; + } + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of yypushback(int) and + * a match-all fallback rule) this method will only be called with things + * that "Can't Possibly Happen". If this method is called, something is + * seriously wrong (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done in error + * fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. This number must + * not be greater than yylength()! + */ + public void yypushback(int number) { + if (number > yylength()) { + zzScanError(ZZ_PUSHBACK_2BIG); + } + + zzMarkedPos -= number; + } + + /** + * Resumes scanning until the next regular expression is matched, the end of + * input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public ParsedSymbol yylex() throws java.io.IOException, ParseException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char[] zzBufferL = zzBuffer; + char[] zzCMapL = ZZ_CMAP; + + int[] zzTransL = ZZ_TRANS; + int[] zzRowMapL = ZZ_ROWMAP; + int[] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + yychar += zzMarkedPosL - zzStartRead; + + boolean zzR = false; + for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL; + zzCurrentPosL++) { + switch (zzBufferL[zzCurrentPosL]) { + case '\u000B': + case '\u000C': + case '\u0085': + case '\u2028': + case '\u2029': + yyline++; + yycolumn = 0; + zzR = false; + break; + case '\r': + yyline++; + yycolumn = 0; + zzR = true; + break; + case '\n': + if (zzR) { + zzR = false; + } else { + yyline++; + yycolumn = 0; + } + break; + default: + zzR = false; + yycolumn++; + } } - } - zzAction = -1; - zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + if (zzR) { + // peek one character ahead if it is \n (if we have counted one line too much) + boolean zzPeek; + if (zzMarkedPosL < zzEndReadL) { + zzPeek = zzBufferL[zzMarkedPosL] == '\n'; + } else if (zzAtEOF) { + zzPeek = false; + } else { + boolean eof = zzRefill(); + zzEndReadL = zzEndRead; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + if (eof) { + zzPeek = false; + } else { + zzPeek = zzBufferL[zzMarkedPosL] == '\n'; + } + } + if (zzPeek) { + yyline--; + } + } + zzAction = -1; - zzState = ZZ_LEXSTATE[zzLexicalState]; + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = ZZ_LEXSTATE[zzLexicalState]; - zzForAction: - { - while (true) { + zzForAction: + { + while (true) { - if (zzCurrentPosL < zzEndReadL) { - zzInput = zzBufferL[zzCurrentPosL++]; - } else if (zzAtEOF) { - zzInput = YYEOF; - break zzForAction; - } else { - // store back cached positions - zzCurrentPos = zzCurrentPosL; - zzMarkedPos = zzMarkedPosL; - boolean eof = zzRefill(); - // get translated positions and possibly new buffer - zzCurrentPosL = zzCurrentPos; - zzMarkedPosL = zzMarkedPos; - zzBufferL = zzBuffer; - zzEndReadL = zzEndRead; - if (eof) { - zzInput = YYEOF; - break zzForAction; - } else { - zzInput = zzBufferL[zzCurrentPosL++]; - } - } - int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput]]; - if (zzNext == -1) { - break zzForAction; - } - zzState = zzNext; + if (zzCurrentPosL < zzEndReadL) { + zzInput = zzBufferL[zzCurrentPosL++]; + } else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } else { + zzInput = zzBufferL[zzCurrentPosL++]; + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput]]; + if (zzNext == -1) { + break zzForAction; + } + zzState = zzNext; - int zzAttributes = zzAttrL[zzState]; - if ((zzAttributes & 1) == 1) { - zzAction = zzState; - zzMarkedPosL = zzCurrentPosL; - if ((zzAttributes & 8) == 8) { - break zzForAction; - } - } + int zzAttributes = zzAttrL[zzState]; + if ((zzAttributes & 1) == 1) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ((zzAttributes & 8) == 8) { + break zzForAction; + } + } + } } - } - // store back cached position - zzMarkedPos = zzMarkedPosL; + // store back cached position + zzMarkedPos = zzMarkedPosL; - switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { - case 8: { - return new ParsedSymbol(ParsedSymbol.TYPE_IDENTIFIER, yytext()); + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 8: { + return new ParsedSymbol(ParsedSymbol.TYPE_IDENTIFIER, yytext()); + } + case 27: + break; + case 21: { + string.append('\''); + } + case 28: + break; + case 9: { + return new ParsedSymbol(ParsedSymbol.TYPE_INTEGER, new Long(Long.parseLong((yytext())))); + } + case 29: + break; + case 26: { + String s = yytext(); + return new ParsedSymbol(ParsedSymbol.TYPE_EXCEPTION_TARGET, Integer.parseInt(s.substring(16, s.length() - 1))); + } + case 30: + break; + case 3: { + string.append(yytext()); + } + case 31: + break; + case 13: { + char val = (char) Integer.parseInt(yytext().substring(1), 8); + string.append(val); + } + case 32: + break; + case 25: { + String s = yytext(); + return new ParsedSymbol(ParsedSymbol.TYPE_EXCEPTION_START, Integer.parseInt(s.substring(15, s.length() - 1))); + } + case 33: + break; + case 5: { + yybegin(PARAMETERS); + // length also includes the trailing quote + if (isMultiname) { + return new ParsedSymbol(ParsedSymbol.TYPE_MULTINAME, new Long(multinameId)); + } else { + return new ParsedSymbol(ParsedSymbol.TYPE_STRING, string.toString()); + } + } + case 34: + break; + case 6: { + yybegin(YYINITIAL); + } + case 35: + break; + case 2: { + yybegin(PARAMETERS); + return new ParsedSymbol(ParsedSymbol.TYPE_INSTRUCTION_NAME, yytext()); + } + case 36: + break; + case 17: { + string.append('\r'); + } + case 37: + break; + case 24: { + String s = yytext(); + return new ParsedSymbol(ParsedSymbol.TYPE_EXCEPTION_END, Integer.parseInt(s.substring(13, s.length() - 1))); + } + case 38: + break; + case 7: { + return new ParsedSymbol(ParsedSymbol.TYPE_COMMENT, yytext().substring(1)); + } + case 39: + break; + case 19: { + string.append('\b'); + } + case 40: + break; + case 11: { + String s = yytext(); + return new ParsedSymbol(ParsedSymbol.TYPE_LABEL, s.substring(0, s.length() - 1)); + } + case 41: + break; + case 4: { + throw new ParseException("Unterminated string at end of line", yyline + 1); + } + case 42: + break; + case 10: { + isMultiname = false; + yybegin(STRING); + string.setLength(0); + } + case 43: + break; + case 15: { + string.append('\t'); + } + case 44: + break; + case 22: { + return new ParsedSymbol(ParsedSymbol.TYPE_FLOAT, new Double(Double.parseDouble((yytext())))); + } + case 45: + break; + case 14: { + string.append('\\'); + } + case 46: + break; + case 12: { + throw new ParseException("Illegal escape sequence \"" + yytext() + "\"", yyline + 1); + } + case 47: + break; + case 23: { + isMultiname = true; + String s = yytext(); + multinameId = Long.parseLong(s.substring(2, s.length() - 2)); + yybegin(STRING); + string.setLength(0); + } + case 48: + break; + case 16: { + string.append('\n'); + } + case 49: + break; + case 20: { + string.append('\f'); + } + case 50: + break; + case 18: { + string.append('\"'); + } + case 51: + break; + case 1: { + } + case 52: + break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + { + return new ParsedSymbol(ParsedSymbol.TYPE_EOF); + } + } else { + zzScanError(ZZ_NO_MATCH); + } } - case 27: - break; - case 21: { - string.append('\''); - } - case 28: - break; - case 9: { - return new ParsedSymbol(ParsedSymbol.TYPE_INTEGER, new Long(Long.parseLong((yytext())))); - } - case 29: - break; - case 26: { - String s = yytext(); - return new ParsedSymbol(ParsedSymbol.TYPE_EXCEPTION_TARGET, Integer.parseInt(s.substring(16, s.length() - 1))); - } - case 30: - break; - case 3: { - string.append(yytext()); - } - case 31: - break; - case 13: { - char val = (char) Integer.parseInt(yytext().substring(1), 8); - string.append(val); - } - case 32: - break; - case 25: { - String s = yytext(); - return new ParsedSymbol(ParsedSymbol.TYPE_EXCEPTION_START, Integer.parseInt(s.substring(15, s.length() - 1))); - } - case 33: - break; - case 5: { - yybegin(PARAMETERS); - // length also includes the trailing quote - if (isMultiname) { - return new ParsedSymbol(ParsedSymbol.TYPE_MULTINAME, new Long(multinameId)); - } else { - return new ParsedSymbol(ParsedSymbol.TYPE_STRING, string.toString()); - } - } - case 34: - break; - case 6: { - yybegin(YYINITIAL); - } - case 35: - break; - case 2: { - yybegin(PARAMETERS); - return new ParsedSymbol(ParsedSymbol.TYPE_INSTRUCTION_NAME, yytext()); - } - case 36: - break; - case 17: { - string.append('\r'); - } - case 37: - break; - case 24: { - String s = yytext(); - return new ParsedSymbol(ParsedSymbol.TYPE_EXCEPTION_END, Integer.parseInt(s.substring(13, s.length() - 1))); - } - case 38: - break; - case 7: { - return new ParsedSymbol(ParsedSymbol.TYPE_COMMENT, yytext().substring(1)); - } - case 39: - break; - case 19: { - string.append('\b'); - } - case 40: - break; - case 11: { - String s = yytext(); - return new ParsedSymbol(ParsedSymbol.TYPE_LABEL, s.substring(0, s.length() - 1)); - } - case 41: - break; - case 4: { - throw new ParseException("Unterminated string at end of line", yyline + 1); - } - case 42: - break; - case 10: { - isMultiname = false; - yybegin(STRING); - string.setLength(0); - } - case 43: - break; - case 15: { - string.append('\t'); - } - case 44: - break; - case 22: { - return new ParsedSymbol(ParsedSymbol.TYPE_FLOAT, new Double(Double.parseDouble((yytext())))); - } - case 45: - break; - case 14: { - string.append('\\'); - } - case 46: - break; - case 12: { - throw new ParseException("Illegal escape sequence \"" + yytext() + "\"", yyline + 1); - } - case 47: - break; - case 23: { - isMultiname = true; - String s = yytext(); - multinameId = Long.parseLong(s.substring(2, s.length() - 2)); - yybegin(STRING); - string.setLength(0); - } - case 48: - break; - case 16: { - string.append('\n'); - } - case 49: - break; - case 20: { - string.append('\f'); - } - case 50: - break; - case 18: { - string.append('\"'); - } - case 51: - break; - case 1: { - } - case 52: - break; - default: - if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { - zzAtEOF = true; - { - return new ParsedSymbol(ParsedSymbol.TYPE_EOF); - } - } else { - zzScanError(ZZ_NO_MATCH); - } - } - } - } + } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/MissingSymbolHandler.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/MissingSymbolHandler.java index 4d60882ba..705234906 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/MissingSymbolHandler.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/MissingSymbolHandler.java @@ -18,11 +18,11 @@ package com.jpexs.decompiler.flash.abc.avm2.parser; public interface MissingSymbolHandler { - public boolean missingString(String value); + public boolean missingString(String value); - public boolean missingInt(long value); + public boolean missingInt(long value); - public boolean missingUInt(long value); + public boolean missingUInt(long value); - public boolean missingDouble(double value); + public boolean missingDouble(double value); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ParseException.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ParseException.java index a4fdbf1b0..48e9856d5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ParseException.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ParseException.java @@ -18,12 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.parser; public class ParseException extends Exception { - public long line; - public String text; + public long line; + public String text; - public ParseException(String text, long line) { - super("ParseException:" + text + " on line " + line); - this.line = line; - this.text = text; - } + public ParseException(String text, long line) { + super("ParseException:" + text + " on line " + line); + this.line = line; + this.text = text; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ParsedSymbol.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ParsedSymbol.java index 31152e53a..18f0815c0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ParsedSymbol.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/ParsedSymbol.java @@ -18,27 +18,27 @@ package com.jpexs.decompiler.flash.abc.avm2.parser; public class ParsedSymbol { - public int type; - public Object value; - public static final int TYPE_STRING = 1; - public static final int TYPE_MULTINAME = 2; - public static final int TYPE_INSTRUCTION_NAME = 3; - public static final int TYPE_INTEGER = 4; - public static final int TYPE_FLOAT = 5; - public static final int TYPE_IDENTIFIER = 6; - public static final int TYPE_EOF = 7; - public static final int TYPE_LABEL = 8; - public static final int TYPE_COMMENT = 9; - public static final int TYPE_EXCEPTION_START = 10; - public static final int TYPE_EXCEPTION_END = 11; - public static final int TYPE_EXCEPTION_TARGET = 12; + public int type; + public Object value; + public static final int TYPE_STRING = 1; + public static final int TYPE_MULTINAME = 2; + public static final int TYPE_INSTRUCTION_NAME = 3; + public static final int TYPE_INTEGER = 4; + public static final int TYPE_FLOAT = 5; + public static final int TYPE_IDENTIFIER = 6; + public static final int TYPE_EOF = 7; + public static final int TYPE_LABEL = 8; + public static final int TYPE_COMMENT = 9; + public static final int TYPE_EXCEPTION_START = 10; + public static final int TYPE_EXCEPTION_END = 11; + public static final int TYPE_EXCEPTION_TARGET = 12; - public ParsedSymbol(int type, Object value) { - this.type = type; - this.value = value; - } + public ParsedSymbol(int type, Object value) { + this.type = type; + this.value = value; + } - public ParsedSymbol(int type) { - this.type = type; - } + public ParsedSymbol(int type) { + this.type = type; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ApplyTypeTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ApplyTypeTreeItem.java index bfa24bcb5..aed998e2f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ApplyTypeTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ApplyTypeTreeItem.java @@ -25,33 +25,33 @@ import java.util.List; public class ApplyTypeTreeItem extends TreeItem { - public GraphTargetItem object; - public List params; + public GraphTargetItem object; + public List params; - public ApplyTypeTreeItem(AVM2Instruction instruction, GraphTargetItem object, List params) { - super(instruction, PRECEDENCE_PRIMARY); - this.params = params; - this.object = object; - } + public ApplyTypeTreeItem(AVM2Instruction instruction, GraphTargetItem object, List params) { + super(instruction, PRECEDENCE_PRIMARY); + this.params = params; + this.object = object; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String ret = object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); - if (!params.isEmpty()) { - ret += hilight(".<"); - for (int i = 0; i < params.size(); i++) { - if (i > 0) { - ret += hilight(","); + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String ret = object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); + if (!params.isEmpty()) { + ret += hilight(".<"); + for (int i = 0; i < params.size(); i++) { + if (i > 0) { + ret += hilight(","); + } + GraphTargetItem p = params.get(i); + if (p instanceof NullTreeItem) { + ret += "*"; + } else { + ret += p.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); + } } - GraphTargetItem p = params.get(i); - if (p instanceof NullTreeItem) { - ret += "*"; - } else { - ret += p.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); - } - } - ret += hilight(">"); - } - return ret; - } + ret += hilight(">"); + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/BooleanTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/BooleanTreeItem.java index b8a84e239..d457744c9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/BooleanTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/BooleanTreeItem.java @@ -23,40 +23,40 @@ import java.util.List; public class BooleanTreeItem extends TreeItem { - public Boolean value; + public Boolean value; - public BooleanTreeItem(AVM2Instruction instruction, Boolean value) { - super(instruction, PRECEDENCE_PRIMARY); - this.value = value; - } + public BooleanTreeItem(AVM2Instruction instruction, Boolean value) { + super(instruction, PRECEDENCE_PRIMARY); + this.value = value; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return value.toString(); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return value.toString(); + } - @Override - public boolean isFalse() { - return value == false; - } + @Override + public boolean isFalse() { + return value == false; + } - @Override - public boolean isTrue() { - return value == true; - } + @Override + public boolean isTrue() { + return value == true; + } - @Override - public boolean toBoolean() { - return value; - } + @Override + public boolean toBoolean() { + return value; + } - @Override - public double toNumber() { - return value ? 1 : 0; - } + @Override + public double toNumber() { + return value ? 1 : 0; + } - @Override - public boolean isCompileTime() { - return true; - } + @Override + public boolean isCompileTime() { + return true; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallMethodTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallMethodTreeItem.java index d82b163cf..8114e2d5c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallMethodTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallMethodTreeItem.java @@ -25,26 +25,26 @@ import java.util.List; public class CallMethodTreeItem extends TreeItem { - public GraphTargetItem receiver; - public String methodName; - public List arguments; + public GraphTargetItem receiver; + public String methodName; + public List arguments; - public CallMethodTreeItem(AVM2Instruction instruction, GraphTargetItem receiver, String methodName, List arguments) { - super(instruction, PRECEDENCE_PRIMARY); - this.receiver = receiver; - this.methodName = methodName; - this.arguments = arguments; - } + public CallMethodTreeItem(AVM2Instruction instruction, GraphTargetItem receiver, String methodName, List arguments) { + super(instruction, PRECEDENCE_PRIMARY); + this.receiver = receiver; + this.methodName = methodName; + this.arguments = arguments; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String args = ""; - for (int a = 0; a < arguments.size(); a++) { - if (a > 0) { - args = args + ","; - } - args = args + arguments.get(a).toString(constants, localRegNames, fullyQualifiedNames); - } - return receiver.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight(".") + methodName + hilight("(") + args + hilight(")"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String args = ""; + for (int a = 0; a < arguments.size(); a++) { + if (a > 0) { + args = args + ","; + } + args = args + arguments.get(a).toString(constants, localRegNames, fullyQualifiedNames); + } + return receiver.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight(".") + methodName + hilight("(") + args + hilight(")"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallPropertyTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallPropertyTreeItem.java index 9116d17a1..b444ba1be 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallPropertyTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallPropertyTreeItem.java @@ -24,28 +24,28 @@ import java.util.List; public class CallPropertyTreeItem extends TreeItem { - public GraphTargetItem receiver; - public FullMultinameTreeItem propertyName; - public List arguments; - public boolean isVoid; + public GraphTargetItem receiver; + public FullMultinameTreeItem propertyName; + public List arguments; + public boolean isVoid; - public CallPropertyTreeItem(AVM2Instruction instruction, boolean isVoid, GraphTargetItem receiver, FullMultinameTreeItem propertyName, List arguments) { - super(instruction, PRECEDENCE_PRIMARY); - this.receiver = receiver; - this.propertyName = propertyName; - this.arguments = arguments; - this.isVoid = isVoid; - } + public CallPropertyTreeItem(AVM2Instruction instruction, boolean isVoid, GraphTargetItem receiver, FullMultinameTreeItem propertyName, List arguments) { + super(instruction, PRECEDENCE_PRIMARY); + this.receiver = receiver; + this.propertyName = propertyName; + this.arguments = arguments; + this.isVoid = isVoid; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String args = ""; - for (int a = 0; a < arguments.size(); a++) { - if (a > 0) { - args = args + hilight(","); - } - args = args + arguments.get(a).toString(constants, localRegNames, fullyQualifiedNames); - } - return formatProperty(constants, receiver, propertyName, localRegNames, fullyQualifiedNames) + hilight("(") + args + hilight(")"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String args = ""; + for (int a = 0; a < arguments.size(); a++) { + if (a > 0) { + args = args + hilight(","); + } + args = args + arguments.get(a).toString(constants, localRegNames, fullyQualifiedNames); + } + return formatProperty(constants, receiver, propertyName, localRegNames, fullyQualifiedNames) + hilight("(") + args + hilight(")"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallStaticTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallStaticTreeItem.java index 5386e7e3f..71f6fd7f3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallStaticTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallStaticTreeItem.java @@ -25,26 +25,26 @@ import java.util.List; public class CallStaticTreeItem extends TreeItem { - public GraphTargetItem receiver; - public String methodName; - public List arguments; + public GraphTargetItem receiver; + public String methodName; + public List arguments; - public CallStaticTreeItem(AVM2Instruction instruction, GraphTargetItem receiver, String methodName, List arguments) { - super(instruction, PRECEDENCE_PRIMARY); - this.receiver = receiver; - this.methodName = methodName; - this.arguments = arguments; - } + public CallStaticTreeItem(AVM2Instruction instruction, GraphTargetItem receiver, String methodName, List arguments) { + super(instruction, PRECEDENCE_PRIMARY); + this.receiver = receiver; + this.methodName = methodName; + this.arguments = arguments; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String args = ""; - for (int a = 0; a < arguments.size(); a++) { - if (a > 0) { - args = args + ","; - } - args = args + arguments.get(a).toString(constants, localRegNames, fullyQualifiedNames); - } - return receiver.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight(".") + methodName + hilight("(") + args + hilight(")"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String args = ""; + for (int a = 0; a < arguments.size(); a++) { + if (a > 0) { + args = args + ","; + } + args = args + arguments.get(a).toString(constants, localRegNames, fullyQualifiedNames); + } + return receiver.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight(".") + methodName + hilight("(") + args + hilight(")"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallSuperTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallSuperTreeItem.java index 133145ea0..6b7e697c5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallSuperTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallSuperTreeItem.java @@ -25,32 +25,32 @@ import java.util.List; public class CallSuperTreeItem extends TreeItem { - public GraphTargetItem receiver; - public FullMultinameTreeItem multiname; - public List arguments; - public boolean isVoid; + public GraphTargetItem receiver; + public FullMultinameTreeItem multiname; + public List arguments; + public boolean isVoid; - public CallSuperTreeItem(AVM2Instruction instruction, boolean isVoid, GraphTargetItem receiver, FullMultinameTreeItem multiname, List arguments) { - super(instruction, PRECEDENCE_PRIMARY); - this.receiver = receiver; - this.multiname = multiname; - this.arguments = arguments; - this.isVoid = isVoid; - } + public CallSuperTreeItem(AVM2Instruction instruction, boolean isVoid, GraphTargetItem receiver, FullMultinameTreeItem multiname, List arguments) { + super(instruction, PRECEDENCE_PRIMARY); + this.receiver = receiver; + this.multiname = multiname; + this.arguments = arguments; + this.isVoid = isVoid; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String args = ""; - for (int a = 0; a < arguments.size(); a++) { - if (a > 0) { - args = args + ","; - } - args = args + arguments.get(a).toString(constants, localRegNames, fullyQualifiedNames); - } - String calee = receiver.toString(constants, localRegNames, fullyQualifiedNames) + "."; - if (Highlighting.stripHilights(calee).equals("this.")) { - calee = ""; - } - return calee + hilight("super.") + multiname.toString(constants, localRegNames, fullyQualifiedNames) + hilight("(") + args + hilight(")"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String args = ""; + for (int a = 0; a < arguments.size(); a++) { + if (a > 0) { + args = args + ","; + } + args = args + arguments.get(a).toString(constants, localRegNames, fullyQualifiedNames); + } + String calee = receiver.toString(constants, localRegNames, fullyQualifiedNames) + "."; + if (Highlighting.stripHilights(calee).equals("this.")) { + calee = ""; + } + return calee + hilight("super.") + multiname.toString(constants, localRegNames, fullyQualifiedNames) + hilight("(") + args + hilight(")"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallTreeItem.java index 33bb2c9f6..b81bc1435 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CallTreeItem.java @@ -24,37 +24,37 @@ import java.util.List; public class CallTreeItem extends TreeItem { - public GraphTargetItem receiver; - public GraphTargetItem function; - public List arguments; + public GraphTargetItem receiver; + public GraphTargetItem function; + public List arguments; - public CallTreeItem(AVM2Instruction instruction, GraphTargetItem receiver, GraphTargetItem function, List arguments) { - super(instruction, PRECEDENCE_PRIMARY); - this.receiver = receiver; - this.function = function; - this.arguments = arguments; - } + public CallTreeItem(AVM2Instruction instruction, GraphTargetItem receiver, GraphTargetItem function, List arguments) { + super(instruction, PRECEDENCE_PRIMARY); + this.receiver = receiver; + this.function = function; + this.arguments = arguments; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String args = ""; - for (int a = 0; a < arguments.size(); a++) { - if (a > 0) { - args = args + ","; + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String args = ""; + for (int a = 0; a < arguments.size(); a++) { + if (a > 0) { + args = args + ","; + } + args = args + arguments.get(a).toString(constants, localRegNames, fullyQualifiedNames); + } + /*String recPart = ""; receiver.toString(constants, localRegNames) + hilight("."); + if (receiver instanceof NewActivationTreeItem) { + recPart = ""; } - args = args + arguments.get(a).toString(constants, localRegNames, fullyQualifiedNames); - } - /*String recPart = ""; receiver.toString(constants, localRegNames) + hilight("."); - if (receiver instanceof NewActivationTreeItem) { - recPart = ""; - } - if (receiver instanceof ThisTreeItem) { - recPart = ""; - }*/ - String fstr = function.toString(constants, localRegNames, fullyQualifiedNames); - if (function.precedence > precedence) { - fstr = "(" + fstr + ")"; - } - return fstr + hilight("(") + args + hilight(")"); - } + if (receiver instanceof ThisTreeItem) { + recPart = ""; + }*/ + String fstr = function.toString(constants, localRegNames, fullyQualifiedNames); + if (function.precedence > precedence) { + fstr = "(" + fstr + ")"; + } + return fstr + hilight("(") + args + hilight(")"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ClassTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ClassTreeItem.java index f8ab1175d..2e3b8407f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ClassTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ClassTreeItem.java @@ -23,15 +23,15 @@ import java.util.List; public class ClassTreeItem extends TreeItem { - public Multiname className; + public Multiname className; - public ClassTreeItem(Multiname className) { - super(null, PRECEDENCE_PRIMARY); - this.className = className; - } + public ClassTreeItem(Multiname className) { + super(null, PRECEDENCE_PRIMARY); + this.className = className; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return className.getName(constants, fullyQualifiedNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return className.getName(constants, fullyQualifiedNames); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CoerceTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CoerceTreeItem.java index 2d81b1ca1..3572ce636 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CoerceTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CoerceTreeItem.java @@ -24,23 +24,23 @@ import java.util.List; public class CoerceTreeItem extends TreeItem { - public GraphTargetItem value; - public String type; + public GraphTargetItem value; + public String type; - public CoerceTreeItem(AVM2Instruction instruction, GraphTargetItem value, String type) { - super(instruction, NOPRECEDENCE); - this.value = value; - this.type = type; - } + public CoerceTreeItem(AVM2Instruction instruction, GraphTargetItem value, String type) { + super(instruction, NOPRECEDENCE); + this.value = value; + this.type = type; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - //return hilight("("+type+")")+ - return value.toString(constants, localRegNames, fullyQualifiedNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + //return hilight("("+type+")")+ + return value.toString(constants, localRegNames, fullyQualifiedNames); + } - @Override - public GraphTargetItem getNotCoerced() { - return value; - } + @Override + public GraphTargetItem getNotCoerced() { + return value; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CommentTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CommentTreeItem.java index ee2ab95a4..2c84c0ace 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CommentTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/CommentTreeItem.java @@ -27,20 +27,20 @@ import java.util.List; */ public class CommentTreeItem extends TreeItem { - public String comment; + public String comment; - public CommentTreeItem(AVM2Instruction instruction, String comment) { - super(instruction, NOPRECEDENCE); - this.comment = comment; - } + public CommentTreeItem(AVM2Instruction instruction, String comment) { + super(instruction, NOPRECEDENCE); + this.comment = comment; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return "//" + comment; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return "//" + comment; + } - @Override - public boolean needsSemicolon() { - return false; - } + @Override + public boolean needsSemicolon() { + return false; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConstructPropTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConstructPropTreeItem.java index 016eba28a..04ed9880f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConstructPropTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConstructPropTreeItem.java @@ -24,31 +24,31 @@ import java.util.List; public class ConstructPropTreeItem extends TreeItem { - public GraphTargetItem object; - public FullMultinameTreeItem propertyName; - public List args; + public GraphTargetItem object; + public FullMultinameTreeItem propertyName; + public List args; - public ConstructPropTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem propertyName, List args) { - super(instruction, PRECEDENCE_PRIMARY); - this.object = object; - this.propertyName = propertyName; - this.args = args; - } + public ConstructPropTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem propertyName, List args) { + super(instruction, PRECEDENCE_PRIMARY); + this.object = object; + this.propertyName = propertyName; + this.args = args; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String argStr = ""; - for (int a = 0; a < args.size(); a++) { - if (a > 0) { - argStr = argStr + ","; - } - argStr = argStr + args.get(a).toString(constants, localRegNames, fullyQualifiedNames); - } - String objstr = object.toString(constants, localRegNames, fullyQualifiedNames); - if (!objstr.equals("")) { - objstr += "."; - } - return hilight("new ") + objstr + propertyName.toString(constants, localRegNames, fullyQualifiedNames) + hilight("(") + argStr + hilight(")"); + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String argStr = ""; + for (int a = 0; a < args.size(); a++) { + if (a > 0) { + argStr = argStr + ","; + } + argStr = argStr + args.get(a).toString(constants, localRegNames, fullyQualifiedNames); + } + String objstr = object.toString(constants, localRegNames, fullyQualifiedNames); + if (!objstr.equals("")) { + objstr += "."; + } + return hilight("new ") + objstr + propertyName.toString(constants, localRegNames, fullyQualifiedNames) + hilight("(") + argStr + hilight(")"); - } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConstructSuperTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConstructSuperTreeItem.java index b91fc3dbd..2279b2027 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConstructSuperTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConstructSuperTreeItem.java @@ -25,29 +25,29 @@ import java.util.List; public class ConstructSuperTreeItem extends TreeItem { - public GraphTargetItem object; - public List args; + public GraphTargetItem object; + public List args; - public ConstructSuperTreeItem(AVM2Instruction instruction, GraphTargetItem object, List args) { - super(instruction, PRECEDENCE_PRIMARY); - this.object = object; - this.args = args; - } + public ConstructSuperTreeItem(AVM2Instruction instruction, GraphTargetItem object, List args) { + super(instruction, PRECEDENCE_PRIMARY); + this.object = object; + this.args = args; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String argStr = ""; - for (int a = 0; a < args.size(); a++) { - if (a > 0) { - argStr = argStr + ","; - } - argStr = argStr + args.get(a).toString(constants, localRegNames, fullyQualifiedNames); - } - String calee = object.toString(constants, localRegNames, fullyQualifiedNames) + "."; - if (Highlighting.stripHilights(calee).equals("this.")) { - calee = ""; - } - return calee + hilight("super(") + argStr + hilight(")"); + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String argStr = ""; + for (int a = 0; a < args.size(); a++) { + if (a > 0) { + argStr = argStr + ","; + } + argStr = argStr + args.get(a).toString(constants, localRegNames, fullyQualifiedNames); + } + String calee = object.toString(constants, localRegNames, fullyQualifiedNames) + "."; + if (Highlighting.stripHilights(calee).equals("this.")) { + calee = ""; + } + return calee + hilight("super(") + argStr + hilight(")"); - } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConstructTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConstructTreeItem.java index a9068f69f..ef98b2a6c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConstructTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConstructTreeItem.java @@ -24,29 +24,29 @@ import java.util.List; public class ConstructTreeItem extends TreeItem { - public GraphTargetItem object; - public List args; + public GraphTargetItem object; + public List args; - public ConstructTreeItem(AVM2Instruction instruction, GraphTargetItem object, List args) { - super(instruction, PRECEDENCE_PRIMARY); - this.object = object; - this.args = args; - } + public ConstructTreeItem(AVM2Instruction instruction, GraphTargetItem object, List args) { + super(instruction, PRECEDENCE_PRIMARY); + this.object = object; + this.args = args; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String argStr = ""; - for (int a = 0; a < args.size(); a++) { - if (a > 0) { - argStr = argStr + ","; - } - argStr = argStr + args.get(a).toString(constants, localRegNames, fullyQualifiedNames); - } - if (object instanceof NewFunctionTreeItem) { - return object.toString(constants, localRegNames, fullyQualifiedNames); - } - String obStr = object.toString(constants, localRegNames, fullyQualifiedNames); - return hilight("new ") + obStr + hilight("(") + argStr + hilight(")"); + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String argStr = ""; + for (int a = 0; a < args.size(); a++) { + if (a > 0) { + argStr = argStr + ","; + } + argStr = argStr + args.get(a).toString(constants, localRegNames, fullyQualifiedNames); + } + if (object instanceof NewFunctionTreeItem) { + return object.toString(constants, localRegNames, fullyQualifiedNames); + } + String obStr = object.toString(constants, localRegNames, fullyQualifiedNames); + return hilight("new ") + obStr + hilight("(") + argStr + hilight(")"); - } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConvertTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConvertTreeItem.java index c99bc9d26..d4e267c9a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConvertTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ConvertTreeItem.java @@ -24,23 +24,23 @@ import java.util.List; public class ConvertTreeItem extends TreeItem { - public GraphTargetItem value; - public String type; + public GraphTargetItem value; + public String type; - public ConvertTreeItem(AVM2Instruction instruction, GraphTargetItem value, String type) { - super(instruction, NOPRECEDENCE); - this.value = value; - this.type = type; - } + public ConvertTreeItem(AVM2Instruction instruction, GraphTargetItem value, String type) { + super(instruction, NOPRECEDENCE); + this.value = value; + this.type = type; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - //return hilight("("+type+")")+ - return value.toString(constants, localRegNames, fullyQualifiedNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + //return hilight("("+type+")")+ + return value.toString(constants, localRegNames, fullyQualifiedNames); + } - @Override - public GraphTargetItem getNotCoerced() { - return value; - } + @Override + public GraphTargetItem getNotCoerced() { + return value; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/DecLocalTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/DecLocalTreeItem.java index 2325e4f95..488567297 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/DecLocalTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/DecLocalTreeItem.java @@ -23,15 +23,15 @@ import java.util.List; public class DecLocalTreeItem extends TreeItem { - public int regIndex; + public int regIndex; - public DecLocalTreeItem(AVM2Instruction instruction, int regIndex) { - super(instruction, PRECEDENCE_POSTFIX); - this.regIndex = regIndex; - } + public DecLocalTreeItem(AVM2Instruction instruction, int regIndex) { + super(instruction, PRECEDENCE_POSTFIX); + this.regIndex = regIndex; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return localRegName(localRegNames, regIndex) + hilight("--"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return localRegName(localRegNames, regIndex) + hilight("--"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/DecrementTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/DecrementTreeItem.java index 1e6957ded..394d90d20 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/DecrementTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/DecrementTreeItem.java @@ -24,15 +24,15 @@ import java.util.List; public class DecrementTreeItem extends TreeItem { - public GraphTargetItem object; + public GraphTargetItem object; - public DecrementTreeItem(AVM2Instruction instruction, GraphTargetItem object) { - super(instruction, PRECEDENCE_ADDITIVE); - this.object = object; - } + public DecrementTreeItem(AVM2Instruction instruction, GraphTargetItem object) { + super(instruction, PRECEDENCE_ADDITIVE); + this.object = object; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return object.toString(constants, localRegNames, fullyQualifiedNames) + hilight("-1"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return object.toString(constants, localRegNames, fullyQualifiedNames) + hilight("-1"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/DefaultXMLNamespace.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/DefaultXMLNamespace.java index b8a09ad8d..591e94c2d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/DefaultXMLNamespace.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/DefaultXMLNamespace.java @@ -29,15 +29,15 @@ import java.util.List; */ public class DefaultXMLNamespace extends TreeItem { - private GraphTargetItem ns; + private GraphTargetItem ns; - public DefaultXMLNamespace(AVM2Instruction instruction, GraphTargetItem ns) { - super(instruction, NOPRECEDENCE); - this.ns = ns; - } + public DefaultXMLNamespace(AVM2Instruction instruction, GraphTargetItem ns) { + super(instruction, NOPRECEDENCE); + this.ns = ns; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("default xml namespace = ") + ns.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight("default xml namespace = ") + ns.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/EscapeXAttrTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/EscapeXAttrTreeItem.java index d7d7d8fa7..b324f9752 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/EscapeXAttrTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/EscapeXAttrTreeItem.java @@ -29,15 +29,15 @@ import java.util.List; */ public class EscapeXAttrTreeItem extends TreeItem { - public GraphTargetItem expression; + public GraphTargetItem expression; - public EscapeXAttrTreeItem(AVM2Instruction instruction, GraphTargetItem expression) { - super(instruction, NOPRECEDENCE); - this.expression = expression; - } + public EscapeXAttrTreeItem(AVM2Instruction instruction, GraphTargetItem expression) { + super(instruction, NOPRECEDENCE); + this.expression = expression; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("{") + expression.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight("}"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight("{") + expression.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight("}"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/EscapeXElemTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/EscapeXElemTreeItem.java index 55d919a4a..da32559a6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/EscapeXElemTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/EscapeXElemTreeItem.java @@ -29,15 +29,15 @@ import java.util.List; */ public class EscapeXElemTreeItem extends TreeItem { - public GraphTargetItem expression; + public GraphTargetItem expression; - public EscapeXElemTreeItem(AVM2Instruction instruction, GraphTargetItem expression) { - super(instruction, NOPRECEDENCE); - this.expression = expression; - } + public EscapeXElemTreeItem(AVM2Instruction instruction, GraphTargetItem expression) { + super(instruction, NOPRECEDENCE); + this.expression = expression; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("{") + expression.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight("}"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight("{") + expression.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight("}"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FilteredCheckTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FilteredCheckTreeItem.java index 14eb4d21f..a18c76e50 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FilteredCheckTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FilteredCheckTreeItem.java @@ -29,15 +29,15 @@ import java.util.List; */ public class FilteredCheckTreeItem extends TreeItem { - GraphTargetItem object; + GraphTargetItem object; - public FilteredCheckTreeItem(AVM2Instruction instruction, GraphTargetItem object) { - super(instruction, NOPRECEDENCE); - this.object = object; - } + public FilteredCheckTreeItem(AVM2Instruction instruction, GraphTargetItem object) { + super(instruction, NOPRECEDENCE); + this.object = object; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FindPropertyTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FindPropertyTreeItem.java index 53e8306f2..e3bf65f47 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FindPropertyTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FindPropertyTreeItem.java @@ -23,15 +23,15 @@ import java.util.List; public class FindPropertyTreeItem extends TreeItem { - public FullMultinameTreeItem propertyName; + public FullMultinameTreeItem propertyName; - public FindPropertyTreeItem(AVM2Instruction instruction, FullMultinameTreeItem propertyName) { - super(instruction, PRECEDENCE_PRIMARY); - this.propertyName = propertyName; - } + public FindPropertyTreeItem(AVM2Instruction instruction, FullMultinameTreeItem propertyName) { + super(instruction, PRECEDENCE_PRIMARY); + this.propertyName = propertyName; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return ""; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return ""; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FloatValueTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FloatValueTreeItem.java index f58ff0ded..459d7c05b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FloatValueTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FloatValueTreeItem.java @@ -23,25 +23,25 @@ import java.util.List; public class FloatValueTreeItem extends NumberValueTreeItem { - public Double value; + public Double value; - public FloatValueTreeItem(AVM2Instruction instruction, Double value) { - super(instruction); - this.value = value; - } + public FloatValueTreeItem(AVM2Instruction instruction, Double value) { + super(instruction); + this.value = value; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("" + value); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight("" + value); + } - @Override - public double toNumber() { - return value; - } + @Override + public double toNumber() { + return value; + } - @Override - public boolean isCompileTime() { - return true; - } + @Override + public boolean isCompileTime() { + return true; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FullMultinameTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FullMultinameTreeItem.java index bca5b2660..6cbe0d12c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FullMultinameTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/FullMultinameTreeItem.java @@ -25,102 +25,102 @@ import java.util.List; public class FullMultinameTreeItem extends TreeItem { - public int multinameIndex; - public GraphTargetItem name; - public GraphTargetItem namespace; + public int multinameIndex; + public GraphTargetItem name; + public GraphTargetItem namespace; - public FullMultinameTreeItem(AVM2Instruction instruction, int multinameIndex, GraphTargetItem name) { - super(instruction, PRECEDENCE_PRIMARY); - this.multinameIndex = multinameIndex; - this.name = name; - this.namespace = null; - } + public FullMultinameTreeItem(AVM2Instruction instruction, int multinameIndex, GraphTargetItem name) { + super(instruction, PRECEDENCE_PRIMARY); + this.multinameIndex = multinameIndex; + this.name = name; + this.namespace = null; + } - public FullMultinameTreeItem(AVM2Instruction instruction, int multinameIndex) { - super(instruction, PRECEDENCE_PRIMARY); - this.multinameIndex = multinameIndex; - this.name = null; - this.namespace = null; - } + public FullMultinameTreeItem(AVM2Instruction instruction, int multinameIndex) { + super(instruction, PRECEDENCE_PRIMARY); + this.multinameIndex = multinameIndex; + this.name = null; + this.namespace = null; + } - public FullMultinameTreeItem(AVM2Instruction instruction, int multinameIndex, GraphTargetItem name, GraphTargetItem namespace) { - super(instruction, PRECEDENCE_PRIMARY); - this.multinameIndex = multinameIndex; - this.name = name; - this.namespace = namespace; - } + public FullMultinameTreeItem(AVM2Instruction instruction, int multinameIndex, GraphTargetItem name, GraphTargetItem namespace) { + super(instruction, PRECEDENCE_PRIMARY); + this.multinameIndex = multinameIndex; + this.name = name; + this.namespace = namespace; + } - public boolean isRuntime() { - return (name != null) || (namespace != null); - } + public boolean isRuntime() { + return (name != null) || (namespace != null); + } - public boolean isXML(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String cname; - if (name != null) { - cname = name.toString(constants, localRegNames, fullyQualifiedNames); - } else { - cname = (constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames)); - } - String cns = ""; - if (namespace != null) { - cns = namespace.toString(constants, localRegNames, fullyQualifiedNames); - } else { - Namespace ns = constants.constant_multiname[multinameIndex].getNamespace(constants); - if ((ns != null) && (ns.name_index != 0)) { - cns = ns.getName(constants); - } - } - return cname.equals("XML") && cns.equals(""); - } + public boolean isXML(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String cname; + if (name != null) { + cname = name.toString(constants, localRegNames, fullyQualifiedNames); + } else { + cname = (constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames)); + } + String cns = ""; + if (namespace != null) { + cns = namespace.toString(constants, localRegNames, fullyQualifiedNames); + } else { + Namespace ns = constants.constant_multiname[multinameIndex].getNamespace(constants); + if ((ns != null) && (ns.name_index != 0)) { + cns = ns.getName(constants); + } + } + return cname.equals("XML") && cns.equals(""); + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String ret = ""; - if (name != null) { - ret = "[" + name.toString(constants, localRegNames, fullyQualifiedNames) + "]"; - } else { - ret = hilight(constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames)); - } - if (namespace != null) { - ret = namespace.toString(constants, localRegNames, fullyQualifiedNames) + "::" + ret; - } else { - /*Namespace ns = constants.constant_multiname[multinameIndex].getNamespace(constants); - if ((ns != null)&&(ns.name_index!=0)) { - ret = hilight(ns.getName(constants) + "::")+ret; - }*/ - } - return ret; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String ret = ""; + if (name != null) { + ret = "[" + name.toString(constants, localRegNames, fullyQualifiedNames) + "]"; + } else { + ret = hilight(constants.constant_multiname[multinameIndex].getName(constants, fullyQualifiedNames)); + } + if (namespace != null) { + ret = namespace.toString(constants, localRegNames, fullyQualifiedNames) + "::" + ret; + } else { + /*Namespace ns = constants.constant_multiname[multinameIndex].getNamespace(constants); + if ((ns != null)&&(ns.name_index!=0)) { + ret = hilight(ns.getName(constants) + "::")+ret; + }*/ + } + return ret; + } - public boolean compareSame(FullMultinameTreeItem other) { - if (multinameIndex != other.multinameIndex) { - return false; - } - GraphTargetItem tiName = name; - while (tiName instanceof LocalRegTreeItem) { - tiName = ((LocalRegTreeItem) tiName).computedValue; - } + public boolean compareSame(FullMultinameTreeItem other) { + if (multinameIndex != other.multinameIndex) { + return false; + } + GraphTargetItem tiName = name; + while (tiName instanceof LocalRegTreeItem) { + tiName = ((LocalRegTreeItem) tiName).computedValue; + } - GraphTargetItem tiName2 = other.name; - while (tiName2 instanceof LocalRegTreeItem) { - tiName2 = ((LocalRegTreeItem) tiName2).computedValue; - } - if (tiName != tiName2) { - return false; - } + GraphTargetItem tiName2 = other.name; + while (tiName2 instanceof LocalRegTreeItem) { + tiName2 = ((LocalRegTreeItem) tiName2).computedValue; + } + if (tiName != tiName2) { + return false; + } - GraphTargetItem tiNameSpace = namespace; - while (tiNameSpace instanceof LocalRegTreeItem) { - tiNameSpace = ((LocalRegTreeItem) tiNameSpace).computedValue; - } + GraphTargetItem tiNameSpace = namespace; + while (tiNameSpace instanceof LocalRegTreeItem) { + tiNameSpace = ((LocalRegTreeItem) tiNameSpace).computedValue; + } - GraphTargetItem tiNameSpace2 = other.namespace; - while (tiNameSpace2 instanceof LocalRegTreeItem) { - tiNameSpace2 = ((LocalRegTreeItem) tiNameSpace2).computedValue; - } - if (tiNameSpace != tiNameSpace2) { - return false; - } - return true; - } + GraphTargetItem tiNameSpace2 = other.namespace; + while (tiNameSpace2 instanceof LocalRegTreeItem) { + tiNameSpace2 = ((LocalRegTreeItem) tiNameSpace2).computedValue; + } + if (tiNameSpace != tiNameSpace2) { + return false; + } + return true; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetDescendantsTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetDescendantsTreeItem.java index 227b3a7da..1cf7cc82e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetDescendantsTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetDescendantsTreeItem.java @@ -24,17 +24,17 @@ import java.util.List; public class GetDescendantsTreeItem extends TreeItem { - public GraphTargetItem object; - public FullMultinameTreeItem multiname; + public GraphTargetItem object; + public FullMultinameTreeItem multiname; - public GetDescendantsTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem multiname) { - super(instruction, PRECEDENCE_PRIMARY); - this.object = object; - this.multiname = multiname; - } + public GetDescendantsTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem multiname) { + super(instruction, PRECEDENCE_PRIMARY); + this.object = object; + this.multiname = multiname; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return object.toString(constants, localRegNames, fullyQualifiedNames) + hilight("..") + multiname.toString(constants, localRegNames, fullyQualifiedNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return object.toString(constants, localRegNames, fullyQualifiedNames) + hilight("..") + multiname.toString(constants, localRegNames, fullyQualifiedNames); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetLexTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetLexTreeItem.java index b0aceb836..614de7152 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetLexTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetLexTreeItem.java @@ -24,15 +24,15 @@ import java.util.List; public class GetLexTreeItem extends TreeItem { - public Multiname propertyName; + public Multiname propertyName; - public GetLexTreeItem(AVM2Instruction instruction, Multiname propertyName) { - super(instruction, PRECEDENCE_PRIMARY); - this.propertyName = propertyName; - } + public GetLexTreeItem(AVM2Instruction instruction, Multiname propertyName) { + super(instruction, PRECEDENCE_PRIMARY); + this.propertyName = propertyName; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight(propertyName.getName(constants, fullyQualifiedNames)); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight(propertyName.getName(constants, fullyQualifiedNames)); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetPropertyTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetPropertyTreeItem.java index 824004ba4..b8a09c1e5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetPropertyTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetPropertyTreeItem.java @@ -24,17 +24,17 @@ import java.util.List; public class GetPropertyTreeItem extends TreeItem { - public GraphTargetItem object; - public FullMultinameTreeItem propertyName; + public GraphTargetItem object; + public FullMultinameTreeItem propertyName; - public GetPropertyTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem propertyName) { - super(instruction, PRECEDENCE_PRIMARY); - this.object = object; - this.propertyName = propertyName; - } + public GetPropertyTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem propertyName) { + super(instruction, PRECEDENCE_PRIMARY); + this.object = object; + this.propertyName = propertyName; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return formatProperty(constants, object, propertyName, localRegNames, fullyQualifiedNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return formatProperty(constants, object, propertyName, localRegNames, fullyQualifiedNames); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetSlotTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetSlotTreeItem.java index 53748ea17..e57eca8e3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetSlotTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetSlotTreeItem.java @@ -25,18 +25,18 @@ import java.util.List; public class GetSlotTreeItem extends TreeItem { - public Multiname slotName; - public GraphTargetItem scope; + public Multiname slotName; + public GraphTargetItem scope; - public GetSlotTreeItem(AVM2Instruction instruction, GraphTargetItem scope, Multiname slotName) { - super(instruction, PRECEDENCE_PRIMARY); - this.slotName = slotName; - this.scope = scope; - } + public GetSlotTreeItem(AVM2Instruction instruction, GraphTargetItem scope, Multiname slotName) { + super(instruction, PRECEDENCE_PRIMARY); + this.slotName = slotName; + this.scope = scope; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - //scope.toString(constants)+"." - return hilight(slotName.getName(constants, fullyQualifiedNames)); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + //scope.toString(constants)+"." + return hilight(slotName.getName(constants, fullyQualifiedNames)); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetSuperTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetSuperTreeItem.java index 7af00d9db..823678b52 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetSuperTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/GetSuperTreeItem.java @@ -25,21 +25,21 @@ import java.util.List; public class GetSuperTreeItem extends TreeItem { - public GraphTargetItem object; - public FullMultinameTreeItem propertyName; + public GraphTargetItem object; + public FullMultinameTreeItem propertyName; - public GetSuperTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem propertyName) { - super(instruction, PRECEDENCE_PRIMARY); - this.object = object; - this.propertyName = propertyName; - } + public GetSuperTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem propertyName) { + super(instruction, PRECEDENCE_PRIMARY); + this.object = object; + this.propertyName = propertyName; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String calee = object.toString(constants, localRegNames, fullyQualifiedNames) + "."; - if (Highlighting.stripHilights(calee).equals("this.")) { - calee = ""; - } - return calee + hilight("super.") + propertyName.toString(constants, localRegNames, fullyQualifiedNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String calee = object.toString(constants, localRegNames, fullyQualifiedNames) + "."; + if (Highlighting.stripHilights(calee).equals("this.")) { + calee = ""; + } + return calee + hilight("super.") + propertyName.toString(constants, localRegNames, fullyQualifiedNames); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/HasNextTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/HasNextTreeItem.java index 512e4c4ea..5edb1d8f5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/HasNextTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/HasNextTreeItem.java @@ -29,17 +29,17 @@ import java.util.List; */ public class HasNextTreeItem extends TreeItem { - public GraphTargetItem object; - public GraphTargetItem collection; + public GraphTargetItem object; + public GraphTargetItem collection; - public HasNextTreeItem(AVM2Instruction instruction, GraphTargetItem object, GraphTargetItem collection) { - super(instruction, NOPRECEDENCE); - this.object = object; - this.collection = collection; - } + public HasNextTreeItem(AVM2Instruction instruction, GraphTargetItem object, GraphTargetItem collection) { + super(instruction, NOPRECEDENCE); + this.object = object; + this.collection = collection; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return collection.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + " hasNext " + object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return collection.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + " hasNext " + object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/InTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/InTreeItem.java index 7b5df5d6a..f1d3b3793 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/InTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/InTreeItem.java @@ -24,17 +24,17 @@ import java.util.List; public class InTreeItem extends TreeItem { - public GraphTargetItem object; - public GraphTargetItem collection; + public GraphTargetItem object; + public GraphTargetItem collection; - public InTreeItem(AVM2Instruction instruction, GraphTargetItem object, GraphTargetItem collection) { - super(instruction, NOPRECEDENCE); - this.object = object; - this.collection = collection; - } + public InTreeItem(AVM2Instruction instruction, GraphTargetItem object, GraphTargetItem collection) { + super(instruction, NOPRECEDENCE); + this.object = object; + this.collection = collection; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return object.toString(constants, localRegNames, fullyQualifiedNames) + hilight(" in ") + collection.toString(constants, localRegNames, fullyQualifiedNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return object.toString(constants, localRegNames, fullyQualifiedNames) + hilight(" in ") + collection.toString(constants, localRegNames, fullyQualifiedNames); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/IncLocalTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/IncLocalTreeItem.java index b09f4ce12..bf7954659 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/IncLocalTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/IncLocalTreeItem.java @@ -23,15 +23,15 @@ import java.util.List; public class IncLocalTreeItem extends TreeItem { - public int regIndex; + public int regIndex; - public IncLocalTreeItem(AVM2Instruction instruction, int regIndex) { - super(instruction, PRECEDENCE_POSTFIX); - this.regIndex = regIndex; - } + public IncLocalTreeItem(AVM2Instruction instruction, int regIndex) { + super(instruction, PRECEDENCE_POSTFIX); + this.regIndex = regIndex; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return localRegName(localRegNames, regIndex) + hilight("++"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return localRegName(localRegNames, regIndex) + hilight("++"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/IncrementTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/IncrementTreeItem.java index 33aa293c6..50a4471b3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/IncrementTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/IncrementTreeItem.java @@ -24,15 +24,15 @@ import java.util.List; public class IncrementTreeItem extends TreeItem { - public GraphTargetItem object; + public GraphTargetItem object; - public IncrementTreeItem(AVM2Instruction instruction, GraphTargetItem object) { - super(instruction, PRECEDENCE_ADDITIVE); - this.object = object; - } + public IncrementTreeItem(AVM2Instruction instruction, GraphTargetItem object) { + super(instruction, PRECEDENCE_ADDITIVE); + this.object = object; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return object.toString(constants, localRegNames, fullyQualifiedNames) + hilight("+1"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return object.toString(constants, localRegNames, fullyQualifiedNames) + hilight("+1"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/InitPropertyTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/InitPropertyTreeItem.java index 6b2786546..e0ce28c64 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/InitPropertyTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/InitPropertyTreeItem.java @@ -25,29 +25,29 @@ import java.util.List; public class InitPropertyTreeItem extends TreeItem implements SetTypeTreeItem, AssignmentTreeItem { - public GraphTargetItem object; - public FullMultinameTreeItem propertyName; - public GraphTargetItem value; + public GraphTargetItem object; + public FullMultinameTreeItem propertyName; + public GraphTargetItem value; - public InitPropertyTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem propertyName, GraphTargetItem value) { - super(instruction, PRECEDENCE_ASSIGMENT); - this.object = object; - this.propertyName = propertyName; - this.value = value; - } + public InitPropertyTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem propertyName, GraphTargetItem value) { + super(instruction, PRECEDENCE_ASSIGMENT); + this.object = object; + this.propertyName = propertyName; + this.value = value; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return formatProperty(constants, object, propertyName, localRegNames, fullyQualifiedNames) + hilight("=") + value.toString(constants, localRegNames, fullyQualifiedNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return formatProperty(constants, object, propertyName, localRegNames, fullyQualifiedNames) + hilight("=") + value.toString(constants, localRegNames, fullyQualifiedNames); + } - @Override - public GraphTargetItem getObject() { - return new GetPropertyTreeItem(instruction, object, propertyName); - } + @Override + public GraphTargetItem getObject() { + return new GetPropertyTreeItem(instruction, object, propertyName); + } - @Override - public GraphTargetItem getValue() { - return value; - } + @Override + public GraphTargetItem getValue() { + return value; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/IntegerValueTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/IntegerValueTreeItem.java index 512228250..16364d4b3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/IntegerValueTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/IntegerValueTreeItem.java @@ -23,25 +23,25 @@ import java.util.List; public class IntegerValueTreeItem extends NumberValueTreeItem { - public Long value; + public Long value; - public IntegerValueTreeItem(AVM2Instruction instruction, Long value) { - super(instruction); - this.value = value; - } + public IntegerValueTreeItem(AVM2Instruction instruction, Long value) { + super(instruction); + this.value = value; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("" + value); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight("" + value); + } - @Override - public double toNumber() { - return value; - } + @Override + public double toNumber() { + return value; + } - @Override - public boolean isCompileTime() { - return true; - } + @Override + public boolean isCompileTime() { + return true; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/LocalRegTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/LocalRegTreeItem.java index 4dfbcaae1..c3d725062 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/LocalRegTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/LocalRegTreeItem.java @@ -26,43 +26,43 @@ import java.util.List; public class LocalRegTreeItem extends TreeItem { - public int regIndex; - public GraphTargetItem computedValue; + public int regIndex; + public GraphTargetItem computedValue; - public LocalRegTreeItem(AVM2Instruction instruction, int regIndex, GraphTargetItem computedValue) { - super(instruction, PRECEDENCE_PRIMARY); - this.regIndex = regIndex; - if (computedValue == null) { - computedValue = new UndefinedTreeItem(instruction); - } - this.computedValue = computedValue; - } + public LocalRegTreeItem(AVM2Instruction instruction, int regIndex, GraphTargetItem computedValue) { + super(instruction, PRECEDENCE_PRIMARY); + this.regIndex = regIndex; + if (computedValue == null) { + computedValue = new UndefinedTreeItem(instruction); + } + this.computedValue = computedValue; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - if (computedValue instanceof FilterTreeItem) { - return computedValue.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); - } - return hilight(localRegName(localRegNames, regIndex)); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + if (computedValue instanceof FilterTreeItem) { + return computedValue.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); + } + return hilight(localRegName(localRegNames, regIndex)); + } - @Override - public GraphTargetItem getThroughRegister() { - return computedValue.getThroughRegister(); - } + @Override + public GraphTargetItem getThroughRegister() { + return computedValue.getThroughRegister(); + } - @Override - public double toNumber() { - return computedValue.toNumber(); - } + @Override + public double toNumber() { + return computedValue.toNumber(); + } - @Override - public boolean toBoolean() { - return computedValue.toBoolean(); - } + @Override + public boolean toBoolean() { + return computedValue.toBoolean(); + } - @Override - public boolean isCompileTime() { - return computedValue.isCompileTime(); - } + @Override + public boolean isCompileTime() { + return computedValue.isCompileTime(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NameSpaceTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NameSpaceTreeItem.java index c9a432ecf..838e07956 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NameSpaceTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NameSpaceTreeItem.java @@ -23,18 +23,18 @@ import java.util.List; public class NameSpaceTreeItem extends TreeItem { - public int namespaceIndex; + public int namespaceIndex; - public NameSpaceTreeItem(AVM2Instruction instruction, int namespaceIndex) { - super(instruction, NOPRECEDENCE); - this.namespaceIndex = namespaceIndex; - } + public NameSpaceTreeItem(AVM2Instruction instruction, int namespaceIndex) { + super(instruction, NOPRECEDENCE); + this.namespaceIndex = namespaceIndex; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - if (namespaceIndex == 0) { - return "*"; - } - return hilight(constants.constant_namespace[namespaceIndex].toString(constants)); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + if (namespaceIndex == 0) { + return "*"; + } + return hilight(constants.constant_namespace[namespaceIndex].toString(constants)); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NameValuePair.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NameValuePair.java index d80228e10..e63ab050a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NameValuePair.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NameValuePair.java @@ -23,20 +23,20 @@ import java.util.List; public class NameValuePair extends TreeItem { - public GraphTargetItem name; - public GraphTargetItem value; + public GraphTargetItem name; + public GraphTargetItem value; - public NameValuePair(GraphTargetItem name, GraphTargetItem value) { - super(name.src, NOPRECEDENCE); - this.name = name; - this.value = value; - } + public NameValuePair(GraphTargetItem name, GraphTargetItem value) { + super(name.src, NOPRECEDENCE); + this.name = name; + this.value = value; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - if (name instanceof StringTreeItem) { - return ((StringTreeItem) name).value + ":" + value.toString(constants, localRegNames, fullyQualifiedNames); - } - return name.toString(constants, localRegNames, fullyQualifiedNames) + ":" + value.toString(constants, localRegNames, fullyQualifiedNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + if (name instanceof StringTreeItem) { + return ((StringTreeItem) name).value + ":" + value.toString(constants, localRegNames, fullyQualifiedNames); + } + return name.toString(constants, localRegNames, fullyQualifiedNames) + ":" + value.toString(constants, localRegNames, fullyQualifiedNames); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NanTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NanTreeItem.java index d7d6692bf..8a4685749 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NanTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NanTreeItem.java @@ -23,12 +23,12 @@ import java.util.List; public class NanTreeItem extends TreeItem { - public NanTreeItem(AVM2Instruction instruction) { - super(instruction, NOPRECEDENCE); - } + public NanTreeItem(AVM2Instruction instruction) { + super(instruction, NOPRECEDENCE); + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("NaN"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight("NaN"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NewActivationTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NewActivationTreeItem.java index 949d5606f..64f92eb10 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NewActivationTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NewActivationTreeItem.java @@ -24,14 +24,14 @@ import java.util.List; public class NewActivationTreeItem extends TreeItem { - public HashMap slots = new HashMap(); + public HashMap slots = new HashMap(); - public NewActivationTreeItem(AVM2Instruction instruction) { - super(instruction, NOPRECEDENCE); - } + public NewActivationTreeItem(AVM2Instruction instruction) { + super(instruction, NOPRECEDENCE); + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("newactivation()"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight("newactivation()"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NewArrayTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NewArrayTreeItem.java index e05740b61..0dcfe9167 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NewArrayTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NewArrayTreeItem.java @@ -24,22 +24,22 @@ import java.util.List; public class NewArrayTreeItem extends TreeItem { - public List values; + public List values; - public NewArrayTreeItem(AVM2Instruction instruction, List values) { - super(instruction, PRECEDENCE_PRIMARY); - this.values = values; - } + public NewArrayTreeItem(AVM2Instruction instruction, List values) { + super(instruction, PRECEDENCE_PRIMARY); + this.values = values; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String args = ""; - for (int a = 0; a < values.size(); a++) { - if (a > 0) { - args = args + ","; - } - args = args + values.get(a).toString(constants, localRegNames, fullyQualifiedNames); - } - return hilight("[") + args + hilight("]"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String args = ""; + for (int a = 0; a < values.size(); a++) { + if (a > 0) { + args = args + ","; + } + args = args + values.get(a).toString(constants, localRegNames, fullyQualifiedNames); + } + return hilight("[") + args + hilight("]"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NewFunctionTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NewFunctionTreeItem.java index 39f25f162..b1bd32da6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NewFunctionTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NewFunctionTreeItem.java @@ -23,21 +23,21 @@ import java.util.List; public class NewFunctionTreeItem extends TreeItem { - public String paramStr; - public String returnStr; - public String functionBody; - public String functionName; + public String paramStr; + public String returnStr; + public String functionBody; + public String functionName; - public NewFunctionTreeItem(AVM2Instruction instruction, String functionName, String paramStr, String returnStr, String functionBody) { - super(instruction, PRECEDENCE_PRIMARY); - this.paramStr = paramStr; - this.returnStr = returnStr; - this.functionBody = functionBody; - this.functionName = functionName; - } + public NewFunctionTreeItem(AVM2Instruction instruction, String functionName, String paramStr, String returnStr, String functionBody) { + super(instruction, PRECEDENCE_PRIMARY); + this.paramStr = paramStr; + this.returnStr = returnStr; + this.functionBody = functionBody; + this.functionName = functionName; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("new function" + (!functionName.equals("") ? " " + functionName : "") + "(" + paramStr + "):" + returnStr + "\r\n{\r\n") + functionBody + "\r\n" + hilight("}"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight("new function" + (!functionName.equals("") ? " " + functionName : "") + "(" + paramStr + "):" + returnStr + "\r\n{\r\n") + functionBody + "\r\n" + hilight("}"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NewObjectTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NewObjectTreeItem.java index 29643fc1a..c7c2b8d64 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NewObjectTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NewObjectTreeItem.java @@ -23,22 +23,22 @@ import java.util.List; public class NewObjectTreeItem extends TreeItem { - public List pairs; + public List pairs; - public NewObjectTreeItem(AVM2Instruction instruction, List pairs) { - super(instruction, PRECEDENCE_PRIMARY); - this.pairs = pairs; - } + public NewObjectTreeItem(AVM2Instruction instruction, List pairs) { + super(instruction, PRECEDENCE_PRIMARY); + this.pairs = pairs; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String params = ""; - for (int n = 0; n < pairs.size(); n++) { - if (n > 0) { - params += ",\r\n"; - } - params += pairs.get(n).toString(constants, localRegNames, fullyQualifiedNames); - } - return hilight("{") + params + hilight("}"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String params = ""; + for (int n = 0; n < pairs.size(); n++) { + if (n > 0) { + params += ",\r\n"; + } + params += pairs.get(n).toString(constants, localRegNames, fullyQualifiedNames); + } + return hilight("{") + params + hilight("}"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NextNameTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NextNameTreeItem.java index e6fa4b4c6..f88a40720 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NextNameTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NextNameTreeItem.java @@ -29,17 +29,17 @@ import java.util.List; */ public class NextNameTreeItem extends TreeItem { - GraphTargetItem index; - GraphTargetItem obj; + GraphTargetItem index; + GraphTargetItem obj; - public NextNameTreeItem(AVM2Instruction instruction, GraphTargetItem index, GraphTargetItem obj) { - super(instruction, NOPRECEDENCE); - this.index = index; - this.obj = obj; - } + public NextNameTreeItem(AVM2Instruction instruction, GraphTargetItem index, GraphTargetItem obj) { + super(instruction, NOPRECEDENCE); + this.index = index; + this.obj = obj; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return "nextName(" + index.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "," + obj.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + ")"; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return "nextName(" + index.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "," + obj.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + ")"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NextValueTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NextValueTreeItem.java index 1f17dd590..fc9568b5d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NextValueTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NextValueTreeItem.java @@ -29,17 +29,17 @@ import java.util.List; */ public class NextValueTreeItem extends TreeItem { - GraphTargetItem index; - GraphTargetItem obj; + GraphTargetItem index; + GraphTargetItem obj; - public NextValueTreeItem(AVM2Instruction instruction, GraphTargetItem index, GraphTargetItem obj) { - super(instruction, NOPRECEDENCE); - this.index = index; - this.obj = obj; - } + public NextValueTreeItem(AVM2Instruction instruction, GraphTargetItem index, GraphTargetItem obj) { + super(instruction, NOPRECEDENCE); + this.index = index; + this.obj = obj; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return "nextValue(" + index.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "," + obj.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + ")"; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return "nextValue(" + index.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "," + obj.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + ")"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NullTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NullTreeItem.java index ff9a5a9b3..4abc4a45f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NullTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NullTreeItem.java @@ -23,27 +23,27 @@ import java.util.List; public class NullTreeItem extends TreeItem { - public NullTreeItem(AVM2Instruction instruction) { - super(instruction, PRECEDENCE_PRIMARY); - } + public NullTreeItem(AVM2Instruction instruction) { + super(instruction, PRECEDENCE_PRIMARY); + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("null"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight("null"); + } - @Override - public boolean isCompileTime() { - return true; - } + @Override + public boolean isCompileTime() { + return true; + } - @Override - public double toNumber() { - return 0; - } + @Override + public double toNumber() { + return 0; + } - @Override - public boolean toBoolean() { - return false; - } + @Override + public boolean toBoolean() { + return false; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NumberValueTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NumberValueTreeItem.java index 1f66c9e37..f866ee848 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NumberValueTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/NumberValueTreeItem.java @@ -20,7 +20,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; public abstract class NumberValueTreeItem extends TreeItem { - public NumberValueTreeItem(AVM2Instruction instruction) { - super(instruction, PRECEDENCE_PRIMARY); - } + public NumberValueTreeItem(AVM2Instruction instruction) { + super(instruction, PRECEDENCE_PRIMARY); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/PostDecrementTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/PostDecrementTreeItem.java index b33b696d2..b0a83eb75 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/PostDecrementTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/PostDecrementTreeItem.java @@ -26,15 +26,15 @@ import java.util.List; public class PostDecrementTreeItem extends TreeItem implements AssignmentTreeItem { - public GraphTargetItem object; + public GraphTargetItem object; - public PostDecrementTreeItem(AVM2Instruction instruction, GraphTargetItem object) { - super(instruction, PRECEDENCE_POSTFIX); - this.object = object; - } + public PostDecrementTreeItem(AVM2Instruction instruction, GraphTargetItem object) { + super(instruction, PRECEDENCE_POSTFIX); + this.object = object; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight("--"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight("--"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/PostIncrementTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/PostIncrementTreeItem.java index 4abc2588c..3c069b3e5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/PostIncrementTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/PostIncrementTreeItem.java @@ -26,15 +26,15 @@ import java.util.List; public class PostIncrementTreeItem extends TreeItem implements AssignmentTreeItem { - public GraphTargetItem object; + public GraphTargetItem object; - public PostIncrementTreeItem(AVM2Instruction instruction, GraphTargetItem object) { - super(instruction, PRECEDENCE_POSTFIX); - this.object = object; - } + public PostIncrementTreeItem(AVM2Instruction instruction, GraphTargetItem object) { + super(instruction, PRECEDENCE_POSTFIX); + this.object = object; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight("++"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + hilight("++"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ReturnValueTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ReturnValueTreeItem.java index 3ab2d2734..1af4a88fc 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ReturnValueTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ReturnValueTreeItem.java @@ -24,15 +24,15 @@ import java.util.List; public class ReturnValueTreeItem extends TreeItem { - public GraphTargetItem value; + public GraphTargetItem value; - public ReturnValueTreeItem(AVM2Instruction instruction, GraphTargetItem value) { - super(instruction, NOPRECEDENCE); - this.value = value; - } + public ReturnValueTreeItem(AVM2Instruction instruction, GraphTargetItem value) { + super(instruction, NOPRECEDENCE); + this.value = value; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("return ") + value.toString(constants, localRegNames, fullyQualifiedNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight("return ") + value.toString(constants, localRegNames, fullyQualifiedNames); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ReturnVoidTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ReturnVoidTreeItem.java index 1f1db2ea8..c6c147641 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ReturnVoidTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ReturnVoidTreeItem.java @@ -23,12 +23,12 @@ import java.util.List; public class ReturnVoidTreeItem extends TreeItem { - public ReturnVoidTreeItem(AVM2Instruction instruction) { - super(instruction, NOPRECEDENCE); - } + public ReturnVoidTreeItem(AVM2Instruction instruction) { + super(instruction, NOPRECEDENCE); + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("return"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight("return"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetGlobalSlotTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetGlobalSlotTreeItem.java index b258b28a8..811420df3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetGlobalSlotTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetGlobalSlotTreeItem.java @@ -24,17 +24,17 @@ import java.util.List; public class SetGlobalSlotTreeItem extends TreeItem { - public int slotId; - public GraphTargetItem value; + public int slotId; + public GraphTargetItem value; - public SetGlobalSlotTreeItem(AVM2Instruction instruction, int slotId, GraphTargetItem value) { - super(instruction, PRECEDENCE_ASSIGMENT); - this.slotId = slotId; - this.value = value; - } + public SetGlobalSlotTreeItem(AVM2Instruction instruction, int slotId, GraphTargetItem value) { + super(instruction, PRECEDENCE_ASSIGMENT); + this.slotId = slotId; + this.value = value; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("setglobalslot(" + slotId + ",") + value.toString(constants, localRegNames, fullyQualifiedNames) + hilight(")"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight("setglobalslot(" + slotId + ",") + value.toString(constants, localRegNames, fullyQualifiedNames) + hilight(")"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetLocalTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetLocalTreeItem.java index 9564e5681..7f534605f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetLocalTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetLocalTreeItem.java @@ -25,27 +25,27 @@ import java.util.List; public class SetLocalTreeItem extends TreeItem implements SetTypeTreeItem, AssignmentTreeItem { - public int regIndex; - public GraphTargetItem value; + public int regIndex; + public GraphTargetItem value; - public SetLocalTreeItem(AVM2Instruction instruction, int regIndex, GraphTargetItem value) { - super(instruction, PRECEDENCE_ASSIGMENT); - this.regIndex = regIndex; - this.value = value; - } + public SetLocalTreeItem(AVM2Instruction instruction, int regIndex, GraphTargetItem value) { + super(instruction, PRECEDENCE_ASSIGMENT); + this.regIndex = regIndex; + this.value = value; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight(localRegName(localRegNames, regIndex) + "=") + value.toString(constants, localRegNames, fullyQualifiedNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight(localRegName(localRegNames, regIndex) + "=") + value.toString(constants, localRegNames, fullyQualifiedNames); + } - @Override - public GraphTargetItem getObject() { - return new LocalRegTreeItem(instruction, regIndex, null); - } + @Override + public GraphTargetItem getObject() { + return new LocalRegTreeItem(instruction, regIndex, null); + } - @Override - public GraphTargetItem getValue() { - return value; - } + @Override + public GraphTargetItem getValue() { + return value; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetPropertyTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetPropertyTreeItem.java index e2eeced9e..1d74d3869 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetPropertyTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetPropertyTreeItem.java @@ -25,29 +25,29 @@ import java.util.List; public class SetPropertyTreeItem extends TreeItem implements SetTypeTreeItem, AssignmentTreeItem { - public GraphTargetItem object; - public FullMultinameTreeItem propertyName; - public GraphTargetItem value; + public GraphTargetItem object; + public FullMultinameTreeItem propertyName; + public GraphTargetItem value; - public SetPropertyTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem propertyName, GraphTargetItem value) { - super(instruction, PRECEDENCE_ASSIGMENT); - this.object = object; - this.propertyName = propertyName; - this.value = value; - } + public SetPropertyTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem propertyName, GraphTargetItem value) { + super(instruction, PRECEDENCE_ASSIGMENT); + this.object = object; + this.propertyName = propertyName; + this.value = value; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return formatProperty(constants, object, propertyName, localRegNames, fullyQualifiedNames) + hilight("=") + value.toString(constants, localRegNames, fullyQualifiedNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return formatProperty(constants, object, propertyName, localRegNames, fullyQualifiedNames) + hilight("=") + value.toString(constants, localRegNames, fullyQualifiedNames); + } - @Override - public GraphTargetItem getObject() { - return new GetPropertyTreeItem(instruction, object, propertyName); - } + @Override + public GraphTargetItem getObject() { + return new GetPropertyTreeItem(instruction, object, propertyName); + } - @Override - public GraphTargetItem getValue() { - return value; - } + @Override + public GraphTargetItem getValue() { + return value; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetSlotTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetSlotTreeItem.java index 1a39be474..d7dd8533f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetSlotTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetSlotTreeItem.java @@ -26,50 +26,50 @@ import java.util.List; public class SetSlotTreeItem extends TreeItem implements SetTypeTreeItem, AssignmentTreeItem { - public Multiname slotName; - public GraphTargetItem value; - public GraphTargetItem scope; + public Multiname slotName; + public GraphTargetItem value; + public GraphTargetItem scope; - public SetSlotTreeItem(AVM2Instruction instruction, GraphTargetItem scope, Multiname slotName, GraphTargetItem value) { - super(instruction, PRECEDENCE_ASSIGMENT); - this.slotName = slotName; - this.value = value; - this.scope = scope; - } + public SetSlotTreeItem(AVM2Instruction instruction, GraphTargetItem scope, Multiname slotName, GraphTargetItem value) { + super(instruction, PRECEDENCE_ASSIGMENT); + this.slotName = slotName; + this.value = value; + this.scope = scope; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return getName(constants, localRegNames, fullyQualifiedNames) + hilight("=") + value.toString(constants, localRegNames, fullyQualifiedNames); - } + return getName(constants, localRegNames, fullyQualifiedNames) + hilight("=") + value.toString(constants, localRegNames, fullyQualifiedNames); + } - public String getName(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String ret = ""; + public String getName(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String ret = ""; - /*ret = scope.toString(constants, localRegNames) + "."; - if (!(scope instanceof NewActivationTreeItem)) { - ret = scope.toString(constants, localRegNames) + "."; - } - if (scope instanceof LocalRegTreeItem) { - if (((LocalRegTreeItem) scope).computedValue != null) { - if (((LocalRegTreeItem) scope).computedValue instanceof NewActivationTreeItem) { - ret = ""; - } - } - }*/ - if (slotName == null) { - return ret + "/*UnknownSlot*/"; - } - return ret + hilight(slotName.getName(constants, fullyQualifiedNames)); - } + /*ret = scope.toString(constants, localRegNames) + "."; + if (!(scope instanceof NewActivationTreeItem)) { + ret = scope.toString(constants, localRegNames) + "."; + } + if (scope instanceof LocalRegTreeItem) { + if (((LocalRegTreeItem) scope).computedValue != null) { + if (((LocalRegTreeItem) scope).computedValue instanceof NewActivationTreeItem) { + ret = ""; + } + } + }*/ + if (slotName == null) { + return ret + "/*UnknownSlot*/"; + } + return ret + hilight(slotName.getName(constants, fullyQualifiedNames)); + } - @Override - public GraphTargetItem getObject() { - return new GetSlotTreeItem(instruction, scope, slotName); - } + @Override + public GraphTargetItem getObject() { + return new GetSlotTreeItem(instruction, scope, slotName); + } - @Override - public GraphTargetItem getValue() { - return value; - } + @Override + public GraphTargetItem getValue() { + return value; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetSuperTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetSuperTreeItem.java index e562e82db..0ce3eca84 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetSuperTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetSuperTreeItem.java @@ -25,23 +25,23 @@ import java.util.List; public class SetSuperTreeItem extends TreeItem { - public GraphTargetItem value; - public GraphTargetItem object; - public FullMultinameTreeItem propertyName; + public GraphTargetItem value; + public GraphTargetItem object; + public FullMultinameTreeItem propertyName; - public SetSuperTreeItem(AVM2Instruction instruction, GraphTargetItem value, GraphTargetItem object, FullMultinameTreeItem propertyName) { - super(instruction, PRECEDENCE_ASSIGMENT); - this.value = value; - this.object = object; - this.propertyName = propertyName; - } + public SetSuperTreeItem(AVM2Instruction instruction, GraphTargetItem value, GraphTargetItem object, FullMultinameTreeItem propertyName) { + super(instruction, PRECEDENCE_ASSIGMENT); + this.value = value; + this.object = object; + this.propertyName = propertyName; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String calee = object.toString(constants, localRegNames, fullyQualifiedNames) + "."; - if (Highlighting.stripHilights(calee).equals("this.")) { - calee = ""; - } - return calee + hilight("super.") + propertyName.toString(constants, localRegNames, fullyQualifiedNames) + hilight("=") + value.toString(constants, localRegNames, fullyQualifiedNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String calee = object.toString(constants, localRegNames, fullyQualifiedNames) + "."; + if (Highlighting.stripHilights(calee).equals("this.")) { + calee = ""; + } + return calee + hilight("super.") + propertyName.toString(constants, localRegNames, fullyQualifiedNames) + hilight("=") + value.toString(constants, localRegNames, fullyQualifiedNames); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetTypeTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetTypeTreeItem.java index c9cf072f8..9bbc7d010 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetTypeTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/SetTypeTreeItem.java @@ -24,7 +24,7 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; */ public interface SetTypeTreeItem { - public GraphTargetItem getObject(); + public GraphTargetItem getObject(); - public GraphTargetItem getValue(); + public GraphTargetItem getValue(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/StringTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/StringTreeItem.java index a37047626..5a894bbd1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/StringTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/StringTreeItem.java @@ -24,15 +24,15 @@ import java.util.List; public class StringTreeItem extends TreeItem { - public String value; + public String value; - public StringTreeItem(AVM2Instruction instruction, String value) { - super(instruction, PRECEDENCE_PRIMARY); - this.value = value; - } + public StringTreeItem(AVM2Instruction instruction, String value) { + super(instruction, PRECEDENCE_PRIMARY); + this.value = value; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("\"" + Helper.escapeString(value) + "\""); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight("\"" + Helper.escapeString(value) + "\""); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ThisTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ThisTreeItem.java index fb3354520..f3d4ce9a2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ThisTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ThisTreeItem.java @@ -23,15 +23,15 @@ import java.util.List; public class ThisTreeItem extends TreeItem { - public Multiname className; + public Multiname className; - public ThisTreeItem(Multiname className) { - super(null, PRECEDENCE_PRIMARY); - this.className = className; - } + public ThisTreeItem(Multiname className) { + super(null, PRECEDENCE_PRIMARY); + this.className = className; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return "this"; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return "this"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ThrowTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ThrowTreeItem.java index ae108e376..80f6ebad9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ThrowTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/ThrowTreeItem.java @@ -24,15 +24,15 @@ import java.util.List; public class ThrowTreeItem extends TreeItem { - public GraphTargetItem value; + public GraphTargetItem value; - public ThrowTreeItem(AVM2Instruction instruction, GraphTargetItem value) { - super(instruction, NOPRECEDENCE); - this.value = value; - } + public ThrowTreeItem(AVM2Instruction instruction, GraphTargetItem value) { + super(instruction, NOPRECEDENCE); + this.value = value; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("throw ") + value.toString(constants, localRegNames, fullyQualifiedNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight("throw ") + value.toString(constants, localRegNames, fullyQualifiedNames); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/TreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/TreeItem.java index d6031ee5f..609f3843e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/TreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/TreeItem.java @@ -27,93 +27,93 @@ import java.util.List; public abstract class TreeItem extends GraphTargetItem { - public AVM2Instruction instruction; - public boolean hidden = false; + public AVM2Instruction instruction; + public boolean hidden = false; - public TreeItem(GraphSourceItem instruction, int precedence) { - super(instruction, precedence); - } - - @Override - public String toString(List localData) { - return toString((ConstantPool) localData.get(0), (HashMap) localData.get(1), (List) localData.get(2)); - } - - public abstract String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames); - - public String toStringNoH(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return Highlighting.stripHilights(toString(constants, localRegNames, fullyQualifiedNames)); - } - - public String toStringSemicoloned(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return toString(constants, localRegNames, fullyQualifiedNames) + (needsSemicolon() ? ";" : ""); - } - - @Override - public boolean needsSemicolon() { - return true; - } - - /*public String hilight(String str) { - if (instruction == null) { - return str; + public TreeItem(GraphSourceItem instruction, int precedence) { + super(instruction, precedence); } - if (instruction.mappedOffset >= 0) { - return Highlighting.hilighOffset(str, instruction.mappedOffset); - } else { - return Highlighting.hilighOffset(str, instruction.offset); + + @Override + public String toString(List localData) { + return toString((ConstantPool) localData.get(0), (HashMap) localData.get(1), (List) localData.get(2)); } - }*/ - public boolean isFalse() { - return false; - } - public boolean isTrue() { - return false; - } + public abstract String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames); - protected String formatProperty(ConstantPool constants, GraphTargetItem object, GraphTargetItem propertyName, HashMap localRegNames, List fullyQualifiedNames) { - String obStr = object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); - if (object.precedence > PRECEDENCE_PRIMARY) { - obStr = "(" + obStr + ")"; - } - if (object instanceof LocalRegTreeItem) { - if (((LocalRegTreeItem) object).computedValue instanceof FindPropertyTreeItem) { - obStr = ""; - } - } - if (obStr.equals("")) { - return propertyName.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); - } - if (propertyName instanceof FullMultinameTreeItem) { - if (((FullMultinameTreeItem) propertyName).isRuntime()) { - return joinProperty(obStr, propertyName.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames))); - } else { - return joinProperty(obStr, ((FullMultinameTreeItem) propertyName).toString(constants, localRegNames, fullyQualifiedNames)); - } - } else { - return obStr + "[" + propertyName.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "]"; - } - } + public String toStringNoH(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return Highlighting.stripHilights(toString(constants, localRegNames, fullyQualifiedNames)); + } - private String joinProperty(String prefix, String name) { - if (prefix.endsWith(".")) { - prefix = prefix.substring(0, prefix.length() - 1); - } - if (!Highlighting.stripHilights(name).startsWith("[")) { - return prefix + "." + name; - } - return prefix + name; - } + public String toStringSemicoloned(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return toString(constants, localRegNames, fullyQualifiedNames) + (needsSemicolon() ? ";" : ""); + } - public static String localRegName(HashMap localRegNames, int reg) { - if (localRegNames.containsKey(reg)) { - return localRegNames.get(reg); - } else { - if (reg == 0) { - return "this"; - } - return "_loc" + reg + "_"; - } - } + @Override + public boolean needsSemicolon() { + return true; + } + + /*public String hilight(String str) { + if (instruction == null) { + return str; + } + if (instruction.mappedOffset >= 0) { + return Highlighting.hilighOffset(str, instruction.mappedOffset); + } else { + return Highlighting.hilighOffset(str, instruction.offset); + } + }*/ + public boolean isFalse() { + return false; + } + + public boolean isTrue() { + return false; + } + + protected String formatProperty(ConstantPool constants, GraphTargetItem object, GraphTargetItem propertyName, HashMap localRegNames, List fullyQualifiedNames) { + String obStr = object.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); + if (object.precedence > PRECEDENCE_PRIMARY) { + obStr = "(" + obStr + ")"; + } + if (object instanceof LocalRegTreeItem) { + if (((LocalRegTreeItem) object).computedValue instanceof FindPropertyTreeItem) { + obStr = ""; + } + } + if (obStr.equals("")) { + return propertyName.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); + } + if (propertyName instanceof FullMultinameTreeItem) { + if (((FullMultinameTreeItem) propertyName).isRuntime()) { + return joinProperty(obStr, propertyName.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames))); + } else { + return joinProperty(obStr, ((FullMultinameTreeItem) propertyName).toString(constants, localRegNames, fullyQualifiedNames)); + } + } else { + return obStr + "[" + propertyName.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "]"; + } + } + + private String joinProperty(String prefix, String name) { + if (prefix.endsWith(".")) { + prefix = prefix.substring(0, prefix.length() - 1); + } + if (!Highlighting.stripHilights(name).startsWith("[")) { + return prefix + "." + name; + } + return prefix + name; + } + + public static String localRegName(HashMap localRegNames, int reg) { + if (localRegNames.containsKey(reg)) { + return localRegNames.get(reg); + } else { + if (reg == 0) { + return "this"; + } + return "_loc" + reg + "_"; + } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/UndefinedTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/UndefinedTreeItem.java index 26096134e..fd4aea794 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/UndefinedTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/UndefinedTreeItem.java @@ -23,12 +23,12 @@ import java.util.List; public class UndefinedTreeItem extends TreeItem { - public UndefinedTreeItem(AVM2Instruction instruction) { - super(instruction, PRECEDENCE_PRIMARY); - } + public UndefinedTreeItem(AVM2Instruction instruction) { + super(instruction, PRECEDENCE_PRIMARY); + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("undefined"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight("undefined"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/UnparsedTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/UnparsedTreeItem.java index 24c63f83d..9fdf71928 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/UnparsedTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/UnparsedTreeItem.java @@ -23,15 +23,15 @@ import java.util.List; public class UnparsedTreeItem extends TreeItem { - public String value; + public String value; - public UnparsedTreeItem(AVM2Instruction instruction, String value) { - super(instruction, NOPRECEDENCE); - this.value = value; - } + public UnparsedTreeItem(AVM2Instruction instruction, String value) { + super(instruction, NOPRECEDENCE); + this.value = value; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return value; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return value; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/WithEndTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/WithEndTreeItem.java index 47d64e296..8f93a30a2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/WithEndTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/WithEndTreeItem.java @@ -24,20 +24,20 @@ import java.util.List; public class WithEndTreeItem extends TreeItem { - public GraphTargetItem scope; + public GraphTargetItem scope; - public WithEndTreeItem(AVM2Instruction instruction, GraphTargetItem scope) { - super(instruction, PRECEDENCE_PRIMARY); - this.scope = scope; - } + public WithEndTreeItem(AVM2Instruction instruction, GraphTargetItem scope) { + super(instruction, PRECEDENCE_PRIMARY); + this.scope = scope; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("}"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight("}"); + } - @Override - public boolean needsSemicolon() { - return false; - } + @Override + public boolean needsSemicolon() { + return false; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/WithObjectTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/WithObjectTreeItem.java index e31c30f4e..634e882c2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/WithObjectTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/WithObjectTreeItem.java @@ -24,15 +24,15 @@ import java.util.List; public class WithObjectTreeItem extends TreeItem { - public GraphTargetItem scope; + public GraphTargetItem scope; - public WithObjectTreeItem(AVM2Instruction instruction, GraphTargetItem scope) { - super(instruction, PRECEDENCE_PRIMARY); - this.scope = scope; - } + public WithObjectTreeItem(AVM2Instruction instruction, GraphTargetItem scope) { + super(instruction, PRECEDENCE_PRIMARY); + this.scope = scope; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return ""; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return ""; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/WithTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/WithTreeItem.java index e21146fd8..a58476640 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/WithTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/WithTreeItem.java @@ -25,34 +25,34 @@ import java.util.List; public class WithTreeItem extends TreeItem { - public GraphTargetItem scope; - public List items; + public GraphTargetItem scope; + public List items; - public WithTreeItem(AVM2Instruction instruction, GraphTargetItem scope, List items) { - super(instruction, NOPRECEDENCE); - this.scope = scope; - this.items = items; - } + public WithTreeItem(AVM2Instruction instruction, GraphTargetItem scope, List items) { + super(instruction, NOPRECEDENCE); + this.scope = scope; + this.items = items; + } - public WithTreeItem(AVM2Instruction instruction, GraphTargetItem scope) { - super(instruction, NOPRECEDENCE); - this.scope = scope; - this.items = new ArrayList(); - } + public WithTreeItem(AVM2Instruction instruction, GraphTargetItem scope) { + super(instruction, NOPRECEDENCE); + this.scope = scope; + this.items = new ArrayList(); + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String ret; - ret = hilight("with(") + scope.toString(constants, localRegNames, fullyQualifiedNames) + hilight(")\r\n{\r\n"); - /*for (GraphTargetItem ti : items) { - ret += ti.toString(constants, localRegNames, fullyQualifiedNames) + "\r\n"; - } - ret += hilight("}");*/ - return ret; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String ret; + ret = hilight("with(") + scope.toString(constants, localRegNames, fullyQualifiedNames) + hilight(")\r\n{\r\n"); + /*for (GraphTargetItem ti : items) { + ret += ti.toString(constants, localRegNames, fullyQualifiedNames) + "\r\n"; + } + ret += hilight("}");*/ + return ret; + } - @Override - public boolean needsSemicolon() { - return false; - } + @Override + public boolean needsSemicolon() { + return false; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/XMLTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/XMLTreeItem.java index 48a75b199..bd5a505c3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/XMLTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/XMLTreeItem.java @@ -28,23 +28,23 @@ import java.util.List; */ public class XMLTreeItem extends TreeItem { - public List parts; + public List parts; - public XMLTreeItem(AVM2Instruction instruction, List parts) { - super(instruction, NOPRECEDENCE); - this.parts = parts; - } + public XMLTreeItem(AVM2Instruction instruction, List parts) { + super(instruction, NOPRECEDENCE); + this.parts = parts; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String ret = ""; - for (GraphTargetItem part : parts) { - if (part instanceof StringTreeItem) { - ret += ((StringTreeItem) part).value; - } else { - ret += part.toString(constants, localRegNames, fullyQualifiedNames); - } - } - return ret; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String ret = ""; + for (GraphTargetItem part : parts) { + if (part instanceof StringTreeItem) { + ret += ((StringTreeItem) part).value; + } else { + ret += part.toString(constants, localRegNames, fullyQualifiedNames); + } + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/DeclarationTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/DeclarationTreeItem.java index 35dee78d7..207dd4957 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/DeclarationTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/DeclarationTreeItem.java @@ -33,36 +33,36 @@ import java.util.List; */ public class DeclarationTreeItem extends TreeItem { - public GraphTargetItem assignment; - public String type; + public GraphTargetItem assignment; + public String type; - public DeclarationTreeItem(GraphTargetItem assignment, String type) { - super(assignment.src, assignment.precedence); - this.type = type; - this.assignment = assignment; - } + public DeclarationTreeItem(GraphTargetItem assignment, String type) { + super(assignment.src, assignment.precedence); + this.type = type; + this.assignment = assignment; + } - public DeclarationTreeItem(GraphTargetItem assignment) { - this(assignment, null); - } + public DeclarationTreeItem(GraphTargetItem assignment) { + this(assignment, null); + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - if (assignment instanceof SetLocalTreeItem) { - SetLocalTreeItem lti = (SetLocalTreeItem) assignment; - String type = "*"; - if (lti.value instanceof CoerceTreeItem) { - type = ((CoerceTreeItem) lti.value).type; - } - if (lti.value instanceof ConvertTreeItem) { - type = ((ConvertTreeItem) lti.value).type; - } - return "var " + hilight(localRegName(localRegNames, lti.regIndex) + ":" + type + " = ") + lti.value.toString(constants, localRegNames, fullyQualifiedNames); - } - if (assignment instanceof SetSlotTreeItem) { - SetSlotTreeItem ssti = (SetSlotTreeItem) assignment; - return "var " + ssti.getName(constants, localRegNames, fullyQualifiedNames) + ":" + type + hilight(" = ") + ssti.value.toString(constants, localRegNames, fullyQualifiedNames); - } - return "var " + assignment.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + if (assignment instanceof SetLocalTreeItem) { + SetLocalTreeItem lti = (SetLocalTreeItem) assignment; + String type = "*"; + if (lti.value instanceof CoerceTreeItem) { + type = ((CoerceTreeItem) lti.value).type; + } + if (lti.value instanceof ConvertTreeItem) { + type = ((ConvertTreeItem) lti.value).type; + } + return "var " + hilight(localRegName(localRegNames, lti.regIndex) + ":" + type + " = ") + lti.value.toString(constants, localRegNames, fullyQualifiedNames); + } + if (assignment instanceof SetSlotTreeItem) { + SetSlotTreeItem ssti = (SetSlotTreeItem) assignment; + return "var " + ssti.getName(constants, localRegNames, fullyQualifiedNames) + ":" + type + hilight(" = ") + ssti.value.toString(constants, localRegNames, fullyQualifiedNames); + } + return "var " + assignment.toString(Helper.toList(constants, localRegNames, fullyQualifiedNames)); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ExceptionTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ExceptionTreeItem.java index 13a6cbf1b..c8556cacd 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ExceptionTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ExceptionTreeItem.java @@ -24,15 +24,15 @@ import java.util.List; public class ExceptionTreeItem extends TreeItem { - public ABCException exception; + public ABCException exception; - public ExceptionTreeItem(ABCException exception) { - super(null, NOPRECEDENCE); - this.exception = exception; - } + public ExceptionTreeItem(ABCException exception) { + super(null, NOPRECEDENCE); + this.exception = exception; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return exception.getVarName(constants, fullyQualifiedNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return exception.getVarName(constants, fullyQualifiedNames); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/FilterTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/FilterTreeItem.java index 8be6de6d7..45138303a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/FilterTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/FilterTreeItem.java @@ -29,17 +29,17 @@ import java.util.List; */ public class FilterTreeItem extends TreeItem { - public GraphTargetItem expression; - public GraphTargetItem collection; + public GraphTargetItem expression; + public GraphTargetItem collection; - public FilterTreeItem(AVM2Instruction instruction, GraphTargetItem collection, GraphTargetItem expression) { - super(instruction, NOPRECEDENCE); - this.expression = expression; - this.collection = collection; - } + public FilterTreeItem(AVM2Instruction instruction, GraphTargetItem collection, GraphTargetItem expression) { + super(instruction, NOPRECEDENCE); + this.expression = expression; + this.collection = collection; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return collection.toString(constants, localRegNames, fullyQualifiedNames) + hilight(".(") + expression.toString(constants, localRegNames, fullyQualifiedNames) + hilight(")"); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return collection.toString(constants, localRegNames, fullyQualifiedNames) + hilight(".(") + expression.toString(constants, localRegNames, fullyQualifiedNames) + hilight(")"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ForEachInTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ForEachInTreeItem.java index 46482be01..a3354ef15 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ForEachInTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ForEachInTreeItem.java @@ -28,66 +28,66 @@ import java.util.List; public class ForEachInTreeItem extends LoopItem implements Block { - public InTreeItem expression; - public List commands; + public InTreeItem expression; + public List commands; - @Override - public List> getSubs() { - List> ret = new ArrayList>(); - ret.add(commands); - return ret; - } + @Override + public List> getSubs() { + List> ret = new ArrayList>(); + ret.add(commands); + return ret; + } - public ForEachInTreeItem(GraphSourceItem instruction, Loop loop, InTreeItem expression, List commands) { - super(instruction, loop); - if (!commands.isEmpty()) { - GraphTargetItem firstAssign = commands.get(0); - if (firstAssign instanceof SetTypeTreeItem) { - if (expression.object instanceof LocalRegTreeItem) { - if (((SetTypeTreeItem) firstAssign).getValue().getNotCoerced() instanceof LocalRegTreeItem) { - if (((LocalRegTreeItem) ((SetTypeTreeItem) firstAssign).getValue().getNotCoerced()).regIndex == ((LocalRegTreeItem) expression.object).regIndex) { - commands.remove(0); - expression.object = ((SetTypeTreeItem) firstAssign).getObject(); - } - } + public ForEachInTreeItem(GraphSourceItem instruction, Loop loop, InTreeItem expression, List commands) { + super(instruction, loop); + if (!commands.isEmpty()) { + GraphTargetItem firstAssign = commands.get(0); + if (firstAssign instanceof SetTypeTreeItem) { + if (expression.object instanceof LocalRegTreeItem) { + if (((SetTypeTreeItem) firstAssign).getValue().getNotCoerced() instanceof LocalRegTreeItem) { + if (((LocalRegTreeItem) ((SetTypeTreeItem) firstAssign).getValue().getNotCoerced()).regIndex == ((LocalRegTreeItem) expression.object).regIndex) { + commands.remove(0); + expression.object = ((SetTypeTreeItem) firstAssign).getObject(); + } + } + } + //locAssign. } - //locAssign. - } - } - this.expression = expression; - this.commands = commands; - } + } + this.expression = expression; + this.commands = commands; + } - @Override - public boolean needsSemicolon() { - return false; - } + @Override + public boolean needsSemicolon() { + return false; + } - @Override - public String toString(List localData) { - String ret = ""; - ret += "loop" + loop.id + ":\r\n"; - ret += hilight("for each (") + expression.toString(localData) + ")\r\n{\r\n"; - for (GraphTargetItem ti : commands) { - ret += ti.toStringSemicoloned(localData) + "\r\n"; - } - ret += hilight("}") + "\r\n"; - ret += ":loop" + loop.id; - return ret; - } + @Override + public String toString(List localData) { + String ret = ""; + ret += "loop" + loop.id + ":\r\n"; + ret += hilight("for each (") + expression.toString(localData) + ")\r\n{\r\n"; + for (GraphTargetItem ti : commands) { + ret += ti.toStringSemicoloned(localData) + "\r\n"; + } + ret += hilight("}") + "\r\n"; + ret += ":loop" + loop.id; + return ret; + } - @Override - public List getContinues() { - List ret = new ArrayList(); - for (GraphTargetItem ti : commands) { - if (ti instanceof ContinueItem) { - ret.add((ContinueItem) ti); - } - if (ti instanceof Block) { - ret.addAll(((Block) ti).getContinues()); - } - } - return ret; - } + @Override + public List getContinues() { + List ret = new ArrayList(); + for (GraphTargetItem ti : commands) { + if (ti instanceof ContinueItem) { + ret.add((ContinueItem) ti); + } + if (ti instanceof Block) { + ret.addAll(((Block) ti).getContinues()); + } + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ForInTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ForInTreeItem.java index dae5fb5ab..db3479f99 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ForInTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/ForInTreeItem.java @@ -28,66 +28,66 @@ import java.util.List; public class ForInTreeItem extends LoopItem implements Block { - public InTreeItem expression; - public List commands; + public InTreeItem expression; + public List commands; - @Override - public List> getSubs() { - List> ret = new ArrayList>(); - ret.add(commands); - return ret; - } + @Override + public List> getSubs() { + List> ret = new ArrayList>(); + ret.add(commands); + return ret; + } - public ForInTreeItem(GraphSourceItem instruction, Loop loop, InTreeItem expression, List commands) { - super(instruction, loop); - if (!commands.isEmpty()) { - GraphTargetItem firstAssign = commands.get(0); - if (firstAssign instanceof SetTypeTreeItem) { - if (expression.object instanceof LocalRegTreeItem) { - if (((SetTypeTreeItem) firstAssign).getValue().getNotCoerced() instanceof LocalRegTreeItem) { - if (((LocalRegTreeItem) ((SetTypeTreeItem) firstAssign).getValue().getNotCoerced()).regIndex == ((LocalRegTreeItem) expression.object).regIndex) { - commands.remove(0); - expression.object = ((SetTypeTreeItem) firstAssign).getObject(); - } - } + public ForInTreeItem(GraphSourceItem instruction, Loop loop, InTreeItem expression, List commands) { + super(instruction, loop); + if (!commands.isEmpty()) { + GraphTargetItem firstAssign = commands.get(0); + if (firstAssign instanceof SetTypeTreeItem) { + if (expression.object instanceof LocalRegTreeItem) { + if (((SetTypeTreeItem) firstAssign).getValue().getNotCoerced() instanceof LocalRegTreeItem) { + if (((LocalRegTreeItem) ((SetTypeTreeItem) firstAssign).getValue().getNotCoerced()).regIndex == ((LocalRegTreeItem) expression.object).regIndex) { + commands.remove(0); + expression.object = ((SetTypeTreeItem) firstAssign).getObject(); + } + } + } + //locAssign. } - //locAssign. - } - } - this.expression = expression; - this.commands = commands; - } + } + this.expression = expression; + this.commands = commands; + } - @Override - public boolean needsSemicolon() { - return false; - } + @Override + public boolean needsSemicolon() { + return false; + } - @Override - public String toString(List localData) { - String ret = ""; - ret += "loop" + loop.id + ":\r\n"; - ret += hilight("for (") + expression.toString(localData) + hilight(")") + "\r\n{\r\n"; - for (GraphTargetItem ti : commands) { - ret += ti.toStringSemicoloned(localData) + "\r\n"; - } - ret += hilight("}") + "\r\n"; - ret += ":loop" + loop.id; - return ret; - } + @Override + public String toString(List localData) { + String ret = ""; + ret += "loop" + loop.id + ":\r\n"; + ret += hilight("for (") + expression.toString(localData) + hilight(")") + "\r\n{\r\n"; + for (GraphTargetItem ti : commands) { + ret += ti.toStringSemicoloned(localData) + "\r\n"; + } + ret += hilight("}") + "\r\n"; + ret += ":loop" + loop.id; + return ret; + } - @Override - public List getContinues() { - List ret = new ArrayList(); - for (GraphTargetItem ti : commands) { - if (ti instanceof ContinueItem) { - ret.add((ContinueItem) ti); - } - if (ti instanceof Block) { - ret.addAll(((Block) ti).getContinues()); - } - } - return ret; - } + @Override + public List getContinues() { + List ret = new ArrayList(); + for (GraphTargetItem ti : commands) { + if (ti instanceof ContinueItem) { + ret.add((ContinueItem) ti); + } + if (ti instanceof Block) { + ret.addAll(((Block) ti).getContinues()); + } + } + return ret; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/TernarOpTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/TernarOpTreeItem.java index 9f328368d..fa2182e18 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/TernarOpTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/TernarOpTreeItem.java @@ -25,19 +25,19 @@ import java.util.List; public class TernarOpTreeItem extends TreeItem { - public GraphTargetItem expression; - public GraphTargetItem onTrue; - public GraphTargetItem onFalse; + public GraphTargetItem expression; + public GraphTargetItem onTrue; + public GraphTargetItem onFalse; - public TernarOpTreeItem(AVM2Instruction instruction, GraphTargetItem expression, GraphTargetItem onTrue, GraphTargetItem onFalse) { - super(instruction, PRECEDENCE_CONDITIONAL); - this.expression = expression; - this.onTrue = onTrue; - this.onFalse = onFalse; - } + public TernarOpTreeItem(AVM2Instruction instruction, GraphTargetItem expression, GraphTargetItem onTrue, GraphTargetItem onFalse) { + super(instruction, PRECEDENCE_CONDITIONAL); + this.expression = expression; + this.onTrue = onTrue; + this.onFalse = onFalse; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return expression.toString(constants, localRegNames, fullyQualifiedNames) + hilight("?") + onTrue.toString(constants, localRegNames, fullyQualifiedNames) + hilight(":") + onFalse.toString(constants, localRegNames, fullyQualifiedNames); - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return expression.toString(constants, localRegNames, fullyQualifiedNames) + hilight("?") + onTrue.toString(constants, localRegNames, fullyQualifiedNames) + hilight(":") + onFalse.toString(constants, localRegNames, fullyQualifiedNames); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/TryTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/TryTreeItem.java index 356602ac7..19e81f942 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/TryTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/clauses/TryTreeItem.java @@ -29,90 +29,90 @@ import java.util.List; public class TryTreeItem extends TreeItem implements Block { - public List tryCommands; - public List catchExceptions; - public List> catchCommands; - public List finallyCommands; + public List tryCommands; + public List catchExceptions; + public List> catchCommands; + public List finallyCommands; - @Override - public List> getSubs() { - List> ret = new ArrayList>(); - ret.add(tryCommands); - ret.addAll(catchCommands); - ret.add(finallyCommands); - return ret; - } + @Override + public List> getSubs() { + List> ret = new ArrayList>(); + ret.add(tryCommands); + ret.addAll(catchCommands); + ret.add(finallyCommands); + return ret; + } - public TryTreeItem(List tryCommands, List catchExceptions, List> catchCommands, List finallyCommands) { - super(null, NOPRECEDENCE); - this.tryCommands = tryCommands; - this.catchExceptions = catchExceptions; - this.catchCommands = catchCommands; - this.finallyCommands = finallyCommands; - } + public TryTreeItem(List tryCommands, List catchExceptions, List> catchCommands, List finallyCommands) { + super(null, NOPRECEDENCE); + this.tryCommands = tryCommands; + this.catchExceptions = catchExceptions; + this.catchCommands = catchCommands; + this.finallyCommands = finallyCommands; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - String ret = ""; - ret += "try\r\n{\r\n"; - for (GraphTargetItem ti : tryCommands) { - ret += ti.toStringSemicoloned(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "\r\n"; - } - ret += "}"; - for (int e = 0; e < catchExceptions.size(); e++) { - ret += "\r\ncatch(" + catchExceptions.get(e).getVarName(constants, fullyQualifiedNames) + ":" + catchExceptions.get(e).getTypeName(constants, fullyQualifiedNames) + ")\r\n{\r\n"; - List commands = catchCommands.get(e); - for (GraphTargetItem ti : commands) { + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + String ret = ""; + ret += "try\r\n{\r\n"; + for (GraphTargetItem ti : tryCommands) { ret += ti.toStringSemicoloned(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "\r\n"; - } - ret += "}"; - } - if (finallyCommands.size() > 0) { - ret += "\r\nfinally\r\n{\r\n"; - for (GraphTargetItem ti : finallyCommands) { - ret += ti.toStringSemicoloned(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "\r\n"; - } - ret += "}"; - } - return ret; - } + } + ret += "}"; + for (int e = 0; e < catchExceptions.size(); e++) { + ret += "\r\ncatch(" + catchExceptions.get(e).getVarName(constants, fullyQualifiedNames) + ":" + catchExceptions.get(e).getTypeName(constants, fullyQualifiedNames) + ")\r\n{\r\n"; + List commands = catchCommands.get(e); + for (GraphTargetItem ti : commands) { + ret += ti.toStringSemicoloned(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "\r\n"; + } + ret += "}"; + } + if (finallyCommands.size() > 0) { + ret += "\r\nfinally\r\n{\r\n"; + for (GraphTargetItem ti : finallyCommands) { + ret += ti.toStringSemicoloned(Helper.toList(constants, localRegNames, fullyQualifiedNames)) + "\r\n"; + } + ret += "}"; + } + return ret; + } - @Override - public List getContinues() { - List ret = new ArrayList(); - for (GraphTargetItem ti : tryCommands) { - if (ti instanceof ContinueItem) { - ret.add((ContinueItem) ti); - } - if (ti instanceof Block) { - ret.addAll(((Block) ti).getContinues()); - } - } - if (finallyCommands != null) { - for (GraphTargetItem ti : finallyCommands) { + @Override + public List getContinues() { + List ret = new ArrayList(); + for (GraphTargetItem ti : tryCommands) { if (ti instanceof ContinueItem) { - ret.add((ContinueItem) ti); + ret.add((ContinueItem) ti); } if (ti instanceof Block) { - ret.addAll(((Block) ti).getContinues()); + ret.addAll(((Block) ti).getContinues()); } - } - } - for (List commands : catchCommands) { - for (GraphTargetItem ti : commands) { - if (ti instanceof ContinueItem) { - ret.add((ContinueItem) ti); + } + if (finallyCommands != null) { + for (GraphTargetItem ti : finallyCommands) { + if (ti instanceof ContinueItem) { + ret.add((ContinueItem) ti); + } + if (ti instanceof Block) { + ret.addAll(((Block) ti).getContinues()); + } } - if (ti instanceof Block) { - ret.addAll(((Block) ti).getContinues()); + } + for (List commands : catchCommands) { + for (GraphTargetItem ti : commands) { + if (ti instanceof ContinueItem) { + ret.add((ContinueItem) ti); + } + if (ti instanceof Block) { + ret.addAll(((Block) ti).getContinues()); + } } - } - } - return ret; - } + } + return ret; + } - @Override - public boolean needsSemicolon() { - return false; - } + @Override + public boolean needsSemicolon() { + return false; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AddTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AddTreeItem.java index 06616e403..404ebbc77 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AddTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AddTreeItem.java @@ -23,29 +23,29 @@ import java.util.List; public class AddTreeItem extends BinaryOpItem { - public AddTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_ADDITIVE, leftSide, rightSide, "+"); - } + public AddTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_ADDITIVE, leftSide, rightSide, "+"); + } - @Override - public String toString(List localData) { - if (rightSide.precedence >= precedence) { - String ret = ""; - if (leftSide.precedence > precedence) { - ret += "(" + leftSide.toString(localData) + ")"; - } else { - ret += leftSide.toString(localData); - } - ret += hilight(operator); - ret += "(" + rightSide.toString(localData) + ")"; - return ret; - } else { - return super.toString(localData); - } - } + @Override + public String toString(List localData) { + if (rightSide.precedence >= precedence) { + String ret = ""; + if (leftSide.precedence > precedence) { + ret += "(" + leftSide.toString(localData) + ")"; + } else { + ret += leftSide.toString(localData); + } + ret += hilight(operator); + ret += "(" + rightSide.toString(localData) + ")"; + return ret; + } else { + return super.toString(localData); + } + } - @Override - public double toNumber() { - return leftSide.toNumber() + rightSide.toNumber(); - } + @Override + public double toNumber() { + return leftSide.toNumber() + rightSide.toNumber(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AndTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AndTreeItem.java index 19b06e04f..1fcf18620 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AndTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AndTreeItem.java @@ -23,9 +23,9 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; public class AndTreeItem extends BinaryOpItem { - public GraphPart firstPart; + public GraphPart firstPart; - public AndTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_LOGICALAND, leftSide, rightSide, "&&"); - } + public AndTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_LOGICALAND, leftSide, rightSide, "&&"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AsTypeTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AsTypeTreeItem.java index 99cefa9a5..a96638823 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AsTypeTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/AsTypeTreeItem.java @@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; public class AsTypeTreeItem extends BinaryOpItem { - public AsTypeTreeItem(AVM2Instruction instruction, GraphTargetItem value, GraphTargetItem type) { - super(instruction, PRECEDENCE_RELATIONAL, value, type, " as "); - } + public AsTypeTreeItem(AVM2Instruction instruction, GraphTargetItem value, GraphTargetItem type) { + super(instruction, PRECEDENCE_RELATIONAL, value, type, " as "); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitAndTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitAndTreeItem.java index 873367267..a943d1bd3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitAndTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitAndTreeItem.java @@ -22,12 +22,12 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; public class BitAndTreeItem extends BinaryOpItem { - public BitAndTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_BITWISEAND, leftSide, rightSide, "&"); - } + public BitAndTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_BITWISEAND, leftSide, rightSide, "&"); + } - @Override - public double toNumber() { - return ((int) leftSide.toNumber()) & ((int) rightSide.toNumber()); - } + @Override + public double toNumber() { + return ((int) leftSide.toNumber()) & ((int) rightSide.toNumber()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitNotTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitNotTreeItem.java index f8d3d9dd3..0610d1c77 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitNotTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitNotTreeItem.java @@ -22,12 +22,12 @@ import com.jpexs.decompiler.flash.graph.UnaryOpItem; public class BitNotTreeItem extends UnaryOpItem { - public BitNotTreeItem(GraphSourceItem instruction, GraphTargetItem value) { - super(instruction, PRECEDENCE_UNARY, value, "~"); - } + public BitNotTreeItem(GraphSourceItem instruction, GraphTargetItem value) { + super(instruction, PRECEDENCE_UNARY, value, "~"); + } - @Override - public double toNumber() { - return ~((int) value.toNumber()); - } + @Override + public double toNumber() { + return ~((int) value.toNumber()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitOrTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitOrTreeItem.java index fd008c117..e7d98fd5c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitOrTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitOrTreeItem.java @@ -22,12 +22,12 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; public class BitOrTreeItem extends BinaryOpItem { - public BitOrTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_BITWISEOR, leftSide, rightSide, "|"); - } + public BitOrTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_BITWISEOR, leftSide, rightSide, "|"); + } - @Override - public double toNumber() { - return ((int) leftSide.toNumber()) | ((int) rightSide.toNumber()); - } + @Override + public double toNumber() { + return ((int) leftSide.toNumber()) | ((int) rightSide.toNumber()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitXorTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitXorTreeItem.java index 74a41c2cb..0c4bef091 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitXorTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/BitXorTreeItem.java @@ -22,12 +22,12 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; public class BitXorTreeItem extends BinaryOpItem { - public BitXorTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_BITWISEXOR, leftSide, rightSide, "^"); - } + public BitXorTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_BITWISEXOR, leftSide, rightSide, "^"); + } - @Override - public double toNumber() { - return ((int) leftSide.toNumber()) ^ ((int) rightSide.toNumber()); - } + @Override + public double toNumber() { + return ((int) leftSide.toNumber()) ^ ((int) rightSide.toNumber()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/DeletePropertyTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/DeletePropertyTreeItem.java index df88c7949..d07c7c8c2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/DeletePropertyTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/DeletePropertyTreeItem.java @@ -26,17 +26,17 @@ import java.util.List; public class DeletePropertyTreeItem extends TreeItem { - public GraphTargetItem object; - public FullMultinameTreeItem propertyName; + public GraphTargetItem object; + public FullMultinameTreeItem propertyName; - public DeletePropertyTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem propertyName) { - super(instruction, PRECEDENCE_UNARY); - this.object = object; - this.propertyName = propertyName; - } + public DeletePropertyTreeItem(AVM2Instruction instruction, GraphTargetItem object, FullMultinameTreeItem propertyName) { + super(instruction, PRECEDENCE_UNARY); + this.object = object; + this.propertyName = propertyName; + } - @Override - public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { - return hilight("delete ") + object.toString(constants, localRegNames, fullyQualifiedNames) + "[" + propertyName.toString(constants, localRegNames, fullyQualifiedNames) + "]"; - } + @Override + public String toString(ConstantPool constants, HashMap localRegNames, List fullyQualifiedNames) { + return hilight("delete ") + object.toString(constants, localRegNames, fullyQualifiedNames) + "[" + propertyName.toString(constants, localRegNames, fullyQualifiedNames) + "]"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/DivideTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/DivideTreeItem.java index 7488ebb68..66ebca0db 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/DivideTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/DivideTreeItem.java @@ -22,12 +22,12 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; public class DivideTreeItem extends BinaryOpItem { - public DivideTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "/"); - } + public DivideTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "/"); + } - @Override - public double toNumber() { - return leftSide.toNumber() / rightSide.toNumber(); - } + @Override + public double toNumber() { + return leftSide.toNumber() / rightSide.toNumber(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/EqTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/EqTreeItem.java index a9be9e1c8..98c6b91ac 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/EqTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/EqTreeItem.java @@ -23,17 +23,17 @@ import com.jpexs.decompiler.flash.graph.LogicalOpItem; public class EqTreeItem extends BinaryOpItem implements LogicalOpItem { - public EqTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "=="); - } + public EqTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "=="); + } - @Override - public boolean toBoolean() { - return (leftSide.toBoolean() == rightSide.toBoolean()) && (leftSide.toNumber() == rightSide.toNumber()); - } + @Override + public boolean toBoolean() { + return (leftSide.toBoolean() == rightSide.toBoolean()) && (leftSide.toNumber() == rightSide.toNumber()); + } - @Override - public GraphTargetItem invert() { - return new NeqTreeItem(src, leftSide, rightSide); - } + @Override + public GraphTargetItem invert() { + return new NeqTreeItem(src, leftSide, rightSide); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/GeTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/GeTreeItem.java index 8ff8960ea..0cef4175b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/GeTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/GeTreeItem.java @@ -23,17 +23,17 @@ import com.jpexs.decompiler.flash.graph.LogicalOpItem; public class GeTreeItem extends BinaryOpItem implements LogicalOpItem { - public GeTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, ">="); - } + public GeTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, ">="); + } - @Override - public GraphTargetItem invert() { - return new LtTreeItem(src, leftSide, rightSide); - } + @Override + public GraphTargetItem invert() { + return new LtTreeItem(src, leftSide, rightSide); + } - @Override - public boolean toBoolean() { - return leftSide.toNumber() >= rightSide.toNumber(); - } + @Override + public boolean toBoolean() { + return leftSide.toNumber() >= rightSide.toNumber(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/GtTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/GtTreeItem.java index 30d2d4daa..6a32d435e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/GtTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/GtTreeItem.java @@ -23,17 +23,17 @@ import com.jpexs.decompiler.flash.graph.LogicalOpItem; public class GtTreeItem extends BinaryOpItem implements LogicalOpItem { - public GtTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, ">"); - } + public GtTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, ">"); + } - @Override - public GraphTargetItem invert() { - return new LeTreeItem(src, leftSide, rightSide); - } + @Override + public GraphTargetItem invert() { + return new LeTreeItem(src, leftSide, rightSide); + } - @Override - public boolean toBoolean() { - return leftSide.toNumber() > rightSide.toNumber(); - } + @Override + public boolean toBoolean() { + return leftSide.toNumber() > rightSide.toNumber(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/InTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/InTreeItem.java index de3ddc120..78c3e99f6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/InTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/InTreeItem.java @@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; public class InTreeItem extends BinaryOpItem { - public InTreeItem(AVM2Instruction instruction, GraphTargetItem name, GraphTargetItem object) { - super(instruction, PRECEDENCE_RELATIONAL, name, object, " in "); - } + public InTreeItem(AVM2Instruction instruction, GraphTargetItem name, GraphTargetItem object) { + super(instruction, PRECEDENCE_RELATIONAL, name, object, " in "); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/InstanceOfTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/InstanceOfTreeItem.java index 899d10062..117d60a75 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/InstanceOfTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/InstanceOfTreeItem.java @@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; public class InstanceOfTreeItem extends BinaryOpItem { - public InstanceOfTreeItem(AVM2Instruction instruction, GraphTargetItem value, GraphTargetItem type) { - super(instruction, PRECEDENCE_RELATIONAL, value, type, " instanceof "); - } + public InstanceOfTreeItem(AVM2Instruction instruction, GraphTargetItem value, GraphTargetItem type) { + super(instruction, PRECEDENCE_RELATIONAL, value, type, " instanceof "); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/IsTypeTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/IsTypeTreeItem.java index 4c8d03c88..0db298af6 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/IsTypeTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/IsTypeTreeItem.java @@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; public class IsTypeTreeItem extends BinaryOpItem { - public IsTypeTreeItem(AVM2Instruction instruction, GraphTargetItem value, GraphTargetItem type) { - super(instruction, PRECEDENCE_RELATIONAL, value, type, " is "); - } + public IsTypeTreeItem(AVM2Instruction instruction, GraphTargetItem value, GraphTargetItem type) { + super(instruction, PRECEDENCE_RELATIONAL, value, type, " is "); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LShiftTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LShiftTreeItem.java index 73a979bdf..bbdb4c146 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LShiftTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LShiftTreeItem.java @@ -22,12 +22,12 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; public class LShiftTreeItem extends BinaryOpItem { - public LShiftTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, "<<"); - } + public LShiftTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, "<<"); + } - @Override - public double toNumber() { - return ((int) leftSide.toNumber()) << ((int) rightSide.toNumber()); - } + @Override + public double toNumber() { + return ((int) leftSide.toNumber()) << ((int) rightSide.toNumber()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LeTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LeTreeItem.java index 6b8677bcb..242fe7343 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LeTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LeTreeItem.java @@ -23,17 +23,17 @@ import com.jpexs.decompiler.flash.graph.LogicalOpItem; public class LeTreeItem extends BinaryOpItem implements LogicalOpItem { - public LeTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, "<="); - } + public LeTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, "<="); + } - @Override - public GraphTargetItem invert() { - return new GtTreeItem(src, leftSide, rightSide); - } + @Override + public GraphTargetItem invert() { + return new GtTreeItem(src, leftSide, rightSide); + } - @Override - public boolean toBoolean() { - return leftSide.toNumber() <= rightSide.toNumber(); - } + @Override + public boolean toBoolean() { + return leftSide.toNumber() <= rightSide.toNumber(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LtTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LtTreeItem.java index 8ad8820aa..7b83950f3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LtTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/LtTreeItem.java @@ -23,17 +23,17 @@ import com.jpexs.decompiler.flash.graph.LogicalOpItem; public class LtTreeItem extends BinaryOpItem implements LogicalOpItem { - public LtTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, "<"); - } + public LtTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_RELATIONAL, leftSide, rightSide, "<"); + } - @Override - public GraphTargetItem invert() { - return new GeTreeItem(src, leftSide, rightSide); - } + @Override + public GraphTargetItem invert() { + return new GeTreeItem(src, leftSide, rightSide); + } - @Override - public boolean toBoolean() { - return leftSide.toNumber() < rightSide.toNumber(); - } + @Override + public boolean toBoolean() { + return leftSide.toNumber() < rightSide.toNumber(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/ModuloTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/ModuloTreeItem.java index 7fab90745..81d334c6e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/ModuloTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/ModuloTreeItem.java @@ -22,12 +22,12 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; public class ModuloTreeItem extends BinaryOpItem { - public ModuloTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "%"); - } + public ModuloTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "%"); + } - @Override - public double toNumber() { - return ((int) leftSide.toNumber()) % ((int) rightSide.toNumber()); - } + @Override + public double toNumber() { + return ((int) leftSide.toNumber()) % ((int) rightSide.toNumber()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/MultiplyTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/MultiplyTreeItem.java index a1ac661ae..ea66ac1f9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/MultiplyTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/MultiplyTreeItem.java @@ -22,12 +22,12 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; public class MultiplyTreeItem extends BinaryOpItem { - public MultiplyTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "*"); - } + public MultiplyTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_MULTIPLICATIVE, leftSide, rightSide, "*"); + } - @Override - public double toNumber() { - return leftSide.toNumber() * rightSide.toNumber(); - } + @Override + public double toNumber() { + return leftSide.toNumber() * rightSide.toNumber(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/NegTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/NegTreeItem.java index 6ee1751cc..e957ea3ea 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/NegTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/NegTreeItem.java @@ -22,12 +22,12 @@ import com.jpexs.decompiler.flash.graph.UnaryOpItem; public class NegTreeItem extends UnaryOpItem { - public NegTreeItem(AVM2Instruction instruction, GraphTargetItem value) { - super(instruction, PRECEDENCE_UNARY, value, "-"); - } + public NegTreeItem(AVM2Instruction instruction, GraphTargetItem value) { + super(instruction, PRECEDENCE_UNARY, value, "-"); + } - @Override - public double toNumber() { - return -value.toNumber(); - } + @Override + public double toNumber() { + return -value.toNumber(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/NeqTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/NeqTreeItem.java index 6f6303bb0..3c1398cb4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/NeqTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/NeqTreeItem.java @@ -23,17 +23,17 @@ import com.jpexs.decompiler.flash.graph.LogicalOpItem; public class NeqTreeItem extends BinaryOpItem implements LogicalOpItem { - public NeqTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "!="); - } + public NeqTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "!="); + } - @Override - public boolean toBoolean() { - return (leftSide.toNumber() != rightSide.toNumber()) || (leftSide.toBoolean() != rightSide.toBoolean()); - } + @Override + public boolean toBoolean() { + return (leftSide.toNumber() != rightSide.toNumber()) || (leftSide.toBoolean() != rightSide.toBoolean()); + } - @Override - public GraphTargetItem invert() { - return new EqTreeItem(src, leftSide, rightSide); - } + @Override + public GraphTargetItem invert() { + return new EqTreeItem(src, leftSide, rightSide); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/OrTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/OrTreeItem.java index b5b44c503..02927cfa8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/OrTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/OrTreeItem.java @@ -23,14 +23,14 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; public class OrTreeItem extends BinaryOpItem { - public GraphPart firstPart; + public GraphPart firstPart; - public OrTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_LOGICALOR, leftSide, rightSide, "||"); - } + public OrTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_LOGICALOR, leftSide, rightSide, "||"); + } - @Override - public boolean toBoolean() { - return leftSide.toBoolean() || rightSide.toBoolean(); - } + @Override + public boolean toBoolean() { + return leftSide.toBoolean() || rightSide.toBoolean(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/PreDecrementTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/PreDecrementTreeItem.java index 5e1e0cdfa..4688377b3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/PreDecrementTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/PreDecrementTreeItem.java @@ -23,7 +23,7 @@ import com.jpexs.decompiler.flash.graph.UnaryOpItem; public class PreDecrementTreeItem extends UnaryOpItem implements AssignmentTreeItem { - public PreDecrementTreeItem(AVM2Instruction instruction, GraphTargetItem object) { - super(instruction, PRECEDENCE_UNARY, object, "--"); - } + public PreDecrementTreeItem(AVM2Instruction instruction, GraphTargetItem object) { + super(instruction, PRECEDENCE_UNARY, object, "--"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/PreIncrementTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/PreIncrementTreeItem.java index e67350d6d..68cef5952 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/PreIncrementTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/PreIncrementTreeItem.java @@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.graph.UnaryOpItem; public class PreIncrementTreeItem extends UnaryOpItem { - public PreIncrementTreeItem(AVM2Instruction instruction, GraphTargetItem object) { - super(instruction, PRECEDENCE_UNARY, object, "++"); - } + public PreIncrementTreeItem(AVM2Instruction instruction, GraphTargetItem object) { + super(instruction, PRECEDENCE_UNARY, object, "++"); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/RShiftTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/RShiftTreeItem.java index c6086e856..ef4cb077c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/RShiftTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/RShiftTreeItem.java @@ -22,12 +22,12 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; public class RShiftTreeItem extends BinaryOpItem { - public RShiftTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, ">>"); - } + public RShiftTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, ">>"); + } - @Override - public double toNumber() { - return ((int) leftSide.toNumber()) >> ((int) rightSide.toNumber()); - } + @Override + public double toNumber() { + return ((int) leftSide.toNumber()) >> ((int) rightSide.toNumber()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/StrictEqTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/StrictEqTreeItem.java index 5845b5c8d..73acbab42 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/StrictEqTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/StrictEqTreeItem.java @@ -23,17 +23,17 @@ import com.jpexs.decompiler.flash.graph.LogicalOpItem; public class StrictEqTreeItem extends BinaryOpItem implements LogicalOpItem { - public StrictEqTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "==="); - } + public StrictEqTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "==="); + } - @Override - public boolean toBoolean() { - return (leftSide.toBoolean() == rightSide.toBoolean()) && (leftSide.toNumber() == rightSide.toNumber()); - } + @Override + public boolean toBoolean() { + return (leftSide.toBoolean() == rightSide.toBoolean()) && (leftSide.toNumber() == rightSide.toNumber()); + } - @Override - public GraphTargetItem invert() { - return new StrictNeqTreeItem(src, leftSide, rightSide); - } + @Override + public GraphTargetItem invert() { + return new StrictNeqTreeItem(src, leftSide, rightSide); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/StrictNeqTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/StrictNeqTreeItem.java index e46921df1..468b4d04d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/StrictNeqTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/StrictNeqTreeItem.java @@ -23,17 +23,17 @@ import com.jpexs.decompiler.flash.graph.LogicalOpItem; public class StrictNeqTreeItem extends BinaryOpItem implements LogicalOpItem { - public StrictNeqTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "!=="); - } + public StrictNeqTreeItem(GraphSourceItem instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_EQUALITY, leftSide, rightSide, "!=="); + } - @Override - public GraphTargetItem invert() { - return new StrictEqTreeItem(src, leftSide, rightSide); - } + @Override + public GraphTargetItem invert() { + return new StrictEqTreeItem(src, leftSide, rightSide); + } - @Override - public boolean toBoolean() { - return (leftSide.toBoolean() != rightSide.toBoolean()) && (leftSide.toNumber() != rightSide.toNumber()); - } + @Override + public boolean toBoolean() { + return (leftSide.toBoolean() != rightSide.toBoolean()) && (leftSide.toNumber() != rightSide.toNumber()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/SubtractTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/SubtractTreeItem.java index 82b387216..126338e5e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/SubtractTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/SubtractTreeItem.java @@ -22,12 +22,12 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; public class SubtractTreeItem extends BinaryOpItem { - public SubtractTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_ADDITIVE, leftSide, rightSide, "-"); - } + public SubtractTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_ADDITIVE, leftSide, rightSide, "-"); + } - @Override - public double toNumber() { - return leftSide.toNumber() - rightSide.toNumber(); - } + @Override + public double toNumber() { + return leftSide.toNumber() - rightSide.toNumber(); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/TypeOfTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/TypeOfTreeItem.java index fa62db03f..e4d56bc78 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/TypeOfTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/TypeOfTreeItem.java @@ -22,7 +22,7 @@ import com.jpexs.decompiler.flash.graph.UnaryOpItem; public class TypeOfTreeItem extends UnaryOpItem { - public TypeOfTreeItem(AVM2Instruction instruction, GraphTargetItem value) { - super(instruction, PRECEDENCE_UNARY, value, "typeof "); - } + public TypeOfTreeItem(AVM2Instruction instruction, GraphTargetItem value) { + super(instruction, PRECEDENCE_UNARY, value, "typeof "); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/URShiftTreeItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/URShiftTreeItem.java index 7135da6f9..ae03ab84b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/URShiftTreeItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/avm2/treemodel/operations/URShiftTreeItem.java @@ -22,12 +22,12 @@ import com.jpexs.decompiler.flash.graph.GraphTargetItem; public class URShiftTreeItem extends BinaryOpItem { - public URShiftTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { - super(instruction, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, ">>>"); - } + public URShiftTreeItem(AVM2Instruction instruction, GraphTargetItem leftSide, GraphTargetItem rightSide) { + super(instruction, PRECEDENCE_BITWISESHIFT, leftSide, rightSide, ">>>"); + } - @Override - public double toNumber() { - return ((int) leftSide.toNumber()) >>> ((int) rightSide.toNumber()); - } + @Override + public double toNumber() { + return ((int) leftSide.toNumber()) >>> ((int) rightSide.toNumber()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCComboBoxModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCComboBoxModel.java index 34c7b1c4f..6bece613b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCComboBoxModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCComboBoxModel.java @@ -24,47 +24,47 @@ import javax.swing.event.ListDataListener; public class ABCComboBoxModel implements ComboBoxModel { - public List list; - public int itemIndex = 0; - public static final String ROOT = " - all - "; + public List list; + public int itemIndex = 0; + public static final String ROOT = " - all - "; - public ABCComboBoxModel(List list) { - this.list = list; - Collections.sort(this.list); - } + public ABCComboBoxModel(List list) { + this.list = list; + Collections.sort(this.list); + } - @Override - public int getSize() { - return 1 + list.size(); - } + @Override + public int getSize() { + return 1 + list.size(); + } - @Override - public Object getElementAt(int index) { - if (index == 0) { - return ROOT; - } - return list.get(index - 1); - } + @Override + public Object getElementAt(int index) { + if (index == 0) { + return ROOT; + } + return list.get(index - 1); + } - @Override - public void addListDataListener(ListDataListener l) { - } + @Override + public void addListDataListener(ListDataListener l) { + } - @Override - public void removeListDataListener(ListDataListener l) { - } + @Override + public void removeListDataListener(ListDataListener l) { + } - @Override - public void setSelectedItem(Object anItem) { - if (anItem == ROOT) { - itemIndex = 0; - } else { - itemIndex = 1 + list.indexOf(anItem); - } - } + @Override + public void setSelectedItem(Object anItem) { + if (anItem == ROOT) { + itemIndex = 0; + } else { + itemIndex = 1 + list.indexOf(anItem); + } + } - @Override - public Object getSelectedItem() { - return getElementAt(itemIndex); - } + @Override + public Object getSelectedItem() { + return getElementAt(itemIndex); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java index 4ef6b5685..6250788e1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ABCPanel.java @@ -39,331 +39,331 @@ import jsyntaxpane.DefaultSyntaxKit; public class ABCPanel extends JPanel implements ItemListener, ActionListener { - public TraitsList navigator; - public ClassesListTree classTree; - public ABC abc; - public List list; - public JComboBox abcComboBox; - public int listIndex = -1; - public DecompiledEditorPane decompiledTextArea; - public JScrollPane decompiledScrollPane; - public JSplitPane splitPaneDecompiledVSDetail; - public JSplitPane splitPaneTreeVSNavigator; - public JSplitPane splitPaneTreeNavVSDecompiledDetail; - private JTable constantTable; - public JComboBox constantTypeList; - public JLabel asmLabel = new JLabel("P-code source"); - public JLabel decLabel = new JLabel("ActionScript source"); - public DetailPanel detailPanel; - public JTextField filterField = new JTextField(""); - public JPanel navPanel; - public JTabbedPane tabbedPane; + public TraitsList navigator; + public ClassesListTree classTree; + public ABC abc; + public List list; + public JComboBox abcComboBox; + public int listIndex = -1; + public DecompiledEditorPane decompiledTextArea; + public JScrollPane decompiledScrollPane; + public JSplitPane splitPaneDecompiledVSDetail; + public JSplitPane splitPaneTreeVSNavigator; + public JSplitPane splitPaneTreeNavVSDecompiledDetail; + private JTable constantTable; + public JComboBox constantTypeList; + public JLabel asmLabel = new JLabel("P-code source"); + public JLabel decLabel = new JLabel("ActionScript source"); + public DetailPanel detailPanel; + public JTextField filterField = new JTextField(""); + public JPanel navPanel; + public JTabbedPane tabbedPane; - private JTable autoResizeColWidth(JTable table, TableModel model) { - table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - table.setModel(model); + private JTable autoResizeColWidth(JTable table, TableModel model) { + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + table.setModel(model); - int margin = 5; + int margin = 5; - for (int i = 0; i < table.getColumnCount(); i++) { - int vColIndex = i; - DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel(); - TableColumn col = colModel.getColumn(vColIndex); - int width; + for (int i = 0; i < table.getColumnCount(); i++) { + int vColIndex = i; + DefaultTableColumnModel colModel = (DefaultTableColumnModel) table.getColumnModel(); + TableColumn col = colModel.getColumn(vColIndex); + int width; - // Get width of column header - TableCellRenderer renderer = col.getHeaderRenderer(); + // Get width of column header + TableCellRenderer renderer = col.getHeaderRenderer(); - if (renderer == null) { - renderer = table.getTableHeader().getDefaultRenderer(); - } - - Component comp = renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false, false, 0, 0); - - width = comp.getPreferredSize().width; - - // Get maximum width of column data - for (int r = 0; r < table.getRowCount(); r++) { - renderer = table.getCellRenderer(r, vColIndex); - comp = renderer.getTableCellRendererComponent(table, table.getValueAt(r, vColIndex), false, false, - r, vColIndex); - width = Math.max(width, comp.getPreferredSize().width); - } - - // Add margin - width += 2 * margin; - - // Set the width - col.setPreferredWidth(width); - } - - ((DefaultTableCellRenderer) table.getTableHeader().getDefaultRenderer()).setHorizontalAlignment( - SwingConstants.LEFT); - - // table.setAutoCreateRowSorter(true); - table.getTableHeader().setReorderingAllowed(false); - - return table; - } - - public void setAbc(ABC abc) { - this.abc = abc; - updateConstList(); - } - - public void updateConstList() { - switch (constantTypeList.getSelectedIndex()) { - case 0: - autoResizeColWidth(constantTable, new UIntTableModel(abc)); - break; - case 1: - autoResizeColWidth(constantTable, new IntTableModel(abc)); - break; - case 2: - autoResizeColWidth(constantTable, new DoubleTableModel(abc)); - break; - case 3: - autoResizeColWidth(constantTable, new DecimalTableModel(abc)); - break; - case 4: - autoResizeColWidth(constantTable, new StringTableModel(abc)); - break; - case 5: - autoResizeColWidth(constantTable, new NamespaceTableModel(abc)); - break; - case 6: - autoResizeColWidth(constantTable, new NamespaceSetTableModel(abc)); - break; - case 7: - autoResizeColWidth(constantTable, new MultinameTableModel(abc)); - break; - } - //DefaultTableColumnModel colModel = (DefaultTableColumnModel) constantTable.getColumnModel(); - //colModel.getColumn(0).setMaxWidth(50); - } - - public void switchAbc(int index) { - listIndex = index; - if (index == -1) { - classTree.setDoABCTags(list); - } else { - List oneList = new ArrayList(); - oneList.add(list.get(index)); - this.abc = list.get(index).abc; - classTree.setDoABCTags(oneList); - } - updateConstList(); - } - - public void initSplits() { - //splitPaneTreeVSNavigator.setDividerLocation(splitPaneTreeVSNavigator.getHeight() / 2); - try { - Thread.sleep(100); - } catch (InterruptedException ex) { - Logger.getLogger(ABCPanel.class.getName()).log(Level.SEVERE, null, ex); - } - //splitPaneTreeNavVSDecompiledDetail.setDividerLocation(splitPaneTreeNavVSDecompiledDetail.getWidth() * 1 / 3); - try { - Thread.sleep(100); - } catch (InterruptedException ex) { - Logger.getLogger(ABCPanel.class.getName()).log(Level.SEVERE, null, ex); - } - splitPaneDecompiledVSDetail.setDividerLocation(splitPaneDecompiledVSDetail.getWidth() * 1 / 2); - - } - - public ABCPanel(List list) { - - - DefaultSyntaxKit.initKit(); - - this.list = list; - if (list.size() > 0) { - this.abc = list.get(0).abc; - } - setLayout(new BorderLayout()); - - - - - - - decompiledTextArea = new DecompiledEditorPane(this); - decompiledScrollPane = new JScrollPane(decompiledTextArea); - detailPanel = new DetailPanel(this); - JPanel panB = new JPanel(); - panB.setLayout(new BorderLayout()); - panB.add(decompiledScrollPane, BorderLayout.CENTER); - panB.add(decLabel, BorderLayout.NORTH); - decLabel.setHorizontalAlignment(SwingConstants.CENTER); - decLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); - splitPaneDecompiledVSDetail = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, - panB, detailPanel); - splitPaneDecompiledVSDetail.setResizeWeight(0.5); - splitPaneDecompiledVSDetail.setContinuousLayout(true); - decompiledTextArea.setContentType("text/actionscript"); - decompiledTextArea.setFont(new Font("Monospaced", Font.PLAIN, decompiledTextArea.getFont().getSize())); - - - JPanel pan2 = new JPanel(); - pan2.setLayout(new BorderLayout()); - pan2.add((abcComboBox = new JComboBox(new ABCComboBoxModel(list))), BorderLayout.NORTH); - - navigator = new TraitsList(this); - navigator.setABC(list, abc); - - - navPanel = new JPanel(new BorderLayout()); - JPanel navIconsPanel = new JPanel(); - navIconsPanel.setLayout(new BoxLayout(navIconsPanel, BoxLayout.X_AXIS)); - final JToggleButton sortButton = new JToggleButton(View.getIcon("sort16")); - sortButton.setMargin(new Insets(3, 3, 3, 3)); - navIconsPanel.add(sortButton); - navPanel.add(navIconsPanel, BorderLayout.SOUTH); - navPanel.add(new JScrollPane(navigator), BorderLayout.CENTER); - sortButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - navigator.setSorted(sortButton.isSelected()); - navigator.updateUI(); - } - }); - - Main.startWork("Building script tree..."); - - filterField.setActionCommand("FILTERSCRIPT"); - filterField.addActionListener(this); - - - filterField.getDocument().addDocumentListener(new DocumentListener() { - @Override - public void changedUpdate(DocumentEvent e) { - warn(); - } - - @Override - public void removeUpdate(DocumentEvent e) { - warn(); - } - - @Override - public void insertUpdate(DocumentEvent e) { - warn(); - } - - public void warn() { - doFilter(); - } - }); - - JPanel treePanel = new JPanel(); - treePanel.setLayout(new BorderLayout()); - treePanel.add(new JScrollPane(classTree = new ClassesListTree(list, this)), BorderLayout.CENTER); - JPanel searchPanel = new JPanel(); - searchPanel.setLayout(new BorderLayout()); - searchPanel.add(filterField, BorderLayout.CENTER); - JLabel picLabel = new JLabel(View.getIcon("search16")); - searchPanel.add(picLabel, BorderLayout.EAST); - treePanel.add(searchPanel, BorderLayout.NORTH); - - splitPaneTreeVSNavigator = new JSplitPane(JSplitPane.VERTICAL_SPLIT, - treePanel, - navPanel); - splitPaneTreeVSNavigator.setResizeWeight(0.5); - splitPaneTreeVSNavigator.setContinuousLayout(true); - tabbedPane = new JTabbedPane(); - tabbedPane.addTab("Traits", navPanel); - //tabbedPane.setTabPlacement(JTabbedPane.BOTTOM); - - //pan2.add(tabbedPane, BorderLayout.CENTER); - abcComboBox.addItemListener(this); - /* - - splitPaneTreeNavVSDecompiledDetail = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, - pan2, - splitPaneDecompiledVSDetail); - splitPaneTreeNavVSDecompiledDetail.setResizeWeight(0); - splitPaneTreeNavVSDecompiledDetail.setContinuousLayout(true); - //pan2.setPreferredSize(new Dimension(300, 200)); - - - - - - add(splitPaneTreeNavVSDecompiledDetail, BorderLayout.CENTER);*/ - add(splitPaneDecompiledVSDetail, BorderLayout.CENTER); - - JPanel panConstants = new JPanel(); - panConstants.setLayout(new BorderLayout()); - constantTypeList = new JComboBox(new String[]{"UINT", "INT", "DOUBLE", "DECIMAL", "STRING", "NAMESPACE", "NAMESPACESET", "MULTINAME"}); - constantTable = new JTable(); - if (abc != null) { - autoResizeColWidth(constantTable, new UIntTableModel(abc)); - } - constantTable.setAutoCreateRowSorter(true); - - final List inlist = list; - final ABCPanel t = this; - constantTable.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) { - if (constantTypeList.getSelectedIndex() == 7) { //MULTINAME - int rowIndex = constantTable.getSelectedRow(); - if (rowIndex == -1) { - return; - } - int multinameIndex = constantTable.convertRowIndexToModel(rowIndex); - if (multinameIndex > 0) { - UsageFrame usageFrame = new UsageFrame(inlist, abc, multinameIndex, t); - usageFrame.setVisible(true); - } - } + if (renderer == null) { + renderer = table.getTableHeader().getDefaultRenderer(); } - } - }); - constantTypeList.addItemListener(this); - panConstants.add(constantTypeList, BorderLayout.NORTH); - panConstants.add(new JScrollPane(constantTable), BorderLayout.CENTER); - tabbedPane.addTab("Constants", panConstants); - } - public void doFilter() { - classTree.applyFilter(filterField.getText()); - } + Component comp = renderer.getTableCellRendererComponent(table, col.getHeaderValue(), false, false, 0, 0); - public void reload() { - switchAbc(listIndex); - decompiledTextArea.clearScriptCache(); - decompiledTextArea.reloadClass(); - } + width = comp.getPreferredSize().width; - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getSource() == abcComboBox) { - int index = ((JComboBox) e.getSource()).getSelectedIndex(); - if (index == -1) { - return; - } - switchAbc(index - 1); - } - if (e.getSource() == constantTypeList) { - int index = ((JComboBox) e.getSource()).getSelectedIndex(); - if (index == -1) { - return; - } - updateConstList(); - } - } + // Get maximum width of column data + for (int r = 0; r < table.getRowCount(); r++) { + renderer = table.getCellRenderer(r, vColIndex); + comp = renderer.getTableCellRendererComponent(table, table.getValueAt(r, vColIndex), false, false, + r, vColIndex); + width = Math.max(width, comp.getPreferredSize().width); + } - public void display() { - setVisible(true); - } + // Add margin + width += 2 * margin; - @Override - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("FILTERSCRIPT")) { - doFilter(); - } - } + // Set the width + col.setPreferredWidth(width); + } + + ((DefaultTableCellRenderer) table.getTableHeader().getDefaultRenderer()).setHorizontalAlignment( + SwingConstants.LEFT); + + // table.setAutoCreateRowSorter(true); + table.getTableHeader().setReorderingAllowed(false); + + return table; + } + + public void setAbc(ABC abc) { + this.abc = abc; + updateConstList(); + } + + public void updateConstList() { + switch (constantTypeList.getSelectedIndex()) { + case 0: + autoResizeColWidth(constantTable, new UIntTableModel(abc)); + break; + case 1: + autoResizeColWidth(constantTable, new IntTableModel(abc)); + break; + case 2: + autoResizeColWidth(constantTable, new DoubleTableModel(abc)); + break; + case 3: + autoResizeColWidth(constantTable, new DecimalTableModel(abc)); + break; + case 4: + autoResizeColWidth(constantTable, new StringTableModel(abc)); + break; + case 5: + autoResizeColWidth(constantTable, new NamespaceTableModel(abc)); + break; + case 6: + autoResizeColWidth(constantTable, new NamespaceSetTableModel(abc)); + break; + case 7: + autoResizeColWidth(constantTable, new MultinameTableModel(abc)); + break; + } + //DefaultTableColumnModel colModel = (DefaultTableColumnModel) constantTable.getColumnModel(); + //colModel.getColumn(0).setMaxWidth(50); + } + + public void switchAbc(int index) { + listIndex = index; + if (index == -1) { + classTree.setDoABCTags(list); + } else { + List oneList = new ArrayList(); + oneList.add(list.get(index)); + this.abc = list.get(index).abc; + classTree.setDoABCTags(oneList); + } + updateConstList(); + } + + public void initSplits() { + //splitPaneTreeVSNavigator.setDividerLocation(splitPaneTreeVSNavigator.getHeight() / 2); + try { + Thread.sleep(100); + } catch (InterruptedException ex) { + Logger.getLogger(ABCPanel.class.getName()).log(Level.SEVERE, null, ex); + } + //splitPaneTreeNavVSDecompiledDetail.setDividerLocation(splitPaneTreeNavVSDecompiledDetail.getWidth() * 1 / 3); + try { + Thread.sleep(100); + } catch (InterruptedException ex) { + Logger.getLogger(ABCPanel.class.getName()).log(Level.SEVERE, null, ex); + } + splitPaneDecompiledVSDetail.setDividerLocation(splitPaneDecompiledVSDetail.getWidth() * 1 / 2); + + } + + public ABCPanel(List list) { + + + DefaultSyntaxKit.initKit(); + + this.list = list; + if (list.size() > 0) { + this.abc = list.get(0).abc; + } + setLayout(new BorderLayout()); + + + + + + + decompiledTextArea = new DecompiledEditorPane(this); + decompiledScrollPane = new JScrollPane(decompiledTextArea); + detailPanel = new DetailPanel(this); + JPanel panB = new JPanel(); + panB.setLayout(new BorderLayout()); + panB.add(decompiledScrollPane, BorderLayout.CENTER); + panB.add(decLabel, BorderLayout.NORTH); + decLabel.setHorizontalAlignment(SwingConstants.CENTER); + decLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); + splitPaneDecompiledVSDetail = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, + panB, detailPanel); + splitPaneDecompiledVSDetail.setResizeWeight(0.5); + splitPaneDecompiledVSDetail.setContinuousLayout(true); + decompiledTextArea.setContentType("text/actionscript"); + decompiledTextArea.setFont(new Font("Monospaced", Font.PLAIN, decompiledTextArea.getFont().getSize())); + + + JPanel pan2 = new JPanel(); + pan2.setLayout(new BorderLayout()); + pan2.add((abcComboBox = new JComboBox(new ABCComboBoxModel(list))), BorderLayout.NORTH); + + navigator = new TraitsList(this); + navigator.setABC(list, abc); + + + navPanel = new JPanel(new BorderLayout()); + JPanel navIconsPanel = new JPanel(); + navIconsPanel.setLayout(new BoxLayout(navIconsPanel, BoxLayout.X_AXIS)); + final JToggleButton sortButton = new JToggleButton(View.getIcon("sort16")); + sortButton.setMargin(new Insets(3, 3, 3, 3)); + navIconsPanel.add(sortButton); + navPanel.add(navIconsPanel, BorderLayout.SOUTH); + navPanel.add(new JScrollPane(navigator), BorderLayout.CENTER); + sortButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + navigator.setSorted(sortButton.isSelected()); + navigator.updateUI(); + } + }); + + Main.startWork("Building script tree..."); + + filterField.setActionCommand("FILTERSCRIPT"); + filterField.addActionListener(this); + + + filterField.getDocument().addDocumentListener(new DocumentListener() { + @Override + public void changedUpdate(DocumentEvent e) { + warn(); + } + + @Override + public void removeUpdate(DocumentEvent e) { + warn(); + } + + @Override + public void insertUpdate(DocumentEvent e) { + warn(); + } + + public void warn() { + doFilter(); + } + }); + + JPanel treePanel = new JPanel(); + treePanel.setLayout(new BorderLayout()); + treePanel.add(new JScrollPane(classTree = new ClassesListTree(list, this)), BorderLayout.CENTER); + JPanel searchPanel = new JPanel(); + searchPanel.setLayout(new BorderLayout()); + searchPanel.add(filterField, BorderLayout.CENTER); + JLabel picLabel = new JLabel(View.getIcon("search16")); + searchPanel.add(picLabel, BorderLayout.EAST); + treePanel.add(searchPanel, BorderLayout.NORTH); + + splitPaneTreeVSNavigator = new JSplitPane(JSplitPane.VERTICAL_SPLIT, + treePanel, + navPanel); + splitPaneTreeVSNavigator.setResizeWeight(0.5); + splitPaneTreeVSNavigator.setContinuousLayout(true); + tabbedPane = new JTabbedPane(); + tabbedPane.addTab("Traits", navPanel); + //tabbedPane.setTabPlacement(JTabbedPane.BOTTOM); + + //pan2.add(tabbedPane, BorderLayout.CENTER); + abcComboBox.addItemListener(this); + /* + + splitPaneTreeNavVSDecompiledDetail = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, + pan2, + splitPaneDecompiledVSDetail); + splitPaneTreeNavVSDecompiledDetail.setResizeWeight(0); + splitPaneTreeNavVSDecompiledDetail.setContinuousLayout(true); + //pan2.setPreferredSize(new Dimension(300, 200)); + + + + + + add(splitPaneTreeNavVSDecompiledDetail, BorderLayout.CENTER);*/ + add(splitPaneDecompiledVSDetail, BorderLayout.CENTER); + + JPanel panConstants = new JPanel(); + panConstants.setLayout(new BorderLayout()); + constantTypeList = new JComboBox(new String[]{"UINT", "INT", "DOUBLE", "DECIMAL", "STRING", "NAMESPACE", "NAMESPACESET", "MULTINAME"}); + constantTable = new JTable(); + if (abc != null) { + autoResizeColWidth(constantTable, new UIntTableModel(abc)); + } + constantTable.setAutoCreateRowSorter(true); + + final List inlist = list; + final ABCPanel t = this; + constantTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { + if (constantTypeList.getSelectedIndex() == 7) { //MULTINAME + int rowIndex = constantTable.getSelectedRow(); + if (rowIndex == -1) { + return; + } + int multinameIndex = constantTable.convertRowIndexToModel(rowIndex); + if (multinameIndex > 0) { + UsageFrame usageFrame = new UsageFrame(inlist, abc, multinameIndex, t); + usageFrame.setVisible(true); + } + } + } + } + }); + constantTypeList.addItemListener(this); + panConstants.add(constantTypeList, BorderLayout.NORTH); + panConstants.add(new JScrollPane(constantTable), BorderLayout.CENTER); + tabbedPane.addTab("Constants", panConstants); + } + + public void doFilter() { + classTree.applyFilter(filterField.getText()); + } + + public void reload() { + switchAbc(listIndex); + decompiledTextArea.clearScriptCache(); + decompiledTextArea.reloadClass(); + } + + @Override + public void itemStateChanged(ItemEvent e) { + if (e.getSource() == abcComboBox) { + int index = ((JComboBox) e.getSource()).getSelectedIndex(); + if (index == -1) { + return; + } + switchAbc(index - 1); + } + if (e.getSource() == constantTypeList) { + int index = ((JComboBox) e.getSource()).getSelectedIndex(); + if (index == -1) { + return; + } + updateConstList(); + } + } + + public void display() { + setVisible(true); + } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("FILTERSCRIPT")) { + doFilter(); + } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ASMSourceEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ASMSourceEditorPane.java index 7a6e34191..c309f0975 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ASMSourceEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ASMSourceEditorPane.java @@ -38,188 +38,188 @@ import javax.swing.event.CaretListener; public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretListener { - public ABC abc; - public int bodyIndex = -1; - private List disassembledHilights = new ArrayList(); - private DecompiledEditorPane decompiledEditor; - private boolean ignoreCarret = false; - private String name; - private String textWithHex = ""; - private String textNoHex = ""; - private boolean hex = false; + public ABC abc; + public int bodyIndex = -1; + private List disassembledHilights = new ArrayList(); + private DecompiledEditorPane decompiledEditor; + private boolean ignoreCarret = false; + private String name; + private String textWithHex = ""; + private String textNoHex = ""; + private boolean hex = false; - public boolean isHex() { - return hex; - } + public boolean isHex() { + return hex; + } - public void switchHex() { - setHex(!hex); - } + public void switchHex() { + setHex(!hex); + } - public void setHex(boolean hex) { - if (this.hex == hex) { - return; - } - this.hex = hex; - long oldOffset = getSelectedOffset(); - if (hex) { - setText(textWithHex); - } else { - setText(textNoHex); - } - hilighOffset(oldOffset); - } + public void setHex(boolean hex) { + if (this.hex == hex) { + return; + } + this.hex = hex; + long oldOffset = getSelectedOffset(); + if (hex) { + setText(textWithHex); + } else { + setText(textNoHex); + } + hilighOffset(oldOffset); + } - public void setIgnoreCarret(boolean ignoreCarret) { - this.ignoreCarret = ignoreCarret; - } + public void setIgnoreCarret(boolean ignoreCarret) { + this.ignoreCarret = ignoreCarret; + } - public ASMSourceEditorPane(DecompiledEditorPane decompiledEditor) { - this.decompiledEditor = decompiledEditor; - addCaretListener(this); - } + public ASMSourceEditorPane(DecompiledEditorPane decompiledEditor) { + this.decompiledEditor = decompiledEditor; + addCaretListener(this); + } - public void hilighOffset(long offset) { - if (isEditable()) { - return; - } - for (Highlighting h2 : disassembledHilights) { - if (h2.offset == offset) { - ignoreCarret = true; - setCaretPosition(h2.startPos); - getCaret().setVisible(true); - ignoreCarret = false; - break; - } - } - } - - @Override - public String getName() { - return super.getName(); - } - - public void setBodyIndex(int bodyIndex, ABC abc, String name) { - this.bodyIndex = bodyIndex; - this.abc = abc; - this.name = name; - String textWithHexTags = abc.bodies[bodyIndex].code.toASMSource(abc.constants, abc.bodies[bodyIndex], true); - textWithHex = Helper.hexToComments(textWithHexTags); - textNoHex = Helper.stripComments(textWithHexTags); - setText(hex ? textWithHex : textNoHex); - } - - public void graph() { - AVM2Graph gr = new AVM2Graph(abc.bodies[bodyIndex].code, abc, abc.bodies[bodyIndex], false, 0, new HashMap(), new Stack(), new HashMap(), new ArrayList()); - (new GraphFrame(gr, name)).setVisible(true); - } - - public void exec() { - HashMap args = new HashMap(); - args.put(0, new Object()); //object "this" - args.put(1, new Long(466561)); //param1 - Object o = abc.bodies[bodyIndex].code.execute(args, abc.constants); - JOptionPane.showMessageDialog(this, "Returned object:" + o.toString()); - } - - public boolean save(ConstantPool constants) { - try { - AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(getText().getBytes()), constants, new DialogMissingSymbolHandler(), abc.bodies[bodyIndex]); - acode.getBytes(abc.bodies[bodyIndex].codeBytes); - abc.bodies[bodyIndex].code = acode; - } catch (IOException ex) { - } catch (ParseException ex) { - JOptionPane.showMessageDialog(this, (ex.text + " on line " + ex.line)); - selectLine((int) ex.line); - return false; - } - return true; - } - - @Override - public void setText(String t) { - disassembledHilights = Highlighting.getInstrHighlights(t); - t = Highlighting.stripHilights(t); - super.setText(t); - } - - public void selectInstruction(int pos) { - String text = getText(); - int lineCnt = 1; - int lineStart = 0; - int lineEnd; - int instrCount = 0; - int dot = -2; - for (int i = 0; i < text.length(); i++) { - if (text.charAt(i) == '\n') { - - lineCnt++; - lineEnd = i; - String ins = text.substring(lineStart, lineEnd).trim(); - if (!((i > 0) && (text.charAt(i - 1) == ':'))) { - if (!ins.startsWith("exception ")) { - instrCount++; - } + public void hilighOffset(long offset) { + if (isEditable()) { + return; + } + for (Highlighting h2 : disassembledHilights) { + if (h2.offset == offset) { + ignoreCarret = true; + setCaretPosition(h2.startPos); + getCaret().setVisible(true); + ignoreCarret = false; + break; } - if (instrCount == pos + 1) { - break; + } + } + + @Override + public String getName() { + return super.getName(); + } + + public void setBodyIndex(int bodyIndex, ABC abc, String name) { + this.bodyIndex = bodyIndex; + this.abc = abc; + this.name = name; + String textWithHexTags = abc.bodies[bodyIndex].code.toASMSource(abc.constants, abc.bodies[bodyIndex], true); + textWithHex = Helper.hexToComments(textWithHexTags); + textNoHex = Helper.stripComments(textWithHexTags); + setText(hex ? textWithHex : textNoHex); + } + + public void graph() { + AVM2Graph gr = new AVM2Graph(abc.bodies[bodyIndex].code, abc, abc.bodies[bodyIndex], false, 0, new HashMap(), new Stack(), new HashMap(), new ArrayList()); + (new GraphFrame(gr, name)).setVisible(true); + } + + public void exec() { + HashMap args = new HashMap(); + args.put(0, new Object()); //object "this" + args.put(1, new Long(466561)); //param1 + Object o = abc.bodies[bodyIndex].code.execute(args, abc.constants); + JOptionPane.showMessageDialog(this, "Returned object:" + o.toString()); + } + + public boolean save(ConstantPool constants) { + try { + AVM2Code acode = ASM3Parser.parse(new ByteArrayInputStream(getText().getBytes("UTF-8")), constants, new DialogMissingSymbolHandler(), abc.bodies[bodyIndex]); + acode.getBytes(abc.bodies[bodyIndex].codeBytes); + abc.bodies[bodyIndex].code = acode; + } catch (IOException ex) { + } catch (ParseException ex) { + JOptionPane.showMessageDialog(this, (ex.text + " on line " + ex.line)); + selectLine((int) ex.line); + return false; + } + return true; + } + + @Override + public void setText(String t) { + disassembledHilights = Highlighting.getInstrHighlights(t); + t = Highlighting.stripHilights(t); + super.setText(t); + } + + public void selectInstruction(int pos) { + String text = getText(); + int lineCnt = 1; + int lineStart = 0; + int lineEnd; + int instrCount = 0; + int dot = -2; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '\n') { + + lineCnt++; + lineEnd = i; + String ins = text.substring(lineStart, lineEnd).trim(); + if (!((i > 0) && (text.charAt(i - 1) == ':'))) { + if (!ins.startsWith("exception ")) { + instrCount++; + } + } + if (instrCount == pos + 1) { + break; + } + lineStart = i + 1; } - lineStart = i + 1; - } - } - if (lineCnt == -1) { - //lineEnd = text.length() - 1; - } - //select(lineStart, lineEnd); - setCaretPosition(lineStart); - //requestFocus(); - } + } + if (lineCnt == -1) { + //lineEnd = text.length() - 1; + } + //select(lineStart, lineEnd); + setCaretPosition(lineStart); + //requestFocus(); + } - public void selectLine(int line) { - String text = getText(); - int lineCnt = 1; - int lineStart = 0; - int lineEnd = -1; - for (int i = 0; i < text.length(); i++) { - if (text.charAt(i) == '\n') { - lineCnt++; - if (lineCnt == line) { - lineStart = i; + public void selectLine(int line) { + String text = getText(); + int lineCnt = 1; + int lineStart = 0; + int lineEnd = -1; + for (int i = 0; i < text.length(); i++) { + if (text.charAt(i) == '\n') { + lineCnt++; + if (lineCnt == line) { + lineStart = i; + } + if (lineCnt == line + 1) { + lineEnd = i; + } } - if (lineCnt == line + 1) { - lineEnd = i; + } + if (lineCnt == -1) { + lineEnd = text.length() - 1; + } + select(lineStart, lineEnd); + requestFocus(); + } + + public long getSelectedOffset() { + int pos = getCaretPosition(); + Highlighting lastH = new Highlighting(0, 0, 0); + for (Highlighting h : disassembledHilights) { + if (pos < h.startPos) { + break; } - } - } - if (lineCnt == -1) { - lineEnd = text.length() - 1; - } - select(lineStart, lineEnd); - requestFocus(); - } + lastH = h; + } + return lastH.offset; + } - public long getSelectedOffset() { - int pos = getCaretPosition(); - Highlighting lastH = new Highlighting(0, 0, 0); - for (Highlighting h : disassembledHilights) { - if (pos < h.startPos) { - break; - } - lastH = h; - } - return lastH.offset; - } + @Override + public void caretUpdate(CaretEvent e) { + if (isEditable()) { + return; + } + if (ignoreCarret) { + return; + } + getCaret().setVisible(true); - @Override - public void caretUpdate(CaretEvent e) { - if (isEditable()) { - return; - } - if (ignoreCarret) { - return; - } - getCaret().setVisible(true); - - decompiledEditor.hilightOffset(getSelectedOffset()); - } + decompiledEditor.hilightOffset(getSelectedOffset()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTree.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTree.java index b8718f4e6..60f027b5c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTree.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTree.java @@ -33,124 +33,124 @@ import javax.swing.tree.TreeSelectionModel; public class ClassesListTree extends JTree implements TreeSelectionListener { - private List abcList; - public HashMap treeList; - private ABCPanel abcPanel; + private List abcList; + public HashMap treeList; + private ABCPanel abcPanel; - public void selectClass(int classIndex) { - ClassesListTreeModel model = (ClassesListTreeModel) getModel(); - TreeElement selectedElement = model.getElementByClassIndex(classIndex); - TreePath treePath = selectedElement.getTreePath(); - setSelectionPath(treePath); - scrollPathToVisible(treePath); - } + public void selectClass(int classIndex) { + ClassesListTreeModel model = (ClassesListTreeModel) getModel(); + TreeElement selectedElement = model.getElementByClassIndex(classIndex); + TreePath treePath = selectedElement.getTreePath(); + setSelectionPath(treePath); + scrollPathToVisible(treePath); + } - public ClassesListTree(List list, ABCPanel abcPanel) { - this.abcList = list; - this.treeList = getTreeList(list); - this.abcPanel = abcPanel; - setModel(new ClassesListTreeModel(this.treeList)); - addTreeSelectionListener(this); - DefaultTreeCellRenderer treeRenderer = new DefaultTreeCellRenderer(); - ClassLoader cldr = this.getClass().getClassLoader(); - treeRenderer.setLeafIcon(View.getIcon("as16")); - setCellRenderer(treeRenderer); - } + public ClassesListTree(List list, ABCPanel abcPanel) { + this.abcList = list; + this.treeList = getTreeList(list); + this.abcPanel = abcPanel; + setModel(new ClassesListTreeModel(this.treeList)); + addTreeSelectionListener(this); + DefaultTreeCellRenderer treeRenderer = new DefaultTreeCellRenderer(); + ClassLoader cldr = this.getClass().getClassLoader(); + treeRenderer.setLeafIcon(View.getIcon("as16")); + setCellRenderer(treeRenderer); + } - public List getSelectedScripts() { - TreeSelectionModel tsm = getSelectionModel(); - final List selectedScripts = new ArrayList(); - TreePath tps[] = tsm.getSelectionPaths(); - if (tps == null) { - return selectedScripts; - } - for (TreePath tp : tps) { - TreeElement te = (TreeElement) tp.getLastPathComponent(); - if (te.isLeaf()) { - Object item = te.getItem(); - if (item instanceof TreeLeafScript) { - selectedScripts.add((TreeLeafScript) item); + public List getSelectedScripts() { + TreeSelectionModel tsm = getSelectionModel(); + final List selectedScripts = new ArrayList(); + TreePath tps[] = tsm.getSelectionPaths(); + if (tps == null) { + return selectedScripts; + } + for (TreePath tp : tps) { + TreeElement te = (TreeElement) tp.getLastPathComponent(); + if (te.isLeaf()) { + Object item = te.getItem(); + if (item instanceof TreeLeafScript) { + selectedScripts.add((TreeLeafScript) item); + } + } else { + TreeVisitor tvi = new TreeVisitor() { + @Override + public void onBranch(TreeElement branch) { + } + + @Override + public void onLeaf(TreeElement leaf) { + Object item = leaf.getItem(); + if (item instanceof TreeLeafScript) { + selectedScripts.add((TreeLeafScript) item); + } + } + }; + te.visitBranches(tvi); + te.visitLeafs(tvi); } - } else { - TreeVisitor tvi = new TreeVisitor() { - @Override - public void onBranch(TreeElement branch) { - } + } + return selectedScripts; + } - @Override - public void onLeaf(TreeElement leaf) { - Object item = leaf.getItem(); - if (item instanceof TreeLeafScript) { - selectedScripts.add((TreeLeafScript) item); - } - } - }; - te.visitBranches(tvi); - te.visitLeafs(tvi); - } - } - return selectedScripts; - } + public HashMap getTreeList(List list) { + HashMap ret = new HashMap(); + for (DoABCTag tag : list) { + for (int i = 0; i < tag.abc.script_info.length; i++) { + String path = tag.abc.script_info[i].getPath(tag.abc); + ret.put(path, new TreeLeafScript(tag.abc, i)); + } + } + return ret; + } - public HashMap getTreeList(List list) { - HashMap ret = new HashMap(); - for (DoABCTag tag : list) { - for (int i = 0; i < tag.abc.script_info.length; i++) { - String path = tag.abc.script_info[i].getPath(tag.abc); - ret.put(path, new TreeLeafScript(tag.abc, i)); - } - } - return ret; - } + public void setDoABCTags(List list) { + this.abcList = list; + this.treeList = getTreeList(list); + setModel(new ClassesListTreeModel(this.treeList)); + } - public void setDoABCTags(List list) { - this.abcList = list; - this.treeList = getTreeList(list); - setModel(new ClassesListTreeModel(this.treeList)); - } + public void applyFilter(String filter) { + setModel(new ClassesListTreeModel(this.treeList, filter)); + } - public void applyFilter(String filter) { - setModel(new ClassesListTreeModel(this.treeList, filter)); - } + @Override + public void valueChanged(TreeSelectionEvent e) { + if (Main.isWorking()) { + return; + } + final TreeElement tp = (TreeElement) getLastSelectedPathComponent(); + if (tp == null) { + return; + } + Object item = tp.getItem(); + if (item instanceof TreeLeafScript) { + final TreeLeafScript scriptLeaf = (TreeLeafScript) item; - @Override - public void valueChanged(TreeSelectionEvent e) { - if (Main.isWorking()) { - return; - } - final TreeElement tp = (TreeElement) getLastSelectedPathComponent(); - if (tp == null) { - return; - } - Object item = tp.getItem(); - if (item instanceof TreeLeafScript) { - final TreeLeafScript scriptLeaf = (TreeLeafScript) item; + if (!Main.isWorking()) { + Main.startWork("Decompiling..."); + (new Thread() { + @Override + public void run() { + int classIndex = -1; + for (Trait t : scriptLeaf.abc.script_info[scriptLeaf.scriptIndex].traits.traits) { + if (t instanceof TraitClass) { + classIndex = ((TraitClass) t).class_info; + break; + } + } + abcPanel.navigator.setABC(abcList, scriptLeaf.abc); + abcPanel.navigator.setClassIndex(classIndex); + abcPanel.setAbc(scriptLeaf.abc); + abcPanel.decompiledTextArea.setScript(scriptLeaf.abc.script_info[scriptLeaf.scriptIndex], scriptLeaf.abc, abcList); + abcPanel.decompiledTextArea.setClassIndex(classIndex); + abcPanel.decompiledTextArea.setNoTrait(); + abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setCode(""); + Main.stopWork(); + } + }).start(); + } - if (!Main.isWorking()) { - Main.startWork("Decompiling..."); - (new Thread() { - @Override - public void run() { - int classIndex = -1; - for (Trait t : scriptLeaf.abc.script_info[scriptLeaf.scriptIndex].traits.traits) { - if (t instanceof TraitClass) { - classIndex = ((TraitClass) t).class_info; - break; - } - } - abcPanel.navigator.setABC(abcList, scriptLeaf.abc); - abcPanel.navigator.setClassIndex(classIndex); - abcPanel.setAbc(scriptLeaf.abc); - abcPanel.decompiledTextArea.setScript(scriptLeaf.abc.script_info[scriptLeaf.scriptIndex], scriptLeaf.abc, abcList); - abcPanel.decompiledTextArea.setClassIndex(classIndex); - abcPanel.decompiledTextArea.setNoTrait(); - abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setCode(""); - Main.stopWork(); - } - }).start(); - } + } - } - - } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTreeModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTreeModel.java index 7b4799a61..118e1a29b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTreeModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ClassesListTreeModel.java @@ -25,135 +25,135 @@ import javax.swing.tree.TreePath; class ClassIndexVisitor implements TreeVisitor { - private TreeElement found = null; - private int classIndex = 0; + private TreeElement found = null; + private int classIndex = 0; - public ClassIndexVisitor(int classIndex) { - this.classIndex = classIndex; - } + public ClassIndexVisitor(int classIndex) { + this.classIndex = classIndex; + } - @Override - public void onBranch(TreeElement branch) { - Object o = branch.getItem(); - if (o == null) { - return; - } - TreeLeafScript sc = (TreeLeafScript) o; - for (Trait t : sc.abc.script_info[sc.scriptIndex].traits.traits) { - if (t instanceof TraitClass) { - if (((TraitClass) t).class_info == classIndex) { - found = branch; - return; + @Override + public void onBranch(TreeElement branch) { + Object o = branch.getItem(); + if (o == null) { + return; + } + TreeLeafScript sc = (TreeLeafScript) o; + for (Trait t : sc.abc.script_info[sc.scriptIndex].traits.traits) { + if (t instanceof TraitClass) { + if (((TraitClass) t).class_info == classIndex) { + found = branch; + return; + } } - } - } - } + } + } - @Override - public void onLeaf(TreeElement leaf) { - Object o = leaf.getItem(); - if (o == null) { - return; - } - TreeLeafScript sc = (TreeLeafScript) o; - for (Trait t : sc.abc.script_info[sc.scriptIndex].traits.traits) { - if (t instanceof TraitClass) { - if (((TraitClass) t).class_info == classIndex) { - found = leaf; - return; + @Override + public void onLeaf(TreeElement leaf) { + Object o = leaf.getItem(); + if (o == null) { + return; + } + TreeLeafScript sc = (TreeLeafScript) o; + for (Trait t : sc.abc.script_info[sc.scriptIndex].traits.traits) { + if (t instanceof TraitClass) { + if (((TraitClass) t).class_info == classIndex) { + found = leaf; + return; + } } - } - } - } + } + } - public TreeElement getFound() { - return found; - } + public TreeElement getFound() { + return found; + } } public class ClassesListTreeModel implements TreeModel { - private Tree classTree = new Tree(); + private Tree classTree = new Tree(); - public ClassesListTreeModel(HashMap list) { - this(list, null); - } + public ClassesListTreeModel(HashMap list) { + this(list, null); + } - public ClassesListTreeModel(HashMap list, String filter) { - for (String path : list.keySet()) { - if (filter != null) { - if (!filter.equals("")) { - if (!path.contains(filter)) { - continue; - } + public ClassesListTreeModel(HashMap list, String filter) { + for (String path : list.keySet()) { + if (filter != null) { + if (!filter.equals("")) { + if (!path.contains(filter)) { + continue; + } + } } - } - String nsName = path.substring(path.lastIndexOf(".") + 1); - String packageName = path.substring(0, path.lastIndexOf(".")); - classTree.add(nsName, packageName, list.get(path)); - } + String nsName = path.substring(path.lastIndexOf(".") + 1); + String packageName = path.substring(0, path.lastIndexOf(".")); + classTree.add(nsName, packageName, list.get(path)); + } - } + } - public Object getItemByPath(String fullPath) { - TreeElement elem = classTree.get(fullPath); - if (elem == null) { - return -1; - } - return elem.getItem(); - } + public Object getItemByPath(String fullPath) { + TreeElement elem = classTree.get(fullPath); + if (elem == null) { + return -1; + } + return elem.getItem(); + } - public TreeElement getElementByClassIndex(int classIndex) { - ClassIndexVisitor civ = new ClassIndexVisitor(classIndex); - classTree.visit(civ); - return civ.getFound(); - } + public TreeElement getElementByClassIndex(int classIndex) { + ClassIndexVisitor civ = new ClassIndexVisitor(classIndex); + classTree.visit(civ); + return civ.getFound(); + } - @Override - public Object getRoot() { - return classTree.getRoot(); - } + @Override + public Object getRoot() { + return classTree.getRoot(); + } - @Override - public Object getChild(Object parent, int index) { - TreeElement pte = (TreeElement) parent; - TreeElement te = pte.getChild(index); - return te; - } + @Override + public Object getChild(Object parent, int index) { + TreeElement pte = (TreeElement) parent; + TreeElement te = pte.getChild(index); + return te; + } - @Override - public int getChildCount(Object parent) { - TreeElement te = (TreeElement) parent; - return te.getChildCount(); - } + @Override + public int getChildCount(Object parent) { + TreeElement te = (TreeElement) parent; + return te.getChildCount(); + } - @Override - public boolean isLeaf(Object node) { - TreeElement te = (TreeElement) node; - return te.isLeaf(); - } + @Override + public boolean isLeaf(Object node) { + TreeElement te = (TreeElement) node; + return te.isLeaf(); + } - @Override - public void valueForPathChanged(TreePath path, Object newValue) { - } + @Override + public void valueForPathChanged(TreePath path, Object newValue) { + } - @Override - public int getIndexOfChild(Object parent, Object child) { - TreeElement te1 = (TreeElement) parent; - TreeElement te2 = (TreeElement) child; - return te1.getIndexOfChild(te2); - } + @Override + public int getIndexOfChild(Object parent, Object child) { + TreeElement te1 = (TreeElement) parent; + TreeElement te2 = (TreeElement) child; + return te1.getIndexOfChild(te2); + } - @Override - public void addTreeModelListener(TreeModelListener l) { - } + @Override + public void addTreeModelListener(TreeModelListener l) { + } - @Override - public void removeTreeModelListener(TreeModelListener l) { - } + @Override + public void removeTreeModelListener(TreeModelListener l) { + } - @Override - public String toString() { - return "scripts"; - } + @Override + public String toString() { + return "scripts"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ConstantsListModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ConstantsListModel.java index 0f312af90..61cb29ad5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/ConstantsListModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/ConstantsListModel.java @@ -24,80 +24,80 @@ import javax.swing.event.ListDataListener; public class ConstantsListModel implements ListModel { - private ConstantPool constants; - public static final int TYPE_UINT = 0; - public static final int TYPE_INT = 1; - public static final int TYPE_DOUBLE = 2; - public static final int TYPE_DECIMAL = 3; - public static final int TYPE_STRING = 4; - public static final int TYPE_NAMESPACE = 5; - public static final int TYPE_NAMESPACESET = 6; - public static final int TYPE_MULTINAME = 7; - private int type = TYPE_INT; + private ConstantPool constants; + public static final int TYPE_UINT = 0; + public static final int TYPE_INT = 1; + public static final int TYPE_DOUBLE = 2; + public static final int TYPE_DECIMAL = 3; + public static final int TYPE_STRING = 4; + public static final int TYPE_NAMESPACE = 5; + public static final int TYPE_NAMESPACESET = 6; + public static final int TYPE_MULTINAME = 7; + private int type = TYPE_INT; - public ConstantsListModel(ConstantPool constants, int type) { - this.type = type; - this.constants = constants; - } + public ConstantsListModel(ConstantPool constants, int type) { + this.type = type; + this.constants = constants; + } - private int makeUp(int i) { - if (i < 0) { - return 0; - } - return i; - } + private int makeUp(int i) { + if (i < 0) { + return 0; + } + return i; + } - @Override - public int getSize() { - switch (type) { - case TYPE_UINT: - return makeUp(constants.constant_uint.length - 1); - case TYPE_INT: - return makeUp(constants.constant_int.length - 1); - case TYPE_DOUBLE: - return makeUp(constants.constant_double.length - 1); - case TYPE_DECIMAL: - return makeUp(constants.constant_decimal.length - 1); - case TYPE_STRING: - return makeUp(constants.constant_string.length - 1); - case TYPE_NAMESPACE: - return makeUp(constants.constant_namespace.length - 1); - case TYPE_NAMESPACESET: - return makeUp(constants.constant_namespace_set.length - 1); - case TYPE_MULTINAME: - return makeUp(constants.constant_multiname.length - 1); - } - return 0; - } + @Override + public int getSize() { + switch (type) { + case TYPE_UINT: + return makeUp(constants.constant_uint.length - 1); + case TYPE_INT: + return makeUp(constants.constant_int.length - 1); + case TYPE_DOUBLE: + return makeUp(constants.constant_double.length - 1); + case TYPE_DECIMAL: + return makeUp(constants.constant_decimal.length - 1); + case TYPE_STRING: + return makeUp(constants.constant_string.length - 1); + case TYPE_NAMESPACE: + return makeUp(constants.constant_namespace.length - 1); + case TYPE_NAMESPACESET: + return makeUp(constants.constant_namespace_set.length - 1); + case TYPE_MULTINAME: + return makeUp(constants.constant_multiname.length - 1); + } + return 0; + } - @Override - public Object getElementAt(int index) { - switch (type) { - case TYPE_UINT: - return "" + (index + 1) + ":" + constants.constant_uint[index + 1]; - case TYPE_INT: - return "" + (index + 1) + ":" + constants.constant_int[index + 1]; - case TYPE_DOUBLE: - return "" + (index + 1) + ":" + constants.constant_double[index + 1]; - case TYPE_DECIMAL: - return "" + (index + 1) + ":" + constants.constant_decimal[index + 1]; - case TYPE_STRING: - return "" + (index + 1) + ":" + Helper.escapeString(constants.constant_string[index + 1]); - case TYPE_NAMESPACE: - return "" + (index + 1) + ":" + constants.constant_namespace[index + 1].getNameWithKind(constants); - case TYPE_NAMESPACESET: - return "" + (index + 1) + ":" + constants.constant_namespace_set[index + 1].toString(constants); - case TYPE_MULTINAME: - return "" + (index + 1) + ":" + constants.constant_multiname[index + 1].toString(constants, new ArrayList()); - } - return null; - } + @Override + public Object getElementAt(int index) { + switch (type) { + case TYPE_UINT: + return "" + (index + 1) + ":" + constants.constant_uint[index + 1]; + case TYPE_INT: + return "" + (index + 1) + ":" + constants.constant_int[index + 1]; + case TYPE_DOUBLE: + return "" + (index + 1) + ":" + constants.constant_double[index + 1]; + case TYPE_DECIMAL: + return "" + (index + 1) + ":" + constants.constant_decimal[index + 1]; + case TYPE_STRING: + return "" + (index + 1) + ":" + Helper.escapeString(constants.constant_string[index + 1]); + case TYPE_NAMESPACE: + return "" + (index + 1) + ":" + constants.constant_namespace[index + 1].getNameWithKind(constants); + case TYPE_NAMESPACESET: + return "" + (index + 1) + ":" + constants.constant_namespace_set[index + 1].toString(constants); + case TYPE_MULTINAME: + return "" + (index + 1) + ":" + constants.constant_multiname[index + 1].toString(constants, new ArrayList()); + } + return null; + } - @Override - public void addListDataListener(ListDataListener l) { - } + @Override + public void addListDataListener(ListDataListener l) { + } - @Override - public void removeListDataListener(ListDataListener l) { - } + @Override + public void removeListDataListener(ListDataListener l) { + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java index 1638fa1ad..2a944d0d5 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DecompiledEditorPane.java @@ -32,293 +32,293 @@ import javax.swing.event.CaretListener; public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretListener { - private List highlights = new ArrayList(); - private List traitHighlights = new ArrayList(); - private List methodHighlights = new ArrayList(); - private List classHighlights = new ArrayList(); - private Highlighting currentMethodHighlight; - private ABC abc; - private ScriptInfo script; - public int lastTraitIndex = 0; - private boolean ignoreCarret = false; - private boolean reset = false; - private ABCPanel abcPanel; + private List highlights = new ArrayList(); + private List traitHighlights = new ArrayList(); + private List methodHighlights = new ArrayList(); + private List classHighlights = new ArrayList(); + private Highlighting currentMethodHighlight; + private ABC abc; + private ScriptInfo script; + public int lastTraitIndex = 0; + private boolean ignoreCarret = false; + private boolean reset = false; + private ABCPanel abcPanel; - public void setNoTrait() { - abcPanel.detailPanel.showCard(DetailPanel.UNSUPPORTED_TRAIT_CARD); - } + public void setNoTrait() { + abcPanel.detailPanel.showCard(DetailPanel.UNSUPPORTED_TRAIT_CARD); + } - public void hilightOffset(long offset) { - if (currentMethodHighlight == null) { - return; - } - for (Highlighting h2 : highlights) { - if ((h2.startPos >= currentMethodHighlight.startPos) && (h2.startPos + h2.len <= currentMethodHighlight.startPos + currentMethodHighlight.len)) { - if (h2.offset == offset) { - ignoreCarret = true; - try { - setCaretPosition(h2.startPos); - } catch (IllegalArgumentException ie) { - } - getCaret().setVisible(true); - ignoreCarret = false; - break; + public void hilightOffset(long offset) { + if (currentMethodHighlight == null) { + return; + } + for (Highlighting h2 : highlights) { + if ((h2.startPos >= currentMethodHighlight.startPos) && (h2.startPos + h2.len <= currentMethodHighlight.startPos + currentMethodHighlight.len)) { + if (h2.offset == offset) { + ignoreCarret = true; + try { + setCaretPosition(h2.startPos); + } catch (IllegalArgumentException ie) { + } + getCaret().setVisible(true); + ignoreCarret = false; + break; + } } - } - } - } + } + } - public void setClassIndex(int classIndex) { - this.classIndex = classIndex; - } + public void setClassIndex(int classIndex) { + this.classIndex = classIndex; + } - private boolean displayMethod(int pos, int methodIndex, String name) { - if (abc == null) { - return false; - } - int bi = abc.findBodyIndex(methodIndex); - if (bi == -1) { - return false; - } - abcPanel.detailPanel.showCard(DetailPanel.METHOD_TRAIT_CARD); - if (reset || (abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex() != bi)) { - abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abc, name); - abcPanel.detailPanel.methodTraitPanel.methodBodyParamsPanel.loadFromBody(abc.bodies[bi]); - abcPanel.detailPanel.methodTraitPanel.methodInfoPanel.load(abc.bodies[bi].method_info, abc); - abcPanel.detailPanel.setEditMode(false); - } - boolean success = false; - for (Highlighting h : highlights) { - if ((pos >= h.startPos) && (pos < h.startPos + h.len)) { - abcPanel.detailPanel.methodTraitPanel.methodCodePanel.hilighOffset(h.offset); - success = true; - //return true; - } - } - return success; - } - - public void displayClass(int classIndex) { - if (abcPanel.navigator.getClassIndex() != classIndex) { - abcPanel.navigator.setClassIndex(classIndex); - } - } - private int classIndex = -1; - - public void resetEditing() { - reset = true; - caretUpdate(null); - reset = false; - } - - @Override - public void caretUpdate(CaretEvent e) { - if (abc == null) { - return; - } - if (ignoreCarret) { - return; - } - - getCaret().setVisible(true); - int pos = getCaretPosition(); - abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setIgnoreCarret(true); - try { - classIndex = -1; - for (Highlighting cm : classHighlights) { - if ((pos >= cm.startPos) && (pos < cm.startPos + cm.len)) { - classIndex = (int) cm.offset; - displayClass(classIndex); - break; + private boolean displayMethod(int pos, int methodIndex, String name) { + if (abc == null) { + return false; + } + int bi = abc.findBodyIndex(methodIndex); + if (bi == -1) { + return false; + } + abcPanel.detailPanel.showCard(DetailPanel.METHOD_TRAIT_CARD); + if (reset || (abcPanel.detailPanel.methodTraitPanel.methodCodePanel.getBodyIndex() != bi)) { + abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setBodyIndex(bi, abc, name); + abcPanel.detailPanel.methodTraitPanel.methodBodyParamsPanel.loadFromBody(abc.bodies[bi]); + abcPanel.detailPanel.methodTraitPanel.methodInfoPanel.load(abc.bodies[bi].method_info, abc); + abcPanel.detailPanel.setEditMode(false); + } + boolean success = false; + for (Highlighting h : highlights) { + if ((pos >= h.startPos) && (pos < h.startPos + h.len)) { + abcPanel.detailPanel.methodTraitPanel.methodCodePanel.hilighOffset(h.offset); + success = true; + //return true; } - } + } + return success; + } - for (Highlighting tm : methodHighlights) { - if ((pos >= tm.startPos) && (pos < tm.startPos + tm.len)) { - String name = ""; - if (abc != null) { - name = abc.instance_info[classIndex].getName(abc.constants).getNameWithNamespace(abc.constants); - } - for (Highlighting th : traitHighlights) { - if ((pos >= th.startPos) && (pos < th.startPos + th.len)) { - lastTraitIndex = (int) th.offset; - if (abc != null) { + public void displayClass(int classIndex) { + if (abcPanel.navigator.getClassIndex() != classIndex) { + abcPanel.navigator.setClassIndex(classIndex); + } + } + private int classIndex = -1; + + public void resetEditing() { + reset = true; + caretUpdate(null); + reset = false; + } + + @Override + public void caretUpdate(CaretEvent e) { + if (abc == null) { + return; + } + if (ignoreCarret) { + return; + } + + getCaret().setVisible(true); + int pos = getCaretPosition(); + abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setIgnoreCarret(true); + try { + classIndex = -1; + for (Highlighting cm : classHighlights) { + if ((pos >= cm.startPos) && (pos < cm.startPos + cm.len)) { + classIndex = (int) cm.offset; + displayClass(classIndex); + break; + } + } + + for (Highlighting tm : methodHighlights) { + if ((pos >= tm.startPos) && (pos < tm.startPos + tm.len)) { + String name = ""; + if (abc != null) { + name = abc.instance_info[classIndex].getName(abc.constants).getNameWithNamespace(abc.constants); + } + for (Highlighting th : traitHighlights) { + if ((pos >= th.startPos) && (pos < th.startPos + th.len)) { + lastTraitIndex = (int) th.offset; + if (abc != null) { + Trait t = abc.findTraitByTraitId(classIndex, lastTraitIndex); + if (t != null) { + name += ":" + t.getName(abc).getName(abc.constants, new ArrayList()); + } + } + } + } + + displayMethod(pos, (int) tm.offset, name); + currentMethodHighlight = tm; + + + return; + } + } + + if (classIndex == -1) { + setNoTrait(); + return; + } + for (Highlighting th : traitHighlights) { + if ((pos >= th.startPos) && (pos < th.startPos + th.len)) { + lastTraitIndex = (int) th.offset; + Trait tr = abc.findTraitByTraitId(classIndex, (int) th.offset); + if (tr != null) { + if (tr instanceof TraitSlotConst) { + abcPanel.detailPanel.slotConstTraitPanel.load((TraitSlotConst) tr, abc); + abcPanel.detailPanel.showCard(DetailPanel.SLOT_CONST_TRAIT_CARD); + abcPanel.detailPanel.setEditMode(false); + return; + } + } + currentMethodHighlight = th; + String name = ""; + if (abc != null) { + name = abc.instance_info[classIndex].getName(abc.constants).getNameWithNamespace(abc.constants); Trait t = abc.findTraitByTraitId(classIndex, lastTraitIndex); if (t != null) { - name += ":" + t.getName(abc).getName(abc.constants, new ArrayList()); + name += ":" + t.getName(abc).getName(abc.constants, new ArrayList()); } - } - } - } + } - displayMethod(pos, (int) tm.offset, name); - currentMethodHighlight = tm; - - - return; + displayMethod(pos, abc.findMethodIdByTraitId(classIndex, (int) th.offset), name); + return; + } } - } - - if (classIndex == -1) { setNoTrait(); + } finally { + abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setIgnoreCarret(false); + } + } + + private class BufferedClass { + + public String text; + public List highlights; + public List traitHighlights; + public List methodHighlights; + public List classHighlights; + + public BufferedClass(String text, List highlights, List traitHighlights, List methodHighlights, List classHighlights) { + this.text = text; + this.highlights = highlights; + this.traitHighlights = traitHighlights; + this.methodHighlights = methodHighlights; + this.classHighlights = classHighlights; + } + } + private HashMap bufferedClasses = new HashMap(); + + public void gotoLastTrait() { + gotoTrait(lastTraitIndex); + } + + public void gotoTrait(int traitId) { + if (traitId == -1) { + setCaretPosition(0); return; - } - for (Highlighting th : traitHighlights) { - if ((pos >= th.startPos) && (pos < th.startPos + th.len)) { - lastTraitIndex = (int) th.offset; - Trait tr = abc.findTraitByTraitId(classIndex, (int) th.offset); - if (tr != null) { - if (tr instanceof TraitSlotConst) { - abcPanel.detailPanel.slotConstTraitPanel.load((TraitSlotConst) tr, abc); - abcPanel.detailPanel.showCard(DetailPanel.SLOT_CONST_TRAIT_CARD); - abcPanel.detailPanel.setEditMode(false); - return; - } - } - currentMethodHighlight = th; - String name = ""; - if (abc != null) { - name = abc.instance_info[classIndex].getName(abc.constants).getNameWithNamespace(abc.constants); - Trait t = abc.findTraitByTraitId(classIndex, lastTraitIndex); - if (t != null) { - name += ":" + t.getName(abc).getName(abc.constants, new ArrayList()); - } - } + } - displayMethod(pos, abc.findMethodIdByTraitId(classIndex, (int) th.offset), name); - return; - } - } - setNoTrait(); - } finally { - abcPanel.detailPanel.methodTraitPanel.methodCodePanel.setIgnoreCarret(false); - } - } - - private class BufferedClass { - - public String text; - public List highlights; - public List traitHighlights; - public List methodHighlights; - public List classHighlights; - - public BufferedClass(String text, List highlights, List traitHighlights, List methodHighlights, List classHighlights) { - this.text = text; - this.highlights = highlights; - this.traitHighlights = traitHighlights; - this.methodHighlights = methodHighlights; - this.classHighlights = classHighlights; - } - } - private HashMap bufferedClasses = new HashMap(); - - public void gotoLastTrait() { - gotoTrait(lastTraitIndex); - } - - public void gotoTrait(int traitId) { - if (traitId == -1) { - setCaretPosition(0); - return; - } - - for (Highlighting tc : classHighlights) { - if (tc.offset == classIndex) { - for (Highlighting th : traitHighlights) { - if ((th.startPos > tc.startPos) && (th.startPos + th.len < tc.startPos + tc.len)) { - if (th.offset == traitId) { - try { - ignoreCarret = true; - setCaretPosition(th.startPos + th.len - 1); - ignoreCarret = false; - } catch (IllegalArgumentException iae) { - } - final int pos = th.startPos; - new Timer().schedule(new TimerTask() { - @Override - public void run() { - try { - setCaretPosition(pos); - } catch (IllegalArgumentException iae) { - } + for (Highlighting tc : classHighlights) { + if (tc.offset == classIndex) { + for (Highlighting th : traitHighlights) { + if ((th.startPos > tc.startPos) && (th.startPos + th.len < tc.startPos + tc.len)) { + if (th.offset == traitId) { + try { + ignoreCarret = true; + setCaretPosition(th.startPos + th.len - 1); + ignoreCarret = false; + } catch (IllegalArgumentException iae) { + } + final int pos = th.startPos; + new Timer().schedule(new TimerTask() { + @Override + public void run() { + try { + setCaretPosition(pos); + } catch (IllegalArgumentException iae) { + } + } + }, 100); + return; } - }, 100); - return; - } - } + } + } + break; } - break; - } - } + } - setCaretPosition(0); - } + setCaretPosition(0); + } - public DecompiledEditorPane(ABCPanel abcPanel) { - setEditable(false); - getCaret().setVisible(true); - addCaretListener(this); - this.abcPanel = abcPanel; - } - private List abcList; + public DecompiledEditorPane(ABCPanel abcPanel) { + setEditable(false); + getCaret().setVisible(true); + addCaretListener(this); + this.abcPanel = abcPanel; + } + private List abcList; - public void clearScriptCache() { - bufferedClasses.clear(); - } + public void clearScriptCache() { + bufferedClasses.clear(); + } - public void setScript(ScriptInfo script, ABC abc, List abcList) { - if (script == null) { - highlights = new ArrayList(); - traitHighlights = new ArrayList(); - methodHighlights = new ArrayList(); - this.script = null; - return; - } - setText("//Please wait..."); + public void setScript(ScriptInfo script, ABC abc, List abcList) { + if (script == null) { + highlights = new ArrayList(); + traitHighlights = new ArrayList(); + methodHighlights = new ArrayList(); + this.script = null; + return; + } + setText("//Please wait..."); - String hilightedCode; - if (!bufferedClasses.containsKey(script)) { - hilightedCode = script.convert(abcList, abc, false, true); - highlights = Highlighting.getInstrHighlights(hilightedCode); - traitHighlights = Highlighting.getTraitHighlights(hilightedCode); - methodHighlights = Highlighting.getMethodHighlights(hilightedCode); - classHighlights = Highlighting.getClassHighlights(hilightedCode); - hilightedCode = Highlighting.stripHilights(hilightedCode); - bufferedClasses.put(script, new BufferedClass(hilightedCode, highlights, traitHighlights, methodHighlights, classHighlights)); - } else { - BufferedClass bc = bufferedClasses.get(script); - hilightedCode = bc.text; - highlights = bc.highlights; - traitHighlights = bc.traitHighlights; - methodHighlights = bc.methodHighlights; - classHighlights = bc.classHighlights; - } - this.abc = abc; - this.abcList = abcList; - this.script = script; - setText(hilightedCode); - } + String hilightedCode; + if (!bufferedClasses.containsKey(script)) { + hilightedCode = script.convert(abcList, abc, false, true); + highlights = Highlighting.getInstrHighlights(hilightedCode); + traitHighlights = Highlighting.getTraitHighlights(hilightedCode); + methodHighlights = Highlighting.getMethodHighlights(hilightedCode); + classHighlights = Highlighting.getClassHighlights(hilightedCode); + hilightedCode = Highlighting.stripHilights(hilightedCode); + bufferedClasses.put(script, new BufferedClass(hilightedCode, highlights, traitHighlights, methodHighlights, classHighlights)); + } else { + BufferedClass bc = bufferedClasses.get(script); + hilightedCode = bc.text; + highlights = bc.highlights; + traitHighlights = bc.traitHighlights; + methodHighlights = bc.methodHighlights; + classHighlights = bc.classHighlights; + } + this.abc = abc; + this.abcList = abcList; + this.script = script; + setText(hilightedCode); + } - public void reloadClass() { - int ci = classIndex; - if (bufferedClasses.containsKey(script)) { - bufferedClasses.remove(script); - } - setScript(script, abc, abcList); - setNoTrait(); - setClassIndex(ci); - } + public void reloadClass() { + int ci = classIndex; + if (bufferedClasses.containsKey(script)) { + bufferedClasses.remove(script); + } + setScript(script, abc, abcList); + setNoTrait(); + setClassIndex(ci); + } - public int getClassIndex() { - return classIndex; - } + public int getClassIndex() { + return classIndex; + } - public void setABC(ABC abc) { - this.abc = abc; - bufferedClasses.clear(); - setText(""); - } + public void setABC(ABC abc) { + this.abc = abc; + bufferedClasses.clear(); + setText(""); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DeobfuscationDialog.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DeobfuscationDialog.java index a98d750e5..7f68cbb00 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DeobfuscationDialog.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DeobfuscationDialog.java @@ -35,80 +35,80 @@ import javax.swing.JSlider; */ public class DeobfuscationDialog extends JDialog implements ActionListener { - public JCheckBox processAllCheckbox = new JCheckBox("Process all classes"); - public JSlider codeProcessingLevel; - public boolean ok = false; - public static final int LEVEL_REMOVE_DEAD_CODE = 1; - public static final int LEVEL_REMOVE_TRAPS = 2; - public static final int LEVEL_RESTORE_CONTROL_FLOW = 3; + public JCheckBox processAllCheckbox = new JCheckBox("Process all classes"); + public JSlider codeProcessingLevel; + public boolean ok = false; + public static final int LEVEL_REMOVE_DEAD_CODE = 1; + public static final int LEVEL_REMOVE_TRAPS = 2; + public static final int LEVEL_RESTORE_CONTROL_FLOW = 3; - public DeobfuscationDialog() { - setDefaultCloseOperation(HIDE_ON_CLOSE); - setSize(new Dimension(300, 270)); - setTitle("PCode deobfuscation"); - Container cp = getContentPane(); - cp.setLayout(null); - codeProcessingLevel = new JSlider(JSlider.VERTICAL, 1, 3, 3); - codeProcessingLevel.setMajorTickSpacing(1); - codeProcessingLevel.setPaintTicks(true); - codeProcessingLevel.setMinorTickSpacing(1); - codeProcessingLevel.setSnapToTicks(true); - JLabel lab1 = new JLabel("Code deobfuscation level:"); - lab1.setBounds(30, 0, getWidth() - 60, 25); - cp.add(lab1); - Hashtable labelTable = new Hashtable(); - //labelTable.put(new Integer(LEVEL_NONE), new JLabel("None")); - labelTable.put(new Integer(LEVEL_REMOVE_DEAD_CODE), new JLabel("Remove dead code")); - labelTable.put(new Integer(LEVEL_REMOVE_TRAPS), new JLabel("Remove traps")); - labelTable.put(new Integer(LEVEL_RESTORE_CONTROL_FLOW), new JLabel("Restore control flow")); - codeProcessingLevel.setLabelTable(labelTable); + public DeobfuscationDialog() { + setDefaultCloseOperation(HIDE_ON_CLOSE); + setSize(new Dimension(300, 270)); + setTitle("PCode deobfuscation"); + Container cp = getContentPane(); + cp.setLayout(null); + codeProcessingLevel = new JSlider(JSlider.VERTICAL, 1, 3, 3); + codeProcessingLevel.setMajorTickSpacing(1); + codeProcessingLevel.setPaintTicks(true); + codeProcessingLevel.setMinorTickSpacing(1); + codeProcessingLevel.setSnapToTicks(true); + JLabel lab1 = new JLabel("Code deobfuscation level:"); + lab1.setBounds(30, 0, getWidth() - 60, 25); + cp.add(lab1); + Hashtable labelTable = new Hashtable(); + //labelTable.put(new Integer(LEVEL_NONE), new JLabel("None")); + labelTable.put(new Integer(LEVEL_REMOVE_DEAD_CODE), new JLabel("Remove dead code")); + labelTable.put(new Integer(LEVEL_REMOVE_TRAPS), new JLabel("Remove traps")); + labelTable.put(new Integer(LEVEL_RESTORE_CONTROL_FLOW), new JLabel("Restore control flow")); + codeProcessingLevel.setLabelTable(labelTable); - codeProcessingLevel.setPaintLabels(true); - codeProcessingLevel.setAlignmentX(Component.CENTER_ALIGNMENT); - codeProcessingLevel.setSize(300, 200); + codeProcessingLevel.setPaintLabels(true); + codeProcessingLevel.setAlignmentX(Component.CENTER_ALIGNMENT); + codeProcessingLevel.setSize(300, 200); - codeProcessingLevel.setBounds(30, 25, getWidth() - 60, 125); + codeProcessingLevel.setBounds(30, 25, getWidth() - 60, 125); - add(codeProcessingLevel); - processAllCheckbox.setBounds(50, 150, getWidth() - 100, 25); - add(processAllCheckbox); + add(codeProcessingLevel); + processAllCheckbox.setBounds(50, 150, getWidth() - 100, 25); + add(processAllCheckbox); - processAllCheckbox.setSelected(true); + processAllCheckbox.setSelected(true); - JButton cancelButton = new JButton("Cancel"); - cancelButton.addActionListener(this); - cancelButton.setActionCommand("CANCEL"); - JButton okButton = new JButton("OK"); - okButton.addActionListener(this); - okButton.setActionCommand("OK"); - okButton.setBounds(50, 200, 75, 25); - cancelButton.setBounds(145, 200, 75, 25); - cp.add(okButton); - cp.add(cancelButton); - setModal(true); - View.centerScreen(this); - View.setWindowIcon(this); - } + JButton cancelButton = new JButton("Cancel"); + cancelButton.addActionListener(this); + cancelButton.setActionCommand("CANCEL"); + JButton okButton = new JButton("OK"); + okButton.addActionListener(this); + okButton.setActionCommand("OK"); + okButton.setBounds(50, 200, 75, 25); + cancelButton.setBounds(145, 200, 75, 25); + cp.add(okButton); + cp.add(cancelButton); + setModal(true); + View.centerScreen(this); + View.setWindowIcon(this); + } - @Override - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("OK")) { - ok = true; - setVisible(false); - } - if (e.getActionCommand().equals("CANCEL")) { - ok = false; - setVisible(false); - } - } + @Override + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("OK")) { + ok = true; + setVisible(false); + } + if (e.getActionCommand().equals("CANCEL")) { + ok = false; + setVisible(false); + } + } - @Override - public void setVisible(boolean b) { - if (b) { - ok = false; - } - super.setVisible(b); - } + @Override + public void setVisible(boolean b) { + if (b) { + ok = false; + } + super.setVisible(b); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DetailPanel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DetailPanel.java index ec983b0aa..f68a2102d 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DetailPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DetailPanel.java @@ -31,107 +31,107 @@ import javax.swing.border.BevelBorder; */ public class DetailPanel extends JPanel implements ActionListener { - public MethodTraitDetailPanel methodTraitPanel; - public JPanel unsupportedTraitPanel; - public SlotConstTraitDetailPanel slotConstTraitPanel; - public static final String METHOD_TRAIT_CARD = "Method/Getter/Setter Trait"; - public static final String UNSUPPORTED_TRAIT_CARD = "-"; - public static final String SLOT_CONST_TRAIT_CARD = "Slot/Const Trait"; - private JPanel innerPanel; - public JButton saveButton = new JButton("Save"); - public JButton editButton = new JButton("Edit"); - public JButton cancelButton = new JButton("Cancel"); - private HashMap cardMap = new HashMap(); - private String selectedCard; - private JLabel selectedLabel; - private boolean editMode = false; - private JPanel buttonsPanel; - private ABCPanel abcPanel; + public MethodTraitDetailPanel methodTraitPanel; + public JPanel unsupportedTraitPanel; + public SlotConstTraitDetailPanel slotConstTraitPanel; + public static final String METHOD_TRAIT_CARD = "Method/Getter/Setter Trait"; + public static final String UNSUPPORTED_TRAIT_CARD = "-"; + public static final String SLOT_CONST_TRAIT_CARD = "Slot/Const Trait"; + private JPanel innerPanel; + public JButton saveButton = new JButton("Save"); + public JButton editButton = new JButton("Edit"); + public JButton cancelButton = new JButton("Cancel"); + private HashMap cardMap = new HashMap(); + private String selectedCard; + private JLabel selectedLabel; + private boolean editMode = false; + private JPanel buttonsPanel; + private ABCPanel abcPanel; - public DetailPanel(ABCPanel abcPanel) { - this.abcPanel = abcPanel; - innerPanel = new JPanel(); - CardLayout layout = new CardLayout(); - innerPanel.setLayout(layout); - methodTraitPanel = new MethodTraitDetailPanel(abcPanel); - cardMap.put(METHOD_TRAIT_CARD, methodTraitPanel); + public DetailPanel(ABCPanel abcPanel) { + this.abcPanel = abcPanel; + innerPanel = new JPanel(); + CardLayout layout = new CardLayout(); + innerPanel.setLayout(layout); + methodTraitPanel = new MethodTraitDetailPanel(abcPanel); + cardMap.put(METHOD_TRAIT_CARD, methodTraitPanel); - unsupportedTraitPanel = new JPanel(new BorderLayout()); - JLabel unsup = new JLabel("Select class and click a trait in Actionscript source to edit it.", SwingConstants.CENTER); - unsupportedTraitPanel.add(unsup, BorderLayout.CENTER); + unsupportedTraitPanel = new JPanel(new BorderLayout()); + JLabel unsup = new JLabel("Select class and click a trait in Actionscript source to edit it.", SwingConstants.CENTER); + unsupportedTraitPanel.add(unsup, BorderLayout.CENTER); - cardMap.put(UNSUPPORTED_TRAIT_CARD, unsupportedTraitPanel); + cardMap.put(UNSUPPORTED_TRAIT_CARD, unsupportedTraitPanel); - slotConstTraitPanel = new SlotConstTraitDetailPanel(); - cardMap.put(SLOT_CONST_TRAIT_CARD, slotConstTraitPanel); + slotConstTraitPanel = new SlotConstTraitDetailPanel(); + cardMap.put(SLOT_CONST_TRAIT_CARD, slotConstTraitPanel); - for (String key : cardMap.keySet()) { - innerPanel.add(cardMap.get(key), key); - } + for (String key : cardMap.keySet()) { + innerPanel.add(cardMap.get(key), key); + } - setLayout(new BorderLayout()); - add(innerPanel, BorderLayout.CENTER); + setLayout(new BorderLayout()); + add(innerPanel, BorderLayout.CENTER); - buttonsPanel = new JPanel(); - buttonsPanel.setLayout(new FlowLayout()); - saveButton.setActionCommand("SAVEDETAIL"); - saveButton.addActionListener(this); - editButton.setActionCommand("EDITDETAIL"); - editButton.addActionListener(this); - cancelButton.setActionCommand("CANCELDETAIL"); - cancelButton.addActionListener(this); - buttonsPanel.setBorder(new BevelBorder(BevelBorder.RAISED)); - buttonsPanel.add(editButton); - buttonsPanel.add(saveButton); - buttonsPanel.add(cancelButton); - add(buttonsPanel, BorderLayout.SOUTH); - selectedCard = UNSUPPORTED_TRAIT_CARD; - layout.show(innerPanel, UNSUPPORTED_TRAIT_CARD); - buttonsPanel.setVisible(false); - selectedLabel = new JLabel(""); - selectedLabel.setText(selectedCard); - selectedLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); - selectedLabel.setHorizontalAlignment(SwingConstants.CENTER); - add(selectedLabel, BorderLayout.NORTH); - } + buttonsPanel = new JPanel(); + buttonsPanel.setLayout(new FlowLayout()); + saveButton.setActionCommand("SAVEDETAIL"); + saveButton.addActionListener(this); + editButton.setActionCommand("EDITDETAIL"); + editButton.addActionListener(this); + cancelButton.setActionCommand("CANCELDETAIL"); + cancelButton.addActionListener(this); + buttonsPanel.setBorder(new BevelBorder(BevelBorder.RAISED)); + buttonsPanel.add(editButton); + buttonsPanel.add(saveButton); + buttonsPanel.add(cancelButton); + add(buttonsPanel, BorderLayout.SOUTH); + selectedCard = UNSUPPORTED_TRAIT_CARD; + layout.show(innerPanel, UNSUPPORTED_TRAIT_CARD); + buttonsPanel.setVisible(false); + selectedLabel = new JLabel(""); + selectedLabel.setText(selectedCard); + selectedLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); + selectedLabel.setHorizontalAlignment(SwingConstants.CENTER); + add(selectedLabel, BorderLayout.NORTH); + } - public void setEditMode(boolean val) { - slotConstTraitPanel.setEditMode(val); - methodTraitPanel.setEditMode(val); - saveButton.setVisible(val); - editButton.setVisible(!val); - cancelButton.setVisible(val); - editMode = val; - } + public void setEditMode(boolean val) { + slotConstTraitPanel.setEditMode(val); + methodTraitPanel.setEditMode(val); + saveButton.setVisible(val); + editButton.setVisible(!val); + cancelButton.setVisible(val); + editMode = val; + } - public void showCard(String name) { - CardLayout layout = (CardLayout) innerPanel.getLayout(); - layout.show(innerPanel, name); - boolean b = cardMap.get(name) instanceof TraitDetail; - buttonsPanel.setVisible(b); - selectedCard = name; - selectedLabel.setText(selectedCard); - } + public void showCard(String name) { + CardLayout layout = (CardLayout) innerPanel.getLayout(); + layout.show(innerPanel, name); + boolean b = cardMap.get(name) instanceof TraitDetail; + buttonsPanel.setVisible(b); + selectedCard = name; + selectedLabel.setText(selectedCard); + } - @Override - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("EDITDETAIL")) { - setEditMode(true); - methodTraitPanel.methodCodePanel.focusEditor(); - } - if (e.getActionCommand().equals("CANCELDETAIL")) { - setEditMode(false); - abcPanel.decompiledTextArea.resetEditing(); - } - if (e.getActionCommand().equals("SAVEDETAIL")) { - if (cardMap.get(selectedCard) instanceof TraitDetail) { - if (((TraitDetail) cardMap.get(selectedCard)).save()) { - int lasttrait = abcPanel.decompiledTextArea.lastTraitIndex; - abcPanel.decompiledTextArea.reloadClass(); - abcPanel.decompiledTextArea.gotoTrait(lasttrait); - JOptionPane.showMessageDialog(this, "Trait Successfully saved"); + @Override + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("EDITDETAIL")) { + setEditMode(true); + methodTraitPanel.methodCodePanel.focusEditor(); + } + if (e.getActionCommand().equals("CANCELDETAIL")) { + setEditMode(false); + abcPanel.decompiledTextArea.resetEditing(); + } + if (e.getActionCommand().equals("SAVEDETAIL")) { + if (cardMap.get(selectedCard) instanceof TraitDetail) { + if (((TraitDetail) cardMap.get(selectedCard)).save()) { + int lasttrait = abcPanel.decompiledTextArea.lastTraitIndex; + abcPanel.decompiledTextArea.reloadClass(); + abcPanel.decompiledTextArea.gotoTrait(lasttrait); + JOptionPane.showMessageDialog(this, "Trait Successfully saved"); + } } - } - } - } + } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DialogMissingSymbolHandler.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DialogMissingSymbolHandler.java index 7f6737134..1eb4375c9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/DialogMissingSymbolHandler.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/DialogMissingSymbolHandler.java @@ -21,23 +21,23 @@ import javax.swing.JOptionPane; public class DialogMissingSymbolHandler implements MissingSymbolHandler { - @Override - public boolean missingString(String value) { - return JOptionPane.showConfirmDialog(null, "String \"" + value + "\" is not present in constants table. Do you want to add it?", "Add String", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; - } + @Override + public boolean missingString(String value) { + return JOptionPane.showConfirmDialog(null, "String \"" + value + "\" is not present in constants table. Do you want to add it?", "Add String", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; + } - @Override - public boolean missingInt(long value) { - return JOptionPane.showConfirmDialog(null, "Integer value \"" + value + "\" is not present in constants table. Do you want to add it?", "Add Integer", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; - } + @Override + public boolean missingInt(long value) { + return JOptionPane.showConfirmDialog(null, "Integer value \"" + value + "\" is not present in constants table. Do you want to add it?", "Add Integer", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; + } - @Override - public boolean missingUInt(long value) { - return JOptionPane.showConfirmDialog(null, "Unsigned integer value \"" + value + "\" is not present in constants table. Do you want to add it?", "Add Unsigned integer", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; - } + @Override + public boolean missingUInt(long value) { + return JOptionPane.showConfirmDialog(null, "Unsigned integer value \"" + value + "\" is not present in constants table. Do you want to add it?", "Add Unsigned integer", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; + } - @Override - public boolean missingDouble(double value) { - return JOptionPane.showConfirmDialog(null, "Double value \"" + value + "\" is not present in constants table. Do you want to add it?", "Add Double", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; - } + @Override + public boolean missingDouble(double value) { + return JOptionPane.showConfirmDialog(null, "Double value \"" + value + "\" is not present in constants table. Do you want to add it?", "Add Double", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/IconListRenderer.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/IconListRenderer.java index 0901941b2..5895effad 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/IconListRenderer.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/IconListRenderer.java @@ -23,49 +23,49 @@ import javax.swing.*; public class IconListRenderer extends DefaultListCellRenderer { - private Icon constIcon; - private Icon functionIcon; - private Icon variableIcon; + private Icon constIcon; + private Icon functionIcon; + private Icon variableIcon; - private Icon loadIcon(String path) { - ClassLoader cldr = this.getClass().getClassLoader(); - java.net.URL imageURL = cldr.getResource(path); - return new ImageIcon(imageURL); - } + private Icon loadIcon(String path) { + ClassLoader cldr = this.getClass().getClassLoader(); + java.net.URL imageURL = cldr.getResource(path); + return new ImageIcon(imageURL); + } - public IconListRenderer() { - constIcon = View.getIcon("constant"); - functionIcon = View.getIcon("function"); - variableIcon = View.getIcon("variable"); - } + public IconListRenderer() { + constIcon = View.getIcon("constant"); + functionIcon = View.getIcon("function"); + variableIcon = View.getIcon("variable"); + } - @Override - public Component getListCellRendererComponent( - JList list, Object value, int index, - boolean isSelected, boolean cellHasFocus) { + @Override + public Component getListCellRendererComponent( + JList list, Object value, int index, + boolean isSelected, boolean cellHasFocus) { - // Get the renderer component from parent class + // Get the renderer component from parent class - JLabel label = - (JLabel) super.getListCellRendererComponent(list, - value, index, isSelected, cellHasFocus); + JLabel label = + (JLabel) super.getListCellRendererComponent(list, + value, index, isSelected, cellHasFocus); - // Get icon to use for the list item value + // Get icon to use for the list item value - TraitsListItem tli = (TraitsListItem) value; + TraitsListItem tli = (TraitsListItem) value; - if (tli.getType() == TraitsListItem.Type.CONST) { - label.setIcon(constIcon); - } - if (tli.getType() == TraitsListItem.Type.VAR) { - label.setIcon(variableIcon); - } - if (tli.getType() == TraitsListItem.Type.METHOD) { - label.setIcon(functionIcon); - } - if (tli.getType() == TraitsListItem.Type.INITIALIZER) { - label.setIcon(functionIcon); - } - return label; - } + if (tli.getType() == TraitsListItem.Type.CONST) { + label.setIcon(constIcon); + } + if (tli.getType() == TraitsListItem.Type.VAR) { + label.setIcon(variableIcon); + } + if (tli.getType() == TraitsListItem.Type.METHOD) { + label.setIcon(functionIcon); + } + if (tli.getType() == TraitsListItem.Type.INITIALIZER) { + label.setIcon(functionIcon); + } + return label; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/LineMarkedEditorPane.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/LineMarkedEditorPane.java index 36c3cb19d..a4536e3c2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/LineMarkedEditorPane.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/LineMarkedEditorPane.java @@ -30,42 +30,42 @@ import javax.swing.text.Element; */ public class LineMarkedEditorPane extends JEditorPane { - int lastLine = -1; + int lastLine = -1; - public LineMarkedEditorPane() { - setOpaque(false); - addCaretListener(new CaretListener() { - @Override - public void caretUpdate(CaretEvent e) { - int caretPosition = getCaretPosition(); - Element root = getDocument().getDefaultRootElement(); - int currentLine = root.getElementIndex(caretPosition); - if (currentLine != lastLine) { - lastLine = currentLine; - repaint(); + public LineMarkedEditorPane() { + setOpaque(false); + addCaretListener(new CaretListener() { + @Override + public void caretUpdate(CaretEvent e) { + int caretPosition = getCaretPosition(); + Element root = getDocument().getDefaultRootElement(); + int currentLine = root.getElementIndex(caretPosition); + if (currentLine != lastLine) { + lastLine = currentLine; + repaint(); + } } - } - }); - } + }); + } - @Override - public void setText(String t) { - lastLine = -1; - super.setText(t); - } + @Override + public void setText(String t) { + lastLine = -1; + super.setText(t); + } - @Override - public void paint(Graphics g) { - g.setColor(Color.white); - g.fillRect(0, 0, getWidth(), getHeight()); - FontMetrics fontMetrics = g.getFontMetrics(); - int lh = fontMetrics.getHeight(); - int a = fontMetrics.getAscent(); - int d = fontMetrics.getDescent(); - int h = a + d; - int rH = h; - g.setColor(new Color(0xee, 0xee, 0xee)); - g.fillRect(0, d + lh * lastLine - 1, getWidth(), lh); - super.paint(g); - } + @Override + public void paint(Graphics g) { + g.setColor(Color.white); + g.fillRect(0, 0, getWidth(), getHeight()); + FontMetrics fontMetrics = g.getFontMetrics(); + int lh = fontMetrics.getHeight(); + int a = fontMetrics.getAscent(); + int d = fontMetrics.getDescent(); + int h = a + d; + int rH = h; + g.setColor(new Color(0xee, 0xee, 0xee)); + g.fillRect(0, d + lh * lastLine - 1, getWidth(), lh); + super.paint(g); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodBodyParamsPanel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodBodyParamsPanel.java index 1f8d1a849..8fbe5d17a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodBodyParamsPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodBodyParamsPanel.java @@ -30,106 +30,106 @@ import javax.swing.event.ChangeListener; */ public class MethodBodyParamsPanel extends JPanel implements ChangeListener { - public JLabel maxStackLabel = new JLabel("Max stack:", SwingConstants.RIGHT); - public JFormattedTextField maxStackField = new JFormattedTextField(NumberFormat.getNumberInstance()); - public JLabel localCountLabel = new JLabel("Local registers count:", SwingConstants.RIGHT); - public JFormattedTextField localCountField = new JFormattedTextField(NumberFormat.getNumberInstance()); - public JLabel initScopeDepthLabel = new JLabel("Minimum scope depth:", SwingConstants.RIGHT); - public JFormattedTextField initScopeDepthField = new JFormattedTextField(NumberFormat.getNumberInstance()); - public JLabel maxScopeDepthLabel = new JLabel("Maximum scope depth:", SwingConstants.RIGHT); - public JFormattedTextField maxScopeDepthField = new JFormattedTextField(NumberFormat.getNumberInstance()); - public MethodBody body; - public JCheckBox autoFillCheckBox = new JCheckBox("Auto fill on code save (GLOBAL SETTING)"); - public JLabel experimentalLabel = new JLabel("...EXPERIMENTAL"); - private ABCPanel abcPanel; + public JLabel maxStackLabel = new JLabel("Max stack:", SwingConstants.RIGHT); + public JFormattedTextField maxStackField = new JFormattedTextField(NumberFormat.getNumberInstance()); + public JLabel localCountLabel = new JLabel("Local registers count:", SwingConstants.RIGHT); + public JFormattedTextField localCountField = new JFormattedTextField(NumberFormat.getNumberInstance()); + public JLabel initScopeDepthLabel = new JLabel("Minimum scope depth:", SwingConstants.RIGHT); + public JFormattedTextField initScopeDepthField = new JFormattedTextField(NumberFormat.getNumberInstance()); + public JLabel maxScopeDepthLabel = new JLabel("Maximum scope depth:", SwingConstants.RIGHT); + public JFormattedTextField maxScopeDepthField = new JFormattedTextField(NumberFormat.getNumberInstance()); + public MethodBody body; + public JCheckBox autoFillCheckBox = new JCheckBox("Auto fill on code save (GLOBAL SETTING)"); + public JLabel experimentalLabel = new JLabel("...EXPERIMENTAL"); + private ABCPanel abcPanel; - public MethodBodyParamsPanel(ABCPanel abcPanel) { - setLayout(null); - this.abcPanel = abcPanel; + public MethodBodyParamsPanel(ABCPanel abcPanel) { + setLayout(null); + this.abcPanel = abcPanel; - maxStackLabel.setBounds(10, 10, 150, 25); - maxStackField.setBounds(10 + 150 + 10, 10, 75, 25); - add(maxStackLabel); - add(maxStackField); + maxStackLabel.setBounds(10, 10, 150, 25); + maxStackField.setBounds(10 + 150 + 10, 10, 75, 25); + add(maxStackLabel); + add(maxStackField); - localCountLabel.setBounds(10, 10 + 30, 150, 25); - localCountField.setBounds(10 + 150 + 10, 10 + 30, 75, 25); - add(localCountLabel); - add(localCountField); + localCountLabel.setBounds(10, 10 + 30, 150, 25); + localCountField.setBounds(10 + 150 + 10, 10 + 30, 75, 25); + add(localCountLabel); + add(localCountField); - initScopeDepthLabel.setBounds(10, 10 + 30 + 30, 150, 25); - initScopeDepthField.setBounds(10 + 150 + 10, 10 + 30 + 30, 75, 25); - add(initScopeDepthLabel); - add(initScopeDepthField); + initScopeDepthLabel.setBounds(10, 10 + 30 + 30, 150, 25); + initScopeDepthField.setBounds(10 + 150 + 10, 10 + 30 + 30, 75, 25); + add(initScopeDepthLabel); + add(initScopeDepthField); - maxScopeDepthLabel.setBounds(10, 10 + 30 + 30 + 30, 150, 25); - maxScopeDepthField.setBounds(10 + 150 + 10, 10 + 30 + 30 + 30, 75, 25); - add(maxScopeDepthLabel); - add(maxScopeDepthField); + maxScopeDepthLabel.setBounds(10, 10 + 30 + 30 + 30, 150, 25); + maxScopeDepthField.setBounds(10 + 150 + 10, 10 + 30 + 30 + 30, 75, 25); + add(maxScopeDepthLabel); + add(maxScopeDepthField); - autoFillCheckBox.setBounds(30, 10 + 30 + 30 + 30 + 30, 230, 25); - add(autoFillCheckBox); - autoFillCheckBox.addChangeListener(this); + autoFillCheckBox.setBounds(30, 10 + 30 + 30 + 30 + 30, 230, 25); + add(autoFillCheckBox); + autoFillCheckBox.addChangeListener(this); - experimentalLabel.setForeground(Color.red); - experimentalLabel.setBounds(250, 10 + 30 + 30 + 30 + 30, 100, 25); - add(experimentalLabel); + experimentalLabel.setForeground(Color.red); + experimentalLabel.setBounds(250, 10 + 30 + 30 + 30 + 30, 100, 25); + add(experimentalLabel); - setPreferredSize(new Dimension(300, 150)); - } + setPreferredSize(new Dimension(300, 150)); + } - public void loadFromBody(MethodBody body) { - this.body = body; - if (body == null) { - maxStackField.setText("0"); - localCountField.setText("0"); - initScopeDepthField.setText("0"); - maxScopeDepthField.setText("0"); - return; - } - maxStackField.setText("" + body.max_stack); - localCountField.setText("" + body.max_regs); - initScopeDepthField.setText("" + body.init_scope_depth); - maxScopeDepthField.setText("" + body.max_scope_depth); - } + public void loadFromBody(MethodBody body) { + this.body = body; + if (body == null) { + maxStackField.setText("0"); + localCountField.setText("0"); + initScopeDepthField.setText("0"); + maxScopeDepthField.setText("0"); + return; + } + maxStackField.setText("" + body.max_stack); + localCountField.setText("" + body.max_regs); + initScopeDepthField.setText("" + body.init_scope_depth); + maxScopeDepthField.setText("" + body.max_scope_depth); + } - public boolean save() { - if (body != null) { - body.init_scope_depth = Integer.parseInt(initScopeDepthField.getText()); - if (!autoFillCheckBox.isSelected()) { - body.max_stack = Integer.parseInt(maxStackField.getText()); - body.max_regs = Integer.parseInt(localCountField.getText()); - body.max_scope_depth = Integer.parseInt(maxScopeDepthField.getText()); - } else { - if (!body.autoFillStats(abcPanel.abc)) { - JOptionPane.showMessageDialog(null, "Cannot get code stats for automatic body params.\r\nUncheck autofill to avoid this message.", "Warning", JOptionPane.WARNING_MESSAGE); + public boolean save() { + if (body != null) { + body.init_scope_depth = Integer.parseInt(initScopeDepthField.getText()); + if (!autoFillCheckBox.isSelected()) { + body.max_stack = Integer.parseInt(maxStackField.getText()); + body.max_regs = Integer.parseInt(localCountField.getText()); + body.max_scope_depth = Integer.parseInt(maxScopeDepthField.getText()); + } else { + if (!body.autoFillStats(abcPanel.abc)) { + JOptionPane.showMessageDialog(null, "Cannot get code stats for automatic body params.\r\nUncheck autofill to avoid this message.", "Warning", JOptionPane.WARNING_MESSAGE); + } } - } - return true; - } - return false; - } + return true; + } + return false; + } - @Override - public void stateChanged(ChangeEvent e) { - if (e.getSource() == autoFillCheckBox) { - if (autoFillCheckBox.isSelected()) { - localCountField.setEnabled(false); - maxScopeDepthField.setEnabled(false); - maxStackField.setEnabled(false); - } else { - localCountField.setEnabled(true); - maxScopeDepthField.setEnabled(true); - maxStackField.setEnabled(true); - } - } - } + @Override + public void stateChanged(ChangeEvent e) { + if (e.getSource() == autoFillCheckBox) { + if (autoFillCheckBox.isSelected()) { + localCountField.setEnabled(false); + maxScopeDepthField.setEnabled(false); + maxStackField.setEnabled(false); + } else { + localCountField.setEnabled(true); + maxScopeDepthField.setEnabled(true); + maxStackField.setEnabled(true); + } + } + } - public void setEditMode(boolean val) { - maxStackField.setEditable(val); - localCountField.setEditable(val); - initScopeDepthField.setEditable(val); - maxScopeDepthField.setEditable(val); - autoFillCheckBox.setEnabled(val); - } + public void setEditMode(boolean val) { + maxStackField.setEditable(val); + localCountField.setEditable(val); + initScopeDepthField.setEditable(val); + maxScopeDepthField.setEditable(val); + autoFillCheckBox.setEnabled(val); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java index 08efbcf6c..81a28eacf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodCodePanel.java @@ -37,114 +37,114 @@ import javax.swing.JToggleButton; */ public class MethodCodePanel extends JPanel implements ActionListener { - private ASMSourceEditorPane sourceTextArea; - public JPanel buttonsPanel; - private JToggleButton hexButton; + private ASMSourceEditorPane sourceTextArea; + public JPanel buttonsPanel; + private JToggleButton hexButton; - public void focusEditor() { - sourceTextArea.requestFocusInWindow(); - } + public void focusEditor() { + sourceTextArea.requestFocusInWindow(); + } - public String getTraitName() { - return sourceTextArea.getName(); - } + public String getTraitName() { + return sourceTextArea.getName(); + } - public void setIgnoreCarret(boolean ignoreCarret) { - sourceTextArea.setIgnoreCarret(ignoreCarret); - } + public void setIgnoreCarret(boolean ignoreCarret) { + sourceTextArea.setIgnoreCarret(ignoreCarret); + } - public void hilighOffset(long offset) { - sourceTextArea.hilighOffset(offset); - } + public void hilighOffset(long offset) { + sourceTextArea.hilighOffset(offset); + } - public void setBodyIndex(int bodyIndex, ABC abc) { - sourceTextArea.setBodyIndex(bodyIndex, abc, sourceTextArea.getName()); - } + public void setBodyIndex(int bodyIndex, ABC abc) { + sourceTextArea.setBodyIndex(bodyIndex, abc, sourceTextArea.getName()); + } - public void setBodyIndex(int bodyIndex, ABC abc, String name) { - sourceTextArea.setBodyIndex(bodyIndex, abc, name); - } + public void setBodyIndex(int bodyIndex, ABC abc, String name) { + sourceTextArea.setBodyIndex(bodyIndex, abc, name); + } - public int getBodyIndex() { - return sourceTextArea.bodyIndex; - } + public int getBodyIndex() { + return sourceTextArea.bodyIndex; + } - public void setCode(String text) { - sourceTextArea.setText(text); - } + public void setCode(String text) { + sourceTextArea.setText(text); + } - public boolean save(ConstantPool constants) { - return sourceTextArea.save(constants); - } + public boolean save(ConstantPool constants) { + return sourceTextArea.save(constants); + } - public MethodCodePanel(DecompiledEditorPane decompiledEditor) { - sourceTextArea = new ASMSourceEditorPane(decompiledEditor); + public MethodCodePanel(DecompiledEditorPane decompiledEditor) { + sourceTextArea = new ASMSourceEditorPane(decompiledEditor); - setLayout(new BorderLayout()); - add(new JScrollPane(sourceTextArea), BorderLayout.CENTER); - sourceTextArea.setContentType("text/flasm3"); - sourceTextArea.setFont(new Font("Monospaced", Font.PLAIN, sourceTextArea.getFont().getSize())); + setLayout(new BorderLayout()); + add(new JScrollPane(sourceTextArea), BorderLayout.CENTER); + sourceTextArea.setContentType("text/flasm3"); + sourceTextArea.setFont(new Font("Monospaced", Font.PLAIN, sourceTextArea.getFont().getSize())); - buttonsPanel = new JPanel(); - buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS)); - JButton verifyButton = new JButton("Verify"); - verifyButton.setActionCommand("VERIFYBODY"); - verifyButton.addActionListener(this); + buttonsPanel = new JPanel(); + buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS)); + JButton verifyButton = new JButton("Verify"); + verifyButton.setActionCommand("VERIFYBODY"); + verifyButton.addActionListener(this); - JButton graphButton = new JButton(View.getIcon("graph16")); - graphButton.setActionCommand("GRAPH"); - graphButton.addActionListener(this); - graphButton.setToolTipText("View Graph"); - graphButton.setMargin(new Insets(3, 3, 3, 3)); + JButton graphButton = new JButton(View.getIcon("graph16")); + graphButton.setActionCommand("GRAPH"); + graphButton.addActionListener(this); + graphButton.setToolTipText("View Graph"); + graphButton.setMargin(new Insets(3, 3, 3, 3)); - hexButton = new JToggleButton(View.getIcon("hex16")); - hexButton.setActionCommand("HEX"); - hexButton.addActionListener(this); - hexButton.setToolTipText("View Hex"); - hexButton.setMargin(new Insets(3, 3, 3, 3)); + hexButton = new JToggleButton(View.getIcon("hex16")); + hexButton.setActionCommand("HEX"); + hexButton.addActionListener(this); + hexButton.setToolTipText("View Hex"); + hexButton.setMargin(new Insets(3, 3, 3, 3)); - JButton execButton = new JButton("Execute"); - execButton.setActionCommand("EXEC"); - execButton.addActionListener(this); + JButton execButton = new JButton("Execute"); + execButton.setActionCommand("EXEC"); + execButton.addActionListener(this); - buttonsPanel.add(graphButton); - buttonsPanel.add(hexButton); - buttonsPanel.add(new JPanel()); - // buttonsPanel.add(saveButton); - // buttonsPan.add(execButton); + buttonsPanel.add(graphButton); + buttonsPanel.add(hexButton); + buttonsPanel.add(new JPanel()); + // buttonsPanel.add(saveButton); + // buttonsPan.add(execButton); - add(buttonsPanel, BorderLayout.NORTH); - } + add(buttonsPanel, BorderLayout.NORTH); + } - @Override - public void actionPerformed(ActionEvent e) { - if (Main.isWorking()) { - return; - } - if (e.getActionCommand().equals("GRAPH")) { - sourceTextArea.graph(); - } + @Override + public void actionPerformed(ActionEvent e) { + if (Main.isWorking()) { + return; + } + if (e.getActionCommand().equals("GRAPH")) { + sourceTextArea.graph(); + } - if (e.getActionCommand().equals("HEX")) { - sourceTextArea.setHex(hexButton.isSelected()); - } + if (e.getActionCommand().equals("HEX")) { + sourceTextArea.setHex(hexButton.isSelected()); + } - if (e.getActionCommand().equals("EXEC")) { - sourceTextArea.exec(); - } - } + if (e.getActionCommand().equals("EXEC")) { + sourceTextArea.exec(); + } + } - public void setEditMode(boolean val) { - if (val) { - sourceTextArea.setHex(false); - } else { - if (hexButton.isSelected()) { - sourceTextArea.setHex(true); - } - } + public void setEditMode(boolean val) { + if (val) { + sourceTextArea.setHex(false); + } else { + if (hexButton.isSelected()) { + sourceTextArea.setHex(true); + } + } - sourceTextArea.setEditable(val); - sourceTextArea.getCaret().setVisible(true); - buttonsPanel.setVisible(!val); - } + sourceTextArea.setEditable(val); + sourceTextArea.getCaret().setVisible(true); + buttonsPanel.setVisible(!val); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodInfoPanel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodInfoPanel.java index 40c0c6fa3..f31870098 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodInfoPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodInfoPanel.java @@ -34,93 +34,93 @@ import jsyntaxpane.syntaxkits.Flasm3MethodInfoSyntaxKit; */ public class MethodInfoPanel extends JPanel { - public LineMarkedEditorPane paramEditor; - public JEditorPane returnTypeEditor; - private MethodInfo methodInfo; - private ABC abc; + public LineMarkedEditorPane paramEditor; + public JEditorPane returnTypeEditor; + private MethodInfo methodInfo; + private ABC abc; - public MethodInfoPanel() { - returnTypeEditor = new JEditorPane(); - paramEditor = new LineMarkedEditorPane(); - setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); - add(new JLabel("Parameters:")); - add(new JScrollPane(paramEditor)); - add(new JLabel("Return value type:")); - JScrollPane jsp = new JScrollPane(returnTypeEditor); - add(jsp); - paramEditor.setContentType("text/flasm3_methodinfo"); - returnTypeEditor.setContentType("text/flasm3_methodinfo"); - paramEditor.setFont(new Font("Monospaced", Font.PLAIN, paramEditor.getFont().getSize())); - returnTypeEditor.setFont(new Font("Monospaced", Font.PLAIN, returnTypeEditor.getFont().getSize())); + public MethodInfoPanel() { + returnTypeEditor = new JEditorPane(); + paramEditor = new LineMarkedEditorPane(); + setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); + add(new JLabel("Parameters:")); + add(new JScrollPane(paramEditor)); + add(new JLabel("Return value type:")); + JScrollPane jsp = new JScrollPane(returnTypeEditor); + add(jsp); + paramEditor.setContentType("text/flasm3_methodinfo"); + returnTypeEditor.setContentType("text/flasm3_methodinfo"); + paramEditor.setFont(new Font("Monospaced", Font.PLAIN, paramEditor.getFont().getSize())); + returnTypeEditor.setFont(new Font("Monospaced", Font.PLAIN, returnTypeEditor.getFont().getSize())); - jsp.setMaximumSize(new Dimension(1024, 25)); - Flasm3MethodInfoSyntaxKit sk = (Flasm3MethodInfoSyntaxKit) returnTypeEditor.getEditorKit(); - sk.deinstallComponent(returnTypeEditor, "jsyntaxpane.components.LineNumbersRuler"); - } + jsp.setMaximumSize(new Dimension(1024, 25)); + Flasm3MethodInfoSyntaxKit sk = (Flasm3MethodInfoSyntaxKit) returnTypeEditor.getEditorKit(); + sk.deinstallComponent(returnTypeEditor, "jsyntaxpane.components.LineNumbersRuler"); + } - public void load(int methodInfoIndex, ABC abc) { - this.abc = abc; - if (methodInfoIndex <= 0) { - paramEditor.setText(""); - } - this.methodInfo = abc.method_info[methodInfoIndex]; - int p = 0; - String ret = ""; - int optParPos = 0; - if (methodInfo.flagHas_optional()) { - optParPos = methodInfo.param_types.length - methodInfo.optional.length; - } - for (int ptype : methodInfo.param_types) { - if (p > 0) { - ret += ",\n"; - } - if (methodInfo.flagHas_paramnames() && Main.PARAM_NAMES_ENABLE) { - ret = ret + abc.constants.constant_string[methodInfo.paramNames[p]]; - } else { - ret = ret + "param" + (p + 1); - } - ret += ":"; - if (ptype == 0) { - ret += "*"; - } else { - ret += "m[" + ptype + "]\"" + Helper.escapeString(abc.constants.constant_multiname[ptype].toString(abc.constants, new ArrayList())) + "\""; - } - if (methodInfo.flagHas_optional()) { - if (p >= optParPos) { - ret += "=" + methodInfo.optional[p - optParPos].toString(abc.constants); + public void load(int methodInfoIndex, ABC abc) { + this.abc = abc; + if (methodInfoIndex <= 0) { + paramEditor.setText(""); + } + this.methodInfo = abc.method_info[methodInfoIndex]; + int p = 0; + String ret = ""; + int optParPos = 0; + if (methodInfo.flagHas_optional()) { + optParPos = methodInfo.param_types.length - methodInfo.optional.length; + } + for (int ptype : methodInfo.param_types) { + if (p > 0) { + ret += ",\n"; } - } - p++; - } - if (methodInfo.flagNeed_rest()) { - ret += ",\n... rest"; - } - paramEditor.setText(ret); - if (methodInfo.ret_type == 0) { - returnTypeEditor.setText("*"); - } else { - returnTypeEditor.setText("m[" + methodInfo.ret_type + "]\"" + Helper.escapeString(abc.constants.constant_multiname[methodInfo.ret_type].toString(abc.constants, new ArrayList())) + "\""); - } - } + if (methodInfo.flagHas_paramnames() && Main.PARAM_NAMES_ENABLE) { + ret = ret + abc.constants.constant_string[methodInfo.paramNames[p]]; + } else { + ret = ret + "param" + (p + 1); + } + ret += ":"; + if (ptype == 0) { + ret += "*"; + } else { + ret += "m[" + ptype + "]\"" + Helper.escapeString(abc.constants.constant_multiname[ptype].toString(abc.constants, new ArrayList())) + "\""; + } + if (methodInfo.flagHas_optional()) { + if (p >= optParPos) { + ret += "=" + methodInfo.optional[p - optParPos].toString(abc.constants); + } + } + p++; + } + if (methodInfo.flagNeed_rest()) { + ret += ",\n... rest"; + } + paramEditor.setText(ret); + if (methodInfo.ret_type == 0) { + returnTypeEditor.setText("*"); + } else { + returnTypeEditor.setText("m[" + methodInfo.ret_type + "]\"" + Helper.escapeString(abc.constants.constant_multiname[methodInfo.ret_type].toString(abc.constants, new ArrayList())) + "\""); + } + } - public boolean save() { - try { - MethodInfoParser.parseParams(paramEditor.getText(), methodInfo, abc); - } catch (ParseException ex) { - JOptionPane.showMessageDialog(paramEditor, ex.text, "MethodInfo Params Error", JOptionPane.ERROR_MESSAGE); - return false; - } - try { - MethodInfoParser.parseReturnType(returnTypeEditor.getText(), methodInfo); - } catch (ParseException ex) { - JOptionPane.showMessageDialog(returnTypeEditor, ex.text, "MethodInfo Return type Error", JOptionPane.ERROR_MESSAGE); - return false; - } - return true; - } + public boolean save() { + try { + MethodInfoParser.parseParams(paramEditor.getText(), methodInfo, abc); + } catch (ParseException ex) { + JOptionPane.showMessageDialog(paramEditor, ex.text, "MethodInfo Params Error", JOptionPane.ERROR_MESSAGE); + return false; + } + try { + MethodInfoParser.parseReturnType(returnTypeEditor.getText(), methodInfo); + } catch (ParseException ex) { + JOptionPane.showMessageDialog(returnTypeEditor, ex.text, "MethodInfo Return type Error", JOptionPane.ERROR_MESSAGE); + return false; + } + return true; + } - public void setEditMode(boolean val) { - returnTypeEditor.setEditable(val); - paramEditor.setEditable(val); - } + public void setEditMode(boolean val) { + returnTypeEditor.setEditable(val); + paramEditor.setEditable(val); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodTraitDetailPanel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodTraitDetailPanel.java index a35b2edcc..edf6cf86b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodTraitDetailPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/MethodTraitDetailPanel.java @@ -25,41 +25,41 @@ import javax.swing.JTabbedPane; */ public class MethodTraitDetailPanel extends JTabbedPane implements TraitDetail { - public MethodCodePanel methodCodePanel; - public MethodBodyParamsPanel methodBodyParamsPanel; - public MethodInfoPanel methodInfoPanel; - public ABCPanel abcPanel; + public MethodCodePanel methodCodePanel; + public MethodBodyParamsPanel methodBodyParamsPanel; + public MethodInfoPanel methodInfoPanel; + public ABCPanel abcPanel; - public MethodTraitDetailPanel(ABCPanel abcPanel) { - this.abcPanel = abcPanel; - methodCodePanel = new MethodCodePanel(abcPanel.decompiledTextArea); - methodBodyParamsPanel = new MethodBodyParamsPanel(abcPanel); - methodInfoPanel = new MethodInfoPanel(); - addTab("MethodInfo", methodInfoPanel); - addTab("MethodBody Code", methodCodePanel); - addTab("MethodBody params", new JScrollPane(methodBodyParamsPanel)); - setSelectedIndex(1); - } + public MethodTraitDetailPanel(ABCPanel abcPanel) { + this.abcPanel = abcPanel; + methodCodePanel = new MethodCodePanel(abcPanel.decompiledTextArea); + methodBodyParamsPanel = new MethodBodyParamsPanel(abcPanel); + methodInfoPanel = new MethodInfoPanel(); + addTab("MethodInfo", methodInfoPanel); + addTab("MethodBody Code", methodCodePanel); + addTab("MethodBody params", new JScrollPane(methodBodyParamsPanel)); + setSelectedIndex(1); + } - @Override - public boolean save() { - if (!methodInfoPanel.save()) { - return false; - } - if (!methodCodePanel.save(abcPanel.abc.constants)) { - return false; - } - if (!methodBodyParamsPanel.save()) { - return false; - } + @Override + public boolean save() { + if (!methodInfoPanel.save()) { + return false; + } + if (!methodCodePanel.save(abcPanel.abc.constants)) { + return false; + } + if (!methodBodyParamsPanel.save()) { + return false; + } - return true; - } + return true; + } - @Override - public void setEditMode(boolean val) { - methodCodePanel.setEditMode(val); - methodBodyParamsPanel.setEditMode(val); - methodInfoPanel.setEditMode(val); - } + @Override + public void setEditMode(boolean val) { + methodCodePanel.setEditMode(val); + methodBodyParamsPanel.setEditMode(val); + methodInfoPanel.setEditMode(val); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/SlotConstTraitDetailPanel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/SlotConstTraitDetailPanel.java index 539994d24..292f93948 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/SlotConstTraitDetailPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/SlotConstTraitDetailPanel.java @@ -33,55 +33,55 @@ import jsyntaxpane.syntaxkits.Flasm3MethodInfoSyntaxKit; */ public class SlotConstTraitDetailPanel extends JPanel implements TraitDetail { - public JEditorPane slotConstEditor; - private ABC abc; - private TraitSlotConst trait; + public JEditorPane slotConstEditor; + private ABC abc; + private TraitSlotConst trait; - public SlotConstTraitDetailPanel() { - slotConstEditor = new JEditorPane(); - setLayout(new BorderLayout()); - add(new JLabel("Type and Value:"), BorderLayout.NORTH); - add(new JScrollPane(slotConstEditor), BorderLayout.CENTER); - slotConstEditor.setContentType("text/flasm3_methodinfo"); - Flasm3MethodInfoSyntaxKit sk = (Flasm3MethodInfoSyntaxKit) slotConstEditor.getEditorKit(); - sk.deinstallComponent(slotConstEditor, "jsyntaxpane.components.LineNumbersRuler"); - } + public SlotConstTraitDetailPanel() { + slotConstEditor = new JEditorPane(); + setLayout(new BorderLayout()); + add(new JLabel("Type and Value:"), BorderLayout.NORTH); + add(new JScrollPane(slotConstEditor), BorderLayout.CENTER); + slotConstEditor.setContentType("text/flasm3_methodinfo"); + Flasm3MethodInfoSyntaxKit sk = (Flasm3MethodInfoSyntaxKit) slotConstEditor.getEditorKit(); + sk.deinstallComponent(slotConstEditor, "jsyntaxpane.components.LineNumbersRuler"); + } - public void load(TraitSlotConst trait, ABC abc) { - this.abc = abc; - this.trait = trait; - String s; - String typeStr; - if (trait.type_index > 0) { - typeStr = "m[" + trait.type_index + "]\"" + Helper.escapeString(abc.constants.constant_multiname[trait.type_index].toString(abc.constants, new ArrayList())) + "\""; - } else { - typeStr = "*"; - } - String valueStr = ""; - if (trait.value_kind != 0) { - valueStr = " = " + (new ValueKind(trait.value_index, trait.value_kind)).toString(abc.constants); - } + public void load(TraitSlotConst trait, ABC abc) { + this.abc = abc; + this.trait = trait; + String s; + String typeStr; + if (trait.type_index > 0) { + typeStr = "m[" + trait.type_index + "]\"" + Helper.escapeString(abc.constants.constant_multiname[trait.type_index].toString(abc.constants, new ArrayList())) + "\""; + } else { + typeStr = "*"; + } + String valueStr = ""; + if (trait.value_kind != 0) { + valueStr = " = " + (new ValueKind(trait.value_index, trait.value_kind)).toString(abc.constants); + } - s = typeStr + valueStr; + s = typeStr + valueStr; - slotConstEditor.setText(s); - } + slotConstEditor.setText(s); + } - @Override - public boolean save() { - try { - if (!MethodInfoParser.parseSlotConst(slotConstEditor.getText(), trait, abc)) { + @Override + public boolean save() { + try { + if (!MethodInfoParser.parseSlotConst(slotConstEditor.getText(), trait, abc)) { + return false; + } + } catch (ParseException ex) { + JOptionPane.showMessageDialog(slotConstEditor, ex.text, "SlotConst typevalue Error", JOptionPane.ERROR_MESSAGE); return false; - } - } catch (ParseException ex) { - JOptionPane.showMessageDialog(slotConstEditor, ex.text, "SlotConst typevalue Error", JOptionPane.ERROR_MESSAGE); - return false; - } - return true; - } + } + return true; + } - @Override - public void setEditMode(boolean val) { - slotConstEditor.setEditable(val); - } + @Override + public void setEditMode(boolean val) { + slotConstEditor.setEditable(val); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitDetail.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitDetail.java index bd782a284..9cad992a2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitDetail.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitDetail.java @@ -22,7 +22,7 @@ package com.jpexs.decompiler.flash.abc.gui; */ public interface TraitDetail { - public void setEditMode(boolean val); + public void setEditMode(boolean val); - public boolean save(); + public boolean save(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsList.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsList.java index 3ff1dbbbb..42a1b6a2f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsList.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsList.java @@ -26,56 +26,56 @@ import javax.swing.event.ListSelectionListener; public class TraitsList extends JList implements ListSelectionListener { - ABC abc; - List abcTags; - int classIndex = -1; - private ABCPanel abcPanel; - private boolean sorted = false; + ABC abc; + List abcTags; + int classIndex = -1; + private ABCPanel abcPanel; + private boolean sorted = false; - public void setSorted(boolean sorted) { - if (getModel() instanceof TraitsListModel) { - ((TraitsListModel) getModel()).setSorted(sorted); - } - this.sorted = sorted; - } + public void setSorted(boolean sorted) { + if (getModel() instanceof TraitsListModel) { + ((TraitsListModel) getModel()).setSorted(sorted); + } + this.sorted = sorted; + } - public int getClassIndex() { - return classIndex; - } + public int getClassIndex() { + return classIndex; + } - public TraitsList(ABCPanel abcPanel) { - addListSelectionListener(this); - this.abcPanel = abcPanel; - setCellRenderer(new IconListRenderer()); - } + public TraitsList(ABCPanel abcPanel) { + addListSelectionListener(this); + this.abcPanel = abcPanel; + setCellRenderer(new IconListRenderer()); + } - public void setABC(List abcTags, ABC abc) { - this.abc = abc; - this.abcTags = abcTags; - setModel(new DefaultListModel()); - setClassIndex(-1); - } + public void setABC(List abcTags, ABC abc) { + this.abc = abc; + this.abcTags = abcTags; + setModel(new DefaultListModel()); + setClassIndex(-1); + } - public void setClassIndex(int classIndex) { - this.classIndex = classIndex; - if (classIndex == -1) { - setModel(new DefaultListModel()); - } else { - if (abc != null) { - setModel(new TraitsListModel(abcTags, abc, classIndex, sorted)); - } - } - } - private int lastSelected = -1; + public void setClassIndex(int classIndex) { + this.classIndex = classIndex; + if (classIndex == -1) { + setModel(new DefaultListModel()); + } else { + if (abc != null) { + setModel(new TraitsListModel(abcTags, abc, classIndex, sorted)); + } + } + } + private int lastSelected = -1; - @Override - public void valueChanged(ListSelectionEvent e) { - if (getSelectedIndex() == lastSelected) { - return; - } - lastSelected = getSelectedIndex(); - TraitsListItem sel = (TraitsListItem) getSelectedValue(); - abcPanel.decompiledTextArea.gotoTrait(sel == null ? -1 : sel.getGlobalTraitId()); + @Override + public void valueChanged(ListSelectionEvent e) { + if (getSelectedIndex() == lastSelected) { + return; + } + lastSelected = getSelectedIndex(); + TraitsListItem sel = (TraitsListItem) getSelectedValue(); + abcPanel.decompiledTextArea.gotoTrait(sel == null ? -1 : sel.getGlobalTraitId()); - } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListItem.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListItem.java index 12f71485a..53ff71380 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListItem.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListItem.java @@ -14,91 +14,91 @@ import java.util.List; */ public class TraitsListItem { - private Type type; - private boolean isStatic; - private List abcTags; - private ABC abc; - private int classIndex; - private int index; - public static final String STR_INSTANCE_INITIALIZER = "instance initializer"; - public static final String STR_CLASS_INITIALIZER = "class initializer"; + private Type type; + private boolean isStatic; + private List abcTags; + private ABC abc; + private int classIndex; + private int index; + public static final String STR_INSTANCE_INITIALIZER = "instance initializer"; + public static final String STR_CLASS_INITIALIZER = "class initializer"; - public TraitsListItem(Type type, int index, boolean isStatic, List abcTags, ABC abc, int classIndex) { - this.type = type; - this.index = index; - this.isStatic = isStatic; - this.abcTags = abcTags; - this.abc = abc; - this.classIndex = classIndex; - } + public TraitsListItem(Type type, int index, boolean isStatic, List abcTags, ABC abc, int classIndex) { + this.type = type; + this.index = index; + this.isStatic = isStatic; + this.abcTags = abcTags; + this.abc = abc; + this.classIndex = classIndex; + } - public int getGlobalTraitId() { - if (type == Type.INITIALIZER) { - if (!isStatic) { - return abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length; - } else { - return abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length + 1; - } - } - if (isStatic) { - return index; - } else { - return abc.class_info[classIndex].static_traits.traits.length + index; - } - } - - public String toStringName() { - if ((type != Type.INITIALIZER) && isStatic) { - return abc.class_info[classIndex].static_traits.traits[index].getName(abc).getName(abc.constants, new ArrayList()); - } else if ((type != Type.INITIALIZER) && (!isStatic)) { - return abc.instance_info[classIndex].instance_traits.traits[index].getName(abc).getName(abc.constants, new ArrayList()); - } else if (!isStatic) { - return "__" + STR_INSTANCE_INITIALIZER; - } else { - return "__" + STR_CLASS_INITIALIZER; - } - } - - @Override - public String toString() { - if ((type != Type.INITIALIZER) && isStatic) { - return abc.class_info[classIndex].static_traits.traits[index].convertHeader("", abcTags, abc, true, false, classIndex, false, new ArrayList()); - } else if ((type != Type.INITIALIZER) && (!isStatic)) { - return abc.instance_info[classIndex].instance_traits.traits[index].convertHeader("", abcTags, abc, false, false, classIndex, false, new ArrayList()); - } else if (!isStatic) { - return STR_INSTANCE_INITIALIZER; - } else { - return STR_CLASS_INITIALIZER; - } - } - - public Type getType() { - return type; - } - - public boolean isStatic() { - return isStatic; - } - - public enum Type { - - METHOD, - VAR, - CONST, - INITIALIZER; - - public static Type getTypeForTrait(Trait t) { - if (t instanceof TraitMethodGetterSetter) { - return METHOD; - } - if (t instanceof TraitSlotConst) { - if (((TraitSlotConst) t).isConst()) { - return CONST; + public int getGlobalTraitId() { + if (type == Type.INITIALIZER) { + if (!isStatic) { + return abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length; } else { - return VAR; + return abc.class_info[classIndex].static_traits.traits.length + abc.instance_info[classIndex].instance_traits.traits.length + 1; } - } - return null; - } - } + } + if (isStatic) { + return index; + } else { + return abc.class_info[classIndex].static_traits.traits.length + index; + } + } + + public String toStringName() { + if ((type != Type.INITIALIZER) && isStatic) { + return abc.class_info[classIndex].static_traits.traits[index].getName(abc).getName(abc.constants, new ArrayList()); + } else if ((type != Type.INITIALIZER) && (!isStatic)) { + return abc.instance_info[classIndex].instance_traits.traits[index].getName(abc).getName(abc.constants, new ArrayList()); + } else if (!isStatic) { + return "__" + STR_INSTANCE_INITIALIZER; + } else { + return "__" + STR_CLASS_INITIALIZER; + } + } + + @Override + public String toString() { + if ((type != Type.INITIALIZER) && isStatic) { + return abc.class_info[classIndex].static_traits.traits[index].convertHeader("", abcTags, abc, true, false, classIndex, false, new ArrayList()); + } else if ((type != Type.INITIALIZER) && (!isStatic)) { + return abc.instance_info[classIndex].instance_traits.traits[index].convertHeader("", abcTags, abc, false, false, classIndex, false, new ArrayList()); + } else if (!isStatic) { + return STR_INSTANCE_INITIALIZER; + } else { + return STR_CLASS_INITIALIZER; + } + } + + public Type getType() { + return type; + } + + public boolean isStatic() { + return isStatic; + } + + public enum Type { + + METHOD, + VAR, + CONST, + INITIALIZER; + + public static Type getTypeForTrait(Trait t) { + if (t instanceof TraitMethodGetterSetter) { + return METHOD; + } + if (t instanceof TraitSlotConst) { + if (((TraitSlotConst) t).isConst()) { + return CONST; + } else { + return VAR; + } + } + return null; + } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListModel.java index c5e89cea1..b95e78383 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TraitsListModel.java @@ -27,61 +27,61 @@ import javax.swing.event.ListDataListener; public class TraitsListModel implements ListModel { - private List items; - private List abcTags; - private ABC abc; - private int classIndex; + private List items; + private List abcTags; + private ABC abc; + private int classIndex; - public void setSorted(boolean sorted) { - if (sorted) { - Collections.sort(items, new Comparator() { - @Override - public int compare(TraitsListItem o1, TraitsListItem o2) { - return o1.toStringName().compareTo(o2.toStringName()); - } - }); - } else { - reset(); - } - } + public void setSorted(boolean sorted) { + if (sorted) { + Collections.sort(items, new Comparator() { + @Override + public int compare(TraitsListItem o1, TraitsListItem o2) { + return o1.toStringName().compareTo(o2.toStringName()); + } + }); + } else { + reset(); + } + } - private void reset() { - items = new ArrayList(); - for (int t = 0; t < abc.class_info[classIndex].static_traits.traits.length; t++) { - items.add(new TraitsListItem(TraitsListItem.Type.getTypeForTrait(abc.class_info[classIndex].static_traits.traits[t]), t, true, abcTags, abc, classIndex)); - } - for (int t = 0; t < abc.instance_info[classIndex].instance_traits.traits.length; t++) { - items.add(new TraitsListItem(TraitsListItem.Type.getTypeForTrait(abc.instance_info[classIndex].instance_traits.traits[t]), t, false, abcTags, abc, classIndex)); - } - items.add(new TraitsListItem(TraitsListItem.Type.INITIALIZER, 0, false, abcTags, abc, classIndex)); - items.add(new TraitsListItem(TraitsListItem.Type.INITIALIZER, 0, true, abcTags, abc, classIndex)); - } + private void reset() { + items = new ArrayList(); + for (int t = 0; t < abc.class_info[classIndex].static_traits.traits.length; t++) { + items.add(new TraitsListItem(TraitsListItem.Type.getTypeForTrait(abc.class_info[classIndex].static_traits.traits[t]), t, true, abcTags, abc, classIndex)); + } + for (int t = 0; t < abc.instance_info[classIndex].instance_traits.traits.length; t++) { + items.add(new TraitsListItem(TraitsListItem.Type.getTypeForTrait(abc.instance_info[classIndex].instance_traits.traits[t]), t, false, abcTags, abc, classIndex)); + } + items.add(new TraitsListItem(TraitsListItem.Type.INITIALIZER, 0, false, abcTags, abc, classIndex)); + items.add(new TraitsListItem(TraitsListItem.Type.INITIALIZER, 0, true, abcTags, abc, classIndex)); + } - public TraitsListModel(List abcTags, ABC abc, int classIndex, boolean sorted) { - this.abcTags = abcTags; - this.abc = abc; - this.classIndex = classIndex; - reset(); - if (sorted) { - setSorted(true); - } - } + public TraitsListModel(List abcTags, ABC abc, int classIndex, boolean sorted) { + this.abcTags = abcTags; + this.abc = abc; + this.classIndex = classIndex; + reset(); + if (sorted) { + setSorted(true); + } + } - @Override - public int getSize() { - return items.size(); - } + @Override + public int getSize() { + return items.size(); + } - @Override - public Object getElementAt(int index) { - return items.get(index); - } + @Override + public Object getElementAt(int index) { + return items.get(index); + } - @Override - public void addListDataListener(ListDataListener l) { - } + @Override + public void addListDataListener(ListDataListener l) { + } - @Override - public void removeListDataListener(ListDataListener l) { - } + @Override + public void removeListDataListener(ListDataListener l) { + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/Tree.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/Tree.java index 9acb9de8a..47440f2a4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/Tree.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/Tree.java @@ -20,31 +20,31 @@ import java.util.StringTokenizer; public class Tree { - private final TreeElement ROOT = new TreeElement("", "", null, null); + private final TreeElement ROOT = new TreeElement("", "", null, null); - public void add(String name, String path, Object item) { - StringTokenizer st = new StringTokenizer(path, "."); - TreeElement parent = ROOT; - while (st.hasMoreTokens()) { - String pathElement = st.nextToken(); - parent = parent.getBranch(pathElement); - } - parent.addLeaf(name, item); - } + public void add(String name, String path, Object item) { + StringTokenizer st = new StringTokenizer(path, "."); + TreeElement parent = ROOT; + while (st.hasMoreTokens()) { + String pathElement = st.nextToken(); + parent = parent.getBranch(pathElement); + } + parent.addLeaf(name, item); + } - public TreeElement getRoot() { - return ROOT; - } + public TreeElement getRoot() { + return ROOT; + } - public void visit(TreeVisitor visitor) { - ROOT.visitLeafs(visitor); - ROOT.visitBranches(visitor); - } + public void visit(TreeVisitor visitor) { + ROOT.visitLeafs(visitor); + ROOT.visitBranches(visitor); + } - public TreeElement get(String fullPath) { - if ("".equals(fullPath)) { - return ROOT; - } - return ROOT.getByPath(fullPath); - } + public TreeElement get(String fullPath) { + if ("".equals(fullPath)) { + return ROOT; + } + return ROOT.getByPath(fullPath); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TreeElement.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TreeElement.java index 408d69804..d60986c90 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TreeElement.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TreeElement.java @@ -21,147 +21,147 @@ import javax.swing.tree.TreePath; public class TreeElement { - private SortedMap branches; - private SortedMap leafs; - private String name; - private String path; - private Object item; - private TreeElement parent; + private SortedMap branches; + private SortedMap leafs; + private String name; + private String path; + private Object item; + private TreeElement parent; - public TreeElement(String name, String path, Object item, TreeElement parent) { - this.name = name; - this.path = path; - this.item = item; - this.parent = parent; - branches = new TreeMap(); - leafs = new TreeMap(); - } + public TreeElement(String name, String path, Object item, TreeElement parent) { + this.name = name; + this.path = path; + this.item = item; + this.parent = parent; + branches = new TreeMap(); + leafs = new TreeMap(); + } - public TreeElement getParent() { - return parent; - } + public TreeElement getParent() { + return parent; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public String getPath() { - return path; - } + public String getPath() { + return path; + } - public TreePath getTreePath() { - List pathList = new ArrayList(); - TreeElement temp = this; - do { - pathList.add(0, temp); - } while ((temp = temp.getParent()) != null); - return new TreePath(pathList.toArray()); - } + public TreePath getTreePath() { + List pathList = new ArrayList(); + TreeElement temp = this; + do { + pathList.add(0, temp); + } while ((temp = temp.getParent()) != null); + return new TreePath(pathList.toArray()); + } - public Object getItem() { - return item; - } + public Object getItem() { + return item; + } - @Override - public String toString() { - return name; - } + @Override + public String toString() { + return name; + } - TreeElement getBranch(String pathElement) { - TreeElement branch = branches.get(pathElement); - if (branch == null) { - branch = new TreeElement(pathElement, path + "." + pathElement, null, this); - branches.put(pathElement, branch); - } - return branch; - } + TreeElement getBranch(String pathElement) { + TreeElement branch = branches.get(pathElement); + if (branch == null) { + branch = new TreeElement(pathElement, path + "." + pathElement, null, this); + branches.put(pathElement, branch); + } + return branch; + } - void addLeaf(String pathElement, Object item) { - TreeElement child = new TreeElement(pathElement, path + "." + pathElement, item, this); - leafs.put(pathElement, child); - } + void addLeaf(String pathElement, Object item) { + TreeElement child = new TreeElement(pathElement, path + "." + pathElement, item, this); + leafs.put(pathElement, child); + } - public TreeElement getChild(int index) { - Iterator iter; - int startingIndex; - if (index < branches.size()) { - iter = branches.values().iterator(); - startingIndex = 0; - } else { - iter = leafs.values().iterator(); - startingIndex = branches.size(); - } - int ii = startingIndex; - TreeElement child = null; - while (ii <= index && iter.hasNext()) { - child = iter.next(); - ii++; - } - return child; - } + public TreeElement getChild(int index) { + Iterator iter; + int startingIndex; + if (index < branches.size()) { + iter = branches.values().iterator(); + startingIndex = 0; + } else { + iter = leafs.values().iterator(); + startingIndex = branches.size(); + } + int ii = startingIndex; + TreeElement child = null; + while (ii <= index && iter.hasNext()) { + child = iter.next(); + ii++; + } + return child; + } - public int getChildCount() { - return branches.size() + leafs.size(); - } + public int getChildCount() { + return branches.size() + leafs.size(); + } - public boolean isLeaf() { - return getChildCount() == 0; - } + public boolean isLeaf() { + return getChildCount() == 0; + } - public int getIndexOfChild(TreeElement child) { - if (getChildCount() < 1) { - return -1; - } - Iterator iter = branches.values().iterator(); - int ii = 0; - TreeElement aChild = null; - while (aChild != child && iter.hasNext()) { - aChild = iter.next(); - if (aChild == child) { - return ii; - } - ii++; - } - iter = leafs.values().iterator(); - while (aChild != child && iter.hasNext()) { - aChild = iter.next(); - if (aChild == child) { - return ii; - } - ii++; - } - return -1; - } + public int getIndexOfChild(TreeElement child) { + if (getChildCount() < 1) { + return -1; + } + Iterator iter = branches.values().iterator(); + int ii = 0; + TreeElement aChild = null; + while (aChild != child && iter.hasNext()) { + aChild = iter.next(); + if (aChild == child) { + return ii; + } + ii++; + } + iter = leafs.values().iterator(); + while (aChild != child && iter.hasNext()) { + aChild = iter.next(); + if (aChild == child) { + return ii; + } + ii++; + } + return -1; + } - void visitBranches(TreeVisitor visitor) { - Iterator iter = branches.values().iterator(); - while (iter.hasNext()) { - TreeElement branch = iter.next(); - visitor.onBranch(branch); - branch.visitLeafs(visitor); - branch.visitBranches(visitor); - } - } + void visitBranches(TreeVisitor visitor) { + Iterator iter = branches.values().iterator(); + while (iter.hasNext()) { + TreeElement branch = iter.next(); + visitor.onBranch(branch); + branch.visitLeafs(visitor); + branch.visitBranches(visitor); + } + } - void visitLeafs(TreeVisitor visitor) { - Iterator iter = leafs.values().iterator(); - while (iter.hasNext()) { - TreeElement leaf = iter.next(); - visitor.onLeaf(leaf); - } - } + void visitLeafs(TreeVisitor visitor) { + Iterator iter = leafs.values().iterator(); + while (iter.hasNext()) { + TreeElement leaf = iter.next(); + visitor.onLeaf(leaf); + } + } - TreeElement getByPath(String fullPath) { - TreeElement te = this; - StringTokenizer st = new StringTokenizer(fullPath, "."); - while (st.hasMoreTokens()) { - String pathElement = st.nextToken(); - TreeElement nte = te.branches.get(pathElement); - if (nte == null) { - nte = te.leafs.get(pathElement); - } - te = nte; - } - return te; - } + TreeElement getByPath(String fullPath) { + TreeElement te = this; + StringTokenizer st = new StringTokenizer(fullPath, "."); + while (st.hasMoreTokens()) { + String pathElement = st.nextToken(); + TreeElement nte = te.branches.get(pathElement); + if (nte == null) { + nte = te.leafs.get(pathElement); + } + te = nte; + } + return te; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TreeLeafScript.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TreeLeafScript.java index 041b9a912..e50e98d8a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TreeLeafScript.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TreeLeafScript.java @@ -24,11 +24,11 @@ import com.jpexs.decompiler.flash.abc.ABC; */ public class TreeLeafScript { - public ABC abc; - public int scriptIndex; + public ABC abc; + public int scriptIndex; - public TreeLeafScript(ABC abc, int scriptIndex) { - this.abc = abc; - this.scriptIndex = scriptIndex; - } + public TreeLeafScript(ABC abc, int scriptIndex) { + this.abc = abc; + this.scriptIndex = scriptIndex; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TreeVisitor.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TreeVisitor.java index 175bdf21b..6c256b04a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/TreeVisitor.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/TreeVisitor.java @@ -18,7 +18,7 @@ package com.jpexs.decompiler.flash.abc.gui; public interface TreeVisitor { - public void onBranch(TreeElement branch); + public void onBranch(TreeElement branch); - public void onLeaf(TreeElement leaf); + public void onLeaf(TreeElement leaf); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/UsageFrame.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/UsageFrame.java index cde2ea9c8..744bb2ff2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/UsageFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/UsageFrame.java @@ -39,106 +39,106 @@ import javax.swing.*; */ public class UsageFrame extends JFrame implements ActionListener, MouseListener { - private JButton gotoButton = new JButton("Go to"); - private JButton cancelButton = new JButton("Cancel"); - private JList usageList; - private UsageListModel usageListModel; - private ABC abc; - private ABCPanel abcPanel; + private JButton gotoButton = new JButton("Go to"); + private JButton cancelButton = new JButton("Cancel"); + private JList usageList; + private UsageListModel usageListModel; + private ABC abc; + private ABCPanel abcPanel; - public UsageFrame(List abcTags, ABC abc, int multinameIndex, ABCPanel abcPanel) { - this.abcPanel = abcPanel; - List usages = abc.findMultinameUsage(multinameIndex); - this.abc = abc; - usageListModel = new UsageListModel(abcTags, abc); - for (MultinameUsage u : usages) { - usageListModel.addElement(u); - } - usageList = new JList(usageListModel); - gotoButton.setActionCommand("GOTO"); - gotoButton.addActionListener(this); - cancelButton.setActionCommand("CANCEL"); - cancelButton.addActionListener(this); - JPanel buttonsPanel = new JPanel(); - buttonsPanel.setLayout(new FlowLayout()); - buttonsPanel.add(gotoButton); - buttonsPanel.add(cancelButton); + public UsageFrame(List abcTags, ABC abc, int multinameIndex, ABCPanel abcPanel) { + this.abcPanel = abcPanel; + List usages = abc.findMultinameUsage(multinameIndex); + this.abc = abc; + usageListModel = new UsageListModel(abcTags, abc); + for (MultinameUsage u : usages) { + usageListModel.addElement(u); + } + usageList = new JList(usageListModel); + gotoButton.setActionCommand("GOTO"); + gotoButton.addActionListener(this); + cancelButton.setActionCommand("CANCEL"); + cancelButton.addActionListener(this); + JPanel buttonsPanel = new JPanel(); + buttonsPanel.setLayout(new FlowLayout()); + buttonsPanel.add(gotoButton); + buttonsPanel.add(cancelButton); - usageList.addMouseListener(this); - Container cont = getContentPane(); - cont.setLayout(new BorderLayout()); - cont.add(new JScrollPane(usageList), BorderLayout.CENTER); - cont.add(buttonsPanel, BorderLayout.SOUTH); - setSize(400, 300); - setTitle("Usages:" + abc.constants.constant_multiname[multinameIndex].getNameWithNamespace(abc.constants)); - View.centerScreen(this); - View.setWindowIcon(this); - } + usageList.addMouseListener(this); + Container cont = getContentPane(); + cont.setLayout(new BorderLayout()); + cont.add(new JScrollPane(usageList), BorderLayout.CENTER); + cont.add(buttonsPanel, BorderLayout.SOUTH); + setSize(400, 300); + setTitle("Usages:" + abc.constants.constant_multiname[multinameIndex].getNameWithNamespace(abc.constants)); + View.centerScreen(this); + View.setWindowIcon(this); + } - private void gotoUsage() { - if (usageList.getSelectedIndex() != -1) { - MultinameUsage usage = usageListModel.getUsage(usageList.getSelectedIndex()); - if (usage instanceof InsideClassMultinameUsage) { - InsideClassMultinameUsage icu = (InsideClassMultinameUsage) usage; - abcPanel.classTree.selectClass(icu.classIndex); - try { - Thread.sleep(100); - } catch (InterruptedException ex) { + private void gotoUsage() { + if (usageList.getSelectedIndex() != -1) { + MultinameUsage usage = usageListModel.getUsage(usageList.getSelectedIndex()); + if (usage instanceof InsideClassMultinameUsage) { + InsideClassMultinameUsage icu = (InsideClassMultinameUsage) usage; + abcPanel.classTree.selectClass(icu.classIndex); + try { + Thread.sleep(100); + } catch (InterruptedException ex) { + } + if (usage instanceof TraitMultinameUsage) { + TraitMultinameUsage tmu = (TraitMultinameUsage) usage; + int traitIndex; + if (tmu.parentTraitIndex > -1) { + traitIndex = tmu.parentTraitIndex; + } else { + traitIndex = tmu.traitIndex; + } + if (!tmu.isStatic) { + traitIndex += abc.class_info[tmu.classIndex].static_traits.traits.length; + } + if (tmu instanceof MethodMultinameUsage) { + MethodMultinameUsage mmu = (MethodMultinameUsage) usage; + if (mmu.isInitializer == true) { + traitIndex = abc.class_info[mmu.classIndex].static_traits.traits.length + abc.instance_info[mmu.classIndex].instance_traits.traits.length + (mmu.isStatic ? 1 : 0); + } + } + abcPanel.decompiledTextArea.gotoTrait(traitIndex); + } } - if (usage instanceof TraitMultinameUsage) { - TraitMultinameUsage tmu = (TraitMultinameUsage) usage; - int traitIndex; - if (tmu.parentTraitIndex > -1) { - traitIndex = tmu.parentTraitIndex; - } else { - traitIndex = tmu.traitIndex; - } - if (!tmu.isStatic) { - traitIndex += abc.class_info[tmu.classIndex].static_traits.traits.length; - } - if (tmu instanceof MethodMultinameUsage) { - MethodMultinameUsage mmu = (MethodMultinameUsage) usage; - if (mmu.isInitializer == true) { - traitIndex = abc.class_info[mmu.classIndex].static_traits.traits.length + abc.instance_info[mmu.classIndex].instance_traits.traits.length + (mmu.isStatic ? 1 : 0); - } - } - abcPanel.decompiledTextArea.gotoTrait(traitIndex); - } - } - } - } + } + } - @Override - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("GOTO")) { - gotoUsage(); - setVisible(false); - } - if (e.getActionCommand().equals("CANCEL")) { - setVisible(false); - } - } + @Override + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("GOTO")) { + gotoUsage(); + setVisible(false); + } + if (e.getActionCommand().equals("CANCEL")) { + setVisible(false); + } + } - @Override - public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) { - gotoUsage(); - } - } + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2) { + gotoUsage(); + } + } - @Override - public void mousePressed(MouseEvent e) { - } + @Override + public void mousePressed(MouseEvent e) { + } - @Override - public void mouseReleased(MouseEvent e) { - } + @Override + public void mouseReleased(MouseEvent e) { + } - @Override - public void mouseEntered(MouseEvent e) { - } + @Override + public void mouseEntered(MouseEvent e) { + } - @Override - public void mouseExited(MouseEvent e) { - } + @Override + public void mouseExited(MouseEvent e) { + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/UsageListModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/UsageListModel.java index c585738b1..825a87bc7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/UsageListModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/UsageListModel.java @@ -28,25 +28,25 @@ import javax.swing.DefaultListModel; */ public class UsageListModel extends DefaultListModel { - private ABC abc; - private List abcTags; + private ABC abc; + private List abcTags; - public UsageListModel(List abcTags, ABC abc) { - this.abc = abc; - this.abcTags = abcTags; - } + public UsageListModel(List abcTags, ABC abc) { + this.abc = abc; + this.abcTags = abcTags; + } - @Override - public Object get(int index) { - return ((MultinameUsage) super.get(index)).toString(abcTags, abc); - } + @Override + public Object get(int index) { + return ((MultinameUsage) super.get(index)).toString(abcTags, abc); + } - @Override - public Object getElementAt(int index) { - return ((MultinameUsage) super.getElementAt(index)).toString(abcTags, abc); - } + @Override + public Object getElementAt(int index) { + return ((MultinameUsage) super.getElementAt(index)).toString(abcTags, abc); + } - public MultinameUsage getUsage(int index) { - return ((MultinameUsage) super.getElementAt(index)); - } + public MultinameUsage getUsage(int index) { + return ((MultinameUsage) super.getElementAt(index)); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/DecimalTableModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/DecimalTableModel.java index 81bb61558..447e2ee81 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/DecimalTableModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/DecimalTableModel.java @@ -22,140 +22,140 @@ import javax.swing.table.TableModel; public class DecimalTableModel implements TableModel { - private ABC abc; - private static final String columnNames[] = new String[]{"Index", "Value"}; - private static final Class classes[] = new Class[]{Long.class, String.class}; + private ABC abc; + private static final String columnNames[] = new String[]{"Index", "Value"}; + private static final Class classes[] = new Class[]{Long.class, String.class}; - public DecimalTableModel(ABC abc) { - this.abc = abc; - } + public DecimalTableModel(ABC abc) { + this.abc = abc; + } - /** - * Returns the number of rows in the model. A - * JTable uses this method to determine how many rows it should - * display. This method should be quick, as it is called frequently during - * rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - @Override - public int getRowCount() { - if (abc == null) { - return 0; - } - return abc.constants.constant_decimal.length; - } + /** + * Returns the number of rows in the model. A + * JTable uses this method to determine how many rows it should + * display. This method should be quick, as it is called frequently during + * rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + @Override + public int getRowCount() { + if (abc == null) { + return 0; + } + return abc.constants.constant_decimal.length; + } - /** - * Returns the number of columns in the model. A - * JTable uses this method to determine how many columns it - * should create and display by default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - @Override - public int getColumnCount() { - return 2; - } + /** + * Returns the number of columns in the model. A + * JTable uses this method to determine how many columns it + * should create and display by default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + @Override + public int getColumnCount() { + return 2; + } - /** - * Returns the name of the column at - * columnIndex. This is used to initialize the table's column - * header name. Note: this name does not need to be unique; two columns in a - * table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - @Override - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } + /** + * Returns the name of the column at + * columnIndex. This is used to initialize the table's column + * header name. Note: this name does not need to be unique; two columns in a + * table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + @Override + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } - /** - * Returns the most specific superclass for all the cell values in the - * column. This is used by the - * JTable to set up a default renderer and editor for the - * column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - @Override - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the + * JTable to set up a default renderer and editor for the + * column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + @Override + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } - /** - * Returns true if the cell at - * rowIndex and - * columnIndex is editable. Otherwise, - * setValueAt on the cell will not change the value of that - * cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } + /** + * Returns true if the cell at + * rowIndex and + * columnIndex is editable. Otherwise, + * setValueAt on the cell will not change the value of that + * cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } - /** - * Returns the value for the cell at - * columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - if (columnIndex == 0) { - return rowIndex; - } else { - return abc.constants.constant_decimal[rowIndex]; - } - } + /** + * Returns the value for the cell at + * columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + if (columnIndex == 0) { + return rowIndex; + } else { + return abc.constants.constant_decimal[rowIndex]; + } + } - /** - * Sets the value in the cell at - * columnIndex and - * rowIndex to - * aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - @Override - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - } + /** + * Sets the value in the cell at + * columnIndex and + * rowIndex to + * aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + @Override + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } - /** - * Adds a listener to the list that is notified each time a change to the - * data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void addTableModelListener(TableModelListener l) { - } + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void addTableModelListener(TableModelListener l) { + } - /** - * Removes a listener from the list that is notified each time a change to - * the data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void removeTableModelListener(TableModelListener l) { - } + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void removeTableModelListener(TableModelListener l) { + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/DoubleTableModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/DoubleTableModel.java index f2dd6f2f1..fcf4126a8 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/DoubleTableModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/DoubleTableModel.java @@ -22,142 +22,142 @@ import javax.swing.table.TableModel; public class DoubleTableModel implements TableModel { - private ABC abc; - private static final String columnNames[] = new String[]{"Index", "Value"}; - private static final Class classes[] = new Class[]{Long.class, String.class}; + private ABC abc; + private static final String columnNames[] = new String[]{"Index", "Value"}; + private static final Class classes[] = new Class[]{Long.class, String.class}; - public DoubleTableModel(ABC abc) { - this.abc = abc; - } + public DoubleTableModel(ABC abc) { + this.abc = abc; + } - /** - * Returns the number of rows in the model. A - * JTable uses this method to determine how many rows it should - * display. This method should be quick, as it is called frequently during - * rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - @Override - public int getRowCount() { - if (abc == null) { - return 0; - } - return abc.constants.constant_double.length; - } + /** + * Returns the number of rows in the model. A + * JTable uses this method to determine how many rows it should + * display. This method should be quick, as it is called frequently during + * rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + @Override + public int getRowCount() { + if (abc == null) { + return 0; + } + return abc.constants.constant_double.length; + } - /** - * Returns the number of columns in the model. A - * JTable uses this method to determine how many columns it - * should create and display by default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - @Override - public int getColumnCount() { - return 2; - } + /** + * Returns the number of columns in the model. A + * JTable uses this method to determine how many columns it + * should create and display by default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + @Override + public int getColumnCount() { + return 2; + } - /** - * Returns the name of the column at - * columnIndex. This is used to initialize the table's column - * header name. Note: this name does not need to be unique; two columns in a - * table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - @Override - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } + /** + * Returns the name of the column at + * columnIndex. This is used to initialize the table's column + * header name. Note: this name does not need to be unique; two columns in a + * table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + @Override + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } - /** - * Returns the most specific superclass for all the cell values in the - * column. This is used by the - * JTable to set up a default renderer and editor for the - * column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - @Override - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the + * JTable to set up a default renderer and editor for the + * column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + @Override + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } - /** - * Returns true if the cell at - * rowIndex and - * columnIndex is editable. Otherwise, - * setValueAt on the cell will not change the value of that - * cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } + /** + * Returns true if the cell at + * rowIndex and + * columnIndex is editable. Otherwise, + * setValueAt on the cell will not change the value of that + * cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } - /** - * Returns the value for the cell at - * columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - if (columnIndex == 0) { - return rowIndex; - } else if (Double.isNaN(abc.constants.constant_double[rowIndex])) { - return "NaN"; - } else { - return "" + abc.constants.constant_double[rowIndex]; - } - } + /** + * Returns the value for the cell at + * columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + if (columnIndex == 0) { + return rowIndex; + } else if (Double.isNaN(abc.constants.constant_double[rowIndex])) { + return "NaN"; + } else { + return "" + abc.constants.constant_double[rowIndex]; + } + } - /** - * Sets the value in the cell at - * columnIndex and - * rowIndex to - * aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - @Override - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - } + /** + * Sets the value in the cell at + * columnIndex and + * rowIndex to + * aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + @Override + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } - /** - * Adds a listener to the list that is notified each time a change to the - * data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void addTableModelListener(TableModelListener l) { - } + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void addTableModelListener(TableModelListener l) { + } - /** - * Removes a listener from the list that is notified each time a change to - * the data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void removeTableModelListener(TableModelListener l) { - } + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void removeTableModelListener(TableModelListener l) { + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/IntTableModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/IntTableModel.java index 1a97a2021..de68772d0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/IntTableModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/IntTableModel.java @@ -22,140 +22,140 @@ import javax.swing.table.TableModel; public class IntTableModel implements TableModel { - private ABC abc; - private static final String columnNames[] = new String[]{"Index", "Value"}; - private static final Class classes[] = new Class[]{Long.class, Long.class}; + private ABC abc; + private static final String columnNames[] = new String[]{"Index", "Value"}; + private static final Class classes[] = new Class[]{Long.class, Long.class}; - public IntTableModel(ABC abc) { - this.abc = abc; - } + public IntTableModel(ABC abc) { + this.abc = abc; + } - /** - * Returns the number of rows in the model. A - * JTable uses this method to determine how many rows it should - * display. This method should be quick, as it is called frequently during - * rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - @Override - public int getRowCount() { - if (abc == null) { - return 0; - } - return abc.constants.constant_int.length; - } + /** + * Returns the number of rows in the model. A + * JTable uses this method to determine how many rows it should + * display. This method should be quick, as it is called frequently during + * rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + @Override + public int getRowCount() { + if (abc == null) { + return 0; + } + return abc.constants.constant_int.length; + } - /** - * Returns the number of columns in the model. A - * JTable uses this method to determine how many columns it - * should create and display by default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - @Override - public int getColumnCount() { - return 2; - } + /** + * Returns the number of columns in the model. A + * JTable uses this method to determine how many columns it + * should create and display by default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + @Override + public int getColumnCount() { + return 2; + } - /** - * Returns the name of the column at - * columnIndex. This is used to initialize the table's column - * header name. Note: this name does not need to be unique; two columns in a - * table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - @Override - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } + /** + * Returns the name of the column at + * columnIndex. This is used to initialize the table's column + * header name. Note: this name does not need to be unique; two columns in a + * table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + @Override + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } - /** - * Returns the most specific superclass for all the cell values in the - * column. This is used by the - * JTable to set up a default renderer and editor for the - * column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - @Override - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the + * JTable to set up a default renderer and editor for the + * column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + @Override + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } - /** - * Returns true if the cell at - * rowIndex and - * columnIndex is editable. Otherwise, - * setValueAt on the cell will not change the value of that - * cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } + /** + * Returns true if the cell at + * rowIndex and + * columnIndex is editable. Otherwise, + * setValueAt on the cell will not change the value of that + * cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } - /** - * Returns the value for the cell at - * columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - if (columnIndex == 0) { - return rowIndex; - } else { - return abc.constants.constant_int[rowIndex]; - } - } + /** + * Returns the value for the cell at + * columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + if (columnIndex == 0) { + return rowIndex; + } else { + return abc.constants.constant_int[rowIndex]; + } + } - /** - * Sets the value in the cell at - * columnIndex and - * rowIndex to - * aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - @Override - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - } + /** + * Sets the value in the cell at + * columnIndex and + * rowIndex to + * aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + @Override + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } - /** - * Adds a listener to the list that is notified each time a change to the - * data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void addTableModelListener(TableModelListener l) { - } + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void addTableModelListener(TableModelListener l) { + } - /** - * Removes a listener from the list that is notified each time a change to - * the data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void removeTableModelListener(TableModelListener l) { - } + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void removeTableModelListener(TableModelListener l) { + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/MultinameTableModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/MultinameTableModel.java index f9a015dc9..6d1accca4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/MultinameTableModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/MultinameTableModel.java @@ -23,170 +23,170 @@ import javax.swing.table.TableModel; public class MultinameTableModel implements TableModel { - private ABC abc; - private static final String columnNames[] = new String[]{"Index", "Kind", "Name", "Namespace", "NamespaceSet"}; - private static final Class classes[] = new Class[]{Long.class, String.class, String.class, String.class, String.class}; + private ABC abc; + private static final String columnNames[] = new String[]{"Index", "Kind", "Name", "Namespace", "NamespaceSet"}; + private static final Class classes[] = new Class[]{Long.class, String.class, String.class, String.class, String.class}; - public MultinameTableModel(ABC abc) { - this.abc = abc; - } + public MultinameTableModel(ABC abc) { + this.abc = abc; + } - /** - * Returns the number of rows in the model. A - * JTable uses this method to determine how many rows it should - * display. This method should be quick, as it is called frequently during - * rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - @Override - public int getRowCount() { - if (abc == null) { - return 0; - } - return abc.constants.constant_multiname.length; - } + /** + * Returns the number of rows in the model. A + * JTable uses this method to determine how many rows it should + * display. This method should be quick, as it is called frequently during + * rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + @Override + public int getRowCount() { + if (abc == null) { + return 0; + } + return abc.constants.constant_multiname.length; + } - /** - * Returns the number of columns in the model. A - * JTable uses this method to determine how many columns it - * should create and display by default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - @Override - public int getColumnCount() { - return 5; - } + /** + * Returns the number of columns in the model. A + * JTable uses this method to determine how many columns it + * should create and display by default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + @Override + public int getColumnCount() { + return 5; + } - /** - * Returns the name of the column at - * columnIndex. This is used to initialize the table's column - * header name. Note: this name does not need to be unique; two columns in a - * table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - @Override - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } + /** + * Returns the name of the column at + * columnIndex. This is used to initialize the table's column + * header name. Note: this name does not need to be unique; two columns in a + * table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + @Override + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } - /** - * Returns the most specific superclass for all the cell values in the - * column. This is used by the - * JTable to set up a default renderer and editor for the - * column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - @Override - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the + * JTable to set up a default renderer and editor for the + * column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + @Override + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } - /** - * Returns true if the cell at - * rowIndex and - * columnIndex is editable. Otherwise, - * setValueAt on the cell will not change the value of that - * cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } + /** + * Returns true if the cell at + * rowIndex and + * columnIndex is editable. Otherwise, + * setValueAt on the cell will not change the value of that + * cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } - /** - * Returns the value for the cell at - * columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - switch (columnIndex) { - case 0: - return rowIndex; - case 1: - if (rowIndex == 0) { - return ""; - } - return abc.constants.constant_multiname[rowIndex].getKindStr(); - case 2: - if (rowIndex == 0) { - return ""; - } - if (abc.constants.constant_multiname[rowIndex].name_index == -1) { - return ""; - } - return abc.constants.constant_multiname[rowIndex].getName(abc.constants, new ArrayList()); - case 3: - if (rowIndex == 0) { - return ""; - } - if (abc.constants.constant_multiname[rowIndex].namespace_index == -1) { - return ""; - } - return abc.constants.constant_multiname[rowIndex].getNamespace(abc.constants).getNameWithKind(abc.constants); - case 4: - if (rowIndex == 0) { - return ""; - } - if (abc.constants.constant_multiname[rowIndex].namespace_set_index == -1) { - return ""; - } - return abc.constants.constant_multiname[rowIndex].getNamespaceSet(abc.constants).toString(abc.constants); - default: - return null; - } - } + /** + * Returns the value for the cell at + * columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + switch (columnIndex) { + case 0: + return rowIndex; + case 1: + if (rowIndex == 0) { + return ""; + } + return abc.constants.constant_multiname[rowIndex].getKindStr(); + case 2: + if (rowIndex == 0) { + return ""; + } + if (abc.constants.constant_multiname[rowIndex].name_index == -1) { + return ""; + } + return abc.constants.constant_multiname[rowIndex].getName(abc.constants, new ArrayList()); + case 3: + if (rowIndex == 0) { + return ""; + } + if (abc.constants.constant_multiname[rowIndex].namespace_index == -1) { + return ""; + } + return abc.constants.constant_multiname[rowIndex].getNamespace(abc.constants).getNameWithKind(abc.constants); + case 4: + if (rowIndex == 0) { + return ""; + } + if (abc.constants.constant_multiname[rowIndex].namespace_set_index == -1) { + return ""; + } + return abc.constants.constant_multiname[rowIndex].getNamespaceSet(abc.constants).toString(abc.constants); + default: + return null; + } + } - /** - * Sets the value in the cell at - * columnIndex and - * rowIndex to - * aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - @Override - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - } + /** + * Sets the value in the cell at + * columnIndex and + * rowIndex to + * aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + @Override + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } - /** - * Adds a listener to the list that is notified each time a change to the - * data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void addTableModelListener(TableModelListener l) { - } + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void addTableModelListener(TableModelListener l) { + } - /** - * Removes a listener from the list that is notified each time a change to - * the data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void removeTableModelListener(TableModelListener l) { - } + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void removeTableModelListener(TableModelListener l) { + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/NamespaceSetTableModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/NamespaceSetTableModel.java index 7196c60de..0993b1e73 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/NamespaceSetTableModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/NamespaceSetTableModel.java @@ -22,146 +22,146 @@ import javax.swing.table.TableModel; public class NamespaceSetTableModel implements TableModel { - private ABC abc; - private static final String columnNames[] = new String[]{"Index", "NameSpaces"}; - private static final Class classes[] = new Class[]{Long.class, String.class, String.class}; + private ABC abc; + private static final String columnNames[] = new String[]{"Index", "NameSpaces"}; + private static final Class classes[] = new Class[]{Long.class, String.class, String.class}; - public NamespaceSetTableModel(ABC abc) { - this.abc = abc; - } + public NamespaceSetTableModel(ABC abc) { + this.abc = abc; + } - /** - * Returns the number of rows in the model. A - * JTable uses this method to determine how many rows it should - * display. This method should be quick, as it is called frequently during - * rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - @Override - public int getRowCount() { - if (abc == null) { - return 0; - } - return abc.constants.constant_namespace_set.length; - } + /** + * Returns the number of rows in the model. A + * JTable uses this method to determine how many rows it should + * display. This method should be quick, as it is called frequently during + * rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + @Override + public int getRowCount() { + if (abc == null) { + return 0; + } + return abc.constants.constant_namespace_set.length; + } - /** - * Returns the number of columns in the model. A - * JTable uses this method to determine how many columns it - * should create and display by default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - @Override - public int getColumnCount() { - return 2; - } + /** + * Returns the number of columns in the model. A + * JTable uses this method to determine how many columns it + * should create and display by default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + @Override + public int getColumnCount() { + return 2; + } - /** - * Returns the name of the column at - * columnIndex. This is used to initialize the table's column - * header name. Note: this name does not need to be unique; two columns in a - * table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - @Override - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } + /** + * Returns the name of the column at + * columnIndex. This is used to initialize the table's column + * header name. Note: this name does not need to be unique; two columns in a + * table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + @Override + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } - /** - * Returns the most specific superclass for all the cell values in the - * column. This is used by the - * JTable to set up a default renderer and editor for the - * column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - @Override - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the + * JTable to set up a default renderer and editor for the + * column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + @Override + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } - /** - * Returns true if the cell at - * rowIndex and - * columnIndex is editable. Otherwise, - * setValueAt on the cell will not change the value of that - * cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } + /** + * Returns true if the cell at + * rowIndex and + * columnIndex is editable. Otherwise, + * setValueAt on the cell will not change the value of that + * cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } - /** - * Returns the value for the cell at - * columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - switch (columnIndex) { - case 0: - return rowIndex; - case 1: - if (rowIndex == 0) { - return ""; - } - return abc.constants.constant_namespace_set[rowIndex].toString(abc.constants); - default: - return null; - } - } + /** + * Returns the value for the cell at + * columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + switch (columnIndex) { + case 0: + return rowIndex; + case 1: + if (rowIndex == 0) { + return ""; + } + return abc.constants.constant_namespace_set[rowIndex].toString(abc.constants); + default: + return null; + } + } - /** - * Sets the value in the cell at - * columnIndex and - * rowIndex to - * aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - @Override - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - } + /** + * Sets the value in the cell at + * columnIndex and + * rowIndex to + * aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + @Override + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } - /** - * Adds a listener to the list that is notified each time a change to the - * data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void addTableModelListener(TableModelListener l) { - } + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void addTableModelListener(TableModelListener l) { + } - /** - * Removes a listener from the list that is notified each time a change to - * the data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void removeTableModelListener(TableModelListener l) { - } + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void removeTableModelListener(TableModelListener l) { + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/NamespaceTableModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/NamespaceTableModel.java index 190f7762d..21820fb9b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/NamespaceTableModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/NamespaceTableModel.java @@ -22,151 +22,151 @@ import javax.swing.table.TableModel; public class NamespaceTableModel implements TableModel { - private ABC abc; - private static final String columnNames[] = new String[]{"Index", "Kind", "Name"}; - private static final Class classes[] = new Class[]{Long.class, String.class, String.class}; + private ABC abc; + private static final String columnNames[] = new String[]{"Index", "Kind", "Name"}; + private static final Class classes[] = new Class[]{Long.class, String.class, String.class}; - public NamespaceTableModel(ABC abc) { - this.abc = abc; - } + public NamespaceTableModel(ABC abc) { + this.abc = abc; + } - /** - * Returns the number of rows in the model. A - * JTable uses this method to determine how many rows it should - * display. This method should be quick, as it is called frequently during - * rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - @Override - public int getRowCount() { - if (abc == null) { - return 0; - } - return abc.constants.constant_namespace.length; - } + /** + * Returns the number of rows in the model. A + * JTable uses this method to determine how many rows it should + * display. This method should be quick, as it is called frequently during + * rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + @Override + public int getRowCount() { + if (abc == null) { + return 0; + } + return abc.constants.constant_namespace.length; + } - /** - * Returns the number of columns in the model. A - * JTable uses this method to determine how many columns it - * should create and display by default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - @Override - public int getColumnCount() { - return 3; - } + /** + * Returns the number of columns in the model. A + * JTable uses this method to determine how many columns it + * should create and display by default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + @Override + public int getColumnCount() { + return 3; + } - /** - * Returns the name of the column at - * columnIndex. This is used to initialize the table's column - * header name. Note: this name does not need to be unique; two columns in a - * table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - @Override - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } + /** + * Returns the name of the column at + * columnIndex. This is used to initialize the table's column + * header name. Note: this name does not need to be unique; two columns in a + * table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + @Override + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } - /** - * Returns the most specific superclass for all the cell values in the - * column. This is used by the - * JTable to set up a default renderer and editor for the - * column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - @Override - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the + * JTable to set up a default renderer and editor for the + * column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + @Override + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } - /** - * Returns true if the cell at - * rowIndex and - * columnIndex is editable. Otherwise, - * setValueAt on the cell will not change the value of that - * cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } + /** + * Returns true if the cell at + * rowIndex and + * columnIndex is editable. Otherwise, + * setValueAt on the cell will not change the value of that + * cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } - /** - * Returns the value for the cell at - * columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - switch (columnIndex) { - case 0: - return rowIndex; - case 1: - if (rowIndex == 0) { - return "-"; - } - return abc.constants.constant_namespace[rowIndex].getKindStr(); - case 2: - if (rowIndex == 0) { - return "-"; - } - return abc.constants.constant_namespace[rowIndex].getName(abc.constants); - default: - return null; - } - } + /** + * Returns the value for the cell at + * columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + switch (columnIndex) { + case 0: + return rowIndex; + case 1: + if (rowIndex == 0) { + return "-"; + } + return abc.constants.constant_namespace[rowIndex].getKindStr(); + case 2: + if (rowIndex == 0) { + return "-"; + } + return abc.constants.constant_namespace[rowIndex].getName(abc.constants); + default: + return null; + } + } - /** - * Sets the value in the cell at - * columnIndex and - * rowIndex to - * aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - @Override - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - } + /** + * Sets the value in the cell at + * columnIndex and + * rowIndex to + * aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + @Override + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } - /** - * Adds a listener to the list that is notified each time a change to the - * data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void addTableModelListener(TableModelListener l) { - } + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void addTableModelListener(TableModelListener l) { + } - /** - * Removes a listener from the list that is notified each time a change to - * the data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void removeTableModelListener(TableModelListener l) { - } + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void removeTableModelListener(TableModelListener l) { + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/StringTableModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/StringTableModel.java index e35a05d3f..ac52715d9 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/StringTableModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/StringTableModel.java @@ -22,140 +22,140 @@ import javax.swing.table.TableModel; public class StringTableModel implements TableModel { - private ABC abc; - private static final String columnNames[] = new String[]{"Index", "Value"}; - private static final Class classes[] = new Class[]{Long.class, String.class}; + private ABC abc; + private static final String columnNames[] = new String[]{"Index", "Value"}; + private static final Class classes[] = new Class[]{Long.class, String.class}; - public StringTableModel(ABC abc) { - this.abc = abc; - } + public StringTableModel(ABC abc) { + this.abc = abc; + } - /** - * Returns the number of rows in the model. A - * JTable uses this method to determine how many rows it should - * display. This method should be quick, as it is called frequently during - * rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - @Override - public int getRowCount() { - if (abc == null) { - return 0; - } - return abc.constants.constant_string.length; - } + /** + * Returns the number of rows in the model. A + * JTable uses this method to determine how many rows it should + * display. This method should be quick, as it is called frequently during + * rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + @Override + public int getRowCount() { + if (abc == null) { + return 0; + } + return abc.constants.constant_string.length; + } - /** - * Returns the number of columns in the model. A - * JTable uses this method to determine how many columns it - * should create and display by default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - @Override - public int getColumnCount() { - return 2; - } + /** + * Returns the number of columns in the model. A + * JTable uses this method to determine how many columns it + * should create and display by default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + @Override + public int getColumnCount() { + return 2; + } - /** - * Returns the name of the column at - * columnIndex. This is used to initialize the table's column - * header name. Note: this name does not need to be unique; two columns in a - * table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - @Override - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } + /** + * Returns the name of the column at + * columnIndex. This is used to initialize the table's column + * header name. Note: this name does not need to be unique; two columns in a + * table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + @Override + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } - /** - * Returns the most specific superclass for all the cell values in the - * column. This is used by the - * JTable to set up a default renderer and editor for the - * column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - @Override - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the + * JTable to set up a default renderer and editor for the + * column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + @Override + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } - /** - * Returns true if the cell at - * rowIndex and - * columnIndex is editable. Otherwise, - * setValueAt on the cell will not change the value of that - * cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } + /** + * Returns true if the cell at + * rowIndex and + * columnIndex is editable. Otherwise, + * setValueAt on the cell will not change the value of that + * cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } - /** - * Returns the value for the cell at - * columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - if (columnIndex == 0) { - return rowIndex; - } else { - return abc.constants.constant_string[rowIndex]; - } - } + /** + * Returns the value for the cell at + * columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + if (columnIndex == 0) { + return rowIndex; + } else { + return abc.constants.constant_string[rowIndex]; + } + } - /** - * Sets the value in the cell at - * columnIndex and - * rowIndex to - * aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - @Override - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - } + /** + * Sets the value in the cell at + * columnIndex and + * rowIndex to + * aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + @Override + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } - /** - * Adds a listener to the list that is notified each time a change to the - * data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void addTableModelListener(TableModelListener l) { - } + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void addTableModelListener(TableModelListener l) { + } - /** - * Removes a listener from the list that is notified each time a change to - * the data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void removeTableModelListener(TableModelListener l) { - } + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void removeTableModelListener(TableModelListener l) { + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/UIntTableModel.java b/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/UIntTableModel.java index e2b4cad89..298e4c36e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/UIntTableModel.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/gui/tablemodels/UIntTableModel.java @@ -22,140 +22,140 @@ import javax.swing.table.TableModel; public class UIntTableModel implements TableModel { - private ABC abc; - private static final String columnNames[] = new String[]{"Index", "Value"}; - private static final Class classes[] = new Class[]{Long.class, Long.class}; + private ABC abc; + private static final String columnNames[] = new String[]{"Index", "Value"}; + private static final Class classes[] = new Class[]{Long.class, Long.class}; - public UIntTableModel(ABC abc) { - this.abc = abc; - } + public UIntTableModel(ABC abc) { + this.abc = abc; + } - /** - * Returns the number of rows in the model. A - * JTable uses this method to determine how many rows it should - * display. This method should be quick, as it is called frequently during - * rendering. - * - * @return the number of rows in the model - * @see #getColumnCount - */ - @Override - public int getRowCount() { - if (abc == null) { - return 0; - } - return abc.constants.constant_uint.length; - } + /** + * Returns the number of rows in the model. A + * JTable uses this method to determine how many rows it should + * display. This method should be quick, as it is called frequently during + * rendering. + * + * @return the number of rows in the model + * @see #getColumnCount + */ + @Override + public int getRowCount() { + if (abc == null) { + return 0; + } + return abc.constants.constant_uint.length; + } - /** - * Returns the number of columns in the model. A - * JTable uses this method to determine how many columns it - * should create and display by default. - * - * @return the number of columns in the model - * @see #getRowCount - */ - @Override - public int getColumnCount() { - return 2; - } + /** + * Returns the number of columns in the model. A + * JTable uses this method to determine how many columns it + * should create and display by default. + * + * @return the number of columns in the model + * @see #getRowCount + */ + @Override + public int getColumnCount() { + return 2; + } - /** - * Returns the name of the column at - * columnIndex. This is used to initialize the table's column - * header name. Note: this name does not need to be unique; two columns in a - * table can have the same name. - * - * @param columnIndex the index of the column - * @return the name of the column - */ - @Override - public String getColumnName(int columnIndex) { - return columnNames[columnIndex]; - } + /** + * Returns the name of the column at + * columnIndex. This is used to initialize the table's column + * header name. Note: this name does not need to be unique; two columns in a + * table can have the same name. + * + * @param columnIndex the index of the column + * @return the name of the column + */ + @Override + public String getColumnName(int columnIndex) { + return columnNames[columnIndex]; + } - /** - * Returns the most specific superclass for all the cell values in the - * column. This is used by the - * JTable to set up a default renderer and editor for the - * column. - * - * @param columnIndex the index of the column - * @return the common ancestor class of the object values in the model. - */ - @Override - public Class getColumnClass(int columnIndex) { - return classes[columnIndex]; - } + /** + * Returns the most specific superclass for all the cell values in the + * column. This is used by the + * JTable to set up a default renderer and editor for the + * column. + * + * @param columnIndex the index of the column + * @return the common ancestor class of the object values in the model. + */ + @Override + public Class getColumnClass(int columnIndex) { + return classes[columnIndex]; + } - /** - * Returns true if the cell at - * rowIndex and - * columnIndex is editable. Otherwise, - * setValueAt on the cell will not change the value of that - * cell. - * - * @param rowIndex the row whose value to be queried - * @param columnIndex the column whose value to be queried - * @return true if the cell is editable - * @see #setValueAt - */ - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } + /** + * Returns true if the cell at + * rowIndex and + * columnIndex is editable. Otherwise, + * setValueAt on the cell will not change the value of that + * cell. + * + * @param rowIndex the row whose value to be queried + * @param columnIndex the column whose value to be queried + * @return true if the cell is editable + * @see #setValueAt + */ + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + return false; + } - /** - * Returns the value for the cell at - * columnIndex and - * rowIndex. - * - * @param rowIndex the row whose value is to be queried - * @param columnIndex the column whose value is to be queried - * @return the value Object at the specified cell - */ - @Override - public Object getValueAt(int rowIndex, int columnIndex) { - if (columnIndex == 0) { - return rowIndex; - } else { - return abc.constants.constant_uint[rowIndex]; - } - } + /** + * Returns the value for the cell at + * columnIndex and + * rowIndex. + * + * @param rowIndex the row whose value is to be queried + * @param columnIndex the column whose value is to be queried + * @return the value Object at the specified cell + */ + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + if (columnIndex == 0) { + return rowIndex; + } else { + return abc.constants.constant_uint[rowIndex]; + } + } - /** - * Sets the value in the cell at - * columnIndex and - * rowIndex to - * aValue. - * - * @param aValue the new value - * @param rowIndex the row whose value is to be changed - * @param columnIndex the column whose value is to be changed - * @see #getValueAt - * @see #isCellEditable - */ - @Override - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - } + /** + * Sets the value in the cell at + * columnIndex and + * rowIndex to + * aValue. + * + * @param aValue the new value + * @param rowIndex the row whose value is to be changed + * @param columnIndex the column whose value is to be changed + * @see #getValueAt + * @see #isCellEditable + */ + @Override + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + } - /** - * Adds a listener to the list that is notified each time a change to the - * data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void addTableModelListener(TableModelListener l) { - } + /** + * Adds a listener to the list that is notified each time a change to the + * data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void addTableModelListener(TableModelListener l) { + } - /** - * Removes a listener from the list that is notified each time a change to - * the data model occurs. - * - * @param l the TableModelListener - */ - @Override - public void removeTableModelListener(TableModelListener l) { - } + /** + * Removes a listener from the list that is notified each time a change to + * the data model occurs. + * + * @param l the TableModelListener + */ + @Override + public void removeTableModelListener(TableModelListener l) { + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/MethodInfoLexer.java b/trunk/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/MethodInfoLexer.java index 80cc60032..b64531caf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/MethodInfoLexer.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/MethodInfoLexer.java @@ -23,1052 +23,1052 @@ package com.jpexs.decompiler.flash.abc.methodinfo_parser; */ public final class MethodInfoLexer { - /** - * This character denotes the end of file - */ - public static final int YYEOF = -1; - /** - * initial size of the lookahead buffer - */ - private static final int ZZ_BUFFERSIZE = 16384; - /** - * lexical states - */ - public static final int STRING = 2; - public static final int YYINITIAL = 0; - /** - * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l - * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l at the - * beginning of a line l is of the form l = 2*k, k a non negative integer - */ - private static final int ZZ_LEXSTATE[] = { - 0, 0, 1, 1 - }; - /** - * Translates characters to character classes - */ - private static final String ZZ_CMAP_PACKED = - "\11\5\1\3\1\2\1\0\1\3\1\1\16\5\4\0\1\3\1\0" - + "\1\42\1\0\1\4\2\0\1\56\2\0\1\45\1\37\1\44\1\7" - + "\1\35\1\0\1\6\3\57\4\40\2\10\1\43\2\0\1\46\3\0" - + "\4\4\1\36\6\4\1\31\1\4\1\25\1\4\1\17\12\4\1\12" - + "\1\41\1\13\1\0\1\4\1\0\1\32\1\27\1\50\1\51\1\24" - + "\1\55\1\53\1\4\1\21\1\4\1\52\1\33\1\11\1\14\1\20" - + "\1\47\1\4\1\30\1\15\1\22\1\26\1\23\1\4\1\54\2\4" - + "\1\16\1\0\1\34\1\0\41\5\2\0\4\4\4\0\1\4\2\0" - + "\1\5\7\0\1\4\4\0\1\4\5\0\27\4\1\0\37\4\1\0" - + "\u013f\4\31\0\162\4\4\0\14\4\16\0\5\4\11\0\1\4\21\0" - + "\130\5\5\0\23\5\12\0\1\4\13\0\1\4\1\0\3\4\1\0" - + "\1\4\1\0\24\4\1\0\54\4\1\0\46\4\1\0\5\4\4\0" - + "\202\4\1\0\4\5\3\0\105\4\1\0\46\4\2\0\2\4\6\0" - + "\20\4\41\0\46\4\2\0\1\4\7\0\47\4\11\0\21\5\1\0" - + "\27\5\1\0\3\5\1\0\1\5\1\0\2\5\1\0\1\5\13\0" - + "\33\4\5\0\3\4\15\0\4\5\14\0\6\5\13\0\32\4\5\0" - + "\13\4\16\5\7\0\12\5\4\0\2\4\1\5\143\4\1\0\1\4" - + "\10\5\1\0\6\5\2\4\2\5\1\0\4\5\2\4\12\5\3\4" - + "\2\0\1\4\17\0\1\5\1\4\1\5\36\4\33\5\2\0\3\4" - + "\60\0\46\4\13\5\1\4\u014f\0\3\5\66\4\2\0\1\5\1\4" - + "\20\5\2\0\1\4\4\5\3\0\12\4\2\5\2\0\12\5\21\0" - + "\3\5\1\0\10\4\2\0\2\4\2\0\26\4\1\0\7\4\1\0" - + "\1\4\3\0\4\4\2\0\1\5\1\4\7\5\2\0\2\5\2\0" - + "\3\5\11\0\1\5\4\0\2\4\1\0\3\4\2\5\2\0\12\5" - + "\4\4\15\0\3\5\1\0\6\4\4\0\2\4\2\0\26\4\1\0" - + "\7\4\1\0\2\4\1\0\2\4\1\0\2\4\2\0\1\5\1\0" - + "\5\5\4\0\2\5\2\0\3\5\13\0\4\4\1\0\1\4\7\0" - + "\14\5\3\4\14\0\3\5\1\0\11\4\1\0\3\4\1\0\26\4" - + "\1\0\7\4\1\0\2\4\1\0\5\4\2\0\1\5\1\4\10\5" - + "\1\0\3\5\1\0\3\5\2\0\1\4\17\0\2\4\2\5\2\0" - + "\12\5\1\0\1\4\17\0\3\5\1\0\10\4\2\0\2\4\2\0" - + "\26\4\1\0\7\4\1\0\2\4\1\0\5\4\2\0\1\5\1\4" - + "\6\5\3\0\2\5\2\0\3\5\10\0\2\5\4\0\2\4\1\0" - + "\3\4\4\0\12\5\1\0\1\4\20\0\1\5\1\4\1\0\6\4" - + "\3\0\3\4\1\0\4\4\3\0\2\4\1\0\1\4\1\0\2\4" - + "\3\0\2\4\3\0\3\4\3\0\10\4\1\0\3\4\4\0\5\5" - + "\3\0\3\5\1\0\4\5\11\0\1\5\17\0\11\5\11\0\1\4" - + "\7\0\3\5\1\0\10\4\1\0\3\4\1\0\27\4\1\0\12\4" - + "\1\0\5\4\4\0\7\5\1\0\3\5\1\0\4\5\7\0\2\5" - + "\11\0\2\4\4\0\12\5\22\0\2\5\1\0\10\4\1\0\3\4" - + "\1\0\27\4\1\0\12\4\1\0\5\4\2\0\1\5\1\4\7\5" - + "\1\0\3\5\1\0\4\5\7\0\2\5\7\0\1\4\1\0\2\4" - + "\4\0\12\5\22\0\2\5\1\0\10\4\1\0\3\4\1\0\27\4" - + "\1\0\20\4\4\0\6\5\2\0\3\5\1\0\4\5\11\0\1\5" - + "\10\0\2\4\4\0\12\5\22\0\2\5\1\0\22\4\3\0\30\4" - + "\1\0\11\4\1\0\1\4\2\0\7\4\3\0\1\5\4\0\6\5" - + "\1\0\1\5\1\0\10\5\22\0\2\5\15\0\60\4\1\5\2\4" - + "\7\5\4\0\10\4\10\5\1\0\12\5\47\0\2\4\1\0\1\4" - + "\2\0\2\4\1\0\1\4\2\0\1\4\6\0\4\4\1\0\7\4" - + "\1\0\3\4\1\0\1\4\1\0\1\4\2\0\2\4\1\0\4\4" - + "\1\5\2\4\6\5\1\0\2\5\1\4\2\0\5\4\1\0\1\4" - + "\1\0\6\5\2\0\12\5\2\0\2\4\42\0\1\4\27\0\2\5" - + "\6\0\12\5\13\0\1\5\1\0\1\5\1\0\1\5\4\0\2\5" - + "\10\4\1\0\42\4\6\0\24\5\1\0\2\5\4\4\4\0\10\5" - + "\1\0\44\5\11\0\1\5\71\0\42\4\1\0\5\4\1\0\2\4" - + "\1\0\7\5\3\0\4\5\6\0\12\5\6\0\6\4\4\5\106\0" - + "\46\4\12\0\51\4\7\0\132\4\5\0\104\4\5\0\122\4\6\0" - + "\7\4\1\0\77\4\1\0\1\4\1\0\4\4\2\0\7\4\1\0" - + "\1\4\1\0\4\4\2\0\47\4\1\0\1\4\1\0\4\4\2\0" - + "\37\4\1\0\1\4\1\0\4\4\2\0\7\4\1\0\1\4\1\0" - + "\4\4\2\0\7\4\1\0\7\4\1\0\27\4\1\0\37\4\1\0" - + "\1\4\1\0\4\4\2\0\7\4\1\0\47\4\1\0\23\4\16\0" - + "\11\5\56\0\125\4\14\0\u026c\4\2\0\10\4\12\0\32\4\5\0" - + "\113\4\3\0\3\4\17\0\15\4\1\0\4\4\3\5\13\0\22\4" - + "\3\5\13\0\22\4\2\5\14\0\15\4\1\0\3\4\1\0\2\5" - + "\14\0\64\4\40\5\3\0\1\4\3\0\2\4\1\5\2\0\12\5" - + "\41\0\3\5\2\0\12\5\6\0\130\4\10\0\51\4\1\5\126\0" - + "\35\4\3\0\14\5\4\0\14\5\12\0\12\5\36\4\2\0\5\4" - + "\u038b\0\154\4\224\0\234\4\4\0\132\4\6\0\26\4\2\0\6\4" - + "\2\0\46\4\2\0\6\4\2\0\10\4\1\0\1\4\1\0\1\4" - + "\1\0\1\4\1\0\37\4\2\0\65\4\1\0\7\4\1\0\1\4" - + "\3\0\3\4\1\0\7\4\3\0\4\4\2\0\6\4\4\0\15\4" - + "\5\0\3\4\1\0\7\4\17\0\4\5\32\0\5\5\20\0\2\4" - + "\23\0\1\4\13\0\4\5\6\0\6\5\1\0\1\4\15\0\1\4" - + "\40\0\22\4\36\0\15\5\4\0\1\5\3\0\6\5\27\0\1\4" - + "\4\0\1\4\2\0\12\4\1\0\1\4\3\0\5\4\6\0\1\4" - + "\1\0\1\4\1\0\1\4\1\0\4\4\1\0\3\4\1\0\7\4" - + "\3\0\3\4\5\0\5\4\26\0\44\4\u0e81\0\3\4\31\0\11\4" - + "\6\5\1\0\5\4\2\0\5\4\4\0\126\4\2\0\2\5\2\0" - + "\3\4\1\0\137\4\5\0\50\4\4\0\136\4\21\0\30\4\70\0" - + "\20\4\u0200\0\u19b6\4\112\0\u51a6\4\132\0\u048d\4\u0773\0\u2ba4\4\u215c\0" - + "\u012e\4\2\0\73\4\225\0\7\4\14\0\5\4\5\0\1\4\1\5" - + "\12\4\1\0\15\4\1\0\5\4\1\0\1\4\1\0\2\4\1\0" - + "\2\4\1\0\154\4\41\0\u016b\4\22\0\100\4\2\0\66\4\50\0" - + "\15\4\3\0\20\5\20\0\4\5\17\0\2\4\30\0\3\4\31\0" - + "\1\4\6\0\5\4\1\0\207\4\2\0\1\5\4\0\1\4\13\0" - + "\12\5\7\0\32\4\4\0\1\4\1\0\32\4\12\0\132\4\3\0" - + "\6\4\2\0\6\4\2\0\6\4\2\0\3\4\3\0\2\4\3\0" - + "\2\4\22\0\3\5\4\0"; - /** - * Translates characters to character classes - */ - private static final char[] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); - /** - * Translates DFA states to action switch labels. - */ - private static final int[] ZZ_ACTION = zzUnpackAction(); - private static final String ZZ_ACTION_PACKED_0 = - "\2\0\2\1\1\2\1\3\1\1\1\3\7\2\1\1" - + "\1\4\1\5\1\6\1\7\1\10\2\2\1\11\2\12" - + "\1\1\1\13\1\14\1\0\1\14\2\0\7\2\1\0" - + "\3\2\1\15\1\16\1\17\1\20\1\21\1\22\1\16" - + "\1\23\1\24\1\25\1\26\1\14\4\0\6\2\1\27" - + "\4\2\1\16\2\0\1\30\2\2\1\31\6\2\1\32" - + "\1\0\7\2\1\33\1\0\1\34\6\2\1\0\4\2" - + "\1\35\1\36\1\0\1\37\1\40\2\2\1\0\1\41" - + "\1\42\20\0\1\43"; + /** + * This character denotes the end of file + */ + public static final int YYEOF = -1; + /** + * initial size of the lookahead buffer + */ + private static final int ZZ_BUFFERSIZE = 16384; + /** + * lexical states + */ + public static final int STRING = 2; + public static final int YYINITIAL = 0; + /** + * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l + * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l at the + * beginning of a line l is of the form l = 2*k, k a non negative integer + */ + private static final int ZZ_LEXSTATE[] = { + 0, 0, 1, 1 + }; + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED = + "\11\5\1\3\1\2\1\0\1\3\1\1\16\5\4\0\1\3\1\0" + + "\1\42\1\0\1\4\2\0\1\56\2\0\1\45\1\37\1\44\1\7" + + "\1\35\1\0\1\6\3\57\4\40\2\10\1\43\2\0\1\46\3\0" + + "\4\4\1\36\6\4\1\31\1\4\1\25\1\4\1\17\12\4\1\12" + + "\1\41\1\13\1\0\1\4\1\0\1\32\1\27\1\50\1\51\1\24" + + "\1\55\1\53\1\4\1\21\1\4\1\52\1\33\1\11\1\14\1\20" + + "\1\47\1\4\1\30\1\15\1\22\1\26\1\23\1\4\1\54\2\4" + + "\1\16\1\0\1\34\1\0\41\5\2\0\4\4\4\0\1\4\2\0" + + "\1\5\7\0\1\4\4\0\1\4\5\0\27\4\1\0\37\4\1\0" + + "\u013f\4\31\0\162\4\4\0\14\4\16\0\5\4\11\0\1\4\21\0" + + "\130\5\5\0\23\5\12\0\1\4\13\0\1\4\1\0\3\4\1\0" + + "\1\4\1\0\24\4\1\0\54\4\1\0\46\4\1\0\5\4\4\0" + + "\202\4\1\0\4\5\3\0\105\4\1\0\46\4\2\0\2\4\6\0" + + "\20\4\41\0\46\4\2\0\1\4\7\0\47\4\11\0\21\5\1\0" + + "\27\5\1\0\3\5\1\0\1\5\1\0\2\5\1\0\1\5\13\0" + + "\33\4\5\0\3\4\15\0\4\5\14\0\6\5\13\0\32\4\5\0" + + "\13\4\16\5\7\0\12\5\4\0\2\4\1\5\143\4\1\0\1\4" + + "\10\5\1\0\6\5\2\4\2\5\1\0\4\5\2\4\12\5\3\4" + + "\2\0\1\4\17\0\1\5\1\4\1\5\36\4\33\5\2\0\3\4" + + "\60\0\46\4\13\5\1\4\u014f\0\3\5\66\4\2\0\1\5\1\4" + + "\20\5\2\0\1\4\4\5\3\0\12\4\2\5\2\0\12\5\21\0" + + "\3\5\1\0\10\4\2\0\2\4\2\0\26\4\1\0\7\4\1\0" + + "\1\4\3\0\4\4\2\0\1\5\1\4\7\5\2\0\2\5\2\0" + + "\3\5\11\0\1\5\4\0\2\4\1\0\3\4\2\5\2\0\12\5" + + "\4\4\15\0\3\5\1\0\6\4\4\0\2\4\2\0\26\4\1\0" + + "\7\4\1\0\2\4\1\0\2\4\1\0\2\4\2\0\1\5\1\0" + + "\5\5\4\0\2\5\2\0\3\5\13\0\4\4\1\0\1\4\7\0" + + "\14\5\3\4\14\0\3\5\1\0\11\4\1\0\3\4\1\0\26\4" + + "\1\0\7\4\1\0\2\4\1\0\5\4\2\0\1\5\1\4\10\5" + + "\1\0\3\5\1\0\3\5\2\0\1\4\17\0\2\4\2\5\2\0" + + "\12\5\1\0\1\4\17\0\3\5\1\0\10\4\2\0\2\4\2\0" + + "\26\4\1\0\7\4\1\0\2\4\1\0\5\4\2\0\1\5\1\4" + + "\6\5\3\0\2\5\2\0\3\5\10\0\2\5\4\0\2\4\1\0" + + "\3\4\4\0\12\5\1\0\1\4\20\0\1\5\1\4\1\0\6\4" + + "\3\0\3\4\1\0\4\4\3\0\2\4\1\0\1\4\1\0\2\4" + + "\3\0\2\4\3\0\3\4\3\0\10\4\1\0\3\4\4\0\5\5" + + "\3\0\3\5\1\0\4\5\11\0\1\5\17\0\11\5\11\0\1\4" + + "\7\0\3\5\1\0\10\4\1\0\3\4\1\0\27\4\1\0\12\4" + + "\1\0\5\4\4\0\7\5\1\0\3\5\1\0\4\5\7\0\2\5" + + "\11\0\2\4\4\0\12\5\22\0\2\5\1\0\10\4\1\0\3\4" + + "\1\0\27\4\1\0\12\4\1\0\5\4\2\0\1\5\1\4\7\5" + + "\1\0\3\5\1\0\4\5\7\0\2\5\7\0\1\4\1\0\2\4" + + "\4\0\12\5\22\0\2\5\1\0\10\4\1\0\3\4\1\0\27\4" + + "\1\0\20\4\4\0\6\5\2\0\3\5\1\0\4\5\11\0\1\5" + + "\10\0\2\4\4\0\12\5\22\0\2\5\1\0\22\4\3\0\30\4" + + "\1\0\11\4\1\0\1\4\2\0\7\4\3\0\1\5\4\0\6\5" + + "\1\0\1\5\1\0\10\5\22\0\2\5\15\0\60\4\1\5\2\4" + + "\7\5\4\0\10\4\10\5\1\0\12\5\47\0\2\4\1\0\1\4" + + "\2\0\2\4\1\0\1\4\2\0\1\4\6\0\4\4\1\0\7\4" + + "\1\0\3\4\1\0\1\4\1\0\1\4\2\0\2\4\1\0\4\4" + + "\1\5\2\4\6\5\1\0\2\5\1\4\2\0\5\4\1\0\1\4" + + "\1\0\6\5\2\0\12\5\2\0\2\4\42\0\1\4\27\0\2\5" + + "\6\0\12\5\13\0\1\5\1\0\1\5\1\0\1\5\4\0\2\5" + + "\10\4\1\0\42\4\6\0\24\5\1\0\2\5\4\4\4\0\10\5" + + "\1\0\44\5\11\0\1\5\71\0\42\4\1\0\5\4\1\0\2\4" + + "\1\0\7\5\3\0\4\5\6\0\12\5\6\0\6\4\4\5\106\0" + + "\46\4\12\0\51\4\7\0\132\4\5\0\104\4\5\0\122\4\6\0" + + "\7\4\1\0\77\4\1\0\1\4\1\0\4\4\2\0\7\4\1\0" + + "\1\4\1\0\4\4\2\0\47\4\1\0\1\4\1\0\4\4\2\0" + + "\37\4\1\0\1\4\1\0\4\4\2\0\7\4\1\0\1\4\1\0" + + "\4\4\2\0\7\4\1\0\7\4\1\0\27\4\1\0\37\4\1\0" + + "\1\4\1\0\4\4\2\0\7\4\1\0\47\4\1\0\23\4\16\0" + + "\11\5\56\0\125\4\14\0\u026c\4\2\0\10\4\12\0\32\4\5\0" + + "\113\4\3\0\3\4\17\0\15\4\1\0\4\4\3\5\13\0\22\4" + + "\3\5\13\0\22\4\2\5\14\0\15\4\1\0\3\4\1\0\2\5" + + "\14\0\64\4\40\5\3\0\1\4\3\0\2\4\1\5\2\0\12\5" + + "\41\0\3\5\2\0\12\5\6\0\130\4\10\0\51\4\1\5\126\0" + + "\35\4\3\0\14\5\4\0\14\5\12\0\12\5\36\4\2\0\5\4" + + "\u038b\0\154\4\224\0\234\4\4\0\132\4\6\0\26\4\2\0\6\4" + + "\2\0\46\4\2\0\6\4\2\0\10\4\1\0\1\4\1\0\1\4" + + "\1\0\1\4\1\0\37\4\2\0\65\4\1\0\7\4\1\0\1\4" + + "\3\0\3\4\1\0\7\4\3\0\4\4\2\0\6\4\4\0\15\4" + + "\5\0\3\4\1\0\7\4\17\0\4\5\32\0\5\5\20\0\2\4" + + "\23\0\1\4\13\0\4\5\6\0\6\5\1\0\1\4\15\0\1\4" + + "\40\0\22\4\36\0\15\5\4\0\1\5\3\0\6\5\27\0\1\4" + + "\4\0\1\4\2\0\12\4\1\0\1\4\3\0\5\4\6\0\1\4" + + "\1\0\1\4\1\0\1\4\1\0\4\4\1\0\3\4\1\0\7\4" + + "\3\0\3\4\5\0\5\4\26\0\44\4\u0e81\0\3\4\31\0\11\4" + + "\6\5\1\0\5\4\2\0\5\4\4\0\126\4\2\0\2\5\2\0" + + "\3\4\1\0\137\4\5\0\50\4\4\0\136\4\21\0\30\4\70\0" + + "\20\4\u0200\0\u19b6\4\112\0\u51a6\4\132\0\u048d\4\u0773\0\u2ba4\4\u215c\0" + + "\u012e\4\2\0\73\4\225\0\7\4\14\0\5\4\5\0\1\4\1\5" + + "\12\4\1\0\15\4\1\0\5\4\1\0\1\4\1\0\2\4\1\0" + + "\2\4\1\0\154\4\41\0\u016b\4\22\0\100\4\2\0\66\4\50\0" + + "\15\4\3\0\20\5\20\0\4\5\17\0\2\4\30\0\3\4\31\0" + + "\1\4\6\0\5\4\1\0\207\4\2\0\1\5\4\0\1\4\13\0" + + "\12\5\7\0\32\4\4\0\1\4\1\0\32\4\12\0\132\4\3\0" + + "\6\4\2\0\6\4\2\0\6\4\2\0\3\4\3\0\2\4\3\0" + + "\2\4\22\0\3\5\4\0"; + /** + * Translates characters to character classes + */ + private static final char[] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED); + /** + * Translates DFA states to action switch labels. + */ + private static final int[] ZZ_ACTION = zzUnpackAction(); + private static final String ZZ_ACTION_PACKED_0 = + "\2\0\2\1\1\2\1\3\1\1\1\3\7\2\1\1" + + "\1\4\1\5\1\6\1\7\1\10\2\2\1\11\2\12" + + "\1\1\1\13\1\14\1\0\1\14\2\0\7\2\1\0" + + "\3\2\1\15\1\16\1\17\1\20\1\21\1\22\1\16" + + "\1\23\1\24\1\25\1\26\1\14\4\0\6\2\1\27" + + "\4\2\1\16\2\0\1\30\2\2\1\31\6\2\1\32" + + "\1\0\7\2\1\33\1\0\1\34\6\2\1\0\4\2" + + "\1\35\1\36\1\0\1\37\1\40\2\2\1\0\1\41" + + "\1\42\20\0\1\43"; - private static int[] zzUnpackAction() { - int[] result = new int[134]; - int offset = 0; - offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); - return result; - } + private static int[] zzUnpackAction() { + int[] result = new int[134]; + int offset = 0; + offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); + return result; + } - private static int zzUnpackAction(String packed, int offset, int[] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - do { - result[j++] = value; - } while (--count > 0); - } - return j; - } - /** - * Translates a state to a row index in the transition table - */ - private static final int[] ZZ_ROWMAP = zzUnpackRowMap(); - private static final String ZZ_ROWMAP_PACKED_0 = - "\0\0\0\60\0\140\0\220\0\300\0\360\0\u0120\0\u0150" - + "\0\u0180\0\u01b0\0\u01e0\0\u0210\0\u0240\0\u0270\0\u02a0\0\u02d0" - + "\0\140\0\140\0\140\0\140\0\140\0\u0300\0\u0330\0\u0360" - + "\0\u0390\0\140\0\u03c0\0\140\0\360\0\u03f0\0\u0420\0\u0450" - + "\0\u0480\0\u04b0\0\u04e0\0\u0510\0\u0540\0\u0570\0\u05a0\0\u05d0" - + "\0\u0600\0\u0630\0\u0660\0\u0690\0\140\0\u06c0\0\140\0\140" - + "\0\140\0\140\0\u06f0\0\140\0\140\0\140\0\140\0\u0720" - + "\0\u0720\0\u0750\0\u0780\0\u07b0\0\u07e0\0\u0810\0\u0840\0\u0870" - + "\0\u08a0\0\u08d0\0\140\0\u0900\0\u0930\0\u0960\0\u0990\0\140" - + "\0\u09c0\0\u09f0\0\300\0\u0a20\0\u0a50\0\300\0\u0a80\0\u0ab0" - + "\0\u0ae0\0\u0b10\0\u0b40\0\u0b70\0\140\0\u0ba0\0\u0bd0\0\u0c00" - + "\0\u0c30\0\u0c60\0\u0c90\0\u0cc0\0\u0cf0\0\300\0\u0d20\0\300" - + "\0\u0d50\0\u0d80\0\u0db0\0\u0de0\0\u0e10\0\u0e40\0\u0e70\0\u0ea0" - + "\0\u0ed0\0\u0f00\0\u0f30\0\300\0\300\0\u0f60\0\300\0\300" - + "\0\u0f90\0\u0fc0\0\u0ff0\0\300\0\300\0\u1020\0\u1050\0\u1080" - + "\0\u10b0\0\u10e0\0\u1110\0\u1140\0\u1170\0\u11a0\0\u11d0\0\u1200" - + "\0\u1230\0\u1260\0\u1290\0\u12c0\0\u12f0\0\140"; + private static int zzUnpackAction(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do { + result[j++] = value; + } while (--count > 0); + } + return j; + } + /** + * Translates a state to a row index in the transition table + */ + private static final int[] ZZ_ROWMAP = zzUnpackRowMap(); + private static final String ZZ_ROWMAP_PACKED_0 = + "\0\0\0\60\0\140\0\220\0\300\0\360\0\u0120\0\u0150" + + "\0\u0180\0\u01b0\0\u01e0\0\u0210\0\u0240\0\u0270\0\u02a0\0\u02d0" + + "\0\140\0\140\0\140\0\140\0\140\0\u0300\0\u0330\0\u0360" + + "\0\u0390\0\140\0\u03c0\0\140\0\360\0\u03f0\0\u0420\0\u0450" + + "\0\u0480\0\u04b0\0\u04e0\0\u0510\0\u0540\0\u0570\0\u05a0\0\u05d0" + + "\0\u0600\0\u0630\0\u0660\0\u0690\0\140\0\u06c0\0\140\0\140" + + "\0\140\0\140\0\u06f0\0\140\0\140\0\140\0\140\0\u0720" + + "\0\u0720\0\u0750\0\u0780\0\u07b0\0\u07e0\0\u0810\0\u0840\0\u0870" + + "\0\u08a0\0\u08d0\0\140\0\u0900\0\u0930\0\u0960\0\u0990\0\140" + + "\0\u09c0\0\u09f0\0\300\0\u0a20\0\u0a50\0\300\0\u0a80\0\u0ab0" + + "\0\u0ae0\0\u0b10\0\u0b40\0\u0b70\0\140\0\u0ba0\0\u0bd0\0\u0c00" + + "\0\u0c30\0\u0c60\0\u0c90\0\u0cc0\0\u0cf0\0\300\0\u0d20\0\300" + + "\0\u0d50\0\u0d80\0\u0db0\0\u0de0\0\u0e10\0\u0e40\0\u0e70\0\u0ea0" + + "\0\u0ed0\0\u0f00\0\u0f30\0\300\0\300\0\u0f60\0\300\0\300" + + "\0\u0f90\0\u0fc0\0\u0ff0\0\300\0\300\0\u1020\0\u1050\0\u1080" + + "\0\u10b0\0\u10e0\0\u1110\0\u1140\0\u1170\0\u11a0\0\u11d0\0\u1200" + + "\0\u1230\0\u1260\0\u1290\0\u12c0\0\u12f0\0\140"; - private static int[] zzUnpackRowMap() { - int[] result = new int[134]; - int offset = 0; - offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); - return result; - } + private static int[] zzUnpackRowMap() { + int[] result = new int[134]; + int offset = 0; + offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); + return result; + } - private static int zzUnpackRowMap(String packed, int offset, int[] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int high = packed.charAt(i++) << 16; - result[j++] = high | packed.charAt(i++); - } - return j; - } - /** - * The transition table of the DFA - */ - private static final int[] ZZ_TRANS = zzUnpackTrans(); - private static final String ZZ_TRANS_PACKED_0 = - "\3\3\1\4\1\5\1\3\1\6\1\7\1\10\1\11" - + "\2\3\1\12\1\13\1\3\2\5\1\14\1\15\1\5" - + "\1\16\1\5\1\17\5\5\1\3\1\20\1\5\1\3" - + "\1\10\1\3\1\21\1\22\1\23\1\24\1\25\1\26" - + "\5\5\1\27\1\3\1\10\1\30\1\31\1\32\36\30" - + "\1\33\1\34\15\30\63\0\1\4\60\0\3\5\1\0" - + "\2\5\2\0\2\5\1\0\15\5\2\0\1\5\1\0" - + "\1\5\6\0\7\5\1\0\1\5\6\0\1\35\1\0" - + "\1\35\13\0\1\36\10\0\1\37\1\36\1\0\1\35" - + "\16\0\1\35\6\0\1\35\1\0\1\10\24\0\1\40" - + "\2\0\1\10\16\0\1\10\6\0\1\10\1\0\1\10" - + "\13\0\1\36\10\0\1\37\1\36\1\0\1\10\16\0" - + "\1\10\4\0\3\5\1\0\2\5\1\41\1\0\2\5" - + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\7\5" - + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\1\5" - + "\1\42\1\0\7\5\1\43\5\5\2\0\1\5\1\0" - + "\1\5\6\0\7\5\1\0\1\5\4\0\3\5\1\0" - + "\2\5\2\0\2\5\1\0\3\5\1\44\11\5\2\0" - + "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\4\0" - + "\3\5\1\0\2\5\2\0\1\45\1\5\1\0\15\5" - + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" - + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\11\5" - + "\1\46\3\5\2\0\1\5\1\0\1\5\6\0\7\5" - + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" - + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\5\5" - + "\1\47\1\5\1\0\1\5\4\0\3\5\1\0\2\5" - + "\2\0\1\50\1\5\1\0\15\5\2\0\1\5\1\0" - + "\1\5\6\0\7\5\1\0\1\5\6\0\1\37\1\0" - + "\1\37\24\0\1\51\2\0\1\37\16\0\1\37\4\0" - + "\3\5\1\0\2\5\2\0\2\5\1\0\11\5\1\52" - + "\1\5\1\53\1\5\2\0\1\5\1\0\1\5\6\0" - + "\7\5\1\0\1\5\4\0\3\5\1\0\2\5\2\0" - + "\2\5\1\0\13\5\1\54\1\5\2\0\1\5\1\0" - + "\1\5\6\0\7\5\1\0\1\5\1\30\2\0\36\30" - + "\2\0\15\30\2\0\1\32\55\0\2\55\1\0\3\55" - + "\1\56\5\55\1\57\5\55\1\60\4\55\1\61\1\62" - + "\7\55\1\63\1\64\1\65\12\55\1\66\1\67\1\56" - + "\6\0\1\70\1\71\1\70\26\0\1\71\1\70\16\0" - + "\1\70\6\0\1\37\1\0\1\37\13\0\1\36\11\0" - + "\1\36\1\0\1\37\16\0\1\37\6\0\1\37\1\0" - + "\1\37\27\0\1\37\16\0\1\37\6\0\1\72\1\0" - + "\1\73\27\0\1\73\16\0\1\73\4\0\3\5\1\0" - + "\2\5\2\0\2\5\1\74\15\5\2\0\1\5\1\0" - + "\1\5\6\0\7\5\1\0\1\5\4\0\3\5\1\0" - + "\2\5\2\0\2\5\1\0\14\5\1\75\2\0\1\5" - + "\1\0\1\5\6\0\7\5\1\0\1\5\4\0\3\5" - + "\1\0\2\5\2\0\2\5\1\0\13\5\1\76\1\5" - + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" - + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\3\5" - + "\1\77\11\5\2\0\1\5\1\0\1\5\6\0\7\5" - + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" - + "\1\0\7\5\1\100\5\5\2\0\1\5\1\0\1\5" - + "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5" - + "\2\0\2\5\1\0\15\5\2\0\1\5\1\0\1\5" - + "\6\0\1\101\6\5\1\0\1\5\4\0\3\5\1\0" - + "\2\5\2\0\2\5\1\0\15\5\2\0\1\5\1\0" - + "\1\5\6\0\2\5\1\102\4\5\1\0\1\5\35\0" - + "\1\103\26\0\3\5\1\0\2\5\2\0\2\5\1\0" - + "\1\5\1\104\1\105\12\5\2\0\1\5\1\0\1\5" - + "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5" - + "\2\0\2\5\1\0\15\5\2\0\1\5\1\0\1\5" - + "\6\0\1\5\1\106\5\5\1\0\1\5\4\0\3\5" - + "\1\0\2\5\2\0\2\5\1\0\14\5\1\107\2\0" - + "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\6\0" - + "\1\63\31\0\1\63\16\0\1\63\6\0\1\110\31\0" - + "\1\110\16\0\1\110\6\0\1\70\1\0\1\70\27\0" - + "\1\70\16\0\1\70\13\0\1\111\52\0\1\73\1\0" - + "\1\73\2\0\1\111\24\0\1\73\16\0\1\73\17\0" - + "\1\112\44\0\3\5\1\0\2\5\2\0\2\5\1\0" - + "\14\5\1\113\2\0\1\5\1\0\1\5\6\0\7\5" - + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" - + "\1\0\3\5\1\114\11\5\2\0\1\5\1\0\1\5" - + "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5" - + "\2\0\2\5\1\0\5\5\1\115\7\5\2\0\1\5" - + "\1\0\1\5\6\0\7\5\1\0\1\5\4\0\3\5" - + "\1\0\2\5\2\0\2\5\1\0\5\5\1\116\7\5" - + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" - + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\14\5" - + "\1\117\2\0\1\5\1\0\1\5\6\0\7\5\1\0" - + "\1\5\4\0\3\5\1\0\2\5\2\0\2\5\1\0" - + "\5\5\1\120\7\5\2\0\1\5\1\0\1\5\6\0" - + "\7\5\1\0\1\5\4\0\3\5\1\0\2\5\2\0" - + "\2\5\1\0\3\5\1\121\11\5\2\0\1\5\1\0" - + "\1\5\6\0\7\5\1\0\1\5\4\0\3\5\1\0" - + "\2\5\2\0\2\5\1\0\4\5\1\122\10\5\2\0" - + "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\4\0" - + "\3\5\1\0\2\5\2\0\2\5\1\0\15\5\2\0" - + "\1\5\1\0\1\5\6\0\3\5\1\123\3\5\1\0" - + "\1\5\4\0\3\5\1\0\2\5\2\0\1\5\1\124" - + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\7\5" - + "\1\0\1\5\42\0\1\125\35\0\1\126\43\0\3\5" - + "\1\0\2\5\2\0\2\5\1\0\2\5\1\127\12\5" - + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" - + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\11\5" - + "\1\130\3\5\2\0\1\5\1\0\1\5\6\0\7\5" - + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" - + "\1\0\2\5\1\131\12\5\2\0\1\5\1\0\1\5" - + "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5" - + "\2\0\2\5\1\0\15\5\2\0\1\5\1\0\1\5" - + "\6\0\6\5\1\132\1\0\1\5\4\0\3\5\1\0" - + "\2\5\2\0\2\5\1\0\5\5\1\133\7\5\2\0" - + "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\4\0" - + "\3\5\1\0\2\5\2\0\2\5\1\0\13\5\1\134" - + "\1\5\2\0\1\5\1\0\1\5\6\0\7\5\1\0" - + "\1\5\4\0\3\5\1\0\2\5\2\0\2\5\1\0" - + "\13\5\1\135\1\5\2\0\1\5\1\0\1\5\6\0" - + "\7\5\1\0\1\5\4\0\3\5\1\0\2\5\2\0" - + "\2\5\1\0\5\5\1\136\7\5\2\0\1\5\1\0" - + "\1\5\6\0\7\5\1\0\1\5\15\0\1\137\46\0" - + "\3\5\1\0\2\5\2\0\2\5\1\0\15\5\2\0" - + "\1\5\1\0\1\5\6\0\1\5\1\140\5\5\1\0" - + "\1\5\4\0\3\5\1\0\2\5\2\0\1\141\1\5" - + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\7\5" - + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" - + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\1\5" - + "\1\142\5\5\1\0\1\5\4\0\3\5\1\0\2\5" - + "\2\0\2\5\1\0\2\5\1\143\12\5\2\0\1\5" - + "\1\0\1\5\6\0\7\5\1\0\1\5\4\0\3\5" - + "\1\0\2\5\2\0\2\5\1\0\15\5\2\0\1\5" - + "\1\0\1\5\6\0\1\5\1\144\5\5\1\0\1\5" - + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\3\5" - + "\1\145\11\5\2\0\1\5\1\0\1\5\6\0\7\5" - + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" - + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\4\5" - + "\1\146\2\5\1\0\1\5\21\0\1\147\42\0\3\5" - + "\1\0\2\5\2\0\2\5\1\0\13\5\1\150\1\5" - + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" - + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\2\5" - + "\1\151\12\5\2\0\1\5\1\0\1\5\6\0\7\5" - + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\1\152" - + "\1\5\1\0\15\5\2\0\1\5\1\0\1\5\6\0" - + "\7\5\1\0\1\5\4\0\3\5\1\0\2\5\2\0" - + "\2\5\1\0\3\5\1\153\11\5\2\0\1\5\1\0" - + "\1\5\6\0\7\5\1\0\1\5\4\0\3\5\1\0" - + "\2\5\2\0\2\5\1\0\5\5\1\154\7\5\2\0" - + "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\4\0" - + "\3\5\1\0\2\5\2\0\2\5\1\0\5\5\1\155" - + "\7\5\2\0\1\5\1\0\1\5\6\0\7\5\1\0" - + "\1\5\22\0\1\156\41\0\3\5\1\0\2\5\2\0" - + "\2\5\1\0\14\5\1\157\2\0\1\5\1\0\1\5" - + "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5" - + "\2\0\2\5\1\0\3\5\1\160\11\5\2\0\1\5" - + "\1\0\1\5\6\0\7\5\1\0\1\5\4\0\3\5" - + "\1\0\2\5\2\0\2\5\1\0\5\5\1\161\7\5" - + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" - + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\5\5" - + "\1\162\7\5\2\0\1\5\1\0\1\5\6\0\7\5" - + "\1\0\1\5\21\0\1\163\42\0\3\5\1\0\2\5" - + "\2\0\2\5\1\0\15\5\2\0\1\5\1\0\1\5" - + "\6\0\2\5\1\164\4\5\1\0\1\5\4\0\3\5" - + "\1\0\2\5\2\0\2\5\1\0\15\5\2\0\1\5" - + "\1\0\1\5\6\0\2\5\1\165\4\5\1\0\1\5" - + "\23\0\1\166\60\0\1\167\60\0\1\170\60\0\1\171" - + "\42\0\1\172\75\0\1\173\54\0\1\174\63\0\1\175" - + "\60\0\1\176\47\0\1\177\60\0\1\200\61\0\1\201" - + "\63\0\1\202\61\0\1\203\60\0\1\204\60\0\1\205" - + "\36\0\1\206\44\0"; + private static int zzUnpackRowMap(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int high = packed.charAt(i++) << 16; + result[j++] = high | packed.charAt(i++); + } + return j; + } + /** + * The transition table of the DFA + */ + private static final int[] ZZ_TRANS = zzUnpackTrans(); + private static final String ZZ_TRANS_PACKED_0 = + "\3\3\1\4\1\5\1\3\1\6\1\7\1\10\1\11" + + "\2\3\1\12\1\13\1\3\2\5\1\14\1\15\1\5" + + "\1\16\1\5\1\17\5\5\1\3\1\20\1\5\1\3" + + "\1\10\1\3\1\21\1\22\1\23\1\24\1\25\1\26" + + "\5\5\1\27\1\3\1\10\1\30\1\31\1\32\36\30" + + "\1\33\1\34\15\30\63\0\1\4\60\0\3\5\1\0" + + "\2\5\2\0\2\5\1\0\15\5\2\0\1\5\1\0" + + "\1\5\6\0\7\5\1\0\1\5\6\0\1\35\1\0" + + "\1\35\13\0\1\36\10\0\1\37\1\36\1\0\1\35" + + "\16\0\1\35\6\0\1\35\1\0\1\10\24\0\1\40" + + "\2\0\1\10\16\0\1\10\6\0\1\10\1\0\1\10" + + "\13\0\1\36\10\0\1\37\1\36\1\0\1\10\16\0" + + "\1\10\4\0\3\5\1\0\2\5\1\41\1\0\2\5" + + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\1\5" + + "\1\42\1\0\7\5\1\43\5\5\2\0\1\5\1\0" + + "\1\5\6\0\7\5\1\0\1\5\4\0\3\5\1\0" + + "\2\5\2\0\2\5\1\0\3\5\1\44\11\5\2\0" + + "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\4\0" + + "\3\5\1\0\2\5\2\0\1\45\1\5\1\0\15\5" + + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" + + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\11\5" + + "\1\46\3\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" + + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\5\5" + + "\1\47\1\5\1\0\1\5\4\0\3\5\1\0\2\5" + + "\2\0\1\50\1\5\1\0\15\5\2\0\1\5\1\0" + + "\1\5\6\0\7\5\1\0\1\5\6\0\1\37\1\0" + + "\1\37\24\0\1\51\2\0\1\37\16\0\1\37\4\0" + + "\3\5\1\0\2\5\2\0\2\5\1\0\11\5\1\52" + + "\1\5\1\53\1\5\2\0\1\5\1\0\1\5\6\0" + + "\7\5\1\0\1\5\4\0\3\5\1\0\2\5\2\0" + + "\2\5\1\0\13\5\1\54\1\5\2\0\1\5\1\0" + + "\1\5\6\0\7\5\1\0\1\5\1\30\2\0\36\30" + + "\2\0\15\30\2\0\1\32\55\0\2\55\1\0\3\55" + + "\1\56\5\55\1\57\5\55\1\60\4\55\1\61\1\62" + + "\7\55\1\63\1\64\1\65\12\55\1\66\1\67\1\56" + + "\6\0\1\70\1\71\1\70\26\0\1\71\1\70\16\0" + + "\1\70\6\0\1\37\1\0\1\37\13\0\1\36\11\0" + + "\1\36\1\0\1\37\16\0\1\37\6\0\1\37\1\0" + + "\1\37\27\0\1\37\16\0\1\37\6\0\1\72\1\0" + + "\1\73\27\0\1\73\16\0\1\73\4\0\3\5\1\0" + + "\2\5\2\0\2\5\1\74\15\5\2\0\1\5\1\0" + + "\1\5\6\0\7\5\1\0\1\5\4\0\3\5\1\0" + + "\2\5\2\0\2\5\1\0\14\5\1\75\2\0\1\5" + + "\1\0\1\5\6\0\7\5\1\0\1\5\4\0\3\5" + + "\1\0\2\5\2\0\2\5\1\0\13\5\1\76\1\5" + + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" + + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\3\5" + + "\1\77\11\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" + + "\1\0\7\5\1\100\5\5\2\0\1\5\1\0\1\5" + + "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5" + + "\2\0\2\5\1\0\15\5\2\0\1\5\1\0\1\5" + + "\6\0\1\101\6\5\1\0\1\5\4\0\3\5\1\0" + + "\2\5\2\0\2\5\1\0\15\5\2\0\1\5\1\0" + + "\1\5\6\0\2\5\1\102\4\5\1\0\1\5\35\0" + + "\1\103\26\0\3\5\1\0\2\5\2\0\2\5\1\0" + + "\1\5\1\104\1\105\12\5\2\0\1\5\1\0\1\5" + + "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5" + + "\2\0\2\5\1\0\15\5\2\0\1\5\1\0\1\5" + + "\6\0\1\5\1\106\5\5\1\0\1\5\4\0\3\5" + + "\1\0\2\5\2\0\2\5\1\0\14\5\1\107\2\0" + + "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\6\0" + + "\1\63\31\0\1\63\16\0\1\63\6\0\1\110\31\0" + + "\1\110\16\0\1\110\6\0\1\70\1\0\1\70\27\0" + + "\1\70\16\0\1\70\13\0\1\111\52\0\1\73\1\0" + + "\1\73\2\0\1\111\24\0\1\73\16\0\1\73\17\0" + + "\1\112\44\0\3\5\1\0\2\5\2\0\2\5\1\0" + + "\14\5\1\113\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" + + "\1\0\3\5\1\114\11\5\2\0\1\5\1\0\1\5" + + "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5" + + "\2\0\2\5\1\0\5\5\1\115\7\5\2\0\1\5" + + "\1\0\1\5\6\0\7\5\1\0\1\5\4\0\3\5" + + "\1\0\2\5\2\0\2\5\1\0\5\5\1\116\7\5" + + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" + + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\14\5" + + "\1\117\2\0\1\5\1\0\1\5\6\0\7\5\1\0" + + "\1\5\4\0\3\5\1\0\2\5\2\0\2\5\1\0" + + "\5\5\1\120\7\5\2\0\1\5\1\0\1\5\6\0" + + "\7\5\1\0\1\5\4\0\3\5\1\0\2\5\2\0" + + "\2\5\1\0\3\5\1\121\11\5\2\0\1\5\1\0" + + "\1\5\6\0\7\5\1\0\1\5\4\0\3\5\1\0" + + "\2\5\2\0\2\5\1\0\4\5\1\122\10\5\2\0" + + "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\4\0" + + "\3\5\1\0\2\5\2\0\2\5\1\0\15\5\2\0" + + "\1\5\1\0\1\5\6\0\3\5\1\123\3\5\1\0" + + "\1\5\4\0\3\5\1\0\2\5\2\0\1\5\1\124" + + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\42\0\1\125\35\0\1\126\43\0\3\5" + + "\1\0\2\5\2\0\2\5\1\0\2\5\1\127\12\5" + + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" + + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\11\5" + + "\1\130\3\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" + + "\1\0\2\5\1\131\12\5\2\0\1\5\1\0\1\5" + + "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5" + + "\2\0\2\5\1\0\15\5\2\0\1\5\1\0\1\5" + + "\6\0\6\5\1\132\1\0\1\5\4\0\3\5\1\0" + + "\2\5\2\0\2\5\1\0\5\5\1\133\7\5\2\0" + + "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\4\0" + + "\3\5\1\0\2\5\2\0\2\5\1\0\13\5\1\134" + + "\1\5\2\0\1\5\1\0\1\5\6\0\7\5\1\0" + + "\1\5\4\0\3\5\1\0\2\5\2\0\2\5\1\0" + + "\13\5\1\135\1\5\2\0\1\5\1\0\1\5\6\0" + + "\7\5\1\0\1\5\4\0\3\5\1\0\2\5\2\0" + + "\2\5\1\0\5\5\1\136\7\5\2\0\1\5\1\0" + + "\1\5\6\0\7\5\1\0\1\5\15\0\1\137\46\0" + + "\3\5\1\0\2\5\2\0\2\5\1\0\15\5\2\0" + + "\1\5\1\0\1\5\6\0\1\5\1\140\5\5\1\0" + + "\1\5\4\0\3\5\1\0\2\5\2\0\1\141\1\5" + + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" + + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\1\5" + + "\1\142\5\5\1\0\1\5\4\0\3\5\1\0\2\5" + + "\2\0\2\5\1\0\2\5\1\143\12\5\2\0\1\5" + + "\1\0\1\5\6\0\7\5\1\0\1\5\4\0\3\5" + + "\1\0\2\5\2\0\2\5\1\0\15\5\2\0\1\5" + + "\1\0\1\5\6\0\1\5\1\144\5\5\1\0\1\5" + + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\3\5" + + "\1\145\11\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\2\5" + + "\1\0\15\5\2\0\1\5\1\0\1\5\6\0\4\5" + + "\1\146\2\5\1\0\1\5\21\0\1\147\42\0\3\5" + + "\1\0\2\5\2\0\2\5\1\0\13\5\1\150\1\5" + + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" + + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\2\5" + + "\1\151\12\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\4\0\3\5\1\0\2\5\2\0\1\152" + + "\1\5\1\0\15\5\2\0\1\5\1\0\1\5\6\0" + + "\7\5\1\0\1\5\4\0\3\5\1\0\2\5\2\0" + + "\2\5\1\0\3\5\1\153\11\5\2\0\1\5\1\0" + + "\1\5\6\0\7\5\1\0\1\5\4\0\3\5\1\0" + + "\2\5\2\0\2\5\1\0\5\5\1\154\7\5\2\0" + + "\1\5\1\0\1\5\6\0\7\5\1\0\1\5\4\0" + + "\3\5\1\0\2\5\2\0\2\5\1\0\5\5\1\155" + + "\7\5\2\0\1\5\1\0\1\5\6\0\7\5\1\0" + + "\1\5\22\0\1\156\41\0\3\5\1\0\2\5\2\0" + + "\2\5\1\0\14\5\1\157\2\0\1\5\1\0\1\5" + + "\6\0\7\5\1\0\1\5\4\0\3\5\1\0\2\5" + + "\2\0\2\5\1\0\3\5\1\160\11\5\2\0\1\5" + + "\1\0\1\5\6\0\7\5\1\0\1\5\4\0\3\5" + + "\1\0\2\5\2\0\2\5\1\0\5\5\1\161\7\5" + + "\2\0\1\5\1\0\1\5\6\0\7\5\1\0\1\5" + + "\4\0\3\5\1\0\2\5\2\0\2\5\1\0\5\5" + + "\1\162\7\5\2\0\1\5\1\0\1\5\6\0\7\5" + + "\1\0\1\5\21\0\1\163\42\0\3\5\1\0\2\5" + + "\2\0\2\5\1\0\15\5\2\0\1\5\1\0\1\5" + + "\6\0\2\5\1\164\4\5\1\0\1\5\4\0\3\5" + + "\1\0\2\5\2\0\2\5\1\0\15\5\2\0\1\5" + + "\1\0\1\5\6\0\2\5\1\165\4\5\1\0\1\5" + + "\23\0\1\166\60\0\1\167\60\0\1\170\60\0\1\171" + + "\42\0\1\172\75\0\1\173\54\0\1\174\63\0\1\175" + + "\60\0\1\176\47\0\1\177\60\0\1\200\61\0\1\201" + + "\63\0\1\202\61\0\1\203\60\0\1\204\60\0\1\205" + + "\36\0\1\206\44\0"; - private static int[] zzUnpackTrans() { - int[] result = new int[4896]; - int offset = 0; - offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); - return result; - } + private static int[] zzUnpackTrans() { + int[] result = new int[4896]; + int offset = 0; + offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); + return result; + } - private static int zzUnpackTrans(String packed, int offset, int[] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - value--; - do { - result[j++] = value; - } while (--count > 0); - } - return j; - } - /* error codes */ - private static final int ZZ_UNKNOWN_ERROR = 0; - private static final int ZZ_NO_MATCH = 1; - private static final int ZZ_PUSHBACK_2BIG = 2; + private static int zzUnpackTrans(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + value--; + do { + result[j++] = value; + } while (--count > 0); + } + return j; + } + /* error codes */ + private static final int ZZ_UNKNOWN_ERROR = 0; + private static final int ZZ_NO_MATCH = 1; + private static final int ZZ_PUSHBACK_2BIG = 2; - /* error messages for the codes above */ - private static final String ZZ_ERROR_MSG[] = { - "Unkown internal scanner error", - "Error: could not match input", - "Error: pushback value was too large" - }; - /** - * ZZ_ATTRIBUTE[aState] contains the attributes of state - * aState - */ - private static final int[] ZZ_ATTRIBUTE = zzUnpackAttribute(); - private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\2\0\1\11\15\1\5\11\4\1\1\11\1\1\1\11" - + "\1\1\1\0\1\1\2\0\7\1\1\0\3\1\1\11" - + "\1\1\4\11\1\1\4\11\1\1\4\0\6\1\1\11" - + "\4\1\1\11\2\0\12\1\1\11\1\0\10\1\1\0" - + "\7\1\1\0\6\1\1\0\4\1\1\0\2\1\20\0" - + "\1\11"; + /* error messages for the codes above */ + private static final String ZZ_ERROR_MSG[] = { + "Unkown internal scanner error", + "Error: could not match input", + "Error: pushback value was too large" + }; + /** + * ZZ_ATTRIBUTE[aState] contains the attributes of state + * aState + */ + private static final int[] ZZ_ATTRIBUTE = zzUnpackAttribute(); + private static final String ZZ_ATTRIBUTE_PACKED_0 = + "\2\0\1\11\15\1\5\11\4\1\1\11\1\1\1\11" + + "\1\1\1\0\1\1\2\0\7\1\1\0\3\1\1\11" + + "\1\1\4\11\1\1\4\11\1\1\4\0\6\1\1\11" + + "\4\1\1\11\2\0\12\1\1\11\1\0\10\1\1\0" + + "\7\1\1\0\6\1\1\0\4\1\1\0\2\1\20\0" + + "\1\11"; - private static int[] zzUnpackAttribute() { - int[] result = new int[134]; - int offset = 0; - offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); - return result; - } + private static int[] zzUnpackAttribute() { + int[] result = new int[134]; + int offset = 0; + offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); + return result; + } - private static int zzUnpackAttribute(String packed, int offset, int[] result) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - do { - result[j++] = value; - } while (--count > 0); - } - return j; - } - /** - * the input device - */ - private java.io.Reader zzReader; - /** - * the current state of the DFA - */ - private int zzState; - /** - * the current lexical state - */ - private int zzLexicalState = YYINITIAL; - /** - * this buffer contains the current text to be matched and is the source of - * the yytext() string - */ - private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; - /** - * the textposition at the last accepting state - */ - private int zzMarkedPos; - /** - * the current text position in the buffer - */ - private int zzCurrentPos; - /** - * startRead marks the beginning of the yytext() string in the buffer - */ - private int zzStartRead; - /** - * endRead marks the last character in the buffer, that has been read from - * input - */ - private int zzEndRead; - /** - * number of newlines encountered up to the start of the matched text - */ - private int yyline; - /** - * the number of characters up to the start of the matched text - */ - private int yychar; - /** - * the number of characters from the last newline up to the start of the - * matched text - */ - private int yycolumn; - /** - * zzAtBOL == true <=> the scanner is currently at the beginning of a line - */ - private boolean zzAtBOL = true; - /** - * zzAtEOF == true <=> the scanner is at the EOF - */ - private boolean zzAtEOF; - /** - * denotes if the user-EOF-code has already been executed - */ - private boolean zzEOFDone; + private static int zzUnpackAttribute(String packed, int offset, int[] result) { + int i = 0; /* index in packed string */ + int j = offset; /* index in unpacked array */ + int l = packed.length(); + while (i < l) { + int count = packed.charAt(i++); + int value = packed.charAt(i++); + do { + result[j++] = value; + } while (--count > 0); + } + return j; + } + /** + * the input device + */ + private java.io.Reader zzReader; + /** + * the current state of the DFA + */ + private int zzState; + /** + * the current lexical state + */ + private int zzLexicalState = YYINITIAL; + /** + * this buffer contains the current text to be matched and is the source of + * the yytext() string + */ + private char zzBuffer[] = new char[ZZ_BUFFERSIZE]; + /** + * the textposition at the last accepting state + */ + private int zzMarkedPos; + /** + * the current text position in the buffer + */ + private int zzCurrentPos; + /** + * startRead marks the beginning of the yytext() string in the buffer + */ + private int zzStartRead; + /** + * endRead marks the last character in the buffer, that has been read from + * input + */ + private int zzEndRead; + /** + * number of newlines encountered up to the start of the matched text + */ + private int yyline; + /** + * the number of characters up to the start of the matched text + */ + private int yychar; + /** + * the number of characters from the last newline up to the start of the + * matched text + */ + private int yycolumn; + /** + * zzAtBOL == true <=> the scanner is currently at the beginning of a line + */ + private boolean zzAtBOL = true; + /** + * zzAtEOF == true <=> the scanner is at the EOF + */ + private boolean zzAtEOF; + /** + * denotes if the user-EOF-code has already been executed + */ + private boolean zzEOFDone; - /* user code: */ - StringBuffer string = new StringBuffer(); - boolean isMultiname = false; - long multinameId = 0; + /* user code: */ + StringBuffer string = new StringBuffer(); + boolean isMultiname = false; + long multinameId = 0; - /** - * Create an empty lexer, yyrset will be called later to reset and assign the - * reader - */ - public MethodInfoLexer() { - } + /** + * Create an empty lexer, yyrset will be called later to reset and assign + * the reader + */ + public MethodInfoLexer() { + } - public int yychar() { - return yychar; - } + public int yychar() { + return yychar; + } - public int yyline() { - return yyline + 1; - } + public int yyline() { + return yyline + 1; + } - /** - * Creates a new scanner There is also a java.io.InputStream version of this - * constructor. - * - * @param in the java.io.Reader to read input from. - */ - public MethodInfoLexer(java.io.Reader in) { - this.zzReader = in; - } + /** + * Creates a new scanner There is also a java.io.InputStream version of this + * constructor. + * + * @param in the java.io.Reader to read input from. + */ + public MethodInfoLexer(java.io.Reader in) { + this.zzReader = in; + } - /** - * Creates a new scanner. There is also java.io.Reader version of this - * constructor. - * - * @param in the java.io.Inputstream to read input from. - */ - public MethodInfoLexer(java.io.InputStream in) { - this(new java.io.InputStreamReader(in)); - } + /** + * Creates a new scanner. There is also java.io.Reader version of this + * constructor. + * + * @param in the java.io.Inputstream to read input from. + */ + public MethodInfoLexer(java.io.InputStream in) { + this(new java.io.InputStreamReader(in)); + } - /** - * Unpacks the compressed character translation table. - * - * @param packed the packed character translation table - * @return the unpacked character translation table - */ - private static char[] zzUnpackCMap(String packed) { - char[] map = new char[0x10000]; - int i = 0; /* index in packed string */ - int j = 0; /* index in unpacked array */ - while (i < 1768) { - int count = packed.charAt(i++); - char value = packed.charAt(i++); - do { - map[j++] = value; - } while (--count > 0); - } - return map; - } + /** + * Unpacks the compressed character translation table. + * + * @param packed the packed character translation table + * @return the unpacked character translation table + */ + private static char[] zzUnpackCMap(String packed) { + char[] map = new char[0x10000]; + int i = 0; /* index in packed string */ + int j = 0; /* index in unpacked array */ + while (i < 1768) { + int count = packed.charAt(i++); + char value = packed.charAt(i++); + do { + map[j++] = value; + } while (--count > 0); + } + return map; + } - /** - * Refills the input buffer. - * - * @return false, iff there was new input. - * - * @exception java.io.IOException if any I/O-Error occurs - */ - private boolean zzRefill() throws java.io.IOException { + /** + * Refills the input buffer. + * + * @return false, iff there was new input. + * + * @exception java.io.IOException if any I/O-Error occurs + */ + private boolean zzRefill() throws java.io.IOException { - /* first: make room (if you can) */ - if (zzStartRead > 0) { - System.arraycopy(zzBuffer, zzStartRead, - zzBuffer, 0, - zzEndRead - zzStartRead); + /* first: make room (if you can) */ + if (zzStartRead > 0) { + System.arraycopy(zzBuffer, zzStartRead, + zzBuffer, 0, + zzEndRead - zzStartRead); - /* translate stored positions */ - zzEndRead -= zzStartRead; - zzCurrentPos -= zzStartRead; - zzMarkedPos -= zzStartRead; - zzStartRead = 0; - } + /* translate stored positions */ + zzEndRead -= zzStartRead; + zzCurrentPos -= zzStartRead; + zzMarkedPos -= zzStartRead; + zzStartRead = 0; + } - /* is the buffer big enough? */ - if (zzCurrentPos >= zzBuffer.length) { - /* if not: blow it up */ - char newBuffer[] = new char[zzCurrentPos * 2]; - System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); - zzBuffer = newBuffer; - } + /* is the buffer big enough? */ + if (zzCurrentPos >= zzBuffer.length) { + /* if not: blow it up */ + char newBuffer[] = new char[zzCurrentPos * 2]; + System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length); + zzBuffer = newBuffer; + } - /* finally: fill the buffer with new input */ - int numRead = zzReader.read(zzBuffer, zzEndRead, - zzBuffer.length - zzEndRead); + /* finally: fill the buffer with new input */ + int numRead = zzReader.read(zzBuffer, zzEndRead, + zzBuffer.length - zzEndRead); - if (numRead > 0) { - zzEndRead += numRead; - return false; - } - // unlikely but not impossible: read 0 characters, but not at end of stream - if (numRead == 0) { - int c = zzReader.read(); - if (c == -1) { - return true; - } else { - zzBuffer[zzEndRead++] = (char) c; + if (numRead > 0) { + zzEndRead += numRead; return false; - } - } - - // numRead < 0 - return true; - } - - /** - * Closes the input stream. - */ - public final void yyclose() throws java.io.IOException { - zzAtEOF = true; /* indicate end of file */ - zzEndRead = zzStartRead; /* invalidate buffer */ - - if (zzReader != null) { - zzReader.close(); - } - } - - /** - * Resets the scanner to read from a new input stream. Does not close the old - * reader. - * - * All internal variables are reset, the old input stream cannot be - * reused (internal buffer is discarded and lost). Lexical state is set to - * ZZ_INITIAL. - * - * @param reader the new input stream - */ - public final void yyreset(java.io.Reader reader) { - zzReader = reader; - zzAtBOL = true; - zzAtEOF = false; - zzEOFDone = false; - zzEndRead = zzStartRead = 0; - zzCurrentPos = zzMarkedPos = 0; - yyline = yychar = yycolumn = 0; - zzLexicalState = YYINITIAL; - } - - /** - * Returns the current lexical state. - */ - public final int yystate() { - return zzLexicalState; - } - - /** - * Enters a new lexical state - * - * @param newState the new lexical state - */ - public final void yybegin(int newState) { - zzLexicalState = newState; - } - - /** - * Returns the text matched by the current regular expression. - */ - public final String yytext() { - return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead); - } - - /** - * Returns the character at position pos from the matched text. - * - * It is equivalent to yytext().charAt(pos), but faster - * - * @param pos the position of the character to fetch. A value from 0 to - * yylength()-1. - * - * @return the character at position pos - */ - public final char yycharat(int pos) { - return zzBuffer[zzStartRead + pos]; - } - - /** - * Returns the length of the matched text region. - */ - public final int yylength() { - return zzMarkedPos - zzStartRead; - } - - /** - * Reports an error that occured while scanning. - * - * In a wellformed scanner (no or only correct usage of yypushback(int) and a - * match-all fallback rule) this method will only be called with things that - * "Can't Possibly Happen". If this method is called, something is seriously - * wrong (e.g. a JFlex bug producing a faulty scanner etc.). - * - * Usual syntax/scanner level error handling should be done in error fallback - * rules. - * - * @param errorCode the code of the errormessage to display - */ - private void zzScanError(int errorCode) { - String message; - try { - message = ZZ_ERROR_MSG[errorCode]; - } catch (ArrayIndexOutOfBoundsException e) { - message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; - } - - throw new Error(message); - } - - /** - * Pushes the specified amount of characters back into the input stream. - * - * They will be read again by then next call of the scanning method - * - * @param number the number of characters to be read again. This number must - * not be greater than yylength()! - */ - public void yypushback(int number) { - if (number > yylength()) { - zzScanError(ZZ_PUSHBACK_2BIG); - } - - zzMarkedPos -= number; - } - - /** - * Resumes scanning until the next regular expression is matched, the end of - * input is encountered or an I/O-Error occurs. - * - * @return the next token - * @exception java.io.IOException if any I/O-Error occurs - */ - public ParsedSymbol yylex() throws java.io.IOException, ParseException { - int zzInput; - int zzAction; - - // cached fields: - int zzCurrentPosL; - int zzMarkedPosL; - int zzEndReadL = zzEndRead; - char[] zzBufferL = zzBuffer; - char[] zzCMapL = ZZ_CMAP; - - int[] zzTransL = ZZ_TRANS; - int[] zzRowMapL = ZZ_ROWMAP; - int[] zzAttrL = ZZ_ATTRIBUTE; - - while (true) { - zzMarkedPosL = zzMarkedPos; - - yychar += zzMarkedPosL - zzStartRead; - - boolean zzR = false; - for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL; - zzCurrentPosL++) { - switch (zzBufferL[zzCurrentPosL]) { - case '\u000B': - case '\u000C': - case '\u0085': - case '\u2028': - case '\u2029': - yyline++; - yycolumn = 0; - zzR = false; - break; - case '\r': - yyline++; - yycolumn = 0; - zzR = true; - break; - case '\n': - if (zzR) { - zzR = false; - } else { - yyline++; - yycolumn = 0; - } - break; - default: - zzR = false; - yycolumn++; - } - } - - if (zzR) { - // peek one character ahead if it is \n (if we have counted one line too much) - boolean zzPeek; - if (zzMarkedPosL < zzEndReadL) { - zzPeek = zzBufferL[zzMarkedPosL] == '\n'; - } else if (zzAtEOF) { - zzPeek = false; + } + // unlikely but not impossible: read 0 characters, but not at end of stream + if (numRead == 0) { + int c = zzReader.read(); + if (c == -1) { + return true; } else { - boolean eof = zzRefill(); - zzEndReadL = zzEndRead; - zzMarkedPosL = zzMarkedPos; - zzBufferL = zzBuffer; - if (eof) { - zzPeek = false; - } else { - zzPeek = zzBufferL[zzMarkedPosL] == '\n'; - } + zzBuffer[zzEndRead++] = (char) c; + return false; } - if (zzPeek) { - yyline--; + } + + // numRead < 0 + return true; + } + + /** + * Closes the input stream. + */ + public final void yyclose() throws java.io.IOException { + zzAtEOF = true; /* indicate end of file */ + zzEndRead = zzStartRead; /* invalidate buffer */ + + if (zzReader != null) { + zzReader.close(); + } + } + + /** + * Resets the scanner to read from a new input stream. Does not close the + * old reader. + * + * All internal variables are reset, the old input stream cannot be + * reused (internal buffer is discarded and lost). Lexical state is set to + * ZZ_INITIAL. + * + * @param reader the new input stream + */ + public final void yyreset(java.io.Reader reader) { + zzReader = reader; + zzAtBOL = true; + zzAtEOF = false; + zzEOFDone = false; + zzEndRead = zzStartRead = 0; + zzCurrentPos = zzMarkedPos = 0; + yyline = yychar = yycolumn = 0; + zzLexicalState = YYINITIAL; + } + + /** + * Returns the current lexical state. + */ + public final int yystate() { + return zzLexicalState; + } + + /** + * Enters a new lexical state + * + * @param newState the new lexical state + */ + public final void yybegin(int newState) { + zzLexicalState = newState; + } + + /** + * Returns the text matched by the current regular expression. + */ + public final String yytext() { + return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead); + } + + /** + * Returns the character at position pos from the matched text. + * + * It is equivalent to yytext().charAt(pos), but faster + * + * @param pos the position of the character to fetch. A value from 0 to + * yylength()-1. + * + * @return the character at position pos + */ + public final char yycharat(int pos) { + return zzBuffer[zzStartRead + pos]; + } + + /** + * Returns the length of the matched text region. + */ + public final int yylength() { + return zzMarkedPos - zzStartRead; + } + + /** + * Reports an error that occured while scanning. + * + * In a wellformed scanner (no or only correct usage of yypushback(int) and + * a match-all fallback rule) this method will only be called with things + * that "Can't Possibly Happen". If this method is called, something is + * seriously wrong (e.g. a JFlex bug producing a faulty scanner etc.). + * + * Usual syntax/scanner level error handling should be done in error + * fallback rules. + * + * @param errorCode the code of the errormessage to display + */ + private void zzScanError(int errorCode) { + String message; + try { + message = ZZ_ERROR_MSG[errorCode]; + } catch (ArrayIndexOutOfBoundsException e) { + message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR]; + } + + throw new Error(message); + } + + /** + * Pushes the specified amount of characters back into the input stream. + * + * They will be read again by then next call of the scanning method + * + * @param number the number of characters to be read again. This number must + * not be greater than yylength()! + */ + public void yypushback(int number) { + if (number > yylength()) { + zzScanError(ZZ_PUSHBACK_2BIG); + } + + zzMarkedPos -= number; + } + + /** + * Resumes scanning until the next regular expression is matched, the end of + * input is encountered or an I/O-Error occurs. + * + * @return the next token + * @exception java.io.IOException if any I/O-Error occurs + */ + public ParsedSymbol yylex() throws java.io.IOException, ParseException { + int zzInput; + int zzAction; + + // cached fields: + int zzCurrentPosL; + int zzMarkedPosL; + int zzEndReadL = zzEndRead; + char[] zzBufferL = zzBuffer; + char[] zzCMapL = ZZ_CMAP; + + int[] zzTransL = ZZ_TRANS; + int[] zzRowMapL = ZZ_ROWMAP; + int[] zzAttrL = ZZ_ATTRIBUTE; + + while (true) { + zzMarkedPosL = zzMarkedPos; + + yychar += zzMarkedPosL - zzStartRead; + + boolean zzR = false; + for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL; + zzCurrentPosL++) { + switch (zzBufferL[zzCurrentPosL]) { + case '\u000B': + case '\u000C': + case '\u0085': + case '\u2028': + case '\u2029': + yyline++; + yycolumn = 0; + zzR = false; + break; + case '\r': + yyline++; + yycolumn = 0; + zzR = true; + break; + case '\n': + if (zzR) { + zzR = false; + } else { + yyline++; + yycolumn = 0; + } + break; + default: + zzR = false; + yycolumn++; + } } - } - zzAction = -1; - zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + if (zzR) { + // peek one character ahead if it is \n (if we have counted one line too much) + boolean zzPeek; + if (zzMarkedPosL < zzEndReadL) { + zzPeek = zzBufferL[zzMarkedPosL] == '\n'; + } else if (zzAtEOF) { + zzPeek = false; + } else { + boolean eof = zzRefill(); + zzEndReadL = zzEndRead; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + if (eof) { + zzPeek = false; + } else { + zzPeek = zzBufferL[zzMarkedPosL] == '\n'; + } + } + if (zzPeek) { + yyline--; + } + } + zzAction = -1; - zzState = ZZ_LEXSTATE[zzLexicalState]; + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = ZZ_LEXSTATE[zzLexicalState]; - zzForAction: - { - while (true) { + zzForAction: + { + while (true) { - if (zzCurrentPosL < zzEndReadL) { - zzInput = zzBufferL[zzCurrentPosL++]; - } else if (zzAtEOF) { - zzInput = YYEOF; - break zzForAction; - } else { - // store back cached positions - zzCurrentPos = zzCurrentPosL; - zzMarkedPos = zzMarkedPosL; - boolean eof = zzRefill(); - // get translated positions and possibly new buffer - zzCurrentPosL = zzCurrentPos; - zzMarkedPosL = zzMarkedPos; - zzBufferL = zzBuffer; - zzEndReadL = zzEndRead; - if (eof) { - zzInput = YYEOF; - break zzForAction; - } else { - zzInput = zzBufferL[zzCurrentPosL++]; - } - } - int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput]]; - if (zzNext == -1) { - break zzForAction; - } - zzState = zzNext; + if (zzCurrentPosL < zzEndReadL) { + zzInput = zzBufferL[zzCurrentPosL++]; + } else if (zzAtEOF) { + zzInput = YYEOF; + break zzForAction; + } else { + // store back cached positions + zzCurrentPos = zzCurrentPosL; + zzMarkedPos = zzMarkedPosL; + boolean eof = zzRefill(); + // get translated positions and possibly new buffer + zzCurrentPosL = zzCurrentPos; + zzMarkedPosL = zzMarkedPos; + zzBufferL = zzBuffer; + zzEndReadL = zzEndRead; + if (eof) { + zzInput = YYEOF; + break zzForAction; + } else { + zzInput = zzBufferL[zzCurrentPosL++]; + } + } + int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput]]; + if (zzNext == -1) { + break zzForAction; + } + zzState = zzNext; - int zzAttributes = zzAttrL[zzState]; - if ((zzAttributes & 1) == 1) { - zzAction = zzState; - zzMarkedPosL = zzCurrentPosL; - if ((zzAttributes & 8) == 8) { - break zzForAction; - } - } + int zzAttributes = zzAttrL[zzState]; + if ((zzAttributes & 1) == 1) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ((zzAttributes & 8) == 8) { + break zzForAction; + } + } + } } - } - // store back cached position - zzMarkedPos = zzMarkedPosL; + // store back cached position + zzMarkedPos = zzMarkedPosL; - switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { - case 2: { - return new ParsedSymbol(ParsedSymbol.TYPE_IDENTIFIER, yytext()); + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 2: { + return new ParsedSymbol(ParsedSymbol.TYPE_IDENTIFIER, yytext()); + } + case 36: + break; + case 8: { + return new ParsedSymbol(ParsedSymbol.TYPE_ASSIGN); + } + case 37: + break; + case 24: { + return new ParsedSymbol(ParsedSymbol.TYPE_NULL); + } + case 38: + break; + case 22: { + string.append('\''); + } + case 39: + break; + case 3: { + return new ParsedSymbol(ParsedSymbol.TYPE_INTEGER, new Long(Long.parseLong((yytext())))); + } + case 40: + break; + case 33: { + return new ParsedSymbol(ParsedSymbol.TYPE_UNDEFINED); + } + case 41: + break; + case 34: { + return new ParsedSymbol(ParsedSymbol.TYPE_PROTECTED); + } + case 42: + break; + case 28: { + return new ParsedSymbol(ParsedSymbol.TYPE_STATIC); + } + case 43: + break; + case 9: { + string.append(yytext()); + } + case 44: + break; + case 14: { + char val = (char) Integer.parseInt(yytext().substring(1), 8); + string.append(val); + } + case 45: + break; + case 29: { + return new ParsedSymbol(ParsedSymbol.TYPE_PRIVATE); + } + case 46: + break; + case 5: { + return new ParsedSymbol(ParsedSymbol.TYPE_COLON); + } + case 47: + break; + case 18: { + string.append('\r'); + } + case 48: + break; + case 25: { + return new ParsedSymbol(ParsedSymbol.TYPE_TRUE); + } + case 49: + break; + case 6: { + return new ParsedSymbol(ParsedSymbol.TYPE_COMMA); + } + case 50: + break; + case 35: { + String s = yytext(); + long ns = Long.parseLong(s.substring(3, s.length() - 2)); + return new ParsedSymbol(ParsedSymbol.TYPE_NAMESPACE, new Long(ns)); + } + case 51: + break; + case 27: { + return new ParsedSymbol(ParsedSymbol.TYPE_FALSE); + } + case 52: + break; + case 11: { + yybegin(YYINITIAL); + // length also includes the trailing quote + if (isMultiname) { + return new ParsedSymbol(ParsedSymbol.TYPE_MULTINAME, new Long(multinameId)); + } else { + return new ParsedSymbol(ParsedSymbol.TYPE_STRING, string.toString()); + } + } + case 53: + break; + case 17: { + string.append('\b'); + } + case 54: + break; + case 10: { + throw new ParseException("Unterminated string at end of line", yyline + 1); + } + case 55: + break; + case 4: { + isMultiname = false; + yybegin(STRING); + string.setLength(0); + } + case 56: + break; + case 32: { + return new ParsedSymbol(ParsedSymbol.TYPE_EXPLICIT); + } + case 57: + break; + case 16: { + string.append('\t'); + } + case 58: + break; + case 12: { + return new ParsedSymbol(ParsedSymbol.TYPE_FLOAT, new Double(Double.parseDouble((yytext())))); + } + case 59: + break; + case 31: { + return new ParsedSymbol(ParsedSymbol.TYPE_INTERNAL); + } + case 60: + break; + case 23: { + return new ParsedSymbol(ParsedSymbol.TYPE_DOTS); + } + case 61: + break; + case 19: { + string.append('\\'); + } + case 62: + break; + case 7: { + return new ParsedSymbol(ParsedSymbol.TYPE_STAR); + } + case 63: + break; + case 13: { + throw new ParseException("Illegal escape sequence \"" + yytext() + "\"", yyline + 1); + } + case 64: + break; + case 30: { + return new ParsedSymbol(ParsedSymbol.TYPE_PACKAGE); + } + case 65: + break; + case 26: { + isMultiname = true; + String s = yytext(); + multinameId = Long.parseLong(s.substring(2, s.length() - 2)); + yybegin(STRING); + string.setLength(0); + } + case 66: + break; + case 15: { + string.append('\n'); + } + case 67: + break; + case 21: { + string.append('\f'); + } + case 68: + break; + case 20: { + string.append('\"'); + } + case 69: + break; + case 1: { + } + case 70: + break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + { + return new ParsedSymbol(ParsedSymbol.TYPE_EOF); + } + } else { + zzScanError(ZZ_NO_MATCH); + } } - case 36: - break; - case 8: { - return new ParsedSymbol(ParsedSymbol.TYPE_ASSIGN); - } - case 37: - break; - case 24: { - return new ParsedSymbol(ParsedSymbol.TYPE_NULL); - } - case 38: - break; - case 22: { - string.append('\''); - } - case 39: - break; - case 3: { - return new ParsedSymbol(ParsedSymbol.TYPE_INTEGER, new Long(Long.parseLong((yytext())))); - } - case 40: - break; - case 33: { - return new ParsedSymbol(ParsedSymbol.TYPE_UNDEFINED); - } - case 41: - break; - case 34: { - return new ParsedSymbol(ParsedSymbol.TYPE_PROTECTED); - } - case 42: - break; - case 28: { - return new ParsedSymbol(ParsedSymbol.TYPE_STATIC); - } - case 43: - break; - case 9: { - string.append(yytext()); - } - case 44: - break; - case 14: { - char val = (char) Integer.parseInt(yytext().substring(1), 8); - string.append(val); - } - case 45: - break; - case 29: { - return new ParsedSymbol(ParsedSymbol.TYPE_PRIVATE); - } - case 46: - break; - case 5: { - return new ParsedSymbol(ParsedSymbol.TYPE_COLON); - } - case 47: - break; - case 18: { - string.append('\r'); - } - case 48: - break; - case 25: { - return new ParsedSymbol(ParsedSymbol.TYPE_TRUE); - } - case 49: - break; - case 6: { - return new ParsedSymbol(ParsedSymbol.TYPE_COMMA); - } - case 50: - break; - case 35: { - String s = yytext(); - long ns = Long.parseLong(s.substring(3, s.length() - 2)); - return new ParsedSymbol(ParsedSymbol.TYPE_NAMESPACE, new Long(ns)); - } - case 51: - break; - case 27: { - return new ParsedSymbol(ParsedSymbol.TYPE_FALSE); - } - case 52: - break; - case 11: { - yybegin(YYINITIAL); - // length also includes the trailing quote - if (isMultiname) { - return new ParsedSymbol(ParsedSymbol.TYPE_MULTINAME, new Long(multinameId)); - } else { - return new ParsedSymbol(ParsedSymbol.TYPE_STRING, string.toString()); - } - } - case 53: - break; - case 17: { - string.append('\b'); - } - case 54: - break; - case 10: { - throw new ParseException("Unterminated string at end of line", yyline + 1); - } - case 55: - break; - case 4: { - isMultiname = false; - yybegin(STRING); - string.setLength(0); - } - case 56: - break; - case 32: { - return new ParsedSymbol(ParsedSymbol.TYPE_EXPLICIT); - } - case 57: - break; - case 16: { - string.append('\t'); - } - case 58: - break; - case 12: { - return new ParsedSymbol(ParsedSymbol.TYPE_FLOAT, new Double(Double.parseDouble((yytext())))); - } - case 59: - break; - case 31: { - return new ParsedSymbol(ParsedSymbol.TYPE_INTERNAL); - } - case 60: - break; - case 23: { - return new ParsedSymbol(ParsedSymbol.TYPE_DOTS); - } - case 61: - break; - case 19: { - string.append('\\'); - } - case 62: - break; - case 7: { - return new ParsedSymbol(ParsedSymbol.TYPE_STAR); - } - case 63: - break; - case 13: { - throw new ParseException("Illegal escape sequence \"" + yytext() + "\"", yyline + 1); - } - case 64: - break; - case 30: { - return new ParsedSymbol(ParsedSymbol.TYPE_PACKAGE); - } - case 65: - break; - case 26: { - isMultiname = true; - String s = yytext(); - multinameId = Long.parseLong(s.substring(2, s.length() - 2)); - yybegin(STRING); - string.setLength(0); - } - case 66: - break; - case 15: { - string.append('\n'); - } - case 67: - break; - case 21: { - string.append('\f'); - } - case 68: - break; - case 20: { - string.append('\"'); - } - case 69: - break; - case 1: { - } - case 70: - break; - default: - if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { - zzAtEOF = true; - { - return new ParsedSymbol(ParsedSymbol.TYPE_EOF); - } - } else { - zzScanError(ZZ_NO_MATCH); - } - } - } - } + } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/MethodInfoParser.java b/trunk/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/MethodInfoParser.java index 58bc8a731..f3b16de90 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/MethodInfoParser.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/MethodInfoParser.java @@ -32,282 +32,282 @@ import java.util.List; */ public class MethodInfoParser { - public static boolean parseSlotConst(String text, TraitSlotConst trait, ABC abc) throws ParseException { - MethodInfoLexer lexer = new MethodInfoLexer(new ByteArrayInputStream(text.getBytes())); - ParsedSymbol symb; - int type_index = -1; - ValueKind value = new ValueKind(0, 0); - try { - ParsedSymbol symbType = lexer.yylex(); - if (symbType.type == ParsedSymbol.TYPE_STAR) { - type_index = 0; - } else if (symbType.type == ParsedSymbol.TYPE_MULTINAME) { - type_index = (int) (long) (Long) symbType.value; - } else { - throw new ParseException("Multiname or * expected", lexer.yyline()); - } - ParsedSymbol symbEqual = lexer.yylex(); - if (symbEqual.type == ParsedSymbol.TYPE_ASSIGN) { - ParsedSymbol symbValue; - String nstype = ""; - do { - symbValue = lexer.yylex(); - if (symbValue.type >= 8 && symbValue.type <= 13) { - nstype = nstype + symbValue.type + ":"; - } - } while (symbValue.type >= 8 && symbValue.type <= 13); - if ((!nstype.equals("")) && (symbValue.type != ParsedSymbol.TYPE_NAMESPACE)) { - throw new ParseException("Namespace expected", lexer.yyline()); + public static boolean parseSlotConst(String text, TraitSlotConst trait, ABC abc) throws ParseException { + MethodInfoLexer lexer = new MethodInfoLexer(new ByteArrayInputStream(text.getBytes())); + ParsedSymbol symb; + int type_index = -1; + ValueKind value = new ValueKind(0, 0); + try { + ParsedSymbol symbType = lexer.yylex(); + if (symbType.type == ParsedSymbol.TYPE_STAR) { + type_index = 0; + } else if (symbType.type == ParsedSymbol.TYPE_MULTINAME) { + type_index = (int) (long) (Long) symbType.value; + } else { + throw new ParseException("Multiname or * expected", lexer.yyline()); } - int id = 0; - switch (symbValue.type) { - case ParsedSymbol.TYPE_INTEGER: - value = new ValueKind(abc.constants.forceGetIntId((Long) symbValue.value), ValueKind.CONSTANT_Int); - break; - case ParsedSymbol.TYPE_FLOAT: - value = new ValueKind(abc.constants.forceGetDoubleId((Double) symbValue.value), ValueKind.CONSTANT_Double); - break; - case ParsedSymbol.TYPE_STRING: - value = new ValueKind(abc.constants.forceGetStringId((String) symbValue.value), ValueKind.CONSTANT_Utf8); - break; - case ParsedSymbol.TYPE_TRUE: - value = new ValueKind(0, ValueKind.CONSTANT_True); - break; - case ParsedSymbol.TYPE_FALSE: - value = new ValueKind(0, ValueKind.CONSTANT_False); - break; - case ParsedSymbol.TYPE_NULL: - value = new ValueKind(0, ValueKind.CONSTANT_Null); - break; - case ParsedSymbol.TYPE_UNDEFINED: - value = new ValueKind(0, ValueKind.CONSTANT_Undefined); - break; - case ParsedSymbol.TYPE_NAMESPACE: - if (nstype.equals("9:")) { - value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageNamespace); - } else if (nstype.equals("9:10:")) { - value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageInternalNs); - } else if (nstype.equals("13:")) { - value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ProtectedNamespace); - } else if (nstype.equals("12:")) { - value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ExplicitNamespace); - } else if (nstype.equals("11:13:")) { - value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_StaticProtectedNs); - } else if (nstype.equals("8:")) { - value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PrivateNs); - } else if (nstype.equals("")) { - value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_Namespace); - } else { - throw new ParseException("Invalid type of namespace", lexer.yyline()); - } - break; - default: - throw new ParseException("Unexpected symbol", lexer.yyline()); + ParsedSymbol symbEqual = lexer.yylex(); + if (symbEqual.type == ParsedSymbol.TYPE_ASSIGN) { + ParsedSymbol symbValue; + String nstype = ""; + do { + symbValue = lexer.yylex(); + if (symbValue.type >= 8 && symbValue.type <= 13) { + nstype = nstype + symbValue.type + ":"; + } + } while (symbValue.type >= 8 && symbValue.type <= 13); + if ((!nstype.equals("")) && (symbValue.type != ParsedSymbol.TYPE_NAMESPACE)) { + throw new ParseException("Namespace expected", lexer.yyline()); + } + int id = 0; + switch (symbValue.type) { + case ParsedSymbol.TYPE_INTEGER: + value = new ValueKind(abc.constants.forceGetIntId((Long) symbValue.value), ValueKind.CONSTANT_Int); + break; + case ParsedSymbol.TYPE_FLOAT: + value = new ValueKind(abc.constants.forceGetDoubleId((Double) symbValue.value), ValueKind.CONSTANT_Double); + break; + case ParsedSymbol.TYPE_STRING: + value = new ValueKind(abc.constants.forceGetStringId((String) symbValue.value), ValueKind.CONSTANT_Utf8); + break; + case ParsedSymbol.TYPE_TRUE: + value = new ValueKind(0, ValueKind.CONSTANT_True); + break; + case ParsedSymbol.TYPE_FALSE: + value = new ValueKind(0, ValueKind.CONSTANT_False); + break; + case ParsedSymbol.TYPE_NULL: + value = new ValueKind(0, ValueKind.CONSTANT_Null); + break; + case ParsedSymbol.TYPE_UNDEFINED: + value = new ValueKind(0, ValueKind.CONSTANT_Undefined); + break; + case ParsedSymbol.TYPE_NAMESPACE: + if (nstype.equals("9:")) { + value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageNamespace); + } else if (nstype.equals("9:10:")) { + value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageInternalNs); + } else if (nstype.equals("13:")) { + value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ProtectedNamespace); + } else if (nstype.equals("12:")) { + value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ExplicitNamespace); + } else if (nstype.equals("11:13:")) { + value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_StaticProtectedNs); + } else if (nstype.equals("8:")) { + value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PrivateNs); + } else if (nstype.equals("")) { + value = new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_Namespace); + } else { + throw new ParseException("Invalid type of namespace", lexer.yyline()); + } + break; + default: + throw new ParseException("Unexpected symbol", lexer.yyline()); + } + symb = lexer.yylex(); + if (symb.type != ParsedSymbol.TYPE_EOF) { + throw new ParseException("Unexpected symbol", lexer.yyline()); + } + } else if (symbEqual.type == ParsedSymbol.TYPE_EOF) { + } else { + throw new ParseException("Unexpected symbol", lexer.yyline()); + } + } catch (IOException ex) { + return false; + } + trait.type_index = type_index; + trait.value_kind = value.value_kind; + trait.value_index = value.value_index; + return true; + } + + public static boolean parseReturnType(String text, MethodInfo update) throws ParseException { + MethodInfoLexer lexer = new MethodInfoLexer(new ByteArrayInputStream(text.getBytes())); + ParsedSymbol symb; + int type = -1; + try { + symb = lexer.yylex(); + if (symb.type == ParsedSymbol.TYPE_STAR) { + type = 0; + } else if (symb.type == ParsedSymbol.TYPE_MULTINAME) { + type = (int) (long) (Long) symb.value; + } else { + throw new ParseException("Multiname or * expected", lexer.yyline()); } symb = lexer.yylex(); if (symb.type != ParsedSymbol.TYPE_EOF) { - throw new ParseException("Unexpected symbol", lexer.yyline()); + throw new ParseException("Only one return type allowed", lexer.yyline()); } - } else if (symbEqual.type == ParsedSymbol.TYPE_EOF) { - } else { - throw new ParseException("Unexpected symbol", lexer.yyline()); - } - } catch (IOException ex) { - return false; - } - trait.type_index = type_index; - trait.value_kind = value.value_kind; - trait.value_index = value.value_index; - return true; - } + update.ret_type = type; + return true; + } catch (IOException ex) { + } + return false; + } - public static boolean parseReturnType(String text, MethodInfo update) throws ParseException { - MethodInfoLexer lexer = new MethodInfoLexer(new ByteArrayInputStream(text.getBytes())); - ParsedSymbol symb; - int type = -1; - try { - symb = lexer.yylex(); - if (symb.type == ParsedSymbol.TYPE_STAR) { - type = 0; - } else if (symb.type == ParsedSymbol.TYPE_MULTINAME) { - type = (int) (long) (Long) symb.value; - } else { - throw new ParseException("Multiname or * expected", lexer.yyline()); - } - symb = lexer.yylex(); - if (symb.type != ParsedSymbol.TYPE_EOF) { - throw new ParseException("Only one return type allowed", lexer.yyline()); - } - update.ret_type = type; - return true; - } catch (IOException ex) { - } - return false; - } - - public static boolean parseParams(String text, MethodInfo update, ABC abc) throws ParseException { - MethodInfoLexer lexer = new MethodInfoLexer(new ByteArrayInputStream(text.getBytes())); - List paramNames = new ArrayList(); - List paramTypes = new ArrayList(); - List optionalValues = new ArrayList(); - boolean hasOptional = false; - boolean needsRest = false; - try { - ParsedSymbol symb; - symb = lexer.yylex(); - while (symb.type != ParsedSymbol.TYPE_EOF) { - if (symb.type == ParsedSymbol.TYPE_DOTS) { - needsRest = true; - symb = lexer.yylex(); - if (symb.type != ParsedSymbol.TYPE_IDENTIFIER) { - throw new ParseException("Identifier expected", lexer.yyline()); - } - symb = lexer.yylex(); - if (symb.type != ParsedSymbol.TYPE_EOF) { - throw new ParseException("End expected after rest params", lexer.yyline()); - } - break; - } - - if (symb.type != ParsedSymbol.TYPE_IDENTIFIER) { - throw new ParseException("Identifier expected", lexer.yyline()); - } - paramNames.add((String) symb.value); + public static boolean parseParams(String text, MethodInfo update, ABC abc) throws ParseException { + MethodInfoLexer lexer = new MethodInfoLexer(new ByteArrayInputStream(text.getBytes())); + List paramNames = new ArrayList(); + List paramTypes = new ArrayList(); + List optionalValues = new ArrayList(); + boolean hasOptional = false; + boolean needsRest = false; + try { + ParsedSymbol symb; symb = lexer.yylex(); - if (symb.type == ParsedSymbol.TYPE_COLON) { - ParsedSymbol symbType = lexer.yylex(); - if (symbType.type == ParsedSymbol.TYPE_STAR) { - paramTypes.add(new Long(0)); - } else if (symbType.type == ParsedSymbol.TYPE_MULTINAME) { - paramTypes.add((Long) symbType.value); - } else { - throw new ParseException("Multiname or * expected", lexer.yyline()); - } - ParsedSymbol symbEqual = lexer.yylex(); - if (symbEqual.type == ParsedSymbol.TYPE_ASSIGN) { - hasOptional = true; - ParsedSymbol symbValue; - String nstype = ""; - do { - symbValue = lexer.yylex(); - if (symbValue.type >= 8 && symbValue.type <= 13) { - nstype = nstype + symbValue.type + ":"; - } - } while (symbValue.type >= 8 && symbValue.type <= 13); - if ((!nstype.equals("")) && (symbValue.type != ParsedSymbol.TYPE_NAMESPACE)) { - throw new ParseException("Namespace expected", lexer.yyline()); - } - int id = 0; - switch (symbValue.type) { - case ParsedSymbol.TYPE_INTEGER: - optionalValues.add(new ValueKind(abc.constants.forceGetIntId((Long) symbValue.value), ValueKind.CONSTANT_Int)); - break; - case ParsedSymbol.TYPE_FLOAT: - optionalValues.add(new ValueKind(abc.constants.forceGetDoubleId((Double) symbValue.value), ValueKind.CONSTANT_Double)); - break; - case ParsedSymbol.TYPE_STRING: - optionalValues.add(new ValueKind(abc.constants.forceGetStringId((String) symbValue.value), ValueKind.CONSTANT_Utf8)); - break; - case ParsedSymbol.TYPE_TRUE: - optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_True)); - break; - case ParsedSymbol.TYPE_FALSE: - optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_False)); - break; - case ParsedSymbol.TYPE_NULL: - optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_Null)); - break; - case ParsedSymbol.TYPE_UNDEFINED: - optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_Undefined)); - break; - case ParsedSymbol.TYPE_NAMESPACE: - if (nstype.equals("9:")) { - optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageNamespace)); - } else if (nstype.equals("9:10:")) { - optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageInternalNs)); - } else if (nstype.equals("13:")) { - optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ProtectedNamespace)); - } else if (nstype.equals("12:")) { - optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ExplicitNamespace)); - } else if (nstype.equals("11:13:")) { - optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_StaticProtectedNs)); - } else if (nstype.equals("8:")) { - optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PrivateNs)); - } else if (nstype.equals("")) { - optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_Namespace)); - } else { - throw new ParseException("Invalid type of namespace", lexer.yyline()); + while (symb.type != ParsedSymbol.TYPE_EOF) { + if (symb.type == ParsedSymbol.TYPE_DOTS) { + needsRest = true; + symb = lexer.yylex(); + if (symb.type != ParsedSymbol.TYPE_IDENTIFIER) { + throw new ParseException("Identifier expected", lexer.yyline()); + } + symb = lexer.yylex(); + if (symb.type != ParsedSymbol.TYPE_EOF) { + throw new ParseException("End expected after rest params", lexer.yyline()); + } + break; + } + + if (symb.type != ParsedSymbol.TYPE_IDENTIFIER) { + throw new ParseException("Identifier expected", lexer.yyline()); + } + paramNames.add((String) symb.value); + symb = lexer.yylex(); + if (symb.type == ParsedSymbol.TYPE_COLON) { + ParsedSymbol symbType = lexer.yylex(); + if (symbType.type == ParsedSymbol.TYPE_STAR) { + paramTypes.add(new Long(0)); + } else if (symbType.type == ParsedSymbol.TYPE_MULTINAME) { + paramTypes.add((Long) symbType.value); + } else { + throw new ParseException("Multiname or * expected", lexer.yyline()); + } + ParsedSymbol symbEqual = lexer.yylex(); + if (symbEqual.type == ParsedSymbol.TYPE_ASSIGN) { + hasOptional = true; + ParsedSymbol symbValue; + String nstype = ""; + do { + symbValue = lexer.yylex(); + if (symbValue.type >= 8 && symbValue.type <= 13) { + nstype = nstype + symbValue.type + ":"; + } + } while (symbValue.type >= 8 && symbValue.type <= 13); + if ((!nstype.equals("")) && (symbValue.type != ParsedSymbol.TYPE_NAMESPACE)) { + throw new ParseException("Namespace expected", lexer.yyline()); + } + int id = 0; + switch (symbValue.type) { + case ParsedSymbol.TYPE_INTEGER: + optionalValues.add(new ValueKind(abc.constants.forceGetIntId((Long) symbValue.value), ValueKind.CONSTANT_Int)); + break; + case ParsedSymbol.TYPE_FLOAT: + optionalValues.add(new ValueKind(abc.constants.forceGetDoubleId((Double) symbValue.value), ValueKind.CONSTANT_Double)); + break; + case ParsedSymbol.TYPE_STRING: + optionalValues.add(new ValueKind(abc.constants.forceGetStringId((String) symbValue.value), ValueKind.CONSTANT_Utf8)); + break; + case ParsedSymbol.TYPE_TRUE: + optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_True)); + break; + case ParsedSymbol.TYPE_FALSE: + optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_False)); + break; + case ParsedSymbol.TYPE_NULL: + optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_Null)); + break; + case ParsedSymbol.TYPE_UNDEFINED: + optionalValues.add(new ValueKind(0, ValueKind.CONSTANT_Undefined)); + break; + case ParsedSymbol.TYPE_NAMESPACE: + if (nstype.equals("9:")) { + optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageNamespace)); + } else if (nstype.equals("9:10:")) { + optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PackageInternalNs)); + } else if (nstype.equals("13:")) { + optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ProtectedNamespace)); + } else if (nstype.equals("12:")) { + optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_ExplicitNamespace)); + } else if (nstype.equals("11:13:")) { + optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_StaticProtectedNs)); + } else if (nstype.equals("8:")) { + optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_PrivateNs)); + } else if (nstype.equals("")) { + optionalValues.add(new ValueKind((int) (long) (Long) symbValue.value, ValueKind.CONSTANT_Namespace)); + } else { + throw new ParseException("Invalid type of namespace", lexer.yyline()); + } + break; + default: + throw new ParseException("Unexpected symbol", lexer.yyline()); + } + symb = lexer.yylex(); + if (symb.type == ParsedSymbol.TYPE_COMMA) { + } else if (symb.type == ParsedSymbol.TYPE_EOF) { + break; + } + } else if (symbEqual.type == ParsedSymbol.TYPE_COMMA) { + if (hasOptional) { + throw new ParseException("Parameter must have default value", lexer.yyline()); + } + } else if (symbEqual.type == ParsedSymbol.TYPE_EOF) { + if (hasOptional) { + throw new ParseException("Parameter must have default value", lexer.yyline()); } break; - default: + } else { throw new ParseException("Unexpected symbol", lexer.yyline()); - } - symb = lexer.yylex(); - if (symb.type == ParsedSymbol.TYPE_COMMA) { - } else if (symb.type == ParsedSymbol.TYPE_EOF) { - break; - } - } else if (symbEqual.type == ParsedSymbol.TYPE_COMMA) { - if (hasOptional) { - throw new ParseException("Parameter must have default value", lexer.yyline()); - } - } else if (symbEqual.type == ParsedSymbol.TYPE_EOF) { - if (hasOptional) { - throw new ParseException("Parameter must have default value", lexer.yyline()); - } - break; - } else { - throw new ParseException("Unexpected symbol", lexer.yyline()); - } - } else if (symb.type == ParsedSymbol.TYPE_COMMA) { - } else if (symb.type == ParsedSymbol.TYPE_EOF) { - break; - } else { - throw new ParseException("Unexpected symbol", lexer.yyline()); + } + } else if (symb.type == ParsedSymbol.TYPE_COMMA) { + } else if (symb.type == ParsedSymbol.TYPE_EOF) { + break; + } else { + throw new ParseException("Unexpected symbol", lexer.yyline()); + } + symb = lexer.yylex(); } - symb = lexer.yylex(); - } - } catch (IOException iex) { - return false; - } + } catch (IOException iex) { + return false; + } - if (needsRest && (!optionalValues.isEmpty())) { - throw new ParseException("Rest parameter canot be combined with default values", lexer.yyline()); - } + if (needsRest && (!optionalValues.isEmpty())) { + throw new ParseException("Rest parameter canot be combined with default values", lexer.yyline()); + } - update.param_types = new int[paramTypes.size()]; - for (int p = 0; p < paramTypes.size(); p++) { - update.param_types[p] = (int) (long) paramTypes.get(p); - } - update.optional = (ValueKind[]) optionalValues.toArray(new ValueKind[optionalValues.size()]); - update.unsetFlagHas_optional(); - if (!optionalValues.isEmpty()) { - update.setFlagHas_optional(); - } - update.unsetFlagNeed_rest(); - if (needsRest) { - update.setFlagNeed_rest(); - } + update.param_types = new int[paramTypes.size()]; + for (int p = 0; p < paramTypes.size(); p++) { + update.param_types[p] = (int) (long) paramTypes.get(p); + } + update.optional = (ValueKind[]) optionalValues.toArray(new ValueKind[optionalValues.size()]); + update.unsetFlagHas_optional(); + if (!optionalValues.isEmpty()) { + update.setFlagHas_optional(); + } + update.unsetFlagNeed_rest(); + if (needsRest) { + update.setFlagNeed_rest(); + } - update.unsetFlagHas_paramnames(); - update.paramNames = new int[]{}; - boolean useParamNames = false; - for (int p = 0; p < paramNames.size(); p++) { - if (!paramNames.get(p).equals("param" + (p + 1))) { - useParamNames = true; - } - } - if (!Main.PARAM_NAMES_ENABLE) { - useParamNames = false; - } - if (useParamNames) { - update.setFlagHas_paramnames(); - update.paramNames = new int[paramNames.size()]; - for (int p = 0; p < paramNames.size(); p++) { - update.paramNames[p] = abc.constants.forceGetStringId(paramNames.get(p)); - } - } - return true; + update.unsetFlagHas_paramnames(); + update.paramNames = new int[]{}; + boolean useParamNames = false; + for (int p = 0; p < paramNames.size(); p++) { + if (!paramNames.get(p).equals("param" + (p + 1))) { + useParamNames = true; + } + } + if (!Main.PARAM_NAMES_ENABLE) { + useParamNames = false; + } + if (useParamNames) { + update.setFlagHas_paramnames(); + update.paramNames = new int[paramNames.size()]; + for (int p = 0; p < paramNames.size(); p++) { + update.paramNames[p] = abc.constants.forceGetStringId(paramNames.get(p)); + } + } + return true; - } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/ParseException.java b/trunk/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/ParseException.java index c91a1ff67..5fcd85c5e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/ParseException.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/ParseException.java @@ -18,12 +18,12 @@ package com.jpexs.decompiler.flash.abc.methodinfo_parser; public class ParseException extends Exception { - public long line; - public String text; + public long line; + public String text; - public ParseException(String text, long line) { - super("ParseException:" + text + " on line " + line); - this.line = line; - this.text = text; - } + public ParseException(String text, long line) { + super("ParseException:" + text + " on line " + line); + this.line = line; + this.text = text; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/ParsedSymbol.java b/trunk/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/ParsedSymbol.java index 382c545c4..dc52a32c1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/ParsedSymbol.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/methodinfo_parser/ParsedSymbol.java @@ -18,38 +18,38 @@ package com.jpexs.decompiler.flash.abc.methodinfo_parser; public class ParsedSymbol { - public int type; - public Object value; - public static final int TYPE_INTEGER = 1; - public static final int TYPE_FLOAT = 2; - public static final int TYPE_TRUE = 3; - public static final int TYPE_FALSE = 4; - public static final int TYPE_NULL = 5; - public static final int TYPE_UNDEFINED = 6; - public static final int TYPE_STRING = 7; - //8-12 namespace prefix - public static final int TYPE_PRIVATE = 8; - public static final int TYPE_PACKAGE = 9; - public static final int TYPE_INTERNAL = 10; - public static final int TYPE_STATIC = 11; - public static final int TYPE_EXPLICIT = 12; - public static final int TYPE_PROTECTED = 13; - public static final int TYPE_NAMESPACE = 14; - public static final int TYPE_COLON = 15; - public static final int TYPE_COMMA = 16; - public static final int TYPE_DOTS = 17; - public static final int TYPE_MULTINAME = 18; - public static final int TYPE_IDENTIFIER = 19; - public static final int TYPE_EOF = 20; - public static final int TYPE_STAR = 21; - public static final int TYPE_ASSIGN = 22; + public int type; + public Object value; + public static final int TYPE_INTEGER = 1; + public static final int TYPE_FLOAT = 2; + public static final int TYPE_TRUE = 3; + public static final int TYPE_FALSE = 4; + public static final int TYPE_NULL = 5; + public static final int TYPE_UNDEFINED = 6; + public static final int TYPE_STRING = 7; + //8-12 namespace prefix + public static final int TYPE_PRIVATE = 8; + public static final int TYPE_PACKAGE = 9; + public static final int TYPE_INTERNAL = 10; + public static final int TYPE_STATIC = 11; + public static final int TYPE_EXPLICIT = 12; + public static final int TYPE_PROTECTED = 13; + public static final int TYPE_NAMESPACE = 14; + public static final int TYPE_COLON = 15; + public static final int TYPE_COMMA = 16; + public static final int TYPE_DOTS = 17; + public static final int TYPE_MULTINAME = 18; + public static final int TYPE_IDENTIFIER = 19; + public static final int TYPE_EOF = 20; + public static final int TYPE_STAR = 21; + public static final int TYPE_ASSIGN = 22; - public ParsedSymbol(int type, Object value) { - this.type = type; - this.value = value; - } + public ParsedSymbol(int type, Object value) { + this.type = type; + this.value = value; + } - public ParsedSymbol(int type) { - this.type = type; - } + public ParsedSymbol(int type) { + this.type = type; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/ABCException.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/ABCException.java index 86e98eea1..428a7ec21 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/ABCException.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/ABCException.java @@ -25,44 +25,44 @@ import java.util.List; public class ABCException implements Serializable { - public int start; - public int end; - public int target; - public int type_index; - public int name_index; + public int start; + public int end; + public int target; + public int type_index; + public int name_index; - @Override - public String toString() { - return "Exception: startServer=" + Helper.formatAddress(start) + " end=" + Helper.formatAddress(end) + " target=" + target + " type_index=" + type_index + " name_index=" + name_index; - } + @Override + public String toString() { + return "Exception: startServer=" + Helper.formatAddress(start) + " end=" + Helper.formatAddress(end) + " target=" + target + " type_index=" + type_index + " name_index=" + name_index; + } - public String toString(ConstantPool constants, List fullyQualifiedNames) { - return "Exception: startServer=" + Helper.formatAddress(start) + " end=" + Helper.formatAddress(end) + " target=" + target + " type=\"" + getTypeName(constants, fullyQualifiedNames) + "\" name=\"" + getVarName(constants, fullyQualifiedNames) + "\""; - } + public String toString(ConstantPool constants, List fullyQualifiedNames) { + return "Exception: startServer=" + Helper.formatAddress(start) + " end=" + Helper.formatAddress(end) + " target=" + target + " type=\"" + getTypeName(constants, fullyQualifiedNames) + "\" name=\"" + getVarName(constants, fullyQualifiedNames) + "\""; + } - public String toString(ConstantPool constants, AVM2Code code, List fullyQualifiedNames) { - try { - return "Exception: startServer=" + code.adr2pos(start) + ":" + code.code.get(code.adr2pos(start)).toStringNoAddress(constants, fullyQualifiedNames) + " end=" + code.adr2pos(end) + ":" + code.code.get(code.adr2pos(end)).toStringNoAddress(constants, fullyQualifiedNames) + " target=" + code.adr2pos(target) + ":" + code.code.get(code.adr2pos(target)).toStringNoAddress(constants, fullyQualifiedNames) + " type=\"" + getTypeName(constants, fullyQualifiedNames) + "\" name=\"" + getVarName(constants, fullyQualifiedNames) + "\""; - } catch (ConvertException ex) { - return ""; - } - } + public String toString(ConstantPool constants, AVM2Code code, List fullyQualifiedNames) { + try { + return "Exception: startServer=" + code.adr2pos(start) + ":" + code.code.get(code.adr2pos(start)).toStringNoAddress(constants, fullyQualifiedNames) + " end=" + code.adr2pos(end) + ":" + code.code.get(code.adr2pos(end)).toStringNoAddress(constants, fullyQualifiedNames) + " target=" + code.adr2pos(target) + ":" + code.code.get(code.adr2pos(target)).toStringNoAddress(constants, fullyQualifiedNames) + " type=\"" + getTypeName(constants, fullyQualifiedNames) + "\" name=\"" + getVarName(constants, fullyQualifiedNames) + "\""; + } catch (ConvertException ex) { + return ""; + } + } - public boolean isFinally() { - return (name_index == 0) && (type_index == 0); - } + public boolean isFinally() { + return (name_index == 0) && (type_index == 0); + } - public String getVarName(ConstantPool constants, List fullyQualifiedNames) { - if (name_index == 0) { - return ""; - } - return constants.constant_multiname[name_index].getName(constants, fullyQualifiedNames); - } + public String getVarName(ConstantPool constants, List fullyQualifiedNames) { + if (name_index == 0) { + return ""; + } + return constants.constant_multiname[name_index].getName(constants, fullyQualifiedNames); + } - public String getTypeName(ConstantPool constants, List fullyQualifiedNames) { - if (type_index == 0) { - return "*"; - } - return constants.constant_multiname[type_index].getName(constants, fullyQualifiedNames); - } + public String getTypeName(ConstantPool constants, List fullyQualifiedNames) { + if (type_index == 0) { + return "*"; + } + return constants.constant_multiname[type_index].getName(constants, fullyQualifiedNames); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/ClassInfo.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/ClassInfo.java index 6dbdec1a1..9feadf838 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/ClassInfo.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/ClassInfo.java @@ -22,15 +22,15 @@ import java.util.List; public class ClassInfo { - public int cinit_index; //MethodInfo - static initializer - public Traits static_traits; + public int cinit_index; //MethodInfo - static initializer + public Traits static_traits; - @Override - public String toString() { - return "method_index=" + cinit_index + "\r\n" + static_traits.toString(); - } + @Override + public String toString() { + return "method_index=" + cinit_index + "\r\n" + static_traits.toString(); + } - public String toString(ABC abc, List fullyQualifiedNames) { - return "method_index=" + cinit_index + "\r\n" + static_traits.toString(abc, fullyQualifiedNames); - } + public String toString(ABC abc, List fullyQualifiedNames) { + return "method_index=" + cinit_index + "\r\n" + static_traits.toString(abc, fullyQualifiedNames); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/Decimal.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/Decimal.java index 65a52cfd4..8f0678d08 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/Decimal.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/Decimal.java @@ -22,14 +22,14 @@ package com.jpexs.decompiler.flash.abc.types; */ public class Decimal { - public byte data[]; + public byte data[]; - public Decimal(byte data[]) { - this.data = data; - } + public Decimal(byte data[]) { + this.data = data; + } - @Override - public String toString() { - return new String(data); - } + @Override + public String toString() { + return new String(data); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java index eb3fa1ec4..20bb62117 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/InstanceInfo.java @@ -25,83 +25,83 @@ import java.util.List; public class InstanceInfo { - public int name_index; - public int super_index; - public int flags; // 1 = sealed, 0 = dynamic, 2 = final, 4 = interface, 8 = ProtectedNs - public int protectedNS; //if flags & 8 - public int interfaces[]; - public int iinit_index; // MethodInfo - constructor - public Traits instance_traits; - public static final int CLASS_SEALED = 1; //not dynamic - public static final int CLASS_FINAL = 2; - public static final int CLASS_INTERFACE = 4; - public static final int CLASS_PROTECTEDNS = 8; + public int name_index; + public int super_index; + public int flags; // 1 = sealed, 0 = dynamic, 2 = final, 4 = interface, 8 = ProtectedNs + public int protectedNS; //if flags & 8 + public int interfaces[]; + public int iinit_index; // MethodInfo - constructor + public Traits instance_traits; + public static final int CLASS_SEALED = 1; //not dynamic + public static final int CLASS_FINAL = 2; + public static final int CLASS_INTERFACE = 4; + public static final int CLASS_PROTECTEDNS = 8; - @Override - public String toString() { - return "name_index=" + name_index + " super_index=" + super_index + " flags=" + flags + " protectedNS=" + protectedNS + " interfaces=" + Helper.intArrToString(interfaces) + " method_index=" + iinit_index + "\r\n" + instance_traits.toString(); - } + @Override + public String toString() { + return "name_index=" + name_index + " super_index=" + super_index + " flags=" + flags + " protectedNS=" + protectedNS + " interfaces=" + Helper.intArrToString(interfaces) + " method_index=" + iinit_index + "\r\n" + instance_traits.toString(); + } - public String toString(ABC abc, List fullyQualifiedNames) { - String supIndexStr = "[nothing]"; - if (super_index > 0) { - supIndexStr = abc.constants.constant_multiname[super_index].toString(abc.constants, fullyQualifiedNames); - } - return "name_index=" + abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " super_index=" + supIndexStr + " flags=" + flags + " protectedNS=" + protectedNS + " interfaces=" + Helper.intArrToString(interfaces) + " method_index=" + iinit_index + "\r\n" + instance_traits.toString(abc, fullyQualifiedNames); - } + public String toString(ABC abc, List fullyQualifiedNames) { + String supIndexStr = "[nothing]"; + if (super_index > 0) { + supIndexStr = abc.constants.constant_multiname[super_index].toString(abc.constants, fullyQualifiedNames); + } + return "name_index=" + abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " super_index=" + supIndexStr + " flags=" + flags + " protectedNS=" + protectedNS + " interfaces=" + Helper.intArrToString(interfaces) + " method_index=" + iinit_index + "\r\n" + instance_traits.toString(abc, fullyQualifiedNames); + } - public String getClassHeaderStr(ABC abc, List fullyQualifiedNames) { - String supIndexStr = ""; - if (super_index > 0) { - supIndexStr = " extends " + abc.constants.constant_multiname[super_index].getName(abc.constants, fullyQualifiedNames);////+" flags="+flags+" protectedNS="+protectedNS+" interfaces="+Helper.intArrToString(interfaces)+" method_index="+iinit_index - } - String implStr = ""; - if (interfaces.length > 0) { - if (isInterface()) { - implStr = " extends "; - } else { - implStr = " implements "; - } - for (int i = 0; i < interfaces.length; i++) { - if (i > 0) { - implStr += ", "; + public String getClassHeaderStr(ABC abc, List fullyQualifiedNames) { + String supIndexStr = ""; + if (super_index > 0) { + supIndexStr = " extends " + abc.constants.constant_multiname[super_index].getName(abc.constants, fullyQualifiedNames);////+" flags="+flags+" protectedNS="+protectedNS+" interfaces="+Helper.intArrToString(interfaces)+" method_index="+iinit_index + } + String implStr = ""; + if (interfaces.length > 0) { + if (isInterface()) { + implStr = " extends "; + } else { + implStr = " implements "; } - implStr += abc.constants.constant_multiname[interfaces[i]].getName(abc.constants, fullyQualifiedNames); - } - } - String modifiers; - Namespace ns = abc.constants.constant_multiname[name_index].getNamespace(abc.constants); - modifiers = ns.getPrefix(abc); - if (!modifiers.equals("")) { - modifiers += " "; - } + for (int i = 0; i < interfaces.length; i++) { + if (i > 0) { + implStr += ", "; + } + implStr += abc.constants.constant_multiname[interfaces[i]].getName(abc.constants, fullyQualifiedNames); + } + } + String modifiers; + Namespace ns = abc.constants.constant_multiname[name_index].getNamespace(abc.constants); + modifiers = ns.getPrefix(abc); + if (!modifiers.equals("")) { + modifiers += " "; + } - if (isFinal()) { - modifiers += "final "; - } - if (isDynamic()) { - modifiers = modifiers + "dynamic "; - } - String objType = "class "; - if (isInterface()) { - objType = "interface "; - } - return modifiers + objType + abc.constants.constant_multiname[name_index].getName(abc.constants, new ArrayList()/* No full names here*/) + supIndexStr + implStr; - } + if (isFinal()) { + modifiers += "final "; + } + if (isDynamic()) { + modifiers = modifiers + "dynamic "; + } + String objType = "class "; + if (isInterface()) { + objType = "interface "; + } + return modifiers + objType + abc.constants.constant_multiname[name_index].getName(abc.constants, new ArrayList()/* No full names here*/) + supIndexStr + implStr; + } - public Multiname getName(ConstantPool constants) { - return constants.constant_multiname[name_index]; - } + public Multiname getName(ConstantPool constants) { + return constants.constant_multiname[name_index]; + } - public boolean isInterface() { - return ((flags & CLASS_INTERFACE) == CLASS_INTERFACE); - } + public boolean isInterface() { + return ((flags & CLASS_INTERFACE) == CLASS_INTERFACE); + } - public boolean isDynamic() { - return (flags & CLASS_SEALED) == 0; - } + public boolean isDynamic() { + return (flags & CLASS_SEALED) == 0; + } - public boolean isFinal() { - return (flags & CLASS_FINAL) == CLASS_FINAL; - } + public boolean isFinal() { + return (flags & CLASS_FINAL) == CLASS_FINAL; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/MetadataInfo.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/MetadataInfo.java index 043b67090..2c9c7763c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/MetadataInfo.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/MetadataInfo.java @@ -21,33 +21,33 @@ import com.jpexs.decompiler.flash.helpers.Helper; public class MetadataInfo { - public int name_index; - public int keys[]; - public int values[]; + public int name_index; + public int keys[]; + public int values[]; - public MetadataInfo(int name_index, int[] keys, int[] values) { - this.name_index = name_index; - this.keys = keys; - this.values = values; - } + public MetadataInfo(int name_index, int[] keys, int[] values) { + this.name_index = name_index; + this.keys = keys; + this.values = values; + } - @Override - public String toString() { - return "name_index=" + name_index + " keys=" + Helper.intArrToString(keys) + " values=" + Helper.intArrToString(values); - } + @Override + public String toString() { + return "name_index=" + name_index + " keys=" + Helper.intArrToString(keys) + " values=" + Helper.intArrToString(values); + } - public String toString(ConstantPool constants) { - String s = "name=" + constants.constant_string[name_index]; - if (keys.length > 0) { - s += "\r\n"; - } - for (int i = 0; i < keys.length; i++) { - if (keys[i] == 0) { - s += "\"" + constants.constant_string[values[i]] + "\"\r\n"; - } else { - s += "\"" + constants.constant_string[keys[i]] + "\"=\"" + constants.constant_string[values[i]] + "\"\r\n"; - } - } - return s; - } + public String toString(ConstantPool constants) { + String s = "name=" + constants.constant_string[name_index]; + if (keys.length > 0) { + s += "\r\n"; + } + for (int i = 0; i < keys.length; i++) { + if (keys[i] == 0) { + s += "\"" + constants.constant_string[values[i]] + "\"\r\n"; + } else { + s += "\"" + constants.constant_string[keys[i]] + "\"=\"" + constants.constant_string[values[i]] + "\"\r\n"; + } + } + return s; + } } 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 b37317db2..db5d92f7c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodBody.java @@ -33,129 +33,129 @@ import java.util.Stack; public class MethodBody implements Cloneable, Serializable { - public int method_info; - public int max_stack; - public int max_regs; - public int init_scope_depth; - public int max_scope_depth; - public byte codeBytes[]; - public AVM2Code code; - public ABCException exceptions[] = new ABCException[0]; - public Traits traits = new Traits(); + public int method_info; + public int max_stack; + public int max_regs; + public int init_scope_depth; + public int max_scope_depth; + public byte codeBytes[]; + public AVM2Code code; + public ABCException exceptions[] = new ABCException[0]; + public Traits traits = new Traits(); - public List getExceptionEntries() { - List ret = new ArrayList(); - for (ABCException e : exceptions) { - ret.add(code.adr2pos(e.start)); - ret.add(code.adr2pos(e.end)); - ret.add(code.adr2pos(e.target)); - } - return ret; - } + public List getExceptionEntries() { + List ret = new ArrayList(); + for (ABCException e : exceptions) { + ret.add(code.adr2pos(e.start)); + ret.add(code.adr2pos(e.end)); + ret.add(code.adr2pos(e.target)); + } + return ret; + } - @Override - public String toString() { - String s = ""; - s += "method_info=" + method_info + " max_stack=" + max_stack + " max_regs=" + max_regs + " scope_depth=" + init_scope_depth + " max_scope=" + max_scope_depth; - s += "\r\nCode:\r\n" + code.toString(); - return s; - } + @Override + public String toString() { + String s = ""; + s += "method_info=" + method_info + " max_stack=" + max_stack + " max_regs=" + max_regs + " scope_depth=" + init_scope_depth + " max_scope=" + max_scope_depth; + s += "\r\nCode:\r\n" + code.toString(); + return s; + } - public int removeDeadCode(ConstantPool constants) { - return code.removeDeadCode(constants, this); - } + public int removeDeadCode(ConstantPool constants) { + return code.removeDeadCode(constants, this); + } - public void restoreControlFlow(ConstantPool constants) { - code.restoreControlFlow(constants, this); - } + public void restoreControlFlow(ConstantPool constants) { + code.restoreControlFlow(constants, this); + } - public int removeTraps(ConstantPool constants, ABC abc) { - return code.removeTraps(constants, this, abc); - } + public int removeTraps(ConstantPool constants, ABC abc) { + return code.removeTraps(constants, this, abc); + } - public HashMap getLocalRegNames(ABC abc) { - HashMap ret = new HashMap(); - for (int i = 1; i <= abc.method_info[this.method_info].param_types.length; i++) { - String paramName = "param" + i; - if (abc.method_info[this.method_info].flagHas_paramnames() && Main.PARAM_NAMES_ENABLE) { - paramName = abc.constants.constant_string[abc.method_info[this.method_info].paramNames[i - 1]]; - } - ret.put(i, paramName); - } - int pos = abc.method_info[this.method_info].param_types.length + 1; - if (abc.method_info[this.method_info].flagNeed_arguments()) { - ret.put(pos, "arguments"); - pos++; - } - if (abc.method_info[this.method_info].flagNeed_rest()) { - ret.put(pos, "rest"); - pos++; - } - - HashMap debugRegNames = code.getLocalRegNamesFromDebug(abc); - for (int k : debugRegNames.keySet()) { - ret.put(k, debugRegNames.get(k)); - } - return ret; - } - - public String toString(String path, boolean pcode, boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], Stack scopeStack, boolean isStaticInitializer, boolean hilight, List fullyQualifiedNames, Traits initTraits) { - String s = ""; - if (!Main.DO_DECOMPILE) { - s = "//NOT DECOMPILED"; - if (hilight) { - s = Highlighting.hilighMethod(s, this.method_info); - } - return s; - } - if (pcode) { - s += code.toASMSource(constants, this, false); - } else { - AVM2Code deobfuscated = null; - MethodBody b = (MethodBody) Helper.deepCopy(this); - deobfuscated = b.code; - deobfuscated.markMappedOffsets(); - deobfuscated.removeTraps(constants, b, abc); - //deobfuscated.restoreControlFlow(constants, b); - try { - s += deobfuscated.toSource(path, isStatic, classIndex, abc, constants, method_info, b, hilight, getLocalRegNames(abc), scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits); - s = s.trim(); - if (hilight) { - s = Highlighting.hilighMethod(s, this.method_info); + public HashMap getLocalRegNames(ABC abc) { + HashMap ret = new HashMap(); + for (int i = 1; i <= abc.method_info[this.method_info].param_types.length; i++) { + String paramName = "param" + i; + if (abc.method_info[this.method_info].flagHas_paramnames() && Main.PARAM_NAMES_ENABLE) { + paramName = abc.constants.constant_string[abc.method_info[this.method_info].paramNames[i - 1]]; } - } catch (Exception ex) { - ex.printStackTrace(); - s = "//error:" + ex.toString(); - } - } - return s; - } + ret.put(i, paramName); + } + int pos = abc.method_info[this.method_info].param_types.length + 1; + if (abc.method_info[this.method_info].flagNeed_arguments()) { + ret.put(pos, "arguments"); + pos++; + } + if (abc.method_info[this.method_info].flagNeed_rest()) { + ret.put(pos, "rest"); + pos++; + } - @Override - public Object clone() throws CloneNotSupportedException { - MethodBody ret = new MethodBody(); - ret.code = code; - ret.codeBytes = codeBytes; - ret.exceptions = exceptions; - ret.max_regs = max_regs; - ret.max_scope_depth = max_scope_depth; - ret.max_stack = max_stack; - ret.method_info = method_info; - ret.init_scope_depth = init_scope_depth; - ret.traits = traits; //maybe deep clone - return ret; - } + HashMap debugRegNames = code.getLocalRegNamesFromDebug(abc); + for (int k : debugRegNames.keySet()) { + ret.put(k, debugRegNames.get(k)); + } + return ret; + } - public boolean autoFillStats(ABC abc) { - CodeStats stats = code.getStats(abc, this); - if (stats == null) { - return false; - } - max_stack = stats.maxstack; - max_scope_depth = init_scope_depth + stats.maxscope; - max_regs = stats.maxlocal; - abc.method_info[method_info].setFlagSetsdxns(stats.has_set_dxns); - abc.method_info[method_info].setFlagNeed_activation(stats.has_activation); - return true; - } + public String toString(String path, boolean pcode, boolean isStatic, int classIndex, ABC abc, ConstantPool constants, MethodInfo method_info[], Stack scopeStack, boolean isStaticInitializer, boolean hilight, List fullyQualifiedNames, Traits initTraits) { + String s = ""; + if (!Main.DO_DECOMPILE) { + s = "//NOT DECOMPILED"; + if (hilight) { + s = Highlighting.hilighMethod(s, this.method_info); + } + return s; + } + if (pcode) { + s += code.toASMSource(constants, this, false); + } else { + AVM2Code deobfuscated = null; + MethodBody b = (MethodBody) Helper.deepCopy(this); + deobfuscated = b.code; + deobfuscated.markMappedOffsets(); + deobfuscated.removeTraps(constants, b, abc); + //deobfuscated.restoreControlFlow(constants, b); + try { + s += deobfuscated.toSource(path, isStatic, classIndex, abc, constants, method_info, b, hilight, getLocalRegNames(abc), scopeStack, isStaticInitializer, fullyQualifiedNames, initTraits); + s = s.trim(); + if (hilight) { + s = Highlighting.hilighMethod(s, this.method_info); + } + } catch (Exception ex) { + ex.printStackTrace(); + s = "//error:" + ex.toString(); + } + } + return s; + } + + @Override + public Object clone() throws CloneNotSupportedException { + MethodBody ret = new MethodBody(); + ret.code = code; + ret.codeBytes = codeBytes; + ret.exceptions = exceptions; + ret.max_regs = max_regs; + ret.max_scope_depth = max_scope_depth; + ret.max_stack = max_stack; + ret.method_info = method_info; + ret.init_scope_depth = init_scope_depth; + ret.traits = traits; //maybe deep clone + return ret; + } + + public boolean autoFillStats(ABC abc) { + CodeStats stats = code.getStats(abc, this); + if (stats == null) { + return false; + } + max_stack = stats.maxstack; + max_scope_depth = init_scope_depth + stats.maxscope; + max_regs = stats.maxlocal; + abc.method_info[method_info].setFlagSetsdxns(stats.has_set_dxns); + abc.method_info[method_info].setFlagNeed_activation(stats.has_activation); + return true; + } } 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 1c8469e7f..62952aa72 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/MethodInfo.java @@ -25,266 +25,266 @@ import java.util.List; public class MethodInfo { - public int param_types[]; - public int ret_type; - public int name_index; //0=no name - // 1=need_arguments, 2=need_activation, 4=need_rest 8=has_optional 16=ignore_rest, 32=explicit, 64=setsdxns, 128=has_paramnames - public int flags; - public ValueKind optional[]; - public int paramNames[]; - private MethodBody body; + public int param_types[]; + public int ret_type; + public int name_index; //0=no name + // 1=need_arguments, 2=need_activation, 4=need_rest 8=has_optional 16=ignore_rest, 32=explicit, 64=setsdxns, 128=has_paramnames + public int flags; + public ValueKind optional[]; + public int paramNames[]; + private MethodBody body; - public void setFlagSetsdxns() { - flags |= 64; - } + public void setFlagSetsdxns() { + flags |= 64; + } - public void setFlagSetsdxns(boolean val) { - if (val) { - setFlagSetsdxns(); - } else { - unsetFlagSetsdxns(); - } - } + public void setFlagSetsdxns(boolean val) { + if (val) { + setFlagSetsdxns(); + } else { + unsetFlagSetsdxns(); + } + } - public void unsetFlagSetsdxns() { - if (flagSetsdxns()) { - flags -= 64; - } - } + public void unsetFlagSetsdxns() { + if (flagSetsdxns()) { + flags -= 64; + } + } - public void setFlagNeed_activation() { - flags |= 2; - } + public void setFlagNeed_activation() { + flags |= 2; + } - public void setFlagNeed_activation(boolean val) { - if (val) { - setFlagNeed_activation(); - } else { - unsetFlagNeed_activation(); - } - } + public void setFlagNeed_activation(boolean val) { + if (val) { + setFlagNeed_activation(); + } else { + unsetFlagNeed_activation(); + } + } - public void unsetFlagNeed_activation() { - if (flagNeed_activation()) { - flags -= 2; - } - } + public void unsetFlagNeed_activation() { + if (flagNeed_activation()) { + flags -= 2; + } + } - public void setFlagNeed_rest() { - flags |= 4; - } + public void setFlagNeed_rest() { + flags |= 4; + } - public void unsetFlagNeed_rest() { - if (flagNeed_rest()) { - flags -= 4; - } - } + public void unsetFlagNeed_rest() { + if (flagNeed_rest()) { + flags -= 4; + } + } - public void setFlagNeed_rest(boolean val) { - if (val) { - setFlagNeed_rest(); - } else { - unsetFlagNeed_rest(); - } - } + public void setFlagNeed_rest(boolean val) { + if (val) { + setFlagNeed_rest(); + } else { + unsetFlagNeed_rest(); + } + } - public void setFlagHas_optional() { - flags |= 8; - } + public void setFlagHas_optional() { + flags |= 8; + } - public void unsetFlagHas_optional() { - if (flagHas_optional()) { - flags -= 8; - } - } + public void unsetFlagHas_optional() { + if (flagHas_optional()) { + flags -= 8; + } + } - public void setFlagHas_optional(boolean val) { - if (val) { - setFlagHas_optional(); - } else { - unsetFlagHas_optional(); - } - } + public void setFlagHas_optional(boolean val) { + if (val) { + setFlagHas_optional(); + } else { + unsetFlagHas_optional(); + } + } - public void setFlagHas_paramnames() { - flags |= 128; - } + public void setFlagHas_paramnames() { + flags |= 128; + } - public void unsetFlagHas_paramnames() { - if (flagHas_paramnames()) { - flags -= 128; - } - } + public void unsetFlagHas_paramnames() { + if (flagHas_paramnames()) { + flags -= 128; + } + } - public void setFlagHas_paramnames(boolean val) { - if (val) { - setFlagHas_paramnames(); - } else { - unsetFlagHas_paramnames(); - } - } + public void setFlagHas_paramnames(boolean val) { + if (val) { + setFlagHas_paramnames(); + } else { + unsetFlagHas_paramnames(); + } + } - public boolean flagNeed_arguments() { - return (flags & 1) == 1; - } + public boolean flagNeed_arguments() { + return (flags & 1) == 1; + } - public boolean flagNeed_activation() { - return (flags & 2) == 2; - } + public boolean flagNeed_activation() { + return (flags & 2) == 2; + } - public boolean flagNeed_rest() { - return (flags & 4) == 4; - } + public boolean flagNeed_rest() { + return (flags & 4) == 4; + } - public boolean flagHas_optional() { - return (flags & 8) == 8; - } + public boolean flagHas_optional() { + return (flags & 8) == 8; + } - public boolean flagIgnore_restHas_optional() { - return (flags & 16) == 16; - } + public boolean flagIgnore_restHas_optional() { + return (flags & 16) == 16; + } - public boolean flagExplicit() { - return (flags & 32) == 32; - } + public boolean flagExplicit() { + return (flags & 32) == 32; + } - public boolean flagSetsdxns() { - return (flags & 64) == 64; - } + public boolean flagSetsdxns() { + return (flags & 64) == 64; + } - public boolean flagHas_paramnames() { - return (flags & 128) == 128; - } + public boolean flagHas_paramnames() { + return (flags & 128) == 128; + } - public MethodInfo(int param_types[], int ret_type, int name_index, int flags, ValueKind optional[], int paramNames[]) { - this.param_types = param_types; - this.ret_type = ret_type; - this.name_index = name_index; - this.flags = flags; - this.optional = optional; - this.paramNames = paramNames; - } + public MethodInfo(int param_types[], int ret_type, int name_index, int flags, ValueKind optional[], int paramNames[]) { + this.param_types = param_types; + this.ret_type = ret_type; + this.name_index = name_index; + this.flags = flags; + this.optional = optional; + this.paramNames = paramNames; + } - @Override - public String toString() { - String optionalStr = "["; - if (optional != null) { - for (int i = 0; i < optional.length; i++) { + @Override + public String toString() { + String optionalStr = "["; + if (optional != null) { + for (int i = 0; i < optional.length; i++) { + if (i > 0) { + optionalStr += ","; + } + optionalStr += optional[i].toString(); + } + } + optionalStr += "]"; + return "MethodInfo: param_types=" + Helper.intArrToString(param_types) + " ret_type=" + ret_type + " name_index=" + name_index + " flags=" + flags + " optional=" + optionalStr + " paramNames=" + Helper.intArrToString(paramNames); + } + + public String toString(ConstantPool constants, List fullyQualifiedNames) { + String optionalStr = "["; + if (optional != null) { + for (int i = 0; i < optional.length; i++) { + if (i > 0) { + optionalStr += ","; + } + optionalStr += optional[i].toString(constants); + } + } + optionalStr += "]"; + + String param_typesStr = ""; + for (int i = 0; i < param_types.length; i++) { if (i > 0) { - optionalStr += ","; + param_typesStr += ","; } - optionalStr += optional[i].toString(); - } - } - optionalStr += "]"; - return "MethodInfo: param_types=" + Helper.intArrToString(param_types) + " ret_type=" + ret_type + " name_index=" + name_index + " flags=" + flags + " optional=" + optionalStr + " paramNames=" + Helper.intArrToString(paramNames); - } + if (param_types[i] == 0) { + param_typesStr += "*"; + } else { + param_typesStr += constants.constant_multiname[param_types[i]].toString(constants, fullyQualifiedNames); + } + } - public String toString(ConstantPool constants, List fullyQualifiedNames) { - String optionalStr = "["; - if (optional != null) { - for (int i = 0; i < optional.length; i++) { + String paramNamesStr = ""; + for (int i = 0; i < paramNames.length; i++) { if (i > 0) { - optionalStr += ","; + paramNamesStr += ","; } - optionalStr += optional[i].toString(constants); - } - } - optionalStr += "]"; + paramNamesStr += constants.constant_string[paramNames[i]]; + } - String param_typesStr = ""; - for (int i = 0; i < param_types.length; i++) { - if (i > 0) { - param_typesStr += ","; - } - if (param_types[i] == 0) { - param_typesStr += "*"; - } else { - param_typesStr += constants.constant_multiname[param_types[i]].toString(constants, fullyQualifiedNames); - } - } + String ret_typeStr = ""; + if (ret_type == 0) { + ret_typeStr += "*"; + } else { + ret_typeStr += constants.constant_multiname[ret_type].toString(constants, fullyQualifiedNames); + } - String paramNamesStr = ""; - for (int i = 0; i < paramNames.length; i++) { - if (i > 0) { - paramNamesStr += ","; - } - paramNamesStr += constants.constant_string[paramNames[i]]; - } + return "param_types=" + param_typesStr + " ret_type=" + ret_typeStr + " name=\"" + constants.constant_string[name_index] + "\" flags=" + flags + " optional=" + optionalStr + " paramNames=" + paramNamesStr; + } - String ret_typeStr = ""; - if (ret_type == 0) { - ret_typeStr += "*"; - } else { - ret_typeStr += constants.constant_multiname[ret_type].toString(constants, fullyQualifiedNames); - } + public String getName(ConstantPool constants) { + if (name_index == 0) { + return "UNKNOWN"; + } + return constants.constant_string[name_index]; + } - return "param_types=" + param_typesStr + " ret_type=" + ret_typeStr + " name=\"" + constants.constant_string[name_index] + "\" flags=" + flags + " optional=" + optionalStr + " paramNames=" + paramNamesStr; - } - - public String getName(ConstantPool constants) { - if (name_index == 0) { - return "UNKNOWN"; - } - return constants.constant_string[name_index]; - } - - public String getParamStr(ConstantPool constants, MethodBody body, ABC abc, List fullyQualifiedNames) { - HashMap localRegNames = new HashMap(); - if (body != null) { - localRegNames = body.code.getLocalRegNamesFromDebug(abc); - } - String paramStr = ""; - for (int i = 0; i < param_types.length; i++) { - if (i > 0) { - paramStr += ", "; - } - if (!localRegNames.isEmpty()) { - paramStr += localRegNames.get(i + 1); - } else if ((paramNames.length > i) && (paramNames[i] != 0) && Main.PARAM_NAMES_ENABLE) { - paramStr += constants.constant_string[paramNames[i]]; - } else { - paramStr += "param" + (i + 1); - } - paramStr += ":"; - if (param_types[i] == 0) { - paramStr += "*"; - } else { - paramStr += constants.constant_multiname[param_types[i]].getName(constants, fullyQualifiedNames); - } - if (optional != null) { - if (i >= param_types.length - optional.length) { - paramStr += "=" + optional[i - (param_types.length - optional.length)].toString(constants); + public String getParamStr(ConstantPool constants, MethodBody body, ABC abc, List fullyQualifiedNames) { + HashMap localRegNames = new HashMap(); + if (body != null) { + localRegNames = body.code.getLocalRegNamesFromDebug(abc); + } + String paramStr = ""; + for (int i = 0; i < param_types.length; i++) { + if (i > 0) { + paramStr += ", "; + } + if (!localRegNames.isEmpty()) { + paramStr += localRegNames.get(i + 1); + } else if ((paramNames.length > i) && (paramNames[i] != 0) && Main.PARAM_NAMES_ENABLE) { + paramStr += constants.constant_string[paramNames[i]]; + } else { + paramStr += "param" + (i + 1); + } + paramStr += ":"; + if (param_types[i] == 0) { + paramStr += "*"; + } else { + paramStr += constants.constant_multiname[param_types[i]].getName(constants, fullyQualifiedNames); + } + if (optional != null) { + if (i >= param_types.length - optional.length) { + paramStr += "=" + optional[i - (param_types.length - optional.length)].toString(constants); + } + } + } + if (flagNeed_rest()) { + if ((param_types != null) && (param_types.length > 0)) { + paramStr += ", "; + } + paramStr += "... "; + if (!localRegNames.isEmpty()) { + paramStr += localRegNames.get(param_types.length + 1); + } else { + paramStr += "rest"; } - } - } - if (flagNeed_rest()) { - if ((param_types != null) && (param_types.length > 0)) { - paramStr += ", "; - } - paramStr += "... "; - if (!localRegNames.isEmpty()) { - paramStr += localRegNames.get(param_types.length + 1); - } else { - paramStr += "rest"; - } - } - return paramStr; - } + } + return paramStr; + } - public String getReturnTypeStr(ConstantPool constants, List fullyQualifiedNames) { - if (ret_type == 0) { - return "*"; - } - return constants.constant_multiname[ret_type].getName(constants, fullyQualifiedNames); - } + public String getReturnTypeStr(ConstantPool constants, List fullyQualifiedNames) { + if (ret_type == 0) { + return "*"; + } + return constants.constant_multiname[ret_type].getName(constants, fullyQualifiedNames); + } - public void setBody(MethodBody body) { - this.body = body; - } + public void setBody(MethodBody body) { + this.body = body; + } - public MethodBody getBody() { - return body; - } + public MethodBody getBody() { + return body; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/Multiname.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/Multiname.java index ceea40048..e80f1f702 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/Multiname.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/Multiname.java @@ -21,223 +21,223 @@ import java.util.List; public class Multiname { - public static final int QNAME = 7; - public static final int QNAMEA = 0x0d; - public static final int RTQNAME = 0x0f; - public static final int RTQNAMEA = 0x10; - public static final int RTQNAMEL = 0x11; - public static final int RTQNAMELA = 0x12; - public static final int MULTINAME = 0x09; - public static final int MULTINAMEA = 0x0e; - public static final int MULTINAMEL = 0x1b; - public static final int MULTINAMELA = 0x1c; - public static final int TYPENAME = 0x1d; - private static final int multinameKinds[] = new int[]{QNAME, QNAMEA, MULTINAME, MULTINAMEA, RTQNAME, RTQNAMEA, MULTINAMEL, RTQNAMEL, RTQNAMELA, MULTINAMELA, TYPENAME}; - private static final String multinameKindNames[] = new String[]{"Qname", "QnameA", "Multiname", "MultinameA", "RTQname", "RTQnameA", "MultinameL", "RTQnameL", "RTQnameLA", "MultinameLA", "TypeName"}; - public int kind = -1; - public int name_index = -1; - public int namespace_index = -1; - public int namespace_set_index = -1; - public int qname_index = -1; //for TypeName - public List params; //for TypeName + public static final int QNAME = 7; + public static final int QNAMEA = 0x0d; + public static final int RTQNAME = 0x0f; + public static final int RTQNAMEA = 0x10; + public static final int RTQNAMEL = 0x11; + public static final int RTQNAMELA = 0x12; + public static final int MULTINAME = 0x09; + public static final int MULTINAMEA = 0x0e; + public static final int MULTINAMEL = 0x1b; + public static final int MULTINAMELA = 0x1c; + public static final int TYPENAME = 0x1d; + private static final int multinameKinds[] = new int[]{QNAME, QNAMEA, MULTINAME, MULTINAMEA, RTQNAME, RTQNAMEA, MULTINAMEL, RTQNAMEL, RTQNAMELA, MULTINAMELA, TYPENAME}; + private static final String multinameKindNames[] = new String[]{"Qname", "QnameA", "Multiname", "MultinameA", "RTQname", "RTQnameA", "MultinameL", "RTQnameL", "RTQnameLA", "MultinameLA", "TypeName"}; + public int kind = -1; + public int name_index = -1; + public int namespace_index = -1; + public int namespace_set_index = -1; + public int qname_index = -1; //for TypeName + public List params; //for TypeName - public Multiname(int kind, int name_index, int namespace_index, int namespace_set_index, int qname_index, List params) { - this.kind = kind; - this.name_index = name_index; - this.namespace_index = namespace_index; - this.namespace_set_index = namespace_set_index; - this.qname_index = qname_index; - this.params = params; - } + public Multiname(int kind, int name_index, int namespace_index, int namespace_set_index, int qname_index, List params) { + this.kind = kind; + this.name_index = name_index; + this.namespace_index = namespace_index; + this.namespace_set_index = namespace_set_index; + this.qname_index = qname_index; + this.params = params; + } - public boolean isAttribute() { - if (kind == QNAMEA) { - return true; - } - if (kind == MULTINAMEA) { - return true; - } - if (kind == RTQNAMEA) { - return true; - } - if (kind == RTQNAMELA) { - return true; - } - if (kind == MULTINAMELA) { - return true; - } - return false; - } + public boolean isAttribute() { + if (kind == QNAMEA) { + return true; + } + if (kind == MULTINAMEA) { + return true; + } + if (kind == RTQNAMEA) { + return true; + } + if (kind == RTQNAMELA) { + return true; + } + if (kind == MULTINAMELA) { + return true; + } + return false; + } - public boolean isRuntime() { - if (kind == RTQNAME) { - return true; - } - if (kind == RTQNAMEA) { - return true; - } - if (kind == MULTINAMEL) { - return true; - } - if (kind == MULTINAMELA) { - return true; - } - return false; - } + public boolean isRuntime() { + if (kind == RTQNAME) { + return true; + } + if (kind == RTQNAMEA) { + return true; + } + if (kind == MULTINAMEL) { + return true; + } + if (kind == MULTINAMELA) { + return true; + } + return false; + } - public boolean needsName() { - if (kind == RTQNAMEL) { - return true; - } - if (kind == RTQNAMELA) { - return true; - } - if (kind == MULTINAMEL) { - return true; - } - if (kind == MULTINAMELA) { - return true; - } - return false; - } + public boolean needsName() { + if (kind == RTQNAMEL) { + return true; + } + if (kind == RTQNAMELA) { + return true; + } + if (kind == MULTINAMEL) { + return true; + } + if (kind == MULTINAMELA) { + return true; + } + return false; + } - public boolean needsNs() { - if (kind == RTQNAME) { - return true; - } - if (kind == RTQNAMEA) { - return true; - } - if (kind == RTQNAMEL) { - return true; - } - if (kind == RTQNAMELA) { - return true; - } - return false; - } + public boolean needsNs() { + if (kind == RTQNAME) { + return true; + } + if (kind == RTQNAMEA) { + return true; + } + if (kind == RTQNAMEL) { + return true; + } + if (kind == RTQNAMELA) { + return true; + } + return false; + } - public String getKindStr() { - String kindStr = "?"; - for (int k = 0; k < multinameKinds.length; k++) { - if (multinameKinds[k] == kind) { - kindStr = multinameKindNames[k]; - break; - } - } - return kindStr; - } - - @Override - public String toString() { - String kindStr = getKindStr(); - return "kind=" + kindStr + " name_index=" + name_index + " namespace_index=" + namespace_index + " namespace_set_index=" + namespace_set_index + " qname_index=" + qname_index + " params_size:" + params.size(); - - } - - public String toString(ConstantPool constants, List fullyQualifiedNames) { - String kindStr = "?"; - for (int k = 0; k < multinameKinds.length; k++) { - if (multinameKinds[k] == kind) { - kindStr = multinameKindNames[k] + " "; - break; - } - } - String nameStr = ""; - if (name_index > 0) { - nameStr = constants.constant_string[name_index]; - } - if (name_index == 0) { - nameStr = "*"; - } - String namespaceStr = ""; - if (namespace_index > 0) { - namespaceStr = constants.constant_namespace[namespace_index].toString(constants); - } - if (!namespaceStr.equals("")) { - namespaceStr = namespaceStr + "."; - } - if (namespace_index == 0) { - namespaceStr = "*."; - } - String namespaceSetStr = ""; - if (namespace_set_index > 0) { - namespaceSetStr = " "; - } - String typeNameStr = ""; - if (kind == TYPENAME) { - typeNameStr = typeNameToStr(constants, fullyQualifiedNames); - } - - return namespaceStr + nameStr + namespaceSetStr + typeNameStr; - - } - - private String typeNameToStr(ConstantPool constants, List fullyQualifiedNames) { - String typeNameStr = constants.constant_multiname[qname_index].getName(constants, fullyQualifiedNames); - if (!params.isEmpty()) { - typeNameStr += ".<"; - for (int i = 0; i < params.size(); i++) { - if (i > 0) { - typeNameStr += ","; + public String getKindStr() { + String kindStr = "?"; + for (int k = 0; k < multinameKinds.length; k++) { + if (multinameKinds[k] == kind) { + kindStr = multinameKindNames[k]; + break; } - if (params.get(i) == 0) { - typeNameStr += "*"; - } else { - typeNameStr += constants.constant_multiname[params.get(i)].getName(constants, fullyQualifiedNames); + } + return kindStr; + } + + @Override + public String toString() { + String kindStr = getKindStr(); + return "kind=" + kindStr + " name_index=" + name_index + " namespace_index=" + namespace_index + " namespace_set_index=" + namespace_set_index + " qname_index=" + qname_index + " params_size:" + params.size(); + + } + + public String toString(ConstantPool constants, List fullyQualifiedNames) { + String kindStr = "?"; + for (int k = 0; k < multinameKinds.length; k++) { + if (multinameKinds[k] == kind) { + kindStr = multinameKindNames[k] + " "; + break; } - } - typeNameStr += ">"; - } - return typeNameStr; - } + } + String nameStr = ""; + if (name_index > 0) { + nameStr = constants.constant_string[name_index]; + } + if (name_index == 0) { + nameStr = "*"; + } + String namespaceStr = ""; + if (namespace_index > 0) { + namespaceStr = constants.constant_namespace[namespace_index].toString(constants); + } + if (!namespaceStr.equals("")) { + namespaceStr = namespaceStr + "."; + } + if (namespace_index == 0) { + namespaceStr = "*."; + } + String namespaceSetStr = ""; + if (namespace_set_index > 0) { + namespaceSetStr = " "; + } + String typeNameStr = ""; + if (kind == TYPENAME) { + typeNameStr = typeNameToStr(constants, fullyQualifiedNames); + } - public String getName(ConstantPool constants, List fullyQualifiedNames) { - if (kind == TYPENAME) { - return typeNameToStr(constants, fullyQualifiedNames); - } - if (name_index == -1) { - return ""; - } - if (name_index == 0) { - return (isAttribute() ? "@*" : "*"); - } else { - String name = constants.constant_string[name_index]; - if ((fullyQualifiedNames != null) && fullyQualifiedNames.contains(name)) { - return getNameWithNamespace(constants); - } - return (isAttribute() ? "@" : "") + name; - } - } + return namespaceStr + nameStr + namespaceSetStr + typeNameStr; - public String getNameWithNamespace(ConstantPool constants) { - String ret = ""; - Namespace ns = getNamespace(constants); - if (ns != null) { - String nsname = ns.getName(constants); - if (!nsname.equals("")) { - ret += nsname + "."; - } - } - ret += getName(constants, null); - return ret; - } + } - public Namespace getNamespace(ConstantPool constants) { - if ((namespace_index == 0) || (namespace_index == -1)) { - return null; - } else { - return constants.constant_namespace[namespace_index]; - } - } + private String typeNameToStr(ConstantPool constants, List fullyQualifiedNames) { + String typeNameStr = constants.constant_multiname[qname_index].getName(constants, fullyQualifiedNames); + if (!params.isEmpty()) { + typeNameStr += ".<"; + for (int i = 0; i < params.size(); i++) { + if (i > 0) { + typeNameStr += ","; + } + if (params.get(i) == 0) { + typeNameStr += "*"; + } else { + typeNameStr += constants.constant_multiname[params.get(i)].getName(constants, fullyQualifiedNames); + } + } + typeNameStr += ">"; + } + return typeNameStr; + } - public NamespaceSet getNamespaceSet(ConstantPool constants) { - if (namespace_set_index == 0) { - return null; - } else if (namespace_set_index == -1) { - return null; - } else { - return constants.constant_namespace_set[namespace_set_index]; - } - } + public String getName(ConstantPool constants, List fullyQualifiedNames) { + if (kind == TYPENAME) { + return typeNameToStr(constants, fullyQualifiedNames); + } + if (name_index == -1) { + return ""; + } + if (name_index == 0) { + return (isAttribute() ? "@*" : "*"); + } else { + String name = constants.constant_string[name_index]; + if ((fullyQualifiedNames != null) && fullyQualifiedNames.contains(name)) { + return getNameWithNamespace(constants); + } + return (isAttribute() ? "@" : "") + name; + } + } + + public String getNameWithNamespace(ConstantPool constants) { + String ret = ""; + Namespace ns = getNamespace(constants); + if (ns != null) { + String nsname = ns.getName(constants); + if (!nsname.equals("")) { + ret += nsname + "."; + } + } + ret += getName(constants, null); + return ret; + } + + public Namespace getNamespace(ConstantPool constants) { + if ((namespace_index == 0) || (namespace_index == -1)) { + return null; + } else { + return constants.constant_namespace[namespace_index]; + } + } + + public NamespaceSet getNamespaceSet(ConstantPool constants) { + if (namespace_set_index == 0) { + return null; + } else if (namespace_set_index == -1) { + return null; + } else { + return constants.constant_namespace_set[namespace_set_index]; + } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/Namespace.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/Namespace.java index eb0681cd3..0345d3569 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/Namespace.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/Namespace.java @@ -21,66 +21,66 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; public class Namespace { - public static final int KIND_NAMESPACE = 8; - public static final int KIND_PRIVATE = 5; - public static final int KIND_PACKAGE = 22; - public static final int KIND_PACKAGE_INTERNAL = 23; - public static final int KIND_PROTECTED = 24; - public static final int KIND_EXPLICIT = 25; - public static final int KIND_STATIC_PROTECTED = 26; - public static final int nameSpaceKinds[] = new int[]{KIND_NAMESPACE, KIND_PRIVATE, KIND_PACKAGE, KIND_PACKAGE_INTERNAL, KIND_PROTECTED, KIND_EXPLICIT, KIND_STATIC_PROTECTED}; - public static final String nameSpaceKindNames[] = new String[]{"Namespace", "PrivateNamespace", "PackageNamespace", "PackageInternalNamespace", "ProtectedNamespace", "ExplicitNamespace", "StaticProtectedNamespace"}; - public static final String namePrefixes[] = new String[]{"", "private", "public", "", "protected", "explicit", "protected"}; - public int kind; - public int name_index; + public static final int KIND_NAMESPACE = 8; + public static final int KIND_PRIVATE = 5; + public static final int KIND_PACKAGE = 22; + public static final int KIND_PACKAGE_INTERNAL = 23; + public static final int KIND_PROTECTED = 24; + public static final int KIND_EXPLICIT = 25; + public static final int KIND_STATIC_PROTECTED = 26; + public static final int nameSpaceKinds[] = new int[]{KIND_NAMESPACE, KIND_PRIVATE, KIND_PACKAGE, KIND_PACKAGE_INTERNAL, KIND_PROTECTED, KIND_EXPLICIT, KIND_STATIC_PROTECTED}; + public static final String nameSpaceKindNames[] = new String[]{"Namespace", "PrivateNamespace", "PackageNamespace", "PackageInternalNamespace", "ProtectedNamespace", "ExplicitNamespace", "StaticProtectedNamespace"}; + public static final String namePrefixes[] = new String[]{"", "private", "public", "", "protected", "explicit", "protected"}; + public int kind; + public int name_index; - public Namespace(int kind, int name_index) { - this.kind = kind; - this.name_index = name_index; - } + public Namespace(int kind, int name_index) { + this.kind = kind; + this.name_index = name_index; + } - public String getKindStr() { - String kindStr = "?"; - for (int k = 0; k < nameSpaceKinds.length; k++) { - if (nameSpaceKinds[k] == kind) { - kindStr = nameSpaceKindNames[k]; - break; - } - } - return kindStr; - } + public String getKindStr() { + String kindStr = "?"; + for (int k = 0; k < nameSpaceKinds.length; k++) { + if (nameSpaceKinds[k] == kind) { + kindStr = nameSpaceKindNames[k]; + break; + } + } + return kindStr; + } - @Override - public String toString() { + @Override + public String toString() { - return "Namespace: kind=" + getKindStr() + " name_index=" + name_index; - } + return "Namespace: kind=" + getKindStr() + " name_index=" + name_index; + } - public String toString(ConstantPool constants) { - return getName(constants); //getPrefix(constants)+" "+getName(constants); - } + public String toString(ConstantPool constants) { + return getName(constants); //getPrefix(constants)+" "+getName(constants); + } - public String getNameWithKind(ConstantPool constants) { - String kindStr = getKindStr(); - String nameStr = constants.constant_string[name_index]; - return kindStr + (nameStr.equals("") ? "" : " " + nameStr); - } + public String getNameWithKind(ConstantPool constants) { + String kindStr = getKindStr(); + String nameStr = constants.constant_string[name_index]; + return kindStr + (nameStr.equals("") ? "" : " " + nameStr); + } - public String getPrefix(ABC abc) { - String kindStr = "?"; - for (int k = 0; k < nameSpaceKinds.length; k++) { - if (nameSpaceKinds[k] == kind) { - kindStr = namePrefixes[k]; - break; - } - } - return kindStr; - } + public String getPrefix(ABC abc) { + String kindStr = "?"; + for (int k = 0; k < nameSpaceKinds.length; k++) { + if (nameSpaceKinds[k] == kind) { + kindStr = namePrefixes[k]; + break; + } + } + return kindStr; + } - public String getName(ConstantPool constants) { - if (name_index == 0) { - return "-"; - } - return constants.constant_string[name_index]; - } + public String getName(ConstantPool constants) { + if (name_index == 0) { + return "-"; + } + return constants.constant_string[name_index]; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/NamespaceSet.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/NamespaceSet.java index a328d7496..9bbaba32b 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/NamespaceSet.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/NamespaceSet.java @@ -20,16 +20,16 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; public class NamespaceSet { - public int namespaces[]; + public int namespaces[]; - public String toString(ConstantPool constants) { - String s = ""; - for (int i = 0; i < this.namespaces.length; i++) { - if (i > 0) { - s += ", "; - } - s += constants.constant_namespace[namespaces[i]].getNameWithKind(constants); - } - return s; - } + public String toString(ConstantPool constants) { + String s = ""; + for (int i = 0; i < this.namespaces.length; i++) { + if (i > 0) { + s += ", "; + } + s += constants.constant_namespace[namespaces[i]].getNameWithKind(constants); + } + return s; + } } 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 bc3631cb4..064cac5be 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/ScriptInfo.java @@ -29,55 +29,55 @@ import java.util.List; public class ScriptInfo { - public int init_index; //MethodInfo - public Traits traits; + public int init_index; //MethodInfo + public Traits traits; - @Override - public String toString() { - return "method_index=" + init_index + "\r\n" + traits.toString(); - } + @Override + public String toString() { + return "method_index=" + init_index + "\r\n" + traits.toString(); + } - public String toString(ABC abc, List fullyQualifiedNames) { - return "method_index=" + init_index + "\r\n" + traits.toString(abc, fullyQualifiedNames); - } + public String toString(ABC abc, List fullyQualifiedNames) { + return "method_index=" + init_index + "\r\n" + traits.toString(abc, fullyQualifiedNames); + } - public String getPath(ABC abc) { - String packageName = ""; - String scriptName = ""; - int classCount = 0; - for (Trait t : traits.traits) { - Multiname name = t.getName(abc); - Namespace ns = name.getNamespace(abc.constants); - if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) { - packageName = ns.getName(abc.constants); - scriptName = name.getName(abc.constants, new ArrayList()); - if (t instanceof TraitClass) { - classCount++; + public String getPath(ABC abc) { + String packageName = ""; + String scriptName = ""; + int classCount = 0; + for (Trait t : traits.traits) { + Multiname name = t.getName(abc); + Namespace ns = name.getNamespace(abc.constants); + if ((ns.kind == Namespace.KIND_PACKAGE) || (ns.kind == Namespace.KIND_PACKAGE_INTERNAL)) { + packageName = ns.getName(abc.constants); + scriptName = name.getName(abc.constants, new ArrayList()); + if (t instanceof TraitClass) { + classCount++; + } } - } - } - if (classCount > 1) { - scriptName = "[script]"; - } - return packageName + "." + scriptName; - } + } + if (classCount > 1) { + scriptName = "[script]"; + } + return packageName + "." + scriptName; + } - public String convert(List abcTags, ABC abc, boolean pcode, boolean highlighting) { - return traits.convert("", abcTags, abc, false, pcode, true, -1, highlighting, new ArrayList()); - } + public String convert(List abcTags, ABC abc, boolean pcode, boolean highlighting) { + return traits.convert("", abcTags, abc, false, pcode, true, -1, highlighting, new ArrayList()); + } - public void export(ABC abc, List abcList, String directory, boolean pcode) throws IOException { - String path = getPath(abc); - String packageName = path.substring(0, path.lastIndexOf(".")); - String className = path.substring(path.lastIndexOf(".") + 1); - File outDir = new File(directory + File.separatorChar + packageName.replace('.', File.separatorChar)); - if (!outDir.exists()) { - outDir.mkdirs(); - } - String fileName = outDir.toString() + File.separator + className + ".as"; - FileOutputStream fos = new FileOutputStream(fileName); - fos.write(convert(abcList, abc, pcode, false).getBytes()); - fos.close(); + public void export(ABC abc, List abcList, String directory, boolean pcode) throws IOException { + String path = getPath(abc); + String packageName = path.substring(0, path.lastIndexOf(".")); + String className = path.substring(path.lastIndexOf(".") + 1); + File outDir = new File(directory + File.separatorChar + packageName.replace('.', File.separatorChar)); + if (!outDir.exists()) { + outDir.mkdirs(); + } + String fileName = outDir.toString() + File.separator + className + ".as"; + FileOutputStream fos = new FileOutputStream(fileName); + fos.write(convert(abcList, abc, pcode, false).getBytes()); + fos.close(); - } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/types/ValueKind.java b/trunk/src/com/jpexs/decompiler/flash/abc/types/ValueKind.java index 47e34d96b..edb7e2bd0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/types/ValueKind.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/types/ValueKind.java @@ -21,103 +21,103 @@ import com.jpexs.decompiler.flash.helpers.Helper; public class ValueKind { - public static final int CONSTANT_Decimal = 0x02; //decimal - public static final int CONSTANT_Int = 0x03;// integer - public static final int CONSTANT_UInt = 0x04;// uinteger - public static final int CONSTANT_Double = 0x06;// double - public static final int CONSTANT_Utf8 = 0x01;// string - public static final int CONSTANT_True = 0x0B;// - - public static final int CONSTANT_False = 0x0A;// - - public static final int CONSTANT_Null = 0x0C;// - - public static final int CONSTANT_Undefined = 0x00;// - - public static final int CONSTANT_Namespace = 0x08;// namespace - public static final int CONSTANT_PackageNamespace = 0x16;// namespace - public static final int CONSTANT_PackageInternalNs = 0x17;// Namespace - public static final int CONSTANT_ProtectedNamespace = 0x18;// Namespace - public static final int CONSTANT_ExplicitNamespace = 0x19;// Namespace - public static final int CONSTANT_StaticProtectedNs = 0x1A;// Namespace - public static final int CONSTANT_PrivateNs = 0x05;// namespace - private static final int optionalKinds[] = new int[]{0x03, 0x04, 0x06, 0x02, 0x01, 0x0B, 0x0A, 0x0C, 0x00, 0x08, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x05}; - private static final String optionalKindNames[] = new String[]{"Int", "UInt", "Double", "Decimal", "Utf8", "True", "False", "Null", "Undefined", "Namespace", "PackageNamespace", "PackageInternalNs", "ProtectedNamespace", "ExplicitNamespace", "StaticProtectedNs", "PrivateNs"}; - public int value_index; - public int value_kind; + public static final int CONSTANT_Decimal = 0x02; //decimal + public static final int CONSTANT_Int = 0x03;// integer + public static final int CONSTANT_UInt = 0x04;// uinteger + public static final int CONSTANT_Double = 0x06;// double + public static final int CONSTANT_Utf8 = 0x01;// string + public static final int CONSTANT_True = 0x0B;// - + public static final int CONSTANT_False = 0x0A;// - + public static final int CONSTANT_Null = 0x0C;// - + public static final int CONSTANT_Undefined = 0x00;// - + public static final int CONSTANT_Namespace = 0x08;// namespace + public static final int CONSTANT_PackageNamespace = 0x16;// namespace + public static final int CONSTANT_PackageInternalNs = 0x17;// Namespace + public static final int CONSTANT_ProtectedNamespace = 0x18;// Namespace + public static final int CONSTANT_ExplicitNamespace = 0x19;// Namespace + public static final int CONSTANT_StaticProtectedNs = 0x1A;// Namespace + public static final int CONSTANT_PrivateNs = 0x05;// namespace + private static final int optionalKinds[] = new int[]{0x03, 0x04, 0x06, 0x02, 0x01, 0x0B, 0x0A, 0x0C, 0x00, 0x08, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x05}; + private static final String optionalKindNames[] = new String[]{"Int", "UInt", "Double", "Decimal", "Utf8", "True", "False", "Null", "Undefined", "Namespace", "PackageNamespace", "PackageInternalNs", "ProtectedNamespace", "ExplicitNamespace", "StaticProtectedNs", "PrivateNs"}; + public int value_index; + public int value_kind; - public ValueKind(int value_index, int value_kind) { - this.value_index = value_index; - this.value_kind = value_kind; - } + public ValueKind(int value_index, int value_kind) { + this.value_index = value_index; + this.value_kind = value_kind; + } - @Override - public String toString() { - String s = ""; - s += value_index + ":"; - boolean found = false; - for (int i = 0; i < optionalKinds.length; i++) { - if (optionalKinds[i] == value_kind) { - s += optionalKindNames[i]; - found = true; - break; - } - } - if (!found) { - s += "?"; - } - return s; - } + @Override + public String toString() { + String s = ""; + s += value_index + ":"; + boolean found = false; + for (int i = 0; i < optionalKinds.length; i++) { + if (optionalKinds[i] == value_kind) { + s += optionalKindNames[i]; + found = true; + break; + } + } + if (!found) { + s += "?"; + } + return s; + } - public boolean isNamespace() { - switch (value_kind) { - case CONSTANT_Namespace: - case CONSTANT_PackageInternalNs: - case CONSTANT_ProtectedNamespace: - case CONSTANT_ExplicitNamespace: - case CONSTANT_StaticProtectedNs: - case CONSTANT_PrivateNs: - return true; - default: - return false; - } - } + public boolean isNamespace() { + switch (value_kind) { + case CONSTANT_Namespace: + case CONSTANT_PackageInternalNs: + case CONSTANT_ProtectedNamespace: + case CONSTANT_ExplicitNamespace: + case CONSTANT_StaticProtectedNs: + case CONSTANT_PrivateNs: + return true; + default: + return false; + } + } - public String toString(ConstantPool constants) { - String ret = "?"; - switch (value_kind) { - case CONSTANT_Int: - ret = "" + constants.constant_int[value_index]; - break; - case CONSTANT_UInt: - ret = "" + constants.constant_uint[value_index]; - break; - case CONSTANT_Double: - ret = "" + constants.constant_double[value_index]; - break; - case CONSTANT_Decimal: - ret = "" + constants.constant_decimal[value_index]; - break; - case CONSTANT_Utf8: - ret = "\"" + Helper.escapeString(constants.constant_string[value_index]) + "\""; - break; - case CONSTANT_True: - ret = "true"; - break; - case CONSTANT_False: - ret = "false"; - break; - case CONSTANT_Null: - ret = "null"; - break; - case CONSTANT_Undefined: - ret = "undefined"; - break; - case CONSTANT_Namespace: - case CONSTANT_PackageInternalNs: - case CONSTANT_ProtectedNamespace: - case CONSTANT_ExplicitNamespace: - case CONSTANT_StaticProtectedNs: - case CONSTANT_PrivateNs: - ret = "\"" + constants.constant_namespace[value_index].getName(constants) + "\""; - break; - } - return ret; - } + public String toString(ConstantPool constants) { + String ret = "?"; + switch (value_kind) { + case CONSTANT_Int: + ret = "" + constants.constant_int[value_index]; + break; + case CONSTANT_UInt: + ret = "" + constants.constant_uint[value_index]; + break; + case CONSTANT_Double: + ret = "" + constants.constant_double[value_index]; + break; + case CONSTANT_Decimal: + ret = "" + constants.constant_decimal[value_index]; + break; + case CONSTANT_Utf8: + ret = "\"" + Helper.escapeString(constants.constant_string[value_index]) + "\""; + break; + case CONSTANT_True: + ret = "true"; + break; + case CONSTANT_False: + ret = "false"; + break; + case CONSTANT_Null: + ret = "null"; + break; + case CONSTANT_Undefined: + ret = "undefined"; + break; + case CONSTANT_Namespace: + case CONSTANT_PackageInternalNs: + case CONSTANT_ProtectedNamespace: + case CONSTANT_ExplicitNamespace: + case CONSTANT_StaticProtectedNs: + case CONSTANT_PrivateNs: + ret = "\"" + constants.constant_namespace[value_index].getName(constants) + "\""; + break; + } + return ret; + } } 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 7cadb1df5..ba7344d0d 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 @@ -26,116 +26,116 @@ import java.util.List; public abstract class Trait implements Serializable { - public boolean debugMode = false; - public int name_index; - public int kindType; - public int kindFlags; - public int metadata[] = new int[0]; - public long fileOffset; - public byte bytes[]; - public static final int ATTR_Final = 0x1; - public static final int ATTR_Override = 0x2; - public static final int ATTR_Metadata = 0x4; - public static final int TRAIT_SLOT = 0; - public static final int TRAIT_METHOD = 1; - public static final int TRAIT_GETTER = 2; - public static final int TRAIT_SETTER = 3; - public static final int TRAIT_CLASS = 4; - public static final int TRAIT_FUNCTION = 5; - public static final int TRAIT_CONST = 6; + public boolean debugMode = false; + public int name_index; + public int kindType; + public int kindFlags; + public int metadata[] = new int[0]; + public long fileOffset; + public byte bytes[]; + public static final int ATTR_Final = 0x1; + public static final int ATTR_Override = 0x2; + public static final int ATTR_Metadata = 0x4; + public static final int TRAIT_SLOT = 0; + public static final int TRAIT_METHOD = 1; + public static final int TRAIT_GETTER = 2; + public static final int TRAIT_SETTER = 3; + public static final int TRAIT_CLASS = 4; + public static final int TRAIT_FUNCTION = 5; + public static final int TRAIT_CONST = 6; - public String getModifiers(List abcTags, ABC abc, boolean isStatic) { - String ret = ""; - if ((kindFlags & ATTR_Override) > 0) { - ret += "override"; - } - Multiname m = getName(abc); - if (m != null) { - String nsname = ""; - //if (abc.constants.constant_namespace[m.namespace_index].kind == Namespace.KIND_NAMESPACE) { - { - for (DoABCTag abcTag : abcTags) { - nsname = abcTag.abc.nsValueToName(abc.constants.constant_namespace[m.namespace_index].getName(abc.constants)); - if (nsname.equals("-")) { - break; - } - if (nsname.contains(".")) { - nsname = nsname.substring(nsname.lastIndexOf(".") + 1); - } - if (!nsname.equals("")) { - break; - } + public String getModifiers(List abcTags, ABC abc, boolean isStatic) { + String ret = ""; + if ((kindFlags & ATTR_Override) > 0) { + ret += "override"; + } + Multiname m = getName(abc); + if (m != null) { + String nsname = ""; + //if (abc.constants.constant_namespace[m.namespace_index].kind == Namespace.KIND_NAMESPACE) { + { + for (DoABCTag abcTag : abcTags) { + nsname = abcTag.abc.nsValueToName(abc.constants.constant_namespace[m.namespace_index].getName(abc.constants)); + if (nsname.equals("-")) { + break; + } + if (nsname.contains(".")) { + nsname = nsname.substring(nsname.lastIndexOf(".") + 1); + } + if (!nsname.equals("")) { + break; + } + } } - } - Namespace ns = m.getNamespace(abc.constants); + Namespace ns = m.getNamespace(abc.constants); - if (nsname.contains(":")) { - nsname = ""; - } + if (nsname.contains(":")) { + nsname = ""; + } - if ((!nsname.equals("")) && (!nsname.equals("-"))) { - } else { + if ((!nsname.equals("")) && (!nsname.equals("-"))) { + } else { + if (ns != null) { + if (ns.kind == Namespace.KIND_NAMESPACE) { + nsname = ns.getName(abc.constants); + } + } + } + + if ((!nsname.contains(":")) && (!nsname.equals(""))) { + ret += " " + nsname; + } if (ns != null) { - if (ns.kind == Namespace.KIND_NAMESPACE) { - nsname = ns.getName(abc.constants); - } + ret += " " + ns.getPrefix(abc); } - } + } + if (isStatic) { + ret += " static"; + } + if ((kindFlags & ATTR_Final) > 0) { + if (!isStatic) { + ret += " final"; + } + } + return ret.trim(); + } - if ((!nsname.contains(":")) && (!nsname.equals(""))) { - ret += " " + nsname; - } - if (ns != null) { - ret += " " + ns.getPrefix(abc); - } - } - if (isStatic) { - ret += " static"; - } - if ((kindFlags & ATTR_Final) > 0) { - if (!isStatic) { - ret += " final"; - } - } - return ret.trim(); - } + @Override + public String toString() { + return "name_index=" + name_index + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata); + } - @Override - public String toString() { - return "name_index=" + name_index + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata); - } + public String toString(ABC abc, List fullyQualifiedNames) { + return abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata); + } - public String toString(ABC abc, List fullyQualifiedNames) { - return abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata); - } + public String convert(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { + return abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata); + } - public String convert(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { - return abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " kind=" + kindType + " metadata=" + Helper.intArrToString(metadata); - } + public String convertPackaged(String path, List abcTags, ABC abc, boolean isStatic, boolean pcod, int classIndex, boolean highlight, List fullyQualifiedNames) { + return makePackageFromIndex(abc, name_index, convert(path, abcTags, abc, isStatic, pcod, classIndex, highlight, fullyQualifiedNames)); + } - public String convertPackaged(String path, List abcTags, ABC abc, boolean isStatic, boolean pcod, int classIndex, boolean highlight, List fullyQualifiedNames) { - return makePackageFromIndex(abc, name_index, convert(path, abcTags, abc, isStatic, pcod, classIndex, highlight, fullyQualifiedNames)); - } + public String convertHeader(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { + return convert(path, abcTags, abc, isStatic, pcode, classIndex, highlight, fullyQualifiedNames).trim(); + } - public String convertHeader(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { - return convert(path, abcTags, abc, isStatic, pcode, classIndex, highlight, fullyQualifiedNames).trim(); - } + protected String makePackageFromIndex(ABC abc, int name_index, String value) { + 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); + return "package " + nsname + "\r\n{\r\n" + value + "\r\n}"; + } + return value; + } - protected String makePackageFromIndex(ABC abc, int name_index, String value) { - 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); - return "package " + nsname + "\r\n{\r\n" + value + "\r\n}"; - } - return value; - } - - public Multiname getName(ABC abc) { - if (name_index == 0) { - return null; - } else { - return abc.constants.constant_multiname[name_index]; - } - } + public Multiname getName(ABC abc) { + if (name_index == 0) { + return null; + } else { + return abc.constants.constant_multiname[name_index]; + } + } } 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 c675f4794..c9a8086aa 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 @@ -37,415 +37,429 @@ import com.jpexs.decompiler.flash.helpers.Highlighting; import com.jpexs.decompiler.flash.tags.DoABCTag; import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Stack; +import java.util.logging.Level; +import java.util.logging.Logger; public class TraitClass extends Trait { - public int slot_id; - public int class_info; - private static final String[] builtInClasses = {"ArgumentError", "arguments", "Array", "Boolean", "Class", "Date", "DefinitionError", "Error", "EvalError", "Function", "int", "JSON", "Math", "Namespace", "Number", "Object", "QName", "RangeError", "ReferenceError", "RegExp", "SecurityError", "String", "SyntaxError", "TypeError", "uint", "URIError", "VerifyError", "XML", "XMLList"}; + public int slot_id; + public int class_info; + private static final String[] builtInClasses = {"ArgumentError", "arguments", "Array", "Boolean", "Class", "Date", "DefinitionError", "Error", "EvalError", "Function", "int", "JSON", "Math", "Namespace", "Number", "Object", "QName", "RangeError", "ReferenceError", "RegExp", "SecurityError", "String", "SyntaxError", "TypeError", "uint", "URIError", "VerifyError", "XML", "XMLList"}; - private static boolean isBuiltInClass(String name) { - for (String g : builtInClasses) { - if (g.equals(name)) { - return true; - } - } - return false; - } + private static boolean isBuiltInClass(String name) { + for (String g : builtInClasses) { + if (g.equals(name)) { + return true; + } + } + return false; + } - @Override - public String toString(ABC abc, List fullyQualifiedNames) { - return "Class " + abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " slot=" + slot_id + " class_info=" + class_info + " metadata=" + Helper.intArrToString(metadata); - } + @Override + public String toString(ABC abc, List fullyQualifiedNames) { + return "Class " + abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " slot=" + slot_id + " class_info=" + class_info + " metadata=" + Helper.intArrToString(metadata); + } - private boolean parseUsagesFromNS(List abcTags, ABC abc, List imports, List uses, int namespace_index, String ignorePackage, String name) { - Namespace ns = abc.constants.constant_namespace[namespace_index]; - if (name.equals("")) { - name = "*"; - } - String newimport = ns.getName(abc.constants); - /*if (ns.kind == Namespace.KIND_NAMESPACE)*/ { - String oldimport = newimport; - newimport = null; - for (DoABCTag abcTag : abcTags) { - String newname = abcTag.abc.nsValueToName(oldimport); - if (newname.equals("-")) { - return true; + private boolean parseUsagesFromNS(List abcTags, ABC abc, List imports, List uses, int namespace_index, String ignorePackage, String name) { + Namespace ns = abc.constants.constant_namespace[namespace_index]; + if (name.equals("")) { + name = "*"; + } + String newimport = ns.getName(abc.constants); + /*if (ns.kind == Namespace.KIND_NAMESPACE)*/ { + String oldimport = newimport; + newimport = null; + for (DoABCTag abcTag : abcTags) { + String newname = abcTag.abc.nsValueToName(oldimport); + if (newname.equals("-")) { + return true; + } + if (!newname.equals("")) { + newimport = newname; + break; + } } - if (!newname.equals("")) { - newimport = newname; - break; + if (newimport != null) { + if (!imports.contains(newimport)) { + if (newimport.contains(":")) { + return true; + } + String pkg = ""; + if (newimport.contains(".")) { + pkg = newimport.substring(0, newimport.lastIndexOf(".")); + } + String usname = newimport; + if (usname.contains(".")) { + usname = usname.substring(usname.lastIndexOf(".") + 1); + } + if (!pkg.equals(ignorePackage)) { + imports.add(newimport); + } + if (!uses.contains(usname)) { + uses.add(usname); + } + } + return true; } - } - if (newimport != null) { - if (!imports.contains(newimport)) { - if (newimport.contains(":")) { - return true; - } - String pkg = ""; - if (newimport.contains(".")) { - pkg = newimport.substring(0, newimport.lastIndexOf(".")); - } - String usname = newimport; - if (usname.contains(".")) { - usname = usname.substring(usname.lastIndexOf(".") + 1); - } - if (!pkg.equals(ignorePackage)) { - imports.add(newimport); - } - if (!uses.contains(usname)) { - uses.add(usname); - } - } - return true; - } - } - return false; - } + } + return false; + } - private void parseImportsUsagesFromNS(List abcTags, ABC abc, List imports, List uses, int namespace_index, String ignorePackage, String name) { - Namespace ns = abc.constants.constant_namespace[namespace_index]; - if (name.equals("")) { - name = "*"; - } - String newimport = ns.getName(abc.constants); - if (parseUsagesFromNS(abcTags, abc, imports, uses, namespace_index, ignorePackage, name)) { - return; - } else if ((ns.kind != Namespace.KIND_PACKAGE) && (ns.kind != Namespace.KIND_PACKAGE_INTERNAL)) { - return; - } - if (newimport.equals("-")) { - newimport = ""; - } - //if (!newimport.equals("")) { - newimport += "." + name; - if (newimport.contains(":")) { - return; - } - if (!imports.contains(newimport)) { - String pkg = newimport.substring(0, newimport.lastIndexOf(".")); - if (!pkg.equals(ignorePackage)) { - imports.add(newimport); - } - } - //} - } - - private void parseUsagesFromMultiname(List abcTags, ABC abc, List imports, List uses, Multiname m, String ignorePackage, List fullyQualifiedNames) { - if (m != null) { - if (m.kind == Multiname.TYPENAME) { - if (m.qname_index != 0) { - parseUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[m.qname_index], ignorePackage, fullyQualifiedNames); - } - for (Integer i : m.params) { - if (i != 0) { - parseUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[i], ignorePackage, fullyQualifiedNames); - } - } + private void parseImportsUsagesFromNS(List abcTags, ABC abc, List imports, List uses, int namespace_index, String ignorePackage, String name) { + Namespace ns = abc.constants.constant_namespace[namespace_index]; + if (name.equals("")) { + name = "*"; + } + String newimport = ns.getName(abc.constants); + if (parseUsagesFromNS(abcTags, abc, imports, uses, namespace_index, ignorePackage, name)) { return; - } - Namespace ns = m.getNamespace(abc.constants); - String name = m.getName(abc.constants, fullyQualifiedNames); - NamespaceSet nss = m.getNamespaceSet(abc.constants); - if (ns != null) { - parseUsagesFromNS(abcTags, abc, imports, uses, m.namespace_index, ignorePackage, name); - } - if (nss != null) { - if (nss.namespaces.length == 1) { - parseUsagesFromNS(abcTags, abc, imports, uses, nss.namespaces[0], ignorePackage, name); - } - } - } - } - - private void parseImportsUsagesFromMultiname(List abcTags, ABC abc, List imports, List uses, Multiname m, String ignorePackage, List fullyQualifiedNames) { - if (m != null) { - if (m.kind == Multiname.TYPENAME) { - if (m.qname_index != 0) { - parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[m.qname_index], ignorePackage, fullyQualifiedNames); - } - for (Integer i : m.params) { - if (i != 0) { - parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[i], ignorePackage, fullyQualifiedNames); - } - } + } else if ((ns.kind != Namespace.KIND_PACKAGE) && (ns.kind != Namespace.KIND_PACKAGE_INTERNAL)) { return; - } - Namespace ns = m.getNamespace(abc.constants); - String name = m.getName(abc.constants, fullyQualifiedNames); - NamespaceSet nss = m.getNamespaceSet(abc.constants); - if (ns != null) { - parseImportsUsagesFromNS(abcTags, abc, imports, uses, m.namespace_index, ignorePackage, name); - } - if (nss != null) { - if (nss.namespaces.length == 1) { - parseImportsUsagesFromNS(abcTags, abc, imports, uses, nss.namespaces[0], ignorePackage, name); + } + if (newimport.equals("-")) { + newimport = ""; + } + //if (!newimport.equals("")) { + newimport += "." + name; + if (newimport.contains(":")) { + return; + } + if (!imports.contains(newimport)) { + String pkg = newimport.substring(0, newimport.lastIndexOf(".")); + if (!pkg.equals(ignorePackage)) { + imports.add(newimport); } - } - } - } + } + //} + } - private void parseImportsUsagesFromMethodInfo(List abcTags, ABC abc, int method_index, List imports, List uses, String ignorePackage, List fullyQualifiedNames, List visitedMethods) { - if (method_index > abc.method_info.length) { - return; - } - visitedMethods.add(method_index); - if (abc.method_info[method_index].ret_type != 0) { - parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[abc.method_info[method_index].ret_type], ignorePackage, fullyQualifiedNames); - } - for (int t : abc.method_info[method_index].param_types) { - if (t != 0) { - parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[t], ignorePackage, fullyQualifiedNames); - } - } - MethodBody body = abc.findBody(method_index); - if (body != null) { - parseImportsUsagesFromTraits(abcTags, abc, body.traits, imports, uses, ignorePackage, fullyQualifiedNames); - for (ABCException ex : body.exceptions) { - parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[ex.type_index], ignorePackage, fullyQualifiedNames); - } - for (AVM2Instruction ins : body.code.code) { - if (ins.definition instanceof NewFunctionIns) { - if (ins.operands[0] != method_index) { - if (!visitedMethods.contains(ins.operands[0])) { - parseImportsUsagesFromMethodInfo(abcTags, abc, ins.operands[0], imports, uses, ignorePackage, fullyQualifiedNames, visitedMethods); - } - } + private void parseUsagesFromMultiname(List abcTags, ABC abc, List imports, List uses, Multiname m, String ignorePackage, List fullyQualifiedNames) { + if (m != null) { + if (m.kind == Multiname.TYPENAME) { + if (m.qname_index != 0) { + parseUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[m.qname_index], ignorePackage, fullyQualifiedNames); + } + for (Integer i : m.params) { + if (i != 0) { + parseUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[i], ignorePackage, fullyQualifiedNames); + } + } + return; } - if ((ins.definition instanceof FindPropertyStrictIns) - || (ins.definition instanceof FindPropertyIns) - || (ins.definition instanceof GetLexIns) - || (ins.definition instanceof CoerceIns) - || (ins.definition instanceof AsTypeIns)) { - int m = ins.operands[0]; - if (m != 0) { - parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[m], ignorePackage, fullyQualifiedNames); - } - } else { - for (int k = 0; k < ins.definition.operands.length; k++) { - - if (ins.definition.operands[k] == AVM2Code.DAT_MULTINAME_INDEX) { - int multinameIndex = ins.operands[k]; - parseUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[multinameIndex], ignorePackage, fullyQualifiedNames); - } - } + Namespace ns = m.getNamespace(abc.constants); + String name = m.getName(abc.constants, fullyQualifiedNames); + NamespaceSet nss = m.getNamespaceSet(abc.constants); + if (ns != null) { + parseUsagesFromNS(abcTags, abc, imports, uses, m.namespace_index, ignorePackage, name); } - } - } - } + if (nss != null) { + if (nss.namespaces.length == 1) { + parseUsagesFromNS(abcTags, abc, imports, uses, nss.namespaces[0], ignorePackage, name); + } + } + } + } - private void parseImportsUsagesFromTraits(List abcTags, ABC abc, Traits ts, List imports, List uses, String ignorePackage, List fullyQualifiedNames) { - for (Trait t : ts.traits) { - parseImportsUsagesFromTrait(abcTags, abc, t, imports, uses, ignorePackage, fullyQualifiedNames); - } - } + private void parseImportsUsagesFromMultiname(List abcTags, ABC abc, List imports, List uses, Multiname m, String ignorePackage, List fullyQualifiedNames) { + if (m != null) { + if (m.kind == Multiname.TYPENAME) { + if (m.qname_index != 0) { + parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[m.qname_index], ignorePackage, fullyQualifiedNames); + } + for (Integer i : m.params) { + if (i != 0) { + parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[i], ignorePackage, fullyQualifiedNames); + } + } + return; + } + Namespace ns = m.getNamespace(abc.constants); + String name = m.getName(abc.constants, fullyQualifiedNames); + NamespaceSet nss = m.getNamespaceSet(abc.constants); + if (ns != null) { + parseImportsUsagesFromNS(abcTags, abc, imports, uses, m.namespace_index, ignorePackage, name); + } + if (nss != null) { + if (nss.namespaces.length == 1) { + parseImportsUsagesFromNS(abcTags, abc, imports, uses, nss.namespaces[0], ignorePackage, name); + } + } + } + } - private void parseImportsUsagesFromTrait(List abcTags, ABC abc, Trait t, List imports, List uses, String ignorePackage, List fullyQualifiedNames) { - if (t instanceof TraitMethodGetterSetter) { - TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t; - parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[tm.name_index], ignorePackage, fullyQualifiedNames); - if (tm.method_info != 0) { - parseImportsUsagesFromMethodInfo(abcTags, abc, tm.method_info, imports, uses, ignorePackage, fullyQualifiedNames, new ArrayList()); - } - } - parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, t.getName(abc), ignorePackage, fullyQualifiedNames); - if (t instanceof TraitSlotConst) { - TraitSlotConst ts = (TraitSlotConst) t; - parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[ts.name_index], ignorePackage, fullyQualifiedNames); - parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[ts.type_index], ignorePackage, fullyQualifiedNames); - } - } + private void parseImportsUsagesFromMethodInfo(List abcTags, ABC abc, int method_index, List imports, List uses, String ignorePackage, List fullyQualifiedNames, List visitedMethods) { + if (method_index > abc.method_info.length) { + return; + } + visitedMethods.add(method_index); + if (abc.method_info[method_index].ret_type != 0) { + parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[abc.method_info[method_index].ret_type], ignorePackage, fullyQualifiedNames); + } + for (int t : abc.method_info[method_index].param_types) { + if (t != 0) { + parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[t], ignorePackage, fullyQualifiedNames); + } + } + MethodBody body = abc.findBody(method_index); + if (body != null) { + parseImportsUsagesFromTraits(abcTags, abc, body.traits, imports, uses, ignorePackage, fullyQualifiedNames); + for (ABCException ex : body.exceptions) { + parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[ex.type_index], ignorePackage, fullyQualifiedNames); + } + for (AVM2Instruction ins : body.code.code) { + if (ins.definition instanceof NewFunctionIns) { + if (ins.operands[0] != method_index) { + if (!visitedMethods.contains(ins.operands[0])) { + parseImportsUsagesFromMethodInfo(abcTags, abc, ins.operands[0], imports, uses, ignorePackage, fullyQualifiedNames, visitedMethods); + } + } + } + if ((ins.definition instanceof FindPropertyStrictIns) + || (ins.definition instanceof FindPropertyIns) + || (ins.definition instanceof GetLexIns) + || (ins.definition instanceof CoerceIns) + || (ins.definition instanceof AsTypeIns)) { + int m = ins.operands[0]; + if (m != 0) { + parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[m], ignorePackage, fullyQualifiedNames); + } + } else { + for (int k = 0; k < ins.definition.operands.length; k++) { - private List getImportsUsages(List abcTags, ABC abc, List imports, List uses, List fullyQualifiedNames) { - //constructor + if (ins.definition.operands[k] == AVM2Code.DAT_MULTINAME_INDEX) { + int multinameIndex = ins.operands[k]; + parseUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[multinameIndex], ignorePackage, fullyQualifiedNames); + } + } + } + } + } + } + + private void parseImportsUsagesFromTraits(List abcTags, ABC abc, Traits ts, List imports, List uses, String ignorePackage, List fullyQualifiedNames) { + for (Trait t : ts.traits) { + parseImportsUsagesFromTrait(abcTags, abc, t, imports, uses, ignorePackage, fullyQualifiedNames); + } + } + + private void parseImportsUsagesFromTrait(List abcTags, ABC abc, Trait t, List imports, List uses, String ignorePackage, List fullyQualifiedNames) { + if (t instanceof TraitMethodGetterSetter) { + TraitMethodGetterSetter tm = (TraitMethodGetterSetter) t; + parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[tm.name_index], ignorePackage, fullyQualifiedNames); + if (tm.method_info != 0) { + parseImportsUsagesFromMethodInfo(abcTags, abc, tm.method_info, imports, uses, ignorePackage, fullyQualifiedNames, new ArrayList()); + } + } + parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, t.getName(abc), ignorePackage, fullyQualifiedNames); + if (t instanceof TraitSlotConst) { + TraitSlotConst ts = (TraitSlotConst) t; + parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[ts.name_index], ignorePackage, fullyQualifiedNames); + parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[ts.type_index], ignorePackage, fullyQualifiedNames); + } + } + + private List getImportsUsages(List abcTags, ABC abc, List imports, List uses, List fullyQualifiedNames) { + //constructor - String packageName = abc.instance_info[class_info].getName(abc.constants).getNamespace(abc.constants).getName(abc.constants); + String packageName = abc.instance_info[class_info].getName(abc.constants).getNamespace(abc.constants).getName(abc.constants); - parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[abc.instance_info[class_info].name_index], packageName, fullyQualifiedNames); + parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[abc.instance_info[class_info].name_index], packageName, fullyQualifiedNames); - if (abc.instance_info[class_info].super_index > 0) { - parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[abc.instance_info[class_info].super_index], packageName, fullyQualifiedNames); - } - for (int i : abc.instance_info[class_info].interfaces) { - parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[i], packageName, fullyQualifiedNames); - } + if (abc.instance_info[class_info].super_index > 0) { + parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[abc.instance_info[class_info].super_index], packageName, fullyQualifiedNames); + } + for (int i : abc.instance_info[class_info].interfaces) { + parseImportsUsagesFromMultiname(abcTags, abc, imports, uses, abc.constants.constant_multiname[i], packageName, fullyQualifiedNames); + } - //static - parseImportsUsagesFromTraits(abcTags, abc, abc.class_info[class_info].static_traits, imports, uses, packageName, fullyQualifiedNames); + //static + parseImportsUsagesFromTraits(abcTags, abc, abc.class_info[class_info].static_traits, imports, uses, packageName, fullyQualifiedNames); - //static initializer - parseImportsUsagesFromMethodInfo(abcTags, abc, abc.class_info[class_info].cinit_index, imports, uses, packageName, fullyQualifiedNames, new ArrayList()); + //static initializer + parseImportsUsagesFromMethodInfo(abcTags, abc, abc.class_info[class_info].cinit_index, imports, uses, packageName, fullyQualifiedNames, new ArrayList()); - //instance - parseImportsUsagesFromTraits(abcTags, abc, abc.instance_info[class_info].instance_traits, imports, uses, packageName, fullyQualifiedNames); + //instance + parseImportsUsagesFromTraits(abcTags, abc, abc.instance_info[class_info].instance_traits, imports, uses, packageName, fullyQualifiedNames); - //instance initializer - parseImportsUsagesFromMethodInfo(abcTags, abc, abc.instance_info[class_info].iinit_index, imports, uses, packageName, fullyQualifiedNames, new ArrayList()); - return imports; - } + //instance initializer + parseImportsUsagesFromMethodInfo(abcTags, abc, abc.instance_info[class_info].iinit_index, imports, uses, packageName, fullyQualifiedNames, new ArrayList()); + return imports; + } - @Override - public String convertHeader(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { - String classHeader = abc.instance_info[class_info].getClassHeaderStr(abc, fullyQualifiedNames); - return classHeader; - } + @Override + public String convertHeader(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { + String classHeader = abc.instance_info[class_info].getClassHeaderStr(abc, fullyQualifiedNames); + return classHeader; + } - @Override - public String convert(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { - if (!highlight) { - Highlighting.doHighlight = false; - } - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream out = new PrintStream(baos); + @Override + public String convert(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { + if (!highlight) { + Highlighting.doHighlight = false; + } + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintStream out = null; + try { + out = new PrintStream(baos, true, "UTF-8"); + } catch (UnsupportedEncodingException ex) { + Logger.getLogger(TraitClass.class.getName()).log(Level.SEVERE, null, ex); + return ""; + } - String packageName = abc.instance_info[class_info].getName(abc.constants).getNamespace(abc.constants).getName(abc.constants); + String packageName = abc.instance_info[class_info].getName(abc.constants).getNamespace(abc.constants).getName(abc.constants); - List namesInThisPackage = new ArrayList(); - for (DoABCTag tag : abcTags) { - for (ScriptInfo si : tag.abc.script_info) { - String spath = si.getPath(tag.abc); + List namesInThisPackage = new ArrayList(); + for (DoABCTag tag : abcTags) { + for (ScriptInfo si : tag.abc.script_info) { + String spath = si.getPath(tag.abc); + String pkg = ""; + String name = spath; + if (spath.contains(".")) { + pkg = spath.substring(0, spath.lastIndexOf(".")); + name = spath.substring(spath.lastIndexOf(".") + 1); + } + if (pkg.equals(packageName)) { + namesInThisPackage.add(name); + } + } + } + //imports + List imports = new ArrayList(); + List uses = new ArrayList(); + getImportsUsages(abcTags, abc, imports, uses, new ArrayList()); + + fullyQualifiedNames = new ArrayList(); + + List importnames = new ArrayList(); + importnames.addAll(namesInThisPackage); + for (String ipath : imports) { + String name = ipath; String pkg = ""; - String name = spath; - if (spath.contains(".")) { - pkg = spath.substring(0, spath.lastIndexOf(".")); - name = spath.substring(spath.lastIndexOf(".") + 1); + if (name.contains(".")) { + pkg = name.substring(0, name.lastIndexOf(".")); + name = name.substring(name.lastIndexOf(".") + 1); } - if (pkg.equals(packageName)) { - namesInThisPackage.add(name); + if (importnames.contains(name) || ((!pkg.equals("")) && isBuiltInClass(name))) { + fullyQualifiedNames.add(name); + } else { + importnames.add(name); } - } - } - //imports - List imports = new ArrayList(); - List uses = new ArrayList(); - getImportsUsages(abcTags, abc, imports, uses, new ArrayList()); - - fullyQualifiedNames = new ArrayList(); - - List importnames = new ArrayList(); - importnames.addAll(namesInThisPackage); - for (String ipath : imports) { - String name = ipath; + } + /*List imports2 = new ArrayList(); + for (String path : imports) { + String name = path; String pkg = ""; if (name.contains(".")) { - pkg = name.substring(0, name.lastIndexOf(".")); - name = name.substring(name.lastIndexOf(".") + 1); + pkg = name.substring(0, name.lastIndexOf(".")); + name = name.substring(name.lastIndexOf(".") + 1); } - if (importnames.contains(name) || ((!pkg.equals("")) && isBuiltInClass(name))) { - fullyQualifiedNames.add(name); - } else { - importnames.add(name); + + if ((!packageName.equals(pkg)) && (!fullyQualifiedNames.contains(name))) { + imports2.add(path); } - } - /*List imports2 = new ArrayList(); - for (String path : imports) { - String name = path; - String pkg = ""; - if (name.contains(".")) { - pkg = name.substring(0, name.lastIndexOf(".")); - name = name.substring(name.lastIndexOf(".") + 1); - } - - if ((!packageName.equals(pkg)) && (!fullyQualifiedNames.contains(name))) { - imports2.add(path); - } - } - imports = imports2;*/ - - for (String imp : imports) { - if (!imp.startsWith(".")) { - out.println(ABC.IDENT_STRING + "import " + imp + ";"); } - } - out.println(); - for (String us : uses) { - out.println(ABC.IDENT_STRING + "use namespace " + us + ";"); - } - out.println(); + imports = imports2;*/ - //class header - String classHeader = abc.instance_info[class_info].getClassHeaderStr(abc, fullyQualifiedNames); - if (classHeader.startsWith("private ")) { - classHeader = classHeader.substring("private ".length()); - } - out.println(ABC.IDENT_STRING + classHeader); - out.println(ABC.IDENT_STRING + "{"); - - String toPrint; - List outTraits = new LinkedList(); - - - int bodyIndex; - String bodyStr = ""; - bodyIndex = abc.findBodyIndex(abc.class_info[class_info].cinit_index); - if (bodyIndex != -1) { - bodyStr = abc.bodies[bodyIndex].toString(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", pcode, true, class_info, abc, abc.constants, abc.method_info, new Stack(), true, highlight, fullyQualifiedNames, abc.class_info[class_info].static_traits); - } - if (Highlighting.stripHilights(bodyStr).equals("")) { - toPrint = ABC.addTabs(bodyStr, 3); - } else { - toPrint = ABC.IDENT_STRING + ABC.IDENT_STRING + "{\r\n" + ABC.addTabs(bodyStr, 3) + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}"; - } - if (highlight) { - toPrint = Highlighting.hilighTrait(toPrint, abc.class_info[class_info].static_traits.traits.length + abc.instance_info[class_info].instance_traits.traits.length + 1); - } - outTraits.add(toPrint); - //} - - //constructor - if (!abc.instance_info[class_info].isInterface()) { - String modifier = ""; - Multiname m = abc.constants.constant_multiname[abc.instance_info[class_info].name_index]; - if (m != null) { - Namespace ns = m.getNamespace(abc.constants); - if (ns != null) { - modifier = ns.getPrefix(abc) + " "; - if (modifier.equals(" ")) { - modifier = ""; - } - if (modifier.startsWith("private")) { //cannot have private constuctor - modifier = ""; - } + for (String imp : imports) { + if (!imp.startsWith(".")) { + out.println(ABC.IDENT_STRING + "import " + imp + ";"); } - } - String constructorParams; + } + out.println(); + for (String us : uses) { + out.println(ABC.IDENT_STRING + "use namespace " + us + ";"); + } + out.println(); - bodyStr = ""; - bodyIndex = abc.findBodyIndex(abc.instance_info[class_info].iinit_index); - if (bodyIndex != -1) { - bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", pcode, false, class_info, abc, abc.constants, abc.method_info, new Stack(), false, highlight, fullyQualifiedNames, abc.instance_info[class_info].instance_traits), 3); - constructorParams = abc.method_info[abc.instance_info[class_info].iinit_index].getParamStr(abc.constants, abc.bodies[bodyIndex], abc, fullyQualifiedNames); - } else { - constructorParams = abc.method_info[abc.instance_info[class_info].iinit_index].getParamStr(abc.constants, null, abc, fullyQualifiedNames); - } - toPrint = ABC.IDENT_STRING + ABC.IDENT_STRING + modifier + "function " + abc.constants.constant_multiname[abc.instance_info[class_info].name_index].getName(abc.constants, new ArrayList()/*do not want full names here*/) + "(" + constructorParams + ") {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}"; - if (highlight) { - toPrint = Highlighting.hilighTrait(toPrint, abc.class_info[class_info].static_traits.traits.length + abc.instance_info[class_info].instance_traits.traits.length); - } - outTraits.add(toPrint); - } - //} + //class header + String classHeader = abc.instance_info[class_info].getClassHeaderStr(abc, fullyQualifiedNames); + if (classHeader.startsWith("private ")) { + classHeader = classHeader.substring("private ".length()); + } + out.println(ABC.IDENT_STRING + classHeader); + out.println(ABC.IDENT_STRING + "{"); - //static variables,constants & methods - outTraits.add(abc.class_info[class_info].static_traits.convert(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, true, pcode, false, class_info, highlight, fullyQualifiedNames)); + String toPrint; + List outTraits = new LinkedList(); - outTraits.add(abc.instance_info[class_info].instance_traits.convert(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, false, pcode, false, class_info, highlight, fullyQualifiedNames)); - out.println(Helper.joinStrings(outTraits, "\r\n\r\n")); - out.println(ABC.IDENT_STRING + "}");//class - out.flush(); - Highlighting.doHighlight = true; - return baos.toString(); - } + int bodyIndex; + String bodyStr = ""; + bodyIndex = abc.findBodyIndex(abc.class_info[class_info].cinit_index); + if (bodyIndex != -1) { + bodyStr = abc.bodies[bodyIndex].toString(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".staticinitializer", pcode, true, class_info, abc, abc.constants, abc.method_info, new Stack(), true, highlight, fullyQualifiedNames, abc.class_info[class_info].static_traits); + } + if (Highlighting.stripHilights(bodyStr).equals("")) { + toPrint = ABC.addTabs(bodyStr, 3); + } else { + toPrint = ABC.IDENT_STRING + ABC.IDENT_STRING + "{\r\n" + ABC.addTabs(bodyStr, 3) + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}"; + } + if (highlight) { + toPrint = Highlighting.hilighTrait(toPrint, abc.class_info[class_info].static_traits.traits.length + abc.instance_info[class_info].instance_traits.traits.length + 1); + } + outTraits.add(toPrint); + //} - @Override - public Multiname getName(ABC abc) { - return abc.constants.constant_multiname[abc.instance_info[class_info].name_index]; - } + //constructor + if (!abc.instance_info[class_info].isInterface()) { + String modifier = ""; + Multiname m = abc.constants.constant_multiname[abc.instance_info[class_info].name_index]; + if (m != null) { + Namespace ns = m.getNamespace(abc.constants); + if (ns != null) { + modifier = ns.getPrefix(abc) + " "; + if (modifier.equals(" ")) { + modifier = ""; + } + if (modifier.startsWith("private")) { //cannot have private constuctor + modifier = ""; + } + } + } + String constructorParams; + + bodyStr = ""; + bodyIndex = abc.findBodyIndex(abc.instance_info[class_info].iinit_index); + if (bodyIndex != -1) { + bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames) + ".initializer", pcode, false, class_info, abc, abc.constants, abc.method_info, new Stack(), false, highlight, fullyQualifiedNames, abc.instance_info[class_info].instance_traits), 3); + constructorParams = abc.method_info[abc.instance_info[class_info].iinit_index].getParamStr(abc.constants, abc.bodies[bodyIndex], abc, fullyQualifiedNames); + } else { + constructorParams = abc.method_info[abc.instance_info[class_info].iinit_index].getParamStr(abc.constants, null, abc, fullyQualifiedNames); + } + toPrint = ABC.IDENT_STRING + ABC.IDENT_STRING + modifier + "function " + abc.constants.constant_multiname[abc.instance_info[class_info].name_index].getName(abc.constants, new ArrayList()/*do not want full names here*/) + "(" + constructorParams + ") {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}"; + if (highlight) { + toPrint = Highlighting.hilighTrait(toPrint, abc.class_info[class_info].static_traits.traits.length + abc.instance_info[class_info].instance_traits.traits.length); + } + outTraits.add(toPrint); + } + //} + + //static variables,constants & methods + outTraits.add(abc.class_info[class_info].static_traits.convert(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, true, pcode, false, class_info, highlight, fullyQualifiedNames)); + + outTraits.add(abc.instance_info[class_info].instance_traits.convert(packageName + "." + abc.instance_info[class_info].getName(abc.constants).getName(abc.constants, fullyQualifiedNames), abcTags, abc, false, pcode, false, class_info, highlight, fullyQualifiedNames)); + + out.println(Helper.joinStrings(outTraits, "\r\n\r\n")); + out.println(ABC.IDENT_STRING + "}");//class + out.flush(); + Highlighting.doHighlight = true; + try { + return new String(baos.toByteArray(), "UTF-8"); + } catch (UnsupportedEncodingException ex) { + Logger.getLogger(TraitClass.class.getName()).log(Level.SEVERE, null, ex); + return ""; + } + } + + @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 2f1db53d6..ac0d315e3 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 @@ -26,33 +26,33 @@ import java.util.Stack; public class TraitFunction extends Trait { - public int slot_index; - public int method_info; + public int slot_index; + public int method_info; - @Override - public String toString(ABC abc, List fullyQualifiedNames) { - return "Function " + abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " slot=" + slot_index + " method_info=" + method_info + " metadata=" + Helper.intArrToString(metadata); - } + @Override + public String toString(ABC abc, List fullyQualifiedNames) { + return "Function " + abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " slot=" + slot_index + " method_info=" + method_info + " metadata=" + Helper.intArrToString(metadata); + } - @Override - public String convertHeader(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { - String modifier = getModifiers(abcTags, abc, isStatic) + " "; - if (modifier.equals(" ")) { - modifier = ""; - } - MethodBody body = abc.findBody(method_info); - return modifier + "function " + abc.constants.constant_multiname[name_index].getName(abc.constants, fullyQualifiedNames) + "(" + abc.method_info[method_info].getParamStr(abc.constants, body, abc, fullyQualifiedNames) + ") : " + abc.method_info[method_info].getReturnTypeStr(abc.constants, fullyQualifiedNames); - } + @Override + public String convertHeader(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { + String modifier = getModifiers(abcTags, abc, isStatic) + " "; + if (modifier.equals(" ")) { + modifier = ""; + } + MethodBody body = abc.findBody(method_info); + return modifier + "function " + abc.constants.constant_multiname[name_index].getName(abc.constants, fullyQualifiedNames) + "(" + abc.method_info[method_info].getParamStr(abc.constants, body, abc, fullyQualifiedNames) + ") : " + abc.method_info[method_info].getReturnTypeStr(abc.constants, fullyQualifiedNames); + } - @Override - public String convert(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { - String header = convertHeader(path, abcTags, abc, isStatic, pcode, classIndex, highlight, fullyQualifiedNames); - String bodyStr = ""; - int bodyIndex = abc.findBodyIndex(method_info); - if (bodyIndex != -1) { - bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path + "." + abc.constants.constant_multiname[name_index].getName(abc.constants, fullyQualifiedNames), pcode, isStatic, classIndex, abc, abc.constants, abc.method_info, new Stack(), false, highlight, fullyQualifiedNames, null), 3); - } - return ABC.IDENT_STRING + ABC.IDENT_STRING + header + (abc.instance_info[classIndex].isInterface() ? ";" : " {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}"); + @Override + public String convert(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { + String header = convertHeader(path, abcTags, abc, isStatic, pcode, classIndex, highlight, fullyQualifiedNames); + String bodyStr = ""; + int bodyIndex = abc.findBodyIndex(method_info); + if (bodyIndex != -1) { + bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path + "." + abc.constants.constant_multiname[name_index].getName(abc.constants, fullyQualifiedNames), pcode, isStatic, classIndex, abc, abc.constants, abc.method_info, new Stack(), false, highlight, fullyQualifiedNames, null), 3); + } + return ABC.IDENT_STRING + ABC.IDENT_STRING + header + (abc.instance_info[classIndex].isInterface() ? ";" : " {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}"); - } + } } 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 120b94849..e23cfaeeb 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 @@ -26,44 +26,44 @@ import java.util.Stack; public class TraitMethodGetterSetter extends Trait { - public int disp_id; //compiler assigned value that helps overriding - public int method_info; + public int disp_id; //compiler assigned value that helps overriding + public int method_info; - @Override - public String toString(ABC abc, List fullyQualifiedNames) { - return "0x" + Helper.formatAddress(fileOffset) + " " + Helper.byteArrToString(bytes) + " MethodGetterSetter " + abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " disp_id=" + disp_id + " method_info=" + method_info + " metadata=" + Helper.intArrToString(metadata); - } + @Override + public String toString(ABC abc, List fullyQualifiedNames) { + return "0x" + Helper.formatAddress(fileOffset) + " " + Helper.byteArrToString(bytes) + " MethodGetterSetter " + abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " disp_id=" + disp_id + " method_info=" + method_info + " metadata=" + Helper.intArrToString(metadata); + } - @Override - public String convertHeader(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { - String modifier = getModifiers(abcTags, abc, isStatic) + " "; - if (modifier.equals(" ")) { - modifier = ""; - } - String addKind = ""; - if (kindType == TRAIT_GETTER) { - addKind = "get "; - } - if (kindType == TRAIT_SETTER) { - addKind = "set "; - } - MethodBody body = abc.findBody(method_info); - return modifier + "function " + addKind + getName(abc).getName(abc.constants, fullyQualifiedNames) + "(" + abc.method_info[method_info].getParamStr(abc.constants, body, abc, fullyQualifiedNames) + ") : " + abc.method_info[method_info].getReturnTypeStr(abc.constants, fullyQualifiedNames); + @Override + public String convertHeader(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { + String modifier = getModifiers(abcTags, abc, isStatic) + " "; + if (modifier.equals(" ")) { + modifier = ""; + } + String addKind = ""; + if (kindType == TRAIT_GETTER) { + addKind = "get "; + } + if (kindType == TRAIT_SETTER) { + addKind = "set "; + } + MethodBody body = abc.findBody(method_info); + return modifier + "function " + addKind + getName(abc).getName(abc.constants, fullyQualifiedNames) + "(" + abc.method_info[method_info].getParamStr(abc.constants, body, abc, fullyQualifiedNames) + ") : " + abc.method_info[method_info].getReturnTypeStr(abc.constants, fullyQualifiedNames); - } + } - @Override - public String convert(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { - if(debugMode){ - System.out.println("Decompiling "+path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames)); - } - String header = convertHeader(path, abcTags, abc, isStatic, pcode, classIndex, highlight, fullyQualifiedNames); + @Override + public String convert(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { + if (debugMode) { + System.out.println("Decompiling " + path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames)); + } + String header = convertHeader(path, abcTags, abc, isStatic, pcode, classIndex, highlight, fullyQualifiedNames); - String bodyStr = ""; - int bodyIndex = abc.findBodyIndex(method_info); - if (bodyIndex != -1) { - bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames), pcode, isStatic, classIndex, abc, abc.constants, abc.method_info, new Stack(), false, highlight, fullyQualifiedNames, null), 3); - } - return ABC.IDENT_STRING + ABC.IDENT_STRING + header + ((classIndex != -1 && abc.instance_info[classIndex].isInterface()) ? ";" : " {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}"); - } + String bodyStr = ""; + int bodyIndex = abc.findBodyIndex(method_info); + if (bodyIndex != -1) { + bodyStr = ABC.addTabs(abc.bodies[bodyIndex].toString(path + "." + getName(abc).getName(abc.constants, fullyQualifiedNames), pcode, isStatic, classIndex, abc, abc.constants, abc.method_info, new Stack(), false, highlight, fullyQualifiedNames, null), 3); + } + return ABC.IDENT_STRING + ABC.IDENT_STRING + header + ((classIndex != -1 && abc.instance_info[classIndex].isInterface()) ? ";" : " {\r\n" + bodyStr + "\r\n" + ABC.IDENT_STRING + ABC.IDENT_STRING + "}"); + } } 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 29e79e121..e5cfc1c75 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 @@ -30,94 +30,94 @@ import java.util.List; public class TraitSlotConst extends Trait { - public int slot_id; - public int type_index; - public int value_index; - public int value_kind; - public GraphTargetItem assignedValue; + public int slot_id; + public int type_index; + public int value_index; + public int value_kind; + public GraphTargetItem assignedValue; - @Override - public String toString(ABC abc, List fullyQualifiedNames) { - String typeStr = "*"; - if (type_index > 0) { - typeStr = abc.constants.constant_multiname[type_index].toString(abc.constants, fullyQualifiedNames); - } - return "0x" + Helper.formatAddress(fileOffset) + " " + Helper.byteArrToString(bytes) + " SlotConst " + abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " slot=" + slot_id + " type=" + typeStr + " value=" + (new ValueKind(value_index, value_kind)).toString(abc.constants) + " metadata=" + Helper.intArrToString(metadata); - } + @Override + public String toString(ABC abc, List fullyQualifiedNames) { + String typeStr = "*"; + if (type_index > 0) { + typeStr = abc.constants.constant_multiname[type_index].toString(abc.constants, fullyQualifiedNames); + } + return "0x" + Helper.formatAddress(fileOffset) + " " + Helper.byteArrToString(bytes) + " SlotConst " + abc.constants.constant_multiname[name_index].toString(abc.constants, fullyQualifiedNames) + " slot=" + slot_id + " type=" + typeStr + " value=" + (new ValueKind(value_index, value_kind)).toString(abc.constants) + " metadata=" + Helper.intArrToString(metadata); + } - public String getType(ConstantPool constants, List fullyQualifiedNames) { - String typeStr = "*"; - if (type_index > 0) { - typeStr = constants.constant_multiname[type_index].getName(constants, fullyQualifiedNames); - } - return typeStr; - } + public String getType(ConstantPool constants, List fullyQualifiedNames) { + String typeStr = "*"; + if (type_index > 0) { + typeStr = constants.constant_multiname[type_index].getName(constants, fullyQualifiedNames); + } + return typeStr; + } - public String getNameValueStr(ABC abc, List fullyQualifiedNames) { + public String getNameValueStr(ABC abc, List fullyQualifiedNames) { - String typeStr = getType(abc.constants, fullyQualifiedNames); - if (typeStr.equals("*")) { - typeStr = ""; - } else { - typeStr = ":" + typeStr; - } - String valueStr = ""; - ValueKind val = null; - if (value_kind != 0) { - val = new ValueKind(value_index, value_kind); - valueStr = " = " + val.toString(abc.constants); - } + String typeStr = getType(abc.constants, fullyQualifiedNames); + if (typeStr.equals("*")) { + typeStr = ""; + } else { + typeStr = ":" + typeStr; + } + String valueStr = ""; + ValueKind val = null; + if (value_kind != 0) { + val = new ValueKind(value_index, value_kind); + valueStr = " = " + val.toString(abc.constants); + } - if (assignedValue != null) { - valueStr = " = " + Highlighting.stripHilights(assignedValue.toString(abc.constants, new HashMap(), fullyQualifiedNames)); - } - String slotconst = "var"; - if (kindType == TRAIT_CONST) { - slotconst = "const"; - } - if (val != null && val.isNamespace()) { - slotconst = "namespace"; - } - return slotconst + " " + getName(abc).getName(abc.constants, fullyQualifiedNames) + typeStr + valueStr + ";"; - } + if (assignedValue != null) { + valueStr = " = " + Highlighting.stripHilights(assignedValue.toString(abc.constants, new HashMap(), fullyQualifiedNames)); + } + String slotconst = "var"; + if (kindType == TRAIT_CONST) { + slotconst = "const"; + } + if (val != null && val.isNamespace()) { + slotconst = "namespace"; + } + return slotconst + " " + getName(abc).getName(abc.constants, fullyQualifiedNames) + typeStr + valueStr + ";"; + } - public boolean isNamespace() { - if (value_kind != 0) { - ValueKind val = new ValueKind(value_index, value_kind); - return val.isNamespace(); - } - return false; - } + public boolean isNamespace() { + if (value_kind != 0) { + ValueKind val = new ValueKind(value_index, value_kind); + return val.isNamespace(); + } + return false; + } - @Override - public String convert(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { - String modifier = getModifiers(abcTags, abc, isStatic) + " "; - if (modifier.equals(" ")) { - modifier = ""; - } - Multiname n = getName(abc); - boolean showModifier = true; - if ((classIndex == -1) && (n != null)) { - Namespace ns = n.getNamespace(abc.constants); - if (ns == null) { - showModifier = false; - } else { - if ((ns.kind != Namespace.KIND_PACKAGE) && (ns.kind != Namespace.KIND_PACKAGE_INTERNAL)) { - showModifier = false; + @Override + public String convert(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, int classIndex, boolean highlight, List fullyQualifiedNames) { + String modifier = getModifiers(abcTags, abc, isStatic) + " "; + if (modifier.equals(" ")) { + modifier = ""; + } + Multiname n = getName(abc); + boolean showModifier = true; + if ((classIndex == -1) && (n != null)) { + Namespace ns = n.getNamespace(abc.constants); + if (ns == null) { + showModifier = false; + } else { + if ((ns.kind != Namespace.KIND_PACKAGE) && (ns.kind != Namespace.KIND_PACKAGE_INTERNAL)) { + showModifier = false; + } } - } - } - if (!showModifier) { - modifier = ""; - } - return ABC.IDENT_STRING + ABC.IDENT_STRING + modifier + getNameValueStr(abc, fullyQualifiedNames); - } + } + if (!showModifier) { + modifier = ""; + } + return ABC.IDENT_STRING + ABC.IDENT_STRING + modifier + getNameValueStr(abc, fullyQualifiedNames); + } - public boolean isConst() { - return kindType == TRAIT_CONST; - } + public boolean isConst() { + return kindType == TRAIT_CONST; + } - public boolean isVar() { - return kindType == TRAIT_SLOT; - } + public boolean isVar() { + return kindType == TRAIT_SLOT; + } } 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 860fe965b..e5a9a8159 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 @@ -24,59 +24,59 @@ import java.util.List; public class Traits implements Serializable { - public Trait traits[] = new Trait[0]; + public Trait traits[] = new Trait[0]; - @Override - public String toString() { - String s = ""; - for (int t = 0; t < traits.length; t++) { - if (t > 0) { - s += "\r\n"; - } - s += traits[t].toString(); - } - return s; - } - - public String toString(ABC abc, List fullyQualifiedNames) { - String s = ""; - for (int t = 0; t < traits.length; t++) { - if (t > 0) { - s += "\r\n"; - } - s += traits[t].toString(abc, fullyQualifiedNames); - } - return s; - } - - public String convert(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, boolean makePackages, int classIndex, boolean highlighting, List fullyQualifiedNames) { - String s = ""; - for (int t = 0; t < traits.length; t++) { - if (t > 0) { - s += "\r\n\r\n"; - } - String plus; - //System.out.println(path+":"+traits[t].convertHeader(path, abcTags, abc, isStatic, pcode, classIndex, highlighting, fullyQualifiedNames)); - if (makePackages) { - plus = traits[t].convertPackaged(path, abcTags, abc, isStatic, pcode, classIndex, highlighting, fullyQualifiedNames); - } else { - plus = traits[t].convert(path, abcTags, abc, isStatic, pcode, classIndex, highlighting, fullyQualifiedNames); - } - if (highlighting) { - int h = t; - if (classIndex != -1) { - if (!isStatic) { - h = h + abc.class_info[classIndex].static_traits.traits.length; - } + @Override + public String toString() { + String s = ""; + for (int t = 0; t < traits.length; t++) { + if (t > 0) { + s += "\r\n"; } - if (traits[t] instanceof TraitClass) { - plus = Highlighting.hilighClass(plus, ((TraitClass) traits[t]).class_info); + s += traits[t].toString(); + } + return s; + } + + public String toString(ABC abc, List fullyQualifiedNames) { + String s = ""; + for (int t = 0; t < traits.length; t++) { + if (t > 0) { + s += "\r\n"; + } + s += traits[t].toString(abc, fullyQualifiedNames); + } + return s; + } + + public String convert(String path, List abcTags, ABC abc, boolean isStatic, boolean pcode, boolean makePackages, int classIndex, boolean highlighting, List fullyQualifiedNames) { + String s = ""; + for (int t = 0; t < traits.length; t++) { + if (t > 0) { + s += "\r\n\r\n"; + } + String plus; + //System.out.println(path+":"+traits[t].convertHeader(path, abcTags, abc, isStatic, pcode, classIndex, highlighting, fullyQualifiedNames)); + if (makePackages) { + plus = traits[t].convertPackaged(path, abcTags, abc, isStatic, pcode, classIndex, highlighting, fullyQualifiedNames); } else { - plus = Highlighting.hilighTrait(plus, h); + plus = traits[t].convert(path, abcTags, abc, isStatic, pcode, classIndex, highlighting, fullyQualifiedNames); } - } - s += plus; - } - return s; - } + if (highlighting) { + int h = t; + if (classIndex != -1) { + if (!isStatic) { + h = h + abc.class_info[classIndex].static_traits.traits.length; + } + } + if (traits[t] instanceof TraitClass) { + plus = Highlighting.hilighClass(plus, ((TraitClass) traits[t]).class_info); + } else { + plus = Highlighting.hilighTrait(plus, h); + } + } + s += plus; + } + return s; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ClassNameMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ClassNameMultinameUsage.java index 1593e85e8..4d7e17cb2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ClassNameMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ClassNameMultinameUsage.java @@ -26,12 +26,12 @@ import java.util.List; */ public class ClassNameMultinameUsage extends InsideClassMultinameUsage { - public ClassNameMultinameUsage(int multinameIndex, int classIndex) { - super(multinameIndex, classIndex); - } + public ClassNameMultinameUsage(int multinameIndex, int classIndex) { + super(multinameIndex, classIndex); + } - @Override - public String toString(List abcTags, ABC abc) { - return "class " + abc.constants.constant_multiname[abc.instance_info[classIndex].name_index].getNameWithNamespace(abc.constants); - } + @Override + public String toString(List abcTags, ABC abc) { + return "class " + abc.constants.constant_multiname[abc.instance_info[classIndex].name_index].getNameWithNamespace(abc.constants); + } } 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 4ac62bb37..b39c29961 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarMultinameUsage.java @@ -30,26 +30,26 @@ import java.util.List; */ public abstract class ConstVarMultinameUsage extends TraitMultinameUsage { - public ConstVarMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) { - super(multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex); - } + public ConstVarMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex); + } - @Override - public String toString(List abcTags, ABC abc) { - return super.toString(abcTags, abc) + " " - + (parentTraitIndex > -1 - ? (isStatic - ? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList())) - : (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList()))) - : "") - + ((TraitSlotConst) traits.traits[traitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList()); - } + @Override + public String toString(List abcTags, ABC abc) { + return super.toString(abcTags, abc) + " " + + (parentTraitIndex > -1 + ? (isStatic + ? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList())) + : (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList()))) + : "") + + ((TraitSlotConst) traits.traits[traitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList()); + } - public int getTraitIndex() { - return traitIndex; - } + public int getTraitIndex() { + return traitIndex; + } - public boolean isStatic() { - return isStatic; - } + public boolean isStatic() { + return isStatic; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarNameMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarNameMultinameUsage.java index 8774c4463..0f255a4cf 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarNameMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarNameMultinameUsage.java @@ -27,12 +27,12 @@ import java.util.List; */ public class ConstVarNameMultinameUsage extends ConstVarMultinameUsage { - public ConstVarNameMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) { - super(multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex); - } + public ConstVarNameMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex); + } - @Override - public String toString(List abcTags, ABC abc) { - return super.toString(abcTags, abc) + " name"; - } + @Override + public String toString(List abcTags, ABC abc) { + return super.toString(abcTags, abc) + " name"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarTypeMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarTypeMultinameUsage.java index a748e4ae3..6ca4a24d1 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarTypeMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ConstVarTypeMultinameUsage.java @@ -27,12 +27,12 @@ import java.util.List; */ public class ConstVarTypeMultinameUsage extends ConstVarMultinameUsage { - public ConstVarTypeMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) { - super(multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex); - } + public ConstVarTypeMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex); + } - @Override - public String toString(List abcTags, ABC abc) { - return super.toString(abcTags, abc) + " type"; - } + @Override + public String toString(List abcTags, ABC abc) { + return super.toString(abcTags, abc) + " type"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ExtendsMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ExtendsMultinameUsage.java index 641fa9470..8571deefe 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ExtendsMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ExtendsMultinameUsage.java @@ -26,12 +26,12 @@ import java.util.List; */ public class ExtendsMultinameUsage extends InsideClassMultinameUsage { - public ExtendsMultinameUsage(int multinameIndex, int classIndex) { - super(multinameIndex, classIndex); - } + public ExtendsMultinameUsage(int multinameIndex, int classIndex) { + super(multinameIndex, classIndex); + } - @Override - public String toString(List abcTags, ABC abc) { - return super.toString(abcTags, abc) + " extends"; - } + @Override + public String toString(List abcTags, ABC abc) { + return super.toString(abcTags, abc) + " extends"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ImplementsMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ImplementsMultinameUsage.java index 7cc74e4c9..e03f75427 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/ImplementsMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/ImplementsMultinameUsage.java @@ -26,12 +26,12 @@ import java.util.List; */ public class ImplementsMultinameUsage extends InsideClassMultinameUsage { - public ImplementsMultinameUsage(int multinameIndex, int classIndex) { - super(multinameIndex, classIndex); - } + public ImplementsMultinameUsage(int multinameIndex, int classIndex) { + super(multinameIndex, classIndex); + } - @Override - public String toString(List abcTags, ABC abc) { - return super.toString(abcTags, abc) + " implements"; - } + @Override + public String toString(List abcTags, ABC abc) { + return super.toString(abcTags, abc) + " implements"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/InsideClassMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/InsideClassMultinameUsage.java index fc3d5ebfa..757efc80e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/InsideClassMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/InsideClassMultinameUsage.java @@ -26,24 +26,24 @@ import java.util.List; */ public abstract class InsideClassMultinameUsage extends MultinameUsage { - public int multinameIndex; - public int classIndex; + public int multinameIndex; + public int classIndex; - public InsideClassMultinameUsage(int multinameIndex, int classIndex) { - this.multinameIndex = multinameIndex; - this.classIndex = classIndex; - } + public InsideClassMultinameUsage(int multinameIndex, int classIndex) { + this.multinameIndex = multinameIndex; + this.classIndex = classIndex; + } - @Override - public String toString(List abcTags, ABC abc) { - return "class " + abc.constants.constant_multiname[abc.instance_info[classIndex].name_index].getNameWithNamespace(abc.constants); - } + @Override + public String toString(List abcTags, ABC abc) { + return "class " + abc.constants.constant_multiname[abc.instance_info[classIndex].name_index].getNameWithNamespace(abc.constants); + } - public int getMultinameIndex() { - return multinameIndex; - } + public int getMultinameIndex() { + return multinameIndex; + } - public int getClassIndex() { - return classIndex; - } + public int getClassIndex() { + return classIndex; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodBodyMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodBodyMultinameUsage.java index c68542981..8b64b1400 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodBodyMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodBodyMultinameUsage.java @@ -27,12 +27,12 @@ import java.util.List; */ public class MethodBodyMultinameUsage extends MethodMultinameUsage { - public MethodBodyMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { - super(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex); - } + public MethodBodyMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex); + } - @Override - public String toString(List abcTags, ABC abc) { - return super.toString(abcTags, abc) + " body"; - } + @Override + public String toString(List abcTags, ABC abc) { + return super.toString(abcTags, abc) + " body"; + } } 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 dde88a671..395acca6f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodMultinameUsage.java @@ -29,36 +29,36 @@ import java.util.List; */ public abstract class MethodMultinameUsage extends TraitMultinameUsage { - public boolean isInitializer; + public boolean isInitializer; - public MethodMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { - super(multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex); - this.isInitializer = isInitializer; - } + public MethodMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex, traitIndex, isStatic, traits, parentTraitIndex); + this.isInitializer = isInitializer; + } - public boolean isInitializer() { - return isInitializer; - } + public boolean isInitializer() { + return isInitializer; + } - @Override - public String toString(List abcTags, ABC abc) { - return super.toString(abcTags, abc) + " " + (isInitializer - ? (isStatic - ? "class initializer" - : "instance initializer") - : ((parentTraitIndex > -1 - ? (isStatic - ? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList())) - : (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList()))) + " " - : "") - + (((TraitMethodGetterSetter) traits.traits[traitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList())))); - } + @Override + public String toString(List abcTags, ABC abc) { + return super.toString(abcTags, abc) + " " + (isInitializer + ? (isStatic + ? "class initializer" + : "instance initializer") + : ((parentTraitIndex > -1 + ? (isStatic + ? (((TraitMethodGetterSetter) abc.class_info[classIndex].static_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList())) + : (((TraitMethodGetterSetter) abc.instance_info[classIndex].instance_traits.traits[parentTraitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList()))) + " " + : "") + + (((TraitMethodGetterSetter) traits.traits[traitIndex]).convertHeader("", abcTags, abc, isStatic, false, classIndex, false, new ArrayList())))); + } - public int getTraitIndex() { - return traitIndex; - } + public int getTraitIndex() { + return traitIndex; + } - public boolean isStatic() { - return isStatic; - } + public boolean isStatic() { + return isStatic; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodNameMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodNameMultinameUsage.java index ea42c1e01..33fb876b4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodNameMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodNameMultinameUsage.java @@ -27,12 +27,12 @@ import java.util.List; */ public class MethodNameMultinameUsage extends MethodMultinameUsage { - public MethodNameMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { - super(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex); - } + public MethodNameMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex); + } - @Override - public String toString(List abcTags, ABC abc) { - return super.toString(abcTags, abc) + " name"; - } + @Override + public String toString(List abcTags, ABC abc) { + return super.toString(abcTags, abc) + " name"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodParamsMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodParamsMultinameUsage.java index 56f4b05c7..567ec9d9a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodParamsMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodParamsMultinameUsage.java @@ -27,12 +27,12 @@ import java.util.List; */ public class MethodParamsMultinameUsage extends MethodMultinameUsage { - public MethodParamsMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { - super(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex); - } + public MethodParamsMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex); + } - @Override - public String toString(List abcTags, ABC abc) { - return super.toString(abcTags, abc) + " params"; - } + @Override + public String toString(List abcTags, ABC abc) { + return super.toString(abcTags, abc) + " params"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodReturnTypeMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodReturnTypeMultinameUsage.java index 86ec402e2..87a80a717 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodReturnTypeMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MethodReturnTypeMultinameUsage.java @@ -27,12 +27,12 @@ import java.util.List; */ public class MethodReturnTypeMultinameUsage extends MethodMultinameUsage { - public MethodReturnTypeMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { - super(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex); - } + public MethodReturnTypeMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, boolean isInitializer, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex, traitIndex, isStatic, isInitializer, traits, parentTraitIndex); + } - @Override - public String toString(List abcTags, ABC abc) { - return super.toString(abcTags, abc) + " return type"; - } + @Override + public String toString(List abcTags, ABC abc) { + return super.toString(abcTags, abc) + " return type"; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MultinameUsage.java index 4f47b2ba7..4f8103f77 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/MultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/MultinameUsage.java @@ -26,5 +26,5 @@ import java.util.List; */ public abstract class MultinameUsage { - public abstract String toString(List abcTags, ABC abc); + public abstract String toString(List abcTags, ABC abc); } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/TraitMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/TraitMultinameUsage.java index af6d68238..42e6cac0a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/TraitMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/TraitMultinameUsage.java @@ -24,16 +24,16 @@ import com.jpexs.decompiler.flash.abc.types.traits.Traits; */ public abstract class TraitMultinameUsage extends InsideClassMultinameUsage { - public int traitIndex; - public boolean isStatic; - public Traits traits; - public int parentTraitIndex; + public int traitIndex; + public boolean isStatic; + public Traits traits; + public int parentTraitIndex; - public TraitMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) { - super(multinameIndex, classIndex); - this.traitIndex = traitIndex; - this.isStatic = isStatic; - this.traits = traits; - this.parentTraitIndex = parentTraitIndex; - } + public TraitMultinameUsage(int multinameIndex, int classIndex, int traitIndex, boolean isStatic, Traits traits, int parentTraitIndex) { + super(multinameIndex, classIndex); + this.traitIndex = traitIndex; + this.isStatic = isStatic; + this.traits = traits; + this.parentTraitIndex = parentTraitIndex; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/abc/usages/TypeNameMultinameUsage.java b/trunk/src/com/jpexs/decompiler/flash/abc/usages/TypeNameMultinameUsage.java index 5b020f51e..6c2d8ec13 100644 --- a/trunk/src/com/jpexs/decompiler/flash/abc/usages/TypeNameMultinameUsage.java +++ b/trunk/src/com/jpexs/decompiler/flash/abc/usages/TypeNameMultinameUsage.java @@ -27,14 +27,14 @@ import java.util.List; */ public class TypeNameMultinameUsage extends MultinameUsage { - public int typename_index; + public int typename_index; - public TypeNameMultinameUsage(int typename_index) { - this.typename_index = typename_index; - } + public TypeNameMultinameUsage(int typename_index) { + this.typename_index = typename_index; + } - @Override - public String toString(List abcTags, ABC abc) { - return "TypeName " + abc.constants.constant_multiname[typename_index].toString(abc.constants, new ArrayList()); - } + @Override + public String toString(List abcTags, ABC abc) { + return "TypeName " + abc.constants.constant_multiname[typename_index].toString(abc.constants, new ArrayList()); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/Action.java b/trunk/src/com/jpexs/decompiler/flash/action/Action.java index 2fbca0dde..42c7390ff 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/Action.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/Action.java @@ -51,1024 +51,1025 @@ import java.util.logging.Logger; */ public class Action implements GraphSourceItem { - public Action beforeInsert; - public Action afterInsert; - public Action replaceWith; - public boolean ignored = false; - /** - * Action type identifier - */ - public int actionCode; - /** - * Length of action data - */ - public int actionLength; - private long address; - /** - * Names of ActionScript properties - */ - public static final String[] propertyNames = new String[]{ - "_x", - "_y", - "_xscale", - "_yscale", - "_currentframe", - "_totalframes", - "_alpha", - "_visible", - "_width", - "_height", - "_rotation", - "_target", - "_framesloaded", - "_name", - "_droptarget", - "_url", - "_highquality", - "_focusrect", - "_soundbuftime", - "_quality", - "_xmouse", - "_ymouse" - }; - private static Logger logger = Logger.getLogger(Action.class.getName()); + public Action beforeInsert; + public Action afterInsert; + public Action replaceWith; + public boolean ignored = false; + /** + * Action type identifier + */ + public int actionCode; + /** + * Length of action data + */ + public int actionLength; + private long address; + /** + * Names of ActionScript properties + */ + public static final String[] propertyNames = new String[]{ + "_x", + "_y", + "_xscale", + "_yscale", + "_currentframe", + "_totalframes", + "_alpha", + "_visible", + "_width", + "_height", + "_rotation", + "_target", + "_framesloaded", + "_name", + "_droptarget", + "_url", + "_highquality", + "_focusrect", + "_soundbuftime", + "_quality", + "_xmouse", + "_ymouse" + }; + private static Logger logger = Logger.getLogger(Action.class.getName()); - /** - * Constructor - * - * @param actionCode Action type identifier - * @param actionLength Length of action data - */ - public Action(int actionCode, int actionLength) { - this.actionCode = actionCode; - this.actionLength = actionLength; - } + /** + * Constructor + * + * @param actionCode Action type identifier + * @param actionLength Length of action data + */ + public Action(int actionCode, int actionLength) { + this.actionCode = actionCode; + this.actionLength = actionLength; + } - /** - * Returns address of this action - * - * @return - */ - public long getAddress() { - return address; - } + /** + * Returns address of this action + * + * @return + */ + public long getAddress() { + return address; + } - /** - * Gets all addresses which are referenced from this action and/or subactions - * - * @param version SWF version - * @return List of addresses - */ - public List getAllRefs(int version) { - List ret = new ArrayList(); - return ret; - } + /** + * Gets all addresses which are referenced from this action and/or + * subactions + * + * @param version SWF version + * @return List of addresses + */ + public List getAllRefs(int version) { + List ret = new ArrayList(); + return ret; + } - /** - * Gets all ActionIf or ActionJump actions from subactions - * - * @return List of actions - */ - public List getAllIfsOrJumps() { - List ret = new ArrayList(); - return ret; - } + /** + * Gets all ActionIf or ActionJump actions from subactions + * + * @return List of actions + */ + public List getAllIfsOrJumps() { + List ret = new ArrayList(); + return ret; + } - /** - * Gets all ActionIf or ActionJump actions from list of actions - * - * @param list List of actions - * @return List of actions - */ - public static List getActionsAllIfsOrJumps(List list) { - List ret = new ArrayList(); - for (Action a : list) { - List part = a.getAllIfsOrJumps(); - ret.addAll(part); - } - return ret; - } + /** + * Gets all ActionIf or ActionJump actions from list of actions + * + * @param list List of actions + * @return List of actions + */ + public static List getActionsAllIfsOrJumps(List list) { + List ret = new ArrayList(); + for (Action a : list) { + List part = a.getAllIfsOrJumps(); + ret.addAll(part); + } + return ret; + } - /** - * Gets all addresses which are referenced from the list of actions - * - * @param list List of actions - * @param version SWF version - * @return List of addresses - */ - public static List getActionsAllRefs(List list, int version) { - List ret = new ArrayList(); - for (Action a : list) { - if (a.replaceWith != null) { - a.replaceWith.setAddress(a.getAddress(), version); - ret.addAll(a.replaceWith.getAllRefs(version)); - } - if (a.beforeInsert != null) { - a.beforeInsert.setAddress(a.getAddress(), version); - ret.addAll(a.beforeInsert.getAllRefs(version)); - } - List part = a.getAllRefs(version); - ret.addAll(part); - if (a.afterInsert != null) { - a.afterInsert.setAddress(a.getAddress(), version); - ret.addAll(a.afterInsert.getAllRefs(version)); - } - } - return ret; - } - - /** - * Sets address of this instruction - * - * @param address Address - * @param version SWF version - */ - public void setAddress(long address, int version) { - this.address = address; - } - - /** - * Returns a string representation of the object - * - * @return a string representation of the object. - */ - @Override - public String toString() { - return "Action" + actionCode; - } - - /** - * Reads String from FlasmLexer - * - * @param lex FlasmLexer - * @return String value - * @throws IOException - * @throws ParseException When read object is not String - */ - protected String lexString(FlasmLexer lex) throws IOException, ParseException { - ParsedSymbol symb = lex.yylex(); - if (symb.type != ParsedSymbol.TYPE_STRING) { - throw new ParseException("String expected", lex.yyline()); - } - return (String) symb.value; - } - - /** - * Reads Block startServer from FlasmLexer - * - * @param lex FlasmLexer - * @throws IOException - * @throws ParseException When read object is not Block startServer - */ - protected void lexBlockOpen(FlasmLexer lex) throws IOException, ParseException { - ParsedSymbol symb = lex.yylex(); - if (symb.type != ParsedSymbol.TYPE_BLOCK_START) { - throw new ParseException("Block startServer ", lex.yyline()); - } - } - - /** - * Reads Identifier from FlasmLexer - * - * @param lex FlasmLexer - * @return Identifier name - * @throws IOException - * @throws ParseException When read object is not Identifier - */ - protected String lexIdentifier(FlasmLexer lex) throws IOException, ParseException { - ParsedSymbol symb = lex.yylex(); - if (symb.type != ParsedSymbol.TYPE_IDENTIFIER) { - throw new ParseException("Identifier expected", lex.yyline()); - } - return (String) symb.value; - } - - /** - * Reads long value from FlasmLexer - * - * @param lex FlasmLexer - * @return long value - * @throws IOException - * @throws ParseException When read object is not long value - */ - protected long lexLong(FlasmLexer lex) throws IOException, ParseException { - ParsedSymbol symb = lex.yylex(); - if (symb.type != ParsedSymbol.TYPE_INTEGER) { - throw new ParseException("Integer expected", lex.yyline()); - } - return (Long) symb.value; - } - - /** - * Reads boolean value from FlasmLexer - * - * @param lex FlasmLexer - * @return boolean value - * @throws IOException - * @throws ParseException When read object is not boolean value - */ - protected boolean lexBoolean(FlasmLexer lex) throws IOException, ParseException { - ParsedSymbol symb = lex.yylex(); - if (symb.type != ParsedSymbol.TYPE_BOOLEAN) { - throw new ParseException("Boolean expected", lex.yyline()); - } - return (Boolean) symb.value; - } - - /** - * Gets action converted to bytes - * - * @param version SWF version - * @return Array of bytes - */ - public byte[] getBytes(int version) { - byte ret[] = new byte[1]; - ret[0] = (byte) actionCode; - return ret; - } - - /** - * Surrounds byte array with Action header - * - * @param data Byte array - * @param version SWF version - * @return Byte array - */ - protected byte[] surroundWithAction(byte[] data, int version) { - ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); - SWFOutputStream sos2 = new SWFOutputStream(baos2, version); - try { - sos2.writeUI8(actionCode); - sos2.writeUI16(data.length); - sos2.write(data); - sos2.close(); - } catch (IOException e) { - } - return baos2.toByteArray(); - } - - /** - * Converts list of Actions to bytes - * - * @param list List of actions - * @param addZero Whether or not to add 0 UI8 value to the end - * @param version SWF version - * @return Array of bytes - */ - public static byte[] actionsToBytes(List list, boolean addZero, int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - for (Action a : list) { - try { - baos.write(a.getBytes(version)); - } catch (IOException e) { - } - } - if (addZero) { - baos.write(0); - } - return baos.toByteArray(); - } - - /** - * Set addresses of actions in the list - * - * @param list List of actions - * @param baseAddress Address of first action in the list - * @param version SWF version - */ - public static void setActionsAddresses(List list, long baseAddress, int version) { - long offset = baseAddress; - for (Action a : list) { - a.setAddress(offset, version); - offset += a.getBytes(version).length; - } - } - - /** - * Converts list of actions to ASM source - * - * @param list List of actions - * @param importantOffsets List of important offsets to mark as labels - * @param version SWF version - * @param hex Add hexadecimal? - * @return ASM source as String - */ - public static String actionsToString(List list, List importantOffsets, int version, boolean hex) { - return actionsToString(list, importantOffsets, new ArrayList(), version, hex); - } - - /** - * Converts list of actions to ASM source - * - * @param list List of actions - * @param importantOffsets List of important offsets to mark as labels - * @param constantPool Constant pool - * @param version SWF version - * @param hex Add hexadecimal? - * @return ASM source as String - */ - public static String actionsToString(List list, List importantOffsets, List constantPool, int version, boolean hex) { - String ret = ""; - long offset; - if (importantOffsets == null) { - //setActionsAddresses(list, 0, version); - importantOffsets = getActionsAllRefs(list, version); - } - - offset = 0; - for (Action a : list) { - if (hex) { - ret += "" + Helper.bytesToHexString((a instanceof ActionContainer) ? ((ActionContainer) a).getHeaderBytes() : a.getBytes(version)) + "\r\n"; - } - offset = a.getAddress(); - if (importantOffsets.contains(offset)) { - ret += "loc" + Helper.formatAddress(offset) + ":"; - } - - if (a.replaceWith != null) { - ret += Highlighting.hilighOffset("", offset) + a.replaceWith.getASMSource(importantOffsets, constantPool, version, hex) + "\r\n"; - } else if (a.ignored) { - int len = a.getBytes(version).length; - for (int i = 0; i < len; i++) { - ret += "Nop\r\n"; + /** + * Gets all addresses which are referenced from the list of actions + * + * @param list List of actions + * @param version SWF version + * @return List of addresses + */ + public static List getActionsAllRefs(List list, int version) { + List ret = new ArrayList(); + for (Action a : list) { + if (a.replaceWith != null) { + a.replaceWith.setAddress(a.getAddress(), version); + ret.addAll(a.replaceWith.getAllRefs(version)); } - } else { if (a.beforeInsert != null) { - ret += a.beforeInsert.getASMSource(importantOffsets, constantPool, version, hex) + "\r\n"; + a.beforeInsert.setAddress(a.getAddress(), version); + ret.addAll(a.beforeInsert.getAllRefs(version)); } - //if (!(a instanceof ActionNop)) { - ret += Highlighting.hilighOffset("", offset) + a.getASMSourceReplaced(importantOffsets, constantPool, version, hex) + (a.ignored ? "; ignored" : "") + "\r\n"; - - //} + List part = a.getAllRefs(version); + ret.addAll(part); if (a.afterInsert != null) { - ret += a.afterInsert.getASMSource(importantOffsets, constantPool, version, hex) + "\r\n"; + a.afterInsert.setAddress(a.getAddress(), version); + ret.addAll(a.afterInsert.getAllRefs(version)); } - } - offset += a.getBytes(version).length; - } - if (importantOffsets.contains(offset)) { - ret += "loc" + Helper.formatAddress(offset) + ":\r\n"; - } - return ret; - } + } + return ret; + } - /** - * Convert action to ASM source - * - * @param knownAddreses List of important offsets to mark as labels - * @param constantPool Constant pool - * @param version SWF version - * @param hex Add hexadecimal - * @return - */ - public String getASMSource(List knownAddreses, List constantPool, int version, boolean hex) { - return toString(); - } + /** + * Sets address of this instruction + * + * @param address Address + * @param version SWF version + */ + public void setAddress(long address, int version) { + this.address = address; + } - /** - * Translates this function to stack and output. - * - * @param stack Stack - * @param constants Constant pool - * @param output Output - * @param regNames Register names - */ - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { - } + /** + * Returns a string representation of the object + * + * @return a string representation of the object. + */ + @Override + public String toString() { + return "Action" + actionCode; + } - /** - * Pops long value off the stack - * - * @param stack Stack - * @return long value - */ - protected long popLong(Stack stack) { - GraphTargetItem item = stack.pop(); - if (item instanceof DirectValueTreeItem) { - if (((DirectValueTreeItem) item).value instanceof Long) { - return (long) (Long) ((DirectValueTreeItem) item).value; - } - } - return 0; - } + /** + * Reads String from FlasmLexer + * + * @param lex FlasmLexer + * @return String value + * @throws IOException + * @throws ParseException When read object is not String + */ + protected String lexString(FlasmLexer lex) throws IOException, ParseException { + ParsedSymbol symb = lex.yylex(); + if (symb.type != ParsedSymbol.TYPE_STRING) { + throw new ParseException("String expected", lex.yyline()); + } + return (String) symb.value; + } - /** - * Converts action index to address in the specified list of actions - * - * @param actions List of actions - * @param ip Action index - * @param version SWF version - * @return address - */ - public static long ip2adr(List actions, int ip, int version) { - if (ip >= actions.size()) { - if (actions.isEmpty()) { - return 0; - } - return actions.get(actions.size() - 1).getAddress() + actions.get(actions.size() - 1).getBytes(version).length; - } - if (ip == -1) { - return 0; - } - return actions.get(ip).getAddress(); - } + /** + * Reads Block startServer from FlasmLexer + * + * @param lex FlasmLexer + * @throws IOException + * @throws ParseException When read object is not Block startServer + */ + protected void lexBlockOpen(FlasmLexer lex) throws IOException, ParseException { + ParsedSymbol symb = lex.yylex(); + if (symb.type != ParsedSymbol.TYPE_BLOCK_START) { + throw new ParseException("Block startServer ", lex.yyline()); + } + } - /** - * Converts address to action index in the specified list of actions - * - * @param actions List of actions - * @param addr Address - * @param version SWF version - * @return action index - */ - public static int adr2ip(List actions, long addr, int version) { - for (int ip = 0; ip < actions.size(); ip++) { - if (actions.get(ip).getAddress() == addr) { - return ip; - } - } - if (actions.size() > 0) { - long outpos = actions.get(actions.size() - 1).getAddress() + actions.get(actions.size() - 1).getBytes(version).length; - if (addr == outpos) { - return actions.size(); - } - } - return -1; - } + /** + * Reads Identifier from FlasmLexer + * + * @param lex FlasmLexer + * @return Identifier name + * @throws IOException + * @throws ParseException When read object is not Identifier + */ + protected String lexIdentifier(FlasmLexer lex) throws IOException, ParseException { + ParsedSymbol symb = lex.yylex(); + if (symb.type != ParsedSymbol.TYPE_IDENTIFIER) { + throw new ParseException("Identifier expected", lex.yyline()); + } + return (String) symb.value; + } - /** - * Converts list of actions to ActionScript source code - * - * @param actions List of actions - * @param version SWF version - * @return String with Source code - */ - public static String actionsToSource(List actions, int version) { - try { - //List tree = actionsToTree(new HashMap(), actions, version); - List tree = actionsToTree(new HashMap(), new HashMap(), new HashMap(), actions, version); + /** + * Reads long value from FlasmLexer + * + * @param lex FlasmLexer + * @return long value + * @throws IOException + * @throws ParseException When read object is not long value + */ + protected long lexLong(FlasmLexer lex) throws IOException, ParseException { + ParsedSymbol symb = lex.yylex(); + if (symb.type != ParsedSymbol.TYPE_INTEGER) { + throw new ParseException("Integer expected", lex.yyline()); + } + return (Long) symb.value; + } + /** + * Reads boolean value from FlasmLexer + * + * @param lex FlasmLexer + * @return boolean value + * @throws IOException + * @throws ParseException When read object is not boolean value + */ + protected boolean lexBoolean(FlasmLexer lex) throws IOException, ParseException { + ParsedSymbol symb = lex.yylex(); + if (symb.type != ParsedSymbol.TYPE_BOOLEAN) { + throw new ParseException("Boolean expected", lex.yyline()); + } + return (Boolean) symb.value; + } - return Graph.graphToString(tree); - } catch (Exception ex) { - Logger.getLogger(Action.class.getName()).log(Level.SEVERE, null, ex); - return "//Decompilation error :" + ex.getLocalizedMessage(); - } - } + /** + * Gets action converted to bytes + * + * @param version SWF version + * @return Array of bytes + */ + public byte[] getBytes(int version) { + byte ret[] = new byte[1]; + ret[0] = (byte) actionCode; + return ret; + } - /** - * Converts list of actions to List of treeItems - * - * @param regNames Register names - * @param actions List of actions - * @param version SWF version - * @return List of treeItems - */ - public static List actionsToTree(HashMap regNames, HashMap variables, HashMap functions, List actions, int version) { - //Stack stack = new Stack(); - return ActionGraph.translateViaGraph(regNames, variables, functions, actions, version); - //return actionsToTree(regNames, stack, actions, 0, actions.size() - 1, version); - } + /** + * Surrounds byte array with Action header + * + * @param data Byte array + * @param version SWF version + * @return Byte array + */ + protected byte[] surroundWithAction(byte[] data, int version) { + ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); + SWFOutputStream sos2 = new SWFOutputStream(baos2, version); + try { + sos2.writeUI8(actionCode); + sos2.writeUI16(data.length); + sos2.write(data); + sos2.close(); + } catch (IOException e) { + } + return baos2.toByteArray(); + } - @Override - public void translate(List localData, Stack stack, List output) { - translate(stack, output, (HashMap) localData.get(0), (HashMap) localData.get(1), (HashMap) localData.get(2)); - } - - @Override - public boolean isJump() { - return false; - } - - @Override - public boolean isBranch() { - return false; - } - - @Override - public boolean isExit() { - return false; - } - - @Override - public long getOffset() { - return getAddress(); - } - - @Override - public List getBranches(GraphSource code) { - return new ArrayList(); - } - - @Override - public boolean isIgnored() { - return ignored; - } - - @Override - public void setIgnored(boolean ignored) { - this.ignored = ignored; - } - - private static class Loop { - - public long loopContinue; - public long loopBreak; - public int continueCount = 0; - public int breakCount = 0; - - public Loop(long loopContinue, long loopBreak) { - this.loopContinue = loopContinue; - this.loopBreak = loopBreak; - } - - @Override - public String toString() { - return "[Loop continue:" + loopContinue + ", break:" + loopBreak + "]"; - } - } - - private static void log(String s) { - logger.fine(s); - } - - public static List actionsPartToTree(HashMap registerNames, HashMap variables, HashMap functions, Stack stack, List actions, int start, int end, int version) { - if (start < actions.size() && (end > 0) && (start > 0)) { - log("Entering " + start + "-" + end + (actions.size() > 0 ? (" (" + actions.get(start).toString() + " - " + actions.get(end == actions.size() ? end - 1 : end) + ")") : "")); - } - List localData = new ArrayList(); - localData.add(registerNames); - localData.add(variables); - localData.add(functions); - List output = new ArrayList(); - int ip = start; - boolean isWhile = false; - boolean isForIn = false; - GraphTargetItem inItem = null; - int loopStart = 0; - loopip: - while (ip <= end + 1) { - - long addr = ip2adr(actions, ip, version); - /*if (unknownJumps.contains(addr)) { - unknownJumps.remove(new Long(addr)); - boolean switchFound = false; - for (int i = output.size() - 1; i >= 0; i--) { - if (output.get(i) instanceof SwitchTreeItem) { - if (((SwitchTreeItem) output.get(i)).defaultCommands == null) { - List continues = ((SwitchTreeItem) output.get(i)).getContinues(); - boolean breakFound = false; - for (ContinueTreeItem cti : continues) { - if (cti.loopPos == addr) { - cti.isKnown = true; - cti.isBreak = true; - ((SwitchTreeItem) output.get(i)).loopBreak = addr; - breakFound = true; - } - } - if (breakFound) { - switchFound = true; - ((SwitchTreeItem) output.get(i)).defaultCommands = new ArrayList(); - for (int k = i + 1; k < output.size(); k++) { - ((SwitchTreeItem) output.get(i)).defaultCommands.add(output.remove(i + 1)); - } - } - } - break; - } - } - if (!switchFound) { - throw new UnknownJumpException(stack, addr, output); - } - }*/ - if (ip > end) { - break; - } - if (ip >= actions.size()) { - break; - } - Action action = actions.get(ip); - //System.out.println(" ip "+ip+" "+action); - //return in for..in - if ((action instanceof ActionPush) && (((ActionPush) action).values.size() == 1) && (((ActionPush) action).values.get(0) instanceof Null)) { - if (ip + 3 <= end) { - if ((actions.get(ip + 1) instanceof ActionEquals) || (actions.get(ip + 1) instanceof ActionEquals2)) { - if (actions.get(ip + 2) instanceof ActionNot) { - if (actions.get(ip + 3) instanceof ActionIf) { - ActionIf aif = (ActionIf) actions.get(ip + 3); - if (adr2ip(actions, ip2adr(actions, ip + 4, version) + aif.offset, version) == ip) { - ip += 4; - continue; - } - } - } - } - } - } - - /*ActionJump && ActionIf removed*/ - if ((action instanceof ActionEnumerate2) || (action instanceof ActionEnumerate)) { - loopStart = ip + 1; - isForIn = true; - ip += 4; - action.translate(localData, stack, output); - EnumerateTreeItem en = (EnumerateTreeItem) stack.peek(); - inItem = en.object; - continue; - } else if (action instanceof ActionTry) { - ActionTry atry = (ActionTry) action; - List tryCommands = ActionGraph.translateViaGraph(registerNames, variables, functions, atry.tryBody, version); - TreeItem catchName; - if (atry.catchInRegisterFlag) { - catchName = new DirectValueTreeItem(atry, -1, new RegisterNumber(atry.catchRegister), new ArrayList()); - } else { - catchName = new DirectValueTreeItem(atry, -1, atry.catchName, new ArrayList()); - } - List catchExceptions = new ArrayList(); - catchExceptions.add(catchName); - List> catchCommands = new ArrayList>(); - catchCommands.add(ActionGraph.translateViaGraph(registerNames, variables, functions, atry.catchBody, version)); - List finallyCommands = ActionGraph.translateViaGraph(registerNames, variables, functions, atry.finallyBody, version); - output.add(new TryTreeItem(tryCommands, catchExceptions, catchCommands, finallyCommands)); - } else if (action instanceof ActionWith) { - ActionWith awith = (ActionWith) action; - List withCommands = ActionGraph.translateViaGraph(registerNames, variables, functions, awith.actions, version); - output.add(new WithTreeItem(action, stack.pop(), withCommands)); - }/*else if (action instanceof ActionPushDuplicate) { - do { - if (actions.get(ip + 1) instanceof ActionNot) { - if (actions.get(ip + 2) instanceof ActionIf) { - int nextPos = adr2ip(actions, ((ActionIf) actions.get(ip + 2)).getRef(version), version); - stack.push(new AndTreeItem(action, stack.pop(), actionsToStackTree(registerNames, actions, constants, ip + 4, nextPos - 1, version).pop())); - ip = nextPos; - } else { - output.add(new UnsupportedTreeItem(action, "ActionPushDuplicate with Not")); - break; - } - } else if (actions.get(ip + 1) instanceof ActionIf) { - int nextPos = adr2ip(actions, ((ActionIf) actions.get(ip + 1)).getRef(version), version); - stack.push(new OrTreeItem(action, stack.pop(), actionsToStackTree(registerNames, actions, constants, ip + 3, nextPos - 1, version).pop())); - ip = nextPos; - } else { - output.add(new UnsupportedTreeItem(action, "ActionPushDuplicate with no If")); - break loopip; - } - action = actions.get(ip); - } while (action instanceof ActionPushDuplicate); - continue; - }*/ else if (action instanceof ActionStoreRegister) { - if ((ip + 1 <= end) && (actions.get(ip + 1) instanceof ActionPop)) { - action.translate(localData, stack, output); - stack.pop(); - ip++; - } else { - try { - action.translate(localData, stack, output); - } catch (Exception ex) { - //ignore - } - } - } /*else if (action instanceof ActionStrictEquals) { - if ((ip + 1 < actions.size()) && (actions.get(ip + 1) instanceof ActionIf)) { - List caseValues = new ArrayList(); - List> caseCommands = new ArrayList>(); - caseValues.add(stack.pop()); - TreeItem switchedObject = stack.pop(); - if (output.size() > 0) { - if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) { - output.remove(output.size() - 1); - } - } - int caseStart = ip + 2; - List caseBodyIps = new ArrayList(); - long defaultAddr = 0; - caseBodyIps.add(adr2ip(actions, ((ActionIf) actions.get(ip + 1)).getRef(version), version)); - ip++; - do { - ip++; - if ((actions.get(ip - 1) instanceof ActionStrictEquals) && (actions.get(ip) instanceof ActionIf)) { - caseValues.add(actionsToStackTree(registerNames, jumpsOrIfs, actions, constants, caseStart, ip - 2, version).pop()); - caseStart = ip + 1; - caseBodyIps.add(adr2ip(actions, ((ActionIf) actions.get(ip)).getRef(version), version)); - if (actions.get(ip + 1) instanceof ActionJump) { - defaultAddr = ((ActionJump) actions.get(ip + 1)).getRef(version); - ip = adr2ip(actions, defaultAddr, version); - break; - } - } - } while (ip < end); - - for (int i = 0; i < caseBodyIps.size(); i++) { - int caseEnd = ip - 1; - if (i < caseBodyIps.size() - 1) { - caseEnd = caseBodyIps.get(i + 1) - 1; - } - caseCommands.add(actionsToTree(registerNames, unknownJumps, loopList, jumpsOrIfs, stack, constants, actions, caseBodyIps.get(i), caseEnd, version)); - } - output.add(new SwitchTreeItem(action, defaultAddr, switchedObject, caseValues, caseCommands, null)); - continue; - } else { - action.translate(stack, constants, output, registerNames); - } - } */ else { + /** + * Converts list of Actions to bytes + * + * @param list List of actions + * @param addZero Whether or not to add 0 UI8 value to the end + * @param version SWF version + * @return Array of bytes + */ + public static byte[] actionsToBytes(List list, boolean addZero, int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + for (Action a : list) { try { - action.translate(localData, stack, output); - } catch (EmptyStackException ese) { - Logger.getLogger(Action.class.getName()).log(Level.SEVERE, null, ese); - output.add(new UnsupportedTreeItem(action, "Empty stack")); + baos.write(a.getBytes(version)); + } catch (IOException e) { + } + } + if (addZero) { + baos.write(0); + } + return baos.toByteArray(); + } + + /** + * Set addresses of actions in the list + * + * @param list List of actions + * @param baseAddress Address of first action in the list + * @param version SWF version + */ + public static void setActionsAddresses(List list, long baseAddress, int version) { + long offset = baseAddress; + for (Action a : list) { + a.setAddress(offset, version); + offset += a.getBytes(version).length; + } + } + + /** + * Converts list of actions to ASM source + * + * @param list List of actions + * @param importantOffsets List of important offsets to mark as labels + * @param version SWF version + * @param hex Add hexadecimal? + * @return ASM source as String + */ + public static String actionsToString(List list, List importantOffsets, int version, boolean hex) { + return actionsToString(list, importantOffsets, new ArrayList(), version, hex); + } + + /** + * Converts list of actions to ASM source + * + * @param list List of actions + * @param importantOffsets List of important offsets to mark as labels + * @param constantPool Constant pool + * @param version SWF version + * @param hex Add hexadecimal? + * @return ASM source as String + */ + public static String actionsToString(List list, List importantOffsets, List constantPool, int version, boolean hex) { + String ret = ""; + long offset; + if (importantOffsets == null) { + //setActionsAddresses(list, 0, version); + importantOffsets = getActionsAllRefs(list, version); + } + + offset = 0; + for (Action a : list) { + if (hex) { + ret += "" + Helper.bytesToHexString((a instanceof ActionContainer) ? ((ActionContainer) a).getHeaderBytes() : a.getBytes(version)) + "\r\n"; + } + offset = a.getAddress(); + if (importantOffsets.contains(offset)) { + ret += "loc" + Helper.formatAddress(offset) + ":"; } - } - - ip++; - } - //output = checkClass(output); - log("Leaving " + start + "-" + end); - return output; - } - - public static GraphTargetItem getWithoutGlobal(GraphTargetItem ti) { - GraphTargetItem t = ti; - if (!(t instanceof GetMemberTreeItem)) { - return ti; - } - GetMemberTreeItem lastMember = null; - while (((GetMemberTreeItem) t).object instanceof GetMemberTreeItem) { - lastMember = (GetMemberTreeItem) t; - t = ((GetMemberTreeItem) t).object; - } - if (((GetMemberTreeItem) t).object instanceof GetVariableTreeItem) { - GetVariableTreeItem v = (GetVariableTreeItem) ((GetMemberTreeItem) t).object; - if (v.name instanceof DirectValueTreeItem) { - if (((DirectValueTreeItem) v.name).value instanceof String) { - if (((DirectValueTreeItem) v.name).value.equals("_global")) { - GetVariableTreeItem gvt = new GetVariableTreeItem(null, ((GetMemberTreeItem) t).memberName); - if (lastMember == null) { - return gvt; - } else { - lastMember.object = gvt; - } - } - } - } - } - return ti; - } - - public static List checkClass(List output) { - List ret = new ArrayList(); - List functions = new ArrayList(); - List staticFunctions = new ArrayList(); - HashMap vars = new HashMap(); - HashMap staticVars = new HashMap(); - GraphTargetItem className; - GraphTargetItem extendsOp = null; - List implementsOp = new ArrayList(); - boolean ok = true; - int prevCount = 0; - for (GraphTargetItem t : output) { - if (t instanceof IfItem) { - IfItem it = (IfItem) t; - if (it.expression instanceof NotItem) { - NotItem nti = (NotItem) it.expression; - if (nti.value instanceof GetMemberTreeItem) { - if (true) { //it.onFalse.isEmpty()){ //||(it.onFalse.get(0) instanceof UnsupportedTreeItem)) { - if ((it.onTrue.size() == 1) && (it.onTrue.get(0) instanceof SetMemberTreeItem) && (((SetMemberTreeItem) it.onTrue.get(0)).value instanceof NewObjectTreeItem)) { - //ignore - } else { - List parts = it.onTrue; - className = getWithoutGlobal((GetMemberTreeItem) nti.value); - if (parts.size() >= 1) { - if (parts.get(0) instanceof StoreRegisterTreeItem) { - int classReg = ((StoreRegisterTreeItem) parts.get(0)).register.number; - if ((parts.size() >= 2) && (parts.get(1) instanceof SetMemberTreeItem)) { - GraphTargetItem ti1 = ((SetMemberTreeItem) parts.get(1)).value; - GraphTargetItem ti2 = ((StoreRegisterTreeItem) parts.get(0)).value; - if (ti1 == ti2) { - if (((SetMemberTreeItem) parts.get(1)).value instanceof FunctionTreeItem) { - ((FunctionTreeItem) ((SetMemberTreeItem) parts.get(1)).value).calculatedFunctionName = (className instanceof GetMemberTreeItem) ? ((GetMemberTreeItem) className).memberName : className; - functions.add((FunctionTreeItem) ((SetMemberTreeItem) parts.get(1)).value); - int pos = 2; - if (parts.size() <= pos) { - ok = false; - break; - } - - if (parts.get(pos) instanceof ExtendsTreeItem) { - ExtendsTreeItem et = (ExtendsTreeItem) parts.get(pos); - extendsOp = getWithoutGlobal(et.superclass); - pos++; - } - - if (parts.size() <= pos) { - List output2 = new ArrayList(); - for (int i = 0; i < prevCount; i++) { - output2.add(output.get(i)); - } - output2.add(new ClassTreeItem(className, extendsOp, implementsOp, functions, vars, staticFunctions, staticVars)); - return output2; - } - if (parts.get(pos) instanceof StoreRegisterTreeItem) { - int instanceReg = -1; - if (((StoreRegisterTreeItem) parts.get(pos)).value instanceof GetMemberTreeItem) { - GraphTargetItem obj = ((GetMemberTreeItem) ((StoreRegisterTreeItem) parts.get(pos)).value).object; - if (obj instanceof DirectValueTreeItem) { - if (((DirectValueTreeItem) obj).value instanceof RegisterNumber) { - if (((RegisterNumber) ((DirectValueTreeItem) obj).value).number == classReg) { - instanceReg = ((StoreRegisterTreeItem) parts.get(pos)).register.number; - } - } - } - } else if (((StoreRegisterTreeItem) parts.get(pos)).value instanceof NewMethodTreeItem) { - - if (parts.get(pos + 1) instanceof SetMemberTreeItem) { - if (((SetMemberTreeItem) parts.get(pos + 1)).value == ((StoreRegisterTreeItem) parts.get(pos)).value) { - instanceReg = ((StoreRegisterTreeItem) parts.get(pos)).register.number; - NewMethodTreeItem nm = (NewMethodTreeItem) ((StoreRegisterTreeItem) parts.get(pos)).value; - GetMemberTreeItem gm = new GetMemberTreeItem(null, nm.scriptObject, nm.methodName); - extendsOp = gm; - } else { - ok = false; - break; - } - } else { - ok = false; - break; - } - pos++; - } else { - ok = false; - break; - } - if (instanceReg == -1) { - ok = false; - break; - } - pos++; - if (parts.size() <= pos) { - ok = false; - break; - } - if (parts.get(pos) instanceof ImplementsOpTreeItem) { - ImplementsOpTreeItem io = (ImplementsOpTreeItem) parts.get(pos); - implementsOp = io.superclasses; - pos++; - } - while ((parts.size() > pos) && ok) { - if (parts.get(pos) instanceof SetMemberTreeItem) { - SetMemberTreeItem smt = (SetMemberTreeItem) parts.get(pos); - if (smt.object instanceof DirectValueTreeItem) { - if (((DirectValueTreeItem) smt.object).value instanceof RegisterNumber) { - if (((RegisterNumber) ((DirectValueTreeItem) smt.object).value).number == instanceReg) { - if (smt.value instanceof FunctionTreeItem) { - ((FunctionTreeItem) smt.value).calculatedFunctionName = smt.objectName; - functions.add((FunctionTreeItem) smt.value); - } else { - vars.put(smt.objectName, smt.value); - } - } else if (((RegisterNumber) ((DirectValueTreeItem) smt.object).value).number == classReg) { - if (smt.value instanceof FunctionTreeItem) { - ((FunctionTreeItem) smt.value).calculatedFunctionName = smt.objectName; - staticFunctions.add((FunctionTreeItem) smt.value); - } else { - staticVars.put(smt.objectName, smt.value); - } - } else { - ok = false; - } - } - } else { - ok = false; - } - } else if (parts.get(pos) instanceof CallFunctionTreeItem) { - //if(((CallFunctionTreeItem)parts.get(pos)).functionName){ - if (((CallFunctionTreeItem) parts.get(pos)).functionName instanceof DirectValueTreeItem) { - if (((DirectValueTreeItem) ((CallFunctionTreeItem) parts.get(pos)).functionName).value.equals("ASSetPropFlags")) { - } else { - ok = false; - } - } else { - ok = false; - } - - } else { - ok = false; - break; - } - pos++; - } - if (ok) { - List output2 = new ArrayList(); - for (int i = 0; i < prevCount; i++) { - output2.add(output.get(i)); - } - output2.add(new ClassTreeItem(className, extendsOp, implementsOp, functions, vars, staticFunctions, staticVars)); - return output2; - } - } else { - ok = false; - } - } else { - ok = false; - } - } else { - ok = false; - } - } else { - ok = false; - } - } else if (parts.get(0) instanceof SetMemberTreeItem) { - SetMemberTreeItem sm = (SetMemberTreeItem) parts.get(0); - if (sm.value instanceof FunctionTreeItem) { - FunctionTreeItem f = (FunctionTreeItem) sm.value; - if (f.actions.isEmpty()) { - - if (parts.size() == 2) { - if (parts.get(1) instanceof ImplementsOpTreeItem) { - ImplementsOpTreeItem iot = (ImplementsOpTreeItem) parts.get(1); - implementsOp = iot.superclasses; - } else { - ok = false; - break; - } - } - List output2 = new ArrayList(); - for (int i = 0; i < prevCount; i++) { - output2.add(output.get(i)); - } - output2.add(new InterfaceTreeItem(sm.objectName, implementsOp)); - return output2; - } else { - ok = false; - } - } else { - ok = false; - } - } else { - ok = false; - } - } else { - ok = false; - } - } - } else { - ok = false; - } - } else { - ok = false; - } + if (a.replaceWith != null) { + ret += Highlighting.hilighOffset("", offset) + a.replaceWith.getASMSource(importantOffsets, constantPool, version, hex) + "\r\n"; + } else if (a.ignored) { + int len = a.getBytes(version).length; + for (int i = 0; i < len; i++) { + ret += "Nop\r\n"; + } } else { - ok = false; - } - } else { - prevCount++; - //ok = false; - } - if (!ok) { - break; - } - } - return output; - } + if (a.beforeInsert != null) { + ret += a.beforeInsert.getASMSource(importantOffsets, constantPool, version, hex) + "\r\n"; + } + //if (!(a instanceof ActionNop)) { + ret += Highlighting.hilighOffset("", offset) + a.getASMSourceReplaced(importantOffsets, constantPool, version, hex) + (a.ignored ? "; ignored" : "") + "\r\n"; - @Override - public boolean ignoredLoops() { - return false; - } - - public static List removeNops(List actions, int version) { - List ret = actions; - String s = null; - try { - s = Highlighting.stripHilights(Action.actionsToString(ret, null, version, false)); - ret = ASMParser.parse(true, new ByteArrayInputStream(s.getBytes()), SWF.DEFAULT_VERSION); - } catch (Exception ex) { - Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "parsing error", ex); - } - return ret; - } - - public static void setConstantPool(List actions, ConstantPool cpool) { - for (Action a : actions) { - if (a instanceof ActionPush) { - if (cpool != null) { - ((ActionPush) a).constantPool = cpool.constants; + //} + if (a.afterInsert != null) { + ret += a.afterInsert.getASMSource(importantOffsets, constantPool, version, hex) + "\r\n"; + } } - } - if (a instanceof ActionDefineFunction) { - if (cpool != null) { - ((ActionDefineFunction) a).setConstantPool(cpool.constants); - } - } - if (a instanceof ActionDefineFunction2) { - if (cpool != null) { - ((ActionDefineFunction2) a).setConstantPool(cpool.constants); - } - } - } - } + offset += a.getBytes(version).length; + } + if (importantOffsets.contains(offset)) { + ret += "loc" + Helper.formatAddress(offset) + ":\r\n"; + } + return ret; + } - public String getASMSourceReplaced(List knownAddreses, List constantPool, int version, boolean hex) { - return getASMSource(knownAddreses, constantPool, version, hex); - } + /** + * Convert action to ASM source + * + * @param knownAddreses List of important offsets to mark as labels + * @param constantPool Constant pool + * @param version SWF version + * @param hex Add hexadecimal + * @return + */ + public String getASMSource(List knownAddreses, List constantPool, int version, boolean hex) { + return toString(); + } + + /** + * Translates this function to stack and output. + * + * @param stack Stack + * @param constants Constant pool + * @param output Output + * @param regNames Register names + */ + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { + } + + /** + * Pops long value off the stack + * + * @param stack Stack + * @return long value + */ + protected long popLong(Stack stack) { + GraphTargetItem item = stack.pop(); + if (item instanceof DirectValueTreeItem) { + if (((DirectValueTreeItem) item).value instanceof Long) { + return (long) (Long) ((DirectValueTreeItem) item).value; + } + } + return 0; + } + + /** + * Converts action index to address in the specified list of actions + * + * @param actions List of actions + * @param ip Action index + * @param version SWF version + * @return address + */ + public static long ip2adr(List actions, int ip, int version) { + if (ip >= actions.size()) { + if (actions.isEmpty()) { + return 0; + } + return actions.get(actions.size() - 1).getAddress() + actions.get(actions.size() - 1).getBytes(version).length; + } + if (ip == -1) { + return 0; + } + return actions.get(ip).getAddress(); + } + + /** + * Converts address to action index in the specified list of actions + * + * @param actions List of actions + * @param addr Address + * @param version SWF version + * @return action index + */ + public static int adr2ip(List actions, long addr, int version) { + for (int ip = 0; ip < actions.size(); ip++) { + if (actions.get(ip).getAddress() == addr) { + return ip; + } + } + if (actions.size() > 0) { + long outpos = actions.get(actions.size() - 1).getAddress() + actions.get(actions.size() - 1).getBytes(version).length; + if (addr == outpos) { + return actions.size(); + } + } + return -1; + } + + /** + * Converts list of actions to ActionScript source code + * + * @param actions List of actions + * @param version SWF version + * @return String with Source code + */ + public static String actionsToSource(List actions, int version) { + try { + //List tree = actionsToTree(new HashMap(), actions, version); + List tree = actionsToTree(new HashMap(), new HashMap(), new HashMap(), actions, version); + + + return Graph.graphToString(tree); + } catch (Exception ex) { + Logger.getLogger(Action.class.getName()).log(Level.SEVERE, null, ex); + return "//Decompilation error :" + ex.getLocalizedMessage(); + } + } + + /** + * Converts list of actions to List of treeItems + * + * @param regNames Register names + * @param actions List of actions + * @param version SWF version + * @return List of treeItems + */ + public static List actionsToTree(HashMap regNames, HashMap variables, HashMap functions, List actions, int version) { + //Stack stack = new Stack(); + return ActionGraph.translateViaGraph(regNames, variables, functions, actions, version); + //return actionsToTree(regNames, stack, actions, 0, actions.size() - 1, version); + } + + @Override + public void translate(List localData, Stack stack, List output) { + translate(stack, output, (HashMap) localData.get(0), (HashMap) localData.get(1), (HashMap) localData.get(2)); + } + + @Override + public boolean isJump() { + return false; + } + + @Override + public boolean isBranch() { + return false; + } + + @Override + public boolean isExit() { + return false; + } + + @Override + public long getOffset() { + return getAddress(); + } + + @Override + public List getBranches(GraphSource code) { + return new ArrayList(); + } + + @Override + public boolean isIgnored() { + return ignored; + } + + @Override + public void setIgnored(boolean ignored) { + this.ignored = ignored; + } + + private static class Loop { + + public long loopContinue; + public long loopBreak; + public int continueCount = 0; + public int breakCount = 0; + + public Loop(long loopContinue, long loopBreak) { + this.loopContinue = loopContinue; + this.loopBreak = loopBreak; + } + + @Override + public String toString() { + return "[Loop continue:" + loopContinue + ", break:" + loopBreak + "]"; + } + } + + private static void log(String s) { + logger.fine(s); + } + + public static List actionsPartToTree(HashMap registerNames, HashMap variables, HashMap functions, Stack stack, List actions, int start, int end, int version) { + if (start < actions.size() && (end > 0) && (start > 0)) { + log("Entering " + start + "-" + end + (actions.size() > 0 ? (" (" + actions.get(start).toString() + " - " + actions.get(end == actions.size() ? end - 1 : end) + ")") : "")); + } + List localData = new ArrayList(); + localData.add(registerNames); + localData.add(variables); + localData.add(functions); + List output = new ArrayList(); + int ip = start; + boolean isWhile = false; + boolean isForIn = false; + GraphTargetItem inItem = null; + int loopStart = 0; + loopip: + while (ip <= end + 1) { + + long addr = ip2adr(actions, ip, version); + /*if (unknownJumps.contains(addr)) { + unknownJumps.remove(new Long(addr)); + boolean switchFound = false; + for (int i = output.size() - 1; i >= 0; i--) { + if (output.get(i) instanceof SwitchTreeItem) { + if (((SwitchTreeItem) output.get(i)).defaultCommands == null) { + List continues = ((SwitchTreeItem) output.get(i)).getContinues(); + boolean breakFound = false; + for (ContinueTreeItem cti : continues) { + if (cti.loopPos == addr) { + cti.isKnown = true; + cti.isBreak = true; + ((SwitchTreeItem) output.get(i)).loopBreak = addr; + breakFound = true; + } + } + if (breakFound) { + switchFound = true; + ((SwitchTreeItem) output.get(i)).defaultCommands = new ArrayList(); + for (int k = i + 1; k < output.size(); k++) { + ((SwitchTreeItem) output.get(i)).defaultCommands.add(output.remove(i + 1)); + } + } + } + break; + } + } + if (!switchFound) { + throw new UnknownJumpException(stack, addr, output); + } + }*/ + if (ip > end) { + break; + } + if (ip >= actions.size()) { + break; + } + Action action = actions.get(ip); + //System.out.println(" ip "+ip+" "+action); + //return in for..in + if ((action instanceof ActionPush) && (((ActionPush) action).values.size() == 1) && (((ActionPush) action).values.get(0) instanceof Null)) { + if (ip + 3 <= end) { + if ((actions.get(ip + 1) instanceof ActionEquals) || (actions.get(ip + 1) instanceof ActionEquals2)) { + if (actions.get(ip + 2) instanceof ActionNot) { + if (actions.get(ip + 3) instanceof ActionIf) { + ActionIf aif = (ActionIf) actions.get(ip + 3); + if (adr2ip(actions, ip2adr(actions, ip + 4, version) + aif.offset, version) == ip) { + ip += 4; + continue; + } + } + } + } + } + } + + /*ActionJump && ActionIf removed*/ + if ((action instanceof ActionEnumerate2) || (action instanceof ActionEnumerate)) { + loopStart = ip + 1; + isForIn = true; + ip += 4; + action.translate(localData, stack, output); + EnumerateTreeItem en = (EnumerateTreeItem) stack.peek(); + inItem = en.object; + continue; + } else if (action instanceof ActionTry) { + ActionTry atry = (ActionTry) action; + List tryCommands = ActionGraph.translateViaGraph(registerNames, variables, functions, atry.tryBody, version); + TreeItem catchName; + if (atry.catchInRegisterFlag) { + catchName = new DirectValueTreeItem(atry, -1, new RegisterNumber(atry.catchRegister), new ArrayList()); + } else { + catchName = new DirectValueTreeItem(atry, -1, atry.catchName, new ArrayList()); + } + List catchExceptions = new ArrayList(); + catchExceptions.add(catchName); + List> catchCommands = new ArrayList>(); + catchCommands.add(ActionGraph.translateViaGraph(registerNames, variables, functions, atry.catchBody, version)); + List finallyCommands = ActionGraph.translateViaGraph(registerNames, variables, functions, atry.finallyBody, version); + output.add(new TryTreeItem(tryCommands, catchExceptions, catchCommands, finallyCommands)); + } else if (action instanceof ActionWith) { + ActionWith awith = (ActionWith) action; + List withCommands = ActionGraph.translateViaGraph(registerNames, variables, functions, awith.actions, version); + output.add(new WithTreeItem(action, stack.pop(), withCommands)); + }/*else if (action instanceof ActionPushDuplicate) { + do { + if (actions.get(ip + 1) instanceof ActionNot) { + if (actions.get(ip + 2) instanceof ActionIf) { + int nextPos = adr2ip(actions, ((ActionIf) actions.get(ip + 2)).getRef(version), version); + stack.push(new AndTreeItem(action, stack.pop(), actionsToStackTree(registerNames, actions, constants, ip + 4, nextPos - 1, version).pop())); + ip = nextPos; + } else { + output.add(new UnsupportedTreeItem(action, "ActionPushDuplicate with Not")); + break; + } + } else if (actions.get(ip + 1) instanceof ActionIf) { + int nextPos = adr2ip(actions, ((ActionIf) actions.get(ip + 1)).getRef(version), version); + stack.push(new OrTreeItem(action, stack.pop(), actionsToStackTree(registerNames, actions, constants, ip + 3, nextPos - 1, version).pop())); + ip = nextPos; + } else { + output.add(new UnsupportedTreeItem(action, "ActionPushDuplicate with no If")); + break loopip; + } + action = actions.get(ip); + } while (action instanceof ActionPushDuplicate); + continue; + }*/ else if (action instanceof ActionStoreRegister) { + if ((ip + 1 <= end) && (actions.get(ip + 1) instanceof ActionPop)) { + action.translate(localData, stack, output); + stack.pop(); + ip++; + } else { + try { + action.translate(localData, stack, output); + } catch (Exception ex) { + //ignore + } + } + } /*else if (action instanceof ActionStrictEquals) { + if ((ip + 1 < actions.size()) && (actions.get(ip + 1) instanceof ActionIf)) { + List caseValues = new ArrayList(); + List> caseCommands = new ArrayList>(); + caseValues.add(stack.pop()); + TreeItem switchedObject = stack.pop(); + if (output.size() > 0) { + if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) { + output.remove(output.size() - 1); + } + } + int caseStart = ip + 2; + List caseBodyIps = new ArrayList(); + long defaultAddr = 0; + caseBodyIps.add(adr2ip(actions, ((ActionIf) actions.get(ip + 1)).getRef(version), version)); + ip++; + do { + ip++; + if ((actions.get(ip - 1) instanceof ActionStrictEquals) && (actions.get(ip) instanceof ActionIf)) { + caseValues.add(actionsToStackTree(registerNames, jumpsOrIfs, actions, constants, caseStart, ip - 2, version).pop()); + caseStart = ip + 1; + caseBodyIps.add(adr2ip(actions, ((ActionIf) actions.get(ip)).getRef(version), version)); + if (actions.get(ip + 1) instanceof ActionJump) { + defaultAddr = ((ActionJump) actions.get(ip + 1)).getRef(version); + ip = adr2ip(actions, defaultAddr, version); + break; + } + } + } while (ip < end); + + for (int i = 0; i < caseBodyIps.size(); i++) { + int caseEnd = ip - 1; + if (i < caseBodyIps.size() - 1) { + caseEnd = caseBodyIps.get(i + 1) - 1; + } + caseCommands.add(actionsToTree(registerNames, unknownJumps, loopList, jumpsOrIfs, stack, constants, actions, caseBodyIps.get(i), caseEnd, version)); + } + output.add(new SwitchTreeItem(action, defaultAddr, switchedObject, caseValues, caseCommands, null)); + continue; + } else { + action.translate(stack, constants, output, registerNames); + } + } */ else { + try { + action.translate(localData, stack, output); + } catch (EmptyStackException ese) { + Logger.getLogger(Action.class.getName()).log(Level.SEVERE, null, ese); + output.add(new UnsupportedTreeItem(action, "Empty stack")); + } + + } + + ip++; + } + //output = checkClass(output); + log("Leaving " + start + "-" + end); + return output; + } + + public static GraphTargetItem getWithoutGlobal(GraphTargetItem ti) { + GraphTargetItem t = ti; + if (!(t instanceof GetMemberTreeItem)) { + return ti; + } + GetMemberTreeItem lastMember = null; + while (((GetMemberTreeItem) t).object instanceof GetMemberTreeItem) { + lastMember = (GetMemberTreeItem) t; + t = ((GetMemberTreeItem) t).object; + } + if (((GetMemberTreeItem) t).object instanceof GetVariableTreeItem) { + GetVariableTreeItem v = (GetVariableTreeItem) ((GetMemberTreeItem) t).object; + if (v.name instanceof DirectValueTreeItem) { + if (((DirectValueTreeItem) v.name).value instanceof String) { + if (((DirectValueTreeItem) v.name).value.equals("_global")) { + GetVariableTreeItem gvt = new GetVariableTreeItem(null, ((GetMemberTreeItem) t).memberName); + if (lastMember == null) { + return gvt; + } else { + lastMember.object = gvt; + } + } + } + } + } + return ti; + } + + public static List checkClass(List output) { + List ret = new ArrayList(); + List functions = new ArrayList(); + List staticFunctions = new ArrayList(); + HashMap vars = new HashMap(); + HashMap staticVars = new HashMap(); + GraphTargetItem className; + GraphTargetItem extendsOp = null; + List implementsOp = new ArrayList(); + boolean ok = true; + int prevCount = 0; + for (GraphTargetItem t : output) { + if (t instanceof IfItem) { + IfItem it = (IfItem) t; + if (it.expression instanceof NotItem) { + NotItem nti = (NotItem) it.expression; + if (nti.value instanceof GetMemberTreeItem) { + if (true) { //it.onFalse.isEmpty()){ //||(it.onFalse.get(0) instanceof UnsupportedTreeItem)) { + if ((it.onTrue.size() == 1) && (it.onTrue.get(0) instanceof SetMemberTreeItem) && (((SetMemberTreeItem) it.onTrue.get(0)).value instanceof NewObjectTreeItem)) { + //ignore + } else { + List parts = it.onTrue; + className = getWithoutGlobal((GetMemberTreeItem) nti.value); + if (parts.size() >= 1) { + if (parts.get(0) instanceof StoreRegisterTreeItem) { + int classReg = ((StoreRegisterTreeItem) parts.get(0)).register.number; + if ((parts.size() >= 2) && (parts.get(1) instanceof SetMemberTreeItem)) { + GraphTargetItem ti1 = ((SetMemberTreeItem) parts.get(1)).value; + GraphTargetItem ti2 = ((StoreRegisterTreeItem) parts.get(0)).value; + if (ti1 == ti2) { + if (((SetMemberTreeItem) parts.get(1)).value instanceof FunctionTreeItem) { + ((FunctionTreeItem) ((SetMemberTreeItem) parts.get(1)).value).calculatedFunctionName = (className instanceof GetMemberTreeItem) ? ((GetMemberTreeItem) className).memberName : className; + functions.add((FunctionTreeItem) ((SetMemberTreeItem) parts.get(1)).value); + int pos = 2; + if (parts.size() <= pos) { + ok = false; + break; + } + + if (parts.get(pos) instanceof ExtendsTreeItem) { + ExtendsTreeItem et = (ExtendsTreeItem) parts.get(pos); + extendsOp = getWithoutGlobal(et.superclass); + pos++; + } + + if (parts.size() <= pos) { + List output2 = new ArrayList(); + for (int i = 0; i < prevCount; i++) { + output2.add(output.get(i)); + } + output2.add(new ClassTreeItem(className, extendsOp, implementsOp, functions, vars, staticFunctions, staticVars)); + return output2; + } + if (parts.get(pos) instanceof StoreRegisterTreeItem) { + int instanceReg = -1; + if (((StoreRegisterTreeItem) parts.get(pos)).value instanceof GetMemberTreeItem) { + GraphTargetItem obj = ((GetMemberTreeItem) ((StoreRegisterTreeItem) parts.get(pos)).value).object; + if (obj instanceof DirectValueTreeItem) { + if (((DirectValueTreeItem) obj).value instanceof RegisterNumber) { + if (((RegisterNumber) ((DirectValueTreeItem) obj).value).number == classReg) { + instanceReg = ((StoreRegisterTreeItem) parts.get(pos)).register.number; + } + } + } + } else if (((StoreRegisterTreeItem) parts.get(pos)).value instanceof NewMethodTreeItem) { + + if (parts.get(pos + 1) instanceof SetMemberTreeItem) { + if (((SetMemberTreeItem) parts.get(pos + 1)).value == ((StoreRegisterTreeItem) parts.get(pos)).value) { + instanceReg = ((StoreRegisterTreeItem) parts.get(pos)).register.number; + NewMethodTreeItem nm = (NewMethodTreeItem) ((StoreRegisterTreeItem) parts.get(pos)).value; + GetMemberTreeItem gm = new GetMemberTreeItem(null, nm.scriptObject, nm.methodName); + extendsOp = gm; + } else { + ok = false; + break; + } + } else { + ok = false; + break; + } + pos++; + } else { + ok = false; + break; + } + if (instanceReg == -1) { + ok = false; + break; + } + pos++; + if (parts.size() <= pos) { + ok = false; + break; + } + if (parts.get(pos) instanceof ImplementsOpTreeItem) { + ImplementsOpTreeItem io = (ImplementsOpTreeItem) parts.get(pos); + implementsOp = io.superclasses; + pos++; + } + while ((parts.size() > pos) && ok) { + if (parts.get(pos) instanceof SetMemberTreeItem) { + SetMemberTreeItem smt = (SetMemberTreeItem) parts.get(pos); + if (smt.object instanceof DirectValueTreeItem) { + if (((DirectValueTreeItem) smt.object).value instanceof RegisterNumber) { + if (((RegisterNumber) ((DirectValueTreeItem) smt.object).value).number == instanceReg) { + if (smt.value instanceof FunctionTreeItem) { + ((FunctionTreeItem) smt.value).calculatedFunctionName = smt.objectName; + functions.add((FunctionTreeItem) smt.value); + } else { + vars.put(smt.objectName, smt.value); + } + } else if (((RegisterNumber) ((DirectValueTreeItem) smt.object).value).number == classReg) { + if (smt.value instanceof FunctionTreeItem) { + ((FunctionTreeItem) smt.value).calculatedFunctionName = smt.objectName; + staticFunctions.add((FunctionTreeItem) smt.value); + } else { + staticVars.put(smt.objectName, smt.value); + } + } else { + ok = false; + } + } + } else { + ok = false; + } + } else if (parts.get(pos) instanceof CallFunctionTreeItem) { + //if(((CallFunctionTreeItem)parts.get(pos)).functionName){ + if (((CallFunctionTreeItem) parts.get(pos)).functionName instanceof DirectValueTreeItem) { + if (((DirectValueTreeItem) ((CallFunctionTreeItem) parts.get(pos)).functionName).value.equals("ASSetPropFlags")) { + } else { + ok = false; + } + } else { + ok = false; + } + + } else { + ok = false; + break; + } + pos++; + } + if (ok) { + List output2 = new ArrayList(); + for (int i = 0; i < prevCount; i++) { + output2.add(output.get(i)); + } + output2.add(new ClassTreeItem(className, extendsOp, implementsOp, functions, vars, staticFunctions, staticVars)); + return output2; + } + } else { + ok = false; + } + } else { + ok = false; + } + } else { + ok = false; + } + } else { + ok = false; + } + } else if (parts.get(0) instanceof SetMemberTreeItem) { + SetMemberTreeItem sm = (SetMemberTreeItem) parts.get(0); + if (sm.value instanceof FunctionTreeItem) { + FunctionTreeItem f = (FunctionTreeItem) sm.value; + if (f.actions.isEmpty()) { + + if (parts.size() == 2) { + if (parts.get(1) instanceof ImplementsOpTreeItem) { + ImplementsOpTreeItem iot = (ImplementsOpTreeItem) parts.get(1); + implementsOp = iot.superclasses; + } else { + ok = false; + break; + } + } + List output2 = new ArrayList(); + for (int i = 0; i < prevCount; i++) { + output2.add(output.get(i)); + } + output2.add(new InterfaceTreeItem(sm.objectName, implementsOp)); + return output2; + } else { + ok = false; + } + } else { + ok = false; + } + } else { + ok = false; + } + } else { + ok = false; + } + } + } else { + ok = false; + } + } else { + ok = false; + } + } else { + ok = false; + } + } else { + prevCount++; + //ok = false; + } + if (!ok) { + break; + } + } + return output; + } + + @Override + public boolean ignoredLoops() { + return false; + } + + public static List removeNops(List actions, int version) { + List ret = actions; + String s = null; + try { + s = Highlighting.stripHilights(Action.actionsToString(ret, null, version, false)); + ret = ASMParser.parse(true, new ByteArrayInputStream(s.getBytes()), SWF.DEFAULT_VERSION); + } catch (Exception ex) { + Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "parsing error", ex); + } + return ret; + } + + public static void setConstantPool(List actions, ConstantPool cpool) { + for (Action a : actions) { + if (a instanceof ActionPush) { + if (cpool != null) { + ((ActionPush) a).constantPool = cpool.constants; + } + } + if (a instanceof ActionDefineFunction) { + if (cpool != null) { + ((ActionDefineFunction) a).setConstantPool(cpool.constants); + } + } + if (a instanceof ActionDefineFunction2) { + if (cpool != null) { + ((ActionDefineFunction2) a).setConstantPool(cpool.constants); + } + } + } + } + + public String getASMSourceReplaced(List knownAddreses, List constantPool, int version, boolean hex) { + return getASMSource(knownAddreses, constantPool, version, hex); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java index 47e889773..01ae0b418 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraph.java @@ -53,919 +53,919 @@ import java.util.Stack; */ public class ActionGraph extends Graph { - public ActionGraph(List code, HashMap registerNames, HashMap variables, HashMap functions, int version) { - super(new ActionGraphSource(code, version, registerNames, variables, functions), new ArrayList()); - //this.version = version; + public ActionGraph(List code, HashMap registerNames, HashMap variables, HashMap functions, int version) { + super(new ActionGraphSource(code, version, registerNames, variables, functions), new ArrayList()); + //this.version = version; /*heads = makeGraph(code, new ArrayList()); - for (GraphPart head : heads) { - fixGraph(head); - makeMulti(head, new ArrayList()); - }*/ - } - - public static List translateViaGraph(HashMap registerNames, HashMap variables, HashMap functions, List code, int version) { - ActionGraph g = new ActionGraph(code, registerNames, variables, functions, version); - List localData = new ArrayList(); - localData.add(registerNames); - return g.translate(localData); - } - - @Override - public void finalProcessStack(Stack stack, List output) { - if (stack.size() > 0) { - for (int i = stack.size() - 1; i >= 0; i--) { - //System.err.println(stack.get(i)); - if (stack.get(i) instanceof FunctionTreeItem) { - FunctionTreeItem f = (FunctionTreeItem) stack.remove(i); - if (!output.contains(f)) { - output.add(0, f); - } - } - } - } - } - - @Override - protected void finalProcess(List list, int level) { - List ret = Action.checkClass(list); - if (ret != list) { - list.clear(); - list.addAll(ret); - } - for (int t = 0; t < list.size(); t++) { - GraphTargetItem it = list.get(t); - if (it instanceof WhileItem) { - WhileItem wi = (WhileItem) it; - if ((!wi.commands.isEmpty()) && (wi.commands.get(0) instanceof SetTypeTreeItem)) { - SetTypeTreeItem sti = (SetTypeTreeItem) wi.commands.get(0); - if (wi.expression instanceof NeqTreeItem) { - NeqTreeItem ne = (NeqTreeItem) wi.expression; - if (ne.rightSide instanceof DirectValueTreeItem) { - DirectValueTreeItem dv = (DirectValueTreeItem) ne.rightSide; - if (dv.value instanceof Null) { - if (ne.leftSide instanceof EnumerateTreeItem) { - EnumerateTreeItem eti = (EnumerateTreeItem) ne.leftSide; - list.remove(t); - wi.commands.remove(0); - list.add(t, new ForInTreeItem(null, wi.loop, sti.getObject(), eti.object, wi.commands)); - } - } - } - } - } - - } - } - } - - @Override - protected List check(GraphSource code, List localData, List allParts, Stack stack, GraphPart parent, GraphPart part, GraphPart stopPart, List loops, List output, HashMap> forFinalCommands) { - if (!output.isEmpty()) { - if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) { - StoreRegisterTreeItem str = (StoreRegisterTreeItem) output.get(output.size() - 1); - if (str.value instanceof EnumerateTreeItem) { - output.remove(output.size() - 1); - } - } - } - List ret = null; - if ((part.nextParts.size() == 2) && (!stack.isEmpty()) && (stack.peek() instanceof StrictEqTreeItem)) { - - GraphTargetItem switchedObject = null; - if (!output.isEmpty()) { - if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) { - switchedObject = ((StoreRegisterTreeItem) output.get(output.size() - 1)).value; - } - } - if (switchedObject == null) { - switchedObject = new DirectValueTreeItem(null, -1, new Null(), null); - } - HashMap caseValuesMap = new HashMap(); - - int pos = 0; - StrictEqTreeItem set = (StrictEqTreeItem) stack.pop(); - caseValuesMap.put(pos, set.rightSide); - - //GraphPart switchLoc = part.nextParts.get(1).nextParts.get(0); - List caseBodyParts = new ArrayList(); - caseBodyParts.add(part.nextParts.get(0)); - GraphTargetItem top = null; - int cnt = 1; - while (part.nextParts.size() > 1 - && part.nextParts.get(1).getHeight() > 1 - && code.get(part.nextParts.get(1).end) instanceof ActionIf - && ((top = translatePartGetStack(localData, part.nextParts.get(1), stack)) instanceof StrictEqTreeItem)) { - cnt++; - part = part.nextParts.get(1); - pos++; - caseBodyParts.add(part.nextParts.get(0)); - - set = (StrictEqTreeItem) top; - caseValuesMap.put(pos, set.rightSide); - } - if (cnt == 1) { - stack.push(set); - } else { - part = part.nextParts.get(1); - - GraphPart defaultPart = part; - //caseBodyParts.add(defaultPart); - - - - List defaultAndLastPart = new ArrayList(); - defaultAndLastPart.add(defaultPart); - defaultAndLastPart.add(caseBodyParts.get(caseBodyParts.size() - 1)); - - GraphPart defaultPart2 = getCommonPart(defaultAndLastPart); - - List defaultCommands = new ArrayList(); - - defaultCommands = printGraph(localData, stack, allParts, null, defaultPart, defaultPart2, loops, forFinalCommands); - - - List loopContinues = new ArrayList(); - for (Loop l : loops) { - if (l.loopContinue != null) { - loopContinues.add(l.loopContinue); - } - } - - List breakParts = new ArrayList(); - for (int g = 0; g < caseBodyParts.size(); g++) { - if (g < caseBodyParts.size() - 1) { - if (caseBodyParts.get(g).leadsTo(code, caseBodyParts.get(g + 1), loopContinues)) { - continue; - } - } - GraphPart nsp = caseBodyParts.get(g).getNextSuperPartPath(loopContinues); - if (nsp != null) { - breakParts.add(nsp); - } - } - Collections.sort(breakParts, new Comparator() { - @Override - public int compare(GraphPart o1, GraphPart o2) { - return o2.path.length() - o1.path.length(); - } - }); - - GraphPart breakPart = breakParts.isEmpty() ? null : breakParts.get(0); - if ((defaultPart2 != breakPart) && (defaultCommands.isEmpty())) { - defaultPart = defaultPart2; - } - - - List caseValues = new ArrayList(); - for (int i = 0; i < caseBodyParts.size(); i++) { - if (caseValuesMap.containsKey(i)) { - caseValues.add(caseValuesMap.get(i)); - } else { - continue; - } - } - - List> caseCommands = new ArrayList>(); - GraphPart next = null; - - - - next = breakPart; - - GraphTargetItem ti = checkLoop(next, stopPart, loops); - Loop currentLoop = new Loop(loops.size(), null, next); - loops.add(currentLoop); - //switchLoc.getNextPartPath(new ArrayList()); - List valuesMapping = new ArrayList(); - List caseBodies = new ArrayList(); - for (int i = 0; i < caseValues.size(); i++) { - GraphPart cur = caseBodyParts.get(i); - if (!caseBodies.contains(cur)) { - caseBodies.add(cur); - } - valuesMapping.add(caseBodies.indexOf(cur)); - } - - - - - if (defaultPart == breakPart) { - defaultPart = null; - } - if ((defaultPart != null) && (defaultCommands.isEmpty())) { - defaultCommands = printGraph(localData, stack, allParts, null, defaultPart, next, loops, forFinalCommands); - } - - List ignored = new ArrayList(); - for (Loop l : loops) { - ignored.add(l.loopContinue); - } - - for (int i = 0; i < caseBodies.size(); i++) { - List cc = new ArrayList(); - GraphPart nextCase = null; - nextCase = next; - if (next != null) { - if (i < caseBodies.size() - 1) { - if (!caseBodies.get(i).leadsTo(code, caseBodies.get(i + 1), ignored)) { - cc.add(new BreakItem(null, currentLoop.id)); - } else { - nextCase = caseBodies.get(i + 1); - } - } else if (!defaultCommands.isEmpty()) { - if (!caseBodies.get(i).leadsTo(code, defaultPart, ignored)) { - cc.add(new BreakItem(null, currentLoop.id)); - } else { - nextCase = defaultPart; - } - } - } - cc.addAll(0, printGraph(localData, stack, allParts, null, caseBodies.get(i), nextCase, loops, forFinalCommands)); - if (cc.size() >= 2) { - if (cc.get(cc.size() - 1) instanceof BreakItem) { - if ((cc.get(cc.size() - 2) instanceof ContinueItem) || (cc.get(cc.size() - 2) instanceof BreakItem)) { - cc.remove(cc.size() - 1); - } - } - } - caseCommands.add(cc); - } - ret = new ArrayList(); - if (!output.isEmpty()) { - if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) { - output.remove(output.size() - 1); - } - } - ret.addAll(output); - SwitchItem sti = new SwitchItem(null, currentLoop, switchedObject, caseValues, caseCommands, defaultCommands, valuesMapping); - ret.add(sti); - - if (next != null) { - if (ti != null) { - ret.add(ti); - } else { - ret.addAll(printGraph(localData, stack, allParts, null, next, stopPart, loops, forFinalCommands)); - } - } - } - } - return ret; - } - /* - private TreeItem translatePartGetStack(GraphPart part, Stack stack, HashMap registerNames) { - stack = (Stack) stack.clone(); - translatePart(part, stack, registerNames); - return stack.pop(); + for (GraphPart head : heads) { + fixGraph(head); + makeMulti(head, new ArrayList()); + }*/ } - private List translatePart(GraphPart part, Stack stack, HashMap registerNames) { - List sub = part.getSubParts(); - List ret = new ArrayList(); - int end = 0; - for (GraphPart p : sub) { - if (p.end == -1) { - p.end = code.size() - 1; - } - if (p.start == code.size()) { - continue; - } else if (p.end == code.size()) { - p.end--; - } - end = p.end; - int start = p.start; - if (code.get(end) instanceof ActionJump) { - end--; - } else if (code.get(end) instanceof ActionIf) { - end--; - } - ret.addAll(Action.actionsPartToTree(registerNames, stack, code, start, end, version)); - } - return ret; + public static List translateViaGraph(HashMap registerNames, HashMap variables, HashMap functions, List code, int version) { + ActionGraph g = new ActionGraph(code, registerNames, variables, functions, version); + List localData = new ArrayList(); + localData.add(registerNames); + return g.translate(localData); } - private TreeItem checkLoop(GraphPart part, GraphPart stopPart, List loops) { - if (part == stopPart) { - return null; - } - for (Loop l : loops) { - if (l.loopContinue == part) { - return (new ContinueTreeItem(null, l.loopBreak == null ? -1 : l.loopBreak.start)); - } - if (l.loopBreak == part) { - return (new BreakTreeItem(null, part.start)); - } - } - return null; - } - private boolean doDecompile = true; - - private List printGraph(HashMap registerNames, Stack stack, List allParts, GraphPart parent, GraphPart part, GraphPart stopPart, List loops, HashMap> forFinalCommands) { - List ret = new ArrayList(); - boolean debugMode = false; - if (part.start >= code.size()) { - return ret; - } - - if (!doDecompile) { - // ret.add(new CommentTreeItem(null, "not decompiled")); - return ret; - } - - if (debugMode) { - System.err.println("PART " + part); - } - - if (part == stopPart) { - return ret; - } - if (part.ignored) { - return ret; - } - List fqn = new ArrayList(); - HashMap lrn = new HashMap(); - List output = new ArrayList(); - boolean isSwitch = false; - List parts = new ArrayList(); - if (part instanceof GraphPartMulti) { - parts = ((GraphPartMulti) part).parts; - } else { - parts.add(part); - } - boolean isIf = false; - int end = part.end; - if (end == -1) { - end = code.size() - 1; - } - if (end == code.size()) { - end--; - } - output.addAll(translatePart(part, stack, registerNames)); - if (end > -1) { - if (code.get(end) instanceof ActionJump) { - end--; - } else if (code.get(end) instanceof ActionIf) { - end--; - isIf = true; - } - } - if (isIf) { - Action ins = code.get(end + 1); - if ((stack.size() >= 2) && (stack.get(stack.size() - 1) instanceof NotTreeItem) && (((NotTreeItem) stack.get(stack.size() - 1)).value == stack.get(stack.size() - 2))) { - ret.addAll(output); - printGraph(registerNames, stack, allParts, parent, part.nextParts.get(1), part.nextParts.get(0), loops, forFinalCommands); - TreeItem second = stack.pop(); - TreeItem first = stack.pop(); - stack.push(new AndTreeItem(ins, first, second)); - ret.addAll(printGraph(registerNames, stack, allParts, parent, part.nextParts.get(0), stopPart, loops, forFinalCommands)); - return ret; - } else if ((stack.size() >= 2) && (stack.get(stack.size() - 1) == stack.get(stack.size() - 2))) { - ret.addAll(output); - printGraph(registerNames, stack, allParts, parent, part.nextParts.get(1), part.nextParts.get(0), loops, forFinalCommands); - TreeItem second = stack.pop(); - TreeItem first = stack.pop(); - stack.push(new OrTreeItem(ins, first, second)); - ret.addAll(printGraph(registerNames, stack, allParts, parent, part.nextParts.get(0), stopPart, loops, forFinalCommands)); - return ret; - } else if (stack.peek() instanceof StrictEqTreeItem) { - - TreeItem switchedObject = null; - if (!output.isEmpty()) { - if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) { - switchedObject = ((StoreRegisterTreeItem) output.get(output.size() - 1)).value; - } - } - if (switchedObject == null) { - switchedObject = new DirectValueTreeItem(null, -1, new Null(), null); - } - HashMap caseValuesMap = new HashMap(); - - int pos = 0; - StrictEqTreeItem set = (StrictEqTreeItem) stack.pop(); - caseValuesMap.put(pos, set.rightSide); - - //GraphPart switchLoc = part.nextParts.get(1).nextParts.get(0); - List caseBodyParts = new ArrayList(); - caseBodyParts.add(part.nextParts.get(0)); - TreeItem top = null; - int cnt = 1; - while (part.nextParts.size() > 1 - && part.nextParts.get(1).getHeight() > 1 - && code.get(part.nextParts.get(1).end) instanceof ActionIf - && ((top = translatePartGetStack(part.nextParts.get(1), stack, registerNames)) instanceof StrictEqTreeItem)) { - cnt++; - part = part.nextParts.get(1); - pos++; - caseBodyParts.add(part.nextParts.get(0)); - - set = (StrictEqTreeItem) top; - caseValuesMap.put(pos, set.rightSide); - } - if (cnt == 1) { - stack.push(set); - } else { - part = part.nextParts.get(1); - - GraphPart defaultPart = part; - //caseBodyParts.add(defaultPart); - - - - List defaultAndLastPart = new ArrayList(); - defaultAndLastPart.add(defaultPart); - defaultAndLastPart.add(caseBodyParts.get(caseBodyParts.size() - 1)); - - GraphPart defaultPart2 = getCommonPart(defaultAndLastPart); - - List defaultCommands = new ArrayList(); - - defaultCommands = printGraph(registerNames, stack, allParts, null, defaultPart, defaultPart2, loops, forFinalCommands); - - - List loopContinues = new ArrayList(); - for (Loop l : loops) { - if (l.loopContinue != null) { - loopContinues.add(l.loopContinue); - } - } - - List breakParts = new ArrayList(); - for (int g = 0; g < caseBodyParts.size(); g++) { - if (g < caseBodyParts.size() - 1) { - if (caseBodyParts.get(g).leadsTo(caseBodyParts.get(g + 1), loopContinues)) { - continue; - } - } - GraphPart nsp = caseBodyParts.get(g).getNextSuperPartPath(loopContinues); - if (nsp != null) { - breakParts.add(nsp); - } - } - Collections.sort(breakParts, new Comparator() { @Override - public int compare(GraphPart o1, GraphPart o2) { - return o2.path.length() - o1.path.length(); - } - }); - - GraphPart breakPart = breakParts.isEmpty() ? null : breakParts.get(0); - if ((defaultPart2 != breakPart) && (defaultCommands.isEmpty())) { - defaultPart = defaultPart2; - } - - - List caseValues = new ArrayList(); - for (int i = 0; i < caseBodyParts.size(); i++) { - if (caseValuesMap.containsKey(i)) { - caseValues.add(caseValuesMap.get(i)); - } else { - continue; - } - } - - List> caseCommands = new ArrayList>(); - GraphPart next = null; - - - - next = breakPart; - - TreeItem ti = checkLoop(next, stopPart, loops); - loops.add(new Loop(null, next)); - //switchLoc.getNextPartPath(new ArrayList()); - List valuesMapping = new ArrayList(); - List caseBodies = new ArrayList(); - for (int i = 0; i < caseValues.size(); i++) { - GraphPart cur = caseBodyParts.get(i); - if (!caseBodies.contains(cur)) { - caseBodies.add(cur); - } - valuesMapping.add(caseBodies.indexOf(cur)); - } - - - - - if (defaultPart == breakPart) { - defaultPart = null; - } - if ((defaultPart != null) && (defaultCommands.isEmpty())) { - defaultCommands = printGraph(registerNames, stack, allParts, null, defaultPart, next, loops, forFinalCommands); - } - - List ignored = new ArrayList(); - for (Loop l : loops) { - ignored.add(l.loopContinue); - } - - for (int i = 0; i < caseBodies.size(); i++) { - List cc = new ArrayList(); - GraphPart nextCase = null; - nextCase = next; - if (next != null) { - if (i < caseBodies.size() - 1) { - if (!caseBodies.get(i).leadsTo(caseBodies.get(i + 1), ignored)) { - cc.add(new BreakTreeItem(null, next.start)); - } else { - nextCase = caseBodies.get(i + 1); - } - } else if (!defaultCommands.isEmpty()) { - if (!caseBodies.get(i).leadsTo(defaultPart, ignored)) { - cc.add(new BreakTreeItem(null, next.start)); - } else { - nextCase = defaultPart; - } - } - } - cc.addAll(0, printGraph(registerNames, stack, allParts, null, caseBodies.get(i), nextCase, loops, forFinalCommands)); - if (cc.size() >= 2) { - if (cc.get(cc.size() - 1) instanceof BreakTreeItem) { - if ((cc.get(cc.size() - 2) instanceof ContinueTreeItem) || (cc.get(cc.size() - 2) instanceof BreakTreeItem)) { - cc.remove(cc.size() - 1); - } - } - } - caseCommands.add(cc); - } - - SwitchTreeItem sti = new SwitchTreeItem(null, next == null ? -1 : next.start, switchedObject, caseValues, caseCommands, defaultCommands, valuesMapping); - ret.add(sti); - - if (next != null) { - if (ti != null) { - ret.add(ti); - } else { - ret.addAll(printGraph(registerNames, stack, allParts, null, next, stopPart, loops, forFinalCommands)); - } - } - return ret; - } - } else { - //ins.translate - } - //((IfTypeIns)ins.definition).translateInverted(new HashMap(), co.stack, ins); - } - - int ip = part.start; - List loopContinues = new ArrayList(); - for (Loop l : loops) { - if (l.loopContinue != null) { - loopContinues.add(l.loopContinue); - } - } - boolean loop = false; - boolean reversed = false; - if ((!part.nextParts.isEmpty()) && part.nextParts.get(0).leadsTo(part, loopContinues)) { - loop = true; - } else if ((part.nextParts.size() > 1) && part.nextParts.get(1).leadsTo(part, loopContinues)) { - loop = true; - reversed = true; - } - if (((part.nextParts.size() == 2) || ((part.nextParts.size() == 1) && loop)) && (!isSwitch)) { - - boolean doWhile = loop; - if (loop && output.isEmpty()) { - doWhile = false; - } - Loop currentLoop = new Loop(part, null); - if (loop) { - loops.add(currentLoop); - } - - - - loopContinues = new ArrayList(); - for (Loop l : loops) { - if (l.loopContinue != null) { - loopContinues.add(l.loopContinue); - } - } - - if (part.nextParts.size() > 1) { - currentLoop.loopBreak = part.nextParts.get(reversed ? 0 : 1); - } - - forFinalCommands.put(currentLoop, new ArrayList()); - - int breakIp = -1; - if (currentLoop.loopBreak != null) { - breakIp = currentLoop.loopBreak.start; - } - TreeItem expr = null; - if ((code.get(part.end) instanceof ActionJump) || (!(code.get(part.end) instanceof ActionIf))) { - expr = new DirectValueTreeItem(null, -1, (Boolean) true, new ArrayList()); - } else { - if (stack.isEmpty()) { - } - expr = stack.pop(); - } - if (doWhile) { - ret.add(new DoWhileTreeItem(null, breakIp, part.start, output, expr)); - } else { - ret.addAll(output); - } - - GraphPart next = part.getNextPartPath(loopContinues); - - if (loop && (!doWhile)) { - - if (reversed && (expr instanceof LogicalOp)) { - expr = ((LogicalOp) expr).invert(); - } - List loopBody = null; - List finalCommands = null; - GraphPart finalPart = null; - loopBody = printGraph(registerNames, stack, allParts, part, part.nextParts.get(reversed ? 1 : 0), stopPart, loops, forFinalCommands); - - finalCommands = forFinalCommands.get(currentLoop); - if (!finalCommands.isEmpty()) { - ret.add(new ForTreeItem(null, breakIp, currentLoop.loopContinue.start, new ArrayList(), expr, finalCommands, loopBody)); - } else { - ret.add(new WhileTreeItem(null, breakIp, part.start, expr, loopBody)); - } - } else if (!loop) { - if (expr instanceof LogicalOp) { - expr = ((LogicalOp) expr).invert(); - } else { - expr = new NotTreeItem(null, expr); - } - - int stackSizeBefore = stack.size(); - Stack trueStack = (Stack) stack.clone(); - Stack falseStack = (Stack) stack.clone(); - TreeItem lopTrue = checkLoop(part.nextParts.get(1), stopPart, loops); - TreeItem lopFalse = null; - if (next != part.nextParts.get(0)) { - lopFalse = checkLoop(part.nextParts.get(0), stopPart, loops); - } - List onTrue = new ArrayList(); - if (lopTrue != null) { - onTrue.add(lopTrue); - } else { - if (debugMode) { - System.err.println("ONTRUE: (inside " + part + ")"); - } - onTrue = printGraph(registerNames, trueStack, allParts, part, part.nextParts.get(1), next == null ? stopPart : next, loops, forFinalCommands); - if (debugMode) { - System.err.println("/ONTRUE (inside " + part + ")"); - } - } - List onFalse = new ArrayList(); - if (lopFalse != null) { - onFalse.add(lopFalse); - } else { - if (debugMode) { - System.err.println("ONFALSE: (inside " + part + ")"); - } - onFalse = (((next == part.nextParts.get(0)) || (part.nextParts.get(0).path.equals(part.path) || part.nextParts.get(0).path.length() < part.path.length())) ? new ArrayList() : printGraph(registerNames, falseStack, allParts, part, part.nextParts.get(0), next == null ? stopPart : next, loops, forFinalCommands)); - if (debugMode) { - System.err.println("/ONFALSE (inside " + part + ")"); - } - } - - if (onTrue.isEmpty() && onFalse.isEmpty() && (trueStack.size() > stackSizeBefore) && (falseStack.size() > stackSizeBefore)) { - stack.push(new TernarOpTreeItem(null, expr, trueStack.pop(), falseStack.pop())); - } else { - ret.add(new IfTreeItem(null, expr, onTrue, onFalse)); - - //Same continues in onTrue and onFalse gets continue on parent level - if ((!onTrue.isEmpty()) && (!onFalse.isEmpty())) { - if (onTrue.get(onTrue.size() - 1) instanceof ContinueTreeItem) { - if (onFalse.get(onFalse.size() - 1) instanceof ContinueTreeItem) { - if (((ContinueTreeItem) onTrue.get(onTrue.size() - 1)).loopPos == ((ContinueTreeItem) onFalse.get(onFalse.size() - 1)).loopPos) { - onTrue.remove(onTrue.size() - 1); - ret.add(onFalse.remove(onFalse.size() - 1)); - } - } - } - } - } - } - if (loop && (part.nextParts.size() > 1)) { - loops.remove(currentLoop); //remove loop so no break shows up - ret.addAll(printGraph(registerNames, stack, allParts, part, part.nextParts.get(reversed ? 0 : 1), stopPart, loops, forFinalCommands)); - } - - if (next != null) { - TreeItem ti = checkLoop(next, stopPart, loops); - if (ti != null) { - ret.add(ti); - } else { - if (debugMode) { - System.err.println("NEXT: (inside " + part + ")"); - } - ret.addAll(printGraph(registerNames, stack, allParts, part, next, stopPart, loops, forFinalCommands)); - if (debugMode) { - System.err.println("/NEXT: (inside " + part + ")"); - } - } - - } - } else { - ret.addAll(output); - } - onepart: - if (part.nextParts.size() == 1 && (!loop)) { - - - GraphPart p = part.nextParts.get(0); - TreeItem lop = checkLoop(p, stopPart, loops); - if (lop == null) { - if (p.path.length() == part.path.length()) { - ret.addAll(printGraph(registerNames, stack, allParts, part, p, stopPart, loops, forFinalCommands)); - } else { - if ((p != stopPart) && (p.refs.size() > 1)) { - List nextList = new ArrayList(); - populateParts(p, nextList); - Loop nearestLoop = null; - loopn: - for (GraphPart n : nextList) { - for (Loop l : loops) { - if (l.loopContinue == n) { - nearestLoop = l; - break loopn; - } - } - } - if ((nearestLoop != null) && (nearestLoop.loopBreak != null)) { - List finalCommands = printGraph(registerNames, stack, allParts, part, p, nearestLoop.loopContinue, loops, forFinalCommands); - nearestLoop.loopContinue = p; - forFinalCommands.put(nearestLoop, finalCommands); - ContinueTreeItem cti = new ContinueTreeItem(null, nearestLoop.loopBreak.start); - ret.add(cti); - } - } - } - } else { - ret.add(lop); - } - } - return ret; - } - private List posCache; - - private void buildCache() { - posCache = new ArrayList(); - int pos = 0; - for (int i = 0; i < code.size(); i++) { - posCache.add(pos); - pos += code.get(i).getBytes(version).length; - } - posCache.add(pos); - } - - private int pos2adr(int pos) { - if (posCache == null) { - buildCache(); - } - return posCache.get(pos); - } - - private int adr2pos(int adr) { - if (posCache == null) { - buildCache(); - } - return posCache.indexOf(adr); - } - - private void visitCode(int ip, int lastIp, HashMap> refs) { - while (ip < code.size()) { - refs.get(ip).add(lastIp); - lastIp = ip; - if (refs.get(ip).size() > 1) { - break; - } - Action ins = code.get(ip); - if (ins instanceof ActionThrow) { - break; - } - if (ins instanceof ActionReturn) { - break; - } - - if (ins instanceof ActionJump) { - ip = adr2pos(pos2adr(ip) + ins.getBytes(version).length + ((ActionJump) ins).offset); - continue; - } else if (ins instanceof ActionIf) { - visitCode(adr2pos(pos2adr(ip) + ins.getBytes(version).length + ((ActionIf) ins).offset), ip, refs); - } - ip++; - }; - } - - public HashMap> visitCode() { - HashMap> refs = new HashMap>(); - for (int i = 0; i < code.size(); i++) { - refs.put(i, new ArrayList()); - } - visitCode(0, 0, refs); - return refs; - } - - private List makeGraph(List actions, List allBlocks) { - HashMap> refs = visitCode(); - List ret = new ArrayList(); - boolean visited[] = new boolean[code.size()]; - ret.add(makeGraph(null, "0", code, 0, 0, allBlocks, refs, visited)); - return ret; - } - - private GraphPart makeGraph(GraphPart parent, String path, List code, int startip, int lastIp, List allBlocks, HashMap> refs, boolean visited2[]) { - - int ip = startip; - for (GraphPart p : allBlocks) { - if (p.start == ip) { - p.refs.add(parent); - return p; - } - } - GraphPart g; - GraphPart ret = new GraphPart(ip, -1); - ret.path = path; - GraphPart part = ret; - while (ip < code.size()) { - if (visited2[ip] || ((ip != startip) && (refs.get(ip).size() > 1))) { - part.end = lastIp; - GraphPart found = null; - for (GraphPart p : allBlocks) { - if (p.start == ip) { - found = p; - break; - } - } - - allBlocks.add(part); - - if (found != null) { - part.nextParts.add(found); - found.refs.add(part); - break; - } else { - GraphPart gp = new GraphPart(ip, -1); - gp.path = path; - part.nextParts.add(gp); - gp.refs.add(part); - part = gp; - } - } - lastIp = ip; - Action ins = code.get(ip); - if ((ins instanceof ActionThrow) || (ins instanceof ActionReturn)) { - part.end = ip; - allBlocks.add(part); - break; - } - if (ins instanceof ActionJump) { - part.end = ip; - allBlocks.add(part); - int newip = adr2pos(pos2adr(ip) + ins.getBytes(version).length + ((ActionJump) ins).offset); - part.nextParts.add(g = makeGraph(part, path, code, newip, lastIp, allBlocks, refs, visited2)); - g.refs.add(part); - break; - } else if (ins instanceof ActionIf) { - part.end = ip; - allBlocks.add(part); - part.nextParts.add(g = makeGraph(part, path + "0", code, adr2pos(pos2adr(ip) + ins.getBytes(version).length + ((ActionIf) ins).offset), ip, allBlocks, refs, visited2)); - g.refs.add(part); - part.nextParts.add(g = makeGraph(part, path + "1", code, ip + 1, ip, allBlocks, refs, visited2)); - g.refs.add(part); - - break; - } - ip++; - }; - if (ip == code.size()) { - allBlocks.add(part); - if (part.start == ip) { - part.end = ip; - } else { - part.end = code.size() - 1; - part.nextParts.add(makeGraph(part, path, code, ip, ip, allBlocks, refs, visited2)); - } - - } - return ret; - } - */ - - @Override - protected int checkIp(int ip) { - - //return in for..in - GraphSourceItem action = code.get(ip); - if ((action instanceof ActionPush) && (((ActionPush) action).values.size() == 1) && (((ActionPush) action).values.get(0) instanceof Null)) { - if (ip + 3 < code.size()) { - if ((code.get(ip + 1) instanceof ActionEquals) || (code.get(ip + 1) instanceof ActionEquals2)) { - if (code.get(ip + 2) instanceof ActionNot) { - if (code.get(ip + 3) instanceof ActionIf) { - ActionIf aif = (ActionIf) code.get(ip + 3); - if (code.adr2pos(code.pos2adr(ip + 4) + aif.offset) == ip) { - ip += 4; - } - } - } + public void finalProcessStack(Stack stack, List output) { + if (stack.size() > 0) { + for (int i = stack.size() - 1; i >= 0; i--) { + //System.err.println(stack.get(i)); + if (stack.get(i) instanceof FunctionTreeItem) { + FunctionTreeItem f = (FunctionTreeItem) stack.remove(i); + if (!output.contains(f)) { + output.add(0, f); + } + } } - } - } - return ip; - } + } + } + + @Override + protected void finalProcess(List list, int level) { + List ret = Action.checkClass(list); + if (ret != list) { + list.clear(); + list.addAll(ret); + } + for (int t = 0; t < list.size(); t++) { + GraphTargetItem it = list.get(t); + if (it instanceof WhileItem) { + WhileItem wi = (WhileItem) it; + if ((!wi.commands.isEmpty()) && (wi.commands.get(0) instanceof SetTypeTreeItem)) { + SetTypeTreeItem sti = (SetTypeTreeItem) wi.commands.get(0); + if (wi.expression instanceof NeqTreeItem) { + NeqTreeItem ne = (NeqTreeItem) wi.expression; + if (ne.rightSide instanceof DirectValueTreeItem) { + DirectValueTreeItem dv = (DirectValueTreeItem) ne.rightSide; + if (dv.value instanceof Null) { + if (ne.leftSide instanceof EnumerateTreeItem) { + EnumerateTreeItem eti = (EnumerateTreeItem) ne.leftSide; + list.remove(t); + wi.commands.remove(0); + list.add(t, new ForInTreeItem(null, wi.loop, sti.getObject(), eti.object, wi.commands)); + } + } + } + } + } + + } + } + } + + @Override + protected List check(GraphSource code, List localData, List allParts, Stack stack, GraphPart parent, GraphPart part, GraphPart stopPart, List loops, List output, HashMap> forFinalCommands) { + if (!output.isEmpty()) { + if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) { + StoreRegisterTreeItem str = (StoreRegisterTreeItem) output.get(output.size() - 1); + if (str.value instanceof EnumerateTreeItem) { + output.remove(output.size() - 1); + } + } + } + List ret = null; + if ((part.nextParts.size() == 2) && (!stack.isEmpty()) && (stack.peek() instanceof StrictEqTreeItem)) { + + GraphTargetItem switchedObject = null; + if (!output.isEmpty()) { + if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) { + switchedObject = ((StoreRegisterTreeItem) output.get(output.size() - 1)).value; + } + } + if (switchedObject == null) { + switchedObject = new DirectValueTreeItem(null, -1, new Null(), null); + } + HashMap caseValuesMap = new HashMap(); + + int pos = 0; + StrictEqTreeItem set = (StrictEqTreeItem) stack.pop(); + caseValuesMap.put(pos, set.rightSide); + + //GraphPart switchLoc = part.nextParts.get(1).nextParts.get(0); + List caseBodyParts = new ArrayList(); + caseBodyParts.add(part.nextParts.get(0)); + GraphTargetItem top = null; + int cnt = 1; + while (part.nextParts.size() > 1 + && part.nextParts.get(1).getHeight() > 1 + && code.get(part.nextParts.get(1).end) instanceof ActionIf + && ((top = translatePartGetStack(localData, part.nextParts.get(1), stack)) instanceof StrictEqTreeItem)) { + cnt++; + part = part.nextParts.get(1); + pos++; + caseBodyParts.add(part.nextParts.get(0)); + + set = (StrictEqTreeItem) top; + caseValuesMap.put(pos, set.rightSide); + } + if (cnt == 1) { + stack.push(set); + } else { + part = part.nextParts.get(1); + + GraphPart defaultPart = part; + //caseBodyParts.add(defaultPart); + + + + List defaultAndLastPart = new ArrayList(); + defaultAndLastPart.add(defaultPart); + defaultAndLastPart.add(caseBodyParts.get(caseBodyParts.size() - 1)); + + GraphPart defaultPart2 = getCommonPart(defaultAndLastPart); + + List defaultCommands = new ArrayList(); + + defaultCommands = printGraph(localData, stack, allParts, null, defaultPart, defaultPart2, loops, forFinalCommands); + + + List loopContinues = new ArrayList(); + for (Loop l : loops) { + if (l.loopContinue != null) { + loopContinues.add(l.loopContinue); + } + } + + List breakParts = new ArrayList(); + for (int g = 0; g < caseBodyParts.size(); g++) { + if (g < caseBodyParts.size() - 1) { + if (caseBodyParts.get(g).leadsTo(code, caseBodyParts.get(g + 1), loopContinues)) { + continue; + } + } + GraphPart nsp = caseBodyParts.get(g).getNextSuperPartPath(loopContinues); + if (nsp != null) { + breakParts.add(nsp); + } + } + Collections.sort(breakParts, new Comparator() { + @Override + public int compare(GraphPart o1, GraphPart o2) { + return o2.path.length() - o1.path.length(); + } + }); + + GraphPart breakPart = breakParts.isEmpty() ? null : breakParts.get(0); + if ((defaultPart2 != breakPart) && (defaultCommands.isEmpty())) { + defaultPart = defaultPart2; + } + + + List caseValues = new ArrayList(); + for (int i = 0; i < caseBodyParts.size(); i++) { + if (caseValuesMap.containsKey(i)) { + caseValues.add(caseValuesMap.get(i)); + } else { + continue; + } + } + + List> caseCommands = new ArrayList>(); + GraphPart next = null; + + + + next = breakPart; + + GraphTargetItem ti = checkLoop(next, stopPart, loops); + Loop currentLoop = new Loop(loops.size(), null, next); + loops.add(currentLoop); + //switchLoc.getNextPartPath(new ArrayList()); + List valuesMapping = new ArrayList(); + List caseBodies = new ArrayList(); + for (int i = 0; i < caseValues.size(); i++) { + GraphPart cur = caseBodyParts.get(i); + if (!caseBodies.contains(cur)) { + caseBodies.add(cur); + } + valuesMapping.add(caseBodies.indexOf(cur)); + } + + + + + if (defaultPart == breakPart) { + defaultPart = null; + } + if ((defaultPart != null) && (defaultCommands.isEmpty())) { + defaultCommands = printGraph(localData, stack, allParts, null, defaultPart, next, loops, forFinalCommands); + } + + List ignored = new ArrayList(); + for (Loop l : loops) { + ignored.add(l.loopContinue); + } + + for (int i = 0; i < caseBodies.size(); i++) { + List cc = new ArrayList(); + GraphPart nextCase = null; + nextCase = next; + if (next != null) { + if (i < caseBodies.size() - 1) { + if (!caseBodies.get(i).leadsTo(code, caseBodies.get(i + 1), ignored)) { + cc.add(new BreakItem(null, currentLoop.id)); + } else { + nextCase = caseBodies.get(i + 1); + } + } else if (!defaultCommands.isEmpty()) { + if (!caseBodies.get(i).leadsTo(code, defaultPart, ignored)) { + cc.add(new BreakItem(null, currentLoop.id)); + } else { + nextCase = defaultPart; + } + } + } + cc.addAll(0, printGraph(localData, stack, allParts, null, caseBodies.get(i), nextCase, loops, forFinalCommands)); + if (cc.size() >= 2) { + if (cc.get(cc.size() - 1) instanceof BreakItem) { + if ((cc.get(cc.size() - 2) instanceof ContinueItem) || (cc.get(cc.size() - 2) instanceof BreakItem)) { + cc.remove(cc.size() - 1); + } + } + } + caseCommands.add(cc); + } + ret = new ArrayList(); + if (!output.isEmpty()) { + if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) { + output.remove(output.size() - 1); + } + } + ret.addAll(output); + SwitchItem sti = new SwitchItem(null, currentLoop, switchedObject, caseValues, caseCommands, defaultCommands, valuesMapping); + ret.add(sti); + + if (next != null) { + if (ti != null) { + ret.add(ti); + } else { + ret.addAll(printGraph(localData, stack, allParts, null, next, stopPart, loops, forFinalCommands)); + } + } + } + } + return ret; + } + /* + private TreeItem translatePartGetStack(GraphPart part, Stack stack, HashMap registerNames) { + stack = (Stack) stack.clone(); + translatePart(part, stack, registerNames); + return stack.pop(); + } + + private List translatePart(GraphPart part, Stack stack, HashMap registerNames) { + List sub = part.getSubParts(); + List ret = new ArrayList(); + int end = 0; + for (GraphPart p : sub) { + if (p.end == -1) { + p.end = code.size() - 1; + } + if (p.start == code.size()) { + continue; + } else if (p.end == code.size()) { + p.end--; + } + end = p.end; + int start = p.start; + if (code.get(end) instanceof ActionJump) { + end--; + } else if (code.get(end) instanceof ActionIf) { + end--; + } + ret.addAll(Action.actionsPartToTree(registerNames, stack, code, start, end, version)); + } + return ret; + } + + private TreeItem checkLoop(GraphPart part, GraphPart stopPart, List loops) { + if (part == stopPart) { + return null; + } + for (Loop l : loops) { + if (l.loopContinue == part) { + return (new ContinueTreeItem(null, l.loopBreak == null ? -1 : l.loopBreak.start)); + } + if (l.loopBreak == part) { + return (new BreakTreeItem(null, part.start)); + } + } + return null; + } + private boolean doDecompile = true; + + private List printGraph(HashMap registerNames, Stack stack, List allParts, GraphPart parent, GraphPart part, GraphPart stopPart, List loops, HashMap> forFinalCommands) { + List ret = new ArrayList(); + boolean debugMode = false; + if (part.start >= code.size()) { + return ret; + } + + if (!doDecompile) { + // ret.add(new CommentTreeItem(null, "not decompiled")); + return ret; + } + + if (debugMode) { + System.err.println("PART " + part); + } + + if (part == stopPart) { + return ret; + } + if (part.ignored) { + return ret; + } + List fqn = new ArrayList(); + HashMap lrn = new HashMap(); + List output = new ArrayList(); + boolean isSwitch = false; + List parts = new ArrayList(); + if (part instanceof GraphPartMulti) { + parts = ((GraphPartMulti) part).parts; + } else { + parts.add(part); + } + boolean isIf = false; + int end = part.end; + if (end == -1) { + end = code.size() - 1; + } + if (end == code.size()) { + end--; + } + output.addAll(translatePart(part, stack, registerNames)); + if (end > -1) { + if (code.get(end) instanceof ActionJump) { + end--; + } else if (code.get(end) instanceof ActionIf) { + end--; + isIf = true; + } + } + if (isIf) { + Action ins = code.get(end + 1); + if ((stack.size() >= 2) && (stack.get(stack.size() - 1) instanceof NotTreeItem) && (((NotTreeItem) stack.get(stack.size() - 1)).value == stack.get(stack.size() - 2))) { + ret.addAll(output); + printGraph(registerNames, stack, allParts, parent, part.nextParts.get(1), part.nextParts.get(0), loops, forFinalCommands); + TreeItem second = stack.pop(); + TreeItem first = stack.pop(); + stack.push(new AndTreeItem(ins, first, second)); + ret.addAll(printGraph(registerNames, stack, allParts, parent, part.nextParts.get(0), stopPart, loops, forFinalCommands)); + return ret; + } else if ((stack.size() >= 2) && (stack.get(stack.size() - 1) == stack.get(stack.size() - 2))) { + ret.addAll(output); + printGraph(registerNames, stack, allParts, parent, part.nextParts.get(1), part.nextParts.get(0), loops, forFinalCommands); + TreeItem second = stack.pop(); + TreeItem first = stack.pop(); + stack.push(new OrTreeItem(ins, first, second)); + ret.addAll(printGraph(registerNames, stack, allParts, parent, part.nextParts.get(0), stopPart, loops, forFinalCommands)); + return ret; + } else if (stack.peek() instanceof StrictEqTreeItem) { + + TreeItem switchedObject = null; + if (!output.isEmpty()) { + if (output.get(output.size() - 1) instanceof StoreRegisterTreeItem) { + switchedObject = ((StoreRegisterTreeItem) output.get(output.size() - 1)).value; + } + } + if (switchedObject == null) { + switchedObject = new DirectValueTreeItem(null, -1, new Null(), null); + } + HashMap caseValuesMap = new HashMap(); + + int pos = 0; + StrictEqTreeItem set = (StrictEqTreeItem) stack.pop(); + caseValuesMap.put(pos, set.rightSide); + + //GraphPart switchLoc = part.nextParts.get(1).nextParts.get(0); + List caseBodyParts = new ArrayList(); + caseBodyParts.add(part.nextParts.get(0)); + TreeItem top = null; + int cnt = 1; + while (part.nextParts.size() > 1 + && part.nextParts.get(1).getHeight() > 1 + && code.get(part.nextParts.get(1).end) instanceof ActionIf + && ((top = translatePartGetStack(part.nextParts.get(1), stack, registerNames)) instanceof StrictEqTreeItem)) { + cnt++; + part = part.nextParts.get(1); + pos++; + caseBodyParts.add(part.nextParts.get(0)); + + set = (StrictEqTreeItem) top; + caseValuesMap.put(pos, set.rightSide); + } + if (cnt == 1) { + stack.push(set); + } else { + part = part.nextParts.get(1); + + GraphPart defaultPart = part; + //caseBodyParts.add(defaultPart); + + + + List defaultAndLastPart = new ArrayList(); + defaultAndLastPart.add(defaultPart); + defaultAndLastPart.add(caseBodyParts.get(caseBodyParts.size() - 1)); + + GraphPart defaultPart2 = getCommonPart(defaultAndLastPart); + + List defaultCommands = new ArrayList(); + + defaultCommands = printGraph(registerNames, stack, allParts, null, defaultPart, defaultPart2, loops, forFinalCommands); + + + List loopContinues = new ArrayList(); + for (Loop l : loops) { + if (l.loopContinue != null) { + loopContinues.add(l.loopContinue); + } + } + + List breakParts = new ArrayList(); + for (int g = 0; g < caseBodyParts.size(); g++) { + if (g < caseBodyParts.size() - 1) { + if (caseBodyParts.get(g).leadsTo(caseBodyParts.get(g + 1), loopContinues)) { + continue; + } + } + GraphPart nsp = caseBodyParts.get(g).getNextSuperPartPath(loopContinues); + if (nsp != null) { + breakParts.add(nsp); + } + } + Collections.sort(breakParts, new Comparator() { + @Override + public int compare(GraphPart o1, GraphPart o2) { + return o2.path.length() - o1.path.length(); + } + }); + + GraphPart breakPart = breakParts.isEmpty() ? null : breakParts.get(0); + if ((defaultPart2 != breakPart) && (defaultCommands.isEmpty())) { + defaultPart = defaultPart2; + } + + + List caseValues = new ArrayList(); + for (int i = 0; i < caseBodyParts.size(); i++) { + if (caseValuesMap.containsKey(i)) { + caseValues.add(caseValuesMap.get(i)); + } else { + continue; + } + } + + List> caseCommands = new ArrayList>(); + GraphPart next = null; + + + + next = breakPart; + + TreeItem ti = checkLoop(next, stopPart, loops); + loops.add(new Loop(null, next)); + //switchLoc.getNextPartPath(new ArrayList()); + List valuesMapping = new ArrayList(); + List caseBodies = new ArrayList(); + for (int i = 0; i < caseValues.size(); i++) { + GraphPart cur = caseBodyParts.get(i); + if (!caseBodies.contains(cur)) { + caseBodies.add(cur); + } + valuesMapping.add(caseBodies.indexOf(cur)); + } + + + + + if (defaultPart == breakPart) { + defaultPart = null; + } + if ((defaultPart != null) && (defaultCommands.isEmpty())) { + defaultCommands = printGraph(registerNames, stack, allParts, null, defaultPart, next, loops, forFinalCommands); + } + + List ignored = new ArrayList(); + for (Loop l : loops) { + ignored.add(l.loopContinue); + } + + for (int i = 0; i < caseBodies.size(); i++) { + List cc = new ArrayList(); + GraphPart nextCase = null; + nextCase = next; + if (next != null) { + if (i < caseBodies.size() - 1) { + if (!caseBodies.get(i).leadsTo(caseBodies.get(i + 1), ignored)) { + cc.add(new BreakTreeItem(null, next.start)); + } else { + nextCase = caseBodies.get(i + 1); + } + } else if (!defaultCommands.isEmpty()) { + if (!caseBodies.get(i).leadsTo(defaultPart, ignored)) { + cc.add(new BreakTreeItem(null, next.start)); + } else { + nextCase = defaultPart; + } + } + } + cc.addAll(0, printGraph(registerNames, stack, allParts, null, caseBodies.get(i), nextCase, loops, forFinalCommands)); + if (cc.size() >= 2) { + if (cc.get(cc.size() - 1) instanceof BreakTreeItem) { + if ((cc.get(cc.size() - 2) instanceof ContinueTreeItem) || (cc.get(cc.size() - 2) instanceof BreakTreeItem)) { + cc.remove(cc.size() - 1); + } + } + } + caseCommands.add(cc); + } + + SwitchTreeItem sti = new SwitchTreeItem(null, next == null ? -1 : next.start, switchedObject, caseValues, caseCommands, defaultCommands, valuesMapping); + ret.add(sti); + + if (next != null) { + if (ti != null) { + ret.add(ti); + } else { + ret.addAll(printGraph(registerNames, stack, allParts, null, next, stopPart, loops, forFinalCommands)); + } + } + return ret; + } + } else { + //ins.translate + } + //((IfTypeIns)ins.definition).translateInverted(new HashMap(), co.stack, ins); + } + + int ip = part.start; + List loopContinues = new ArrayList(); + for (Loop l : loops) { + if (l.loopContinue != null) { + loopContinues.add(l.loopContinue); + } + } + boolean loop = false; + boolean reversed = false; + if ((!part.nextParts.isEmpty()) && part.nextParts.get(0).leadsTo(part, loopContinues)) { + loop = true; + } else if ((part.nextParts.size() > 1) && part.nextParts.get(1).leadsTo(part, loopContinues)) { + loop = true; + reversed = true; + } + if (((part.nextParts.size() == 2) || ((part.nextParts.size() == 1) && loop)) && (!isSwitch)) { + + boolean doWhile = loop; + if (loop && output.isEmpty()) { + doWhile = false; + } + Loop currentLoop = new Loop(part, null); + if (loop) { + loops.add(currentLoop); + } + + + + loopContinues = new ArrayList(); + for (Loop l : loops) { + if (l.loopContinue != null) { + loopContinues.add(l.loopContinue); + } + } + + if (part.nextParts.size() > 1) { + currentLoop.loopBreak = part.nextParts.get(reversed ? 0 : 1); + } + + forFinalCommands.put(currentLoop, new ArrayList()); + + int breakIp = -1; + if (currentLoop.loopBreak != null) { + breakIp = currentLoop.loopBreak.start; + } + TreeItem expr = null; + if ((code.get(part.end) instanceof ActionJump) || (!(code.get(part.end) instanceof ActionIf))) { + expr = new DirectValueTreeItem(null, -1, (Boolean) true, new ArrayList()); + } else { + if (stack.isEmpty()) { + } + expr = stack.pop(); + } + if (doWhile) { + ret.add(new DoWhileTreeItem(null, breakIp, part.start, output, expr)); + } else { + ret.addAll(output); + } + + GraphPart next = part.getNextPartPath(loopContinues); + + if (loop && (!doWhile)) { + + if (reversed && (expr instanceof LogicalOp)) { + expr = ((LogicalOp) expr).invert(); + } + List loopBody = null; + List finalCommands = null; + GraphPart finalPart = null; + loopBody = printGraph(registerNames, stack, allParts, part, part.nextParts.get(reversed ? 1 : 0), stopPart, loops, forFinalCommands); + + finalCommands = forFinalCommands.get(currentLoop); + if (!finalCommands.isEmpty()) { + ret.add(new ForTreeItem(null, breakIp, currentLoop.loopContinue.start, new ArrayList(), expr, finalCommands, loopBody)); + } else { + ret.add(new WhileTreeItem(null, breakIp, part.start, expr, loopBody)); + } + } else if (!loop) { + if (expr instanceof LogicalOp) { + expr = ((LogicalOp) expr).invert(); + } else { + expr = new NotTreeItem(null, expr); + } + + int stackSizeBefore = stack.size(); + Stack trueStack = (Stack) stack.clone(); + Stack falseStack = (Stack) stack.clone(); + TreeItem lopTrue = checkLoop(part.nextParts.get(1), stopPart, loops); + TreeItem lopFalse = null; + if (next != part.nextParts.get(0)) { + lopFalse = checkLoop(part.nextParts.get(0), stopPart, loops); + } + List onTrue = new ArrayList(); + if (lopTrue != null) { + onTrue.add(lopTrue); + } else { + if (debugMode) { + System.err.println("ONTRUE: (inside " + part + ")"); + } + onTrue = printGraph(registerNames, trueStack, allParts, part, part.nextParts.get(1), next == null ? stopPart : next, loops, forFinalCommands); + if (debugMode) { + System.err.println("/ONTRUE (inside " + part + ")"); + } + } + List onFalse = new ArrayList(); + if (lopFalse != null) { + onFalse.add(lopFalse); + } else { + if (debugMode) { + System.err.println("ONFALSE: (inside " + part + ")"); + } + onFalse = (((next == part.nextParts.get(0)) || (part.nextParts.get(0).path.equals(part.path) || part.nextParts.get(0).path.length() < part.path.length())) ? new ArrayList() : printGraph(registerNames, falseStack, allParts, part, part.nextParts.get(0), next == null ? stopPart : next, loops, forFinalCommands)); + if (debugMode) { + System.err.println("/ONFALSE (inside " + part + ")"); + } + } + + if (onTrue.isEmpty() && onFalse.isEmpty() && (trueStack.size() > stackSizeBefore) && (falseStack.size() > stackSizeBefore)) { + stack.push(new TernarOpTreeItem(null, expr, trueStack.pop(), falseStack.pop())); + } else { + ret.add(new IfTreeItem(null, expr, onTrue, onFalse)); + + //Same continues in onTrue and onFalse gets continue on parent level + if ((!onTrue.isEmpty()) && (!onFalse.isEmpty())) { + if (onTrue.get(onTrue.size() - 1) instanceof ContinueTreeItem) { + if (onFalse.get(onFalse.size() - 1) instanceof ContinueTreeItem) { + if (((ContinueTreeItem) onTrue.get(onTrue.size() - 1)).loopPos == ((ContinueTreeItem) onFalse.get(onFalse.size() - 1)).loopPos) { + onTrue.remove(onTrue.size() - 1); + ret.add(onFalse.remove(onFalse.size() - 1)); + } + } + } + } + } + } + if (loop && (part.nextParts.size() > 1)) { + loops.remove(currentLoop); //remove loop so no break shows up + ret.addAll(printGraph(registerNames, stack, allParts, part, part.nextParts.get(reversed ? 0 : 1), stopPart, loops, forFinalCommands)); + } + + if (next != null) { + TreeItem ti = checkLoop(next, stopPart, loops); + if (ti != null) { + ret.add(ti); + } else { + if (debugMode) { + System.err.println("NEXT: (inside " + part + ")"); + } + ret.addAll(printGraph(registerNames, stack, allParts, part, next, stopPart, loops, forFinalCommands)); + if (debugMode) { + System.err.println("/NEXT: (inside " + part + ")"); + } + } + + } + } else { + ret.addAll(output); + } + onepart: + if (part.nextParts.size() == 1 && (!loop)) { + + + GraphPart p = part.nextParts.get(0); + TreeItem lop = checkLoop(p, stopPart, loops); + if (lop == null) { + if (p.path.length() == part.path.length()) { + ret.addAll(printGraph(registerNames, stack, allParts, part, p, stopPart, loops, forFinalCommands)); + } else { + if ((p != stopPart) && (p.refs.size() > 1)) { + List nextList = new ArrayList(); + populateParts(p, nextList); + Loop nearestLoop = null; + loopn: + for (GraphPart n : nextList) { + for (Loop l : loops) { + if (l.loopContinue == n) { + nearestLoop = l; + break loopn; + } + } + } + if ((nearestLoop != null) && (nearestLoop.loopBreak != null)) { + List finalCommands = printGraph(registerNames, stack, allParts, part, p, nearestLoop.loopContinue, loops, forFinalCommands); + nearestLoop.loopContinue = p; + forFinalCommands.put(nearestLoop, finalCommands); + ContinueTreeItem cti = new ContinueTreeItem(null, nearestLoop.loopBreak.start); + ret.add(cti); + } + } + } + } else { + ret.add(lop); + } + } + return ret; + } + private List posCache; + + private void buildCache() { + posCache = new ArrayList(); + int pos = 0; + for (int i = 0; i < code.size(); i++) { + posCache.add(pos); + pos += code.get(i).getBytes(version).length; + } + posCache.add(pos); + } + + private int pos2adr(int pos) { + if (posCache == null) { + buildCache(); + } + return posCache.get(pos); + } + + private int adr2pos(int adr) { + if (posCache == null) { + buildCache(); + } + return posCache.indexOf(adr); + } + + private void visitCode(int ip, int lastIp, HashMap> refs) { + while (ip < code.size()) { + refs.get(ip).add(lastIp); + lastIp = ip; + if (refs.get(ip).size() > 1) { + break; + } + Action ins = code.get(ip); + if (ins instanceof ActionThrow) { + break; + } + if (ins instanceof ActionReturn) { + break; + } + + if (ins instanceof ActionJump) { + ip = adr2pos(pos2adr(ip) + ins.getBytes(version).length + ((ActionJump) ins).offset); + continue; + } else if (ins instanceof ActionIf) { + visitCode(adr2pos(pos2adr(ip) + ins.getBytes(version).length + ((ActionIf) ins).offset), ip, refs); + } + ip++; + }; + } + + public HashMap> visitCode() { + HashMap> refs = new HashMap>(); + for (int i = 0; i < code.size(); i++) { + refs.put(i, new ArrayList()); + } + visitCode(0, 0, refs); + return refs; + } + + private List makeGraph(List actions, List allBlocks) { + HashMap> refs = visitCode(); + List ret = new ArrayList(); + boolean visited[] = new boolean[code.size()]; + ret.add(makeGraph(null, "0", code, 0, 0, allBlocks, refs, visited)); + return ret; + } + + private GraphPart makeGraph(GraphPart parent, String path, List code, int startip, int lastIp, List allBlocks, HashMap> refs, boolean visited2[]) { + + int ip = startip; + for (GraphPart p : allBlocks) { + if (p.start == ip) { + p.refs.add(parent); + return p; + } + } + GraphPart g; + GraphPart ret = new GraphPart(ip, -1); + ret.path = path; + GraphPart part = ret; + while (ip < code.size()) { + if (visited2[ip] || ((ip != startip) && (refs.get(ip).size() > 1))) { + part.end = lastIp; + GraphPart found = null; + for (GraphPart p : allBlocks) { + if (p.start == ip) { + found = p; + break; + } + } + + allBlocks.add(part); + + if (found != null) { + part.nextParts.add(found); + found.refs.add(part); + break; + } else { + GraphPart gp = new GraphPart(ip, -1); + gp.path = path; + part.nextParts.add(gp); + gp.refs.add(part); + part = gp; + } + } + lastIp = ip; + Action ins = code.get(ip); + if ((ins instanceof ActionThrow) || (ins instanceof ActionReturn)) { + part.end = ip; + allBlocks.add(part); + break; + } + if (ins instanceof ActionJump) { + part.end = ip; + allBlocks.add(part); + int newip = adr2pos(pos2adr(ip) + ins.getBytes(version).length + ((ActionJump) ins).offset); + part.nextParts.add(g = makeGraph(part, path, code, newip, lastIp, allBlocks, refs, visited2)); + g.refs.add(part); + break; + } else if (ins instanceof ActionIf) { + part.end = ip; + allBlocks.add(part); + part.nextParts.add(g = makeGraph(part, path + "0", code, adr2pos(pos2adr(ip) + ins.getBytes(version).length + ((ActionIf) ins).offset), ip, allBlocks, refs, visited2)); + g.refs.add(part); + part.nextParts.add(g = makeGraph(part, path + "1", code, ip + 1, ip, allBlocks, refs, visited2)); + g.refs.add(part); + + break; + } + ip++; + }; + if (ip == code.size()) { + allBlocks.add(part); + if (part.start == ip) { + part.end = ip; + } else { + part.end = code.size() - 1; + part.nextParts.add(makeGraph(part, path, code, ip, ip, allBlocks, refs, visited2)); + } + + } + return ret; + } + */ + + @Override + protected int checkIp(int ip) { + + //return in for..in + GraphSourceItem action = code.get(ip); + if ((action instanceof ActionPush) && (((ActionPush) action).values.size() == 1) && (((ActionPush) action).values.get(0) instanceof Null)) { + if (ip + 3 < code.size()) { + if ((code.get(ip + 1) instanceof ActionEquals) || (code.get(ip + 1) instanceof ActionEquals2)) { + if (code.get(ip + 2) instanceof ActionNot) { + if (code.get(ip + 3) instanceof ActionIf) { + ActionIf aif = (ActionIf) code.get(ip + 3); + if (code.adr2pos(code.pos2adr(ip + 4) + aif.offset) == ip) { + ip += 4; + } + } + } + } + } + } + return ip; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java index eaf3b3f90..d89fbc0e0 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/ActionGraphSource.java @@ -13,67 +13,67 @@ import java.util.Stack; */ public class ActionGraphSource extends GraphSource { - private List actions; - public int version; - private HashMap registerNames; - private HashMap variables; - private HashMap functions; + private List actions; + public int version; + private HashMap registerNames; + private HashMap variables; + private HashMap functions; - public ActionGraphSource(List actions, int version, HashMap registerNames, HashMap variables, HashMap functions) { - this.actions = actions; - this.version = version; - this.registerNames = registerNames; - this.variables = variables; - this.functions = functions; - } + public ActionGraphSource(List actions, int version, HashMap registerNames, HashMap variables, HashMap functions) { + this.actions = actions; + this.version = version; + this.registerNames = registerNames; + this.variables = variables; + this.functions = functions; + } - @Override - public int size() { - return actions.size(); - } + @Override + public int size() { + return actions.size(); + } - @Override - public GraphSourceItem get(int pos) { - return actions.get(pos); - } + @Override + public GraphSourceItem get(int pos) { + return actions.get(pos); + } - public void set(int pos, Action t) { - actions.set(pos, t); - } + public void set(int pos, Action t) { + actions.set(pos, t); + } - @Override - public boolean isEmpty() { - return actions.isEmpty(); - } + @Override + public boolean isEmpty() { + return actions.isEmpty(); + } - @Override - public List translatePart(List localData, Stack stack, int start, int end) { - return (Action.actionsPartToTree(registerNames, variables, functions, stack, actions, start, end, version)); - } + @Override + public List translatePart(List localData, Stack stack, int start, int end) { + return (Action.actionsPartToTree(registerNames, variables, functions, stack, actions, start, end, version)); + } - @Override - public int adr2pos(long adr) { - int pos = 0; - long lastAddr = 0; - for (Action a : actions) { - lastAddr = a.getAddress(); - if (lastAddr == adr) { - return pos; - } + @Override + public int adr2pos(long adr) { + int pos = 0; + long lastAddr = 0; + for (Action a : actions) { + lastAddr = a.getAddress(); + if (lastAddr == adr) { + return pos; + } - pos++; - } - if (adr > lastAddr) { - return actions.size(); - } - if (adr == 0) { - return 0; - } - return -1; - } + pos++; + } + if (adr > lastAddr) { + return actions.size(); + } + if (adr == 0) { + return 0; + } + return -1; + } - @Override - public long pos2adr(int pos) { - return actions.get(pos).getAddress();//Action.ip2adr(actions, pos, version); - } + @Override + public long pos2adr(int pos) { + return actions.get(pos).getAddress();//Action.ip2adr(actions, pos, version); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/UnknownActionException.java b/trunk/src/com/jpexs/decompiler/flash/action/UnknownActionException.java index 7ecdaa3e4..723855d42 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/UnknownActionException.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/UnknownActionException.java @@ -6,10 +6,10 @@ package com.jpexs.decompiler.flash.action; */ public class UnknownActionException extends RuntimeException { - public int opCode; + public int opCode; - public UnknownActionException(int opCode) { - super("Unknown opCode: 0x" + Integer.toHexString(opCode)); - this.opCode = opCode; - } + public UnknownActionException(int opCode) { + super("Unknown opCode: 0x" + Integer.toHexString(opCode)); + this.opCode = opCode; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/UnknownJumpException.java b/trunk/src/com/jpexs/decompiler/flash/action/UnknownJumpException.java index cc2be5a08..94e32f31f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/UnknownJumpException.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/UnknownJumpException.java @@ -27,39 +27,39 @@ import java.util.Stack; */ public class UnknownJumpException extends RuntimeException { - /** - * Actual stack - */ - public Stack stack; - /** - * Actual address - */ - public long addr; - /** - * Output of the method before raising the exception - */ - public List output; + /** + * Actual stack + */ + public Stack stack; + /** + * Actual address + */ + public long addr; + /** + * Output of the method before raising the exception + */ + public List output; - /** - * Constructor - * - * @param stack Actual stack - * @param addr Actual address - * @param output Output of the method before raising the exception - */ - public UnknownJumpException(Stack stack, long addr, List output) { - this.stack = stack; - this.addr = addr; - this.output = output; - } + /** + * Constructor + * + * @param stack Actual stack + * @param addr Actual address + * @param output Output of the method before raising the exception + */ + public UnknownJumpException(Stack stack, long addr, List output) { + this.stack = stack; + this.addr = addr; + this.output = output; + } - /** - * Returns a string representation of the object - * - * @return a string representation of the object. - */ - @Override - public String toString() { - return "Unknown jump to " + addr; - } + /** + * Returns a string representation of the object + * + * @return a string representation of the object. + */ + @Override + public String toString() { + return "Unknown jump to " + addr; + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java b/trunk/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java index dbabef07a..0711bd912 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java @@ -26,23 +26,23 @@ import java.util.Stack; public class ActionFSCommand2 extends Action { - public ActionFSCommand2() { - super(0x2D, 0); - } + public ActionFSCommand2() { + super(0x2D, 0); + } - @Override - public String toString() { - return "FSCommand2"; - } + @Override + public String toString() { + return "FSCommand2"; + } - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { - long numArgs = popLong(stack); - GraphTargetItem command = stack.pop(); - List args = new ArrayList(); - for (long l = 0; l < numArgs; l++) { - args.add(stack.pop()); - } - stack.push(new FSCommand2TreeItem(this, command, args)); - } + @Override + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { + long numArgs = popLong(stack); + GraphTargetItem command = stack.pop(); + List args = new ArrayList(); + for (long l = 0; l < numArgs; l++) { + args.add(stack.pop()); + } + stack.push(new FSCommand2TreeItem(this, command, args)); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java b/trunk/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java index 6b417300d..48157369e 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java @@ -31,37 +31,37 @@ import java.util.Stack; public class ActionStrictMode extends Action { - public int mode; + public int mode; - public ActionStrictMode(SWFInputStream sis) throws IOException { - super(0x89, 1); - mode = sis.readUI8(); - } + public ActionStrictMode(SWFInputStream sis) throws IOException { + super(0x89, 1); + mode = sis.readUI8(); + } - public ActionStrictMode(FlasmLexer lexer) throws IOException, ParseException { - super(0x89, 1); - mode = (int) lexLong(lexer); - } + public ActionStrictMode(FlasmLexer lexer) throws IOException, ParseException { + super(0x89, 1); + mode = (int) lexLong(lexer); + } - @Override - public byte[] getBytes(int version) { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFOutputStream sos = new SWFOutputStream(baos, version); - try { - sos.writeUI8(mode); - sos.close(); - } catch (IOException e) { - } - return surroundWithAction(baos.toByteArray(), version); - } + @Override + public byte[] getBytes(int version) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFOutputStream sos = new SWFOutputStream(baos, version); + try { + sos.writeUI8(mode); + sos.close(); + } catch (IOException e) { + } + return surroundWithAction(baos.toByteArray(), version); + } - @Override - public String toString() { - return "StrictMode " + mode; - } + @Override + public String toString() { + return "StrictMode " + mode; + } - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { - output.add(new StrictModeTreeItem(this, mode)); - } + @Override + public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions) { + output.add(new StrictModeTreeItem(this, mode)); + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java b/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java index 3d02808cc..bf5da6af2 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/gui/ActionPanel.java @@ -48,284 +48,284 @@ import jsyntaxpane.DefaultSyntaxKit; public class ActionPanel extends JPanel implements ActionListener { - public LineMarkedEditorPane editor; - public LineMarkedEditorPane decompiledEditor; - public List list; - public JSplitPane splitPane; - public JSplitPane splitPane2; - public JButton saveButton = new JButton("Save"); - public JButton editButton = new JButton("Edit"); - public JButton cancelButton = new JButton("Cancel"); - public JToggleButton hexButton; - public JButton saveHexButton = new JButton("Save hex"); - public JButton loadHexButton = new JButton("Load hex"); - public JLabel asmLabel = new JLabel("P-code source"); - public JLabel decLabel = new JLabel("ActionScript source"); - public List decompiledHilights = new ArrayList(); - public List disassembledHilights = new ArrayList(); - public String lastDisasm = ""; - private boolean ignoreCarret = false; - private boolean editMode = false; - private List lastCode; - private ASMSource src; - public JPanel topButtonsPan; - private String srcWithHex; - private String srcNoHex; + public LineMarkedEditorPane editor; + public LineMarkedEditorPane decompiledEditor; + public List list; + public JSplitPane splitPane; + public JSplitPane splitPane2; + public JButton saveButton = new JButton("Save"); + public JButton editButton = new JButton("Edit"); + public JButton cancelButton = new JButton("Cancel"); + public JToggleButton hexButton; + public JButton saveHexButton = new JButton("Save hex"); + public JButton loadHexButton = new JButton("Load hex"); + public JLabel asmLabel = new JLabel("P-code source"); + public JLabel decLabel = new JLabel("ActionScript source"); + public List decompiledHilights = new ArrayList(); + public List disassembledHilights = new ArrayList(); + public String lastDisasm = ""; + private boolean ignoreCarret = false; + private boolean editMode = false; + private List lastCode; + private ASMSource src; + public JPanel topButtonsPan; + private String srcWithHex; + private String srcNoHex; - public void setText(String text) { - int pos = editor.getCaretPosition(); - Highlighting lastH = new Highlighting(0, 0, 0); - for (Highlighting h : disassembledHilights) { - if (pos < h.startPos) { - break; - } - lastH = h; - } - long offset = lastH.offset; - disassembledHilights = Highlighting.getInstrHighlights(text); - editor.setText(Highlighting.stripHilights(text)); - for (Highlighting h : disassembledHilights) { - if (h.offset == offset) { - editor.setCaretPosition(h.startPos); - break; - } - } - - } - - public void setHex(boolean hex) { - setText(hex ? srcWithHex : srcNoHex); - } - - public void setSource(ASMSource src) { - this.src = src; - Main.startWork("Decompiling..."); - final ASMSource asm = (ASMSource) src; - (new Thread() { - @Override - public void run() { - editor.setText("; Disassembling..."); - if (Main.DO_DECOMPILE) { - decompiledEditor.setText("//Decompiling..."); + public void setText(String text) { + int pos = editor.getCaretPosition(); + Highlighting lastH = new Highlighting(0, 0, 0); + for (Highlighting h : disassembledHilights) { + if (pos < h.startPos) { + break; } - lastDisasm = asm.getASMSource(SWF.DEFAULT_VERSION, true); - srcWithHex = Helper.hexToComments(lastDisasm); - srcNoHex = Helper.stripComments(lastDisasm); - setHex(hexButton.isSelected()); - if (Main.DO_DECOMPILE) { - List as = asm.getActions(SWF.DEFAULT_VERSION); - lastCode = as; - com.jpexs.decompiler.flash.action.Action.setActionsAddresses(as, 0, SWF.DEFAULT_VERSION); - String s = com.jpexs.decompiler.flash.action.Action.actionsToSource(as, SWF.DEFAULT_VERSION); - decompiledHilights = Highlighting.getInstrHighlights(s); - decompiledEditor.setText(Highlighting.stripHilights(s)); + lastH = h; + } + long offset = lastH.offset; + disassembledHilights = Highlighting.getInstrHighlights(text); + editor.setText(Highlighting.stripHilights(text)); + for (Highlighting h : disassembledHilights) { + if (h.offset == offset) { + editor.setCaretPosition(h.startPos); + break; } - setEditMode(false); - Main.stopWork(); - } - }).start(); - } + } - public void hilightOffset(long offset) { - } + } - public ActionPanel() { - this.list = list; - DefaultSyntaxKit.initKit(); - editor = new LineMarkedEditorPane(); - editor.setEditable(false); - decompiledEditor = new LineMarkedEditorPane(); - decompiledEditor.setEditable(false); + public void setHex(boolean hex) { + setText(hex ? srcWithHex : srcNoHex); + } + + public void setSource(ASMSource src) { + this.src = src; + Main.startWork("Decompiling..."); + final ASMSource asm = (ASMSource) src; + (new Thread() { + @Override + public void run() { + editor.setText("; Disassembling..."); + if (Main.DO_DECOMPILE) { + decompiledEditor.setText("//Decompiling..."); + } + lastDisasm = asm.getASMSource(SWF.DEFAULT_VERSION, true); + srcWithHex = Helper.hexToComments(lastDisasm); + srcNoHex = Helper.stripComments(lastDisasm); + setHex(hexButton.isSelected()); + if (Main.DO_DECOMPILE) { + List as = asm.getActions(SWF.DEFAULT_VERSION); + lastCode = as; + com.jpexs.decompiler.flash.action.Action.setActionsAddresses(as, 0, SWF.DEFAULT_VERSION); + String s = com.jpexs.decompiler.flash.action.Action.actionsToSource(as, SWF.DEFAULT_VERSION); + decompiledHilights = Highlighting.getInstrHighlights(s); + decompiledEditor.setText(Highlighting.stripHilights(s)); + } + setEditMode(false); + Main.stopWork(); + } + }).start(); + } + + public void hilightOffset(long offset) { + } + + public ActionPanel() { + this.list = list; + DefaultSyntaxKit.initKit(); + editor = new LineMarkedEditorPane(); + editor.setEditable(false); + decompiledEditor = new LineMarkedEditorPane(); + decompiledEditor.setEditable(false); - JButton graphButton = new JButton(View.getIcon("graph16")); - graphButton.setActionCommand("GRAPH"); - graphButton.addActionListener(this); - graphButton.setToolTipText("View Graph"); - graphButton.setMargin(new Insets(3, 3, 3, 3)); + JButton graphButton = new JButton(View.getIcon("graph16")); + graphButton.setActionCommand("GRAPH"); + graphButton.addActionListener(this); + graphButton.setToolTipText("View Graph"); + graphButton.setMargin(new Insets(3, 3, 3, 3)); - hexButton = new JToggleButton(View.getIcon("hex16")); - hexButton.setActionCommand("HEX"); - hexButton.addActionListener(this); - hexButton.setToolTipText("View Hex"); - hexButton.setMargin(new Insets(3, 3, 3, 3)); + hexButton = new JToggleButton(View.getIcon("hex16")); + hexButton.setActionCommand("HEX"); + hexButton.addActionListener(this); + hexButton.setToolTipText("View Hex"); + hexButton.setMargin(new Insets(3, 3, 3, 3)); - topButtonsPan = new JPanel(); - topButtonsPan.setLayout(new BoxLayout(topButtonsPan, BoxLayout.X_AXIS)); - topButtonsPan.add(graphButton); - topButtonsPan.add(hexButton); - JPanel panCode = new JPanel(new BorderLayout()); - panCode.add(new JScrollPane(editor), BorderLayout.CENTER); - panCode.add(topButtonsPan, BorderLayout.NORTH); + topButtonsPan = new JPanel(); + topButtonsPan.setLayout(new BoxLayout(topButtonsPan, BoxLayout.X_AXIS)); + topButtonsPan.add(graphButton); + topButtonsPan.add(hexButton); + JPanel panCode = new JPanel(new BorderLayout()); + panCode.add(new JScrollPane(editor), BorderLayout.CENTER); + panCode.add(topButtonsPan, BorderLayout.NORTH); - JPanel panB = new JPanel(); - panB.setLayout(new BorderLayout()); - asmLabel.setHorizontalAlignment(SwingConstants.CENTER); - asmLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); - panB.add(asmLabel, BorderLayout.NORTH); - panB.add(panCode, BorderLayout.CENTER); + JPanel panB = new JPanel(); + panB.setLayout(new BorderLayout()); + asmLabel.setHorizontalAlignment(SwingConstants.CENTER); + asmLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); + panB.add(asmLabel, BorderLayout.NORTH); + panB.add(panCode, BorderLayout.CENTER); - JPanel buttonsPan = new JPanel(); - buttonsPan.setLayout(new FlowLayout()); - buttonsPan.add(editButton); - buttonsPan.add(saveButton); - buttonsPan.add(cancelButton); + JPanel buttonsPan = new JPanel(); + buttonsPan.setLayout(new FlowLayout()); + buttonsPan.add(editButton); + buttonsPan.add(saveButton); + buttonsPan.add(cancelButton); - //buttonsPan.add(saveHexButton); - //buttonsPan.add(loadHexButton); - panB.add(buttonsPan, BorderLayout.SOUTH); + //buttonsPan.add(saveHexButton); + //buttonsPan.add(loadHexButton); + panB.add(buttonsPan, BorderLayout.SOUTH); - saveHexButton.addActionListener(this); - saveHexButton.setActionCommand("SAVEHEXACTION"); - loadHexButton.addActionListener(this); - loadHexButton.setActionCommand("LOADHEXACTION"); - saveButton.addActionListener(this); - saveButton.setActionCommand("SAVEACTION"); - editButton.addActionListener(this); - editButton.setActionCommand("EDITACTION"); - cancelButton.addActionListener(this); - cancelButton.setActionCommand("CANCELACTION"); - saveButton.setVisible(false); - cancelButton.setVisible(false); + saveHexButton.addActionListener(this); + saveHexButton.setActionCommand("SAVEHEXACTION"); + loadHexButton.addActionListener(this); + loadHexButton.setActionCommand("LOADHEXACTION"); + saveButton.addActionListener(this); + saveButton.setActionCommand("SAVEACTION"); + editButton.addActionListener(this); + editButton.setActionCommand("EDITACTION"); + cancelButton.addActionListener(this); + cancelButton.setActionCommand("CANCELACTION"); + saveButton.setVisible(false); + cancelButton.setVisible(false); - JPanel panA = new JPanel(); - panA.setLayout(new BorderLayout()); - panA.add(new JScrollPane(decompiledEditor), BorderLayout.CENTER); - panA.add(decLabel, BorderLayout.NORTH); - decLabel.setHorizontalAlignment(SwingConstants.CENTER); - decLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); + JPanel panA = new JPanel(); + panA.setLayout(new BorderLayout()); + panA.add(new JScrollPane(decompiledEditor), BorderLayout.CENTER); + panA.add(decLabel, BorderLayout.NORTH); + decLabel.setHorizontalAlignment(SwingConstants.CENTER); + decLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); - setLayout(new BorderLayout()); - //add(splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(tagTree), splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panA, panB)), BorderLayout.CENTER); - add(splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panA, panB), BorderLayout.CENTER); + setLayout(new BorderLayout()); + //add(splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(tagTree), splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panA, panB)), BorderLayout.CENTER); + add(splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panA, panB), BorderLayout.CENTER); // splitPane.setResizeWeight(0.5); - splitPane2.setResizeWeight(0.5); - editor.setContentType("text/flasm"); - editor.setFont(new Font("Monospaced", Font.PLAIN, editor.getFont().getSize())); - decompiledEditor.setContentType("text/actionscript"); - decompiledEditor.setFont(new Font("Monospaced", Font.PLAIN, decompiledEditor.getFont().getSize())); + splitPane2.setResizeWeight(0.5); + editor.setContentType("text/flasm"); + editor.setFont(new Font("Monospaced", Font.PLAIN, editor.getFont().getSize())); + decompiledEditor.setContentType("text/actionscript"); + decompiledEditor.setFont(new Font("Monospaced", Font.PLAIN, decompiledEditor.getFont().getSize())); - //tagTree.addTreeSelectionListener(this); - editor.addCaretListener(new CaretListener() { - @Override - public void caretUpdate(CaretEvent e) { - if (ignoreCarret) { - return; - } - editor.getCaret().setVisible(true); - int pos = editor.getCaretPosition(); - Highlighting lastH = new Highlighting(0, 0, 0); - for (Highlighting h : disassembledHilights) { - if (pos < h.startPos) { - break; - } - lastH = h; - } - for (Highlighting h2 : decompiledHilights) { - if (h2.offset == lastH.offset) { - ignoreCarret = true; - decompiledEditor.setCaretPosition(h2.startPos); - decompiledEditor.getCaret().setVisible(true); - ignoreCarret = false; - break; - } - } - } - }); - decompiledEditor.addCaretListener(new CaretListener() { - @Override - public void caretUpdate(CaretEvent e) { - if (ignoreCarret) { - return; - } - if (editMode) { - return; - } - decompiledEditor.getCaret().setVisible(true); - int pos = decompiledEditor.getCaretPosition(); - for (Highlighting h : decompiledHilights) { - if ((pos >= h.startPos) && (pos < h.startPos + h.len)) { - for (Highlighting h2 : disassembledHilights) { - if (h2.offset == h.offset) { + //tagTree.addTreeSelectionListener(this); + editor.addCaretListener(new CaretListener() { + @Override + public void caretUpdate(CaretEvent e) { + if (ignoreCarret) { + return; + } + editor.getCaret().setVisible(true); + int pos = editor.getCaretPosition(); + Highlighting lastH = new Highlighting(0, 0, 0); + for (Highlighting h : disassembledHilights) { + if (pos < h.startPos) { + break; + } + lastH = h; + } + for (Highlighting h2 : decompiledHilights) { + if (h2.offset == lastH.offset) { ignoreCarret = true; - editor.setCaretPosition(h2.startPos); - editor.getCaret().setVisible(true); + decompiledEditor.setCaretPosition(h2.startPos); + decompiledEditor.getCaret().setVisible(true); ignoreCarret = false; break; - } - } - break; - } + } + } } - } - }); - } + }); + decompiledEditor.addCaretListener(new CaretListener() { + @Override + public void caretUpdate(CaretEvent e) { + if (ignoreCarret) { + return; + } + if (editMode) { + return; + } + decompiledEditor.getCaret().setVisible(true); + int pos = decompiledEditor.getCaretPosition(); + for (Highlighting h : decompiledHilights) { + if ((pos >= h.startPos) && (pos < h.startPos + h.len)) { + for (Highlighting h2 : disassembledHilights) { + if (h2.offset == h.offset) { + ignoreCarret = true; + editor.setCaretPosition(h2.startPos); + editor.getCaret().setVisible(true); + ignoreCarret = false; + break; + } + } + break; + } + } + } + }); + } - public void initSplits() { - //splitPane.setDividerLocation(getWidth() / 3); - splitPane2.setDividerLocation(getWidth() / 2); - } + public void initSplits() { + //splitPane.setDividerLocation(getWidth() / 3); + splitPane2.setDividerLocation(getWidth() / 2); + } - public void display() { - setVisible(true); - splitPane.setDividerLocation(0.5); - splitPane2.setDividerLocation(0.5); - } + public void display() { + setVisible(true); + splitPane.setDividerLocation(0.5); + splitPane2.setDividerLocation(0.5); + } - public void setEditMode(boolean val) { - if (val) { - setText(srcNoHex); - editor.setEditable(true); - saveButton.setVisible(true); - editButton.setVisible(false); - cancelButton.setVisible(true); - editor.getCaret().setVisible(true); - } else { - setText(hexButton.isSelected() ? srcWithHex : srcNoHex); - editor.setEditable(false); - saveButton.setVisible(false); - editButton.setVisible(true); - cancelButton.setVisible(false); - editor.getCaret().setVisible(true); - } - topButtonsPan.setVisible(!val); - editMode = val; - } + public void setEditMode(boolean val) { + if (val) { + setText(srcNoHex); + editor.setEditable(true); + saveButton.setVisible(true); + editButton.setVisible(false); + cancelButton.setVisible(true); + editor.getCaret().setVisible(true); + } else { + setText(hexButton.isSelected() ? srcWithHex : srcNoHex); + editor.setEditable(false); + saveButton.setVisible(false); + editButton.setVisible(true); + cancelButton.setVisible(false); + editor.getCaret().setVisible(true); + } + topButtonsPan.setVisible(!val); + editMode = val; + } - @Override - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("GRAPH")) { - if (lastCode != null) { - GraphFrame gf = new GraphFrame(new ActionGraph(lastCode, new HashMap(), new HashMap(), new HashMap(), SWF.DEFAULT_VERSION), ""); - gf.setVisible(true); - } - } else if (e.getActionCommand().equals("EDITACTION")) { - setEditMode(true); - } else if (e.getActionCommand().equals("HEX")) { - setHex(hexButton.isSelected()); - } else if (e.getActionCommand().equals("CANCELACTION")) { - setEditMode(false); - setHex(hexButton.isSelected()); - } else if (e.getActionCommand().equals("SAVEACTION")) { - try { - src.setActions(ASMParser.parse(true, new ByteArrayInputStream(editor.getText().getBytes()), SWF.DEFAULT_VERSION), SWF.DEFAULT_VERSION); - setSource(this.src); - JOptionPane.showMessageDialog(this, "Code successfully saved"); - } catch (IOException ex) { - } catch (ParseException ex) { - JOptionPane.showMessageDialog(this, "" + ex.text + " on line " + ex.line, "Error", JOptionPane.ERROR_MESSAGE); - } - saveButton.setVisible(false); - editButton.setVisible(true); - editor.setEditable(false); - } - } + @Override + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().equals("GRAPH")) { + if (lastCode != null) { + GraphFrame gf = new GraphFrame(new ActionGraph(lastCode, new HashMap(), new HashMap(), new HashMap(), SWF.DEFAULT_VERSION), ""); + gf.setVisible(true); + } + } else if (e.getActionCommand().equals("EDITACTION")) { + setEditMode(true); + } else if (e.getActionCommand().equals("HEX")) { + setHex(hexButton.isSelected()); + } else if (e.getActionCommand().equals("CANCELACTION")) { + setEditMode(false); + setHex(hexButton.isSelected()); + } else if (e.getActionCommand().equals("SAVEACTION")) { + try { + src.setActions(ASMParser.parse(true, new ByteArrayInputStream(editor.getText().getBytes()), SWF.DEFAULT_VERSION), SWF.DEFAULT_VERSION); + setSource(this.src); + JOptionPane.showMessageDialog(this, "Code successfully saved"); + } catch (IOException ex) { + } catch (ParseException ex) { + JOptionPane.showMessageDialog(this, "" + ex.text + " on line " + ex.line, "Error", JOptionPane.ERROR_MESSAGE); + } + saveButton.setVisible(false); + editButton.setVisible(true); + editor.setEditable(false); + } + } } diff --git a/trunk/src/com/jpexs/decompiler/flash/action/parser/ASMParser.java b/trunk/src/com/jpexs/decompiler/flash/action/parser/ASMParser.java index cd1c5f0e6..541a1907c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/action/parser/ASMParser.java +++ b/trunk/src/com/jpexs/decompiler/flash/action/parser/ASMParser.java @@ -32,286 +32,286 @@ import java.util.List; public class ASMParser { - public static List parse(boolean ignoreNops, List