From 1faee7eaa5aeb6a0fb43dd3aa014d7e5979eea81 Mon Sep 17 00:00:00 2001 From: honfika Date: Sun, 20 Jul 2014 00:42:57 +0200 Subject: [PATCH] fixed some NetBeanscode hints --- src/com/jpexs/decompiler/flash/SWF.java | 5872 ++++++++--------- .../flash/SourceGeneratorLocalData.java | 4 +- .../decompiler/flash/abc/avm2/AVM2Code.java | 13 +- .../abc/avm2/instructions/IfTypeIns.java | 51 +- .../instructions/InstructionDefinition.java | 330 +- .../avm2/instructions/arithmetic/AddIIns.java | 98 +- .../avm2/instructions/arithmetic/AddIns.java | 144 +- .../arithmetic/DecrementIIns.java | 132 +- .../instructions/arithmetic/DecrementIns.java | 132 +- .../instructions/arithmetic/DivideIns.java | 142 +- .../arithmetic/IncrementIIns.java | 94 +- .../instructions/arithmetic/IncrementIns.java | 94 +- .../instructions/arithmetic/ModuloIns.java | 126 +- .../instructions/arithmetic/MultiplyIIns.java | 98 +- .../instructions/arithmetic/MultiplyIns.java | 142 +- .../instructions/arithmetic/NegateIIns.java | 96 +- .../instructions/arithmetic/NegateIns.java | 96 +- .../avm2/instructions/arithmetic/NotIns.java | 96 +- .../instructions/arithmetic/SubtractIIns.java | 98 +- .../instructions/arithmetic/SubtractIns.java | 98 +- .../avm2/instructions/bitwise/BitAndIns.java | 116 +- .../avm2/instructions/bitwise/BitNotIns.java | 112 +- .../avm2/instructions/bitwise/BitOrIns.java | 116 +- .../avm2/instructions/bitwise/BitXorIns.java | 116 +- .../avm2/instructions/bitwise/LShiftIns.java | 98 +- .../avm2/instructions/bitwise/RShiftIns.java | 98 +- .../avm2/instructions/bitwise/URShiftIns.java | 98 +- .../instructions/comparison/EqualsIns.java | 116 +- .../comparison/GreaterEqualsIns.java | 98 +- .../comparison/GreaterThanIns.java | 98 +- .../comparison/LessEqualsIns.java | 98 +- .../instructions/comparison/LessThanIns.java | 98 +- .../comparison/StrictEqualsIns.java | 98 +- .../construction/ConstructIns.java | 238 +- .../construction/ConstructPropIns.java | 188 +- .../construction/ConstructSuperIns.java | 136 +- .../construction/NewActivationIns.java | 94 +- .../construction/NewArrayIns.java | 106 +- .../construction/NewCatchIns.java | 96 +- .../construction/NewClassIns.java | 108 +- .../construction/NewFunctionIns.java | 98 +- .../construction/NewObjectIns.java | 112 +- .../avm2/instructions/executing/CallIns.java | 138 +- .../instructions/executing/CallMethodIns.java | 140 +- .../executing/CallPropLexIns.java | 132 +- .../executing/CallPropVoidIns.java | 170 +- .../executing/CallPropertyIns.java | 166 +- .../instructions/executing/CallStaticIns.java | 140 +- .../instructions/executing/CallSuperIns.java | 164 +- .../executing/CallSuperVoidIns.java | 166 +- .../abc/avm2/instructions/jumps/IfEqIns.java | 116 +- .../avm2/instructions/jumps/IfFalseIns.java | 110 +- .../abc/avm2/instructions/jumps/IfGeIns.java | 116 +- .../abc/avm2/instructions/jumps/IfGtIns.java | 116 +- .../abc/avm2/instructions/jumps/IfLeIns.java | 116 +- .../abc/avm2/instructions/jumps/IfLtIns.java | 116 +- .../abc/avm2/instructions/jumps/IfNGeIns.java | 116 +- .../abc/avm2/instructions/jumps/IfNGtIns.java | 116 +- .../abc/avm2/instructions/jumps/IfNLeIns.java | 116 +- .../abc/avm2/instructions/jumps/IfNLtIns.java | 116 +- .../abc/avm2/instructions/jumps/IfNeIns.java | 116 +- .../instructions/jumps/IfStrictEqIns.java | 116 +- .../instructions/jumps/IfStrictNeIns.java | 116 +- .../avm2/instructions/jumps/IfTrueIns.java | 110 +- .../abc/avm2/instructions/jumps/JumpIns.java | 92 +- .../instructions/jumps/LookupSwitchIns.java | 96 +- .../instructions/localregs/DecLocalIIns.java | 150 +- .../instructions/localregs/DecLocalIns.java | 148 +- .../instructions/localregs/GetLocal0Ins.java | 124 +- .../localregs/GetLocalTypeIns.java | 134 +- .../instructions/localregs/IncLocalIIns.java | 108 +- .../instructions/localregs/IncLocalIns.java | 108 +- .../avm2/instructions/localregs/KillIns.java | 82 +- .../localregs/SetLocalTypeIns.java | 264 +- .../instructions/other/DeletePropertyIns.java | 146 +- .../avm2/instructions/other/FindDefIns.java | 100 +- .../instructions/other/FindPropertyIns.java | 136 +- .../other/FindPropertyStrictIns.java | 134 +- .../instructions/other/GetDescendantsIns.java | 138 +- .../instructions/other/GetGlobalScopeIns.java | 124 +- .../instructions/other/GetGlobalSlotIns.java | 132 +- .../avm2/instructions/other/GetLexIns.java | 102 +- .../instructions/other/GetPropertyIns.java | 128 +- .../instructions/other/GetScopeObjectIns.java | 94 +- .../avm2/instructions/other/GetSlotIns.java | 170 +- .../avm2/instructions/other/GetSuperIns.java | 118 +- .../avm2/instructions/other/HasNext2Ins.java | 104 +- .../avm2/instructions/other/HasNextIns.java | 100 +- .../abc/avm2/instructions/other/InIns.java | 98 +- .../instructions/other/InitPropertyIns.java | 122 +- .../avm2/instructions/other/NextNameIns.java | 98 +- .../avm2/instructions/other/NextValueIns.java | 98 +- .../instructions/other/ReturnValueIns.java | 94 +- .../instructions/other/ReturnVoidIns.java | 84 +- .../instructions/other/SetGlobalSlotIns.java | 108 +- .../instructions/other/SetPropertyIns.java | 6 +- .../avm2/instructions/other/SetSlotIns.java | 362 +- .../avm2/instructions/other/SetSuperIns.java | 152 +- .../abc/avm2/instructions/other/ThrowIns.java | 94 +- .../abc/avm2/instructions/stack/DupIns.java | 118 +- .../abc/avm2/instructions/stack/PopIns.java | 8 +- .../avm2/instructions/stack/PopScopeIns.java | 116 +- .../avm2/instructions/stack/PushByteIns.java | 106 +- .../instructions/stack/PushDoubleIns.java | 106 +- .../avm2/instructions/stack/PushFalseIns.java | 106 +- .../avm2/instructions/stack/PushIntIns.java | 106 +- .../instructions/stack/PushNamespaceIns.java | 94 +- .../avm2/instructions/stack/PushNanIns.java | 94 +- .../avm2/instructions/stack/PushNullIns.java | 94 +- .../avm2/instructions/stack/PushScopeIns.java | 114 +- .../avm2/instructions/stack/PushShortIns.java | 2 +- .../instructions/stack/PushStringIns.java | 106 +- .../avm2/instructions/stack/PushTrueIns.java | 106 +- .../avm2/instructions/stack/PushUIntIns.java | 106 +- .../instructions/stack/PushUndefinedIns.java | 94 +- .../avm2/instructions/stack/PushWithIns.java | 112 +- .../abc/avm2/instructions/stack/SwapIns.java | 124 +- .../avm2/instructions/types/ApplyTypeIns.java | 132 +- .../avm2/instructions/types/AsTypeIns.java | 122 +- .../instructions/types/AsTypeLateIns.java | 118 +- .../avm2/instructions/types/CoerceAIns.java | 128 +- .../avm2/instructions/types/CoerceIns.java | 4 +- .../avm2/instructions/types/CoerceSIns.java | 120 +- .../avm2/instructions/types/ConvertBIns.java | 140 +- .../avm2/instructions/types/ConvertDIns.java | 156 +- .../avm2/instructions/types/ConvertIIns.java | 152 +- .../avm2/instructions/types/ConvertOIns.java | 118 +- .../avm2/instructions/types/ConvertSIns.java | 120 +- .../avm2/instructions/types/ConvertUIns.java | 118 +- .../instructions/types/InstanceOfIns.java | 98 +- .../avm2/instructions/types/IsTypeIns.java | 100 +- .../instructions/types/IsTypeLateIns.java | 98 +- .../avm2/instructions/types/TypeOfIns.java | 94 +- .../avm2/instructions/xml/CheckFilterIns.java | 108 +- .../avm2/instructions/xml/DXNSLateIns.java | 112 +- .../avm2/instructions/xml/EscXAttrIns.java | 110 +- .../avm2/instructions/xml/EscXElemIns.java | 110 +- .../flash/abc/avm2/model/WithAVM2Item.java | 178 +- .../abc/avm2/model/clauses/TryAVM2Item.java | 328 +- .../parser/script/AVM2SourceGenerator.java | 2 +- .../avm2/parser/script/ActionScriptLexer.java | 4464 ++++++------- .../parser/script/ActionScriptParser.java | 18 +- .../avm2/parser/script/PackageAVM2Item.java | 2 +- .../avm2/parser/script/PropertyAVM2Item.java | 2 +- .../parser/script/UnresolvedAVM2Item.java | 2 +- .../jpexs/decompiler/flash/action/Action.java | 2648 ++++---- .../action/flashlite/ActionFSCommand2.java | 96 +- .../action/flashlite/ActionStrictMode.java | 2 +- .../parser/script/ActionScriptLexer.java | 2 +- .../flash/action/special/ActionEnd.java | 92 +- .../flash/action/special/ActionNop.java | 80 +- .../flash/action/swf3/ActionGetURL.java | 2 +- .../flash/action/swf3/ActionGoToLabel.java | 2 +- .../flash/action/swf3/ActionGotoFrame.java | 2 +- .../flash/action/swf3/ActionNextFrame.java | 82 +- .../flash/action/swf3/ActionPlay.java | 2 +- .../flash/action/swf3/ActionPrevFrame.java | 82 +- .../flash/action/swf3/ActionSetTarget.java | 2 +- .../flash/action/swf3/ActionStop.java | 82 +- .../flash/action/swf3/ActionStopSounds.java | 82 +- .../action/swf3/ActionToggleQuality.java | 82 +- .../flash/action/swf3/ActionWaitForFrame.java | 2 +- .../flash/action/swf4/ActionAdd.java | 86 +- .../flash/action/swf4/ActionAnd.java | 86 +- .../flash/action/swf4/ActionAsciiToChar.java | 84 +- .../flash/action/swf4/ActionCall.java | 90 +- .../flash/action/swf4/ActionCharToAscii.java | 84 +- .../flash/action/swf4/ActionCloneSprite.java | 88 +- .../flash/action/swf4/ActionDivide.java | 86 +- .../flash/action/swf4/ActionEndDrag.java | 82 +- .../flash/action/swf4/ActionEquals.java | 86 +- .../flash/action/swf4/ActionGetProperty.java | 108 +- .../flash/action/swf4/ActionGetTime.java | 82 +- .../flash/action/swf4/ActionGetURL2.java | 2 +- .../flash/action/swf4/ActionGetVariable.java | 110 +- .../flash/action/swf4/ActionGotoFrame2.java | 2 +- .../flash/action/swf4/ActionLess.java | 86 +- .../action/swf4/ActionMBAsciiToChar.java | 84 +- .../action/swf4/ActionMBCharToAscii.java | 84 +- .../action/swf4/ActionMBStringExtract.java | 88 +- .../action/swf4/ActionMBStringLength.java | 84 +- .../flash/action/swf4/ActionMultiply.java | 86 +- .../flash/action/swf4/ActionNot.java | 84 +- .../flash/action/swf4/ActionOr.java | 86 +- .../flash/action/swf4/ActionPop.java | 96 +- .../flash/action/swf4/ActionPush.java | 2 +- .../flash/action/swf4/ActionRandomNumber.java | 84 +- .../flash/action/swf4/ActionRemoveSprite.java | 84 +- .../flash/action/swf4/ActionSetProperty.java | 224 +- .../flash/action/swf4/ActionSetTarget2.java | 84 +- .../flash/action/swf4/ActionSetVariable.java | 260 +- .../flash/action/swf4/ActionStartDrag.java | 126 +- .../flash/action/swf4/ActionStringAdd.java | 86 +- .../flash/action/swf4/ActionStringEquals.java | 86 +- .../action/swf4/ActionStringExtract.java | 88 +- .../flash/action/swf4/ActionStringLength.java | 84 +- .../flash/action/swf4/ActionStringLess.java | 86 +- .../flash/action/swf4/ActionSubtract.java | 86 +- .../flash/action/swf4/ActionToInteger.java | 84 +- .../flash/action/swf4/ActionTrace.java | 84 +- .../action/swf4/ActionWaitForFrame2.java | 2 +- .../flash/action/swf5/ActionAdd2.java | 86 +- .../flash/action/swf5/ActionBitAnd.java | 86 +- .../flash/action/swf5/ActionBitLShift.java | 86 +- .../flash/action/swf5/ActionBitOr.java | 86 +- .../flash/action/swf5/ActionBitRShift.java | 86 +- .../flash/action/swf5/ActionBitURShift.java | 86 +- .../flash/action/swf5/ActionBitXor.java | 86 +- .../flash/action/swf5/ActionCallFunction.java | 102 +- .../flash/action/swf5/ActionCallMethod.java | 98 +- .../flash/action/swf5/ActionConstantPool.java | 2 +- .../flash/action/swf5/ActionDecrement.java | 84 +- .../flash/action/swf5/ActionDefineLocal.java | 90 +- .../flash/action/swf5/ActionDefineLocal2.java | 84 +- .../flash/action/swf5/ActionDelete.java | 88 +- .../flash/action/swf5/ActionDelete2.java | 86 +- .../flash/action/swf5/ActionEnumerate.java | 92 +- .../flash/action/swf5/ActionEquals2.java | 86 +- .../flash/action/swf5/ActionGetMember.java | 86 +- .../flash/action/swf5/ActionIncrement.java | 84 +- .../flash/action/swf5/ActionInitArray.java | 94 +- .../flash/action/swf5/ActionInitObject.java | 98 +- .../flash/action/swf5/ActionLess2.java | 86 +- .../flash/action/swf5/ActionModulo.java | 86 +- .../flash/action/swf5/ActionNewMethod.java | 98 +- .../flash/action/swf5/ActionNewObject.java | 96 +- .../action/swf5/ActionPushDuplicate.java | 88 +- .../flash/action/swf5/ActionReturn.java | 94 +- .../flash/action/swf5/ActionSetMember.java | 240 +- .../flash/action/swf5/ActionStackSwap.java | 92 +- .../action/swf5/ActionStoreRegister.java | 2 +- .../flash/action/swf5/ActionTargetPath.java | 84 +- .../flash/action/swf5/ActionToNumber.java | 84 +- .../flash/action/swf5/ActionToString.java | 84 +- .../flash/action/swf5/ActionTypeOf.java | 84 +- .../flash/action/swf6/ActionEnumerate2.java | 92 +- .../flash/action/swf6/ActionGreater.java | 86 +- .../flash/action/swf6/ActionInstanceOf.java | 86 +- .../flash/action/swf6/ActionStrictEquals.java | 86 +- .../action/swf6/ActionStringGreater.java | 2 +- .../flash/action/swf7/ActionCastOp.java | 86 +- .../flash/action/swf7/ActionExtends.java | 86 +- .../flash/action/swf7/ActionImplementsOp.java | 96 +- .../flash/action/swf7/ActionThrow.java | 94 +- .../jpexs/decompiler/flash/gui/MainPanel.java | 4 +- .../decompiler/flash/gui/QuickFindPanel.java | 2 +- .../decompiler/flash/gui/TagTreeModel.java | 25 +- .../flash/gui/abc/DecompiledEditorPane.java | 2 +- .../flash/gui/proxy/ProxyFrame.java | 848 +-- .../flash/tags/DefineButton2Tag.java | 2 +- .../flash/tags/DefineButtonTag.java | 2 +- .../flash/tags/DefineSpriteTag.java | 2 +- src/com/jpexs/helpers/SoundPlayer.java | 204 +- 253 files changed, 19088 insertions(+), 19091 deletions(-) diff --git a/src/com/jpexs/decompiler/flash/SWF.java b/src/com/jpexs/decompiler/flash/SWF.java index 6a307618b..6e6aa138e 100644 --- a/src/com/jpexs/decompiler/flash/SWF.java +++ b/src/com/jpexs/decompiler/flash/SWF.java @@ -1,2936 +1,2936 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash; - -import SevenZip.Compression.LZMA.Encoder; -import com.jpacker.JPacker; -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.ClassPath; -import com.jpexs.decompiler.flash.abc.RenameType; -import com.jpexs.decompiler.flash.abc.ScriptPack; -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.ActionDeobfuscation; -import com.jpexs.decompiler.flash.action.ActionGraphSource; -import com.jpexs.decompiler.flash.action.ActionLocalData; -import com.jpexs.decompiler.flash.action.model.ConstantPool; -import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; -import com.jpexs.decompiler.flash.action.model.FunctionActionItem; -import com.jpexs.decompiler.flash.action.model.GetMemberActionItem; -import com.jpexs.decompiler.flash.action.model.GetVariableActionItem; -import com.jpexs.decompiler.flash.action.model.clauses.ClassActionItem; -import com.jpexs.decompiler.flash.action.model.clauses.InterfaceActionItem; -import com.jpexs.decompiler.flash.action.swf4.ActionEquals; -import com.jpexs.decompiler.flash.action.swf4.ActionGetVariable; -import com.jpexs.decompiler.flash.action.swf4.ActionIf; -import com.jpexs.decompiler.flash.action.swf4.ActionPush; -import com.jpexs.decompiler.flash.action.swf4.ActionSetVariable; -import com.jpexs.decompiler.flash.action.swf4.ConstantIndex; -import com.jpexs.decompiler.flash.action.swf5.ActionCallFunction; -import com.jpexs.decompiler.flash.action.swf5.ActionCallMethod; -import com.jpexs.decompiler.flash.action.swf5.ActionConstantPool; -import com.jpexs.decompiler.flash.action.swf5.ActionDefineFunction; -import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal; -import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal2; -import com.jpexs.decompiler.flash.action.swf5.ActionEquals2; -import com.jpexs.decompiler.flash.action.swf5.ActionGetMember; -import com.jpexs.decompiler.flash.action.swf5.ActionNewMethod; -import com.jpexs.decompiler.flash.action.swf5.ActionNewObject; -import com.jpexs.decompiler.flash.action.swf5.ActionSetMember; -import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2; -import com.jpexs.decompiler.flash.configuration.Configuration; -import com.jpexs.decompiler.flash.dumpview.DumpInfoSwfNode; -import com.jpexs.decompiler.flash.ecma.Null; -import com.jpexs.decompiler.flash.exporters.BinaryDataExporter; -import com.jpexs.decompiler.flash.exporters.FontExporter; -import com.jpexs.decompiler.flash.exporters.ImageExporter; -import com.jpexs.decompiler.flash.exporters.MorphShapeExporter; -import com.jpexs.decompiler.flash.exporters.MovieExporter; -import com.jpexs.decompiler.flash.exporters.ShapeExporter; -import com.jpexs.decompiler.flash.exporters.SoundExporter; -import com.jpexs.decompiler.flash.exporters.TextExporter; -import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle; -import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; -import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; -import com.jpexs.decompiler.flash.exporters.modes.FramesExportMode; -import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; -import com.jpexs.decompiler.flash.exporters.settings.BinaryDataExportSettings; -import com.jpexs.decompiler.flash.exporters.settings.FontExportSettings; -import com.jpexs.decompiler.flash.exporters.settings.FramesExportSettings; -import com.jpexs.decompiler.flash.exporters.settings.ImageExportSettings; -import com.jpexs.decompiler.flash.exporters.settings.MorphShapeExportSettings; -import com.jpexs.decompiler.flash.exporters.settings.MovieExportSettings; -import com.jpexs.decompiler.flash.exporters.settings.ShapeExportSettings; -import com.jpexs.decompiler.flash.exporters.settings.SoundExportSettings; -import com.jpexs.decompiler.flash.exporters.settings.TextExportSettings; -import com.jpexs.decompiler.flash.exporters.shape.CanvasShapeExporter; -import com.jpexs.decompiler.flash.helpers.collections.MyEntry; -import com.jpexs.decompiler.flash.tags.ABCContainerTag; -import com.jpexs.decompiler.flash.tags.DefineButton2Tag; -import com.jpexs.decompiler.flash.tags.DefineButtonTag; -import com.jpexs.decompiler.flash.tags.DefineSpriteTag; -import com.jpexs.decompiler.flash.tags.DoInitActionTag; -import com.jpexs.decompiler.flash.tags.EndTag; -import com.jpexs.decompiler.flash.tags.ExportAssetsTag; -import com.jpexs.decompiler.flash.tags.FileAttributesTag; -import com.jpexs.decompiler.flash.tags.JPEGTablesTag; -import com.jpexs.decompiler.flash.tags.SetBackgroundColorTag; -import com.jpexs.decompiler.flash.tags.ShowFrameTag; -import com.jpexs.decompiler.flash.tags.SymbolClassTag; -import com.jpexs.decompiler.flash.tags.Tag; -import com.jpexs.decompiler.flash.tags.TagStub; -import com.jpexs.decompiler.flash.tags.VideoFrameTag; -import com.jpexs.decompiler.flash.tags.base.ASMSource; -import com.jpexs.decompiler.flash.tags.base.BoundedTag; -import com.jpexs.decompiler.flash.tags.base.ButtonTag; -import com.jpexs.decompiler.flash.tags.base.CharacterIdTag; -import com.jpexs.decompiler.flash.tags.base.CharacterTag; -import com.jpexs.decompiler.flash.tags.base.Container; -import com.jpexs.decompiler.flash.tags.base.ContainerItem; -import com.jpexs.decompiler.flash.tags.base.DrawableTag; -import com.jpexs.decompiler.flash.tags.base.FontTag; -import com.jpexs.decompiler.flash.tags.base.ImageTag; -import com.jpexs.decompiler.flash.tags.base.MorphShapeTag; -import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; -import com.jpexs.decompiler.flash.tags.base.RemoveTag; -import com.jpexs.decompiler.flash.tags.base.ShapeTag; -import com.jpexs.decompiler.flash.tags.base.TextTag; -import com.jpexs.decompiler.flash.timeline.Clip; -import com.jpexs.decompiler.flash.timeline.DepthState; -import com.jpexs.decompiler.flash.timeline.Frame; -import com.jpexs.decompiler.flash.timeline.SvgClip; -import com.jpexs.decompiler.flash.timeline.Timeline; -import com.jpexs.decompiler.flash.timeline.Timelined; -import com.jpexs.decompiler.flash.treeitems.AS2PackageNodeItem; -import com.jpexs.decompiler.flash.treeitems.AS3PackageNodeItem; -import com.jpexs.decompiler.flash.treeitems.FrameNodeItem; -import com.jpexs.decompiler.flash.treeitems.SWFList; -import com.jpexs.decompiler.flash.treeitems.TreeItem; -import com.jpexs.decompiler.flash.treenodes.AS2PackageNode; -import com.jpexs.decompiler.flash.treenodes.ContainerNode; -import com.jpexs.decompiler.flash.treenodes.FrameNode; -import com.jpexs.decompiler.flash.treenodes.TagNode; -import com.jpexs.decompiler.flash.treenodes.TreeNode; -import com.jpexs.decompiler.flash.types.ColorTransform; -import com.jpexs.decompiler.flash.types.MATRIX; -import com.jpexs.decompiler.flash.types.RECT; -import com.jpexs.decompiler.flash.types.RGB; -import com.jpexs.decompiler.flash.types.RGBA; -import com.jpexs.decompiler.flash.types.filters.BEVELFILTER; -import com.jpexs.decompiler.flash.types.filters.BlendComposite; -import com.jpexs.decompiler.flash.types.filters.COLORMATRIXFILTER; -import com.jpexs.decompiler.flash.types.filters.CONVOLUTIONFILTER; -import com.jpexs.decompiler.flash.types.filters.DROPSHADOWFILTER; -import com.jpexs.decompiler.flash.types.filters.FILTER; -import com.jpexs.decompiler.flash.types.filters.GLOWFILTER; -import com.jpexs.decompiler.flash.types.filters.GRADIENTBEVELFILTER; -import com.jpexs.decompiler.flash.types.filters.GRADIENTGLOWFILTER; -import com.jpexs.decompiler.flash.xfl.FLAVersion; -import com.jpexs.decompiler.flash.xfl.XFLConverter; -import com.jpexs.decompiler.graph.Graph; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.decompiler.graph.GraphSourceItemContainer; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.model.LocalData; -import com.jpexs.helpers.Cache; -import com.jpexs.helpers.CancellableWorker; -import com.jpexs.helpers.Helper; -import com.jpexs.helpers.NulStream; -import com.jpexs.helpers.ProgressListener; -import com.jpexs.helpers.SerializableImage; -import com.jpexs.helpers.utf8.Utf8Helper; -import gnu.jpdf.PDFJob; -import java.awt.AlphaComposite; -import java.awt.Color; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.RenderingHints; -import java.awt.Shape; -import java.awt.geom.AffineTransform; -import java.awt.image.BufferedImage; -import java.awt.print.PageFormat; -import java.awt.print.Paper; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.EmptyStackException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; -import java.util.Stack; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.zip.DeflaterOutputStream; -import java.util.zip.InflaterInputStream; -import javax.imageio.ImageIO; -import javax.imageio.stream.FileImageOutputStream; -import javax.imageio.stream.ImageOutputStream; -import javax.xml.bind.DatatypeConverter; -import net.kroo.elliot.GifSequenceWriter; -import org.monte.media.VideoFormatKeys; -import org.monte.media.avi.AVIWriter; - -/** - * Class representing SWF file - * - * @author JPEXS - */ -public final class SWF implements TreeItem, Timelined { - - /** - * Default version of SWF file format - */ - public static final int DEFAULT_VERSION = 10; - /** - * Tags inside of file - */ - public List tags = new ArrayList<>(); - public boolean hasEndTag; - /** - * ExportRectangle 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; - /** - * Uncompressed size of the file - */ - public long fileSize; - /** - * Used compression mode - */ - public SWFCompression compression = SWFCompression.NONE; - /** - * Compressed size of the file (LZMA) - */ - public long compressedSize; - /** - * LZMA Properties - */ - public byte[] lzmaProperties; - public byte[] uncompressedData; - public FileAttributesTag fileAttributes; - /** - * ScaleForm GFx - */ - public boolean gfx = false; - - public SWFList swfList; - public String file; - public String fileTitle; - public boolean readOnly; - public boolean isAS3; - public Map characters = new HashMap<>(); - public List abcList; - public JPEGTablesTag jtt; - public Map sourceFontsMap = new HashMap<>(); - public static final double unitDivisor = 20; - - private Timeline timeline; - - public DumpInfoSwfNode dumpInfo; - - public void updateCharacters() { - characters.clear(); - parseCharacters(new ArrayList(tags)); - } - - public void resetTimelines(Timelined timelined) { - timelined.resetTimeline(); - List tags = timelined.getTimeline().tags; - for (int i = 0; i < tags.size(); i++) { - Tag t = tags.get(i); - if (t instanceof Timelined) { - resetTimelines((Timelined) t); - } - } - } - - private void parseCharacters(List list) { - for (ContainerItem t : list) { - if (t instanceof CharacterTag) { - characters.put(((CharacterTag) t).getCharacterId(), (CharacterTag) t); - } - if (t instanceof Container) { - parseCharacters(((Container) t).getSubItems()); - } - } - } - - /** - * Unresolve recursive sprites - */ - private void checkInvalidSprites() { - for (int i = 0; i < tags.size(); i++) { - Tag t = tags.get(i); - if (t instanceof DefineSpriteTag) { - if (!isSpriteValid((DefineSpriteTag) t, new ArrayList())) { - tags.set(i, new TagStub(this, t.getId(), "InvalidSprite", t.getOriginalRange(), null)); - } - } - } - } - - private boolean isSpriteValid(DefineSpriteTag sprite, List path) { - if (path.contains(sprite.spriteId)) { - return false; - } - path.add(sprite.spriteId); - for (Tag t : sprite.subTags) { - if (t instanceof DefineSpriteTag) { - if (!isSpriteValid((DefineSpriteTag) t, path)) { - return false; - } - } - } - path.remove((Integer) sprite.spriteId); - return true; - } - - @Override - public Timeline getTimeline() { - if (timeline == null) { - timeline = new Timeline(this); - } - return timeline; - } - - @Override - public void resetTimeline() { - timeline = null; - } - - /** - * 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 { - saveTo(os, compression); - } - - /** - * Saves this SWF into new file - * - * @param os OutputStream to save SWF in - * @param compression - * @throws IOException - */ - public void saveTo(OutputStream os, SWFCompression compression) 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); - if (hasEndTag) { - sos.writeUI16(0); - } - sos.close(); - if (compression == SWFCompression.LZMA) { - os.write('Z'); - } else if (compression == SWFCompression.ZLIB) { - os.write('C'); - } else { - if (gfx) { - os.write('G'); - } else { - os.write('F'); - } - } - if (gfx) { - os.write('F'); - os.write('X'); - } else { - os.write('W'); - os.write('S'); - } - os.write(version); - byte[] data = baos.toByteArray(); - sos = new SWFOutputStream(os, version); - sos.writeUI32(data.length + 8); - - if (compression == SWFCompression.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 if (compression == SWFCompression.ZLIB) { - os = new DeflaterOutputStream(os); - } - os.write(data); - } finally { - if (os != null) { - os.close(); - } - } - } - - public void clearModified() { - for (Tag tag : tags) { - if (tag.isModified()) { - tag.createOriginalData(); - tag.setModified(false); - } - } - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try { - saveTo(baos, SWFCompression.NONE); - byte[] swfData = baos.toByteArray(); - uncompressedData = swfData; - } catch (IOException ex) { - Logger.getLogger(SWF.class.getName()).log(Level.SEVERE, "Cannot save SWF", ex); - } - } - - public SWF(InputStream is, boolean parallelRead) throws IOException, InterruptedException { - this(is, null, parallelRead); - } - - /** - * Construct SWF from stream - * - * @param is Stream to read SWF from - * @param listener - * @param parallelRead Use parallel threads? - * @throws IOException - * @throws java.lang.InterruptedException - */ - public SWF(InputStream is, ProgressListener listener, boolean parallelRead) throws IOException, InterruptedException { - this(is, listener, parallelRead, false); - } - - /** - * Faster constructor to check SWF only - * - * @param is - * @throws java.io.IOException - */ - public SWF(InputStream is) throws IOException { - decompress(is, new NulStream(), true); - } - - /** - * Construct SWF from stream - * - * @param is Stream to read SWF from - * @param listener - * @param parallelRead Use parallel threads? - * @param checkOnly Check only file validity - * @throws IOException - * @throws java.lang.InterruptedException - */ - public SWF(InputStream is, ProgressListener listener, boolean parallelRead, boolean checkOnly) throws IOException, InterruptedException { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - SWFHeader header = decompress(is, baos, true); - gfx = header.gfx; - compression = header.compression; - uncompressedData = baos.toByteArray(); - - SWFInputStream sis = new SWFInputStream(this, uncompressedData); - dumpInfo = new DumpInfoSwfNode(this, "rootswf", "", null, 0, 0); - if (Configuration.dumpInfoCollecting.get()) { - sis.dumpInfo = dumpInfo; - } - sis.readBytesEx(3, "signature"); // skip siganture - version = sis.readUI8("version"); - fileSize = sis.readUI32("fileSize"); - dumpInfo.lengthBytes = fileSize; - if (listener != null) { - sis.addPercentListener(listener); - } - sis.setPercentMax(fileSize); - displayRect = sis.readRECT("displayRect"); - // FIXED8 (16 bit fixed point) frameRate - sis.readUI8("tmpFirstByetOfFrameRate"); //tmpFirstByetOfFrameRate - frameRate = sis.readUI8("frameRate"); - frameCount = sis.readUI16("frameCount"); - List tags = sis.readTagList(this, 0, parallelRead, true, !checkOnly, gfx); - if (tags.get(tags.size() - 1).getId() == EndTag.ID) { - hasEndTag = true; - tags.remove(tags.size() - 1); - } - this.tags = tags; - if (!checkOnly) { - checkInvalidSprites(); - updateCharacters(); - assignExportNamesToSymbols(); - assignClassesToSymbols(); - findFileAttributes(); - findABCTags(); - } else { - boolean hasNonUnknownTag = false; - for (Tag tag : tags) { - if (tag.getOriginalDataLength() > 0 && Tag.getRequiredTags().contains(tag.getId())) { - hasNonUnknownTag = true; - } - } - if (!hasNonUnknownTag) { - throw new IOException("Invalid SWF file. No known tag found."); - } - } - } - - @Override - public SWF getSwf() { - return this; - } - - /** - * Get title of the file - * - * @return file title - */ - public String getFileTitle() { - if (fileTitle != null) { - return fileTitle; - } - return file; - } - - public String getShortFileName() { - String title = getFileTitle(); - if (title == null) { - return ""; - } - return new File(title).getName(); - } - - private void findABCTags() { - List objs = new ArrayList<>(); - objs.addAll(tags); - - ArrayList newAbcList = new ArrayList<>(); - getABCTags(objs, newAbcList); - this.abcList = newAbcList; - } - - private static void getABCTags(List list, List actionScripts) { - for (ContainerItem t : list) { - if (t instanceof Container) { - getABCTags(((Container) t).getSubItems(), actionScripts); - } - if (t instanceof ABCContainerTag) { - actionScripts.add((ABCContainerTag) t); - } - } - } - - private void findFileAttributes() { - for (Tag t : tags) { - if (t instanceof FileAttributesTag) { - fileAttributes = (FileAttributesTag) t; - break; - } - } - } - - private void assignExportNamesToSymbols() { - HashMap exportNames = new HashMap<>(); - for (Tag t : tags) { - if (t instanceof ExportAssetsTag) { - ExportAssetsTag eat = (ExportAssetsTag) t; - for (int i = 0; i < eat.tags.size(); i++) { - if ((!exportNames.containsKey(eat.tags.get(i))) && (!exportNames.containsValue(eat.names.get(i)))) { - exportNames.put(eat.tags.get(i), eat.names.get(i)); - } - } - } - } - for (Tag t : tags) { - if (t instanceof CharacterIdTag) { - CharacterIdTag ct = (CharacterIdTag) t; - if (exportNames.containsKey(ct.getCharacterId())) { - ct.setExportName(exportNames.get(ct.getCharacterId())); - } - } - } - } - - public void assignClassesToSymbols() { - HashMap classes = new HashMap<>(); - for (Tag t : tags) { - if (t instanceof SymbolClassTag) { - SymbolClassTag sct = (SymbolClassTag) t; - for (int i = 0; i < sct.tags.length; i++) { - if ((!classes.containsKey(sct.tags[i])) && (!classes.containsValue(sct.names[i]))) { - classes.put(sct.tags[i], sct.names[i]); - } - } - } - } - for (Tag t : tags) { - if (t instanceof CharacterTag) { - CharacterTag ct = (CharacterTag) t; - if (classes.containsKey(ct.getCharacterId())) { - ct.setClassName(classes.get(ct.getCharacterId())); - } - } - } - } - - /** - * Compress SWF file - * - * @param fis Input stream - * @param fos Output stream - * @return True on success - */ - 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 (IOException ex) { - return false; - } - return true; - } - - public static boolean decompress(InputStream fis, OutputStream fos) { - try { - decompress(fis, fos, false); - return true; - } catch (IOException ex) { - return false; - } - } - - private static SWFHeader decompress(InputStream is, OutputStream os, boolean allowUncompressed) throws IOException { - byte[] hdr = new byte[8]; - - // SWFheader: signature, version and fileSize - if (is.read(hdr) != 8) { - throw new IOException("SWF header is too short"); - } - - String signature = new String(hdr, 0, 3, Utf8Helper.charset); - if (!Arrays.asList( - "FWS", //Uncompressed Flash - "CWS", //ZLib compressed Flash - "ZWS", //LZMA compressed Flash - "GFX", //Uncompressed ScaleForm GFx - "CFX" //Compressed ScaleForm GFx - ).contains(signature)) { - throw new IOException("Invalid SWF file"); - } - - int version = hdr[3]; - SWFInputStream sis = new SWFInputStream(null, Arrays.copyOfRange(hdr, 4, 8), 4, 4); - long fileSize = sis.readUI32("fileSize"); - SWFHeader header = new SWFHeader(); - header.version = version; - header.fileSize = fileSize; - - if (hdr[1] == 'F' && hdr[2] == 'X') { - header.gfx = true; - } - - try (SWFOutputStream sos = new SWFOutputStream(os, version)) { - sos.write(Utf8Helper.getBytes("FWS")); - sos.writeUI8(version); - sos.writeUI32(fileSize); - - switch (hdr[0]) { - case 'C': { // CWS, CFX - Helper.copyStream(new InflaterInputStream(is), os, fileSize - 8); - header.compression = SWFCompression.ZLIB; - break; - } - case 'Z': { // ZWS - sis.readUI32("LZMAsize"); // compressed LZMA data size = compressed SWF - 17 byte, - // where 17 = 8 byte header + this 4 byte + 5 bytes decoder properties - int propertiesSize = 5; - byte[] lzmaProperties = sis.readBytes(propertiesSize, "lzmaproperties"); - if (lzmaProperties.length != 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"); - } - if (!decoder.Code(is, os, fileSize - 8)) { - throw new IOException("LZMA:Error in data stream"); - } - - header.compression = SWFCompression.LZMA; - break; - } - default: { // FWS, GFX - if (allowUncompressed) { - Helper.copyStream(is, os, fileSize - 8); - } else { - throw new IOException("SWF is not compressed"); - } - } - } - - return header; - } - } - - public static boolean renameInvalidIdentifiers(RenameType renameType, InputStream fis, OutputStream fos) { - try { - SWF swf = new SWF(fis, Configuration.parallelSpeedUp.get()); - int cnt = swf.deobfuscateIdentifiers(renameType); - swf.assignClassesToSymbols(); - System.out.println(cnt + " identifiers renamed."); - swf.saveTo(fos); - } catch (InterruptedException ex) { - return false; - } catch (IOException ex) { - return false; - } - return true; - } - - public boolean exportAS3Class(String className, String outdir, ScriptExportMode exportMode, boolean parallel) throws Exception { - List abcTags = new ArrayList<>(); - - for (Tag t : tags) { - if (t instanceof ABCContainerTag) { - ABCContainerTag cnt = (ABCContainerTag) t; - abcTags.add(cnt); - } - } - - boolean exported = false; - - for (int i = 0; i < abcTags.size(); i++) { - ABC abc = abcTags.get(i).getABC(); - List scrs = abc.findScriptPacksByPath(className); - for (ScriptPack scr : scrs) { - String cnt = ""; - if (abc.script_info.size() > 1) { - cnt = "script " + (i + 1) + "/" + abc.script_info.size() + " "; - } - String exStr = "Exporting " + "tag " + (i + 1) + "/" + abcTags.size() + " " + cnt + scr.getPath() + " ..."; - informListeners("exporting", exStr); - scr.export(outdir, abcTags, exportMode, parallel); - exStr = "Exported " + "tag " + (i + 1) + "/" + abcTags.size() + " " + cnt + scr.getPath() + " ..."; - informListeners("exported", exStr); - exported = true; - } - } - return exported; - } - - private List> uniqueAS3Packs(List> packs) { - List> ret = new ArrayList<>(); - for (MyEntry item : packs) { - for (MyEntry itemOld : ret) { - if (item.key.equals(itemOld.key)) { - Logger.getLogger(SWF.class.getName()).log(Level.SEVERE, "Duplicate pack path found (" + itemOld.key + ")!"); - break; - } - } - ret.add(item); - } - return ret; - } - - public List> getAS3Packs() { - List abcTags = new ArrayList<>(); - for (Tag t : tags) { - if (t instanceof ABCContainerTag) { - abcTags.add((ABCContainerTag) t); - } - } - List> packs = new ArrayList<>(); - for (int i = 0; i < abcTags.size(); i++) { - ABCContainerTag t = abcTags.get(i); - packs.addAll(t.getABC().getScriptPacks()); - } - return uniqueAS3Packs(packs); - } - - @Override - public RECT getRect() { - return displayRect; - } - - private class ExportPackTask implements Callable { - - ScriptPack pack; - String directory; - List abcList; - ScriptExportMode exportMode; - ClassPath path; - AtomicInteger index; - int count; - boolean parallel; - AbortRetryIgnoreHandler handler; - long startTime; - long stopTime; - - public ExportPackTask(AbortRetryIgnoreHandler handler, AtomicInteger index, int count, ClassPath path, ScriptPack pack, String directory, List abcList, ScriptExportMode exportMode, boolean parallel) { - this.pack = pack; - this.directory = directory; - this.abcList = abcList; - this.exportMode = exportMode; - this.path = path; - this.index = index; - this.count = count; - this.parallel = parallel; - this.handler = handler; - } - - @Override - public File call() throws Exception { - RunnableIOExResult rio = new RunnableIOExResult() { - @Override - public void run() throws IOException { - startTime = System.currentTimeMillis(); - this.result = pack.export(directory, abcList, exportMode, parallel); - stopTime = System.currentTimeMillis(); - } - }; - int currentIndex = index.getAndIncrement(); - synchronized (ABC.class) { - long time = stopTime - startTime; - informListeners("exporting", "Exporting script " + currentIndex + "/" + count + " " + path); - } - new RetryTask(rio, handler).run(); - synchronized (ABC.class) { - long time = stopTime - startTime; - informListeners("exported", "Exported script " + currentIndex + "/" + count + " " + path + ", " + Helper.formatTimeSec(time)); - } - return rio.result; - } - } - - public List exportActionScript2(AbortRetryIgnoreHandler handler, String outdir, ScriptExportMode exportMode, boolean parallel, EventListener evl) throws IOException { - List ret = new ArrayList<>(); - 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; - ret.addAll(TagNode.exportNodeAS(handler, list, outdir, exportMode, evl)); - return ret; - } - - public List exportActionScript3(final AbortRetryIgnoreHandler handler, final String outdir, final ScriptExportMode exportMode, final boolean parallel) { - final AtomicInteger cnt = new AtomicInteger(1); - final List abcTags = new ArrayList<>(); - for (Tag t : tags) { - if (t instanceof ABCContainerTag) { - abcTags.add((ABCContainerTag) t); - } - } - - final List ret = new ArrayList<>(); - final List> packs = getAS3Packs(); - - if (!parallel || packs.size() < 2) { - try { - CancellableWorker.call(new Callable() { - @Override - public Void call() throws Exception { - for (MyEntry item : packs) { - ExportPackTask task = new ExportPackTask(handler, cnt, packs.size(), item.key, item.value, outdir, abcTags, exportMode, parallel); - ret.add(task.call()); - } - return null; - } - }, Configuration.exportTimeout.get(), TimeUnit.SECONDS); - } catch (TimeoutException ex) { - Logger.getLogger(ABC.class.getName()).log(Level.SEVERE, Helper.formatTimeToText(Configuration.exportTimeout.get()) + " ActionScript export limit reached", ex); - } catch (Exception ex) { - Logger.getLogger(ABC.class.getName()).log(Level.SEVERE, "Error during ABC export", ex); - } - } else { - ExecutorService executor = Executors.newFixedThreadPool(Configuration.parallelThreadCount.get()); - List> futureResults = new ArrayList<>(); - for (MyEntry item : packs) { - Future future = executor.submit(new ExportPackTask(handler, cnt, packs.size(), item.key, item.value, outdir, abcTags, exportMode, parallel)); - futureResults.add(future); - } - - try { - executor.shutdown(); - if (!executor.awaitTermination(Configuration.exportTimeout.get(), TimeUnit.SECONDS)) { - Logger.getLogger(ABC.class.getName()).log(Level.SEVERE, Helper.formatTimeToText(Configuration.exportTimeout.get()) + " ActionScript export limit reached"); - } - } catch (InterruptedException ex) { - } finally { - executor.shutdownNow(); - } - - for (int f = 0; f < futureResults.size(); f++) { - try { - if (futureResults.get(f).isDone()) { - ret.add(futureResults.get(f).get()); - } - } catch (InterruptedException ex) { - } catch (ExecutionException ex) { - Logger.getLogger(SWF.class.getName()).log(Level.SEVERE, "Error during ABC export", ex); - } - } - } - - return ret; - } - - public List exportActionScript(AbortRetryIgnoreHandler handler, String outdir, ScriptExportMode exportMode, boolean parallel) throws Exception { - boolean asV3Found = false; - List ret = new ArrayList<>(); - final EventListener evl = new EventListener() { - @Override - public void handleEvent(String event, Object data) { - if (event.equals("exporting") || event.equals("exported")) { - informListeners(event, data); - } - } - }; - for (Tag t : tags) { - if (t instanceof ABCContainerTag) { - asV3Found = true; - } - } - - if (asV3Found) { - ret.addAll(exportActionScript3(handler, outdir, exportMode, parallel)); - } else { - ret.addAll(exportActionScript2(handler, outdir, exportMode, parallel, evl)); - } - return ret; - } - - public static List createASTagList(List list, Timelined parent) { - List ret = new ArrayList<>(); - int frame = 1; - List frames = new ArrayList<>(); - - List exportAssetsTags = new ArrayList<>(); - for (ContainerItem t : list) { - if (t instanceof ExportAssetsTag) { - exportAssetsTags.add((ExportAssetsTag) t); - } - TreeNode addNode = null; - if (t instanceof ShowFrameTag) { - // do not add PlaceObjects (+etc) to script nodes - FrameNode tti = new FrameNode(new FrameNodeItem(t.getSwf(), frame, parent, false), null, true); - - for (int r = ret.size() - 1; r >= 0; r--) { - if (!(ret.get(r).getItem() instanceof DefineSpriteTag)) { - if (!(ret.get(r).getItem() instanceof DefineButtonTag)) { - if (!(ret.get(r).getItem() instanceof DefineButton2Tag)) { - if (!(ret.get(r).getItem() instanceof DoInitActionTag)) { - if (!(ret.get(r).getItem() instanceof AS2PackageNodeItem)) { - tti.subNodes.add(ret.get(r)); - ret.remove(r); - } - } - } - } - } - } - frame++; - frames.add(tti); - } else if (t instanceof ASMSource) { - ContainerNode tti = new ContainerNode(t); - //ret.add(tti); - addNode = tti; - } else if (t instanceof Container) { - if (((Container) t).getItemCount() > 0) { - - ContainerNode tti = new ContainerNode(t); - List subItems = ((Container) t).getSubItems(); - - Timelined timelined = t instanceof Timelined ? (Timelined) t : null; - tti.subNodes = createASTagList(subItems, timelined); - addNode = tti; - //ret.add(tti); - } - } - if (addNode != null) { - if (addNode.getItem() instanceof CharacterIdTag) { - CharacterIdTag cit = (CharacterIdTag) addNode.getItem(); - String path = cit.getExportName(); - if (path == null) { - path = ""; - } - String[] pathParts; - if (path.contains(".")) { - pathParts = path.split("\\."); - } else { - pathParts = new String[]{path}; - } - List items = ret; - int pos = 0; - TreeNode selNode = null; - do { - if (pos == pathParts.length - 1) { - break; - } - selNode = null; - for (TreeNode node : items) { - if (node.getItem() instanceof AS2PackageNodeItem) { - AS2PackageNodeItem pkg = (AS2PackageNodeItem) node.getItem(); - if (pkg.packageName.equals(pathParts[pos])) { - selNode = node; - break; - } - } - } - int pkgCount = 0; - for (; pkgCount < items.size(); pkgCount++) { - if (items.get(pkgCount).getItem() instanceof AS3PackageNodeItem) { - AS2PackageNodeItem pkg = (AS2PackageNodeItem) items.get(pkgCount).getItem(); - if (pkg.packageName.compareTo(pathParts[pos]) > 0) { - break; - } - } else { - break; - } - } - if (selNode == null) { - items.add(pkgCount, selNode = new AS2PackageNode(new AS2PackageNodeItem(pathParts[pos], t.getSwf()))); - } - pos++; - if (selNode != null) { - items = selNode.subNodes; - } - - } while (selNode != null); - - int clsCount = 0; - for (; clsCount < items.size(); clsCount++) { - if (items.get(clsCount).getItem() instanceof CharacterIdTag) { - CharacterIdTag ct = (CharacterIdTag) items.get(clsCount).getItem(); - String expName = ct.getExportName(); - if (expName == null) { - expName = ""; - } - if (expName.contains(".")) { - expName = expName.substring(expName.lastIndexOf('.') + 1); - } - if ((ct.getClass().getName() + "_" + expName).compareTo(addNode.getItem().getClass().getName() + "_" + pathParts[pos]) > 0) { - break; - } - } - } - items.add(clsCount, addNode); - } else { - ret.add(addNode); - } - } - - } - ret.addAll(frames); - for (int i = ret.size() - 1; i >= 0; i--) { - if (ret.get(i).getItem() instanceof DefineSpriteTag) { - ((DefineSpriteTag) ret.get(i).getItem()).exportAssetsTags = exportAssetsTags; - } - if (ret.get(i).getItem() instanceof DefineButtonTag) { - ((DefineButtonTag) ret.get(i).getItem()).exportAssetsTags = exportAssetsTags; - } - if (ret.get(i).getItem() instanceof DefineButton2Tag) { - ((DefineButton2Tag) ret.get(i).getItem()).exportAssetsTags = exportAssetsTags; - } - /*if (ret.get(i).tag instanceof DoInitActionTag) { - //((DoInitActionTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; - }*/ - if (ret.get(i).getItem() instanceof ASMSource) { - ASMSource ass = (ASMSource) ret.get(i).getItem(); - if (ass.containsSource()) { - continue; - } - } - if (ret.get(i).subNodes.isEmpty()) { - ret.remove(i); - } - } - return ret; - } - - public static void getTagsFromTreeNodes(List treeNodes, List result) { - for (TreeNode treeNode : treeNodes) { - TreeItem treeItem = treeNode.getItem(); - if (treeItem instanceof Tag) { - result.add((Tag) treeItem); - } - getTagsFromTreeNodes(treeNode.subNodes, result); - } - } - - private final HashSet listeners = new HashSet<>(); - - public final void addEventListener(EventListener listener) { - listeners.add(listener); - for (Tag t : tags) { - if (t instanceof ABCContainerTag) { - (((ABCContainerTag) t).getABC()).addEventListener(listener); - } - } - } - - public final void removeEventListener(EventListener listener) { - listeners.remove(listener); - for (Tag t : tags) { - if (t instanceof ABCContainerTag) { - (((ABCContainerTag) t).getABC()).removeEventListener(listener); - } - } - } - - protected void informListeners(String event, Object data) { - for (EventListener listener : listeners) { - listener.handleEvent(event, data); - } - } - - 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 populateVideoFrames(int streamId, List tags, HashMap output) { - for (ContainerItem 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(AbortRetryIgnoreHandler handler, String outdir, MovieExportSettings settings) throws IOException { - new MovieExporter().exportMovies(handler, outdir, tags, settings); - } - - public void exportSounds(AbortRetryIgnoreHandler handler, String outdir, SoundExportSettings settings) throws IOException { - new SoundExporter().exportSounds(handler, outdir, tags, settings); - } - - public void exportFonts(AbortRetryIgnoreHandler handler, String outdir, FontExportSettings settings) throws IOException { - new FontExporter().exportFonts(handler, outdir, tags, settings); - } - - private static void writeLE(OutputStream os, long val, int size) throws IOException { - for (int i = 0; i < size; i++) { - os.write((int) (val & 0xff)); - val >>= 8; - } - } - - public static void createWavFromPcmData(OutputStream fos, int soundRateHz, boolean soundSize, boolean soundType, byte[] data) throws IOException { - ByteArrayOutputStream subChunk1Data = new ByteArrayOutputStream(); - int audioFormat = 1; //PCM - writeLE(subChunk1Data, audioFormat, 2); - int numChannels = soundType ? 2 : 1; - writeLE(subChunk1Data, numChannels, 2); - int[] rateMap = {5512, 11025, 22050, 44100}; - int sampleRate = soundRateHz;//rateMap[soundRate]; - writeLE(subChunk1Data, sampleRate, 4); - int bitsPerSample = soundSize ? 16 : 8; - int byteRate = sampleRate * numChannels * bitsPerSample / 8; - writeLE(subChunk1Data, byteRate, 4); - int blockAlign = numChannels * bitsPerSample / 8; - writeLE(subChunk1Data, blockAlign, 2); - writeLE(subChunk1Data, bitsPerSample, 2); - - ByteArrayOutputStream chunks = new ByteArrayOutputStream(); - chunks.write(Utf8Helper.getBytes("fmt ")); - byte[] subChunk1DataBytes = subChunk1Data.toByteArray(); - writeLE(chunks, subChunk1DataBytes.length, 4); - chunks.write(subChunk1DataBytes); - - chunks.write(Utf8Helper.getBytes("data")); - writeLE(chunks, data.length, 4); - chunks.write(data); - - fos.write(Utf8Helper.getBytes("RIFF")); - byte[] chunkBytes = chunks.toByteArray(); - writeLE(fos, 4 + chunkBytes.length, 4); - fos.write(Utf8Helper.getBytes("WAVE")); - fos.write(chunkBytes); - } - - private static void makeAVI(Iterator images, int frameRate, File file) throws IOException { - if (!images.hasNext()) { - return; - } - AVIWriter out = new AVIWriter(file); - BufferedImage img0 = images.next(); - out.addVideoTrack(VideoFormatKeys.ENCODING_AVI_PNG, 1, frameRate, img0.getWidth(), img0.getHeight(), 0, 0); - try { - while (images.hasNext()) { - out.write(0, images.next(), 1); - } - } finally { - out.close(); - } - - } - - private static void makeGIF(Iterator images, int frameRate, File file) throws IOException { - if (!images.hasNext()) { - return; - } - try (ImageOutputStream output = new FileImageOutputStream(file)) { - BufferedImage img0 = images.next(); - GifSequenceWriter writer = new GifSequenceWriter(output, img0.getType(), 1000 / frameRate, true); - writer.writeToSequence(img0); - - while (images.hasNext()) { - writer.writeToSequence(images.next()); - } - - writer.close(); - } - } - - private static String getTypePrefix(CharacterTag c) { - if (c instanceof ShapeTag) { - return "shape"; - } - if (c instanceof MorphShapeTag) { - return "morphshape"; - } - if (c instanceof DefineSpriteTag) { - return "sprite"; - } - if (c instanceof TextTag) { - return "text"; - } - if (c instanceof ButtonTag) { - return "button"; - } - if (c instanceof FontTag) { - return "font"; - } - if (c instanceof ImageTag) { - return "image"; - } - return "character"; - } - - public static void writeLibrary(SWF fswf, Set library, OutputStream fos) throws IOException { - for (int c : library) { - CharacterTag ch = fswf.characters.get(c); - if (ch instanceof FontTag) { - fos.write(Utf8Helper.getBytes("function " + getTypePrefix(ch) + c + "(ctx,ch,textColor){\r\n")); - fos.write(Utf8Helper.getBytes(((FontTag) ch).toHtmlCanvas(1))); - fos.write(Utf8Helper.getBytes("}\r\n\r\n")); - } else { - fos.write(Utf8Helper.getBytes("function " + getTypePrefix(ch) + c + "(ctx,ctrans,frame,ratio,time){\r\n")); - if (ch instanceof ImageTag) { - ImageTag image = (ImageTag) ch; - String format = image.getImageFormat(); - InputStream imageStream = image.getImageData(); - byte[] imageData; - if (imageStream != null) { - imageData = Helper.readStream(image.getImageData()); - } else { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try { - ImageIO.write(image.getImage().getBufferedImage(), format.toUpperCase(Locale.ENGLISH), baos); - } catch (IOException ex) { - } - imageData = baos.toByteArray(); - } - String base64ImgData = DatatypeConverter.printBase64Binary(imageData); - fos.write(Utf8Helper.getBytes("var imageObj" + c + " = document.createElement(\"img\");\r\nimageObj" + c + ".src=\"data:image/" + format + ";base64," + base64ImgData + "\";\r\n")); - } - if (ch instanceof DrawableTag) { - fos.write(Utf8Helper.getBytes(((DrawableTag) ch).toHtmlCanvas(1))); - } - fos.write(Utf8Helper.getBytes("}\r\n\r\n")); - } - } - } - - public List exportFrames(AbortRetryIgnoreHandler handler, String outdir, int containerId, List frames, final FramesExportSettings settings) throws IOException { - final List ret = new ArrayList<>(); - if (tags.isEmpty()) { - return ret; - } - Timeline tim = null; - String path = ""; - if (containerId == 0) { - tim = getTimeline(); - } else { - tim = ((Timelined) characters.get(containerId)).getTimeline(); - path = File.separator + Helper.makeFileName(characters.get(containerId).getExportFileName()); - } - if (frames == null) { - int frameCnt = tim.frames.size(); - frames = new ArrayList<>(); - for (int i = 0; i < frameCnt; i++) { - frames.add(i); - } - } - - final File foutdir = new File(outdir + path); - if (!foutdir.exists()) { - if (!foutdir.mkdirs()) { - if (!foutdir.exists()) { - throw new IOException("Cannot create directory " + outdir); - } - } - } - - final List fframes = frames; - - Color backgroundColor = null; - if (settings.mode == FramesExportMode.AVI) { - for (Tag t : tags) { - if (t instanceof SetBackgroundColorTag) { - SetBackgroundColorTag sb = (SetBackgroundColorTag) t; - backgroundColor = sb.backgroundColor.toColor(); - } - } - } - - if (settings.mode == FramesExportMode.SVG) { - for (int i = 0; i < frames.size(); i++) { - final int fi = i; - final Timeline ftim = tim; - final Color fbackgroundColor = backgroundColor; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - int frame = fframes.get(fi); - File f = new File(foutdir + File.separator + frame + ".svg"); - try (FileOutputStream fos = new FileOutputStream(f)) { - SVGExporter exporter = new SVGExporter(new ExportRectangle(ftim.displayRect)); - if (fbackgroundColor != null) { - exporter.setBackGroundColor(fbackgroundColor); - } - frameToSvg(ftim, frame, 0, null, 0, exporter, new ColorTransform(), 0); - fos.write(Utf8Helper.getBytes(exporter.getSVG())); - } - ret.add(f); - } - }, handler).run(); - } - return ret; - } - - if (settings.mode == FramesExportMode.CANVAS) { - final Timeline ftim = tim; - final Color fbackgroundColor = backgroundColor; - final SWF fswf = this; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - File fcanvas = new File(foutdir + File.separator + "canvas.js"); - Helper.saveStream(SWF.class.getClassLoader().getResourceAsStream("com/jpexs/helpers/resource/canvas.js"), fcanvas); - ret.add(fcanvas); - - File f = new File(foutdir + File.separator + "frames.js"); - File fmin = new File(foutdir + File.separator + "frames.min.js"); - int width = (int) (ftim.displayRect.getWidth() / SWF.unitDivisor); - int height = (int) (ftim.displayRect.getHeight() / SWF.unitDivisor); - try (FileOutputStream fos = new FileOutputStream(f)) { - fos.write(Utf8Helper.getBytes("\r\n")); - Set library = new HashSet<>(); - ftim.getNeededCharacters(fframes, library); - - writeLibrary(fswf, library, fos); - - String currentName = ftim.id == 0 ? "main" : getTypePrefix(fswf.characters.get(ftim.id)) + ftim.id; - - fos.write(Utf8Helper.getBytes("function " + currentName + "(ctx,ctrans,frame,ratio,time){\r\n")); - fos.write(Utf8Helper.getBytes("\tctx.save();\r\n")); - fos.write(Utf8Helper.getBytes("\tctx.transform(1,0,0,1," + (-ftim.displayRect.Xmin / unitDivisor) + "," + (-ftim.displayRect.Ymin / unitDivisor) + ");\r\n")); - fos.write(Utf8Helper.getBytes(framesToHtmlCanvas(unitDivisor, ftim, fframes, 0, null, 0, ftim.displayRect, new ColorTransform(), fbackgroundColor))); - fos.write(Utf8Helper.getBytes("\tctx.restore();\r\n")); - fos.write(Utf8Helper.getBytes("}\r\n\r\n")); - - fos.write(Utf8Helper.getBytes("var frame = -1;\r\n")); - fos.write(Utf8Helper.getBytes("var time = 0;\r\n")); - fos.write(Utf8Helper.getBytes("var frames = [];\r\n")); - for (int i : fframes) { - fos.write(Utf8Helper.getBytes("frames.push(" + i + ");\r\n")); - } - fos.write(Utf8Helper.getBytes("\r\n")); - RGB backgroundColor = new RGB(255, 255, 255); - for (Tag t : fswf.tags) { - if (t instanceof SetBackgroundColorTag) { - SetBackgroundColorTag sb = (SetBackgroundColorTag) t; - backgroundColor = sb.backgroundColor; - } - } - - fos.write(Utf8Helper.getBytes("var backgroundColor = \"" + backgroundColor.toHexRGB() + "\";\r\n")); - fos.write(Utf8Helper.getBytes("var originalWidth = " + width + ";\r\n")); - fos.write(Utf8Helper.getBytes("var originalHeight= " + height + ";\r\n")); - fos.write(Utf8Helper.getBytes("function nextFrame(ctx,ctrans){\r\n")); - fos.write(Utf8Helper.getBytes("\tvar oldframe = frame;\r\n")); - fos.write(Utf8Helper.getBytes("\tframe = (frame+1)%frames.length;\r\n")); - fos.write(Utf8Helper.getBytes("\tif(frame==oldframe){time++;}else{time=0;};\r\n")); - fos.write(Utf8Helper.getBytes("\tdrawFrame();\r\n")); - fos.write(Utf8Helper.getBytes("}\r\n\r\n")); - - fos.write(Utf8Helper.getBytes("function drawFrame(){\r\n")); - fos.write(Utf8Helper.getBytes("\tctx.fillStyle = backgroundColor;\r\n")); - fos.write(Utf8Helper.getBytes("\tctx.fillRect(0,0,canvas.width,canvas.height);\r\n")); - fos.write(Utf8Helper.getBytes("\tctx.save();\r\n")); - fos.write(Utf8Helper.getBytes("\tctx.transform(canvas.width/originalWidth,0,0,canvas.height/originalHeight,0,0);\r\n")); - fos.write(Utf8Helper.getBytes("\t" + currentName + "(ctx,ctrans,frames[frame],0,time);\r\n")); - fos.write(Utf8Helper.getBytes("\tctx.restore();\r\n")); - fos.write(Utf8Helper.getBytes("}\r\n\r\n")); - fos.write(Utf8Helper.getBytes("window.setInterval(function(){nextFrame(ctx,ctrans);}," + (int) (1000.0 / ftim.swf.frameRate) + ");\r\n")); - } - - if (Configuration.packJavaScripts.get()) { - try { - JPacker.main(new String[]{"-q", "-b", "62", "-o", fmin.getAbsolutePath(), f.getAbsolutePath()}); - f.delete(); - } catch (Exception | Error e) { //Something wrong in the packer - Logger.getLogger(SWF.class.getName()).log(Level.WARNING, "JPacker: Cannot minimize script"); - f.renameTo(fmin); - } - } else { - f.renameTo(fmin); - } - - File fh = new File(foutdir + File.separator + "frames.html"); - try (FileOutputStream fos = new FileOutputStream(fh); FileInputStream fis = new FileInputStream(fmin)) { - fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getHtmlPrefix(width, height))); - fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getJsPrefix())); - byte buf[] = new byte[1000]; - int cnt; - while ((cnt = fis.read(buf)) > 0) { - fos.write(buf, 0, cnt); - } - if (Configuration.packJavaScripts.get()) { - fos.write(Utf8Helper.getBytes(";")); - } - fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getJsSuffix())); - fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getHtmlSuffix())); - } - fmin.delete(); - - ret.add(f); - } - }, handler).run(); - - return ret; - } - - final Timeline ftim = tim; - final Color fbackgroundColor = backgroundColor; - final Iterator frameImages = new Iterator() { - - private int pos = 0; - - @Override - public boolean hasNext() { - return fframes.size() > pos; - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - - @Override - public BufferedImage next() { - if (!hasNext()) { - return null; - } - return frameToImageGet(ftim, fframes.get(pos++), 0, null, 0, ftim.displayRect, new Matrix(), new ColorTransform(), fbackgroundColor, false).getBufferedImage(); - } - }; - - switch (settings.mode) { - case GIF: - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - File f = new File(foutdir + File.separator + "frames.gif"); - makeGIF(frameImages, frameRate, f); - ret.add(f); - } - }, handler).run(); - break; - case PNG: - for (int i = 0; frameImages.hasNext(); i++) { - final int fi = i; - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - File f = new File(foutdir + File.separator + (fframes.get(fi)+1) + ".png"); - ImageIO.write(frameImages.next(), "PNG", f); - ret.add(f); - } - }, handler).run(); - } - break; - case PDF: - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - File f = new File(foutdir + File.separator + "frames.pdf"); - PDFJob job = new PDFJob(new FileOutputStream(f)); - PageFormat pf = new PageFormat(); - pf.setOrientation(PageFormat.PORTRAIT); - Paper p = new Paper(); - BufferedImage img0 = frameImages.next(); - p.setSize(img0.getWidth() + 10, img0.getHeight() + 10); - pf.setPaper(p); - - for (int i = 0; frameImages.hasNext(); i++) { - BufferedImage img = frameImages.next(); - Graphics g = job.getGraphics(pf); - g.drawImage(img, 5, 5, img.getWidth(), img.getHeight(), null); - g.dispose(); - } - - job.end(); - ret.add(f); - } - }, handler).run(); - break; - case AVI: - new RetryTask(new RunnableIOEx() { - @Override - public void run() throws IOException { - File f = new File(foutdir + File.separator + "frames.avi"); - makeAVI(frameImages, frameRate, f); - ret.add(f); - } - }, handler).run(); - break; - } - - return ret; - } - - public void exportTexts(AbortRetryIgnoreHandler handler, String outdir, TextExportSettings settings) throws IOException { - new TextExporter().exportTexts(handler, outdir, tags, settings); - } - - public void exportImages(AbortRetryIgnoreHandler handler, String outdir, ImageExportSettings settings) throws IOException { - new ImageExporter().exportImages(handler, outdir, tags, settings); - } - - public void exportShapes(AbortRetryIgnoreHandler handler, String outdir, ShapeExportSettings settings) throws IOException { - new ShapeExporter().exportShapes(handler, outdir, tags, settings); - } - - public void exportMorphShapes(AbortRetryIgnoreHandler handler, String outdir, MorphShapeExportSettings settings) throws IOException { - new MorphShapeExporter().exportMorphShapes(handler, outdir, tags, settings); - } - - public void exportBinaryData(AbortRetryIgnoreHandler handler, String outdir, BinaryDataExportSettings settings) throws IOException { - new BinaryDataExporter().exportBinaryData(handler, outdir, tags, settings); - } - - private final HashMap deobfuscated = new HashMap<>(); - private List> allVariableNames = new ArrayList<>(); - private List allFunctions = new ArrayList<>(); - private HashMap allStrings = new HashMap<>(); - private final HashMap usageTypes = new HashMap<>(); - private final ActionDeobfuscation deobfuscation = new ActionDeobfuscation(); - - private static void getVariables(ConstantPool constantPool, BaseLocalData localData, Stack stack, List output, ActionGraphSource code, int ip, List> variables, List functions, HashMap strings, List visited, HashMap usageTypes, String path) throws InterruptedException { - boolean debugMode = false; - while ((ip > -1) && ip < code.size()) { - if (visited.contains(ip)) { - break; - } - GraphSourceItem ins = code.get(ip); - - if (debugMode) { - System.err.println("Visit " + ip + ": ofs" + Helper.formatAddress(((Action) ins).getAddress()) + ":" + ((Action) ins).getASMSource(new ArrayList(), new ArrayList(), new ArrayList(), code.version, ScriptExportMode.PCODE) + " stack:" + Helper.stackToString(stack, LocalData.create(new ConstantPool()))); - } - if (ins.isExit()) { - break; - } - if (ins.isIgnored()) { - ip++; - continue; - } - - String usageType = "name"; - 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)) { - if (stack.isEmpty()) { - break; - } - name = stack.peek(); - } - - if ((ins instanceof ActionGetVariable) || (ins instanceof ActionDefineLocal2)) { - usageType = "variable"; - } - if (ins instanceof ActionGetMember) { - usageType = "member"; - } - if ((ins instanceof ActionNewMethod) || (ins instanceof ActionNewObject)) { - usageType = "class"; - } - if (ins instanceof ActionCallMethod) { - usageType = "function"; //can there be method? - } - if (ins instanceof ActionCallFunction) { - usageType = "function"; - } - - if ((ins instanceof ActionDefineFunction) || (ins instanceof ActionDefineFunction2)) { - functions.add(ins); - } - - if (ins instanceof GraphSourceItemContainer) { - GraphSourceItemContainer cnt = (GraphSourceItemContainer) ins; - List cntSizes = cnt.getContainerSizes(); - long addr = code.pos2adr(ip + 1); - ip = code.adr2pos(addr); - String cntName = cnt.getName(); - for (Long size : cntSizes) { - if (size == 0) { - continue; - } - ip = code.adr2pos(addr); - addr += size; - int nextip = code.adr2pos(addr); - getVariables(variables, functions, strings, usageTypes, new ActionGraphSource(code.getActions().subList(ip, nextip), code.version, new HashMap(), new HashMap(), new HashMap()), 0, path + (cntName == null ? "" : "/" + cntName)); - ip = nextip; - } - List> r = new ArrayList<>(); - r.add(new ArrayList()); - r.add(new ArrayList()); - r.add(new ArrayList()); - try { - ((GraphSourceItemContainer) ins).translateContainer(r, stack, output, new HashMap(), new HashMap(), new HashMap()); - } catch (EmptyStackException ex) { - } - //ip++; - continue; - } - - if ((ins instanceof ActionSetVariable) || (ins instanceof ActionSetMember) || (ins instanceof ActionDefineLocal)) { - if (stack.size() < 2) { - break; - } - name = stack.get(stack.size() - 2); - } - - if ((ins instanceof ActionSetVariable) || (ins instanceof ActionDefineLocal)) { - usageType = "variable"; - } - - if (ins instanceof ActionSetMember) { - usageType = "member"; - } - - if (name instanceof DirectValueActionItem) { - variables.add(new MyEntry<>((DirectValueActionItem) name, constantPool)); - usageTypes.put((DirectValueActionItem) name, usageType); - } - - //for..in return - if (((ins instanceof ActionEquals) || (ins instanceof ActionEquals2)) && (stack.size() == 1) && (stack.peek() instanceof DirectValueActionItem)) { - stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList())); - } - - if (ins instanceof ActionConstantPool) { - constantPool = new ConstantPool(((ActionConstantPool) ins).constantPool); - } - int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC; - - try { - ins.translate(localData, stack, output, staticOperation, path); - } catch (EmptyStackException ex) { - // probably obfucated code, never executed branch - break; - } - if (ins.isExit()) { - break; - } - - if (ins instanceof ActionPush) { - if (!stack.isEmpty()) { - GraphTargetItem top = stack.peek(); - if (top instanceof DirectValueActionItem) { - DirectValueActionItem dvt = (DirectValueActionItem) top; - if ((dvt.value instanceof String) || (dvt.value instanceof ConstantIndex)) { - if (constantPool == null) { - constantPool = new ConstantPool(dvt.constants); - } - strings.put(dvt, constantPool); - } - } - } - } - - if (ins.isBranch() || ins.isJump()) { - if (ins instanceof ActionIf) { - if (stack.isEmpty()) { - break; - } - stack.pop(); - } - visited.add(ip); - List branches = ins.getBranches(code); - for (int b : branches) { - @SuppressWarnings("unchecked") - Stack brStack = (Stack) stack.clone(); - if (b >= 0) { - getVariables(constantPool, localData, brStack, output, code, b, variables, functions, strings, visited, usageTypes, path); - } else { - if (debugMode) { - System.out.println("Negative branch:" + b); - } - } - } - // } - break; - } - ip++; - }; - } - - private static void getVariables(List> variables, List functions, HashMap strings, HashMap usageType, ActionGraphSource code, int addr, String path) throws InterruptedException { - ActionLocalData localData = new ActionLocalData(); - getVariables(null, localData, new Stack(), new ArrayList(), code, code.adr2pos(addr), variables, functions, strings, new ArrayList(), usageType, path); - } - - private List> getVariables(List> variables, List functions, HashMap strings, HashMap usageType, ASMSource src, String path) throws InterruptedException { - List> ret = new ArrayList<>(); - List actions = src.getActions(); - actionsMap.put(src, actions); - getVariables(variables, functions, strings, usageType, new ActionGraphSource(actions, version, new HashMap(), new HashMap(), new HashMap()), 0, path); - return ret; - } - private HashMap> actionsMap = new HashMap<>(); - - private void getVariables(List objs, String path) throws InterruptedException { - List processed = new ArrayList<>(); - for (ContainerItem o : objs) { - if (o instanceof ASMSource) { - String infPath = path + "/" + o.toString(); - int pos = 1; - String infPath2 = infPath; - while (processed.contains(infPath2)) { - pos++; - infPath2 = infPath + "[" + pos + "]"; - } - processed.add(infPath2); - informListeners("getVariables", infPath2); - getVariables(allVariableNames, allFunctions, allStrings, usageTypes, (ASMSource) o, path); - } - if (o instanceof Container) { - getVariables(((Container) o).getSubItems(), path + "/" + o.toString()); - } - } - } - - public int deobfuscateAS3Identifiers(RenameType renameType) { - for (Tag tag : tags) { - if (tag instanceof ABCContainerTag) { - ((ABCContainerTag) tag).getABC().deobfuscateIdentifiers(deobfuscated, renameType, true); - tag.setModified(true); - } - } - for (Tag tag : tags) { - if (tag instanceof ABCContainerTag) { - ((ABCContainerTag) tag).getABC().deobfuscateIdentifiers(deobfuscated, renameType, false); - tag.setModified(true); - } - } - for (Tag tag : tags) { - if (tag instanceof SymbolClassTag) { - SymbolClassTag sc = (SymbolClassTag) tag; - for (int i = 0; i < sc.names.length; i++) { - String newname = deobfuscation.deobfuscateNameWithPackage(sc.names[i], deobfuscated, renameType, deobfuscated); - if (newname != null) { - sc.names[i] = newname; - } - } - sc.setModified(true); - } - } - deobfuscation.deobfuscateInstanceNames(deobfuscated, renameType, tags, new HashMap()); - return deobfuscated.size(); - } - - public int deobfuscateIdentifiers(RenameType renameType) throws InterruptedException { - findFileAttributes(); - if (fileAttributes == null) { - int cnt = 0; - cnt += deobfuscateAS2Identifiers(renameType); - cnt += deobfuscateAS3Identifiers(renameType); - return cnt; - } else { - if (fileAttributes.actionScript3) { - return deobfuscateAS3Identifiers(renameType); - } else { - return deobfuscateAS2Identifiers(renameType); - } - } - } - - public void renameAS2Identifier(String identifier, String newname) throws InterruptedException { - Map selected = new HashMap<>(); - selected.put(identifier, newname); - renameAS2Identifiers(null, selected); - } - - private int deobfuscateAS2Identifiers(RenameType renameType) throws InterruptedException { - return renameAS2Identifiers(renameType, null); - } - - private int renameAS2Identifiers(RenameType renameType, Map selected) throws InterruptedException { - actionsMap = new HashMap<>(); - allFunctions = new ArrayList<>(); - allVariableNames = new ArrayList<>(); - allStrings = new HashMap<>(); - - List objs = new ArrayList<>(); - int ret = 0; - objs.addAll(tags); - getVariables(objs, ""); - informListeners("rename", ""); - int fc = 0; - for (MyEntry it : allVariableNames) { - String name = it.key.toStringNoH(it.value); - deobfuscation.allVariableNamesStr.add(name); - } - - informListeners("rename", "classes"); - int classCount = 0; - for (Tag t : tags) { - if (t instanceof DoInitActionTag) { - classCount++; - } - } - int cnt = 0; - for (Tag t : tags) { - if (t instanceof DoInitActionTag) { - cnt++; - informListeners("rename", "class " + cnt + "/" + classCount); - DoInitActionTag dia = (DoInitActionTag) t; - String exportName = dia.getExportName(); - final String pkgPrefix = "__Packages."; - String[] classNameParts = null; - if ((exportName != null) && exportName.startsWith(pkgPrefix)) { - String className = exportName.substring(pkgPrefix.length()); - if (className.contains(".")) { - classNameParts = className.split("\\."); - } else { - classNameParts = new String[]{className}; - } - } - int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC; - List dec; - try { - dec = Action.actionsToTree(dia.getActions(), version, staticOperation, ""/*FIXME*/); - } catch (EmptyStackException ex) { - continue; - } - GraphTargetItem name = null; - for (GraphTargetItem it : dec) { - if (it instanceof ClassActionItem) { - ClassActionItem cti = (ClassActionItem) it; - List methods = new ArrayList<>(); - methods.addAll(cti.functions); - methods.addAll(cti.staticFunctions); - - for (GraphTargetItem gti : methods) { - if (gti instanceof FunctionActionItem) { - FunctionActionItem fun = (FunctionActionItem) gti; - if (fun.calculatedFunctionName instanceof DirectValueActionItem) { - DirectValueActionItem dvf = (DirectValueActionItem) fun.calculatedFunctionName; - String fname = dvf.toStringNoH(null); - String changed = deobfuscation.deobfuscateName(fname, false, "method", deobfuscated, renameType, selected); - if (changed != null) { - deobfuscated.put(fname, changed); - } - } - } - } - - List vars = new ArrayList<>(); - for (MyEntry item : cti.vars) { - vars.add(item.key); - } - for (MyEntry item : cti.staticVars) { - vars.add(item.key); - } - for (GraphTargetItem gti : vars) { - if (gti instanceof DirectValueActionItem) { - DirectValueActionItem dvf = (DirectValueActionItem) gti; - String vname = dvf.toStringNoH(null); - String changed = deobfuscation.deobfuscateName(vname, false, "attribute", deobfuscated, renameType, selected); - if (changed != null) { - deobfuscated.put(vname, changed); - } - } - } - - name = cti.className; - break; - } - if (it instanceof InterfaceActionItem) { - InterfaceActionItem ift = (InterfaceActionItem) it; - name = ift.name; - } - } - - if (name != null) { - int pos = 0; - while (name instanceof GetMemberActionItem) { - GetMemberActionItem mem = (GetMemberActionItem) name; - GraphTargetItem memberName = mem.memberName; - if (memberName instanceof DirectValueActionItem) { - DirectValueActionItem dvt = (DirectValueActionItem) memberName; - String nameStr = dvt.toStringNoH(null); - if (classNameParts != null) { - if (classNameParts.length - 1 - pos < 0) { - break; - } - } - String changedNameStr = nameStr; - if (classNameParts != null) { - changedNameStr = classNameParts[classNameParts.length - 1 - pos]; - } - String changedNameStr2 = deobfuscation.deobfuscateName(changedNameStr, pos == 0, pos == 0 ? "class" : "package", deobfuscated, renameType, selected); - if (changedNameStr2 != null) { - changedNameStr = changedNameStr2; - } - ret++; - deobfuscated.put(nameStr, changedNameStr); - pos++; - } - name = mem.object; - } - if (name instanceof GetVariableActionItem) { - GetVariableActionItem var = (GetVariableActionItem) name; - if (var.name instanceof DirectValueActionItem) { - DirectValueActionItem dvt = (DirectValueActionItem) var.name; - String nameStr = dvt.toStringNoH(null); - if (classNameParts != null) { - if (classNameParts.length - 1 - pos < 0) { - break; - } - } - String changedNameStr = nameStr; - if (classNameParts != null) { - changedNameStr = classNameParts[classNameParts.length - 1 - pos]; - } - String changedNameStr2 = deobfuscation.deobfuscateName(changedNameStr, pos == 0, pos == 0 ? "class" : "package", deobfuscated, renameType, selected); - if (changedNameStr2 != null) { - changedNameStr = changedNameStr2; - } - ret++; - deobfuscated.put(nameStr, changedNameStr); - pos++; - } - } - } - t.setModified(true); - } - } - - for (GraphSourceItem fun : allFunctions) { - fc++; - informListeners("rename", "function " + fc + "/" + allFunctions.size()); - if (fun instanceof ActionDefineFunction) { - ActionDefineFunction f = (ActionDefineFunction) fun; - if (f.functionName.isEmpty()) { //anonymous function, leave as is - continue; - } - String changed = deobfuscation.deobfuscateName(f.functionName, false, "function", deobfuscated, renameType, selected); - if (changed != null) { - f.replacedFunctionName = changed; - ret++; - } - } - if (fun instanceof ActionDefineFunction2) { - ActionDefineFunction2 f = (ActionDefineFunction2) fun; - if (f.functionName.isEmpty()) { //anonymous function, leave as is - continue; - } - String changed = deobfuscation.deobfuscateName(f.functionName, false, "function", deobfuscated, renameType, selected); - if (changed != null) { - f.replacedFunctionName = changed; - ret++; - } - } - } - - HashSet stringsNoVarH = new HashSet<>(); - List allVariableNamesDv = new ArrayList<>(); - for (MyEntry it : allVariableNames) { - allVariableNamesDv.add(it.key); - } - for (DirectValueActionItem ti : allStrings.keySet()) { - if (!allVariableNamesDv.contains(ti)) { - stringsNoVarH.add(System.identityHashCode(allStrings.get(ti)) + "_" + ti.toStringNoH(allStrings.get(ti))); - } - } - - int vc = 0; - for (MyEntry it : allVariableNames) { - vc++; - String name = it.key.toStringNoH(it.value); - String changed = deobfuscation.deobfuscateName(name, false, usageTypes.get(it.key), deobfuscated, renameType, selected); - if (changed != null) { - boolean addNew = false; - String h = System.identityHashCode(it.key) + "_" + name; - if (stringsNoVarH.contains(h)) { - addNew = true; - } - ActionPush pu = (ActionPush) it.key.src; - if (pu.replacement == null) { - pu.replacement = new ArrayList<>(); - pu.replacement.addAll(pu.values); - } - if (pu.replacement.get(it.key.pos) instanceof ConstantIndex) { - ConstantIndex ci = (ConstantIndex) pu.replacement.get(it.key.pos); - ConstantPool pool = it.value; - if (pool == null) { - continue; - } - if (pool.constants == null) { - continue; - } - if (addNew) { - pool.constants.add(changed); - ci.index = pool.constants.size() - 1; - } else { - pool.constants.set(ci.index, changed); - } - } else { - pu.replacement.set(it.key.pos, changed); - } - ret++; - } - } - for (ASMSource src : actionsMap.keySet()) { - actionsMap.put(src, Action.removeNops(0, actionsMap.get(src), version, ""/*FIXME path*/)); - src.setActions(actionsMap.get(src)); - src.setModified(); - } - deobfuscation.deobfuscateInstanceNames(deobfuscated, renameType, tags, selected); - return ret; - } - - public void exportFla(AbortRetryIgnoreHandler handler, String outfile, String swfName, String generator, String generatorVerName, String generatorVersion, boolean parallel, FLAVersion version) throws IOException { - XFLConverter.convertSWF(handler, this, swfName, outfile, true, generator, generatorVerName, generatorVersion, parallel, version); - } - - public void exportXfl(AbortRetryIgnoreHandler handler, String outfile, String swfName, String generator, String generatorVerName, String generatorVersion, boolean parallel, FLAVersion version) throws IOException { - XFLConverter.convertSWF(handler, this, swfName, outfile, false, generator, generatorVerName, generatorVersion, parallel, version); - } - - public static AffineTransform matrixToTransform(MATRIX mat) { - return new AffineTransform(mat.getScaleXFloat(), mat.getRotateSkew0Float(), - mat.getRotateSkew1Float(), mat.getScaleYFloat(), - mat.translateX, mat.translateY); - } - - private static Cache frameCache = Cache.getInstance(false); - - public static SerializableImage getFromCache(String key) { - if (frameCache.contains(key)) { - return (SerializableImage) SWF.frameCache.get(key); - } - return null; - } - - public static void putToCache(String key, SerializableImage img) { - if (Configuration.useFrameCache.get()) { - frameCache.put(key, img); - } - } - - public static void clearImageCache() { - frameCache.clear(); - } - - public static RECT fixRect(RECT rect) { - RECT ret = new RECT(); - ret.Xmin = rect.Xmin; - ret.Xmax = rect.Xmax; - ret.Ymin = rect.Ymin; - ret.Ymax = rect.Ymax; - - if (ret.Xmax <= 0) { - ret.Xmax = ret.getWidth(); - ret.Xmin = 0; - } - if (ret.Ymax <= 0) { - ret.Ymax = ret.getHeight(); - ret.Ymin = 0; - } - if (ret.Xmin < 0) { - ret.Xmax += (-ret.Xmin); - ret.Xmin = 0; - } - if (ret.Ymin < 0) { - ret.Ymax += (-ret.Ymin); - ret.Ymin = 0; - } - - if (ret.getWidth() < 1 || ret.getHeight() < 1) { - ret.Xmin = 0; - ret.Ymin = 0; - ret.Xmax = 20; - ret.Ymax = 20; - } - return ret; - } - - private static String jsArrColor(RGB rgb) { - return "[" + rgb.red + "," + rgb.green + "," + rgb.blue + "," + ((rgb instanceof RGBA) ? ((RGBA) rgb).getAlphaFloat() : 1) + "]"; - } - - public static String framesToHtmlCanvas(double unitDivisor, Timeline timeline, List frames, int time, DepthState stateUnderCursor, int mouseButton, RECT displayRect, ColorTransform colorTransform, Color backGroundColor) { - StringBuilder sb = new StringBuilder(); - if (frames == null) { - frames = new ArrayList<>(); - for (int i = 0; i < timeline.getFrameCount(); i++) { - frames.add(i); - } - } - sb.append("\tvar clips = [];\r\n"); - sb.append("\tvar frame_cnt = ").append(timeline.getFrameCount()).append(";\r\n"); - sb.append("\tframe = frame % frame_cnt;\r\n"); - sb.append("\tswitch(frame){\r\n"); - int maxDepth = timeline.getMaxDepth(); - Stack clipDepths = new Stack<>(); - for (int frame = 0; frame < frames.size(); frame++) { - sb.append("\t\tcase ").append(frame).append(":\r\n"); - Frame frameObj = timeline.frames.get(frame); - for (int i = 1; i <= maxDepth + 1; i++) { - while (!clipDepths.isEmpty() && clipDepths.peek() <= i) { - clipDepths.pop(); - sb.append("\t\t\tvar o = clips.pop();\r\n"); - sb.append("\t\t\tctx.globalCompositeOperation = \"destination-in\";\r\n"); - sb.append("\t\t\tctx.setTransform(1,0,0,1,0,0);\r\n"); - sb.append("\t\t\tctx.drawImage(o.clipCanvas,0,0);\r\n"); - sb.append("\t\t\tvar ms=o.ctx._matrices.slice();\r\n"); - sb.append("\t\t\to.ctx.setTransform(1,0,0,1,0,0);\r\n"); - sb.append("\t\t\to.ctx.globalCompositeOperation = \"source-over\";\r\n"); - sb.append("\t\t\to.ctx.drawImage(canvas,0,0);\r\n"); - sb.append("\t\t\to.ctx.applyTransforms(ms);\r\n"); - sb.append("\t\t\tctx = o.ctx;\r\n"); - sb.append("\t\t\tcanvas = o.canvas;\r\n"); - } - if (!frameObj.layers.containsKey(i)) { - continue; - } - DepthState layer = frameObj.layers.get(i); - if (!timeline.swf.characters.containsKey(layer.characterId)) { - continue; - } - if (!layer.isVisible) { - continue; - } - CharacterTag character = timeline.swf.characters.get(layer.characterId); - - if (colorTransform == null) { - colorTransform = new ColorTransform(); - } - Matrix placeMatrix = new Matrix(layer.matrix); - placeMatrix.scaleX /= unitDivisor; - placeMatrix.scaleY /= unitDivisor; - placeMatrix.rotateSkew0 /= unitDivisor; - placeMatrix.rotateSkew1 /= unitDivisor; - placeMatrix.translateX /= unitDivisor; - placeMatrix.translateY /= unitDivisor; - - int f = 0; - String fstr = "0"; - if (character instanceof DefineSpriteTag) { - DefineSpriteTag sp = (DefineSpriteTag) character; - Timeline tim = sp.getTimeline(); - if (tim.getFrameCount() > 0) { - f = layer.time % tim.getFrameCount(); - fstr = "(" + f + "+time)%" + tim.getFrameCount(); - } - } - - if (layer.clipDepth != -1) { - clipDepths.push(layer.clipDepth); - sb.append("\t\t\tclips.push({ctx:ctx,canvas:canvas});\r\n"); - sb.append("\t\t\tvar ccanvas = createCanvas(canvas.width,canvas.height);\r\n"); - sb.append("\t\t\tvar cctx = ccanvas.getContext(\"2d\");\r\n"); - sb.append("\t\t\tenhanceContext(cctx);\r\n"); - sb.append("\t\t\tcctx.applyTransforms(ctx._matrices);\r\n"); - sb.append("\t\t\tcanvas = ccanvas;\r\n"); - sb.append("\t\t\tctx = cctx;\r\n"); - } - - if (layer.filters != null && layer.filters.size() > 0) { - sb.append("\t\t\tvar oldctx = ctx;\r\n"); - sb.append("\t\t\tvar fcanvas = createCanvas(canvas.width,canvas.height);"); - sb.append("\t\t\tvar fctx = fcanvas.getContext(\"2d\");\r\n"); - sb.append("\t\t\tenhanceContext(fctx);\r\n"); - sb.append("\t\t\tfctx.applyTransforms(ctx._matrices);\r\n"); - sb.append("\t\t\tctx = fctx;\r\n"); - } - - ColorTransform ctrans = layer.colorTransForm; - String ctrans_str = "ctrans"; - if (ctrans == null) { - ctrans = new ColorTransform(); - } else { - ctrans_str = "ctrans.merge(new cxform(" - + ctrans.getRedAdd() + "," + ctrans.getGreenAdd() + "," + ctrans.getBlueAdd() + "," + ctrans.getAlphaAdd() + "," - + ctrans.getRedMulti() + "," + ctrans.getGreenMulti() + "," + ctrans.getBlueMulti() + "," + ctrans.getAlphaMulti() - + "))"; - } - sb.append("\t\t\tplace(\"").append(getTypePrefix(character)).append(layer.characterId).append("\",canvas,ctx,[").append(placeMatrix.scaleX).append(",") - .append(placeMatrix.rotateSkew0).append(",") - .append(placeMatrix.rotateSkew1).append(",") - .append(placeMatrix.scaleY).append(",") - .append(placeMatrix.translateX).append(",") - .append(placeMatrix.translateY).append("],").append(ctrans_str).append(",").append("").append(layer.blendMode < 1 ? 1 : layer.blendMode).append(",").append(fstr).append(",").append(layer.ratio < 0 ? 0 : layer.ratio).append(",time").append(");\r\n"); - - if (layer.filters != null && layer.filters.size() > 0) { - for (FILTER filter : layer.filters) { - if (filter instanceof COLORMATRIXFILTER) { - COLORMATRIXFILTER cmf = (COLORMATRIXFILTER) filter; - String mat = "["; - for (int k = 0; k < cmf.matrix.length; k++) { - if (k > 0) { - mat += ","; - } - mat += cmf.matrix[k]; - } - mat += "]"; - sb.append("\t\t\tfcanvas = Filters.colorMatrix(fcanvas,fcanvas.getContext(\"2d\"),").append(mat).append(");\r\n"); - } - - if (filter instanceof CONVOLUTIONFILTER) { - CONVOLUTIONFILTER cf = (CONVOLUTIONFILTER) filter; - int height = cf.matrix.length; - int width = cf.matrix[0].length; - float[] matrix2 = new float[width * height]; - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - matrix2[y * width + x] = cf.matrix[x][y] * cf.divisor + cf.bias; - } - } - String mat = "["; - for (int k = 0; k < matrix2.length; k++) { - if (k > 0) { - mat += ","; - } - mat += matrix2[k]; - } - mat += "]"; - sb.append("\t\t\tfcanvas = Filters.convolution(fcanvas,fcanvas.getContext(\"2d\"),").append(mat).append(",false);\r\n"); - } - - if (filter instanceof GLOWFILTER) { - GLOWFILTER gf = (GLOWFILTER) filter; - sb.append("\t\t\tfcanvas = Filters.glow(fcanvas,fcanvas.getContext(\"2d\"),").append(gf.blurX).append(",").append(gf.blurY).append(",").append(gf.strength).append(",").append(jsArrColor(gf.glowColor)).append(",").append(gf.innerGlow ? "true" : "false").append(",").append(gf.knockout ? "true" : "false").append(",").append(gf.passes).append(");\r\n"); - } - - if (filter instanceof DROPSHADOWFILTER) { - DROPSHADOWFILTER ds = (DROPSHADOWFILTER) filter; - sb.append("\t\t\tfcanvas = Filters.dropShadow(fcanvas,fcanvas.getContext(\"2d\"),").append(ds.blurX).append(",").append(ds.blurY).append(",").append((int) (ds.angle * 180 / Math.PI)).append(",").append(ds.distance).append(",").append(jsArrColor(ds.dropShadowColor)).append(",").append(ds.innerShadow ? "true" : "false").append(",").append(ds.passes).append(",").append(ds.strength).append(",").append(ds.knockout ? "true" : "false").append(");\r\n"); - } - if (filter instanceof BEVELFILTER) { - BEVELFILTER bv = (BEVELFILTER) filter; - String type = "Filters.INNER"; - if (bv.onTop && !bv.innerShadow) { - type = "Filters.FULL"; - } else if (!bv.innerShadow) { - type = "Filters.OUTER"; - } - sb.append("\t\t\tfcanvas = Filters.bevel(fcanvas,fcanvas.getContext(\"2d\"),").append(bv.blurX).append(",").append(bv.blurY).append(",").append(bv.strength).append(",").append(type).append(",").append(jsArrColor(bv.highlightColor)).append(",").append(jsArrColor(bv.shadowColor)).append(",").append((int) (bv.angle * 180 / Math.PI)).append(",").append(bv.distance).append(",").append(bv.knockout ? "true" : "false").append(",").append(bv.passes).append(");\r\n"); - } - - if (filter instanceof GRADIENTBEVELFILTER) { - GRADIENTBEVELFILTER gbf = (GRADIENTBEVELFILTER) filter; - String colArr = "["; - String ratArr = "["; - for (int k = 0; k < gbf.gradientColors.length; k++) { - if (k > 0) { - colArr += ","; - ratArr += ","; - } - colArr += jsArrColor(gbf.gradientColors[k]); - ratArr += gbf.gradientRatio[k] / 255f; - } - colArr += "]"; - ratArr += "]"; - String type = "Filters.INNER"; - if (gbf.onTop && !gbf.innerShadow) { - type = "Filters.FULL"; - } else if (!gbf.innerShadow) { - type = "Filters.OUTER"; - } - - sb.append("\t\t\tfcanvas = Filters.gradientBevel(fcanvas,fcanvas.getContext(\"2d\"),").append(colArr).append(",").append(ratArr).append(",").append(gbf.blurX).append(",").append(gbf.blurY).append(",").append(gbf.strength).append(",").append(type).append(",").append((int) (gbf.angle * 180 / Math.PI)).append(",").append(gbf.distance).append(",").append(gbf.knockout ? "true" : "false").append(",").append(gbf.passes).append(");\r\n"); - } - - if (filter instanceof GRADIENTGLOWFILTER) { - GRADIENTGLOWFILTER ggf = (GRADIENTGLOWFILTER) filter; - String colArr = "["; - String ratArr = "["; - for (int k = 0; k < ggf.gradientColors.length; k++) { - if (k > 0) { - colArr += ","; - ratArr += ","; - } - colArr += jsArrColor(ggf.gradientColors[k]); - ratArr += ggf.gradientRatio[k] / 255f; - } - colArr += "]"; - ratArr += "]"; - String type = "Filters.INNER"; - if (ggf.onTop && !ggf.innerShadow) { - type = "Filters.FULL"; - } else if (!ggf.innerShadow) { - type = "Filters.OUTER"; - } - - sb.append("\t\t\tfcanvas = Filters.gradientGlow(fcanvas,fcanvas.getContext(\"2d\"),").append(ggf.blurX).append(",").append(ggf.blurY).append(",").append((int) (ggf.angle * 180 / Math.PI)).append(",").append(ggf.distance).append(",").append(colArr).append(",").append(ratArr).append(",").append(type).append(",").append(ggf.passes).append(",").append(ggf.strength).append(",").append(ggf.knockout ? "true" : "false").append(");\r\n"); - } - } - sb.append("\t\t\tctx = oldctx;\r\n"); - sb.append("\t\t\tvar ms=ctx._matrices;\r\n"); - sb.append("\t\t\tctx.setTransform(1,0,0,1,0,0);\r\n"); - sb.append("\t\t\tctx.drawImage(fcanvas,0,0);\r\n"); - sb.append("\t\t\tctx.applyTransforms(ms);\r\n"); - } - - if (layer.clipDepth != -1) { - sb.append("\t\t\tclips[clips.length-1].clipCanvas = canvas;\r\n"); - sb.append("\t\t\tcanvas = createCanvas(canvas.width,canvas.height);\r\n"); - sb.append("\t\t\tvar nctx = canvas.getContext(\"2d\");\r\n"); - sb.append("\t\t\tenhanceContext(nctx);\r\n"); - sb.append("\t\t\tnctx.applyTransforms(ctx._matrices);\r\n"); - sb.append("\t\t\tctx = nctx;\r\n"); - } - } - sb.append("\t\t\tbreak;\r\n"); - } - sb.append("\t}\r\n"); - return sb.toString(); - } - - public static void frameToSvg(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, SVGExporter exporter, ColorTransform colorTransform, int level) throws IOException { - if (timeline.frames.size() <= frame) { - return; - } - Frame frameObj = timeline.frames.get(frame); - List clips = new ArrayList<>(); - List prevClips = new ArrayList<>(); - - int maxDepth = timeline.getMaxDepth(); - for (int i = 1; i <= maxDepth; i++) { - for (int c = 0; c < clips.size(); c++) { - if (clips.get(c).depth == i) { - exporter.setClip(prevClips.get(c)); - prevClips.remove(c); - clips.remove(c); - } - } - if (!frameObj.layers.containsKey(i)) { - continue; - } - DepthState layer = frameObj.layers.get(i); - if (!timeline.swf.characters.containsKey(layer.characterId)) { - continue; - } - if (!layer.isVisible) { - continue; - } - CharacterTag character = timeline.swf.characters.get(layer.characterId); - - if (colorTransform == null) { - colorTransform = new ColorTransform(); - } - - ColorTransform clrTrans = Helper.deepCopy(colorTransform); - if (layer.colorTransForm != null && layer.blendMode <= 1) { //Normal blend mode - clrTrans = colorTransform.merge(layer.colorTransForm); - } - - if (character instanceof DrawableTag) { - DrawableTag drawable = (DrawableTag) character; - - String assetName; - Tag drawableTag = (Tag) drawable; - if (exporter.exportedTags.containsKey(drawableTag)) { - assetName = exporter.exportedTags.get(drawableTag); - } else { - assetName = getTagIdPrefix(drawableTag, exporter); - exporter.exportedTags.put(drawableTag, assetName); - exporter.createDefGroup(new ExportRectangle(drawable.getRect()), assetName); - drawable.toSVG(exporter, layer.ratio, clrTrans, level + 1); - exporter.endGroup(); - } - RECT boundRect = drawable.getRect(); - ExportRectangle rect = new ExportRectangle(boundRect); - - // TODO: if (layer.filters != null) - // TODO: if (layer.blendMode > 1) - if (layer.clipDepth > -1) { - String clipName = exporter.getUniqueId("clipPath"); - exporter.createClipPath(new Matrix(), clipName); - SvgClip clip = new SvgClip(clipName, layer.clipDepth); - clips.add(clip); - prevClips.add(exporter.getClip()); - Matrix mat = Matrix.getTranslateInstance(rect.xMin, rect.yMin).preConcatenate(new Matrix(layer.matrix)); - exporter.addUse(mat, boundRect, assetName); - exporter.setClip(clip.shape); - exporter.endGroup(); - } else { - Matrix mat = Matrix.getTranslateInstance(rect.xMin, rect.yMin).preConcatenate(new Matrix(layer.matrix)); - exporter.addUse(mat, boundRect, assetName); - } - } - } - } - - private static String getTagIdPrefix(Tag tag, SVGExporter exporter) { - if (tag instanceof ShapeTag) { - return exporter.getUniqueId("shape"); - } - if (tag instanceof MorphShapeTag) { - return exporter.getUniqueId("morphshape"); - } - if (tag instanceof DefineSpriteTag) { - return exporter.getUniqueId("sprite"); - } - if (tag instanceof TextTag) { - return exporter.getUniqueId("text"); - } - if (tag instanceof ButtonTag) { - return exporter.getUniqueId("button"); - } - return exporter.getUniqueId("tag"); - } - - public static SerializableImage frameToImageGet(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, RECT displayRect, Matrix transformation, ColorTransform colorTransform, Color backGroundColor, boolean useCache) { - String key = "frame_" + frame + "_" + timeline.id + "_" + timeline.swf.hashCode(); - SerializableImage image; - if (useCache) { - image = getFromCache(key); - if (image != null) { - return image; - } - } - - if (timeline.frames.isEmpty()) { - return new SerializableImage(1, 1, SerializableImage.TYPE_INT_ARGB); - } - - RECT rect = displayRect; - image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1, - (int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB); - if (backGroundColor == null) { - image.fillTransparent(); - } else { - Graphics2D g = (Graphics2D) image.getBufferedImage().getGraphics(); - g.setComposite(AlphaComposite.Src); - g.setColor(backGroundColor); - g.fill(new Rectangle(image.getWidth(), image.getHeight())); - } - Matrix m = transformation.clone(); - m.translate(-rect.Xmin, -rect.Ymin); - frameToImage(timeline, frame, time, stateUnderCursor, mouseButton, image, m, colorTransform); - putToCache(key, image); - return image; - } - - public static void framesToImage(Timeline timeline, List ret, int startFrame, int stopFrame, DepthState stateUnderCursor, int mouseButton, RECT displayRect, int totalFrameCount, Stack visited, Matrix transformation, ColorTransform colorTransform) { - RECT rect = displayRect; - for (int f = 0; f < timeline.frames.size(); f++) { - SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1, - (int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB); - image.fillTransparent(); - Matrix m = new Matrix(); - m.translate(-rect.Xmin, -rect.Ymin); - frameToImage(timeline, f, 0, stateUnderCursor, mouseButton, image, m, colorTransform); - ret.add(image); - } - } - - public static void frameToImage(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { - float unzoom = (float) SWF.unitDivisor; - if (timeline.frames.size() <= frame) { - return; - } - Frame frameObj = timeline.frames.get(frame); - Graphics2D g = (Graphics2D) image.getGraphics(); - g.setPaint(frameObj.backgroundColor.toColor()); - g.fill(new Rectangle(image.getWidth(), image.getHeight())); - g.setTransform(transformation.toTransform()); - List clips = new ArrayList<>(); - List prevClips = new ArrayList<>(); - - int maxDepth = timeline.getMaxDepth(); - for (int i = 1; i <= maxDepth; i++) { - for (int c = 0; c < clips.size(); c++) { - if (clips.get(c).depth == i) { - g.setClip(prevClips.get(c)); - prevClips.remove(c); - clips.remove(c); - } - } - if (!frameObj.layers.containsKey(i)) { - continue; - } - DepthState layer = frameObj.layers.get(i); - if (!timeline.swf.characters.containsKey(layer.characterId)) { - continue; - } - if (!layer.isVisible) { - continue; - } - CharacterTag character = timeline.swf.characters.get(layer.characterId); - Matrix mat = new Matrix(layer.matrix); - mat = mat.preConcatenate(transformation); - - if (colorTransform == null) { - colorTransform = new ColorTransform(); - } - - ColorTransform clrTrans = Helper.deepCopy(colorTransform); - if (layer.colorTransForm != null && layer.blendMode <= 1) { //Normal blend mode - clrTrans = colorTransform.merge(layer.colorTransForm); - } - - boolean showPlaceholder = false; - if (character instanceof DrawableTag) { - DrawableTag drawable = (DrawableTag) character; - SerializableImage img; - Matrix drawMatrix = new Matrix(); - int drawableFrameCount = drawable.getNumFrames(); - if (drawableFrameCount == 0) { - drawableFrameCount = 1; - } - int dframe = (time + layer.time) % drawableFrameCount; - if (character instanceof ButtonTag) { - ButtonTag bt = (ButtonTag) character; - dframe = ButtonTag.FRAME_UP; - if (stateUnderCursor == layer) { - if (mouseButton > 0) { - dframe = ButtonTag.FRAME_DOWN; - } else { - dframe = ButtonTag.FRAME_OVER; - } - } - } - - RECT boundRect = drawable.getRect(); - ExportRectangle rect = new ExportRectangle(boundRect); - rect = mat.transform(rect); - Matrix m = mat.clone(); - if (layer.filters != null && layer.filters.size() > 0) { - // calculate size after applying the filters - double deltaXMax = 0; - double deltaYMax = 0; - for (FILTER filter : layer.filters) { - double x = filter.getDeltaX(); - double y = filter.getDeltaY(); - deltaXMax = Math.max(x, deltaXMax); - deltaYMax = Math.max(y, deltaYMax); - } - rect.xMin -= deltaXMax * SWF.unitDivisor; - rect.xMax += deltaXMax * SWF.unitDivisor; - rect.yMin -= deltaYMax * SWF.unitDivisor; - rect.yMax += deltaYMax * SWF.unitDivisor; - } - - rect.xMin -= SWF.unitDivisor; - rect.yMin -= SWF.unitDivisor; - rect.xMin = Math.max(0, rect.xMin); - rect.yMin = Math.max(0, rect.yMin); - - int newWidth = (int) (rect.getWidth() / SWF.unitDivisor); - int newHeight = (int) (rect.getHeight() / SWF.unitDivisor); - int deltaX = (int) (rect.xMin / SWF.unitDivisor); - int deltaY = (int) (rect.yMin / SWF.unitDivisor); - newWidth = Math.min(image.getWidth() - deltaX, newWidth) + 1; - newHeight = Math.min(image.getHeight() - deltaY, newHeight) + 1; - - if (newWidth <= 0 || newHeight <= 0) { - continue; - } - - img = new SerializableImage(newWidth, newHeight, SerializableImage.TYPE_INT_ARGB); - img.fillTransparent(); - - m.translate(-rect.xMin, -rect.yMin); - drawMatrix.translate(rect.xMin, rect.yMin); - - drawable.toImage(dframe, layer.time + time, layer.ratio, stateUnderCursor, mouseButton, img, m, clrTrans); - //if(stateUnderCursor == layer){ - /* if(true){ - Graphics2D gg = (Graphics2D)img.getGraphics(); - gg.setStroke(new BasicStroke(3)); - gg.setPaint(Color.red); - gg.setTransform(AffineTransform.getTranslateInstance(0, 0)); - gg.draw(SHAPERECORD.twipToPixelShape(drawable.getOutline(frame, layer.ratio, stateUnderCursor, mouseButton, m))); - }*/ - - if (layer.filters != null) { - for (FILTER filter : layer.filters) { - img = filter.apply(img); - } - } - if (layer.blendMode > 1) { - if (layer.colorTransForm != null) { - img = layer.colorTransForm.apply(img); - } - } - - drawMatrix.translateX /= unzoom; - drawMatrix.translateY /= unzoom; - AffineTransform trans = drawMatrix.toTransform(); - - switch (layer.blendMode) { - case 0: - case 1: - g.setComposite(AlphaComposite.SrcOver); - break; - case 2://Layer - g.setComposite(AlphaComposite.SrcOver); - break; - case 3: - g.setComposite(BlendComposite.Multiply); - break; - case 4: - g.setComposite(BlendComposite.Screen); - break; - case 5: - g.setComposite(BlendComposite.Lighten); - break; - case 6: - g.setComposite(BlendComposite.Darken); - break; - case 7: - g.setComposite(BlendComposite.Difference); - break; - case 8: - g.setComposite(BlendComposite.Add); - break; - case 9: - g.setComposite(BlendComposite.Subtract); - break; - case 10: - g.setComposite(BlendComposite.Invert); - break; - case 11: - g.setComposite(BlendComposite.Alpha); - break; - case 12: - g.setComposite(BlendComposite.Erase); - break; - case 13: - g.setComposite(BlendComposite.Overlay); - break; - case 14: - g.setComposite(BlendComposite.HardLight); - break; - default: //Not implemented - g.setComposite(AlphaComposite.SrcOver); - break; - } - - if (layer.clipDepth > -1) { - BufferedImage mask = new BufferedImage(image.getWidth(), image.getHeight(), image.getType()); - Graphics2D gm = (Graphics2D) mask.getGraphics(); - gm.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); - gm.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); - gm.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - gm.setComposite(AlphaComposite.Src); - gm.setColor(new Color(0, 0, 0, 0f)); - gm.fillRect(0, 0, image.getWidth(), image.getHeight()); - gm.setTransform(trans); - gm.drawImage(img.getBufferedImage(), 0, 0, null); - Clip clip = new Clip(Helper.imageToShape(mask), layer.clipDepth); //Maybe we can get current outline instead converting from image (?) - clips.add(clip); - prevClips.add(g.getClip()); - g.setTransform(AffineTransform.getTranslateInstance(0, 0)); - g.setClip(clip.shape); - } else { - g.setTransform(trans); - g.drawImage(img.getBufferedImage(), 0, 0, null); - } - } else if (character instanceof BoundedTag) { - showPlaceholder = true; - } - - if (showPlaceholder) { - mat.translateX /= unzoom; - mat.translateY /= unzoom; - AffineTransform trans = mat.toTransform(); - g.setTransform(trans); - BoundedTag b = (BoundedTag) character; - g.setPaint(new Color(255, 255, 255, 128)); - g.setComposite(BlendComposite.Invert); - RECT r = b.getRect(); - int div = (int) unzoom; - g.drawString(character.toString(), r.Xmin / div + 3, r.Ymin / div + 15); - g.draw(new Rectangle(r.Xmin / div, r.Ymin / div, r.getWidth() / div, r.getHeight() / div)); - g.drawLine(r.Xmin / div, r.Ymin / div, r.Xmax / div, r.Ymax / div); - g.drawLine(r.Xmax / div, r.Ymin / div, r.Xmin / div, r.Ymax / div); - g.setComposite(AlphaComposite.Dst); - } - } - - g.setTransform(AffineTransform.getScaleInstance(1, 1)); - } - - private void removeTagWithDependenciesFromTimeline(Tag toRemove, Timeline timeline) { - int characterId = 0; - if (toRemove instanceof CharacterTag) { - characterId = ((CharacterTag) toRemove).getCharacterId(); - } - Map stage = new HashMap<>(); - - Set dependingChars = new HashSet<>(); - if (characterId != 0) { - dependingChars.add(characterId); - for (int i = 0; i < timeline.tags.size(); i++) { - Tag t = timeline.tags.get(i); - if (t instanceof CharacterIdTag) { - CharacterIdTag c = (CharacterIdTag) t; - Set needed = new HashSet<>(); - t.getNeededCharacters(needed); - if (needed.contains(characterId)) { - dependingChars.add(c.getCharacterId()); - } - } - } - } - - for (int i = 0; i < timeline.tags.size(); i++) { - Tag t = timeline.tags.get(i); - if (t instanceof RemoveTag) { - RemoveTag rt = (RemoveTag) t; - int depth = rt.getDepth(); - if (stage.containsKey(depth)) { - int currentCharId = stage.get(depth); - stage.remove(depth); - if (dependingChars.contains(currentCharId)) { - timeline.tags.remove(i); - i--; - continue; - } - } - } - if (t instanceof PlaceObjectTypeTag) { - PlaceObjectTypeTag po = (PlaceObjectTypeTag) t; - int placeCharId = po.getCharacterId(); - int depth = po.getDepth(); - if (placeCharId != 0) { - stage.put(depth, placeCharId); - if (dependingChars.contains(placeCharId)) { - timeline.tags.remove(i); - i--; - continue; - } - } - } - if (t instanceof CharacterIdTag) { - CharacterIdTag c = (CharacterIdTag) t; - if (dependingChars.contains(c.getCharacterId())) { - timeline.tags.remove(i); - i--; - continue; - } - } - Set needed = new HashSet<>(); - t.getNeededCharacters(needed); - for (int dep : dependingChars) { - if (needed.contains(dep)) { - timeline.tags.remove(i); - i--; - continue; - } - } - if (t == toRemove) { - timeline.tags.remove(i); - i--; - continue; - } - if (t instanceof Timelined) { - removeTagWithDependenciesFromTimeline(toRemove, ((Timelined) t).getTimeline()); - } - } - } - - private boolean removeTagFromTimeline(Tag toRemove, Timeline timeline) { - boolean modified = false; - int characterId = -1; - if (toRemove instanceof CharacterTag) { - characterId = ((CharacterTag) toRemove).getCharacterId(); - modified = timeline.removeCharacter(characterId); - } - for (int i = 0; i < timeline.tags.size(); i++) { - Tag t = timeline.tags.get(i); - if (t == toRemove) { - timeline.tags.remove(t); - i--; - continue; - } - - if (toRemove instanceof CharacterTag) { - if (t.removeCharacter(characterId)) { - modified = true; - i = -1; - continue; - } - } - - if (t instanceof DefineSpriteTag) { - DefineSpriteTag spr = (DefineSpriteTag) t; - boolean sprModified = removeTagFromTimeline(toRemove, spr.getTimeline()); - if (sprModified) { - spr.setModified(true); - } - modified |= sprModified; - } - } - return modified; - } - - public void removeTag(Tag t, boolean removeDependencies) { - Timelined timelined = t.getTimelined(); - if (t instanceof ShowFrameTag || ShowFrameTag.isNestedTagType(t.getId())) { - List tags; - if (timelined instanceof DefineSpriteTag) { - tags = ((DefineSpriteTag) timelined).getSubTags(); - } else { - tags = this.tags; - } - tags.remove(t); - timelined.resetTimeline(); - } else { - // timeline should be always the swf here - if (removeDependencies) { - removeTagWithDependenciesFromTimeline(t, timelined.getTimeline()); - } else { - removeTagFromTimeline(t, timeline); - } - } - resetTimelines(timelined); - updateCharacters(); - clearImageCache(); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash; + +import SevenZip.Compression.LZMA.Encoder; +import com.jpacker.JPacker; +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.ClassPath; +import com.jpexs.decompiler.flash.abc.RenameType; +import com.jpexs.decompiler.flash.abc.ScriptPack; +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.ActionDeobfuscation; +import com.jpexs.decompiler.flash.action.ActionGraphSource; +import com.jpexs.decompiler.flash.action.ActionLocalData; +import com.jpexs.decompiler.flash.action.model.ConstantPool; +import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.flash.action.model.FunctionActionItem; +import com.jpexs.decompiler.flash.action.model.GetMemberActionItem; +import com.jpexs.decompiler.flash.action.model.GetVariableActionItem; +import com.jpexs.decompiler.flash.action.model.clauses.ClassActionItem; +import com.jpexs.decompiler.flash.action.model.clauses.InterfaceActionItem; +import com.jpexs.decompiler.flash.action.swf4.ActionEquals; +import com.jpexs.decompiler.flash.action.swf4.ActionGetVariable; +import com.jpexs.decompiler.flash.action.swf4.ActionIf; +import com.jpexs.decompiler.flash.action.swf4.ActionPush; +import com.jpexs.decompiler.flash.action.swf4.ActionSetVariable; +import com.jpexs.decompiler.flash.action.swf4.ConstantIndex; +import com.jpexs.decompiler.flash.action.swf5.ActionCallFunction; +import com.jpexs.decompiler.flash.action.swf5.ActionCallMethod; +import com.jpexs.decompiler.flash.action.swf5.ActionConstantPool; +import com.jpexs.decompiler.flash.action.swf5.ActionDefineFunction; +import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal; +import com.jpexs.decompiler.flash.action.swf5.ActionDefineLocal2; +import com.jpexs.decompiler.flash.action.swf5.ActionEquals2; +import com.jpexs.decompiler.flash.action.swf5.ActionGetMember; +import com.jpexs.decompiler.flash.action.swf5.ActionNewMethod; +import com.jpexs.decompiler.flash.action.swf5.ActionNewObject; +import com.jpexs.decompiler.flash.action.swf5.ActionSetMember; +import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2; +import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.dumpview.DumpInfoSwfNode; +import com.jpexs.decompiler.flash.ecma.Null; +import com.jpexs.decompiler.flash.exporters.BinaryDataExporter; +import com.jpexs.decompiler.flash.exporters.FontExporter; +import com.jpexs.decompiler.flash.exporters.ImageExporter; +import com.jpexs.decompiler.flash.exporters.MorphShapeExporter; +import com.jpexs.decompiler.flash.exporters.MovieExporter; +import com.jpexs.decompiler.flash.exporters.ShapeExporter; +import com.jpexs.decompiler.flash.exporters.SoundExporter; +import com.jpexs.decompiler.flash.exporters.TextExporter; +import com.jpexs.decompiler.flash.exporters.commonshape.ExportRectangle; +import com.jpexs.decompiler.flash.exporters.commonshape.Matrix; +import com.jpexs.decompiler.flash.exporters.commonshape.SVGExporter; +import com.jpexs.decompiler.flash.exporters.modes.FramesExportMode; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; +import com.jpexs.decompiler.flash.exporters.settings.BinaryDataExportSettings; +import com.jpexs.decompiler.flash.exporters.settings.FontExportSettings; +import com.jpexs.decompiler.flash.exporters.settings.FramesExportSettings; +import com.jpexs.decompiler.flash.exporters.settings.ImageExportSettings; +import com.jpexs.decompiler.flash.exporters.settings.MorphShapeExportSettings; +import com.jpexs.decompiler.flash.exporters.settings.MovieExportSettings; +import com.jpexs.decompiler.flash.exporters.settings.ShapeExportSettings; +import com.jpexs.decompiler.flash.exporters.settings.SoundExportSettings; +import com.jpexs.decompiler.flash.exporters.settings.TextExportSettings; +import com.jpexs.decompiler.flash.exporters.shape.CanvasShapeExporter; +import com.jpexs.decompiler.flash.helpers.collections.MyEntry; +import com.jpexs.decompiler.flash.tags.ABCContainerTag; +import com.jpexs.decompiler.flash.tags.DefineButton2Tag; +import com.jpexs.decompiler.flash.tags.DefineButtonTag; +import com.jpexs.decompiler.flash.tags.DefineSpriteTag; +import com.jpexs.decompiler.flash.tags.DoInitActionTag; +import com.jpexs.decompiler.flash.tags.EndTag; +import com.jpexs.decompiler.flash.tags.ExportAssetsTag; +import com.jpexs.decompiler.flash.tags.FileAttributesTag; +import com.jpexs.decompiler.flash.tags.JPEGTablesTag; +import com.jpexs.decompiler.flash.tags.SetBackgroundColorTag; +import com.jpexs.decompiler.flash.tags.ShowFrameTag; +import com.jpexs.decompiler.flash.tags.SymbolClassTag; +import com.jpexs.decompiler.flash.tags.Tag; +import com.jpexs.decompiler.flash.tags.TagStub; +import com.jpexs.decompiler.flash.tags.VideoFrameTag; +import com.jpexs.decompiler.flash.tags.base.ASMSource; +import com.jpexs.decompiler.flash.tags.base.BoundedTag; +import com.jpexs.decompiler.flash.tags.base.ButtonTag; +import com.jpexs.decompiler.flash.tags.base.CharacterIdTag; +import com.jpexs.decompiler.flash.tags.base.CharacterTag; +import com.jpexs.decompiler.flash.tags.base.Container; +import com.jpexs.decompiler.flash.tags.base.ContainerItem; +import com.jpexs.decompiler.flash.tags.base.DrawableTag; +import com.jpexs.decompiler.flash.tags.base.FontTag; +import com.jpexs.decompiler.flash.tags.base.ImageTag; +import com.jpexs.decompiler.flash.tags.base.MorphShapeTag; +import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; +import com.jpexs.decompiler.flash.tags.base.RemoveTag; +import com.jpexs.decompiler.flash.tags.base.ShapeTag; +import com.jpexs.decompiler.flash.tags.base.TextTag; +import com.jpexs.decompiler.flash.timeline.Clip; +import com.jpexs.decompiler.flash.timeline.DepthState; +import com.jpexs.decompiler.flash.timeline.Frame; +import com.jpexs.decompiler.flash.timeline.SvgClip; +import com.jpexs.decompiler.flash.timeline.Timeline; +import com.jpexs.decompiler.flash.timeline.Timelined; +import com.jpexs.decompiler.flash.treeitems.AS2PackageNodeItem; +import com.jpexs.decompiler.flash.treeitems.AS3PackageNodeItem; +import com.jpexs.decompiler.flash.treeitems.FrameNodeItem; +import com.jpexs.decompiler.flash.treeitems.SWFList; +import com.jpexs.decompiler.flash.treeitems.TreeItem; +import com.jpexs.decompiler.flash.treenodes.AS2PackageNode; +import com.jpexs.decompiler.flash.treenodes.ContainerNode; +import com.jpexs.decompiler.flash.treenodes.FrameNode; +import com.jpexs.decompiler.flash.treenodes.TagNode; +import com.jpexs.decompiler.flash.treenodes.TreeNode; +import com.jpexs.decompiler.flash.types.ColorTransform; +import com.jpexs.decompiler.flash.types.MATRIX; +import com.jpexs.decompiler.flash.types.RECT; +import com.jpexs.decompiler.flash.types.RGB; +import com.jpexs.decompiler.flash.types.RGBA; +import com.jpexs.decompiler.flash.types.filters.BEVELFILTER; +import com.jpexs.decompiler.flash.types.filters.BlendComposite; +import com.jpexs.decompiler.flash.types.filters.COLORMATRIXFILTER; +import com.jpexs.decompiler.flash.types.filters.CONVOLUTIONFILTER; +import com.jpexs.decompiler.flash.types.filters.DROPSHADOWFILTER; +import com.jpexs.decompiler.flash.types.filters.FILTER; +import com.jpexs.decompiler.flash.types.filters.GLOWFILTER; +import com.jpexs.decompiler.flash.types.filters.GRADIENTBEVELFILTER; +import com.jpexs.decompiler.flash.types.filters.GRADIENTGLOWFILTER; +import com.jpexs.decompiler.flash.xfl.FLAVersion; +import com.jpexs.decompiler.flash.xfl.XFLConverter; +import com.jpexs.decompiler.graph.Graph; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphSourceItemContainer; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.model.LocalData; +import com.jpexs.helpers.Cache; +import com.jpexs.helpers.CancellableWorker; +import com.jpexs.helpers.Helper; +import com.jpexs.helpers.NulStream; +import com.jpexs.helpers.ProgressListener; +import com.jpexs.helpers.SerializableImage; +import com.jpexs.helpers.utf8.Utf8Helper; +import gnu.jpdf.PDFJob; +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.RenderingHints; +import java.awt.Shape; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import java.awt.print.PageFormat; +import java.awt.print.Paper; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.EmptyStackException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.Stack; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.zip.DeflaterOutputStream; +import java.util.zip.InflaterInputStream; +import javax.imageio.ImageIO; +import javax.imageio.stream.FileImageOutputStream; +import javax.imageio.stream.ImageOutputStream; +import javax.xml.bind.DatatypeConverter; +import net.kroo.elliot.GifSequenceWriter; +import org.monte.media.VideoFormatKeys; +import org.monte.media.avi.AVIWriter; + +/** + * Class representing SWF file + * + * @author JPEXS + */ +public final class SWF implements TreeItem, Timelined { + + /** + * Default version of SWF file format + */ + public static final int DEFAULT_VERSION = 10; + /** + * Tags inside of file + */ + public List tags = new ArrayList<>(); + public boolean hasEndTag; + /** + * ExportRectangle 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; + /** + * Uncompressed size of the file + */ + public long fileSize; + /** + * Used compression mode + */ + public SWFCompression compression = SWFCompression.NONE; + /** + * Compressed size of the file (LZMA) + */ + public long compressedSize; + /** + * LZMA Properties + */ + public byte[] lzmaProperties; + public byte[] uncompressedData; + public FileAttributesTag fileAttributes; + /** + * ScaleForm GFx + */ + public boolean gfx = false; + + public SWFList swfList; + public String file; + public String fileTitle; + public boolean readOnly; + public boolean isAS3; + public Map characters = new HashMap<>(); + public List abcList; + public JPEGTablesTag jtt; + public Map sourceFontsMap = new HashMap<>(); + public static final double unitDivisor = 20; + + private Timeline timeline; + + public DumpInfoSwfNode dumpInfo; + + public void updateCharacters() { + characters.clear(); + parseCharacters(new ArrayList(tags)); + } + + public void resetTimelines(Timelined timelined) { + timelined.resetTimeline(); + List tags = timelined.getTimeline().tags; + for (int i = 0; i < tags.size(); i++) { + Tag t = tags.get(i); + if (t instanceof Timelined) { + resetTimelines((Timelined) t); + } + } + } + + private void parseCharacters(List list) { + for (ContainerItem t : list) { + if (t instanceof CharacterTag) { + characters.put(((CharacterTag) t).getCharacterId(), (CharacterTag) t); + } + if (t instanceof Container) { + parseCharacters(((Container) t).getSubItems()); + } + } + } + + /** + * Unresolve recursive sprites + */ + private void checkInvalidSprites() { + for (int i = 0; i < tags.size(); i++) { + Tag t = tags.get(i); + if (t instanceof DefineSpriteTag) { + if (!isSpriteValid((DefineSpriteTag) t, new ArrayList())) { + tags.set(i, new TagStub(this, t.getId(), "InvalidSprite", t.getOriginalRange(), null)); + } + } + } + } + + private boolean isSpriteValid(DefineSpriteTag sprite, List path) { + if (path.contains(sprite.spriteId)) { + return false; + } + path.add(sprite.spriteId); + for (Tag t : sprite.subTags) { + if (t instanceof DefineSpriteTag) { + if (!isSpriteValid((DefineSpriteTag) t, path)) { + return false; + } + } + } + path.remove((Integer) sprite.spriteId); + return true; + } + + @Override + public Timeline getTimeline() { + if (timeline == null) { + timeline = new Timeline(this); + } + return timeline; + } + + @Override + public void resetTimeline() { + timeline = null; + } + + /** + * 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 { + saveTo(os, compression); + } + + /** + * Saves this SWF into new file + * + * @param os OutputStream to save SWF in + * @param compression + * @throws IOException + */ + public void saveTo(OutputStream os, SWFCompression compression) 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); + if (hasEndTag) { + sos.writeUI16(0); + } + sos.close(); + if (compression == SWFCompression.LZMA) { + os.write('Z'); + } else if (compression == SWFCompression.ZLIB) { + os.write('C'); + } else { + if (gfx) { + os.write('G'); + } else { + os.write('F'); + } + } + if (gfx) { + os.write('F'); + os.write('X'); + } else { + os.write('W'); + os.write('S'); + } + os.write(version); + byte[] data = baos.toByteArray(); + sos = new SWFOutputStream(os, version); + sos.writeUI32(data.length + 8); + + if (compression == SWFCompression.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 if (compression == SWFCompression.ZLIB) { + os = new DeflaterOutputStream(os); + } + os.write(data); + } finally { + if (os != null) { + os.close(); + } + } + } + + public void clearModified() { + for (Tag tag : tags) { + if (tag.isModified()) { + tag.createOriginalData(); + tag.setModified(false); + } + } + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + saveTo(baos, SWFCompression.NONE); + byte[] swfData = baos.toByteArray(); + uncompressedData = swfData; + } catch (IOException ex) { + Logger.getLogger(SWF.class.getName()).log(Level.SEVERE, "Cannot save SWF", ex); + } + } + + public SWF(InputStream is, boolean parallelRead) throws IOException, InterruptedException { + this(is, null, parallelRead); + } + + /** + * Construct SWF from stream + * + * @param is Stream to read SWF from + * @param listener + * @param parallelRead Use parallel threads? + * @throws IOException + * @throws java.lang.InterruptedException + */ + public SWF(InputStream is, ProgressListener listener, boolean parallelRead) throws IOException, InterruptedException { + this(is, listener, parallelRead, false); + } + + /** + * Faster constructor to check SWF only + * + * @param is + * @throws java.io.IOException + */ + public SWF(InputStream is) throws IOException { + decompress(is, new NulStream(), true); + } + + /** + * Construct SWF from stream + * + * @param is Stream to read SWF from + * @param listener + * @param parallelRead Use parallel threads? + * @param checkOnly Check only file validity + * @throws IOException + * @throws java.lang.InterruptedException + */ + public SWF(InputStream is, ProgressListener listener, boolean parallelRead, boolean checkOnly) throws IOException, InterruptedException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SWFHeader header = decompress(is, baos, true); + gfx = header.gfx; + compression = header.compression; + uncompressedData = baos.toByteArray(); + + SWFInputStream sis = new SWFInputStream(this, uncompressedData); + dumpInfo = new DumpInfoSwfNode(this, "rootswf", "", null, 0, 0); + if (Configuration.dumpInfoCollecting.get()) { + sis.dumpInfo = dumpInfo; + } + sis.readBytesEx(3, "signature"); // skip siganture + version = sis.readUI8("version"); + fileSize = sis.readUI32("fileSize"); + dumpInfo.lengthBytes = fileSize; + if (listener != null) { + sis.addPercentListener(listener); + } + sis.setPercentMax(fileSize); + displayRect = sis.readRECT("displayRect"); + // FIXED8 (16 bit fixed point) frameRate + sis.readUI8("tmpFirstByetOfFrameRate"); //tmpFirstByetOfFrameRate + frameRate = sis.readUI8("frameRate"); + frameCount = sis.readUI16("frameCount"); + List tags = sis.readTagList(this, 0, parallelRead, true, !checkOnly, gfx); + if (tags.get(tags.size() - 1).getId() == EndTag.ID) { + hasEndTag = true; + tags.remove(tags.size() - 1); + } + this.tags = tags; + if (!checkOnly) { + checkInvalidSprites(); + updateCharacters(); + assignExportNamesToSymbols(); + assignClassesToSymbols(); + findFileAttributes(); + findABCTags(); + } else { + boolean hasNonUnknownTag = false; + for (Tag tag : tags) { + if (tag.getOriginalDataLength() > 0 && Tag.getRequiredTags().contains(tag.getId())) { + hasNonUnknownTag = true; + } + } + if (!hasNonUnknownTag) { + throw new IOException("Invalid SWF file. No known tag found."); + } + } + } + + @Override + public SWF getSwf() { + return this; + } + + /** + * Get title of the file + * + * @return file title + */ + public String getFileTitle() { + if (fileTitle != null) { + return fileTitle; + } + return file; + } + + public String getShortFileName() { + String title = getFileTitle(); + if (title == null) { + return ""; + } + return new File(title).getName(); + } + + private void findABCTags() { + List objs = new ArrayList<>(); + objs.addAll(tags); + + ArrayList newAbcList = new ArrayList<>(); + getABCTags(objs, newAbcList); + this.abcList = newAbcList; + } + + private static void getABCTags(List list, List actionScripts) { + for (ContainerItem t : list) { + if (t instanceof Container) { + getABCTags(((Container) t).getSubItems(), actionScripts); + } + if (t instanceof ABCContainerTag) { + actionScripts.add((ABCContainerTag) t); + } + } + } + + private void findFileAttributes() { + for (Tag t : tags) { + if (t instanceof FileAttributesTag) { + fileAttributes = (FileAttributesTag) t; + break; + } + } + } + + private void assignExportNamesToSymbols() { + HashMap exportNames = new HashMap<>(); + for (Tag t : tags) { + if (t instanceof ExportAssetsTag) { + ExportAssetsTag eat = (ExportAssetsTag) t; + for (int i = 0; i < eat.tags.size(); i++) { + if ((!exportNames.containsKey(eat.tags.get(i))) && (!exportNames.containsValue(eat.names.get(i)))) { + exportNames.put(eat.tags.get(i), eat.names.get(i)); + } + } + } + } + for (Tag t : tags) { + if (t instanceof CharacterIdTag) { + CharacterIdTag ct = (CharacterIdTag) t; + if (exportNames.containsKey(ct.getCharacterId())) { + ct.setExportName(exportNames.get(ct.getCharacterId())); + } + } + } + } + + public void assignClassesToSymbols() { + HashMap classes = new HashMap<>(); + for (Tag t : tags) { + if (t instanceof SymbolClassTag) { + SymbolClassTag sct = (SymbolClassTag) t; + for (int i = 0; i < sct.tags.length; i++) { + if ((!classes.containsKey(sct.tags[i])) && (!classes.containsValue(sct.names[i]))) { + classes.put(sct.tags[i], sct.names[i]); + } + } + } + } + for (Tag t : tags) { + if (t instanceof CharacterTag) { + CharacterTag ct = (CharacterTag) t; + if (classes.containsKey(ct.getCharacterId())) { + ct.setClassName(classes.get(ct.getCharacterId())); + } + } + } + } + + /** + * Compress SWF file + * + * @param fis Input stream + * @param fos Output stream + * @return True on success + */ + 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 (IOException ex) { + return false; + } + return true; + } + + public static boolean decompress(InputStream fis, OutputStream fos) { + try { + decompress(fis, fos, false); + return true; + } catch (IOException ex) { + return false; + } + } + + private static SWFHeader decompress(InputStream is, OutputStream os, boolean allowUncompressed) throws IOException { + byte[] hdr = new byte[8]; + + // SWFheader: signature, version and fileSize + if (is.read(hdr) != 8) { + throw new IOException("SWF header is too short"); + } + + String signature = new String(hdr, 0, 3, Utf8Helper.charset); + if (!Arrays.asList( + "FWS", //Uncompressed Flash + "CWS", //ZLib compressed Flash + "ZWS", //LZMA compressed Flash + "GFX", //Uncompressed ScaleForm GFx + "CFX" //Compressed ScaleForm GFx + ).contains(signature)) { + throw new IOException("Invalid SWF file"); + } + + int version = hdr[3]; + SWFInputStream sis = new SWFInputStream(null, Arrays.copyOfRange(hdr, 4, 8), 4, 4); + long fileSize = sis.readUI32("fileSize"); + SWFHeader header = new SWFHeader(); + header.version = version; + header.fileSize = fileSize; + + if (hdr[1] == 'F' && hdr[2] == 'X') { + header.gfx = true; + } + + try (SWFOutputStream sos = new SWFOutputStream(os, version)) { + sos.write(Utf8Helper.getBytes("FWS")); + sos.writeUI8(version); + sos.writeUI32(fileSize); + + switch (hdr[0]) { + case 'C': { // CWS, CFX + Helper.copyStream(new InflaterInputStream(is), os, fileSize - 8); + header.compression = SWFCompression.ZLIB; + break; + } + case 'Z': { // ZWS + sis.readUI32("LZMAsize"); // compressed LZMA data size = compressed SWF - 17 byte, + // where 17 = 8 byte header + this 4 byte + 5 bytes decoder properties + int propertiesSize = 5; + byte[] lzmaProperties = sis.readBytes(propertiesSize, "lzmaproperties"); + if (lzmaProperties.length != 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"); + } + if (!decoder.Code(is, os, fileSize - 8)) { + throw new IOException("LZMA:Error in data stream"); + } + + header.compression = SWFCompression.LZMA; + break; + } + default: { // FWS, GFX + if (allowUncompressed) { + Helper.copyStream(is, os, fileSize - 8); + } else { + throw new IOException("SWF is not compressed"); + } + } + } + + return header; + } + } + + public static boolean renameInvalidIdentifiers(RenameType renameType, InputStream fis, OutputStream fos) { + try { + SWF swf = new SWF(fis, Configuration.parallelSpeedUp.get()); + int cnt = swf.deobfuscateIdentifiers(renameType); + swf.assignClassesToSymbols(); + System.out.println(cnt + " identifiers renamed."); + swf.saveTo(fos); + } catch (InterruptedException ex) { + return false; + } catch (IOException ex) { + return false; + } + return true; + } + + public boolean exportAS3Class(String className, String outdir, ScriptExportMode exportMode, boolean parallel) throws Exception { + List abcTags = new ArrayList<>(); + + for (Tag t : tags) { + if (t instanceof ABCContainerTag) { + ABCContainerTag cnt = (ABCContainerTag) t; + abcTags.add(cnt); + } + } + + boolean exported = false; + + for (int i = 0; i < abcTags.size(); i++) { + ABC abc = abcTags.get(i).getABC(); + List scrs = abc.findScriptPacksByPath(className); + for (ScriptPack scr : scrs) { + String cnt = ""; + if (abc.script_info.size() > 1) { + cnt = "script " + (i + 1) + "/" + abc.script_info.size() + " "; + } + String exStr = "Exporting " + "tag " + (i + 1) + "/" + abcTags.size() + " " + cnt + scr.getPath() + " ..."; + informListeners("exporting", exStr); + scr.export(outdir, abcTags, exportMode, parallel); + exStr = "Exported " + "tag " + (i + 1) + "/" + abcTags.size() + " " + cnt + scr.getPath() + " ..."; + informListeners("exported", exStr); + exported = true; + } + } + return exported; + } + + private List> uniqueAS3Packs(List> packs) { + List> ret = new ArrayList<>(); + for (MyEntry item : packs) { + for (MyEntry itemOld : ret) { + if (item.key.equals(itemOld.key)) { + Logger.getLogger(SWF.class.getName()).log(Level.SEVERE, "Duplicate pack path found (" + itemOld.key + ")!"); + break; + } + } + ret.add(item); + } + return ret; + } + + public List> getAS3Packs() { + List abcTags = new ArrayList<>(); + for (Tag t : tags) { + if (t instanceof ABCContainerTag) { + abcTags.add((ABCContainerTag) t); + } + } + List> packs = new ArrayList<>(); + for (int i = 0; i < abcTags.size(); i++) { + ABCContainerTag t = abcTags.get(i); + packs.addAll(t.getABC().getScriptPacks()); + } + return uniqueAS3Packs(packs); + } + + @Override + public RECT getRect() { + return displayRect; + } + + private class ExportPackTask implements Callable { + + ScriptPack pack; + String directory; + List abcList; + ScriptExportMode exportMode; + ClassPath path; + AtomicInteger index; + int count; + boolean parallel; + AbortRetryIgnoreHandler handler; + long startTime; + long stopTime; + + public ExportPackTask(AbortRetryIgnoreHandler handler, AtomicInteger index, int count, ClassPath path, ScriptPack pack, String directory, List abcList, ScriptExportMode exportMode, boolean parallel) { + this.pack = pack; + this.directory = directory; + this.abcList = abcList; + this.exportMode = exportMode; + this.path = path; + this.index = index; + this.count = count; + this.parallel = parallel; + this.handler = handler; + } + + @Override + public File call() throws Exception { + RunnableIOExResult rio = new RunnableIOExResult() { + @Override + public void run() throws IOException { + startTime = System.currentTimeMillis(); + this.result = pack.export(directory, abcList, exportMode, parallel); + stopTime = System.currentTimeMillis(); + } + }; + int currentIndex = index.getAndIncrement(); + synchronized (ABC.class) { + long time = stopTime - startTime; + informListeners("exporting", "Exporting script " + currentIndex + "/" + count + " " + path); + } + new RetryTask(rio, handler).run(); + synchronized (ABC.class) { + long time = stopTime - startTime; + informListeners("exported", "Exported script " + currentIndex + "/" + count + " " + path + ", " + Helper.formatTimeSec(time)); + } + return rio.result; + } + } + + public List exportActionScript2(AbortRetryIgnoreHandler handler, String outdir, ScriptExportMode exportMode, boolean parallel, EventListener evl) throws IOException { + List ret = new ArrayList<>(); + 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; + ret.addAll(TagNode.exportNodeAS(handler, list, outdir, exportMode, evl)); + return ret; + } + + public List exportActionScript3(final AbortRetryIgnoreHandler handler, final String outdir, final ScriptExportMode exportMode, final boolean parallel) { + final AtomicInteger cnt = new AtomicInteger(1); + final List abcTags = new ArrayList<>(); + for (Tag t : tags) { + if (t instanceof ABCContainerTag) { + abcTags.add((ABCContainerTag) t); + } + } + + final List ret = new ArrayList<>(); + final List> packs = getAS3Packs(); + + if (!parallel || packs.size() < 2) { + try { + CancellableWorker.call(new Callable() { + @Override + public Void call() throws Exception { + for (MyEntry item : packs) { + ExportPackTask task = new ExportPackTask(handler, cnt, packs.size(), item.key, item.value, outdir, abcTags, exportMode, parallel); + ret.add(task.call()); + } + return null; + } + }, Configuration.exportTimeout.get(), TimeUnit.SECONDS); + } catch (TimeoutException ex) { + Logger.getLogger(ABC.class.getName()).log(Level.SEVERE, Helper.formatTimeToText(Configuration.exportTimeout.get()) + " ActionScript export limit reached", ex); + } catch (Exception ex) { + Logger.getLogger(ABC.class.getName()).log(Level.SEVERE, "Error during ABC export", ex); + } + } else { + ExecutorService executor = Executors.newFixedThreadPool(Configuration.parallelThreadCount.get()); + List> futureResults = new ArrayList<>(); + for (MyEntry item : packs) { + Future future = executor.submit(new ExportPackTask(handler, cnt, packs.size(), item.key, item.value, outdir, abcTags, exportMode, parallel)); + futureResults.add(future); + } + + try { + executor.shutdown(); + if (!executor.awaitTermination(Configuration.exportTimeout.get(), TimeUnit.SECONDS)) { + Logger.getLogger(ABC.class.getName()).log(Level.SEVERE, Helper.formatTimeToText(Configuration.exportTimeout.get()) + " ActionScript export limit reached"); + } + } catch (InterruptedException ex) { + } finally { + executor.shutdownNow(); + } + + for (int f = 0; f < futureResults.size(); f++) { + try { + if (futureResults.get(f).isDone()) { + ret.add(futureResults.get(f).get()); + } + } catch (InterruptedException ex) { + } catch (ExecutionException ex) { + Logger.getLogger(SWF.class.getName()).log(Level.SEVERE, "Error during ABC export", ex); + } + } + } + + return ret; + } + + public List exportActionScript(AbortRetryIgnoreHandler handler, String outdir, ScriptExportMode exportMode, boolean parallel) throws Exception { + boolean asV3Found = false; + List ret = new ArrayList<>(); + final EventListener evl = new EventListener() { + @Override + public void handleEvent(String event, Object data) { + if (event.equals("exporting") || event.equals("exported")) { + informListeners(event, data); + } + } + }; + for (Tag t : tags) { + if (t instanceof ABCContainerTag) { + asV3Found = true; + } + } + + if (asV3Found) { + ret.addAll(exportActionScript3(handler, outdir, exportMode, parallel)); + } else { + ret.addAll(exportActionScript2(handler, outdir, exportMode, parallel, evl)); + } + return ret; + } + + public static List createASTagList(List list, Timelined parent) { + List ret = new ArrayList<>(); + int frame = 1; + List frames = new ArrayList<>(); + + List exportAssetsTags = new ArrayList<>(); + for (ContainerItem t : list) { + if (t instanceof ExportAssetsTag) { + exportAssetsTags.add((ExportAssetsTag) t); + } + TreeNode addNode = null; + if (t instanceof ShowFrameTag) { + // do not add PlaceObjects (+etc) to script nodes + FrameNode tti = new FrameNode(new FrameNodeItem(t.getSwf(), frame, parent, false), null, true); + + for (int r = ret.size() - 1; r >= 0; r--) { + if (!(ret.get(r).getItem() instanceof DefineSpriteTag)) { + if (!(ret.get(r).getItem() instanceof DefineButtonTag)) { + if (!(ret.get(r).getItem() instanceof DefineButton2Tag)) { + if (!(ret.get(r).getItem() instanceof DoInitActionTag)) { + if (!(ret.get(r).getItem() instanceof AS2PackageNodeItem)) { + tti.subNodes.add(ret.get(r)); + ret.remove(r); + } + } + } + } + } + } + frame++; + frames.add(tti); + } else if (t instanceof ASMSource) { + ContainerNode tti = new ContainerNode(t); + //ret.add(tti); + addNode = tti; + } else if (t instanceof Container) { + if (((Container) t).getItemCount() > 0) { + + ContainerNode tti = new ContainerNode(t); + List subItems = ((Container) t).getSubItems(); + + Timelined timelined = t instanceof Timelined ? (Timelined) t : null; + tti.subNodes = createASTagList(subItems, timelined); + addNode = tti; + //ret.add(tti); + } + } + if (addNode != null) { + if (addNode.getItem() instanceof CharacterIdTag) { + CharacterIdTag cit = (CharacterIdTag) addNode.getItem(); + String path = cit.getExportName(); + if (path == null) { + path = ""; + } + String[] pathParts; + if (path.contains(".")) { + pathParts = path.split("\\."); + } else { + pathParts = new String[]{path}; + } + List items = ret; + int pos = 0; + TreeNode selNode = null; + do { + if (pos == pathParts.length - 1) { + break; + } + selNode = null; + for (TreeNode node : items) { + if (node.getItem() instanceof AS2PackageNodeItem) { + AS2PackageNodeItem pkg = (AS2PackageNodeItem) node.getItem(); + if (pkg.packageName.equals(pathParts[pos])) { + selNode = node; + break; + } + } + } + int pkgCount = 0; + for (; pkgCount < items.size(); pkgCount++) { + if (items.get(pkgCount).getItem() instanceof AS3PackageNodeItem) { + AS2PackageNodeItem pkg = (AS2PackageNodeItem) items.get(pkgCount).getItem(); + if (pkg.packageName.compareTo(pathParts[pos]) > 0) { + break; + } + } else { + break; + } + } + if (selNode == null) { + items.add(pkgCount, selNode = new AS2PackageNode(new AS2PackageNodeItem(pathParts[pos], t.getSwf()))); + } + pos++; + if (selNode != null) { + items = selNode.subNodes; + } + + } while (selNode != null); + + int clsCount = 0; + for (; clsCount < items.size(); clsCount++) { + if (items.get(clsCount).getItem() instanceof CharacterIdTag) { + CharacterIdTag ct = (CharacterIdTag) items.get(clsCount).getItem(); + String expName = ct.getExportName(); + if (expName == null) { + expName = ""; + } + if (expName.contains(".")) { + expName = expName.substring(expName.lastIndexOf('.') + 1); + } + if ((ct.getClass().getName() + "_" + expName).compareTo(addNode.getItem().getClass().getName() + "_" + pathParts[pos]) > 0) { + break; + } + } + } + items.add(clsCount, addNode); + } else { + ret.add(addNode); + } + } + + } + ret.addAll(frames); + for (int i = ret.size() - 1; i >= 0; i--) { + if (ret.get(i).getItem() instanceof DefineSpriteTag) { + ((DefineSpriteTag) ret.get(i).getItem()).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).getItem() instanceof DefineButtonTag) { + ((DefineButtonTag) ret.get(i).getItem()).exportAssetsTags = exportAssetsTags; + } + if (ret.get(i).getItem() instanceof DefineButton2Tag) { + ((DefineButton2Tag) ret.get(i).getItem()).exportAssetsTags = exportAssetsTags; + } + /*if (ret.get(i).tag instanceof DoInitActionTag) { + //((DoInitActionTag) ret.get(i).tag).exportAssetsTags = exportAssetsTags; + }*/ + if (ret.get(i).getItem() instanceof ASMSource) { + ASMSource ass = (ASMSource) ret.get(i).getItem(); + if (ass.containsSource()) { + continue; + } + } + if (ret.get(i).subNodes.isEmpty()) { + ret.remove(i); + } + } + return ret; + } + + public static void getTagsFromTreeNodes(List treeNodes, List result) { + for (TreeNode treeNode : treeNodes) { + TreeItem treeItem = treeNode.getItem(); + if (treeItem instanceof Tag) { + result.add((Tag) treeItem); + } + getTagsFromTreeNodes(treeNode.subNodes, result); + } + } + + private final HashSet listeners = new HashSet<>(); + + public final void addEventListener(EventListener listener) { + listeners.add(listener); + for (Tag t : tags) { + if (t instanceof ABCContainerTag) { + (((ABCContainerTag) t).getABC()).addEventListener(listener); + } + } + } + + public final void removeEventListener(EventListener listener) { + listeners.remove(listener); + for (Tag t : tags) { + if (t instanceof ABCContainerTag) { + (((ABCContainerTag) t).getABC()).removeEventListener(listener); + } + } + } + + protected void informListeners(String event, Object data) { + for (EventListener listener : listeners) { + listener.handleEvent(event, data); + } + } + + 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 populateVideoFrames(int streamId, List tags, HashMap output) { + for (ContainerItem 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(AbortRetryIgnoreHandler handler, String outdir, MovieExportSettings settings) throws IOException { + new MovieExporter().exportMovies(handler, outdir, tags, settings); + } + + public void exportSounds(AbortRetryIgnoreHandler handler, String outdir, SoundExportSettings settings) throws IOException { + new SoundExporter().exportSounds(handler, outdir, tags, settings); + } + + public void exportFonts(AbortRetryIgnoreHandler handler, String outdir, FontExportSettings settings) throws IOException { + new FontExporter().exportFonts(handler, outdir, tags, settings); + } + + private static void writeLE(OutputStream os, long val, int size) throws IOException { + for (int i = 0; i < size; i++) { + os.write((int) (val & 0xff)); + val >>= 8; + } + } + + public static void createWavFromPcmData(OutputStream fos, int soundRateHz, boolean soundSize, boolean soundType, byte[] data) throws IOException { + ByteArrayOutputStream subChunk1Data = new ByteArrayOutputStream(); + int audioFormat = 1; //PCM + writeLE(subChunk1Data, audioFormat, 2); + int numChannels = soundType ? 2 : 1; + writeLE(subChunk1Data, numChannels, 2); + int[] rateMap = {5512, 11025, 22050, 44100}; + int sampleRate = soundRateHz;//rateMap[soundRate]; + writeLE(subChunk1Data, sampleRate, 4); + int bitsPerSample = soundSize ? 16 : 8; + int byteRate = sampleRate * numChannels * bitsPerSample / 8; + writeLE(subChunk1Data, byteRate, 4); + int blockAlign = numChannels * bitsPerSample / 8; + writeLE(subChunk1Data, blockAlign, 2); + writeLE(subChunk1Data, bitsPerSample, 2); + + ByteArrayOutputStream chunks = new ByteArrayOutputStream(); + chunks.write(Utf8Helper.getBytes("fmt ")); + byte[] subChunk1DataBytes = subChunk1Data.toByteArray(); + writeLE(chunks, subChunk1DataBytes.length, 4); + chunks.write(subChunk1DataBytes); + + chunks.write(Utf8Helper.getBytes("data")); + writeLE(chunks, data.length, 4); + chunks.write(data); + + fos.write(Utf8Helper.getBytes("RIFF")); + byte[] chunkBytes = chunks.toByteArray(); + writeLE(fos, 4 + chunkBytes.length, 4); + fos.write(Utf8Helper.getBytes("WAVE")); + fos.write(chunkBytes); + } + + private static void makeAVI(Iterator images, int frameRate, File file) throws IOException { + if (!images.hasNext()) { + return; + } + AVIWriter out = new AVIWriter(file); + BufferedImage img0 = images.next(); + out.addVideoTrack(VideoFormatKeys.ENCODING_AVI_PNG, 1, frameRate, img0.getWidth(), img0.getHeight(), 0, 0); + try { + while (images.hasNext()) { + out.write(0, images.next(), 1); + } + } finally { + out.close(); + } + + } + + private static void makeGIF(Iterator images, int frameRate, File file) throws IOException { + if (!images.hasNext()) { + return; + } + try (ImageOutputStream output = new FileImageOutputStream(file)) { + BufferedImage img0 = images.next(); + GifSequenceWriter writer = new GifSequenceWriter(output, img0.getType(), 1000 / frameRate, true); + writer.writeToSequence(img0); + + while (images.hasNext()) { + writer.writeToSequence(images.next()); + } + + writer.close(); + } + } + + private static String getTypePrefix(CharacterTag c) { + if (c instanceof ShapeTag) { + return "shape"; + } + if (c instanceof MorphShapeTag) { + return "morphshape"; + } + if (c instanceof DefineSpriteTag) { + return "sprite"; + } + if (c instanceof TextTag) { + return "text"; + } + if (c instanceof ButtonTag) { + return "button"; + } + if (c instanceof FontTag) { + return "font"; + } + if (c instanceof ImageTag) { + return "image"; + } + return "character"; + } + + public static void writeLibrary(SWF fswf, Set library, OutputStream fos) throws IOException { + for (int c : library) { + CharacterTag ch = fswf.characters.get(c); + if (ch instanceof FontTag) { + fos.write(Utf8Helper.getBytes("function " + getTypePrefix(ch) + c + "(ctx,ch,textColor){\r\n")); + fos.write(Utf8Helper.getBytes(((FontTag) ch).toHtmlCanvas(1))); + fos.write(Utf8Helper.getBytes("}\r\n\r\n")); + } else { + fos.write(Utf8Helper.getBytes("function " + getTypePrefix(ch) + c + "(ctx,ctrans,frame,ratio,time){\r\n")); + if (ch instanceof ImageTag) { + ImageTag image = (ImageTag) ch; + String format = image.getImageFormat(); + InputStream imageStream = image.getImageData(); + byte[] imageData; + if (imageStream != null) { + imageData = Helper.readStream(image.getImageData()); + } else { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + ImageIO.write(image.getImage().getBufferedImage(), format.toUpperCase(Locale.ENGLISH), baos); + } catch (IOException ex) { + } + imageData = baos.toByteArray(); + } + String base64ImgData = DatatypeConverter.printBase64Binary(imageData); + fos.write(Utf8Helper.getBytes("var imageObj" + c + " = document.createElement(\"img\");\r\nimageObj" + c + ".src=\"data:image/" + format + ";base64," + base64ImgData + "\";\r\n")); + } + if (ch instanceof DrawableTag) { + fos.write(Utf8Helper.getBytes(((DrawableTag) ch).toHtmlCanvas(1))); + } + fos.write(Utf8Helper.getBytes("}\r\n\r\n")); + } + } + } + + public List exportFrames(AbortRetryIgnoreHandler handler, String outdir, int containerId, List frames, final FramesExportSettings settings) throws IOException { + final List ret = new ArrayList<>(); + if (tags.isEmpty()) { + return ret; + } + Timeline tim = null; + String path = ""; + if (containerId == 0) { + tim = getTimeline(); + } else { + tim = ((Timelined) characters.get(containerId)).getTimeline(); + path = File.separator + Helper.makeFileName(characters.get(containerId).getExportFileName()); + } + if (frames == null) { + int frameCnt = tim.frames.size(); + frames = new ArrayList<>(); + for (int i = 0; i < frameCnt; i++) { + frames.add(i); + } + } + + final File foutdir = new File(outdir + path); + if (!foutdir.exists()) { + if (!foutdir.mkdirs()) { + if (!foutdir.exists()) { + throw new IOException("Cannot create directory " + outdir); + } + } + } + + final List fframes = frames; + + Color backgroundColor = null; + if (settings.mode == FramesExportMode.AVI) { + for (Tag t : tags) { + if (t instanceof SetBackgroundColorTag) { + SetBackgroundColorTag sb = (SetBackgroundColorTag) t; + backgroundColor = sb.backgroundColor.toColor(); + } + } + } + + if (settings.mode == FramesExportMode.SVG) { + for (int i = 0; i < frames.size(); i++) { + final int fi = i; + final Timeline ftim = tim; + final Color fbackgroundColor = backgroundColor; + new RetryTask(new RunnableIOEx() { + @Override + public void run() throws IOException { + int frame = fframes.get(fi); + File f = new File(foutdir + File.separator + frame + ".svg"); + try (FileOutputStream fos = new FileOutputStream(f)) { + SVGExporter exporter = new SVGExporter(new ExportRectangle(ftim.displayRect)); + if (fbackgroundColor != null) { + exporter.setBackGroundColor(fbackgroundColor); + } + frameToSvg(ftim, frame, 0, null, 0, exporter, new ColorTransform(), 0); + fos.write(Utf8Helper.getBytes(exporter.getSVG())); + } + ret.add(f); + } + }, handler).run(); + } + return ret; + } + + if (settings.mode == FramesExportMode.CANVAS) { + final Timeline ftim = tim; + final Color fbackgroundColor = backgroundColor; + final SWF fswf = this; + new RetryTask(new RunnableIOEx() { + @Override + public void run() throws IOException { + File fcanvas = new File(foutdir + File.separator + "canvas.js"); + Helper.saveStream(SWF.class.getClassLoader().getResourceAsStream("com/jpexs/helpers/resource/canvas.js"), fcanvas); + ret.add(fcanvas); + + File f = new File(foutdir + File.separator + "frames.js"); + File fmin = new File(foutdir + File.separator + "frames.min.js"); + int width = (int) (ftim.displayRect.getWidth() / SWF.unitDivisor); + int height = (int) (ftim.displayRect.getHeight() / SWF.unitDivisor); + try (FileOutputStream fos = new FileOutputStream(f)) { + fos.write(Utf8Helper.getBytes("\r\n")); + Set library = new HashSet<>(); + ftim.getNeededCharacters(fframes, library); + + writeLibrary(fswf, library, fos); + + String currentName = ftim.id == 0 ? "main" : getTypePrefix(fswf.characters.get(ftim.id)) + ftim.id; + + fos.write(Utf8Helper.getBytes("function " + currentName + "(ctx,ctrans,frame,ratio,time){\r\n")); + fos.write(Utf8Helper.getBytes("\tctx.save();\r\n")); + fos.write(Utf8Helper.getBytes("\tctx.transform(1,0,0,1," + (-ftim.displayRect.Xmin / unitDivisor) + "," + (-ftim.displayRect.Ymin / unitDivisor) + ");\r\n")); + fos.write(Utf8Helper.getBytes(framesToHtmlCanvas(unitDivisor, ftim, fframes, 0, null, 0, ftim.displayRect, new ColorTransform(), fbackgroundColor))); + fos.write(Utf8Helper.getBytes("\tctx.restore();\r\n")); + fos.write(Utf8Helper.getBytes("}\r\n\r\n")); + + fos.write(Utf8Helper.getBytes("var frame = -1;\r\n")); + fos.write(Utf8Helper.getBytes("var time = 0;\r\n")); + fos.write(Utf8Helper.getBytes("var frames = [];\r\n")); + for (int i : fframes) { + fos.write(Utf8Helper.getBytes("frames.push(" + i + ");\r\n")); + } + fos.write(Utf8Helper.getBytes("\r\n")); + RGB backgroundColor = new RGB(255, 255, 255); + for (Tag t : fswf.tags) { + if (t instanceof SetBackgroundColorTag) { + SetBackgroundColorTag sb = (SetBackgroundColorTag) t; + backgroundColor = sb.backgroundColor; + } + } + + fos.write(Utf8Helper.getBytes("var backgroundColor = \"" + backgroundColor.toHexRGB() + "\";\r\n")); + fos.write(Utf8Helper.getBytes("var originalWidth = " + width + ";\r\n")); + fos.write(Utf8Helper.getBytes("var originalHeight= " + height + ";\r\n")); + fos.write(Utf8Helper.getBytes("function nextFrame(ctx,ctrans){\r\n")); + fos.write(Utf8Helper.getBytes("\tvar oldframe = frame;\r\n")); + fos.write(Utf8Helper.getBytes("\tframe = (frame+1)%frames.length;\r\n")); + fos.write(Utf8Helper.getBytes("\tif(frame==oldframe){time++;}else{time=0;};\r\n")); + fos.write(Utf8Helper.getBytes("\tdrawFrame();\r\n")); + fos.write(Utf8Helper.getBytes("}\r\n\r\n")); + + fos.write(Utf8Helper.getBytes("function drawFrame(){\r\n")); + fos.write(Utf8Helper.getBytes("\tctx.fillStyle = backgroundColor;\r\n")); + fos.write(Utf8Helper.getBytes("\tctx.fillRect(0,0,canvas.width,canvas.height);\r\n")); + fos.write(Utf8Helper.getBytes("\tctx.save();\r\n")); + fos.write(Utf8Helper.getBytes("\tctx.transform(canvas.width/originalWidth,0,0,canvas.height/originalHeight,0,0);\r\n")); + fos.write(Utf8Helper.getBytes("\t" + currentName + "(ctx,ctrans,frames[frame],0,time);\r\n")); + fos.write(Utf8Helper.getBytes("\tctx.restore();\r\n")); + fos.write(Utf8Helper.getBytes("}\r\n\r\n")); + fos.write(Utf8Helper.getBytes("window.setInterval(function(){nextFrame(ctx,ctrans);}," + (int) (1000.0 / ftim.swf.frameRate) + ");\r\n")); + } + + if (Configuration.packJavaScripts.get()) { + try { + JPacker.main(new String[]{"-q", "-b", "62", "-o", fmin.getAbsolutePath(), f.getAbsolutePath()}); + f.delete(); + } catch (Exception | Error e) { //Something wrong in the packer + Logger.getLogger(SWF.class.getName()).log(Level.WARNING, "JPacker: Cannot minimize script"); + f.renameTo(fmin); + } + } else { + f.renameTo(fmin); + } + + File fh = new File(foutdir + File.separator + "frames.html"); + try (FileOutputStream fos = new FileOutputStream(fh); FileInputStream fis = new FileInputStream(fmin)) { + fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getHtmlPrefix(width, height))); + fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getJsPrefix())); + byte buf[] = new byte[1000]; + int cnt; + while ((cnt = fis.read(buf)) > 0) { + fos.write(buf, 0, cnt); + } + if (Configuration.packJavaScripts.get()) { + fos.write(Utf8Helper.getBytes(";")); + } + fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getJsSuffix())); + fos.write(Utf8Helper.getBytes(CanvasShapeExporter.getHtmlSuffix())); + } + fmin.delete(); + + ret.add(f); + } + }, handler).run(); + + return ret; + } + + final Timeline ftim = tim; + final Color fbackgroundColor = backgroundColor; + final Iterator frameImages = new Iterator() { + + private int pos = 0; + + @Override + public boolean hasNext() { + return fframes.size() > pos; + } + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + @Override + public BufferedImage next() { + if (!hasNext()) { + return null; + } + return frameToImageGet(ftim, fframes.get(pos++), 0, null, 0, ftim.displayRect, new Matrix(), new ColorTransform(), fbackgroundColor, false).getBufferedImage(); + } + }; + + switch (settings.mode) { + case GIF: + new RetryTask(new RunnableIOEx() { + @Override + public void run() throws IOException { + File f = new File(foutdir + File.separator + "frames.gif"); + makeGIF(frameImages, frameRate, f); + ret.add(f); + } + }, handler).run(); + break; + case PNG: + for (int i = 0; frameImages.hasNext(); i++) { + final int fi = i; + new RetryTask(new RunnableIOEx() { + @Override + public void run() throws IOException { + File f = new File(foutdir + File.separator + (fframes.get(fi)+1) + ".png"); + ImageIO.write(frameImages.next(), "PNG", f); + ret.add(f); + } + }, handler).run(); + } + break; + case PDF: + new RetryTask(new RunnableIOEx() { + @Override + public void run() throws IOException { + File f = new File(foutdir + File.separator + "frames.pdf"); + PDFJob job = new PDFJob(new FileOutputStream(f)); + PageFormat pf = new PageFormat(); + pf.setOrientation(PageFormat.PORTRAIT); + Paper p = new Paper(); + BufferedImage img0 = frameImages.next(); + p.setSize(img0.getWidth() + 10, img0.getHeight() + 10); + pf.setPaper(p); + + for (int i = 0; frameImages.hasNext(); i++) { + BufferedImage img = frameImages.next(); + Graphics g = job.getGraphics(pf); + g.drawImage(img, 5, 5, img.getWidth(), img.getHeight(), null); + g.dispose(); + } + + job.end(); + ret.add(f); + } + }, handler).run(); + break; + case AVI: + new RetryTask(new RunnableIOEx() { + @Override + public void run() throws IOException { + File f = new File(foutdir + File.separator + "frames.avi"); + makeAVI(frameImages, frameRate, f); + ret.add(f); + } + }, handler).run(); + break; + } + + return ret; + } + + public void exportTexts(AbortRetryIgnoreHandler handler, String outdir, TextExportSettings settings) throws IOException { + new TextExporter().exportTexts(handler, outdir, tags, settings); + } + + public void exportImages(AbortRetryIgnoreHandler handler, String outdir, ImageExportSettings settings) throws IOException { + new ImageExporter().exportImages(handler, outdir, tags, settings); + } + + public void exportShapes(AbortRetryIgnoreHandler handler, String outdir, ShapeExportSettings settings) throws IOException { + new ShapeExporter().exportShapes(handler, outdir, tags, settings); + } + + public void exportMorphShapes(AbortRetryIgnoreHandler handler, String outdir, MorphShapeExportSettings settings) throws IOException { + new MorphShapeExporter().exportMorphShapes(handler, outdir, tags, settings); + } + + public void exportBinaryData(AbortRetryIgnoreHandler handler, String outdir, BinaryDataExportSettings settings) throws IOException { + new BinaryDataExporter().exportBinaryData(handler, outdir, tags, settings); + } + + private final HashMap deobfuscated = new HashMap<>(); + private List> allVariableNames = new ArrayList<>(); + private List allFunctions = new ArrayList<>(); + private HashMap allStrings = new HashMap<>(); + private final HashMap usageTypes = new HashMap<>(); + private final ActionDeobfuscation deobfuscation = new ActionDeobfuscation(); + + private static void getVariables(ConstantPool constantPool, BaseLocalData localData, Stack stack, List output, ActionGraphSource code, int ip, List> variables, List functions, HashMap strings, List visited, HashMap usageTypes, String path) throws InterruptedException { + boolean debugMode = false; + while ((ip > -1) && ip < code.size()) { + if (visited.contains(ip)) { + break; + } + GraphSourceItem ins = code.get(ip); + + if (debugMode) { + System.err.println("Visit " + ip + ": ofs" + Helper.formatAddress(((Action) ins).getAddress()) + ":" + ((Action) ins).getASMSource(new ArrayList(), new ArrayList(), new ArrayList(), code.version, ScriptExportMode.PCODE) + " stack:" + Helper.stackToString(stack, LocalData.create(new ConstantPool()))); + } + if (ins.isExit()) { + break; + } + if (ins.isIgnored()) { + ip++; + continue; + } + + String usageType = "name"; + 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)) { + if (stack.isEmpty()) { + break; + } + name = stack.peek(); + } + + if ((ins instanceof ActionGetVariable) || (ins instanceof ActionDefineLocal2)) { + usageType = "variable"; + } + if (ins instanceof ActionGetMember) { + usageType = "member"; + } + if ((ins instanceof ActionNewMethod) || (ins instanceof ActionNewObject)) { + usageType = "class"; + } + if (ins instanceof ActionCallMethod) { + usageType = "function"; //can there be method? + } + if (ins instanceof ActionCallFunction) { + usageType = "function"; + } + + if ((ins instanceof ActionDefineFunction) || (ins instanceof ActionDefineFunction2)) { + functions.add(ins); + } + + if (ins instanceof GraphSourceItemContainer) { + GraphSourceItemContainer cnt = (GraphSourceItemContainer) ins; + List cntSizes = cnt.getContainerSizes(); + long addr = code.pos2adr(ip + 1); + ip = code.adr2pos(addr); + String cntName = cnt.getName(); + for (Long size : cntSizes) { + if (size == 0) { + continue; + } + ip = code.adr2pos(addr); + addr += size; + int nextip = code.adr2pos(addr); + getVariables(variables, functions, strings, usageTypes, new ActionGraphSource(code.getActions().subList(ip, nextip), code.version, new HashMap(), new HashMap(), new HashMap()), 0, path + (cntName == null ? "" : "/" + cntName)); + ip = nextip; + } + List> r = new ArrayList<>(); + r.add(new ArrayList()); + r.add(new ArrayList()); + r.add(new ArrayList()); + try { + ((GraphSourceItemContainer) ins).translateContainer(r, stack, output, new HashMap(), new HashMap(), new HashMap()); + } catch (EmptyStackException ex) { + } + //ip++; + continue; + } + + if ((ins instanceof ActionSetVariable) || (ins instanceof ActionSetMember) || (ins instanceof ActionDefineLocal)) { + if (stack.size() < 2) { + break; + } + name = stack.get(stack.size() - 2); + } + + if ((ins instanceof ActionSetVariable) || (ins instanceof ActionDefineLocal)) { + usageType = "variable"; + } + + if (ins instanceof ActionSetMember) { + usageType = "member"; + } + + if (name instanceof DirectValueActionItem) { + variables.add(new MyEntry<>((DirectValueActionItem) name, constantPool)); + usageTypes.put((DirectValueActionItem) name, usageType); + } + + //for..in return + if (((ins instanceof ActionEquals) || (ins instanceof ActionEquals2)) && (stack.size() == 1) && (stack.peek() instanceof DirectValueActionItem)) { + stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList())); + } + + if (ins instanceof ActionConstantPool) { + constantPool = new ConstantPool(((ActionConstantPool) ins).constantPool); + } + int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC; + + try { + ins.translate(localData, stack, output, staticOperation, path); + } catch (EmptyStackException ex) { + // probably obfucated code, never executed branch + break; + } + if (ins.isExit()) { + break; + } + + if (ins instanceof ActionPush) { + if (!stack.isEmpty()) { + GraphTargetItem top = stack.peek(); + if (top instanceof DirectValueActionItem) { + DirectValueActionItem dvt = (DirectValueActionItem) top; + if ((dvt.value instanceof String) || (dvt.value instanceof ConstantIndex)) { + if (constantPool == null) { + constantPool = new ConstantPool(dvt.constants); + } + strings.put(dvt, constantPool); + } + } + } + } + + if (ins.isBranch() || ins.isJump()) { + if (ins instanceof ActionIf) { + if (stack.isEmpty()) { + break; + } + stack.pop(); + } + visited.add(ip); + List branches = ins.getBranches(code); + for (int b : branches) { + @SuppressWarnings("unchecked") + Stack brStack = (Stack) stack.clone(); + if (b >= 0) { + getVariables(constantPool, localData, brStack, output, code, b, variables, functions, strings, visited, usageTypes, path); + } else { + if (debugMode) { + System.out.println("Negative branch:" + b); + } + } + } + // } + break; + } + ip++; + }; + } + + private static void getVariables(List> variables, List functions, HashMap strings, HashMap usageType, ActionGraphSource code, int addr, String path) throws InterruptedException { + ActionLocalData localData = new ActionLocalData(); + getVariables(null, localData, new Stack(), new ArrayList(), code, code.adr2pos(addr), variables, functions, strings, new ArrayList(), usageType, path); + } + + private List> getVariables(List> variables, List functions, HashMap strings, HashMap usageType, ASMSource src, String path) throws InterruptedException { + List> ret = new ArrayList<>(); + List actions = src.getActions(); + actionsMap.put(src, actions); + getVariables(variables, functions, strings, usageType, new ActionGraphSource(actions, version, new HashMap(), new HashMap(), new HashMap()), 0, path); + return ret; + } + private HashMap> actionsMap = new HashMap<>(); + + private void getVariables(List objs, String path) throws InterruptedException { + List processed = new ArrayList<>(); + for (ContainerItem o : objs) { + if (o instanceof ASMSource) { + String infPath = path + "/" + o.toString(); + int pos = 1; + String infPath2 = infPath; + while (processed.contains(infPath2)) { + pos++; + infPath2 = infPath + "[" + pos + "]"; + } + processed.add(infPath2); + informListeners("getVariables", infPath2); + getVariables(allVariableNames, allFunctions, allStrings, usageTypes, (ASMSource) o, path); + } + if (o instanceof Container) { + getVariables(((Container) o).getSubItems(), path + "/" + o.toString()); + } + } + } + + public int deobfuscateAS3Identifiers(RenameType renameType) { + for (Tag tag : tags) { + if (tag instanceof ABCContainerTag) { + ((ABCContainerTag) tag).getABC().deobfuscateIdentifiers(deobfuscated, renameType, true); + tag.setModified(true); + } + } + for (Tag tag : tags) { + if (tag instanceof ABCContainerTag) { + ((ABCContainerTag) tag).getABC().deobfuscateIdentifiers(deobfuscated, renameType, false); + tag.setModified(true); + } + } + for (Tag tag : tags) { + if (tag instanceof SymbolClassTag) { + SymbolClassTag sc = (SymbolClassTag) tag; + for (int i = 0; i < sc.names.length; i++) { + String newname = deobfuscation.deobfuscateNameWithPackage(sc.names[i], deobfuscated, renameType, deobfuscated); + if (newname != null) { + sc.names[i] = newname; + } + } + sc.setModified(true); + } + } + deobfuscation.deobfuscateInstanceNames(deobfuscated, renameType, tags, new HashMap()); + return deobfuscated.size(); + } + + public int deobfuscateIdentifiers(RenameType renameType) throws InterruptedException { + findFileAttributes(); + if (fileAttributes == null) { + int cnt = 0; + cnt += deobfuscateAS2Identifiers(renameType); + cnt += deobfuscateAS3Identifiers(renameType); + return cnt; + } else { + if (fileAttributes.actionScript3) { + return deobfuscateAS3Identifiers(renameType); + } else { + return deobfuscateAS2Identifiers(renameType); + } + } + } + + public void renameAS2Identifier(String identifier, String newname) throws InterruptedException { + Map selected = new HashMap<>(); + selected.put(identifier, newname); + renameAS2Identifiers(null, selected); + } + + private int deobfuscateAS2Identifiers(RenameType renameType) throws InterruptedException { + return renameAS2Identifiers(renameType, null); + } + + private int renameAS2Identifiers(RenameType renameType, Map selected) throws InterruptedException { + actionsMap = new HashMap<>(); + allFunctions = new ArrayList<>(); + allVariableNames = new ArrayList<>(); + allStrings = new HashMap<>(); + + List objs = new ArrayList<>(); + int ret = 0; + objs.addAll(tags); + getVariables(objs, ""); + informListeners("rename", ""); + int fc = 0; + for (MyEntry it : allVariableNames) { + String name = it.key.toStringNoH(it.value); + deobfuscation.allVariableNamesStr.add(name); + } + + informListeners("rename", "classes"); + int classCount = 0; + for (Tag t : tags) { + if (t instanceof DoInitActionTag) { + classCount++; + } + } + int cnt = 0; + for (Tag t : tags) { + if (t instanceof DoInitActionTag) { + cnt++; + informListeners("rename", "class " + cnt + "/" + classCount); + DoInitActionTag dia = (DoInitActionTag) t; + String exportName = dia.getExportName(); + final String pkgPrefix = "__Packages."; + String[] classNameParts = null; + if ((exportName != null) && exportName.startsWith(pkgPrefix)) { + String className = exportName.substring(pkgPrefix.length()); + if (className.contains(".")) { + classNameParts = className.split("\\."); + } else { + classNameParts = new String[]{className}; + } + } + int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC; + List dec; + try { + dec = Action.actionsToTree(dia.getActions(), version, staticOperation, ""/*FIXME*/); + } catch (EmptyStackException ex) { + continue; + } + GraphTargetItem name = null; + for (GraphTargetItem it : dec) { + if (it instanceof ClassActionItem) { + ClassActionItem cti = (ClassActionItem) it; + List methods = new ArrayList<>(); + methods.addAll(cti.functions); + methods.addAll(cti.staticFunctions); + + for (GraphTargetItem gti : methods) { + if (gti instanceof FunctionActionItem) { + FunctionActionItem fun = (FunctionActionItem) gti; + if (fun.calculatedFunctionName instanceof DirectValueActionItem) { + DirectValueActionItem dvf = (DirectValueActionItem) fun.calculatedFunctionName; + String fname = dvf.toStringNoH(null); + String changed = deobfuscation.deobfuscateName(fname, false, "method", deobfuscated, renameType, selected); + if (changed != null) { + deobfuscated.put(fname, changed); + } + } + } + } + + List vars = new ArrayList<>(); + for (MyEntry item : cti.vars) { + vars.add(item.key); + } + for (MyEntry item : cti.staticVars) { + vars.add(item.key); + } + for (GraphTargetItem gti : vars) { + if (gti instanceof DirectValueActionItem) { + DirectValueActionItem dvf = (DirectValueActionItem) gti; + String vname = dvf.toStringNoH(null); + String changed = deobfuscation.deobfuscateName(vname, false, "attribute", deobfuscated, renameType, selected); + if (changed != null) { + deobfuscated.put(vname, changed); + } + } + } + + name = cti.className; + break; + } + if (it instanceof InterfaceActionItem) { + InterfaceActionItem ift = (InterfaceActionItem) it; + name = ift.name; + } + } + + if (name != null) { + int pos = 0; + while (name instanceof GetMemberActionItem) { + GetMemberActionItem mem = (GetMemberActionItem) name; + GraphTargetItem memberName = mem.memberName; + if (memberName instanceof DirectValueActionItem) { + DirectValueActionItem dvt = (DirectValueActionItem) memberName; + String nameStr = dvt.toStringNoH(null); + if (classNameParts != null) { + if (classNameParts.length - 1 - pos < 0) { + break; + } + } + String changedNameStr = nameStr; + if (classNameParts != null) { + changedNameStr = classNameParts[classNameParts.length - 1 - pos]; + } + String changedNameStr2 = deobfuscation.deobfuscateName(changedNameStr, pos == 0, pos == 0 ? "class" : "package", deobfuscated, renameType, selected); + if (changedNameStr2 != null) { + changedNameStr = changedNameStr2; + } + ret++; + deobfuscated.put(nameStr, changedNameStr); + pos++; + } + name = mem.object; + } + if (name instanceof GetVariableActionItem) { + GetVariableActionItem var = (GetVariableActionItem) name; + if (var.name instanceof DirectValueActionItem) { + DirectValueActionItem dvt = (DirectValueActionItem) var.name; + String nameStr = dvt.toStringNoH(null); + if (classNameParts != null) { + if (classNameParts.length - 1 - pos < 0) { + break; + } + } + String changedNameStr = nameStr; + if (classNameParts != null) { + changedNameStr = classNameParts[classNameParts.length - 1 - pos]; + } + String changedNameStr2 = deobfuscation.deobfuscateName(changedNameStr, pos == 0, pos == 0 ? "class" : "package", deobfuscated, renameType, selected); + if (changedNameStr2 != null) { + changedNameStr = changedNameStr2; + } + ret++; + deobfuscated.put(nameStr, changedNameStr); + pos++; + } + } + } + t.setModified(true); + } + } + + for (GraphSourceItem fun : allFunctions) { + fc++; + informListeners("rename", "function " + fc + "/" + allFunctions.size()); + if (fun instanceof ActionDefineFunction) { + ActionDefineFunction f = (ActionDefineFunction) fun; + if (f.functionName.isEmpty()) { //anonymous function, leave as is + continue; + } + String changed = deobfuscation.deobfuscateName(f.functionName, false, "function", deobfuscated, renameType, selected); + if (changed != null) { + f.replacedFunctionName = changed; + ret++; + } + } + if (fun instanceof ActionDefineFunction2) { + ActionDefineFunction2 f = (ActionDefineFunction2) fun; + if (f.functionName.isEmpty()) { //anonymous function, leave as is + continue; + } + String changed = deobfuscation.deobfuscateName(f.functionName, false, "function", deobfuscated, renameType, selected); + if (changed != null) { + f.replacedFunctionName = changed; + ret++; + } + } + } + + HashSet stringsNoVarH = new HashSet<>(); + List allVariableNamesDv = new ArrayList<>(); + for (MyEntry it : allVariableNames) { + allVariableNamesDv.add(it.key); + } + for (DirectValueActionItem ti : allStrings.keySet()) { + if (!allVariableNamesDv.contains(ti)) { + stringsNoVarH.add(System.identityHashCode(allStrings.get(ti)) + "_" + ti.toStringNoH(allStrings.get(ti))); + } + } + + int vc = 0; + for (MyEntry it : allVariableNames) { + vc++; + String name = it.key.toStringNoH(it.value); + String changed = deobfuscation.deobfuscateName(name, false, usageTypes.get(it.key), deobfuscated, renameType, selected); + if (changed != null) { + boolean addNew = false; + String h = System.identityHashCode(it.key) + "_" + name; + if (stringsNoVarH.contains(h)) { + addNew = true; + } + ActionPush pu = (ActionPush) it.key.src; + if (pu.replacement == null) { + pu.replacement = new ArrayList<>(); + pu.replacement.addAll(pu.values); + } + if (pu.replacement.get(it.key.pos) instanceof ConstantIndex) { + ConstantIndex ci = (ConstantIndex) pu.replacement.get(it.key.pos); + ConstantPool pool = it.value; + if (pool == null) { + continue; + } + if (pool.constants == null) { + continue; + } + if (addNew) { + pool.constants.add(changed); + ci.index = pool.constants.size() - 1; + } else { + pool.constants.set(ci.index, changed); + } + } else { + pu.replacement.set(it.key.pos, changed); + } + ret++; + } + } + for (ASMSource src : actionsMap.keySet()) { + actionsMap.put(src, Action.removeNops(0, actionsMap.get(src), version, ""/*FIXME path*/)); + src.setActions(actionsMap.get(src)); + src.setModified(); + } + deobfuscation.deobfuscateInstanceNames(deobfuscated, renameType, tags, selected); + return ret; + } + + public void exportFla(AbortRetryIgnoreHandler handler, String outfile, String swfName, String generator, String generatorVerName, String generatorVersion, boolean parallel, FLAVersion version) throws IOException { + XFLConverter.convertSWF(handler, this, swfName, outfile, true, generator, generatorVerName, generatorVersion, parallel, version); + } + + public void exportXfl(AbortRetryIgnoreHandler handler, String outfile, String swfName, String generator, String generatorVerName, String generatorVersion, boolean parallel, FLAVersion version) throws IOException { + XFLConverter.convertSWF(handler, this, swfName, outfile, false, generator, generatorVerName, generatorVersion, parallel, version); + } + + public static AffineTransform matrixToTransform(MATRIX mat) { + return new AffineTransform(mat.getScaleXFloat(), mat.getRotateSkew0Float(), + mat.getRotateSkew1Float(), mat.getScaleYFloat(), + mat.translateX, mat.translateY); + } + + private static Cache frameCache = Cache.getInstance(false); + + public static SerializableImage getFromCache(String key) { + if (frameCache.contains(key)) { + return SWF.frameCache.get(key); + } + return null; + } + + public static void putToCache(String key, SerializableImage img) { + if (Configuration.useFrameCache.get()) { + frameCache.put(key, img); + } + } + + public static void clearImageCache() { + frameCache.clear(); + } + + public static RECT fixRect(RECT rect) { + RECT ret = new RECT(); + ret.Xmin = rect.Xmin; + ret.Xmax = rect.Xmax; + ret.Ymin = rect.Ymin; + ret.Ymax = rect.Ymax; + + if (ret.Xmax <= 0) { + ret.Xmax = ret.getWidth(); + ret.Xmin = 0; + } + if (ret.Ymax <= 0) { + ret.Ymax = ret.getHeight(); + ret.Ymin = 0; + } + if (ret.Xmin < 0) { + ret.Xmax += (-ret.Xmin); + ret.Xmin = 0; + } + if (ret.Ymin < 0) { + ret.Ymax += (-ret.Ymin); + ret.Ymin = 0; + } + + if (ret.getWidth() < 1 || ret.getHeight() < 1) { + ret.Xmin = 0; + ret.Ymin = 0; + ret.Xmax = 20; + ret.Ymax = 20; + } + return ret; + } + + private static String jsArrColor(RGB rgb) { + return "[" + rgb.red + "," + rgb.green + "," + rgb.blue + "," + ((rgb instanceof RGBA) ? ((RGBA) rgb).getAlphaFloat() : 1) + "]"; + } + + public static String framesToHtmlCanvas(double unitDivisor, Timeline timeline, List frames, int time, DepthState stateUnderCursor, int mouseButton, RECT displayRect, ColorTransform colorTransform, Color backGroundColor) { + StringBuilder sb = new StringBuilder(); + if (frames == null) { + frames = new ArrayList<>(); + for (int i = 0; i < timeline.getFrameCount(); i++) { + frames.add(i); + } + } + sb.append("\tvar clips = [];\r\n"); + sb.append("\tvar frame_cnt = ").append(timeline.getFrameCount()).append(";\r\n"); + sb.append("\tframe = frame % frame_cnt;\r\n"); + sb.append("\tswitch(frame){\r\n"); + int maxDepth = timeline.getMaxDepth(); + Stack clipDepths = new Stack<>(); + for (int frame = 0; frame < frames.size(); frame++) { + sb.append("\t\tcase ").append(frame).append(":\r\n"); + Frame frameObj = timeline.frames.get(frame); + for (int i = 1; i <= maxDepth + 1; i++) { + while (!clipDepths.isEmpty() && clipDepths.peek() <= i) { + clipDepths.pop(); + sb.append("\t\t\tvar o = clips.pop();\r\n"); + sb.append("\t\t\tctx.globalCompositeOperation = \"destination-in\";\r\n"); + sb.append("\t\t\tctx.setTransform(1,0,0,1,0,0);\r\n"); + sb.append("\t\t\tctx.drawImage(o.clipCanvas,0,0);\r\n"); + sb.append("\t\t\tvar ms=o.ctx._matrices.slice();\r\n"); + sb.append("\t\t\to.ctx.setTransform(1,0,0,1,0,0);\r\n"); + sb.append("\t\t\to.ctx.globalCompositeOperation = \"source-over\";\r\n"); + sb.append("\t\t\to.ctx.drawImage(canvas,0,0);\r\n"); + sb.append("\t\t\to.ctx.applyTransforms(ms);\r\n"); + sb.append("\t\t\tctx = o.ctx;\r\n"); + sb.append("\t\t\tcanvas = o.canvas;\r\n"); + } + if (!frameObj.layers.containsKey(i)) { + continue; + } + DepthState layer = frameObj.layers.get(i); + if (!timeline.swf.characters.containsKey(layer.characterId)) { + continue; + } + if (!layer.isVisible) { + continue; + } + CharacterTag character = timeline.swf.characters.get(layer.characterId); + + if (colorTransform == null) { + colorTransform = new ColorTransform(); + } + Matrix placeMatrix = new Matrix(layer.matrix); + placeMatrix.scaleX /= unitDivisor; + placeMatrix.scaleY /= unitDivisor; + placeMatrix.rotateSkew0 /= unitDivisor; + placeMatrix.rotateSkew1 /= unitDivisor; + placeMatrix.translateX /= unitDivisor; + placeMatrix.translateY /= unitDivisor; + + int f = 0; + String fstr = "0"; + if (character instanceof DefineSpriteTag) { + DefineSpriteTag sp = (DefineSpriteTag) character; + Timeline tim = sp.getTimeline(); + if (tim.getFrameCount() > 0) { + f = layer.time % tim.getFrameCount(); + fstr = "(" + f + "+time)%" + tim.getFrameCount(); + } + } + + if (layer.clipDepth != -1) { + clipDepths.push(layer.clipDepth); + sb.append("\t\t\tclips.push({ctx:ctx,canvas:canvas});\r\n"); + sb.append("\t\t\tvar ccanvas = createCanvas(canvas.width,canvas.height);\r\n"); + sb.append("\t\t\tvar cctx = ccanvas.getContext(\"2d\");\r\n"); + sb.append("\t\t\tenhanceContext(cctx);\r\n"); + sb.append("\t\t\tcctx.applyTransforms(ctx._matrices);\r\n"); + sb.append("\t\t\tcanvas = ccanvas;\r\n"); + sb.append("\t\t\tctx = cctx;\r\n"); + } + + if (layer.filters != null && layer.filters.size() > 0) { + sb.append("\t\t\tvar oldctx = ctx;\r\n"); + sb.append("\t\t\tvar fcanvas = createCanvas(canvas.width,canvas.height);"); + sb.append("\t\t\tvar fctx = fcanvas.getContext(\"2d\");\r\n"); + sb.append("\t\t\tenhanceContext(fctx);\r\n"); + sb.append("\t\t\tfctx.applyTransforms(ctx._matrices);\r\n"); + sb.append("\t\t\tctx = fctx;\r\n"); + } + + ColorTransform ctrans = layer.colorTransForm; + String ctrans_str = "ctrans"; + if (ctrans == null) { + ctrans = new ColorTransform(); + } else { + ctrans_str = "ctrans.merge(new cxform(" + + ctrans.getRedAdd() + "," + ctrans.getGreenAdd() + "," + ctrans.getBlueAdd() + "," + ctrans.getAlphaAdd() + "," + + ctrans.getRedMulti() + "," + ctrans.getGreenMulti() + "," + ctrans.getBlueMulti() + "," + ctrans.getAlphaMulti() + + "))"; + } + sb.append("\t\t\tplace(\"").append(getTypePrefix(character)).append(layer.characterId).append("\",canvas,ctx,[").append(placeMatrix.scaleX).append(",") + .append(placeMatrix.rotateSkew0).append(",") + .append(placeMatrix.rotateSkew1).append(",") + .append(placeMatrix.scaleY).append(",") + .append(placeMatrix.translateX).append(",") + .append(placeMatrix.translateY).append("],").append(ctrans_str).append(",").append("").append(layer.blendMode < 1 ? 1 : layer.blendMode).append(",").append(fstr).append(",").append(layer.ratio < 0 ? 0 : layer.ratio).append(",time").append(");\r\n"); + + if (layer.filters != null && layer.filters.size() > 0) { + for (FILTER filter : layer.filters) { + if (filter instanceof COLORMATRIXFILTER) { + COLORMATRIXFILTER cmf = (COLORMATRIXFILTER) filter; + String mat = "["; + for (int k = 0; k < cmf.matrix.length; k++) { + if (k > 0) { + mat += ","; + } + mat += cmf.matrix[k]; + } + mat += "]"; + sb.append("\t\t\tfcanvas = Filters.colorMatrix(fcanvas,fcanvas.getContext(\"2d\"),").append(mat).append(");\r\n"); + } + + if (filter instanceof CONVOLUTIONFILTER) { + CONVOLUTIONFILTER cf = (CONVOLUTIONFILTER) filter; + int height = cf.matrix.length; + int width = cf.matrix[0].length; + float[] matrix2 = new float[width * height]; + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + matrix2[y * width + x] = cf.matrix[x][y] * cf.divisor + cf.bias; + } + } + String mat = "["; + for (int k = 0; k < matrix2.length; k++) { + if (k > 0) { + mat += ","; + } + mat += matrix2[k]; + } + mat += "]"; + sb.append("\t\t\tfcanvas = Filters.convolution(fcanvas,fcanvas.getContext(\"2d\"),").append(mat).append(",false);\r\n"); + } + + if (filter instanceof GLOWFILTER) { + GLOWFILTER gf = (GLOWFILTER) filter; + sb.append("\t\t\tfcanvas = Filters.glow(fcanvas,fcanvas.getContext(\"2d\"),").append(gf.blurX).append(",").append(gf.blurY).append(",").append(gf.strength).append(",").append(jsArrColor(gf.glowColor)).append(",").append(gf.innerGlow ? "true" : "false").append(",").append(gf.knockout ? "true" : "false").append(",").append(gf.passes).append(");\r\n"); + } + + if (filter instanceof DROPSHADOWFILTER) { + DROPSHADOWFILTER ds = (DROPSHADOWFILTER) filter; + sb.append("\t\t\tfcanvas = Filters.dropShadow(fcanvas,fcanvas.getContext(\"2d\"),").append(ds.blurX).append(",").append(ds.blurY).append(",").append((int) (ds.angle * 180 / Math.PI)).append(",").append(ds.distance).append(",").append(jsArrColor(ds.dropShadowColor)).append(",").append(ds.innerShadow ? "true" : "false").append(",").append(ds.passes).append(",").append(ds.strength).append(",").append(ds.knockout ? "true" : "false").append(");\r\n"); + } + if (filter instanceof BEVELFILTER) { + BEVELFILTER bv = (BEVELFILTER) filter; + String type = "Filters.INNER"; + if (bv.onTop && !bv.innerShadow) { + type = "Filters.FULL"; + } else if (!bv.innerShadow) { + type = "Filters.OUTER"; + } + sb.append("\t\t\tfcanvas = Filters.bevel(fcanvas,fcanvas.getContext(\"2d\"),").append(bv.blurX).append(",").append(bv.blurY).append(",").append(bv.strength).append(",").append(type).append(",").append(jsArrColor(bv.highlightColor)).append(",").append(jsArrColor(bv.shadowColor)).append(",").append((int) (bv.angle * 180 / Math.PI)).append(",").append(bv.distance).append(",").append(bv.knockout ? "true" : "false").append(",").append(bv.passes).append(");\r\n"); + } + + if (filter instanceof GRADIENTBEVELFILTER) { + GRADIENTBEVELFILTER gbf = (GRADIENTBEVELFILTER) filter; + String colArr = "["; + String ratArr = "["; + for (int k = 0; k < gbf.gradientColors.length; k++) { + if (k > 0) { + colArr += ","; + ratArr += ","; + } + colArr += jsArrColor(gbf.gradientColors[k]); + ratArr += gbf.gradientRatio[k] / 255f; + } + colArr += "]"; + ratArr += "]"; + String type = "Filters.INNER"; + if (gbf.onTop && !gbf.innerShadow) { + type = "Filters.FULL"; + } else if (!gbf.innerShadow) { + type = "Filters.OUTER"; + } + + sb.append("\t\t\tfcanvas = Filters.gradientBevel(fcanvas,fcanvas.getContext(\"2d\"),").append(colArr).append(",").append(ratArr).append(",").append(gbf.blurX).append(",").append(gbf.blurY).append(",").append(gbf.strength).append(",").append(type).append(",").append((int) (gbf.angle * 180 / Math.PI)).append(",").append(gbf.distance).append(",").append(gbf.knockout ? "true" : "false").append(",").append(gbf.passes).append(");\r\n"); + } + + if (filter instanceof GRADIENTGLOWFILTER) { + GRADIENTGLOWFILTER ggf = (GRADIENTGLOWFILTER) filter; + String colArr = "["; + String ratArr = "["; + for (int k = 0; k < ggf.gradientColors.length; k++) { + if (k > 0) { + colArr += ","; + ratArr += ","; + } + colArr += jsArrColor(ggf.gradientColors[k]); + ratArr += ggf.gradientRatio[k] / 255f; + } + colArr += "]"; + ratArr += "]"; + String type = "Filters.INNER"; + if (ggf.onTop && !ggf.innerShadow) { + type = "Filters.FULL"; + } else if (!ggf.innerShadow) { + type = "Filters.OUTER"; + } + + sb.append("\t\t\tfcanvas = Filters.gradientGlow(fcanvas,fcanvas.getContext(\"2d\"),").append(ggf.blurX).append(",").append(ggf.blurY).append(",").append((int) (ggf.angle * 180 / Math.PI)).append(",").append(ggf.distance).append(",").append(colArr).append(",").append(ratArr).append(",").append(type).append(",").append(ggf.passes).append(",").append(ggf.strength).append(",").append(ggf.knockout ? "true" : "false").append(");\r\n"); + } + } + sb.append("\t\t\tctx = oldctx;\r\n"); + sb.append("\t\t\tvar ms=ctx._matrices;\r\n"); + sb.append("\t\t\tctx.setTransform(1,0,0,1,0,0);\r\n"); + sb.append("\t\t\tctx.drawImage(fcanvas,0,0);\r\n"); + sb.append("\t\t\tctx.applyTransforms(ms);\r\n"); + } + + if (layer.clipDepth != -1) { + sb.append("\t\t\tclips[clips.length-1].clipCanvas = canvas;\r\n"); + sb.append("\t\t\tcanvas = createCanvas(canvas.width,canvas.height);\r\n"); + sb.append("\t\t\tvar nctx = canvas.getContext(\"2d\");\r\n"); + sb.append("\t\t\tenhanceContext(nctx);\r\n"); + sb.append("\t\t\tnctx.applyTransforms(ctx._matrices);\r\n"); + sb.append("\t\t\tctx = nctx;\r\n"); + } + } + sb.append("\t\t\tbreak;\r\n"); + } + sb.append("\t}\r\n"); + return sb.toString(); + } + + public static void frameToSvg(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, SVGExporter exporter, ColorTransform colorTransform, int level) throws IOException { + if (timeline.frames.size() <= frame) { + return; + } + Frame frameObj = timeline.frames.get(frame); + List clips = new ArrayList<>(); + List prevClips = new ArrayList<>(); + + int maxDepth = timeline.getMaxDepth(); + for (int i = 1; i <= maxDepth; i++) { + for (int c = 0; c < clips.size(); c++) { + if (clips.get(c).depth == i) { + exporter.setClip(prevClips.get(c)); + prevClips.remove(c); + clips.remove(c); + } + } + if (!frameObj.layers.containsKey(i)) { + continue; + } + DepthState layer = frameObj.layers.get(i); + if (!timeline.swf.characters.containsKey(layer.characterId)) { + continue; + } + if (!layer.isVisible) { + continue; + } + CharacterTag character = timeline.swf.characters.get(layer.characterId); + + if (colorTransform == null) { + colorTransform = new ColorTransform(); + } + + ColorTransform clrTrans = Helper.deepCopy(colorTransform); + if (layer.colorTransForm != null && layer.blendMode <= 1) { //Normal blend mode + clrTrans = colorTransform.merge(layer.colorTransForm); + } + + if (character instanceof DrawableTag) { + DrawableTag drawable = (DrawableTag) character; + + String assetName; + Tag drawableTag = (Tag) drawable; + if (exporter.exportedTags.containsKey(drawableTag)) { + assetName = exporter.exportedTags.get(drawableTag); + } else { + assetName = getTagIdPrefix(drawableTag, exporter); + exporter.exportedTags.put(drawableTag, assetName); + exporter.createDefGroup(new ExportRectangle(drawable.getRect()), assetName); + drawable.toSVG(exporter, layer.ratio, clrTrans, level + 1); + exporter.endGroup(); + } + RECT boundRect = drawable.getRect(); + ExportRectangle rect = new ExportRectangle(boundRect); + + // TODO: if (layer.filters != null) + // TODO: if (layer.blendMode > 1) + if (layer.clipDepth > -1) { + String clipName = exporter.getUniqueId("clipPath"); + exporter.createClipPath(new Matrix(), clipName); + SvgClip clip = new SvgClip(clipName, layer.clipDepth); + clips.add(clip); + prevClips.add(exporter.getClip()); + Matrix mat = Matrix.getTranslateInstance(rect.xMin, rect.yMin).preConcatenate(new Matrix(layer.matrix)); + exporter.addUse(mat, boundRect, assetName); + exporter.setClip(clip.shape); + exporter.endGroup(); + } else { + Matrix mat = Matrix.getTranslateInstance(rect.xMin, rect.yMin).preConcatenate(new Matrix(layer.matrix)); + exporter.addUse(mat, boundRect, assetName); + } + } + } + } + + private static String getTagIdPrefix(Tag tag, SVGExporter exporter) { + if (tag instanceof ShapeTag) { + return exporter.getUniqueId("shape"); + } + if (tag instanceof MorphShapeTag) { + return exporter.getUniqueId("morphshape"); + } + if (tag instanceof DefineSpriteTag) { + return exporter.getUniqueId("sprite"); + } + if (tag instanceof TextTag) { + return exporter.getUniqueId("text"); + } + if (tag instanceof ButtonTag) { + return exporter.getUniqueId("button"); + } + return exporter.getUniqueId("tag"); + } + + public static SerializableImage frameToImageGet(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, RECT displayRect, Matrix transformation, ColorTransform colorTransform, Color backGroundColor, boolean useCache) { + String key = "frame_" + frame + "_" + timeline.id + "_" + timeline.swf.hashCode(); + SerializableImage image; + if (useCache) { + image = getFromCache(key); + if (image != null) { + return image; + } + } + + if (timeline.frames.isEmpty()) { + return new SerializableImage(1, 1, SerializableImage.TYPE_INT_ARGB); + } + + RECT rect = displayRect; + image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1, + (int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB); + if (backGroundColor == null) { + image.fillTransparent(); + } else { + Graphics2D g = (Graphics2D) image.getBufferedImage().getGraphics(); + g.setComposite(AlphaComposite.Src); + g.setColor(backGroundColor); + g.fill(new Rectangle(image.getWidth(), image.getHeight())); + } + Matrix m = transformation.clone(); + m.translate(-rect.Xmin, -rect.Ymin); + frameToImage(timeline, frame, time, stateUnderCursor, mouseButton, image, m, colorTransform); + putToCache(key, image); + return image; + } + + public static void framesToImage(Timeline timeline, List ret, int startFrame, int stopFrame, DepthState stateUnderCursor, int mouseButton, RECT displayRect, int totalFrameCount, Stack visited, Matrix transformation, ColorTransform colorTransform) { + RECT rect = displayRect; + for (int f = 0; f < timeline.frames.size(); f++) { + SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1, + (int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB); + image.fillTransparent(); + Matrix m = new Matrix(); + m.translate(-rect.Xmin, -rect.Ymin); + frameToImage(timeline, f, 0, stateUnderCursor, mouseButton, image, m, colorTransform); + ret.add(image); + } + } + + public static void frameToImage(Timeline timeline, int frame, int time, DepthState stateUnderCursor, int mouseButton, SerializableImage image, Matrix transformation, ColorTransform colorTransform) { + float unzoom = (float) SWF.unitDivisor; + if (timeline.frames.size() <= frame) { + return; + } + Frame frameObj = timeline.frames.get(frame); + Graphics2D g = (Graphics2D) image.getGraphics(); + g.setPaint(frameObj.backgroundColor.toColor()); + g.fill(new Rectangle(image.getWidth(), image.getHeight())); + g.setTransform(transformation.toTransform()); + List clips = new ArrayList<>(); + List prevClips = new ArrayList<>(); + + int maxDepth = timeline.getMaxDepth(); + for (int i = 1; i <= maxDepth; i++) { + for (int c = 0; c < clips.size(); c++) { + if (clips.get(c).depth == i) { + g.setClip(prevClips.get(c)); + prevClips.remove(c); + clips.remove(c); + } + } + if (!frameObj.layers.containsKey(i)) { + continue; + } + DepthState layer = frameObj.layers.get(i); + if (!timeline.swf.characters.containsKey(layer.characterId)) { + continue; + } + if (!layer.isVisible) { + continue; + } + CharacterTag character = timeline.swf.characters.get(layer.characterId); + Matrix mat = new Matrix(layer.matrix); + mat = mat.preConcatenate(transformation); + + if (colorTransform == null) { + colorTransform = new ColorTransform(); + } + + ColorTransform clrTrans = Helper.deepCopy(colorTransform); + if (layer.colorTransForm != null && layer.blendMode <= 1) { //Normal blend mode + clrTrans = colorTransform.merge(layer.colorTransForm); + } + + boolean showPlaceholder = false; + if (character instanceof DrawableTag) { + DrawableTag drawable = (DrawableTag) character; + SerializableImage img; + Matrix drawMatrix = new Matrix(); + int drawableFrameCount = drawable.getNumFrames(); + if (drawableFrameCount == 0) { + drawableFrameCount = 1; + } + int dframe = (time + layer.time) % drawableFrameCount; + if (character instanceof ButtonTag) { + ButtonTag bt = (ButtonTag) character; + dframe = ButtonTag.FRAME_UP; + if (stateUnderCursor == layer) { + if (mouseButton > 0) { + dframe = ButtonTag.FRAME_DOWN; + } else { + dframe = ButtonTag.FRAME_OVER; + } + } + } + + RECT boundRect = drawable.getRect(); + ExportRectangle rect = new ExportRectangle(boundRect); + rect = mat.transform(rect); + Matrix m = mat.clone(); + if (layer.filters != null && layer.filters.size() > 0) { + // calculate size after applying the filters + double deltaXMax = 0; + double deltaYMax = 0; + for (FILTER filter : layer.filters) { + double x = filter.getDeltaX(); + double y = filter.getDeltaY(); + deltaXMax = Math.max(x, deltaXMax); + deltaYMax = Math.max(y, deltaYMax); + } + rect.xMin -= deltaXMax * SWF.unitDivisor; + rect.xMax += deltaXMax * SWF.unitDivisor; + rect.yMin -= deltaYMax * SWF.unitDivisor; + rect.yMax += deltaYMax * SWF.unitDivisor; + } + + rect.xMin -= SWF.unitDivisor; + rect.yMin -= SWF.unitDivisor; + rect.xMin = Math.max(0, rect.xMin); + rect.yMin = Math.max(0, rect.yMin); + + int newWidth = (int) (rect.getWidth() / SWF.unitDivisor); + int newHeight = (int) (rect.getHeight() / SWF.unitDivisor); + int deltaX = (int) (rect.xMin / SWF.unitDivisor); + int deltaY = (int) (rect.yMin / SWF.unitDivisor); + newWidth = Math.min(image.getWidth() - deltaX, newWidth) + 1; + newHeight = Math.min(image.getHeight() - deltaY, newHeight) + 1; + + if (newWidth <= 0 || newHeight <= 0) { + continue; + } + + img = new SerializableImage(newWidth, newHeight, SerializableImage.TYPE_INT_ARGB); + img.fillTransparent(); + + m.translate(-rect.xMin, -rect.yMin); + drawMatrix.translate(rect.xMin, rect.yMin); + + drawable.toImage(dframe, layer.time + time, layer.ratio, stateUnderCursor, mouseButton, img, m, clrTrans); + //if(stateUnderCursor == layer){ + /* if(true){ + Graphics2D gg = (Graphics2D)img.getGraphics(); + gg.setStroke(new BasicStroke(3)); + gg.setPaint(Color.red); + gg.setTransform(AffineTransform.getTranslateInstance(0, 0)); + gg.draw(SHAPERECORD.twipToPixelShape(drawable.getOutline(frame, layer.ratio, stateUnderCursor, mouseButton, m))); + }*/ + + if (layer.filters != null) { + for (FILTER filter : layer.filters) { + img = filter.apply(img); + } + } + if (layer.blendMode > 1) { + if (layer.colorTransForm != null) { + img = layer.colorTransForm.apply(img); + } + } + + drawMatrix.translateX /= unzoom; + drawMatrix.translateY /= unzoom; + AffineTransform trans = drawMatrix.toTransform(); + + switch (layer.blendMode) { + case 0: + case 1: + g.setComposite(AlphaComposite.SrcOver); + break; + case 2://Layer + g.setComposite(AlphaComposite.SrcOver); + break; + case 3: + g.setComposite(BlendComposite.Multiply); + break; + case 4: + g.setComposite(BlendComposite.Screen); + break; + case 5: + g.setComposite(BlendComposite.Lighten); + break; + case 6: + g.setComposite(BlendComposite.Darken); + break; + case 7: + g.setComposite(BlendComposite.Difference); + break; + case 8: + g.setComposite(BlendComposite.Add); + break; + case 9: + g.setComposite(BlendComposite.Subtract); + break; + case 10: + g.setComposite(BlendComposite.Invert); + break; + case 11: + g.setComposite(BlendComposite.Alpha); + break; + case 12: + g.setComposite(BlendComposite.Erase); + break; + case 13: + g.setComposite(BlendComposite.Overlay); + break; + case 14: + g.setComposite(BlendComposite.HardLight); + break; + default: //Not implemented + g.setComposite(AlphaComposite.SrcOver); + break; + } + + if (layer.clipDepth > -1) { + BufferedImage mask = new BufferedImage(image.getWidth(), image.getHeight(), image.getType()); + Graphics2D gm = (Graphics2D) mask.getGraphics(); + gm.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + gm.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + gm.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + gm.setComposite(AlphaComposite.Src); + gm.setColor(new Color(0, 0, 0, 0f)); + gm.fillRect(0, 0, image.getWidth(), image.getHeight()); + gm.setTransform(trans); + gm.drawImage(img.getBufferedImage(), 0, 0, null); + Clip clip = new Clip(Helper.imageToShape(mask), layer.clipDepth); //Maybe we can get current outline instead converting from image (?) + clips.add(clip); + prevClips.add(g.getClip()); + g.setTransform(AffineTransform.getTranslateInstance(0, 0)); + g.setClip(clip.shape); + } else { + g.setTransform(trans); + g.drawImage(img.getBufferedImage(), 0, 0, null); + } + } else if (character instanceof BoundedTag) { + showPlaceholder = true; + } + + if (showPlaceholder) { + mat.translateX /= unzoom; + mat.translateY /= unzoom; + AffineTransform trans = mat.toTransform(); + g.setTransform(trans); + BoundedTag b = (BoundedTag) character; + g.setPaint(new Color(255, 255, 255, 128)); + g.setComposite(BlendComposite.Invert); + RECT r = b.getRect(); + int div = (int) unzoom; + g.drawString(character.toString(), r.Xmin / div + 3, r.Ymin / div + 15); + g.draw(new Rectangle(r.Xmin / div, r.Ymin / div, r.getWidth() / div, r.getHeight() / div)); + g.drawLine(r.Xmin / div, r.Ymin / div, r.Xmax / div, r.Ymax / div); + g.drawLine(r.Xmax / div, r.Ymin / div, r.Xmin / div, r.Ymax / div); + g.setComposite(AlphaComposite.Dst); + } + } + + g.setTransform(AffineTransform.getScaleInstance(1, 1)); + } + + private void removeTagWithDependenciesFromTimeline(Tag toRemove, Timeline timeline) { + int characterId = 0; + if (toRemove instanceof CharacterTag) { + characterId = ((CharacterTag) toRemove).getCharacterId(); + } + Map stage = new HashMap<>(); + + Set dependingChars = new HashSet<>(); + if (characterId != 0) { + dependingChars.add(characterId); + for (int i = 0; i < timeline.tags.size(); i++) { + Tag t = timeline.tags.get(i); + if (t instanceof CharacterIdTag) { + CharacterIdTag c = (CharacterIdTag) t; + Set needed = new HashSet<>(); + t.getNeededCharacters(needed); + if (needed.contains(characterId)) { + dependingChars.add(c.getCharacterId()); + } + } + } + } + + for (int i = 0; i < timeline.tags.size(); i++) { + Tag t = timeline.tags.get(i); + if (t instanceof RemoveTag) { + RemoveTag rt = (RemoveTag) t; + int depth = rt.getDepth(); + if (stage.containsKey(depth)) { + int currentCharId = stage.get(depth); + stage.remove(depth); + if (dependingChars.contains(currentCharId)) { + timeline.tags.remove(i); + i--; + continue; + } + } + } + if (t instanceof PlaceObjectTypeTag) { + PlaceObjectTypeTag po = (PlaceObjectTypeTag) t; + int placeCharId = po.getCharacterId(); + int depth = po.getDepth(); + if (placeCharId != 0) { + stage.put(depth, placeCharId); + if (dependingChars.contains(placeCharId)) { + timeline.tags.remove(i); + i--; + continue; + } + } + } + if (t instanceof CharacterIdTag) { + CharacterIdTag c = (CharacterIdTag) t; + if (dependingChars.contains(c.getCharacterId())) { + timeline.tags.remove(i); + i--; + continue; + } + } + Set needed = new HashSet<>(); + t.getNeededCharacters(needed); + for (int dep : dependingChars) { + if (needed.contains(dep)) { + timeline.tags.remove(i); + i--; + continue; + } + } + if (t == toRemove) { + timeline.tags.remove(i); + i--; + continue; + } + if (t instanceof Timelined) { + removeTagWithDependenciesFromTimeline(toRemove, ((Timelined) t).getTimeline()); + } + } + } + + private boolean removeTagFromTimeline(Tag toRemove, Timeline timeline) { + boolean modified = false; + int characterId = -1; + if (toRemove instanceof CharacterTag) { + characterId = ((CharacterTag) toRemove).getCharacterId(); + modified = timeline.removeCharacter(characterId); + } + for (int i = 0; i < timeline.tags.size(); i++) { + Tag t = timeline.tags.get(i); + if (t == toRemove) { + timeline.tags.remove(t); + i--; + continue; + } + + if (toRemove instanceof CharacterTag) { + if (t.removeCharacter(characterId)) { + modified = true; + i = -1; + continue; + } + } + + if (t instanceof DefineSpriteTag) { + DefineSpriteTag spr = (DefineSpriteTag) t; + boolean sprModified = removeTagFromTimeline(toRemove, spr.getTimeline()); + if (sprModified) { + spr.setModified(true); + } + modified |= sprModified; + } + } + return modified; + } + + public void removeTag(Tag t, boolean removeDependencies) { + Timelined timelined = t.getTimelined(); + if (t instanceof ShowFrameTag || ShowFrameTag.isNestedTagType(t.getId())) { + List tags; + if (timelined instanceof DefineSpriteTag) { + tags = ((DefineSpriteTag) timelined).getSubTags(); + } else { + tags = this.tags; + } + tags.remove(t); + timelined.resetTimeline(); + } else { + // timeline should be always the swf here + if (removeDependencies) { + removeTagWithDependenciesFromTimeline(t, timelined.getTimeline()); + } else { + removeTagFromTimeline(t, timeline); + } + } + resetTimelines(timelined); + updateCharacters(); + clearImageCache(); + } +} diff --git a/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java b/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java index e51caaa0d..d33aa8070 100644 --- a/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java +++ b/src/com/jpexs/decompiler/flash/SourceGeneratorLocalData.java @@ -39,7 +39,7 @@ public class SourceGeneratorLocalData implements Serializable { //TODO: handle AVM2 separately public List exceptions = new ArrayList<>(); - public List finallyCatches = new ArrayList(); + public List finallyCatches = new ArrayList<>(); public Map finallyCounter = new HashMap<>(); public int finallyRegister = -1; public String currentClass; @@ -47,7 +47,7 @@ public class SourceGeneratorLocalData implements Serializable { public List callStack = new ArrayList<>(); public Map> traitUsages = new HashMap<>(); public String pkg = ""; - public List scopeStack = new ArrayList(); + public List scopeStack = new ArrayList<>(); public boolean documentClass; public ScriptInfo currentScript; diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index adbce977e..97698b00e 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -1249,7 +1249,7 @@ public class AVM2Code implements Serializable { return pos2adr(fixIPAfterDebugLine(adr2pos(addr))); } - public ConvertOutput toSourceOutput(String path, GraphPart part, boolean processJumps, boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ABC abc, ConstantPool constants, List method_info, MethodBody body, int start, int end, HashMap localRegNames, List fullyQualifiedNames, boolean[] visited, HashMap localRegAssigmentIps, HashMap> refs) throws ConvertException, InterruptedException { + public ConvertOutput toSourceOutput(String path, GraphPart part, boolean processJumps, boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ABC abc, ConstantPool constants, List method_info, MethodBody body, int start, int end, HashMap localRegNames, List fullyQualifiedNames, boolean[] visited, HashMap localRegAssigmentIps, HashMap> refs) throws ConvertException, InterruptedException { boolean debugMode = DEBUG_MODE; if (debugMode) { System.out.println("OPEN SubSource:" + start + "-" + end + " " + code.get(start).toString() + " to " + code.get(end).toString()); @@ -2699,7 +2699,7 @@ public class AVM2Code implements Serializable { }*/ } - if (((AVM2Instruction) ins).definition instanceof NewFunctionIns) { + if (ins.definition instanceof NewFunctionIns) { stack.push(new BooleanAVM2Item(null, true)); } else { localData.ip = ip; @@ -2724,8 +2724,8 @@ public class AVM2Code implements Serializable { if (ins.isBranch() || ins.isJump()) { List branches = ins.getBranches(code); - if (((AVM2Instruction) ins).definition instanceof IfTypeIns - && (!(((AVM2Instruction) ins).definition instanceof JumpIns)) + if (ins.definition instanceof IfTypeIns + && (!(ins.definition instanceof JumpIns)) && (!stack.isEmpty()) && (stack.peek().isCompileTime()) && (!stack.peek().hasSideEffect())) { @@ -2858,11 +2858,10 @@ public class AVM2Code implements Serializable { for (AVM2Instruction src : decisions.keySet()) { Decision dec = decisions.get(src); if (dec != null) { - if (((AVM2Instruction) src).definition instanceof LookupSwitchIns) { - AVM2Instruction asrc = (AVM2Instruction) src; + if (src.definition instanceof LookupSwitchIns) { if (dec.casesUsed.size() == 1) { for (int c : dec.casesUsed) { - asrc.setFixBranch(c); + src.setFixBranch(c); cnt++; } } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/IfTypeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/IfTypeIns.java index e1cfdadee..bb5ac1899 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/IfTypeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/IfTypeIns.java @@ -1,25 +1,26 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions; - -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.Stack; - -public interface IfTypeIns { - - public abstract void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins); -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions; + +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.Stack; + +public interface IfTypeIns { + + public abstract void translateInverted(HashMap localRegs, Stack stack, AVM2Instruction ins); +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java index 6e7af9c88..c5e68a5fb 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java @@ -1,165 +1,165 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.DecLocalIIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.DecLocalIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.IncLocalIIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.IncLocalIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocalTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.flash.helpers.GraphTextWriter; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.io.Serializable; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.Stack; - -public class InstructionDefinition implements Serializable { - - public static final long serialVersionUID = 1L; - - 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; - } - - @Override - public String toString() { - StringBuilder s = new StringBuilder(); - s.append(instructionName); - for (int i = 0; i < operands.length; i++) { - if ((operands[i] & 0xff00) == AVM2Code.OPT_U30) { - s.append(" U30"); - } - if ((operands[i] & 0xff00) == AVM2Code.OPT_U8) { - s.append(" U8"); - } - if ((operands[i] & 0xff00) == AVM2Code.OPT_BYTE) { - s.append(" BYTE"); - } - if ((operands[i] & 0xff00) == AVM2Code.OPT_S24) { - s.append(" S24"); - } - if ((operands[i] & 0xff00) == AVM2Code.OPT_CASE_OFFSETS) { - s.append(" U30 S24,[S24]..."); - } - } - return s.toString(); - } - - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - throw new UnsupportedOperationException("Instruction " + instructionName + " not implemented"); - } - - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { - } - - protected FullMultinameAVM2Item resolveMultiname(Stack stack, ConstantPool constants, int multinameIndex, AVM2Instruction ins) { - GraphTargetItem ns = null; - GraphTargetItem name = null; - if (constants.getMultiname(multinameIndex).needsName()) { - name = (GraphTargetItem) stack.pop(); - } - if (constants.getMultiname(multinameIndex).needsNs()) { - ns = (GraphTargetItem) stack.pop(); - } - return new FullMultinameAVM2Item(ins, multinameIndex, name, ns); - } - - protected int resolvedCount(ConstantPool constants, int multinameIndex) { - int pos = 0; - if (constants.getMultiname(multinameIndex).needsNs()) { - pos++; - } - if (constants.getMultiname(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.getMultiname(multinameIndex).needsNs()) { - ns = "[" + stack.get(pos) + "]"; - pos++; - } - if (constants.getMultiname(multinameIndex).needsName()) { - name = stack.get(pos).toString(); - } else { - name = GraphTextWriter.hilighOffset(constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames), ins.offset); - } - return name + ns; - } - - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 0; - } - - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 0; - } - - protected boolean isRegisterCompileTime(int regId, int ip, HashMap> refs, AVM2Code code) { - Set previous = new HashSet<>(); - AVM2Code.getPreviousReachableIps(ip, refs, previous, new HashSet()); - for (int p : previous) { - if (p < 0) { - continue; - } - if (p >= code.code.size()) { - continue; - } - AVM2Instruction sins = code.code.get(p); - if (code.code.get(p).definition instanceof SetLocalTypeIns) { - SetLocalTypeIns sl = (SetLocalTypeIns) sins.definition; - if (sl.getRegisterId(sins) == regId) { - if (!AVM2Code.isDirectAncestor(ip, p, refs)) { - return false; - } - } - } - if ((code.code.get(p).definition instanceof IncLocalIns) - || (code.code.get(p).definition instanceof IncLocalIIns) - || (code.code.get(p).definition instanceof DecLocalIns) - || (code.code.get(p).definition instanceof DecLocalIIns)) { - if (sins.operands[0] == regId) { - if (!AVM2Code.isDirectAncestor(ip, p, refs)) { - return false; - } - } - } - } - return true; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.DecLocalIIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.DecLocalIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.IncLocalIIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.IncLocalIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.SetLocalTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.io.Serializable; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.Stack; + +public class InstructionDefinition implements Serializable { + + public static final long serialVersionUID = 1L; + + 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; + } + + @Override + public String toString() { + StringBuilder s = new StringBuilder(); + s.append(instructionName); + for (int i = 0; i < operands.length; i++) { + if ((operands[i] & 0xff00) == AVM2Code.OPT_U30) { + s.append(" U30"); + } + if ((operands[i] & 0xff00) == AVM2Code.OPT_U8) { + s.append(" U8"); + } + if ((operands[i] & 0xff00) == AVM2Code.OPT_BYTE) { + s.append(" BYTE"); + } + if ((operands[i] & 0xff00) == AVM2Code.OPT_S24) { + s.append(" S24"); + } + if ((operands[i] & 0xff00) == AVM2Code.OPT_CASE_OFFSETS) { + s.append(" U30 S24,[S24]..."); + } + } + return s.toString(); + } + + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + throw new UnsupportedOperationException("Instruction " + instructionName + " not implemented"); + } + + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { + } + + protected FullMultinameAVM2Item resolveMultiname(Stack stack, ConstantPool constants, int multinameIndex, AVM2Instruction ins) { + GraphTargetItem ns = null; + GraphTargetItem name = null; + if (constants.getMultiname(multinameIndex).needsName()) { + name = stack.pop(); + } + if (constants.getMultiname(multinameIndex).needsNs()) { + ns = stack.pop(); + } + return new FullMultinameAVM2Item(ins, multinameIndex, name, ns); + } + + protected int resolvedCount(ConstantPool constants, int multinameIndex) { + int pos = 0; + if (constants.getMultiname(multinameIndex).needsNs()) { + pos++; + } + if (constants.getMultiname(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.getMultiname(multinameIndex).needsNs()) { + ns = "[" + stack.get(pos) + "]"; + pos++; + } + if (constants.getMultiname(multinameIndex).needsName()) { + name = stack.get(pos).toString(); + } else { + name = GraphTextWriter.hilighOffset(constants.getMultiname(multinameIndex).getName(constants, fullyQualifiedNames), ins.offset); + } + return name + ns; + } + + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } + + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 0; + } + + protected boolean isRegisterCompileTime(int regId, int ip, HashMap> refs, AVM2Code code) { + Set previous = new HashSet<>(); + AVM2Code.getPreviousReachableIps(ip, refs, previous, new HashSet()); + for (int p : previous) { + if (p < 0) { + continue; + } + if (p >= code.code.size()) { + continue; + } + AVM2Instruction sins = code.code.get(p); + if (code.code.get(p).definition instanceof SetLocalTypeIns) { + SetLocalTypeIns sl = (SetLocalTypeIns) sins.definition; + if (sl.getRegisterId(sins) == regId) { + if (!AVM2Code.isDirectAncestor(ip, p, refs)) { + return false; + } + } + } + if ((code.code.get(p).definition instanceof IncLocalIns) + || (code.code.get(p).definition instanceof IncLocalIIns) + || (code.code.get(p).definition instanceof DecLocalIns) + || (code.code.get(p).definition instanceof DecLocalIIns)) { + if (sins.operands[0] == regId) { + if (!AVM2Code.isDirectAncestor(ip, p, refs)) { + return false; + } + } + } + } + return true; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java index f7ab9cf5f..84c785513 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class AddIIns extends AddIns { - - public AddIIns() { - instructionName = "add_i"; - instructionCode = 0xc5; - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new AddAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class AddIIns extends AddIns { + + public AddIIns() { + instructionName = "add_i"; + instructionCode = 0xc5; + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new AddAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java index ad1cc9b11..dfaedf40c 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java @@ -1,72 +1,72 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.operations.AddAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class AddIns extends InstructionDefinition { - - 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 = Long.valueOf(((Long) o1).longValue() + ((Long) o2).longValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { - Double ret = Double.valueOf(((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 scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new AddAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.operations.AddAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class AddIns extends InstructionDefinition { + + 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 = Long.valueOf(((Long) o1).longValue() + ((Long) o2).longValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { + Double ret = Double.valueOf(((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 scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new AddAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java index 345107666..4d1b6663b 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java @@ -1,66 +1,66 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.DecrementAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class DecrementIIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new DecrementAVM2Item(ins, (GraphTargetItem) stack.pop())); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.DecrementAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class DecrementIIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new DecrementAVM2Item(ins, stack.pop())); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java index da6034bfd..66a57966c 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java @@ -1,66 +1,66 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.DecrementAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class DecrementIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new DecrementAVM2Item(ins, (GraphTargetItem) stack.pop())); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.DecrementAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class DecrementIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new DecrementAVM2Item(ins, stack.pop())); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DivideIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DivideIns.java index 11a0b9258..54c8b601f 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DivideIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DivideIns.java @@ -1,71 +1,71 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.operations.DivideAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class DivideIns extends InstructionDefinition { - - 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 = Long.valueOf(((Long) o1).longValue() / ((Long) o2).longValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { - Double ret = Double.valueOf(((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 scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new DivideAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.operations.DivideAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class DivideIns extends InstructionDefinition { + + 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 = Long.valueOf(((Long) o1).longValue() / ((Long) o2).longValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { + Double ret = Double.valueOf(((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 scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new DivideAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIIns.java index 98ce0eaea..3660c6d63 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIIns.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.IncrementAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IncrementIIns extends InstructionDefinition { - - public IncrementIIns() { - super(0xc0, "increment_i", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new IncrementAVM2Item(ins, (GraphTargetItem) stack.pop())); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.IncrementAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IncrementIIns extends InstructionDefinition { + + public IncrementIIns() { + super(0xc0, "increment_i", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new IncrementAVM2Item(ins, stack.pop())); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIns.java index ecb377c14..8af671e81 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIns.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.IncrementAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IncrementIns extends InstructionDefinition { - - public IncrementIns() { - super(0x91, "increment", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new IncrementAVM2Item(ins, (GraphTargetItem) stack.pop())); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.IncrementAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IncrementIns extends InstructionDefinition { + + public IncrementIns() { + super(0x91, "increment", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new IncrementAVM2Item(ins, stack.pop())); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/ModuloIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/ModuloIns.java index 5ab256ff0..5657c7341 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/ModuloIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/ModuloIns.java @@ -1,63 +1,63 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.operations.ModuloAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ModuloIns extends InstructionDefinition { - - 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(); - - if ((o1 instanceof Long) && ((o2 instanceof Long))) { - Long ret = Long.valueOf(((Long) o2).longValue() % ((Long) o1).longValue()); - lda.operandStack.push(ret); - } else { - throw new RuntimeException("Cannot modulo"); - } - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new ModuloAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.operations.ModuloAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ModuloIns extends InstructionDefinition { + + 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(); + + if ((o1 instanceof Long) && ((o2 instanceof Long))) { + Long ret = Long.valueOf(((Long) o2).longValue() % ((Long) o1).longValue()); + lda.operandStack.push(ret); + } else { + throw new RuntimeException("Cannot modulo"); + } + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new ModuloAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIIns.java index ac1e6a88d..337091b34 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.MultiplyAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class MultiplyIIns extends InstructionDefinition { - - public MultiplyIIns() { - super(0xc7, "multiply_i", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new MultiplyAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.MultiplyAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class MultiplyIIns extends InstructionDefinition { + + public MultiplyIIns() { + super(0xc7, "multiply_i", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new MultiplyAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIns.java index df5383bd5..eaf5425ab 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/MultiplyIns.java @@ -1,71 +1,71 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.operations.MultiplyAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class MultiplyIns extends InstructionDefinition { - - 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 = Long.valueOf(((Long) o1).longValue() * ((Long) o2).longValue()); - lda.operandStack.push(ret); - } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { - Double ret = Double.valueOf(((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 scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new MultiplyAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.operations.MultiplyAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class MultiplyIns extends InstructionDefinition { + + 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 = Long.valueOf(((Long) o1).longValue() * ((Long) o2).longValue()); + lda.operandStack.push(ret); + } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { + Double ret = Double.valueOf(((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 scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new MultiplyAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIIns.java index b235af625..b92a57d00 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIIns.java @@ -1,48 +1,48 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.NegAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class NegateIIns extends InstructionDefinition { - - public NegateIIns() { - super(0xc4, "negate_i", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v = (GraphTargetItem) stack.pop(); - stack.push(new NegAVM2Item(ins, v)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.NegAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class NegateIIns extends InstructionDefinition { + + public NegateIIns() { + super(0xc4, "negate_i", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v = stack.pop(); + stack.push(new NegAVM2Item(ins, v)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIns.java index b51ae57e7..7ae3a98d1 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIns.java @@ -1,48 +1,48 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.NegAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class NegateIns extends InstructionDefinition { - - public NegateIns() { - super(0x90, "negate", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v = (GraphTargetItem) stack.pop(); - stack.push(new NegAVM2Item(ins, v)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.NegAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class NegateIns extends InstructionDefinition { + + public NegateIns() { + super(0x90, "negate", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v = stack.pop(); + stack.push(new NegAVM2Item(ins, v)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NotIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NotIns.java index c5c7b356e..54f22a7d4 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NotIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NotIns.java @@ -1,48 +1,48 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.model.NotItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class NotIns extends InstructionDefinition { - - public NotIns() { - super(0x96, "not", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v = (GraphTargetItem) stack.pop(); - stack.push(new NotItem(ins, v)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.model.NotItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class NotIns extends InstructionDefinition { + + public NotIns() { + super(0x96, "not", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v = stack.pop(); + stack.push(new NotItem(ins, v)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIIns.java index 940416655..fe8ce5ddb 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class SubtractIIns extends InstructionDefinition { - - public SubtractIIns() { - super(0xc6, "subtract_i", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new SubtractAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class SubtractIIns extends InstructionDefinition { + + public SubtractIIns() { + super(0xc6, "subtract_i", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new SubtractAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIns.java index cdb3958f3..5bbe09b8e 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class SubtractIns extends InstructionDefinition { - - public SubtractIns() { - super(0xa1, "subtract", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new SubtractAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class SubtractIns extends InstructionDefinition { + + public SubtractIns() { + super(0xa1, "subtract", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new SubtractAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitAndIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitAndIns.java index c77d89672..44fdca8eb 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitAndIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitAndIns.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.operations.BitAndAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class BitAndIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new BitAndAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.operations.BitAndAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class BitAndIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new BitAndAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java index 3900ca7f4..a55e1dff6 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java @@ -1,56 +1,56 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.operations.BitNotAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class BitNotIns extends InstructionDefinition { - - 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 = Long.valueOf(-value.longValue()); - lda.operandStack.push(ret); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v = (GraphTargetItem) stack.pop(); - stack.push(new BitNotAVM2Item(ins, v)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.operations.BitNotAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class BitNotIns extends InstructionDefinition { + + 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 = Long.valueOf(-value.longValue()); + lda.operandStack.push(ret); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v = stack.pop(); + stack.push(new BitNotAVM2Item(ins, v)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitOrIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitOrIns.java index 02f192564..426236016 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitOrIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitOrIns.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.operations.BitOrAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class BitOrIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new BitOrAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.operations.BitOrAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class BitOrIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new BitOrAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitXorIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitXorIns.java index 7c9fe246b..615734e38 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitXorIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitXorIns.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.operations.BitXorAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class BitXorIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new BitXorAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.operations.BitXorAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class BitXorIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new BitXorAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/LShiftIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/LShiftIns.java index 69dea6f47..04a13116a 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/LShiftIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/LShiftIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.LShiftAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class LShiftIns extends InstructionDefinition { - - public LShiftIns() { - super(0xa5, "lshift", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LShiftAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.LShiftAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class LShiftIns extends InstructionDefinition { + + public LShiftIns() { + super(0xa5, "lshift", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new LShiftAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/RShiftIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/RShiftIns.java index 85f5e6420..d88746129 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/RShiftIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/RShiftIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.RShiftAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class RShiftIns extends InstructionDefinition { - - public RShiftIns() { - super(0xa6, "rshift", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new RShiftAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.RShiftAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class RShiftIns extends InstructionDefinition { + + public RShiftIns() { + super(0xa6, "rshift", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new RShiftAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/URShiftIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/URShiftIns.java index 68db6be42..53a037a85 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/URShiftIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/URShiftIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.URShiftAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class URShiftIns extends InstructionDefinition { - - public URShiftIns() { - super(0xa7, "urshift", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new URShiftAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.bitwise; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.URShiftAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class URShiftIns extends InstructionDefinition { + + public URShiftIns() { + super(0xa7, "urshift", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new URShiftAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/EqualsIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/EqualsIns.java index 4066d802a..e1f4a3f9e 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/EqualsIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/EqualsIns.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.operations.EqAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class EqualsIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new EqAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.operations.EqAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class EqualsIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new EqAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterEqualsIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterEqualsIns.java index af99c23ee..95fb8513d 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterEqualsIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterEqualsIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class GreaterEqualsIns extends InstructionDefinition { - - public GreaterEqualsIns() { - super(0xb0, "greaterequals", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new GeAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class GreaterEqualsIns extends InstructionDefinition { + + public GreaterEqualsIns() { + super(0xb0, "greaterequals", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new GeAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterThanIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterThanIns.java index 659cc68b8..5efddfddc 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterThanIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterThanIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class GreaterThanIns extends InstructionDefinition { - - public GreaterThanIns() { - super(0xaf, "greaterthan", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new GtAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class GreaterThanIns extends InstructionDefinition { + + public GreaterThanIns() { + super(0xaf, "greaterthan", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new GtAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessEqualsIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessEqualsIns.java index 8d12d3dcb..a8a11b0d0 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessEqualsIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessEqualsIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class LessEqualsIns extends InstructionDefinition { - - public LessEqualsIns() { - super(0xae, "lessequals", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LeAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class LessEqualsIns extends InstructionDefinition { + + public LessEqualsIns() { + super(0xae, "lessequals", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new LeAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessThanIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessThanIns.java index 0d10a0bf1..b5d8c99c3 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessThanIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessThanIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class LessThanIns extends InstructionDefinition { - - public LessThanIns() { - super(0xad, "lessthan", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LtAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class LessThanIns extends InstructionDefinition { + + public LessThanIns() { + super(0xad, "lessthan", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new LtAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/StrictEqualsIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/StrictEqualsIns.java index 7213ee911..67d0d2ea6 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/StrictEqualsIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/StrictEqualsIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictEqAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class StrictEqualsIns extends InstructionDefinition { - - public StrictEqualsIns() { - super(0xac, "strictequals", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new StrictEqAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictEqAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class StrictEqualsIns extends InstructionDefinition { + + public StrictEqualsIns() { + super(0xac, "strictequals", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new StrictEqAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java index b13d44e58..9d77fe333 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructIns.java @@ -1,119 +1,119 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.ConstructAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.EscapeXAttrAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.EscapeXElemAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.StringAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.XMLAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ConstructIns extends InstructionDefinition { - - 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 StringAVM2Item) { - list.add(item); - } else if (item instanceof AddAVM2Item) { - ret = ret && walkXML(((AddAVM2Item) item).leftSide, list); - ret = ret && walkXML(((AddAVM2Item) item).rightSide, list); - } else if ((item instanceof EscapeXElemAVM2Item) || (item instanceof EscapeXAttrAVM2Item)) { - list.add(item); - } else { - return false; - } - return ret; - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { - 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(); - - FullMultinameAVM2Item xmlMult = null; - boolean isXML = false; - if (obj instanceof GetPropertyAVM2Item) { - GetPropertyAVM2Item gpt = (GetPropertyAVM2Item) obj; - if (gpt.object instanceof FindPropertyAVM2Item) { - FindPropertyAVM2Item fpt = (FindPropertyAVM2Item) gpt.object; - xmlMult = (FullMultinameAVM2Item) fpt.propertyName; - isXML = xmlMult.isXML(constants, localRegNames, fullyQualifiedNames) && xmlMult.isXML(constants, localRegNames, fullyQualifiedNames); - } - } - if (obj instanceof GetLexAVM2Item) { - GetLexAVM2Item glt = (GetLexAVM2Item) obj; - isXML = glt.propertyName.getName(constants, fullyQualifiedNames).equals("XML"); - } - - if (isXML) { - if (args.size() == 1) { - GraphTargetItem arg = args.get(0); - List xmlLines = new ArrayList<>(); - if (walkXML(arg, xmlLines)) { - stack.push(new XMLAVM2Item(ins, xmlLines)); - return; - } - } - } - - stack.push(new ConstructAVM2Item(ins, obj, args)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -ins.operands[0] - 1 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.ConstructAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.EscapeXAttrAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.EscapeXElemAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.StringAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.XMLAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ConstructIns extends InstructionDefinition { + + 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 StringAVM2Item) { + list.add(item); + } else if (item instanceof AddAVM2Item) { + ret = ret && walkXML(((AddAVM2Item) item).leftSide, list); + ret = ret && walkXML(((AddAVM2Item) item).rightSide, list); + } else if ((item instanceof EscapeXElemAVM2Item) || (item instanceof EscapeXAttrAVM2Item)) { + list.add(item); + } else { + return false; + } + return ret; + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { + int argCount = ins.operands[0]; + List args = new ArrayList<>(); + for (int a = 0; a < argCount; a++) { + args.add(0, stack.pop()); + } + GraphTargetItem obj = stack.pop(); + + FullMultinameAVM2Item xmlMult = null; + boolean isXML = false; + if (obj instanceof GetPropertyAVM2Item) { + GetPropertyAVM2Item gpt = (GetPropertyAVM2Item) obj; + if (gpt.object instanceof FindPropertyAVM2Item) { + FindPropertyAVM2Item fpt = (FindPropertyAVM2Item) gpt.object; + xmlMult = (FullMultinameAVM2Item) fpt.propertyName; + isXML = xmlMult.isXML(constants, localRegNames, fullyQualifiedNames) && xmlMult.isXML(constants, localRegNames, fullyQualifiedNames); + } + } + if (obj instanceof GetLexAVM2Item) { + GetLexAVM2Item glt = (GetLexAVM2Item) obj; + isXML = glt.propertyName.getName(constants, fullyQualifiedNames).equals("XML"); + } + + if (isXML) { + if (args.size() == 1) { + GraphTargetItem arg = args.get(0); + List xmlLines = new ArrayList<>(); + if (walkXML(arg, xmlLines)) { + stack.push(new XMLAVM2Item(ins, xmlLines)); + return; + } + } + } + + stack.push(new ConstructAVM2Item(ins, obj, args)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -ins.operands[0] - 1 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructPropIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructPropIns.java index c6d680453..6ef59124f 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructPropIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructPropIns.java @@ -1,94 +1,94 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.ConstructPropAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.XMLAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ConstructPropIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { - 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()); - } - FullMultinameAVM2Item 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 XMLAVM2Item(ins, xmlLines)); - return; - } - } - } - - stack.push(new ConstructPropAVM2Item(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.getMultiname(multinameIndex).needsName()) { - ret--; - } - if (abc.constants.getMultiname(multinameIndex).needsNs()) { - ret--; - } - return ret; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.ConstructPropAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.XMLAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ConstructPropIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { + int multinameIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList<>(); + for (int a = 0; a < argCount; a++) { + args.add(0, stack.pop()); + } + FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem obj = 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 XMLAVM2Item(ins, xmlLines)); + return; + } + } + } + + stack.push(new ConstructPropAVM2Item(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.getMultiname(multinameIndex).needsName()) { + ret--; + } + if (abc.constants.getMultiname(multinameIndex).needsNs()) { + ret--; + } + return ret; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructSuperIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructSuperIns.java index 130ec7ea7..d2f5c1efd 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructSuperIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/ConstructSuperIns.java @@ -1,68 +1,68 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.ConstructSuperAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ConstructSuperIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - 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 ConstructSuperAVM2Item(ins, obj, args)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -ins.operands[0] - 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.ConstructSuperAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ConstructSuperIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int argCount = ins.operands[0]; + List args = new ArrayList<>(); + for (int a = 0; a < argCount; a++) { + args.add(0, stack.pop()); + } + GraphTargetItem obj = stack.pop(); + output.add(new ConstructSuperAVM2Item(ins, obj, args)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -ins.operands[0] - 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewActivationIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewActivationIns.java index 82c419737..a6034b3ef 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewActivationIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewActivationIns.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class NewActivationIns extends InstructionDefinition { - - public NewActivationIns() { - super(0x57, "newactivation", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new NewActivationAVM2Item(ins)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class NewActivationIns extends InstructionDefinition { + + public NewActivationIns() { + super(0x57, "newactivation", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new NewActivationAVM2Item(ins)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewArrayIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewArrayIns.java index 4095db293..e4c0d6326 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewArrayIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewArrayIns.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.NewArrayAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class NewArrayIns extends InstructionDefinition { - - public NewArrayIns() { - super(0x56, "newarray", new int[]{AVM2Code.DAT_ARG_COUNT}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - 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 NewArrayAVM2Item(ins, args)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -ins.operands[0] + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.NewArrayAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class NewArrayIns extends InstructionDefinition { + + public NewArrayIns() { + super(0x56, "newarray", new int[]{AVM2Code.DAT_ARG_COUNT}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int argCount = ins.operands[0]; + List args = new ArrayList<>(); + for (int a = 0; a < argCount; a++) { + args.add(0, stack.pop()); + } + stack.push(new NewArrayAVM2Item(ins, args)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -ins.operands[0] + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewCatchIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewCatchIns.java index acdc49cea..a0651488f 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewCatchIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewCatchIns.java @@ -1,48 +1,48 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class NewCatchIns extends InstructionDefinition { - - public NewCatchIns() { - super(0x5a, "newcatch", new int[]{AVM2Code.DAT_EXCEPTION_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int exInfo = ins.operands[0]; - stack.push(new ExceptionAVM2Item(body.exceptions[exInfo])); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class NewCatchIns extends InstructionDefinition { + + public NewCatchIns() { + super(0x5a, "newcatch", new int[]{AVM2Code.DAT_EXCEPTION_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int exInfo = ins.operands[0]; + stack.push(new ExceptionAVM2Item(body.exceptions[exInfo])); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java index 499fb9c86..64eb4cced 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewClassIns.java @@ -1,54 +1,54 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.UnparsedAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.flash.configuration.Configuration; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.model.LocalData; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class NewClassIns extends InstructionDefinition { - - public NewClassIns() { - super(0x58, "newclass", new int[]{AVM2Code.DAT_CLASS_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { - int clsIndex = ins.operands[0]; - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); - stack.pop().toString(writer, LocalData.create(constants, localRegNames, fullyQualifiedNames)); - String baseType = writer.toString(); - stack.push(new UnparsedAVM2Item(ins, "new " + abc.constants.getMultiname(abc.instance_info.get(clsIndex).name_index).getName(constants, fullyQualifiedNames) + ".class extends " + baseType)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.UnparsedAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.model.LocalData; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class NewClassIns extends InstructionDefinition { + + public NewClassIns() { + super(0x58, "newclass", new int[]{AVM2Code.DAT_CLASS_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) throws InterruptedException { + int clsIndex = ins.operands[0]; + HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); + stack.pop().toString(writer, LocalData.create(constants, localRegNames, fullyQualifiedNames)); + String baseType = writer.toString(); + stack.push(new UnparsedAVM2Item(ins, "new " + abc.constants.getMultiname(abc.instance_info.get(clsIndex).name_index).getName(constants, fullyQualifiedNames) + ".class extends " + baseType)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java index 2487af241..02536e177 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewFunctionIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.NewFunctionAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class NewFunctionIns extends InstructionDefinition { - - public NewFunctionIns() { - super(0x40, "newfunction", new int[]{AVM2Code.DAT_METHOD_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int methodIndex = ins.operands[0]; - NewFunctionAVM2Item function = new NewFunctionAVM2Item(ins, "", path, isStatic, scriptIndex, classIndex, abc, fullyQualifiedNames, constants, method_info, methodIndex); - stack.push(function); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.NewFunctionAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class NewFunctionIns extends InstructionDefinition { + + public NewFunctionIns() { + super(0x40, "newfunction", new int[]{AVM2Code.DAT_METHOD_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int methodIndex = ins.operands[0]; + NewFunctionAVM2Item function = new NewFunctionAVM2Item(ins, "", path, isStatic, scriptIndex, classIndex, abc, fullyQualifiedNames, constants, method_info, methodIndex); + stack.push(function); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewObjectIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewObjectIns.java index 333aaff97..783b15fac 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewObjectIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/construction/NewObjectIns.java @@ -1,56 +1,56 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.NameValuePair; -import com.jpexs.decompiler.flash.abc.avm2.model.NewObjectAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class NewObjectIns extends InstructionDefinition { - - public NewObjectIns() { - super(0x55, "newobject", new int[]{AVM2Code.DAT_ARG_COUNT}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - 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 NewObjectAVM2Item(ins, args)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -ins.operands[0] * 2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.construction; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.NameValuePair; +import com.jpexs.decompiler.flash.abc.avm2.model.NewObjectAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class NewObjectIns extends InstructionDefinition { + + public NewObjectIns() { + super(0x55, "newobject", new int[]{AVM2Code.DAT_ARG_COUNT}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int argCount = ins.operands[0]; + List args = new ArrayList<>(); + for (int a = 0; a < argCount; a++) { + GraphTargetItem value = stack.pop(); + GraphTargetItem name = stack.pop(); + args.add(0, new NameValuePair(name, value)); + } + stack.push(new NewObjectAVM2Item(ins, args)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -ins.operands[0] * 2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallIns.java index deaecc539..d02d98019 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallIns.java @@ -1,69 +1,69 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.executing; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.CallAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class CallIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - 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 CallAVM2Item(ins, receiver, function, args)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1 - ins.operands[0]; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.executing; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.CallAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class CallIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int argCount = ins.operands[0]; + List args = new ArrayList<>(); + for (int a = 0; a < argCount; a++) { + args.add(0, stack.pop()); + } + GraphTargetItem receiver = stack.pop(); + GraphTargetItem function = stack.pop(); + stack.push(new CallAVM2Item(ins, receiver, function, args)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1 - ins.operands[0]; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallMethodIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallMethodIns.java index 0a27e9784..2da91c42c 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallMethodIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallMethodIns.java @@ -1,70 +1,70 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.executing; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.CallMethodAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class CallMethodIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - 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.get(methodIndex).getName(constants); - stack.push(new CallMethodAVM2Item(ins, receiver, methodName, args)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1 - ins.operands[1]; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.executing; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.CallMethodAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class CallMethodIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int methodIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList<>(); + for (int a = 0; a < argCount; a++) { + args.add(0, stack.pop()); + } + GraphTargetItem receiver = stack.pop(); + String methodName = method_info.get(methodIndex).getName(constants); + stack.push(new CallMethodAVM2Item(ins, receiver, methodName, args)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1 - ins.operands[1]; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java index e90f5118a..1e854e01c 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropLexIns.java @@ -1,66 +1,66 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.executing; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.model.CallPropertyAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class CallPropLexIns extends CallPropertyIns { - - public CallPropLexIns() { - instructionName = "callproplex"; - instructionCode = 0x4c; - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - 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()); - } - FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem receiver = (GraphTargetItem) stack.pop(); - - stack.push(new CallPropertyAVM2Item(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.getMultiname(multinameIndex).needsName()) { - ret--; - } - if (abc.constants.getMultiname(multinameIndex).needsNs()) { - ret--; - } - return ret; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.executing; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.model.CallPropertyAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class CallPropLexIns extends CallPropertyIns { + + public CallPropLexIns() { + instructionName = "callproplex"; + instructionCode = 0x4c; + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int multinameIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList<>(); + for (int a = 0; a < argCount; a++) { + args.add(0, stack.pop()); + } + FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem receiver = stack.pop(); + + stack.push(new CallPropertyAVM2Item(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.getMultiname(multinameIndex).needsName()) { + ret--; + } + if (abc.constants.getMultiname(multinameIndex).needsNs()) { + ret--; + } + return ret; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java index a2b504b00..bd3ccf9cf 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropVoidIns.java @@ -1,85 +1,85 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.executing; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.CallPropertyAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class CallPropVoidIns extends InstructionDefinition { - - 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 -/* - 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 scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - 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()); - } - FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); - - GraphTargetItem receiver = (GraphTargetItem) stack.pop(); - - output.add(new CallPropertyAVM2Item(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.getMultiname(multinameIndex).needsName()) { - ret--; - } - if (abc.constants.getMultiname(multinameIndex).needsNs()) { - ret--; - } - return ret; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.executing; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.CallPropertyAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class CallPropVoidIns extends InstructionDefinition { + + 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 +/* + 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 scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int multinameIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList<>(); + for (int a = 0; a < argCount; a++) { + args.add(0, stack.pop()); + } + FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); + + GraphTargetItem receiver = stack.pop(); + + output.add(new CallPropertyAVM2Item(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.getMultiname(multinameIndex).needsName()) { + ret--; + } + if (abc.constants.getMultiname(multinameIndex).needsNs()) { + ret--; + } + return ret; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java index d955cd21e..af1d96229 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallPropertyIns.java @@ -1,83 +1,83 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.executing; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.CallPropertyAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class CallPropertyIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - 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()); - } - FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); - - GraphTargetItem receiver = (GraphTargetItem) stack.pop(); - - stack.push(new CallPropertyAVM2Item(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.getMultiname(multinameIndex).needsName()) { - ret--; - } - if (abc.constants.getMultiname(multinameIndex).needsNs()) { - ret--; - } - return ret; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.executing; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.CallPropertyAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class CallPropertyIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int multinameIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList<>(); + for (int a = 0; a < argCount; a++) { + args.add(0, stack.pop()); + } + FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); + + GraphTargetItem receiver = stack.pop(); + + stack.push(new CallPropertyAVM2Item(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.getMultiname(multinameIndex).needsName()) { + ret--; + } + if (abc.constants.getMultiname(multinameIndex).needsNs()) { + ret--; + } + return ret; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallStaticIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallStaticIns.java index e9cd35d4f..a5b00b0c4 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallStaticIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallStaticIns.java @@ -1,70 +1,70 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.executing; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.CallStaticAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class CallStaticIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - 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.get(methodIndex).getName(constants); - stack.push(new CallStaticAVM2Item(ins, receiver, methodName, args)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1 - ins.operands[1]; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.executing; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.CallStaticAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class CallStaticIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int methodIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList<>(); + for (int a = 0; a < argCount; a++) { + args.add(0, stack.pop()); + } + GraphTargetItem receiver = stack.pop(); + String methodName = method_info.get(methodIndex).getName(constants); + stack.push(new CallStaticAVM2Item(ins, receiver, methodName, args)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1 - ins.operands[1]; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperIns.java index dbd69e5f8..e155b95e6 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperIns.java @@ -1,82 +1,82 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.executing; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.CallSuperAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class CallSuperIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - 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()); - } - FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem receiver = (GraphTargetItem) stack.pop(); - - stack.push(new CallSuperAVM2Item(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.getMultiname(multinameIndex).needsName()) { - ret--; - } - if (abc.constants.getMultiname(multinameIndex).needsNs()) { - ret--; - } - return ret; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.executing; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.CallSuperAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class CallSuperIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int multinameIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList<>(); + for (int a = 0; a < argCount; a++) { + args.add(0, stack.pop()); + } + FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem receiver = stack.pop(); + + stack.push(new CallSuperAVM2Item(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.getMultiname(multinameIndex).needsName()) { + ret--; + } + if (abc.constants.getMultiname(multinameIndex).needsNs()) { + ret--; + } + return ret; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperVoidIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperVoidIns.java index 5d274a2bb..c1ce5923d 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperVoidIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/executing/CallSuperVoidIns.java @@ -1,83 +1,83 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.executing; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.CallSuperAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class CallSuperVoidIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - 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()); - } - FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem receiver = (GraphTargetItem) stack.pop(); - - output.add(new CallSuperAVM2Item(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.getMultiname(multinameIndex).needsName()) { - ret--; - } - if (abc.constants.getMultiname(multinameIndex).needsNs()) { - ret--; - } - return ret; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.executing; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.CallSuperAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class CallSuperVoidIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int multinameIndex = ins.operands[0]; + int argCount = ins.operands[1]; + List args = new ArrayList<>(); + for (int a = 0; a < argCount; a++) { + args.add(0, stack.pop()); + } + FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem receiver = stack.pop(); + + output.add(new CallSuperAVM2Item(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.getMultiname(multinameIndex).needsName()) { + ret--; + } + if (abc.constants.getMultiname(multinameIndex).needsNs()) { + ret--; + } + return ret; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfEqIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfEqIns.java index 1d24ae599..2d13a9da3 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfEqIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfEqIns.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.EqAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.NeqAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IfEqIns extends InstructionDefinition implements IfTypeIns { - - public IfEqIns() { - super(0x13, "ifeq", new int[]{AVM2Code.DAT_OFFSET}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new EqAVM2Item(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 NeqAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.EqAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.NeqAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IfEqIns extends InstructionDefinition implements IfTypeIns { + + public IfEqIns() { + super(0x13, "ifeq", new int[]{AVM2Code.DAT_OFFSET}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new EqAVM2Item(ins, v1, v2)); + } + + @Override + public void translateInverted(HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new NeqAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfFalseIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfFalseIns.java index b1a5bf645..3a3cf0b44 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfFalseIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfFalseIns.java @@ -1,55 +1,55 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.model.NotItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IfFalseIns extends InstructionDefinition implements IfTypeIns { - - public IfFalseIns() { - super(0x12, "iffalse", new int[]{AVM2Code.DAT_OFFSET}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - 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 int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.model.NotItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IfFalseIns extends InstructionDefinition implements IfTypeIns { + + public IfFalseIns() { + super(0x12, "iffalse", new int[]{AVM2Code.DAT_OFFSET}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v1 = stack.pop(); + stack.push(new NotItem(ins, v1)); + } + + @Override + public void translateInverted(HashMap localRegs, Stack stack, AVM2Instruction ins) { + //String v1 = stack.pop().toString(); + //stack.push("(" + v1 + ")"); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGeIns.java index 00f515e06..91451be75 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGeIns.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IfGeIns extends InstructionDefinition implements IfTypeIns { - - public IfGeIns() { - super(0x18, "ifge", new int[]{AVM2Code.DAT_OFFSET}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new GeAVM2Item(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 LtAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IfGeIns extends InstructionDefinition implements IfTypeIns { + + public IfGeIns() { + super(0x18, "ifge", new int[]{AVM2Code.DAT_OFFSET}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new GeAVM2Item(ins, v1, v2)); + } + + @Override + public void translateInverted(HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new LtAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGtIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGtIns.java index 8fc30aee8..a76331ff7 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGtIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGtIns.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IfGtIns extends InstructionDefinition implements IfTypeIns { - - public IfGtIns() { - super(0x17, "ifgt", new int[]{AVM2Code.DAT_OFFSET}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new GtAVM2Item(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 LeAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IfGtIns extends InstructionDefinition implements IfTypeIns { + + public IfGtIns() { + super(0x17, "ifgt", new int[]{AVM2Code.DAT_OFFSET}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new GtAVM2Item(ins, v1, v2)); + } + + @Override + public void translateInverted(HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new LeAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLeIns.java index c56ff2c66..aac40399c 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLeIns.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IfLeIns extends InstructionDefinition implements IfTypeIns { - - public IfLeIns() { - super(0x16, "ifle", new int[]{AVM2Code.DAT_OFFSET}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LeAVM2Item(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 GtAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IfLeIns extends InstructionDefinition implements IfTypeIns { + + public IfLeIns() { + super(0x16, "ifle", new int[]{AVM2Code.DAT_OFFSET}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new LeAVM2Item(ins, v1, v2)); + } + + @Override + public void translateInverted(HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new GtAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLtIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLtIns.java index bf2261ce5..e41e27ecb 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLtIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLtIns.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IfLtIns extends InstructionDefinition implements IfTypeIns { - - public IfLtIns() { - super(0x15, "iflt", new int[]{AVM2Code.DAT_OFFSET}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LtAVM2Item(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 GeAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IfLtIns extends InstructionDefinition implements IfTypeIns { + + public IfLtIns() { + super(0x15, "iflt", new int[]{AVM2Code.DAT_OFFSET}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new LtAVM2Item(ins, v1, v2)); + } + + @Override + public void translateInverted(HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new GeAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGeIns.java index 515a49f22..02ab8c9dd 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGeIns.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IfNGeIns extends InstructionDefinition implements IfTypeIns { - - public IfNGeIns() { - super(0x0f, "ifnge", new int[]{AVM2Code.DAT_OFFSET}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LtAVM2Item(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 GeAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IfNGeIns extends InstructionDefinition implements IfTypeIns { + + public IfNGeIns() { + super(0x0f, "ifnge", new int[]{AVM2Code.DAT_OFFSET}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new LtAVM2Item(ins, v1, v2)); + } + + @Override + public void translateInverted(HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new GeAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGtIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGtIns.java index 7e38b614b..165142d88 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGtIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGtIns.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IfNGtIns extends InstructionDefinition implements IfTypeIns { - - public IfNGtIns() { - super(0x0e, "ifngt", new int[]{AVM2Code.DAT_OFFSET}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new LeAVM2Item(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 GtAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IfNGtIns extends InstructionDefinition implements IfTypeIns { + + public IfNGtIns() { + super(0x0e, "ifngt", new int[]{AVM2Code.DAT_OFFSET}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new LeAVM2Item(ins, v1, v2)); + } + + @Override + public void translateInverted(HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new GtAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLeIns.java index 12ac7507c..e8aed6c41 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLeIns.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IfNLeIns extends InstructionDefinition implements IfTypeIns { - - public IfNLeIns() { - super(0x0d, "ifnle", new int[]{AVM2Code.DAT_OFFSET}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new GtAVM2Item(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 LeAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IfNLeIns extends InstructionDefinition implements IfTypeIns { + + public IfNLeIns() { + super(0x0d, "ifnle", new int[]{AVM2Code.DAT_OFFSET}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new GtAVM2Item(ins, v1, v2)); + } + + @Override + public void translateInverted(HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new LeAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLtIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLtIns.java index 4b3d3a19b..24e6653d9 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLtIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLtIns.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IfNLtIns extends InstructionDefinition implements IfTypeIns { - - public IfNLtIns() { - super(0x0c, "ifnlt", new int[]{AVM2Code.DAT_OFFSET}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new GeAVM2Item(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 LtAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IfNLtIns extends InstructionDefinition implements IfTypeIns { + + public IfNLtIns() { + super(0x0c, "ifnlt", new int[]{AVM2Code.DAT_OFFSET}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new GeAVM2Item(ins, v1, v2)); + } + + @Override + public void translateInverted(HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new LtAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNeIns.java index 0d470317b..7ece860b2 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNeIns.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.EqAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.NeqAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IfNeIns extends InstructionDefinition implements IfTypeIns { - - public IfNeIns() { - super(0x14, "ifne", new int[]{AVM2Code.DAT_OFFSET}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new NeqAVM2Item(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 EqAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.EqAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.NeqAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IfNeIns extends InstructionDefinition implements IfTypeIns { + + public IfNeIns() { + super(0x14, "ifne", new int[]{AVM2Code.DAT_OFFSET}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new NeqAVM2Item(ins, v1, v2)); + } + + @Override + public void translateInverted(HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new EqAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictEqIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictEqIns.java index b78bda55a..3c928a191 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictEqIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictEqIns.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictEqAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictNeqAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IfStrictEqIns extends InstructionDefinition implements IfTypeIns { - - public IfStrictEqIns() { - super(0x19, "ifstricteq", new int[]{AVM2Code.DAT_OFFSET}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new StrictEqAVM2Item(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 StrictNeqAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictEqAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictNeqAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IfStrictEqIns extends InstructionDefinition implements IfTypeIns { + + public IfStrictEqIns() { + super(0x19, "ifstricteq", new int[]{AVM2Code.DAT_OFFSET}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new StrictEqAVM2Item(ins, v1, v2)); + } + + @Override + public void translateInverted(HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new StrictNeqAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictNeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictNeIns.java index 34d6e52c8..ed263d428 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictNeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictNeIns.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictEqAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictNeqAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IfStrictNeIns extends InstructionDefinition implements IfTypeIns { - - public IfStrictNeIns() { - super(0x1A, "ifstrictne", new int[]{AVM2Code.DAT_OFFSET}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v2 = (GraphTargetItem) stack.pop(); - GraphTargetItem v1 = (GraphTargetItem) stack.pop(); - stack.push(new StrictNeqAVM2Item(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 StrictEqAVM2Item(ins, v1, v2)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictEqAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictNeqAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IfStrictNeIns extends InstructionDefinition implements IfTypeIns { + + public IfStrictNeIns() { + super(0x1A, "ifstrictne", new int[]{AVM2Code.DAT_OFFSET}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new StrictNeqAVM2Item(ins, v1, v2)); + } + + @Override + public void translateInverted(HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v2 = stack.pop(); + GraphTargetItem v1 = stack.pop(); + stack.push(new StrictEqAVM2Item(ins, v1, v2)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfTrueIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfTrueIns.java index 1ee950c28..06db86277 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfTrueIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfTrueIns.java @@ -1,55 +1,55 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.model.NotItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IfTrueIns extends InstructionDefinition implements IfTypeIns { - - public IfTrueIns() { - super(0x11, "iftrue", new int[]{AVM2Code.DAT_OFFSET}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - //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 int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.model.NotItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IfTrueIns extends InstructionDefinition implements IfTypeIns { + + public IfTrueIns() { + super(0x11, "iftrue", new int[]{AVM2Code.DAT_OFFSET}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + //String v1 = stack.pop().toString(); + //stack.push("(" + v1 + ")"); + } + + @Override + public void translateInverted(HashMap localRegs, Stack stack, AVM2Instruction ins) { + GraphTargetItem v1 = stack.pop(); + stack.push(new NotItem(ins, v1)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/JumpIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/JumpIns.java index 75859c659..9a4f67e2d 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/JumpIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/JumpIns.java @@ -1,46 +1,46 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class JumpIns extends InstructionDefinition implements IfTypeIns { - - public JumpIns() { - super(0x10, "jump", new int[]{AVM2Code.DAT_OFFSET}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - //stack.push(new BooleanAVM2Item(ins, Boolean.TRUE));// + ins.operands[0]); - } - - @Override - public void translateInverted(java.util.HashMap localRegs, Stack stack, AVM2Instruction ins) { - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class JumpIns extends InstructionDefinition implements IfTypeIns { + + public JumpIns() { + super(0x10, "jump", new int[]{AVM2Code.DAT_OFFSET}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + //stack.push(new BooleanAVM2Item(ins, Boolean.TRUE));// + ins.operands[0]); + } + + @Override + public void translateInverted(HashMap localRegs, Stack stack, AVM2Instruction ins) { + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/LookupSwitchIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/LookupSwitchIns.java index a2396fbdd..1c7883a3b 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/LookupSwitchIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/LookupSwitchIns.java @@ -1,48 +1,48 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class LookupSwitchIns extends InstructionDefinition { - - public LookupSwitchIns() { - super(0x1b, "lookupswitch", new int[]{AVM2Code.DAT_CASE_BASEOFFSET, AVM2Code.OPT_CASE_OFFSETS}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - //int defaultOffset = ins.operands[0]; - //int caseCount = ins.operands[1]; - //stack.push("switch(...)"); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class LookupSwitchIns extends InstructionDefinition { + + public LookupSwitchIns() { + super(0x1b, "lookupswitch", new int[]{AVM2Code.DAT_CASE_BASEOFFSET, AVM2Code.OPT_CASE_OFFSETS}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + //int defaultOffset = ins.operands[0]; + //int caseCount = ins.operands[1]; + //stack.push("switch(...)"); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java index 0d4ebe365..757631768 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java @@ -1,75 +1,75 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.DecLocalAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class DecLocalIIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { - int regId = ins.operands[0]; - output.add(new DecLocalAVM2Item(ins, regId)); - if (localRegs.containsKey(regId)) { - localRegs.put(regId, new SubtractAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, Long.valueOf(1)))); - } else { - //localRegs.put(regIndex, new SubtractAVM2Item(ins, new IntegerValueAVM2Item(ins, new Long(0)), new IntegerValueAVM2Item(ins, new Long(1)))); - } - if (!regAssignCount.containsKey(regId)) { - regAssignCount.put(regId, 0); - } - regAssignCount.put(regId, regAssignCount.get(regId) + 1); - - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.DecLocalAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class DecLocalIIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { + int regId = ins.operands[0]; + output.add(new DecLocalAVM2Item(ins, regId)); + if (localRegs.containsKey(regId)) { + localRegs.put(regId, new SubtractAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, Long.valueOf(1)))); + } else { + //localRegs.put(regIndex, new SubtractAVM2Item(ins, new IntegerValueAVM2Item(ins, new Long(0)), new IntegerValueAVM2Item(ins, new Long(1)))); + } + if (!regAssignCount.containsKey(regId)) { + regAssignCount.put(regId, 0); + } + regAssignCount.put(regId, regAssignCount.get(regId) + 1); + + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java index ad57494c1..21a6d603e 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java @@ -1,74 +1,74 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.DecLocalAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class DecLocalIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { - int regId = ins.operands[0]; - output.add(new DecLocalAVM2Item(ins, regId)); - if (localRegs.containsKey(regId)) { - localRegs.put(regId, new SubtractAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, Long.valueOf(1)))); - } else { - //localRegs.put(regIndex, new SubtractAVM2Item(ins, new IntegerValueAVM2Item(ins, new Long(0)), new IntegerValueAVM2Item(ins, new Long(1)))); - } - if (!regAssignCount.containsKey(regId)) { - regAssignCount.put(regId, 0); - } - regAssignCount.put(regId, regAssignCount.get(regId) + 1); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.DecLocalAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class DecLocalIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { + int regId = ins.operands[0]; + output.add(new DecLocalAVM2Item(ins, regId)); + if (localRegs.containsKey(regId)) { + localRegs.put(regId, new SubtractAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, Long.valueOf(1)))); + } else { + //localRegs.put(regIndex, new SubtractAVM2Item(ins, new IntegerValueAVM2Item(ins, new Long(0)), new IntegerValueAVM2Item(ins, new Long(1)))); + } + if (!regAssignCount.containsKey(regId)) { + regAssignCount.put(regId, 0); + } + regAssignCount.put(regId, regAssignCount.get(regId) + 1); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java index dadcac48c..38fb24c1d 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java @@ -1,62 +1,62 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.model.ClassAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.ScriptAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class GetLocal0Ins extends GetLocalTypeIns { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - if ((classIndex >= abc.instance_info.size()) || classIndex < 0) { - stack.push(new ScriptAVM2Item(scriptIndex)); - return; - } - if (isStatic) { - stack.push(new ClassAVM2Item(abc.instance_info.get(classIndex).getName(constants))); - } else { - stack.push(new ThisAVM2Item(abc.instance_info.get(classIndex).getName(constants))); - } - } - - @Override - public int getRegisterId(AVM2Instruction par0) { - return 0; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.model.ClassAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.ScriptAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class GetLocal0Ins extends GetLocalTypeIns { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + if ((classIndex >= abc.instance_info.size()) || classIndex < 0) { + stack.push(new ScriptAVM2Item(scriptIndex)); + return; + } + if (isStatic) { + stack.push(new ClassAVM2Item(abc.instance_info.get(classIndex).getName(constants))); + } else { + stack.push(new ThisAVM2Item(abc.instance_info.get(classIndex).getName(constants))); + } + } + + @Override + public int getRegisterId(AVM2Instruction par0) { + return 0; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java index 78ec1f081..1a186eaf9 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java @@ -1,67 +1,67 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.NotCompileTimeItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public abstract class GetLocalTypeIns extends InstructionDefinition { - - public GetLocalTypeIns(int instructionCode, String instructionName, int[] operands) { - super(instructionCode, instructionName, operands); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { - int regId = getRegisterId(ins); - GraphTargetItem computedValue = localRegs.get(regId); - int assignCount = 0; - if (regAssignCount.containsKey(regId)) { - assignCount = regAssignCount.get(regId); - } - if (assignCount > 5) { //Do not allow change register more than 5 - for deobfuscation - computedValue = new NotCompileTimeItem(ins, computedValue); - } - /*if (!isRegisterCompileTime(regId, ip, refs, code)) { - computedValue = new NotCompileTimeAVM2Item(ins, computedValue); - } - if (computedValue == null) { - if (!localRegNames.containsKey(regId)) { - computedValue = new UndefinedAVM2Item(null); //In some obfuscated code there seems to be reading of undefined registers - } - }*/ - stack.push(new LocalRegAVM2Item(ins, regId, computedValue)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } - - public abstract int getRegisterId(AVM2Instruction ins); -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.NotCompileTimeItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public abstract class GetLocalTypeIns extends InstructionDefinition { + + public GetLocalTypeIns(int instructionCode, String instructionName, int[] operands) { + super(instructionCode, instructionName, operands); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { + int regId = getRegisterId(ins); + GraphTargetItem computedValue = localRegs.get(regId); + int assignCount = 0; + if (regAssignCount.containsKey(regId)) { + assignCount = regAssignCount.get(regId); + } + if (assignCount > 5) { //Do not allow change register more than 5 - for deobfuscation + computedValue = new NotCompileTimeItem(ins, computedValue); + } + /*if (!isRegisterCompileTime(regId, ip, refs, code)) { + computedValue = new NotCompileTimeAVM2Item(ins, computedValue); + } + if (computedValue == null) { + if (!localRegNames.containsKey(regId)) { + computedValue = new UndefinedAVM2Item(null); //In some obfuscated code there seems to be reading of undefined registers + } + }*/ + stack.push(new LocalRegAVM2Item(ins, regId, computedValue)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } + + public abstract int getRegisterId(AVM2Instruction ins); +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java index 5d075bdf4..3745cdf93 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java @@ -1,54 +1,54 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.IncLocalAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IncLocalIIns extends InstructionDefinition { - - public IncLocalIIns() { - super(0xc2, "inclocal_i", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { - int regId = ins.operands[0]; - output.add(new IncLocalAVM2Item(ins, regId)); - if (localRegs.containsKey(regId)) { - localRegs.put(regId, new AddAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, Long.valueOf(1)))); - } else { - //localRegs.put(regIndex, new AddAVM2Item(ins, null, new IntegerValueAVM2Item(ins, new Long(1)))); - } - if (!regAssignCount.containsKey(regId)) { - regAssignCount.put(regId, 0); - } - regAssignCount.put(regId, regAssignCount.get(regId) + 1); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.IncLocalAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IncLocalIIns extends InstructionDefinition { + + public IncLocalIIns() { + super(0xc2, "inclocal_i", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { + int regId = ins.operands[0]; + output.add(new IncLocalAVM2Item(ins, regId)); + if (localRegs.containsKey(regId)) { + localRegs.put(regId, new AddAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, Long.valueOf(1)))); + } else { + //localRegs.put(regIndex, new AddAVM2Item(ins, null, new IntegerValueAVM2Item(ins, new Long(1)))); + } + if (!regAssignCount.containsKey(regId)) { + regAssignCount.put(regId, 0); + } + regAssignCount.put(regId, regAssignCount.get(regId) + 1); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java index 164ebfc32..802f32257 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java @@ -1,54 +1,54 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.IncLocalAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IncLocalIns extends InstructionDefinition { - - public IncLocalIns() { - super(0x92, "inclocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { - int regId = ins.operands[0]; - output.add(new IncLocalAVM2Item(ins, regId)); - if (localRegs.containsKey(regId)) { - localRegs.put(regId, new AddAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, Long.valueOf(1)))); - } else { - //localRegs.put(regIndex, new AddAVM2Item(ins, null, new IntegerValueAVM2Item(ins, new Long(1)))); - } - if (!regAssignCount.containsKey(regId)) { - regAssignCount.put(regId, 0); - } - regAssignCount.put(regId, regAssignCount.get(regId) + 1); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.IncLocalAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IncLocalIns extends InstructionDefinition { + + public IncLocalIns() { + super(0x92, "inclocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { + int regId = ins.operands[0]; + output.add(new IncLocalAVM2Item(ins, regId)); + if (localRegs.containsKey(regId)) { + localRegs.put(regId, new AddAVM2Item(ins, localRegs.get(regId), new IntegerValueAVM2Item(ins, Long.valueOf(1)))); + } else { + //localRegs.put(regIndex, new AddAVM2Item(ins, null, new IntegerValueAVM2Item(ins, new Long(1)))); + } + if (!regAssignCount.containsKey(regId)) { + regAssignCount.put(regId, 0); + } + regAssignCount.put(regId, regAssignCount.get(regId) + 1); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/KillIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/KillIns.java index eaebaeb9b..fd3416b56 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/KillIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/KillIns.java @@ -1,41 +1,41 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class KillIns extends InstructionDefinition { - - public KillIns() { - super(0x08, "kill", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - //kill local register - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class KillIns extends InstructionDefinition { + + public KillIns() { + super(0x08, "kill", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + //kill local register + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java index 8075a266a..e96f0cad3 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java @@ -1,132 +1,132 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.SetTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.DecrementAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.IncrementAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.PostDecrementAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.PostIncrementAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.SetLocalAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.PreDecrementAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.PreIncrementAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public abstract class SetLocalTypeIns extends InstructionDefinition implements SetTypeIns { - - public SetLocalTypeIns(int instructionCode, String instructionName, int[] operands) { - super(instructionCode, instructionName, operands); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { - int regId = getRegisterId(ins); - GraphTargetItem value = (GraphTargetItem) stack.pop(); - /*if (localRegs.containsKey(regId)) { - localRegs.put(regId, new NotCompileTimeAVM2Item(ins, value)); - } else { - localRegs.put(regId, value); - }*/ - localRegs.put(regId, value); - if (!regAssignCount.containsKey(regId)) { - regAssignCount.put(regId, 0); - } - regAssignCount.put(regId, regAssignCount.get(regId) + 1); - //localRegsAssignmentIps.put(regId, ip); - if (value instanceof NewActivationAVM2Item) { - return; - } - if (value instanceof FindPropertyAVM2Item) { - return; - } - if (value.getNotCoerced() instanceof IncrementAVM2Item) { - GraphTargetItem inside = ((IncrementAVM2Item) value.getNotCoerced()).value.getNotCoerced().getThroughDuplicate(); - if (inside instanceof LocalRegAVM2Item) { - if (((LocalRegAVM2Item) inside).regIndex == regId) { - if (stack.size() > 0) { - GraphTargetItem top = stack.peek().getNotCoerced().getThroughDuplicate(); - if (top == inside) { - stack.pop(); - stack.push(new PostIncrementAVM2Item(ins, inside)); - } else if ((top instanceof IncrementAVM2Item) && (((IncrementAVM2Item) top).value == inside)) { - stack.pop(); - stack.push(new PreIncrementAVM2Item(ins, inside)); - } else { - output.add(new PostIncrementAVM2Item(ins, inside)); - } - } else { - output.add(new PostIncrementAVM2Item(ins, inside)); - } - return; - } - } - } - - if (value.getNotCoerced() instanceof DecrementAVM2Item) { - GraphTargetItem inside = ((DecrementAVM2Item) value.getNotCoerced()).value.getNotCoerced().getThroughDuplicate(); - if (inside instanceof LocalRegAVM2Item) { - if (((LocalRegAVM2Item) inside).regIndex == regId) { - if (stack.size() > 0) { - GraphTargetItem top = stack.peek().getNotCoerced().getThroughDuplicate(); - if (top == inside) { - stack.pop(); - stack.push(new PostDecrementAVM2Item(ins, inside)); - } else if ((top instanceof DecrementAVM2Item) && (((DecrementAVM2Item) top).value == inside)) { - stack.pop(); - stack.push(new PreDecrementAVM2Item(ins, inside)); - } else { - output.add(new PostDecrementAVM2Item(ins, inside)); - } - } else { - output.add(new PostDecrementAVM2Item(ins, inside)); - } - return; - } - } - } - - //if(val.startsWith("catchscope ")) return; - //if(val.startsWith("newactivation()")) return; - output.add(new SetLocalAVM2Item(ins, regId, value)); - } - - @Override - public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { - return AVM2Item.localRegName(localRegNames, getRegisterId(ins)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } - - public abstract int getRegisterId(AVM2Instruction ins); -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.instructions.SetTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.DecrementAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.FindPropertyAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.IncrementAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.PostDecrementAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.PostIncrementAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.SetLocalAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.PreDecrementAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.PreIncrementAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public abstract class SetLocalTypeIns extends InstructionDefinition implements SetTypeIns { + + public SetLocalTypeIns(int instructionCode, String instructionName, int[] operands) { + super(instructionCode, instructionName, operands); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap regAssignCount, int ip, HashMap> refs, AVM2Code code) { + int regId = getRegisterId(ins); + GraphTargetItem value = stack.pop(); + /*if (localRegs.containsKey(regId)) { + localRegs.put(regId, new NotCompileTimeAVM2Item(ins, value)); + } else { + localRegs.put(regId, value); + }*/ + localRegs.put(regId, value); + if (!regAssignCount.containsKey(regId)) { + regAssignCount.put(regId, 0); + } + regAssignCount.put(regId, regAssignCount.get(regId) + 1); + //localRegsAssignmentIps.put(regId, ip); + if (value instanceof NewActivationAVM2Item) { + return; + } + if (value instanceof FindPropertyAVM2Item) { + return; + } + if (value.getNotCoerced() instanceof IncrementAVM2Item) { + GraphTargetItem inside = ((IncrementAVM2Item) value.getNotCoerced()).value.getNotCoerced().getThroughDuplicate(); + if (inside instanceof LocalRegAVM2Item) { + if (((LocalRegAVM2Item) inside).regIndex == regId) { + if (stack.size() > 0) { + GraphTargetItem top = stack.peek().getNotCoerced().getThroughDuplicate(); + if (top == inside) { + stack.pop(); + stack.push(new PostIncrementAVM2Item(ins, inside)); + } else if ((top instanceof IncrementAVM2Item) && (((IncrementAVM2Item) top).value == inside)) { + stack.pop(); + stack.push(new PreIncrementAVM2Item(ins, inside)); + } else { + output.add(new PostIncrementAVM2Item(ins, inside)); + } + } else { + output.add(new PostIncrementAVM2Item(ins, inside)); + } + return; + } + } + } + + if (value.getNotCoerced() instanceof DecrementAVM2Item) { + GraphTargetItem inside = ((DecrementAVM2Item) value.getNotCoerced()).value.getNotCoerced().getThroughDuplicate(); + if (inside instanceof LocalRegAVM2Item) { + if (((LocalRegAVM2Item) inside).regIndex == regId) { + if (stack.size() > 0) { + GraphTargetItem top = stack.peek().getNotCoerced().getThroughDuplicate(); + if (top == inside) { + stack.pop(); + stack.push(new PostDecrementAVM2Item(ins, inside)); + } else if ((top instanceof DecrementAVM2Item) && (((DecrementAVM2Item) top).value == inside)) { + stack.pop(); + stack.push(new PreDecrementAVM2Item(ins, inside)); + } else { + output.add(new PostDecrementAVM2Item(ins, inside)); + } + } else { + output.add(new PostDecrementAVM2Item(ins, inside)); + } + return; + } + } + } + + //if(val.startsWith("catchscope ")) return; + //if(val.startsWith("newactivation()")) return; + output.add(new SetLocalAVM2Item(ins, regId, value)); + } + + @Override + public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { + return AVM2Item.localRegName(localRegNames, getRegisterId(ins)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } + + public abstract int getRegisterId(AVM2Instruction ins); +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java index 52cc319ef..f57a48968 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/DeletePropertyIns.java @@ -1,73 +1,73 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.BooleanAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.DeletePropertyAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class DeletePropertyIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int multinameIndex = ins.operands[0]; - FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - stack.add(new BooleanAVM2Item(ins, Boolean.TRUE));//property successfully deleted - output.add(new DeletePropertyAVM2Item(ins, obj, multiname)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -1 + 1; - int multinameIndex = ins.operands[0]; - if (abc.constants.getMultiname(multinameIndex).needsName()) { - ret--; - } - if (abc.constants.getMultiname(multinameIndex).needsNs()) { - ret--; - } - return ret; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.BooleanAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.DeletePropertyAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class DeletePropertyIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int multinameIndex = ins.operands[0]; + FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem obj = stack.pop(); + stack.add(new BooleanAVM2Item(ins, Boolean.TRUE));//property successfully deleted + output.add(new DeletePropertyAVM2Item(ins, obj, multiname)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -1 + 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.getMultiname(multinameIndex).needsName()) { + ret--; + } + if (abc.constants.getMultiname(multinameIndex).needsNs()) { + ret--; + } + return ret; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindDefIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindDefIns.java index 3bbc86777..77d638624 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindDefIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindDefIns.java @@ -1,50 +1,50 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.FindDefAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.flash.abc.types.Multiname; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class FindDefIns extends InstructionDefinition { - - public FindDefIns() { - super(0x5f, "finddef", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int multinameIndex = ins.operands[0]; - Multiname multiname = constants.getMultiname(multinameIndex); - stack.push(new FindDefAVM2Item(ins, multiname)); - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 1; //multiname may not be runtime - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.FindDefAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.flash.abc.types.Multiname; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class FindDefIns extends InstructionDefinition { + + public FindDefIns() { + super(0x5f, "finddef", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int multinameIndex = ins.operands[0]; + Multiname multiname = constants.getMultiname(multinameIndex); + stack.push(new FindDefAVM2Item(ins, multiname)); + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 1; //multiname may not be runtime + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyIns.java index fcb9e0a20..0e3a3f4f0 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyIns.java @@ -1,68 +1,68 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.FindPropertyAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class FindPropertyIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int multinameIndex = ins.operands[0]; - FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); - stack.push(new FindPropertyAVM2Item(ins, multiname)); //resolve right object - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = 1; - int multinameIndex = ins.operands[0]; - if (abc.constants.getMultiname(multinameIndex).needsName()) { - ret--; - } - if (abc.constants.getMultiname(multinameIndex).needsNs()) { - ret--; - } - return ret; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.FindPropertyAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class FindPropertyIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int multinameIndex = ins.operands[0]; + FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); + stack.push(new FindPropertyAVM2Item(ins, multiname)); //resolve right object + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.getMultiname(multinameIndex).needsName()) { + ret--; + } + if (abc.constants.getMultiname(multinameIndex).needsNs()) { + ret--; + } + return ret; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyStrictIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyStrictIns.java index 3da8ee078..16e404837 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyStrictIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/FindPropertyStrictIns.java @@ -1,67 +1,67 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.FindPropertyAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class FindPropertyStrictIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int multinameIndex = ins.operands[0]; - FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); - stack.push(new FindPropertyAVM2Item(ins, multiname)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = 1; - int multinameIndex = ins.operands[0]; - if (abc.constants.getMultiname(multinameIndex).needsName()) { - ret--; - } - if (abc.constants.getMultiname(multinameIndex).needsNs()) { - ret--; - } - return ret; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.FindPropertyAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class FindPropertyStrictIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int multinameIndex = ins.operands[0]; + FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); + stack.push(new FindPropertyAVM2Item(ins, multiname)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.getMultiname(multinameIndex).needsName()) { + ret--; + } + if (abc.constants.getMultiname(multinameIndex).needsNs()) { + ret--; + } + return ret; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java index 627341f44..5b87806cf 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java @@ -1,69 +1,69 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.GetDescendantsAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class GetDescendantsIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int multinameIndex = ins.operands[0]; - FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - stack.push(new GetDescendantsAVM2Item(ins, obj, multiname)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -1 + 1; - int multinameIndex = ins.operands[0]; - if (abc.constants.getMultiname(multinameIndex).needsName()) { - ret--; - } - if (abc.constants.getMultiname(multinameIndex).needsNs()) { - ret--; - } - return ret; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.GetDescendantsAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class GetDescendantsIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int multinameIndex = ins.operands[0]; + FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem obj = stack.pop(); + stack.push(new GetDescendantsAVM2Item(ins, obj, multiname)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -1 + 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.getMultiname(multinameIndex).needsName()) { + ret--; + } + if (abc.constants.getMultiname(multinameIndex).needsNs()) { + ret--; + } + return ret; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java index 00ae12161..5ee495e77 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java @@ -1,62 +1,62 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.ClassAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.ScriptAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class GetGlobalScopeIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - if (scopeStack.isEmpty()) { - if (classIndex == -1) { - stack.push(new ScriptAVM2Item(scriptIndex)); - } else { - stack.push(new ClassAVM2Item(abc.instance_info.get(classIndex).getName(constants))); - } - return; - } - stack.push(scopeStack.get(0)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.ClassAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.ScriptAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class GetGlobalScopeIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + if (scopeStack.isEmpty()) { + if (classIndex == -1) { + stack.push(new ScriptAVM2Item(scriptIndex)); + } else { + stack.push(new ClassAVM2Item(abc.instance_info.get(classIndex).getName(constants))); + } + return; + } + stack.push(scopeStack.get(0)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java index cbfe5d1f3..b98dd89ad 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalSlotIns.java @@ -1,66 +1,66 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.GetSlotAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.flash.abc.types.Multiname; -import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class GetGlobalSlotIns extends InstructionDefinition { - - public GetGlobalSlotIns() { - super(0x6e, "getglobalslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int slotIndex = ins.operands[0]; - GraphTargetItem obj = (GraphTargetItem) scopeStack.get(0); //scope - Multiname slotname = null; - if (obj instanceof ExceptionAVM2Item) { - slotname = constants.getMultiname(((ExceptionAVM2Item) obj).exception.name_index); - } else { - - for (int t = 0; t < body.traits.traits.size(); t++) { - if (body.traits.traits.get(t) instanceof TraitSlotConst) { - if (((TraitSlotConst) body.traits.traits.get(t)).slot_id == slotIndex) { - slotname = body.traits.traits.get(t).getName(abc); - } - } - - } - } - stack.push(new GetSlotAVM2Item(ins, obj, slotname)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.GetSlotAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.flash.abc.types.Multiname; +import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class GetGlobalSlotIns extends InstructionDefinition { + + public GetGlobalSlotIns() { + super(0x6e, "getglobalslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int slotIndex = ins.operands[0]; + GraphTargetItem obj = scopeStack.get(0); //scope + Multiname slotname = null; + if (obj instanceof ExceptionAVM2Item) { + slotname = constants.getMultiname(((ExceptionAVM2Item) obj).exception.name_index); + } else { + + for (int t = 0; t < body.traits.traits.size(); t++) { + if (body.traits.traits.get(t) instanceof TraitSlotConst) { + if (((TraitSlotConst) body.traits.traits.get(t)).slot_id == slotIndex) { + slotname = body.traits.traits.get(t).getName(abc); + } + } + + } + } + stack.push(new GetSlotAVM2Item(ins, obj, slotname)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java index c3e63de0a..97c4d05f4 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetLexIns.java @@ -1,51 +1,51 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.flash.abc.types.Multiname; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class GetLexIns extends InstructionDefinition { - - public GetLexIns() { - super(0x60, "getlex", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int multinameIndex = ins.operands[0]; - Multiname multiname = constants.getMultiname(multinameIndex); - stack.push(new GetLexAVM2Item(ins, multiname)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } - -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.GetLexAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.flash.abc.types.Multiname; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class GetLexIns extends InstructionDefinition { + + public GetLexIns() { + super(0x60, "getlex", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int multinameIndex = ins.operands[0]; + Multiname multiname = constants.getMultiname(multinameIndex); + stack.push(new GetLexAVM2Item(ins, multiname)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } + +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java index 9271a599e..7853cd4f0 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetPropertyIns.java @@ -1,64 +1,64 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class GetPropertyIns extends InstructionDefinition { - - public GetPropertyIns() { - super(0x66, "getproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int multinameIndex = ins.operands[0]; - FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - stack.push(new GetPropertyAVM2Item(ins, obj, multiname)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -1 + 1; - int multinameIndex = ins.operands[0]; - //Note: In official compiler, the stack can be wrong(greater) for some MULTINAMEL/A, e.g. increments - /* - var arr=[1,2,3]; - return arr[2]++; - */ - if (abc.constants.getMultiname(multinameIndex).needsName()) { - ret--; - } - if (abc.constants.getMultiname(multinameIndex).needsNs()) { - ret--; - } - return ret; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class GetPropertyIns extends InstructionDefinition { + + public GetPropertyIns() { + super(0x66, "getproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int multinameIndex = ins.operands[0]; + FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem obj = stack.pop(); + stack.push(new GetPropertyAVM2Item(ins, obj, multiname)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -1 + 1; + int multinameIndex = ins.operands[0]; + //Note: In official compiler, the stack can be wrong(greater) for some MULTINAMEL/A, e.g. increments + /* + var arr=[1,2,3]; + return arr[2]++; + */ + if (abc.constants.getMultiname(multinameIndex).needsName()) { + ret--; + } + if (abc.constants.getMultiname(multinameIndex).needsNs()) { + ret--; + } + return ret; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetScopeObjectIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetScopeObjectIns.java index 543c575e1..190e50cdb 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetScopeObjectIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetScopeObjectIns.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class GetScopeObjectIns extends InstructionDefinition { - - public GetScopeObjectIns() { - super(0x65, "getscopeobject", new int[]{AVM2Code.DAT_SLOT_SCOPE_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int index = ins.operands[0]; - stack.push(scopeStack.get(index)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class GetScopeObjectIns extends InstructionDefinition { + + public GetScopeObjectIns() { + super(0x65, "getscopeobject", new int[]{AVM2Code.DAT_SLOT_SCOPE_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int index = ins.operands[0]; + stack.push(scopeStack.get(index)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java index cacaf34e8..a26fb17c6 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSlotIns.java @@ -1,85 +1,85 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.ClassAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.GetSlotAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.ScriptAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.flash.abc.types.Multiname; -import com.jpexs.decompiler.flash.abc.types.traits.Trait; -import com.jpexs.decompiler.flash.abc.types.traits.TraitWithSlot; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class GetSlotIns extends InstructionDefinition { - - public GetSlotIns() { - super(0x6c, "getslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int slotIndex = ins.operands[0]; - GraphTargetItem obj = (GraphTargetItem) stack.pop(); //scope - obj = obj.getThroughRegister(); - Multiname slotname = null; - if (obj instanceof ExceptionAVM2Item) { - slotname = constants.getMultiname(((ExceptionAVM2Item) obj).exception.name_index); - } else if (obj instanceof ClassAVM2Item) { - slotname = ((ClassAVM2Item) obj).className; - } else if (obj instanceof ThisAVM2Item) { - slotname = ((ThisAVM2Item) obj).className; - } else if (obj instanceof ScriptAVM2Item) { - for (int t = 0; t < abc.script_info.get(((ScriptAVM2Item) obj).scriptIndex).traits.traits.size(); t++) { - Trait tr = abc.script_info.get(((ScriptAVM2Item) obj).scriptIndex).traits.traits.get(t); - if (tr instanceof TraitWithSlot) { - if (((TraitWithSlot) tr).getSlotIndex() == slotIndex) { - slotname = tr.getName(abc); - } - } - } - } else if (obj instanceof NewActivationAVM2Item) { - - for (int t = 0; t < body.traits.traits.size(); t++) { - if (body.traits.traits.get(t) instanceof TraitWithSlot) { - if (((TraitWithSlot) body.traits.traits.get(t)).getSlotIndex() == slotIndex) { - slotname = body.traits.traits.get(t).getName(abc); - } - } - - } - } - stack.push(new GetSlotAVM2Item(ins, obj, slotname)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.ClassAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.GetSlotAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.ScriptAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.flash.abc.types.Multiname; +import com.jpexs.decompiler.flash.abc.types.traits.Trait; +import com.jpexs.decompiler.flash.abc.types.traits.TraitWithSlot; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class GetSlotIns extends InstructionDefinition { + + public GetSlotIns() { + super(0x6c, "getslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int slotIndex = ins.operands[0]; + GraphTargetItem obj = stack.pop(); //scope + obj = obj.getThroughRegister(); + Multiname slotname = null; + if (obj instanceof ExceptionAVM2Item) { + slotname = constants.getMultiname(((ExceptionAVM2Item) obj).exception.name_index); + } else if (obj instanceof ClassAVM2Item) { + slotname = ((ClassAVM2Item) obj).className; + } else if (obj instanceof ThisAVM2Item) { + slotname = ((ThisAVM2Item) obj).className; + } else if (obj instanceof ScriptAVM2Item) { + for (int t = 0; t < abc.script_info.get(((ScriptAVM2Item) obj).scriptIndex).traits.traits.size(); t++) { + Trait tr = abc.script_info.get(((ScriptAVM2Item) obj).scriptIndex).traits.traits.get(t); + if (tr instanceof TraitWithSlot) { + if (((TraitWithSlot) tr).getSlotIndex() == slotIndex) { + slotname = tr.getName(abc); + } + } + } + } else if (obj instanceof NewActivationAVM2Item) { + + for (int t = 0; t < body.traits.traits.size(); t++) { + if (body.traits.traits.get(t) instanceof TraitWithSlot) { + if (((TraitWithSlot) body.traits.traits.get(t)).getSlotIndex() == slotIndex) { + slotname = body.traits.traits.get(t).getName(abc); + } + } + + } + } + stack.push(new GetSlotAVM2Item(ins, obj, slotname)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSuperIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSuperIns.java index 7040dbdf8..1202bc2f0 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSuperIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetSuperIns.java @@ -1,59 +1,59 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.GetSuperAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class GetSuperIns extends InstructionDefinition { - - public GetSuperIns() { - super(0x04, "getsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int multinameIndex = ins.operands[0]; - FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - stack.push(new GetSuperAVM2Item(ins, obj, multiname)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -1 + 1; - int multinameIndex = ins.operands[0]; - if (abc.constants.getMultiname(multinameIndex).needsName()) { - ret--; - } - if (abc.constants.getMultiname(multinameIndex).needsNs()) { - ret--; - } - return ret; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.GetSuperAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class GetSuperIns extends InstructionDefinition { + + public GetSuperIns() { + super(0x04, "getsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int multinameIndex = ins.operands[0]; + FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem obj = stack.pop(); + stack.push(new GetSuperAVM2Item(ins, obj, multiname)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -1 + 1; + int multinameIndex = ins.operands[0]; + if (abc.constants.getMultiname(multinameIndex).needsName()) { + ret--; + } + if (abc.constants.getMultiname(multinameIndex).needsNs()) { + ret--; + } + return ret; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNext2Ins.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNext2Ins.java index 7985852a9..41f229df2 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNext2Ins.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNext2Ins.java @@ -1,52 +1,52 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.HasNextAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class HasNext2Ins extends InstructionDefinition { - - public HasNext2Ins() { - super(0x32, "hasnext2", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX, AVM2Code.DAT_LOCAL_REG_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int objectReg = ins.operands[0]; - int indexReg = ins.operands[1]; - //stack.push("_loc_" + objectReg + ".hasNext(cnt=_loc_" + indexReg + ")"); - stack.push(new HasNextAVM2Item(ins, new LocalRegAVM2Item(ins, indexReg, localRegs.get(indexReg)), localRegs.get(objectReg))); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } - -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.HasNextAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class HasNext2Ins extends InstructionDefinition { + + public HasNext2Ins() { + super(0x32, "hasnext2", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX, AVM2Code.DAT_LOCAL_REG_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int objectReg = ins.operands[0]; + int indexReg = ins.operands[1]; + //stack.push("_loc_" + objectReg + ".hasNext(cnt=_loc_" + indexReg + ")"); + stack.push(new HasNextAVM2Item(ins, new LocalRegAVM2Item(ins, indexReg, localRegs.get(indexReg)), localRegs.get(objectReg))); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } + +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNextIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNextIns.java index 9212eadaf..8cba888f9 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNextIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/HasNextIns.java @@ -1,50 +1,50 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.HasNextAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class HasNextIns extends InstructionDefinition { - - public HasNextIns() { - super(0x1f, "hasnext", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem curIndex = (GraphTargetItem) stack.pop(); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - stack.push(new HasNextAVM2Item(ins, curIndex, obj)); - - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.HasNextAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class HasNextIns extends InstructionDefinition { + + public HasNextIns() { + super(0x1f, "hasnext", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem curIndex = stack.pop(); + GraphTargetItem obj = stack.pop(); + stack.push(new HasNextAVM2Item(ins, curIndex, obj)); + + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InIns.java index 607b7b88a..fcbccc91c 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.InAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class InIns extends InstructionDefinition { - - public InIns() { - super(0xb4, "in", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - GraphTargetItem name = (GraphTargetItem) stack.pop(); - stack.push(new InAVM2Item(ins, name, obj)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.InAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class InIns extends InstructionDefinition { + + public InIns() { + super(0xb4, "in", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem obj = stack.pop(); + GraphTargetItem name = stack.pop(); + stack.push(new InAVM2Item(ins, name, obj)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java index ff8646774..f2ef6d8b7 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/InitPropertyIns.java @@ -1,61 +1,61 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.InitPropertyAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class InitPropertyIns extends InstructionDefinition { - - public InitPropertyIns() { - super(0x68, "initproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int multinameIndex = ins.operands[0]; - - GraphTargetItem val = (GraphTargetItem) stack.pop(); - FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - output.add(new InitPropertyAVM2Item(ins, obj, multiname, val)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -2; - int multinameIndex = ins.operands[0]; - if (abc.constants.getMultiname(multinameIndex).needsName()) { - ret--; - } - if (abc.constants.getMultiname(multinameIndex).needsNs()) { - ret--; - } - return ret; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.InitPropertyAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class InitPropertyIns extends InstructionDefinition { + + public InitPropertyIns() { + super(0x68, "initproperty", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int multinameIndex = ins.operands[0]; + + GraphTargetItem val = stack.pop(); + FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem obj = stack.pop(); + output.add(new InitPropertyAVM2Item(ins, obj, multiname, val)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -2; + int multinameIndex = ins.operands[0]; + if (abc.constants.getMultiname(multinameIndex).needsName()) { + ret--; + } + if (abc.constants.getMultiname(multinameIndex).needsNs()) { + ret--; + } + return ret; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextNameIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextNameIns.java index 12d70bbf2..91fb92946 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextNameIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextNameIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.NextNameAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class NextNameIns extends InstructionDefinition { - - public NextNameIns() { - super(0x1e, "nextname", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem index = stack.pop(); - GraphTargetItem obj = stack.pop(); - stack.push(new NextNameAVM2Item(ins, index, obj)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.NextNameAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class NextNameIns extends InstructionDefinition { + + public NextNameIns() { + super(0x1e, "nextname", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem index = stack.pop(); + GraphTargetItem obj = stack.pop(); + stack.push(new NextNameAVM2Item(ins, index, obj)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextValueIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextValueIns.java index 0d3d0907c..1381be249 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextValueIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/NextValueIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.NextValueAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class NextValueIns extends InstructionDefinition { - - public NextValueIns() { - super(0x23, "nextvalue", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem index = stack.pop(); - GraphTargetItem obj = stack.pop(); - stack.push(new NextValueAVM2Item(ins, index, obj)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.NextValueAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class NextValueIns extends InstructionDefinition { + + public NextValueIns() { + super(0x23, "nextvalue", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem index = stack.pop(); + GraphTargetItem obj = stack.pop(); + stack.push(new NextValueAVM2Item(ins, index, obj)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnValueIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnValueIns.java index 454d67747..c5a436e44 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnValueIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnValueIns.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.ReturnValueAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ReturnValueIns extends InstructionDefinition { - - public ReturnValueIns() { - super(0x48, "returnvalue", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - output.add(new ReturnValueAVM2Item(ins, (GraphTargetItem) stack.pop())); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.ReturnValueAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ReturnValueIns extends InstructionDefinition { + + public ReturnValueIns() { + super(0x48, "returnvalue", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + output.add(new ReturnValueAVM2Item(ins, stack.pop())); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnVoidIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnVoidIns.java index 275ea8798..f5336da17 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnVoidIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ReturnVoidIns.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.ReturnVoidAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ReturnVoidIns extends InstructionDefinition { - - public ReturnVoidIns() { - super(0x47, "returnvoid", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - output.add(new ReturnVoidAVM2Item(ins)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.ReturnVoidAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ReturnVoidIns extends InstructionDefinition { + + public ReturnVoidIns() { + super(0x47, "returnvoid", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + output.add(new ReturnVoidAVM2Item(ins)); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetGlobalSlotIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetGlobalSlotIns.java index c4fd6c634..9680d76ae 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetGlobalSlotIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetGlobalSlotIns.java @@ -1,54 +1,54 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.SetTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.SetGlobalSlotAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class SetGlobalSlotIns extends InstructionDefinition implements SetTypeIns { - - public SetGlobalSlotIns() { - super(0x6f, "setglobalslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - output.add(new SetGlobalSlotAVM2Item(ins, ins.operands[0], (GraphTargetItem) stack.pop())); - } - - @Override - public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { - return "globalslot" + ins.operands[0]; - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.instructions.SetTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.SetGlobalSlotAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class SetGlobalSlotIns extends InstructionDefinition implements SetTypeIns { + + public SetGlobalSlotIns() { + super(0x6f, "setglobalslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + output.add(new SetGlobalSlotAVM2Item(ins, ins.operands[0], stack.pop())); + } + + @Override + public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, MethodBody body, HashMap localRegNames, List fullyQualifiedNames) { + return "globalslot" + ins.operands[0]; + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java index f8492db12..366864104 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetPropertyIns.java @@ -51,11 +51,11 @@ public class SetPropertyIns extends InstructionDefinition implements SetTypeIns } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; - GraphTargetItem value = (GraphTargetItem) stack.pop(); + GraphTargetItem value = stack.pop(); FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); + GraphTargetItem obj = stack.pop(); if (value.getThroughDuplicate().getThroughRegister().getThroughDuplicate() instanceof IncrementAVM2Item) { GraphTargetItem inside = ((IncrementAVM2Item) value.getThroughDuplicate().getThroughRegister().getThroughDuplicate()).value.getThroughRegister().getNotCoerced().getThroughDuplicate(); if (inside instanceof GetPropertyAVM2Item) { diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java index 4e966be9c..649f278cd 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSlotIns.java @@ -1,181 +1,181 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.SetTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.ClassAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.DecrementAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.GetSlotAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.IncrementAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.PostDecrementAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.PostIncrementAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.ScriptAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.SetSlotAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.PreDecrementAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.PreIncrementAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.flash.abc.types.Multiname; -import com.jpexs.decompiler.flash.abc.types.traits.Trait; -import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; -import com.jpexs.decompiler.flash.abc.types.traits.TraitWithSlot; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class SetSlotIns extends InstructionDefinition implements SetTypeIns { - - public SetSlotIns() { - super(0x6d, "setslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int slotIndex = ins.operands[0]; - GraphTargetItem value = (GraphTargetItem) stack.pop(); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); //scopeId - GraphTargetItem objnoreg = obj; - obj = obj.getThroughRegister(); - Multiname slotname = null; - if (obj instanceof NewActivationAVM2Item) { - ((NewActivationAVM2Item) obj).slots.put(slotIndex, value); - } - - if (obj instanceof ExceptionAVM2Item) { - slotname = constants.getMultiname(((ExceptionAVM2Item) obj).exception.name_index); - } else if (obj instanceof ClassAVM2Item) { - slotname = ((ClassAVM2Item) obj).className; - } else if (obj instanceof ThisAVM2Item) { - slotname = ((ThisAVM2Item) obj).className; - } else if (obj instanceof ScriptAVM2Item) { - for (int t = 0; t < abc.script_info.get(((ScriptAVM2Item) obj).scriptIndex).traits.traits.size(); t++) { - Trait tr = abc.script_info.get(((ScriptAVM2Item) obj).scriptIndex).traits.traits.get(t); - if (tr instanceof TraitWithSlot) { - if (((TraitWithSlot) tr).getSlotIndex() == slotIndex) { - slotname = tr.getName(abc); - } - } - } - } else if (obj instanceof NewActivationAVM2Item) { - - for (int t = 0; t < body.traits.traits.size(); t++) { - if (body.traits.traits.get(t) instanceof TraitWithSlot) { - if (((TraitWithSlot) body.traits.traits.get(t)).getSlotIndex() == slotIndex) { - slotname = body.traits.traits.get(t).getName(abc); - } - } - - } - } - - if (slotname != null) { - if (value instanceof LocalRegAVM2Item) { - LocalRegAVM2Item lr = (LocalRegAVM2Item) value; - String slotNameStr = slotname.getName(constants, fullyQualifiedNames); - if (localRegNames.containsKey(lr.regIndex)) { - if (localRegNames.get(lr.regIndex).equals(slotNameStr)) { - return; //Register with same name to slot - } - } - } - } - - if (value.getNotCoerced().getThroughDuplicate() instanceof IncrementAVM2Item) { - GraphTargetItem inside = ((IncrementAVM2Item) value.getNotCoerced()).value.getThroughRegister().getNotCoerced().getThroughDuplicate(); - if (inside instanceof GetSlotAVM2Item) { - GetSlotAVM2Item slotItem = (GetSlotAVM2Item) inside; - if ((slotItem.scope.getThroughRegister() == obj.getThroughRegister()) - && (slotItem.slotName == slotname)) { - if (stack.size() > 0) { - GraphTargetItem top = stack.peek().getNotCoerced().getThroughDuplicate(); - if (top == inside) { - stack.pop(); - stack.push(new PostIncrementAVM2Item(ins, inside)); - } else if ((top instanceof IncrementAVM2Item) && (((IncrementAVM2Item) top).value == inside)) { - stack.pop(); - stack.push(new PreIncrementAVM2Item(ins, inside)); - } else { - output.add(new PostIncrementAVM2Item(ins, inside)); - } - } else { - output.add(new PostIncrementAVM2Item(ins, inside)); - } - return; - } - } - } - - if (value.getNotCoerced().getThroughDuplicate() instanceof DecrementAVM2Item) { - GraphTargetItem inside = ((DecrementAVM2Item) value.getNotCoerced()).value.getThroughRegister().getNotCoerced().getThroughDuplicate(); - if (inside instanceof GetSlotAVM2Item) { - GetSlotAVM2Item slotItem = (GetSlotAVM2Item) inside; - if ((slotItem.scope.getThroughRegister() == obj.getThroughRegister()) - && (slotItem.slotName == slotname)) { - if (stack.size() > 0) { - GraphTargetItem top = stack.peek().getNotCoerced().getThroughDuplicate(); - if (top == inside) { - stack.pop(); - stack.push(new PostDecrementAVM2Item(ins, inside)); - } else if ((top instanceof DecrementAVM2Item) && (((DecrementAVM2Item) top).value == inside)) { - stack.pop(); - stack.push(new PreDecrementAVM2Item(ins, inside)); - } else { - output.add(new PostDecrementAVM2Item(ins, inside)); - } - } else { - output.add(new PostDecrementAVM2Item(ins, inside)); - } - return; - } - } - } - - output.add(new SetSlotAVM2Item(ins, obj, slotname, value)); - } - - @Override - public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, 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.size(); t++) { - if (body.traits.traits.get(t) instanceof TraitSlotConst) { - if (((TraitSlotConst) body.traits.traits.get(t)).slot_id == slotIndex) { - slotname = body.traits.traits.get(t).getName(abc).getName(abc.constants, fullyQualifiedNames); - } - } - - } - return slotname; - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.instructions.SetTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.ClassAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.DecrementAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.GetSlotAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.IncrementAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.NewActivationAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.PostDecrementAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.PostIncrementAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.ScriptAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.SetSlotAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.clauses.ExceptionAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.PreDecrementAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.PreIncrementAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.flash.abc.types.Multiname; +import com.jpexs.decompiler.flash.abc.types.traits.Trait; +import com.jpexs.decompiler.flash.abc.types.traits.TraitSlotConst; +import com.jpexs.decompiler.flash.abc.types.traits.TraitWithSlot; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class SetSlotIns extends InstructionDefinition implements SetTypeIns { + + public SetSlotIns() { + super(0x6d, "setslot", new int[]{AVM2Code.DAT_SLOT_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int slotIndex = ins.operands[0]; + GraphTargetItem value = stack.pop(); + GraphTargetItem obj = stack.pop(); //scopeId + GraphTargetItem objnoreg = obj; + obj = obj.getThroughRegister(); + Multiname slotname = null; + if (obj instanceof NewActivationAVM2Item) { + ((NewActivationAVM2Item) obj).slots.put(slotIndex, value); + } + + if (obj instanceof ExceptionAVM2Item) { + slotname = constants.getMultiname(((ExceptionAVM2Item) obj).exception.name_index); + } else if (obj instanceof ClassAVM2Item) { + slotname = ((ClassAVM2Item) obj).className; + } else if (obj instanceof ThisAVM2Item) { + slotname = ((ThisAVM2Item) obj).className; + } else if (obj instanceof ScriptAVM2Item) { + for (int t = 0; t < abc.script_info.get(((ScriptAVM2Item) obj).scriptIndex).traits.traits.size(); t++) { + Trait tr = abc.script_info.get(((ScriptAVM2Item) obj).scriptIndex).traits.traits.get(t); + if (tr instanceof TraitWithSlot) { + if (((TraitWithSlot) tr).getSlotIndex() == slotIndex) { + slotname = tr.getName(abc); + } + } + } + } else if (obj instanceof NewActivationAVM2Item) { + + for (int t = 0; t < body.traits.traits.size(); t++) { + if (body.traits.traits.get(t) instanceof TraitWithSlot) { + if (((TraitWithSlot) body.traits.traits.get(t)).getSlotIndex() == slotIndex) { + slotname = body.traits.traits.get(t).getName(abc); + } + } + + } + } + + if (slotname != null) { + if (value instanceof LocalRegAVM2Item) { + LocalRegAVM2Item lr = (LocalRegAVM2Item) value; + String slotNameStr = slotname.getName(constants, fullyQualifiedNames); + if (localRegNames.containsKey(lr.regIndex)) { + if (localRegNames.get(lr.regIndex).equals(slotNameStr)) { + return; //Register with same name to slot + } + } + } + } + + if (value.getNotCoerced().getThroughDuplicate() instanceof IncrementAVM2Item) { + GraphTargetItem inside = ((IncrementAVM2Item) value.getNotCoerced()).value.getThroughRegister().getNotCoerced().getThroughDuplicate(); + if (inside instanceof GetSlotAVM2Item) { + GetSlotAVM2Item slotItem = (GetSlotAVM2Item) inside; + if ((slotItem.scope.getThroughRegister() == obj.getThroughRegister()) + && (slotItem.slotName == slotname)) { + if (stack.size() > 0) { + GraphTargetItem top = stack.peek().getNotCoerced().getThroughDuplicate(); + if (top == inside) { + stack.pop(); + stack.push(new PostIncrementAVM2Item(ins, inside)); + } else if ((top instanceof IncrementAVM2Item) && (((IncrementAVM2Item) top).value == inside)) { + stack.pop(); + stack.push(new PreIncrementAVM2Item(ins, inside)); + } else { + output.add(new PostIncrementAVM2Item(ins, inside)); + } + } else { + output.add(new PostIncrementAVM2Item(ins, inside)); + } + return; + } + } + } + + if (value.getNotCoerced().getThroughDuplicate() instanceof DecrementAVM2Item) { + GraphTargetItem inside = ((DecrementAVM2Item) value.getNotCoerced()).value.getThroughRegister().getNotCoerced().getThroughDuplicate(); + if (inside instanceof GetSlotAVM2Item) { + GetSlotAVM2Item slotItem = (GetSlotAVM2Item) inside; + if ((slotItem.scope.getThroughRegister() == obj.getThroughRegister()) + && (slotItem.slotName == slotname)) { + if (stack.size() > 0) { + GraphTargetItem top = stack.peek().getNotCoerced().getThroughDuplicate(); + if (top == inside) { + stack.pop(); + stack.push(new PostDecrementAVM2Item(ins, inside)); + } else if ((top instanceof DecrementAVM2Item) && (((DecrementAVM2Item) top).value == inside)) { + stack.pop(); + stack.push(new PreDecrementAVM2Item(ins, inside)); + } else { + output.add(new PostDecrementAVM2Item(ins, inside)); + } + } else { + output.add(new PostDecrementAVM2Item(ins, inside)); + } + return; + } + } + } + + output.add(new SetSlotAVM2Item(ins, obj, slotname, value)); + } + + @Override + public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, 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.size(); t++) { + if (body.traits.traits.get(t) instanceof TraitSlotConst) { + if (((TraitSlotConst) body.traits.traits.get(t)).slot_id == slotIndex) { + slotname = body.traits.traits.get(t).getName(abc).getName(abc.constants, fullyQualifiedNames); + } + } + + } + return slotname; + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java index dae44658a..7009dfad9 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/SetSuperIns.java @@ -1,76 +1,76 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.instructions.SetTypeIns; -import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.SetSuperAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.flash.configuration.Configuration; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.model.LocalData; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class SetSuperIns extends InstructionDefinition implements SetTypeIns { - - public SetSuperIns() { - super(0x05, "setsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int multinameIndex = ins.operands[0]; - - GraphTargetItem value = (GraphTargetItem) stack.pop(); - FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); - GraphTargetItem obj = (GraphTargetItem) stack.pop(); - output.add(new SetSuperAVM2Item(ins, value, obj, multiname)); - } - - @Override - public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, MethodBody body, HashMap localRegNames, List fullyQualifiedNames) throws InterruptedException { - int multinameIndex = ins.operands[0]; - String multiname = resolveMultinameNoPop(1, stack, abc.constants, multinameIndex, ins, fullyQualifiedNames); - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); - stack.get(1 + resolvedCount(abc.constants, multinameIndex)).toString(writer, LocalData.create(abc.constants, localRegNames, fullyQualifiedNames)); - String obj = writer.toString(); - return obj + ".super." + multiname; - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - int ret = -2; - int multinameIndex = ins.operands[0]; - if (abc.constants.getMultiname(multinameIndex).needsName()) { - ret--; - } - if (abc.constants.getMultiname(multinameIndex).needsNs()) { - ret--; - } - return ret; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.instructions.SetTypeIns; +import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.SetSuperAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.model.LocalData; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class SetSuperIns extends InstructionDefinition implements SetTypeIns { + + public SetSuperIns() { + super(0x05, "setsuper", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int multinameIndex = ins.operands[0]; + + GraphTargetItem value = stack.pop(); + FullMultinameAVM2Item multiname = resolveMultiname(stack, constants, multinameIndex, ins); + GraphTargetItem obj = stack.pop(); + output.add(new SetSuperAVM2Item(ins, value, obj, multiname)); + } + + @Override + public String getObject(Stack stack, ABC abc, AVM2Instruction ins, List output, MethodBody body, HashMap localRegNames, List fullyQualifiedNames) throws InterruptedException { + int multinameIndex = ins.operands[0]; + String multiname = resolveMultinameNoPop(1, stack, abc.constants, multinameIndex, ins, fullyQualifiedNames); + HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); + stack.get(1 + resolvedCount(abc.constants, multinameIndex)).toString(writer, LocalData.create(abc.constants, localRegNames, fullyQualifiedNames)); + String obj = writer.toString(); + return obj + ".super." + multiname; + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + int ret = -2; + int multinameIndex = ins.operands[0]; + if (abc.constants.getMultiname(multinameIndex).needsName()) { + ret--; + } + if (abc.constants.getMultiname(multinameIndex).needsNs()) { + ret--; + } + return ret; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ThrowIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ThrowIns.java index 80e32d32d..904aafffe 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ThrowIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ThrowIns.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.other; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.ThrowAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ThrowIns extends InstructionDefinition { - - public ThrowIns() { - super(0x03, "throw", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - output.add(new ThrowAVM2Item(ins, (GraphTargetItem) stack.pop())); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.other; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.ThrowAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ThrowIns extends InstructionDefinition { + + public ThrowIns() { + super(0x03, "throw", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + output.add(new ThrowAVM2Item(ins, stack.pop())); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/DupIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/DupIns.java index ded77249f..069a343ef 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/DupIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/DupIns.java @@ -1,59 +1,59 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.model.DuplicateItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class DupIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem v = stack.pop(); - stack.push(v); - stack.push(new DuplicateItem(ins, v)); - //v.moreSrc.add(new GraphSourceItemPos(ins, 0)); - - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 2; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.model.DuplicateItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class DupIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem v = stack.pop(); + stack.push(v); + stack.push(new DuplicateItem(ins, v)); + //v.moreSrc.add(new GraphSourceItemPos(ins, 0)); + + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 2; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopIns.java index ebe8afa84..27756f7a9 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopIns.java @@ -22,13 +22,7 @@ import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; 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.avm2.model.CallAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.CallMethodAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.CallPropertyAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.CallStaticAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.CallSuperAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.clauses.AssignmentAVM2Item; import com.jpexs.decompiler.flash.abc.types.MethodBody; import com.jpexs.decompiler.flash.abc.types.MethodInfo; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -48,7 +42,7 @@ public class PopIns extends InstructionDefinition { } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { if (stack.size() > 0) { GraphTargetItem top = stack.pop(); //Note: Commands like "5;" - numbers are unsupported as it collide with try..finally block decompilation. TODO: allow this somehow diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopScopeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopScopeIns.java index 26f90ca58..ac5cff751 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopScopeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PopScopeIns.java @@ -1,58 +1,58 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.WithEndAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.WithObjectAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class PopScopeIns extends InstructionDefinition { - - public PopScopeIns() { - super(0x1d, "popscope", new int[]{}); - } - - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - lda.scopeStack.pop(); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem scope = (GraphTargetItem) scopeStack.pop(); - if (scope instanceof WithObjectAVM2Item) { - scope = ((WithObjectAVM2Item) scope).scope; - output.add(new WithEndAVM2Item(ins, scope)); - } - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.WithEndAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.WithObjectAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class PopScopeIns extends InstructionDefinition { + + public PopScopeIns() { + super(0x1d, "popscope", new int[]{}); + } + + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + lda.scopeStack.pop(); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem scope = scopeStack.pop(); + if (scope instanceof WithObjectAVM2Item) { + scope = ((WithObjectAVM2Item) scope).scope; + output.add(new WithEndAVM2Item(ins, scope)); + } + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushByteIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushByteIns.java index 670740d4a..727cab0db 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushByteIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushByteIns.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.IntegerValueAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class PushByteIns extends InstructionDefinition implements PushIntegerTypeIns { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new IntegerValueAVM2Item(ins, Long.valueOf(ins.operands[0]))); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.IntegerValueAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class PushByteIns extends InstructionDefinition implements PushIntegerTypeIns { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new IntegerValueAVM2Item(ins, Long.valueOf(ins.operands[0]))); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushDoubleIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushDoubleIns.java index 6ffc48495..45a01e171 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushDoubleIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushDoubleIns.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.FloatValueAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class PushDoubleIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new FloatValueAVM2Item(ins, constants.getDouble(ins.operands[0]))); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.FloatValueAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class PushDoubleIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new FloatValueAVM2Item(ins, constants.getDouble(ins.operands[0]))); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushFalseIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushFalseIns.java index 572752c39..02f642eb2 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushFalseIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushFalseIns.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.BooleanAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class PushFalseIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new BooleanAVM2Item(ins, Boolean.FALSE)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.BooleanAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class PushFalseIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new BooleanAVM2Item(ins, Boolean.FALSE)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushIntIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushIntIns.java index c071efedb..34bee82cb 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushIntIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushIntIns.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.IntegerValueAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class PushIntIns extends InstructionDefinition implements PushIntegerTypeIns { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new IntegerValueAVM2Item(ins, constants.getInt(ins.operands[0]))); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.IntegerValueAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class PushIntIns extends InstructionDefinition implements PushIntegerTypeIns { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new IntegerValueAVM2Item(ins, constants.getInt(ins.operands[0]))); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNamespaceIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNamespaceIns.java index c86c91885..dd11f57f3 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNamespaceIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNamespaceIns.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.NameSpaceAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class PushNamespaceIns extends InstructionDefinition { - - public PushNamespaceIns() { - super(0x31, "pushnamespace", new int[]{AVM2Code.OPT_U30}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new NameSpaceAVM2Item(ins, ins.operands[0])); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.NameSpaceAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class PushNamespaceIns extends InstructionDefinition { + + public PushNamespaceIns() { + super(0x31, "pushnamespace", new int[]{AVM2Code.OPT_U30}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new NameSpaceAVM2Item(ins, ins.operands[0])); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNanIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNanIns.java index 2af933893..65b4c2235 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNanIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNanIns.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.NanAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class PushNanIns extends InstructionDefinition { - - public PushNanIns() { - super(0x28, "pushnan", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new NanAVM2Item(ins)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.NanAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class PushNanIns extends InstructionDefinition { + + public PushNanIns() { + super(0x28, "pushnan", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new NanAVM2Item(ins)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNullIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNullIns.java index eddd07d58..e692d30b5 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNullIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNullIns.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class PushNullIns extends InstructionDefinition { - - public PushNullIns() { - super(0x20, "pushnull", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new NullAVM2Item(ins)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class PushNullIns extends InstructionDefinition { + + public PushNullIns() { + super(0x20, "pushnull", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new NullAVM2Item(ins)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushScopeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushScopeIns.java index 0cad1314b..97a9867f6 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushScopeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushScopeIns.java @@ -1,57 +1,57 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class PushScopeIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - scopeStack.push(stack.pop()); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class PushScopeIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + scopeStack.push(stack.pop()); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushShortIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushShortIns.java index 345345337..bc2b8a0f0 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushShortIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushShortIns.java @@ -42,7 +42,7 @@ public class PushShortIns extends InstructionDefinition implements PushIntegerTy } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { stack.push(new IntegerValueAVM2Item(ins, Long.valueOf((long) (short) ins.operands[0]))); } diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushStringIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushStringIns.java index dbfea4b89..e28fd7312 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushStringIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushStringIns.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.StringAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class PushStringIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new StringAVM2Item(ins, constants.getString(ins.operands[0]))); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.StringAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class PushStringIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new StringAVM2Item(ins, constants.getString(ins.operands[0]))); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushTrueIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushTrueIns.java index 4740fe516..d096365ae 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushTrueIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushTrueIns.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.BooleanAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class PushTrueIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new BooleanAVM2Item(ins, Boolean.TRUE)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.BooleanAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class PushTrueIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new BooleanAVM2Item(ins, Boolean.TRUE)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUIntIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUIntIns.java index 8d2ca76d2..c63e32c94 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUIntIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUIntIns.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.IntegerValueAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class PushUIntIns extends InstructionDefinition implements PushIntegerTypeIns { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new IntegerValueAVM2Item(ins, constants.getUInt(ins.operands[0]))); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.IntegerValueAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class PushUIntIns extends InstructionDefinition implements PushIntegerTypeIns { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new IntegerValueAVM2Item(ins, constants.getUInt(ins.operands[0]))); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUndefinedIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUndefinedIns.java index 80581e9c4..7666e1dd4 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUndefinedIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUndefinedIns.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.UndefinedAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class PushUndefinedIns extends InstructionDefinition { - - public PushUndefinedIns() { - super(0x21, "pushundefined", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new UndefinedAVM2Item(ins)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.UndefinedAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class PushUndefinedIns extends InstructionDefinition { + + public PushUndefinedIns() { + super(0x21, "pushundefined", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new UndefinedAVM2Item(ins)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushWithIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushWithIns.java index 5fc640de9..3c98155e1 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushWithIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushWithIns.java @@ -1,56 +1,56 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.WithAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.WithObjectAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class PushWithIns extends InstructionDefinition { - - public PushWithIns() { - super(0x1c, "pushwith", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem w = (GraphTargetItem) stack.pop(); - WithObjectAVM2Item wot = new WithObjectAVM2Item(ins, w); - scopeStack.push(wot); - output.add(new WithAVM2Item(ins, w)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } - - @Override - public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { - return 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.WithAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.WithObjectAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class PushWithIns extends InstructionDefinition { + + public PushWithIns() { + super(0x1c, "pushwith", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem w = stack.pop(); + WithObjectAVM2Item wot = new WithObjectAVM2Item(ins, w); + scopeStack.push(wot); + output.add(new WithAVM2Item(ins, w)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } + + @Override + public int getScopeStackDelta(AVM2Instruction ins, ABC abc) { + return 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/SwapIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/SwapIns.java index 19d41ef9e..40b41cd52 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/SwapIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/SwapIns.java @@ -1,62 +1,62 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphSourceItemPos; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class SwapIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - - 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; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphSourceItemPos; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class SwapIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + + 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; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ApplyTypeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ApplyTypeIns.java index bf6eeb384..306e88edf 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ApplyTypeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ApplyTypeIns.java @@ -1,66 +1,66 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.types; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.ApplyTypeAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ApplyTypeIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int argCount = ins.operands[0]; - List params = new ArrayList<>(); - for (int i = 0; i < argCount; i++) { - params.add(0, stack.pop()); - } - stack.push(new ApplyTypeAVM2Item(ins, stack.pop(), params)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -ins.operands[0] - 1 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.types; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.ApplyTypeAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ApplyTypeIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int argCount = ins.operands[0]; + List params = new ArrayList<>(); + for (int i = 0; i < argCount; i++) { + params.add(0, stack.pop()); + } + stack.push(new ApplyTypeAVM2Item(ins, stack.pop(), params)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -ins.operands[0] - 1 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java index 0bfbf5f07..6bf83269a 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeIns.java @@ -1,61 +1,61 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.types; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.AsTypeAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class AsTypeIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem val = (GraphTargetItem) stack.pop(); - - stack.push(new AsTypeAVM2Item(ins, val, new FullMultinameAVM2Item(ins, ins.operands[0]))); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.types; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.AsTypeAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class AsTypeIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem val = stack.pop(); + + stack.push(new AsTypeAVM2Item(ins, val, new FullMultinameAVM2Item(ins, ins.operands[0]))); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeLateIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeLateIns.java index 169d6c86d..d17d1258b 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeLateIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/AsTypeLateIns.java @@ -1,59 +1,59 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.types; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.operations.AsTypeAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class AsTypeLateIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem cls = (GraphTargetItem) stack.pop(); - GraphTargetItem val = (GraphTargetItem) stack.pop(); - stack.push(new AsTypeAVM2Item(ins, val, cls)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.types; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.operations.AsTypeAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class AsTypeLateIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem cls = stack.pop(); + GraphTargetItem val = stack.pop(); + stack.push(new AsTypeAVM2Item(ins, val, cls)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java index ce3e3a6fb..539a7a93c 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java @@ -1,64 +1,64 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.types; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.CoerceAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.TypeItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class CoerceAIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - - public CoerceAIns() { - super(0x82, "coerce_a", new int[]{}); - } - - public String getTargetType() { - return "*"; - } - - @Override - public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { - //coerce any type - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new CoerceAVM2Item(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); - - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } - - @Override - public GraphTargetItem getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return TypeItem.UNBOUNDED; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.types; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.CoerceAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TypeItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class CoerceAIns extends InstructionDefinition implements CoerceOrConvertTypeIns { + + public CoerceAIns() { + super(0x82, "coerce_a", new int[]{}); + } + + public String getTargetType() { + return "*"; + } + + @Override + public void execute(LocalDataArea lda, ConstantPool constants, List arguments) { + //coerce any type + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new CoerceAVM2Item(ins, stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); + + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } + + @Override + public GraphTargetItem getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { + return TypeItem.UNBOUNDED; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java index 9908d574f..7dbfe2b12 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java @@ -44,9 +44,9 @@ public class CoerceIns extends InstructionDefinition implements CoerceOrConvertT } @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { int multinameIndex = ins.operands[0]; - stack.push(new CoerceAVM2Item(ins, (GraphTargetItem) stack.pop(), PropertyAVM2Item.multinameToType(multinameIndex, constants))); + stack.push(new CoerceAVM2Item(ins, stack.pop(), PropertyAVM2Item.multinameToType(multinameIndex, constants))); } @Override diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java index f2a269559..23151202f 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceSIns.java @@ -1,60 +1,60 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.types; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.CoerceAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.TypeItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class CoerceSIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new CoerceAVM2Item(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } - - @Override - public GraphTargetItem getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return new TypeItem("String"); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.types; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.CoerceAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TypeItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class CoerceSIns extends InstructionDefinition implements CoerceOrConvertTypeIns { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new CoerceAVM2Item(ins, stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } + + @Override + public GraphTargetItem getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { + return new TypeItem("String"); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java index 521a60500..4870d770e 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java @@ -1,70 +1,70 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.types; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.ConvertAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.TypeItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ConvertBIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - - 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).isEmpty(); - } else { - bval = true; - } - lda.operandStack.push((Boolean) bval); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new ConvertAVM2Item(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } - - @Override - public GraphTargetItem getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return new TypeItem("Boolean"); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.types; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.ConvertAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TypeItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ConvertBIns extends InstructionDefinition implements CoerceOrConvertTypeIns { + + 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).isEmpty(); + } else { + bval = true; + } + lda.operandStack.push((Boolean) bval); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } + + @Override + public GraphTargetItem getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { + return new TypeItem("Boolean"); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java index f70fd7161..295211781 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java @@ -1,78 +1,78 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.types; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.ConvertAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.TypeItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ConvertDIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - - 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 { - 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(Double.valueOf(ret)); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new ConvertAVM2Item(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } - - @Override - public GraphTargetItem getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return new TypeItem("Number"); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.types; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.ConvertAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TypeItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ConvertDIns extends InstructionDefinition implements CoerceOrConvertTypeIns { + + 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 { + 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(Double.valueOf(ret)); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } + + @Override + public GraphTargetItem getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { + return new TypeItem("Number"); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java index 5b57f436b..9b6d51cd2 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java @@ -1,76 +1,76 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.types; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.ConvertAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.TypeItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ConvertIIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - - 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 { - 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(Long.valueOf(ret)); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new ConvertAVM2Item(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } - - @Override - public GraphTargetItem getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return new TypeItem("int"); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.types; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.ConvertAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TypeItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ConvertIIns extends InstructionDefinition implements CoerceOrConvertTypeIns { + + 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 { + 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(Long.valueOf(ret)); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } + + @Override + public GraphTargetItem getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { + return new TypeItem("int"); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java index 57ac1973e..1b8aaf2c6 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java @@ -1,59 +1,59 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.types; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.ConvertAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.TypeItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ConvertOIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new ConvertAVM2Item(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } - - @Override - public GraphTargetItem getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return new TypeItem("Object"); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.types; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.ConvertAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TypeItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ConvertOIns extends InstructionDefinition implements CoerceOrConvertTypeIns { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } + + @Override + public GraphTargetItem getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { + return new TypeItem("Object"); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java index 760a41acd..fbf5355b7 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertSIns.java @@ -1,60 +1,60 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.types; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.ConvertAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.TypeItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ConvertSIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new ConvertAVM2Item(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } - - @Override - public GraphTargetItem getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return new TypeItem("String"); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.types; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.ConvertAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TypeItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ConvertSIns extends InstructionDefinition implements CoerceOrConvertTypeIns { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } + + @Override + public GraphTargetItem getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { + return new TypeItem("String"); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java index 5e37c6b7c..851f55c76 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java @@ -1,59 +1,59 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.types; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.ConvertAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.TypeItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ConvertUIns extends InstructionDefinition implements CoerceOrConvertTypeIns { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new ConvertAVM2Item(ins, (GraphTargetItem) stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } - - @Override - public GraphTargetItem getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { - return new TypeItem("uint"); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.types; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.ConvertAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TypeItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ConvertUIns extends InstructionDefinition implements CoerceOrConvertTypeIns { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new ConvertAVM2Item(ins, stack.pop(), getTargetType(constants, ins, fullyQualifiedNames))); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } + + @Override + public GraphTargetItem getTargetType(ConstantPool constants, AVM2Instruction ins, List fullyQualifiedNames) { + return new TypeItem("uint"); + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/InstanceOfIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/InstanceOfIns.java index 951b4cce2..79749b797 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/InstanceOfIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/InstanceOfIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.types; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.InstanceOfAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class InstanceOfIns extends InstructionDefinition { - - public InstanceOfIns() { - super(0xb1, "instanceof", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem type = (GraphTargetItem) stack.pop(); - GraphTargetItem value = (GraphTargetItem) stack.pop(); - stack.push(new InstanceOfAVM2Item(ins, value, type)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.types; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.InstanceOfAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class InstanceOfIns extends InstructionDefinition { + + public InstanceOfIns() { + super(0xb1, "instanceof", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem type = stack.pop(); + GraphTargetItem value = stack.pop(); + stack.push(new InstanceOfAVM2Item(ins, value, type)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java index 5ac1ca02d..68f0bda20 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeIns.java @@ -1,50 +1,50 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.types; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.IsTypeAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IsTypeIns extends InstructionDefinition { - - public IsTypeIns() { - super(0xb2, "istype", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - int multinameIndex = ins.operands[0]; - GraphTargetItem value = (GraphTargetItem) stack.pop(); - stack.push(new IsTypeAVM2Item(ins, value, new FullMultinameAVM2Item(ins, multinameIndex))); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; //may not be runtime multiname - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.types; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.FullMultinameAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.IsTypeAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IsTypeIns extends InstructionDefinition { + + public IsTypeIns() { + super(0xb2, "istype", new int[]{AVM2Code.DAT_MULTINAME_INDEX}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + int multinameIndex = ins.operands[0]; + GraphTargetItem value = stack.pop(); + stack.push(new IsTypeAVM2Item(ins, value, new FullMultinameAVM2Item(ins, multinameIndex))); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; //may not be runtime multiname + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeLateIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeLateIns.java index 98d8d0618..0545c511d 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeLateIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/IsTypeLateIns.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.types; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.IsTypeAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class IsTypeLateIns extends InstructionDefinition { - - public IsTypeLateIns() { - super(0xb3, "istypelate", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem type = (GraphTargetItem) stack.pop(); - GraphTargetItem value = (GraphTargetItem) stack.pop(); - stack.push(new IsTypeAVM2Item(ins, value, type)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -2 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.types; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.IsTypeAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class IsTypeLateIns extends InstructionDefinition { + + public IsTypeLateIns() { + super(0xb3, "istypelate", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem type = stack.pop(); + GraphTargetItem value = stack.pop(); + stack.push(new IsTypeAVM2Item(ins, value, type)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -2 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/TypeOfIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/TypeOfIns.java index 682cb4b44..2ec2dc9f3 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/TypeOfIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/TypeOfIns.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.types; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; -import com.jpexs.decompiler.flash.abc.avm2.model.operations.TypeOfAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class TypeOfIns extends InstructionDefinition { - - public TypeOfIns() { - super(0x95, "typeof", new int[]{}); - } - - @Override - public void translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new TypeOfAVM2Item(ins, (GraphTargetItem) stack.pop())); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.types; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.model.operations.TypeOfAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class TypeOfIns extends InstructionDefinition { + + public TypeOfIns() { + super(0x95, "typeof", new int[]{}); + } + + @Override + public void translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new TypeOfAVM2Item(ins, stack.pop())); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/CheckFilterIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/CheckFilterIns.java index 91009a1a9..a2a4afd78 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/CheckFilterIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/CheckFilterIns.java @@ -1,54 +1,54 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.xml; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.FilteredCheckAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class CheckFilterIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem obj = stack.pop(); - stack.push(new FilteredCheckAVM2Item(ins, obj)); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.xml; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.FilteredCheckAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class CheckFilterIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem obj = stack.pop(); + stack.push(new FilteredCheckAVM2Item(ins, obj)); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSLateIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSLateIns.java index f588cad47..4d571dd9b 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSLateIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/DXNSLateIns.java @@ -1,56 +1,56 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.xml; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.DefaultXMLNamespace; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class DXNSLateIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - GraphTargetItem xmlns = stack.pop(); - output.add(new DefaultXMLNamespace(ins, xmlns)); - - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.xml; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.DefaultXMLNamespace; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class DXNSLateIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + GraphTargetItem xmlns = stack.pop(); + output.add(new DefaultXMLNamespace(ins, xmlns)); + + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXAttrIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXAttrIns.java index 5583a028e..624ac21cd 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXAttrIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXAttrIns.java @@ -1,55 +1,55 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.xml; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.EscapeXAttrAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class EscXAttrIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new EscapeXAttrAVM2Item(ins, stack.pop())); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.xml; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.EscapeXAttrAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class EscXAttrIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new EscapeXAttrAVM2Item(ins, stack.pop())); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXElemIns.java b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXElemIns.java index 4ff0d7a0e..f338a3fbd 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXElemIns.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/instructions/xml/EscXElemIns.java @@ -1,55 +1,55 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.instructions.xml; - -import com.jpexs.decompiler.flash.abc.ABC; -import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; -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.avm2.model.EscapeXElemAVM2Item; -import com.jpexs.decompiler.flash.abc.types.MethodBody; -import com.jpexs.decompiler.flash.abc.types.MethodInfo; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class EscXElemIns extends InstructionDefinition { - - 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 translate(boolean isStatic, int scriptIndex, int classIndex, java.util.HashMap localRegs, Stack stack, java.util.Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { - stack.push(new EscapeXElemAVM2Item(ins, stack.pop())); - } - - @Override - public int getStackDelta(AVM2Instruction ins, ABC abc) { - return -1 + 1; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.instructions.xml; + +import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.ConstantPool; +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.avm2.model.EscapeXElemAVM2Item; +import com.jpexs.decompiler.flash.abc.types.MethodBody; +import com.jpexs.decompiler.flash.abc.types.MethodInfo; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class EscXElemIns extends InstructionDefinition { + + 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 translate(boolean isStatic, int scriptIndex, int classIndex, HashMap localRegs, Stack stack, Stack scopeStack, ConstantPool constants, AVM2Instruction ins, List method_info, List output, MethodBody body, ABC abc, HashMap localRegNames, List fullyQualifiedNames, String path, HashMap localRegsAssignmentIps, int ip, HashMap> refs, AVM2Code code) { + stack.push(new EscapeXElemAVM2Item(ins, stack.pop())); + } + + @Override + public int getStackDelta(AVM2Instruction ins, ABC abc) { + return -1 + 1; + } +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/model/WithAVM2Item.java b/src/com/jpexs/decompiler/flash/abc/avm2/model/WithAVM2Item.java index 08f23640e..57c861989 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/model/WithAVM2Item.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/model/WithAVM2Item.java @@ -1,89 +1,89 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.model; - -import com.jpexs.decompiler.flash.SourceGeneratorLocalData; -import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; -import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; -import com.jpexs.decompiler.flash.abc.avm2.parser.script.AssignableAVM2Item; -import com.jpexs.decompiler.flash.helpers.GraphTextWriter; -import com.jpexs.decompiler.graph.CompilationException; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.SourceGenerator; -import com.jpexs.decompiler.graph.TypeItem; -import com.jpexs.decompiler.graph.model.LocalData; -import java.util.ArrayList; -import java.util.List; - -public class WithAVM2Item extends AVM2Item { - - public GraphTargetItem scope; - public List items; - public List subvariables = new ArrayList(); - - public WithAVM2Item(AVM2Instruction instruction, GraphTargetItem scope, List items) { - super(instruction, NOPRECEDENCE); - this.scope = scope; - this.items = items; - } - - public WithAVM2Item(AVM2Instruction instruction, GraphTargetItem scope) { - super(instruction, NOPRECEDENCE); - this.scope = scope; - this.items = new ArrayList<>(); - } - - @Override - public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { - writer.append("with"); - if (writer.getFormatting().spaceBeforeParenthesesWithParentheses) { - writer.append(" "); - } - writer.append("("); - scope.toString(writer, localData); - writer.append(")").newLine(); - writer.append("{").newLine(); - writer.indent(); - /*for (GraphTargetItem ti : items) { - ret += ti.toString(constants, localRegNames, fullyQualifiedNames) + "\r\n"; - }*/ - writer.unindent(); - return writer.append("}"); - } - - @Override - public boolean needsSemicolon() { - return false; - } - - @Override - public GraphTargetItem returnType() { - return TypeItem.UNBOUNDED; - } - - @Override - public boolean hasReturnValue() { - return false; - } - - @Override - public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { - return ((AVM2SourceGenerator) generator).generate(localData, this); - } - -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.model; + +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.AssignableAVM2Item; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; +import com.jpexs.decompiler.graph.TypeItem; +import com.jpexs.decompiler.graph.model.LocalData; +import java.util.ArrayList; +import java.util.List; + +public class WithAVM2Item extends AVM2Item { + + public GraphTargetItem scope; + public List items; + public List subvariables = new ArrayList<>(); + + public WithAVM2Item(AVM2Instruction instruction, GraphTargetItem scope, List items) { + super(instruction, NOPRECEDENCE); + this.scope = scope; + this.items = items; + } + + public WithAVM2Item(AVM2Instruction instruction, GraphTargetItem scope) { + super(instruction, NOPRECEDENCE); + this.scope = scope; + this.items = new ArrayList<>(); + } + + @Override + public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { + writer.append("with"); + if (writer.getFormatting().spaceBeforeParenthesesWithParentheses) { + writer.append(" "); + } + writer.append("("); + scope.toString(writer, localData); + writer.append(")").newLine(); + writer.append("{").newLine(); + writer.indent(); + /*for (GraphTargetItem ti : items) { + ret += ti.toString(constants, localRegNames, fullyQualifiedNames) + "\r\n"; + }*/ + writer.unindent(); + return writer.append("}"); + } + + @Override + public boolean needsSemicolon() { + return false; + } + + @Override + public GraphTargetItem returnType() { + return TypeItem.UNBOUNDED; + } + + @Override + public boolean hasReturnValue() { + return false; + } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { + return ((AVM2SourceGenerator) generator).generate(localData, this); + } + +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java b/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java index 64e8fbb32..8b6be6918 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/model/clauses/TryAVM2Item.java @@ -1,164 +1,164 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.model.clauses; - -import com.jpexs.decompiler.flash.SourceGeneratorLocalData; -import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; -import com.jpexs.decompiler.flash.abc.avm2.parser.script.AssignableAVM2Item; -import com.jpexs.decompiler.flash.abc.avm2.parser.script.NameAVM2Item; -import com.jpexs.decompiler.flash.abc.types.ABCException; -import com.jpexs.decompiler.flash.helpers.GraphTextWriter; -import com.jpexs.decompiler.graph.Block; -import com.jpexs.decompiler.graph.CompilationException; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.SourceGenerator; -import com.jpexs.decompiler.graph.TypeItem; -import com.jpexs.decompiler.graph.model.ContinueItem; -import com.jpexs.decompiler.graph.model.LocalData; -import java.util.ArrayList; -import java.util.List; - -public class TryAVM2Item extends AVM2Item implements Block { - - public List tryCommands; - public List catchExceptions; - public List catchExceptions2; - public List> catchCommands; - public List finallyCommands; - public List> catchVariables = new ArrayList>(); - - @Override - public List> getSubs() { - List> ret = new ArrayList<>(); - if (tryCommands != null) { - ret.add(tryCommands); - } - ret.addAll(catchCommands); - if (finallyCommands != null) { - ret.add(finallyCommands); - } - return ret; - } - - public TryAVM2Item(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 GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { - writer.append("try").newLine(); - writer.append("{").newLine(); - writer.indent(); - for (GraphTargetItem ti : tryCommands) { - if (!ti.isEmpty()) { - ti.toStringSemicoloned(writer, localData).newLine(); - } - } - writer.unindent(); - writer.append("}"); - for (int e = 0; e < catchExceptions.size(); e++) { - writer.newLine(); - writer.append("catch(" + catchExceptions.get(e).getVarName(localData.constantsAvm2, localData.fullyQualifiedNames) + ":" + catchExceptions.get(e).getTypeName(localData.constantsAvm2, localData.fullyQualifiedNames) + ")"); - writer.newLine(); - writer.append("{").newLine(); - writer.indent(); - List commands = catchCommands.get(e); - for (GraphTargetItem ti : commands) { - if (!ti.isEmpty()) { - ti.toStringSemicoloned(writer, localData).newLine(); - } - } - writer.unindent(); - writer.append("}"); - } - if (finallyCommands.size() > 0) { - writer.newLine(); - writer.append("finally").newLine(); - writer.append("{").newLine(); - writer.indent(); - for (GraphTargetItem ti : finallyCommands) { - if (!ti.isEmpty()) { - ti.toStringSemicoloned(writer, localData).newLine(); - } - } - writer.unindent(); - writer.append("}"); - } - return writer; - } - - @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) { - if (ti instanceof ContinueItem) { - ret.add((ContinueItem) ti); - } - 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; - } - - @Override - public boolean needsSemicolon() { - return false; - } - - @Override - public GraphTargetItem returnType() { - return TypeItem.UNBOUNDED; - } - - @Override - public boolean hasReturnValue() { - return false; - } - - @Override - public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { - return ((AVM2SourceGenerator) generator).generate(localData, this); - } - -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.model.clauses; + +import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.AVM2SourceGenerator; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.AssignableAVM2Item; +import com.jpexs.decompiler.flash.abc.avm2.parser.script.NameAVM2Item; +import com.jpexs.decompiler.flash.abc.types.ABCException; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.graph.Block; +import com.jpexs.decompiler.graph.CompilationException; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.SourceGenerator; +import com.jpexs.decompiler.graph.TypeItem; +import com.jpexs.decompiler.graph.model.ContinueItem; +import com.jpexs.decompiler.graph.model.LocalData; +import java.util.ArrayList; +import java.util.List; + +public class TryAVM2Item extends AVM2Item implements Block { + + public List tryCommands; + public List catchExceptions; + public List catchExceptions2; + public List> catchCommands; + public List finallyCommands; + public List> catchVariables = new ArrayList<>(); + + @Override + public List> getSubs() { + List> ret = new ArrayList<>(); + if (tryCommands != null) { + ret.add(tryCommands); + } + ret.addAll(catchCommands); + if (finallyCommands != null) { + ret.add(finallyCommands); + } + return ret; + } + + public TryAVM2Item(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 GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException { + writer.append("try").newLine(); + writer.append("{").newLine(); + writer.indent(); + for (GraphTargetItem ti : tryCommands) { + if (!ti.isEmpty()) { + ti.toStringSemicoloned(writer, localData).newLine(); + } + } + writer.unindent(); + writer.append("}"); + for (int e = 0; e < catchExceptions.size(); e++) { + writer.newLine(); + writer.append("catch(" + catchExceptions.get(e).getVarName(localData.constantsAvm2, localData.fullyQualifiedNames) + ":" + catchExceptions.get(e).getTypeName(localData.constantsAvm2, localData.fullyQualifiedNames) + ")"); + writer.newLine(); + writer.append("{").newLine(); + writer.indent(); + List commands = catchCommands.get(e); + for (GraphTargetItem ti : commands) { + if (!ti.isEmpty()) { + ti.toStringSemicoloned(writer, localData).newLine(); + } + } + writer.unindent(); + writer.append("}"); + } + if (finallyCommands.size() > 0) { + writer.newLine(); + writer.append("finally").newLine(); + writer.append("{").newLine(); + writer.indent(); + for (GraphTargetItem ti : finallyCommands) { + if (!ti.isEmpty()) { + ti.toStringSemicoloned(writer, localData).newLine(); + } + } + writer.unindent(); + writer.append("}"); + } + return writer; + } + + @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) { + if (ti instanceof ContinueItem) { + ret.add((ContinueItem) ti); + } + 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; + } + + @Override + public boolean needsSemicolon() { + return false; + } + + @Override + public GraphTargetItem returnType() { + return TypeItem.UNBOUNDED; + } + + @Override + public boolean hasReturnValue() { + return false; + } + + @Override + public List toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException { + return ((AVM2SourceGenerator) generator).generate(localData, this); + } + +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java b/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java index efddf52a9..2db032f06 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/AVM2SourceGenerator.java @@ -1795,7 +1795,7 @@ public class AVM2SourceGenerator implements SourceGenerator { if (custom != null) { PropertyAVM2Item prop = new PropertyAVM2Item(null, custom, abc, allABCs, openedNamespaces, new ArrayList()); Reference value = new Reference<>(null); - prop.resolve(localData, new Reference(null), new Reference(null), new Reference(0), value); + prop.resolve(localData, new Reference(null), new Reference(null), new Reference<>(0), value); boolean resolved = true; if (value.getVal() == null) { resolved = false; diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java b/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java index ac048054a..b463378cf 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java @@ -1,2232 +1,2232 @@ -/* The following code was generated by JFlex 1.5.0-SNAPSHOT */ - -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.abc.avm2.parser.script; - -import com.jpexs.decompiler.flash.abc.avm2.parser.ParseException; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; -import java.util.Stack; - -/** - * This class is a scanner generated by - * JFlex 1.5.0-SNAPSHOT from the - * specification file - * D:/Dropbox/Programovani/JavaSE/FFDec/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/actionscript.flex - */ -public final class ActionScriptLexer { - - /** - * 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 YYINITIAL = 0; - public static final int STRING = 2; - public static final int CHARLITERAL = 4; - public static final int XMLOPENTAG = 6; - public static final int XMLOPENTAGATTRIB = 8; - public static final int XMLINSTROPENTAG = 10; - public static final int XMLINSTRATTRIB = 12; - public static final int XMLCDATA = 14; - public static final int XMLCOMMENT = 16; - public static final int XML = 18; - - /** - * 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, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, - 8, 8, 9, 9 - }; - - /** - * Translates characters to character classes - */ - private static final String ZZ_CMAP_PACKED - = "\11\7\1\12\1\2\1\111\1\3\1\1\16\7\4\0\1\12\1\13" - + "\1\33\1\0\1\6\1\107\1\104\1\34\1\75\1\76\1\5\1\45" - + "\1\102\1\14\1\10\1\4\1\35\3\41\4\42\2\21\1\16\1\101" - + "\1\11\1\32\1\15\1\23\1\110\1\27\1\17\1\25\1\26\1\43" - + "\1\17\2\20\1\73\4\20\1\74\5\20\1\30\3\20\1\37\2\20" - + "\1\24\1\46\1\31\1\106\1\20\1\0\1\51\1\47\1\53\1\62" - + "\1\44\1\40\1\72\1\65\1\60\1\20\1\52\1\63\1\70\1\56" - + "\1\55\1\66\1\20\1\50\1\54\1\57\1\61\1\71\1\64\1\36" - + "\1\67\1\20\1\77\1\105\1\100\1\103\6\7\1\112\32\7\2\0" - + "\4\6\4\0\1\6\2\0\1\7\7\0\1\6\1\0\1\22\2\0" - + "\1\6\5\0\27\6\1\0\37\6\1\0\u01ca\6\4\0\14\6\16\0" - + "\5\6\7\0\1\6\1\0\1\6\21\0\160\7\5\6\1\0\2\6" - + "\2\0\4\6\1\0\7\0\1\6\1\0\3\6\1\0\1\6\1\0" - + "\24\6\1\0\123\6\1\0\213\6\1\0\5\7\2\0\236\6\11\0" - + "\46\6\2\0\1\6\7\0\47\6\11\0\55\7\1\0\1\7\1\0" - + "\2\7\1\0\2\7\1\0\1\7\10\0\33\6\5\0\3\6\15\0" - + "\4\7\7\0\1\6\4\0\13\7\5\0\53\6\37\7\4\0\2\6" - + "\1\7\143\6\1\0\1\6\10\7\1\0\6\7\2\6\2\7\1\0" - + "\4\7\2\6\12\7\3\6\2\0\1\6\17\0\1\7\1\6\1\7" - + "\36\6\33\7\2\0\131\6\13\7\1\6\16\0\12\7\41\6\11\7" - + "\2\6\4\0\1\6\5\0\26\6\4\7\1\6\11\7\1\6\3\7" - + "\1\6\5\7\22\0\31\6\3\7\244\0\4\7\66\6\3\7\1\6" - + "\22\7\1\6\7\7\12\6\2\7\2\0\12\7\1\0\7\6\1\0" - + "\7\6\1\0\3\7\1\0\10\6\2\0\2\6\2\0\26\6\1\0" - + "\7\6\1\0\1\6\3\0\4\6\2\0\1\7\1\6\7\7\2\0" - + "\2\7\2\0\3\7\1\6\10\0\1\7\4\0\2\6\1\0\3\6" - + "\2\7\2\0\12\7\4\6\7\0\1\6\5\0\3\7\1\0\6\6" - + "\4\0\2\6\2\0\26\6\1\0\7\6\1\0\2\6\1\0\2\6" - + "\1\0\2\6\2\0\1\7\1\0\5\7\4\0\2\7\2\0\3\7" - + "\3\0\1\7\7\0\4\6\1\0\1\6\7\0\14\7\3\6\1\7" - + "\13\0\3\7\1\0\11\6\1\0\3\6\1\0\26\6\1\0\7\6" - + "\1\0\2\6\1\0\5\6\2\0\1\7\1\6\10\7\1\0\3\7" - + "\1\0\3\7\2\0\1\6\17\0\2\6\2\7\2\0\12\7\1\0" - + "\1\6\17\0\3\7\1\0\10\6\2\0\2\6\2\0\26\6\1\0" - + "\7\6\1\0\2\6\1\0\5\6\2\0\1\7\1\6\7\7\2\0" - + "\2\7\2\0\3\7\10\0\2\7\4\0\2\6\1\0\3\6\2\7" - + "\2\0\12\7\1\0\1\6\20\0\1\7\1\6\1\0\6\6\3\0" - + "\3\6\1\0\4\6\3\0\2\6\1\0\1\6\1\0\2\6\3\0" - + "\2\6\3\0\3\6\3\0\14\6\4\0\5\7\3\0\3\7\1\0" - + "\4\7\2\0\1\6\6\0\1\7\16\0\12\7\11\0\1\6\7\0" - + "\3\7\1\0\10\6\1\0\3\6\1\0\27\6\1\0\12\6\1\0" - + "\5\6\3\0\1\6\7\7\1\0\3\7\1\0\4\7\7\0\2\7" - + "\1\0\2\6\6\0\2\6\2\7\2\0\12\7\22\0\2\7\1\0" - + "\10\6\1\0\3\6\1\0\27\6\1\0\12\6\1\0\5\6\2\0" - + "\1\7\1\6\7\7\1\0\3\7\1\0\4\7\7\0\2\7\7\0" - + "\1\6\1\0\2\6\2\7\2\0\12\7\1\0\2\6\17\0\2\7" - + "\1\0\10\6\1\0\3\6\1\0\51\6\2\0\1\6\7\7\1\0" - + "\3\7\1\0\4\7\1\6\10\0\1\7\10\0\2\6\2\7\2\0" - + "\12\7\12\0\6\6\2\0\2\7\1\0\22\6\3\0\30\6\1\0" - + "\11\6\1\0\1\6\2\0\7\6\3\0\1\7\4\0\6\7\1\0" - + "\1\7\1\0\10\7\22\0\2\7\15\0\60\6\1\7\2\6\7\7" - + "\4\0\10\6\10\7\1\0\12\7\47\0\2\6\1\0\1\6\2\0" - + "\2\6\1\0\1\6\2\0\1\6\6\0\4\6\1\0\7\6\1\0" - + "\3\6\1\0\1\6\1\0\1\6\2\0\2\6\1\0\4\6\1\7" - + "\2\6\6\7\1\0\2\7\1\6\2\0\5\6\1\0\1\6\1\0" - + "\6\7\2\0\12\7\2\0\2\6\42\0\1\6\27\0\2\7\6\0" - + "\12\7\13\0\1\7\1\0\1\7\1\0\1\7\4\0\2\7\10\6" - + "\1\0\44\6\4\0\24\7\1\0\2\7\5\6\13\7\1\0\44\7" - + "\11\0\1\7\71\0\53\6\24\7\1\6\12\7\6\0\6\6\4\7" - + "\4\6\3\7\1\6\3\7\2\6\7\7\3\6\4\7\15\6\14\7" - + "\1\6\17\7\2\0\46\6\12\0\53\6\1\0\1\6\3\0\u0149\6" - + "\1\0\4\6\2\0\7\6\1\0\1\6\1\0\4\6\2\0\51\6" - + "\1\0\4\6\2\0\41\6\1\0\4\6\2\0\7\6\1\0\1\6" - + "\1\0\4\6\2\0\17\6\1\0\71\6\1\0\4\6\2\0\103\6" - + "\2\0\3\7\40\0\20\6\20\0\125\6\14\0\u026c\6\2\0\21\6" - + "\1\0\32\6\5\0\113\6\3\0\3\6\17\0\15\6\1\0\4\6" - + "\3\7\13\0\22\6\3\7\13\0\22\6\2\7\14\0\15\6\1\0" - + "\3\6\1\0\2\7\14\0\64\6\40\7\3\0\1\6\3\0\2\6" - + "\1\7\2\0\12\7\41\0\3\7\2\0\12\7\6\0\130\6\10\0" - + "\51\6\1\7\1\6\5\0\106\6\12\0\35\6\3\0\14\7\4\0" - + "\14\7\12\0\12\7\36\6\2\0\5\6\13\0\54\6\4\0\21\7" - + "\7\6\2\7\6\0\12\7\46\0\27\6\5\7\4\0\65\6\12\7" - + "\1\0\35\7\2\0\13\7\6\0\12\7\15\0\1\6\130\0\5\7" - + "\57\6\21\7\7\6\4\0\12\7\21\0\11\7\14\0\3\7\36\6" - + "\12\7\3\0\2\6\12\7\6\0\46\6\16\7\14\0\44\6\24\7" - + "\10\0\12\7\3\0\3\6\12\7\44\6\122\0\3\7\1\0\25\7" - + "\4\6\1\7\4\6\1\7\15\0\300\6\47\7\25\0\4\7\u0116\6" - + "\2\0\6\6\2\0\46\6\2\0\6\6\2\0\10\6\1\0\1\6" - + "\1\0\1\6\1\0\1\6\1\0\37\6\2\0\65\6\1\0\7\6" - + "\1\0\1\6\3\0\3\6\1\0\7\6\3\0\4\6\2\0\6\6" - + "\4\0\15\6\5\0\3\6\1\0\7\6\3\0\13\0\1\7\2\7" - + "\2\7\30\0\1\111\1\111\5\7\20\0\2\6\23\0\1\6\13\0" - + "\5\7\5\0\6\7\1\0\1\6\15\0\1\6\20\0\15\6\3\0" - + "\32\6\26\0\15\7\4\0\1\7\3\0\14\7\21\0\1\6\4\0" - + "\1\6\2\0\12\6\1\0\1\6\3\0\5\6\6\0\1\6\1\0" - + "\1\6\1\0\1\6\1\0\4\6\1\0\13\6\2\0\4\6\5\0" - + "\5\6\4\0\1\6\21\0\51\6\7\0\u0a70\0\57\6\1\0\57\6" - + "\1\0\205\6\6\0\4\6\3\7\16\0\46\6\12\0\66\6\11\0" - + "\1\6\17\0\1\7\27\6\11\0\7\6\1\0\7\6\1\0\7\6" - + "\1\0\7\6\1\0\7\6\1\0\7\6\1\0\7\6\1\0\7\6" - + "\1\0\40\7\57\0\1\6\u01c0\0\21\0\4\0\3\6\31\0\11\6" - + "\6\7\1\0\5\6\2\0\5\6\4\0\126\6\2\0\2\7\2\0" - + "\3\6\1\0\132\6\1\0\4\6\5\0\51\6\3\0\136\6\21\0" - + "\33\6\65\0\20\6\u0200\0\u19b6\6\112\0\u51cc\6\64\0\u048d\6\103\0" - + "\56\6\2\0\u010d\6\3\0\20\6\12\7\2\6\24\0\57\6\1\7" - + "\14\0\2\7\1\0\31\6\10\0\120\6\2\7\45\0\11\6\2\0" - + "\147\6\2\0\4\6\1\0\2\6\16\0\12\6\120\0\10\6\1\7" - + "\3\6\1\7\4\6\1\7\27\6\5\7\20\0\1\6\7\0\64\6" - + "\14\0\2\7\62\6\21\7\13\0\12\7\6\0\22\7\6\6\3\0" - + "\1\6\4\0\12\7\34\6\10\7\2\0\27\6\15\7\14\0\35\6" - + "\3\0\4\7\57\6\16\7\16\0\1\6\12\7\46\0\51\6\16\7" - + "\11\0\3\6\1\7\10\6\2\7\2\0\12\7\6\0\27\6\3\0" - + "\1\6\1\7\4\0\60\6\1\7\1\6\3\7\2\6\2\7\5\6" - + "\2\7\1\6\1\7\1\6\30\0\3\6\43\0\6\6\2\0\6\6" - + "\2\0\6\6\11\0\7\6\1\0\7\6\221\0\43\6\10\7\1\0" - + "\2\7\2\0\12\7\6\0\u2ba4\6\14\0\27\6\4\0\61\6\4\0" - + "\u1800\0\u0900\0\u012e\6\2\0\76\6\2\0\152\6\46\0\7\6\14\0" - + "\5\6\5\0\1\6\1\7\12\6\1\0\15\6\1\0\5\6\1\0" - + "\1\6\1\0\2\6\1\0\2\6\1\0\154\6\41\0\u016b\6\22\0" - + "\100\6\2\0\66\6\10\0\40\0\15\6\3\0\20\7\20\0\7\7" - + "\14\0\2\6\30\0\3\6\31\0\1\6\6\0\5\6\1\0\207\6" - + "\2\0\1\7\4\0\1\6\13\0\12\7\7\0\32\6\4\0\1\6" - + "\1\0\32\6\13\0\131\6\3\0\6\6\2\0\6\6\2\0\6\6" - + "\2\0\3\6\3\0\2\6\3\0\2\6\22\0\3\7\2\0\2\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 - = "\12\0\1\1\2\2\1\3\1\4\1\5\1\6\1\7" - + "\1\10\1\11\1\12\1\13\1\14\1\15\1\16\1\17" - + "\1\20\1\21\1\22\1\23\1\15\2\6\1\24\21\6" - + "\1\25\1\26\1\27\1\30\1\31\1\32\1\33\1\34" - + "\1\35\1\36\1\37\1\40\1\41\2\42\1\43\1\1" - + "\1\41\2\44\1\41\1\1\1\45\1\1\1\46\1\1" - + "\1\47\2\1\1\50\1\1\1\51\2\41\2\52\1\41" - + "\1\53\1\3\1\0\1\54\1\55\1\56\1\57\1\60" - + "\1\61\1\62\1\63\1\64\1\65\1\66\1\67\1\70" - + "\1\71\1\72\1\73\1\0\1\74\1\60\1\75\1\0" - + "\2\75\7\6\1\76\1\77\2\6\1\100\16\6\1\101" - + "\1\102\1\103\4\6\1\104\13\6\1\105\1\106\1\107" - + "\1\110\1\111\1\112\1\113\1\114\1\115\1\116\1\117" - + "\1\116\1\120\1\121\1\122\1\123\1\124\1\125\1\0" - + "\1\126\1\0\1\127\1\0\1\130\1\131\1\0\1\132" - + "\5\0\1\133\1\0\1\134\2\3\2\0\1\135\1\136" - + "\1\137\1\140\1\141\1\0\1\60\1\142\2\143\1\75" - + "\1\6\1\144\13\6\1\145\4\6\1\146\3\6\1\147" - + "\6\6\1\150\12\6\1\151\1\6\1\152\1\6\1\153" - + "\1\116\1\0\1\132\1\154\1\155\1\0\1\156\2\0" - + "\1\157\1\160\1\0\1\161\1\143\1\75\4\6\1\162" - + "\1\163\2\6\1\164\11\6\1\165\1\166\1\6\1\167" - + "\11\6\1\170\5\6\1\171\1\6\1\0\1\172\1\173" - + "\1\0\1\143\1\75\1\174\1\175\2\6\1\176\1\6" - + "\1\177\1\200\1\6\1\201\1\6\1\202\3\6\1\203" - + "\11\6\1\204\5\6\1\0\1\143\1\75\3\6\1\205" - + "\1\6\1\206\1\207\2\6\1\210\3\6\1\211\3\6" - + "\1\212\4\6\1\213\1\6\1\0\1\143\1\75\1\214" - + "\1\6\1\215\10\6\1\216\1\217\1\6\1\220\1\221" - + "\1\6\1\0\1\143\1\75\1\222\1\223\1\224\3\6" - + "\1\225\3\6\1\226\1\0\1\143\1\75\1\227\1\6" - + "\1\230\1\6\1\231\1\232\1\233\1\143\1\75\1\234" - + "\1\235\6\75"; - - private static int[] zzUnpackAction() { - int[] result = new int[426]; - 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\113\0\226\0\341\0\u012c\0\u0177\0\u01c2\0\u020d" - + "\0\u0258\0\u02a3\0\u02ee\0\u0339\0\u02ee\0\u0384\0\u03cf\0\u041a" - + "\0\u0465\0\u04b0\0\u04fb\0\u0546\0\u0591\0\u05dc\0\u0627\0\u0672" - + "\0\u02ee\0\u02ee\0\u02ee\0\u06bd\0\u02ee\0\u02ee\0\u0708\0\u0753" - + "\0\u079e\0\u07e9\0\u0834\0\u087f\0\u08ca\0\u0915\0\u0960\0\u09ab" - + "\0\u09f6\0\u0a41\0\u0a8c\0\u0ad7\0\u0b22\0\u0b6d\0\u0bb8\0\u0c03" - + "\0\u0c4e\0\u0c99\0\u0ce4\0\u02ee\0\u02ee\0\u02ee\0\u02ee\0\u02ee" - + "\0\u02ee\0\u02ee\0\u0d2f\0\u0d7a\0\u0dc5\0\u0e10\0\u02ee\0\u0e5b" - + "\0\u0ea6\0\u02ee\0\u02ee\0\u0ef1\0\u0f3c\0\u0f87\0\u02ee\0\u0fd2" - + "\0\u101d\0\u02ee\0\u1068\0\u02ee\0\u10b3\0\u02ee\0\u10fe\0\u1149" - + "\0\u02ee\0\u1194\0\u02ee\0\u02ee\0\u11df\0\u02ee\0\u122a\0\u1275" - + "\0\u02ee\0\u12c0\0\u130b\0\u02ee\0\u02ee\0\u1356\0\u02ee\0\u13a1" - + "\0\u02ee\0\u13ec\0\u1437\0\u02ee\0\u02ee\0\u1482\0\u02ee\0\u02ee" - + "\0\u14cd\0\u02ee\0\u02ee\0\u1518\0\u1563\0\u15ae\0\u15f9\0\u1644" - + "\0\u168f\0\u16da\0\u1725\0\u1770\0\u17bb\0\u1806\0\u1851\0\u189c" - + "\0\u18e7\0\u02ee\0\u02ee\0\u1932\0\u197d\0\u0465\0\u19c8\0\u1a13" - + "\0\u1a5e\0\u1aa9\0\u1af4\0\u1b3f\0\u1b8a\0\u1bd5\0\u1c20\0\u1c6b" - + "\0\u1cb6\0\u1d01\0\u1d4c\0\u1d97\0\u0465\0\u0465\0\u1de2\0\u1e2d" - + "\0\u1e78\0\u1ec3\0\u1f0e\0\u0465\0\u1f59\0\u1fa4\0\u1fef\0\u203a" - + "\0\u2085\0\u20d0\0\u211b\0\u2166\0\u21b1\0\u21fc\0\u2247\0\u02ee" - + "\0\u02ee\0\u02ee\0\u02ee\0\u02ee\0\u02ee\0\u02ee\0\u02ee\0\u02ee" - + "\0\u2292\0\u02ee\0\u22dd\0\u02ee\0\u02ee\0\u02ee\0\u02ee\0\u02ee" - + "\0\u02ee\0\u1068\0\u02ee\0\u10b3\0\u02ee\0\u10fe\0\u02ee\0\u02ee" - + "\0\u1194\0\u2328\0\u2373\0\u23be\0\u2409\0\u2454\0\u249f\0\u24ea" - + "\0\u2535\0\u02ee\0\u2580\0\u02ee\0\u25cb\0\u2616\0\u02ee\0\u02ee" - + "\0\u02ee\0\u2661\0\u02ee\0\u26ac\0\u26ac\0\u02ee\0\u26f7\0\u1644" - + "\0\u2742\0\u278d\0\u0465\0\u27d8\0\u2823\0\u286e\0\u28b9\0\u2904" - + "\0\u294f\0\u299a\0\u29e5\0\u2a30\0\u2a7b\0\u2ac6\0\u0465\0\u2b11" - + "\0\u2b5c\0\u2ba7\0\u2bf2\0\u0465\0\u2c3d\0\u2c88\0\u2cd3\0\u0465" - + "\0\u2d1e\0\u2d69\0\u2db4\0\u2dff\0\u2e4a\0\u2e95\0\u0465\0\u2ee0" - + "\0\u2f2b\0\u2f76\0\u2fc1\0\u300c\0\u3057\0\u30a2\0\u30ed\0\u3138" - + "\0\u3183\0\u0465\0\u31ce\0\u0465\0\u3219\0\u0465\0\u02ee\0\u2328" - + "\0\u02ee\0\u02ee\0\u02ee\0\u3264\0\u02ee\0\u32af\0\u32fa\0\u3345" - + "\0\u02ee\0\u3390\0\u02ee\0\u33db\0\u3426\0\u3471\0\u34bc\0\u3507" - + "\0\u3552\0\u0465\0\u0465\0\u359d\0\u35e8\0\u0465\0\u3633\0\u367e" - + "\0\u36c9\0\u3714\0\u375f\0\u37aa\0\u37f5\0\u3840\0\u388b\0\u0465" - + "\0\u0465\0\u38d6\0\u0465\0\u3921\0\u396c\0\u39b7\0\u3a02\0\u3a4d" - + "\0\u3a98\0\u3ae3\0\u3b2e\0\u3b79\0\u0465\0\u3bc4\0\u3c0f\0\u3c5a" - + "\0\u3ca5\0\u3cf0\0\u0465\0\u3d3b\0\u3d86\0\u02ee\0\u02ee\0\u3dd1" - + "\0\u3e1c\0\u3e67\0\u0465\0\u3eb2\0\u3efd\0\u3f48\0\u0465\0\u3f93" - + "\0\u0465\0\u0465\0\u3fde\0\u0465\0\u4029\0\u0465\0\u4074\0\u40bf" - + "\0\u410a\0\u0465\0\u4155\0\u41a0\0\u41eb\0\u4236\0\u4281\0\u42cc" - + "\0\u4317\0\u4362\0\u43ad\0\u0465\0\u43f8\0\u4443\0\u448e\0\u44d9" - + "\0\u4524\0\u456f\0\u45ba\0\u4605\0\u4650\0\u469b\0\u46e6\0\u0465" - + "\0\u4731\0\u0465\0\u0465\0\u477c\0\u47c7\0\u0465\0\u4812\0\u485d" - + "\0\u48a8\0\u0465\0\u48f3\0\u493e\0\u4989\0\u0465\0\u49d4\0\u4a1f" - + "\0\u4a6a\0\u4ab5\0\u0465\0\u4b00\0\u4b4b\0\u4b96\0\u4be1\0\u0465" - + "\0\u4c2c\0\u0465\0\u4c77\0\u4cc2\0\u4d0d\0\u4d58\0\u4da3\0\u4dee" - + "\0\u4e39\0\u4e84\0\u0465\0\u0465\0\u4ecf\0\u0465\0\u0465\0\u4f1a" - + "\0\u4f65\0\u4fb0\0\u4ffb\0\u0465\0\u0465\0\u0465\0\u5046\0\u5091" - + "\0\u50dc\0\u0465\0\u5127\0\u5172\0\u51bd\0\u0465\0\u5208\0\u5253" - + "\0\u529e\0\u0465\0\u52e9\0\u0465\0\u5334\0\u0465\0\u0465\0\u02ee" - + "\0\u02ee\0\u537f\0\u0465\0\u0465\0\u53ca\0\u5415\0\u5460\0\u54ab" - + "\0\u54f6\0\u15ae"; - - private static int[] zzUnpackRowMap() { - int[] result = new int[426]; - 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 - = "\1\13\1\14\1\15\1\16\1\17\1\20\1\21\1\13" - + "\1\22\1\23\1\16\1\24\1\25\1\26\1\27\2\21" - + "\1\30\1\13\1\31\1\32\4\21\1\33\1\34\1\35" - + "\1\36\1\37\2\21\1\40\2\30\1\21\1\41\1\42" - + "\1\13\1\43\1\44\1\45\1\21\1\46\1\47\1\50" - + "\1\51\1\52\1\53\1\54\1\55\1\21\1\56\1\21" - + "\1\57\2\21\1\60\1\61\1\62\1\63\1\64\1\65" - + "\1\66\1\67\1\70\1\71\1\72\1\73\1\74\1\75" - + "\1\76\1\77\2\0\1\100\1\101\1\102\30\100\1\103" - + "\12\100\1\104\44\100\1\105\1\101\1\102\31\105\1\103" - + "\11\105\1\104\44\105\1\13\1\106\1\107\1\110\1\111" - + "\5\13\1\110\2\13\1\112\3\113\4\13\4\113\5\13" - + "\3\113\2\13\2\113\2\13\26\113\2\13\1\114\11\13" - + "\2\0\1\13\1\0\1\13\1\0\27\13\1\115\43\13" - + "\1\116\11\13\2\0\1\13\1\106\1\107\1\110\6\13" - + "\1\110\3\13\3\117\2\13\1\120\1\13\4\117\5\13" - + "\3\117\2\13\2\117\2\13\26\117\2\13\1\121\11\13" - + "\2\0\1\13\1\0\1\13\1\0\27\13\1\122\43\13" - + "\1\123\11\13\2\0\1\124\1\106\1\107\1\0\25\124" - + "\1\125\57\124\2\0\1\126\1\106\1\107\1\0\10\126" - + "\1\127\74\126\2\0\1\124\1\106\1\107\1\0\5\124" - + "\1\130\65\124\1\131\11\124\117\0\1\15\113\0\1\16" - + "\6\0\1\16\104\0\1\132\1\133\24\0\1\134\112\0" - + "\1\135\66\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\26\21\15\0\1\21\10\0\1\136\1\137" - + "\7\0\1\140\13\0\1\140\3\0\2\140\32\0\1\141" - + "\26\0\1\142\4\0\3\143\4\0\4\143\1\0\1\144" - + "\3\0\3\143\2\0\2\143\2\0\26\143\2\0\1\145" - + "\45\0\1\146\74\0\1\147\15\0\1\150\75\0\1\151" - + "\14\0\1\152\76\0\1\153\104\0\1\140\10\0\1\30" - + "\13\0\1\30\3\0\2\30\2\154\100\0\1\155\70\0" - + "\1\140\10\0\1\156\13\0\1\157\2\160\1\0\1\161" - + "\1\162\2\154\54\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\10\21\2\0\2\21\1\163\3\21\1\164\2\21" - + "\1\165\1\166\13\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\1\21\1\167\6\21\2\0" - + "\2\21\1\170\11\21\1\171\11\21\15\0\1\21\32\0" - + "\1\172\12\0\1\173\53\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\1\21\1\174\24\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\7\21\1\175\2\0\26\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\5\21" - + "\1\176\20\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\10\21\2\0\2\21\1\177\3\21" - + "\1\200\5\21\1\201\11\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\7\21\1\202\2\0" - + "\10\21\1\203\1\21\1\204\2\21\1\205\10\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\22\21\1\206\3\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\7\21\1\207" - + "\2\0\2\21\1\210\7\21\1\211\13\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\1\21\1\212\14\21\1\213\1\21\1\214\5\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\3\21\1\215\4\21\2\0\5\21\1\216\1\21" - + "\1\217\11\21\1\220\4\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\5\21" - + "\1\221\1\21\1\222\16\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\7\21\1\223\2\0" - + "\6\21\1\224\11\21\1\225\5\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\11\21\1\226\4\21\1\227\7\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\1\21\1\230\1\231\7\21\1\232\13\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\2\21\1\233\3\21\1\234\17\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\7\21" - + "\1\235\2\0\26\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\10\21\2\0\7\21\1\236" - + "\16\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\2\21\1\237\23\21\15\0" - + "\1\21\32\0\1\240\51\0\1\241\40\0\1\242\52\0" - + "\1\243\37\0\1\244\112\0\1\245\60\0\1\100\2\0" - + "\30\100\1\0\12\100\1\0\44\100\2\0\1\102\110\0" - + "\1\246\3\0\27\246\1\247\1\250\1\251\2\246\1\252" - + "\1\251\1\253\3\246\1\254\1\255\1\256\5\246\1\257" - + "\1\260\31\246\2\0\1\105\2\0\31\105\1\0\11\105" - + "\1\0\44\105\2\0\1\107\113\0\1\110\6\0\1\110" - + "\115\0\1\261\105\0\1\262\3\0\1\262\1\0\5\262" - + "\2\0\4\262\1\0\1\263\2\0\10\262\2\0\26\262" - + "\16\0\1\264\2\0\30\264\1\265\57\264\10\0\1\266" - + "\3\0\1\266\1\0\5\266\2\0\4\266\1\0\1\267" - + "\2\0\10\266\2\0\26\266\33\0\1\270\75\0\1\271" - + "\2\0\30\271\1\272\1\273\56\271\31\0\1\274\75\0" - + "\1\275\102\0\1\276\6\0\1\277\2\0\3\300\2\0" - + "\1\301\1\0\4\300\5\0\3\300\2\0\2\300\2\0" - + "\26\300\2\0\1\302\13\0\1\132\1\303\1\304\110\132" - + "\5\305\1\306\105\305\10\0\1\307\123\0\1\140\13\0" - + "\1\140\3\0\2\140\2\154\100\0\1\310\70\0\1\143" - + "\3\0\1\143\1\0\5\143\2\0\4\143\4\0\10\143" - + "\2\0\26\143\50\0\1\311\75\0\1\312\14\0\1\313" - + "\74\0\1\314\4\0\1\315\13\0\1\315\3\0\2\315" - + "\2\0\1\314\77\0\1\316\70\0\1\140\10\0\1\156" - + "\13\0\1\156\3\0\2\156\2\154\56\0\1\140\10\0" - + "\1\156\13\0\1\157\3\0\1\161\1\162\2\154\65\0" - + "\1\317\1\0\1\317\3\0\3\317\5\0\1\320\2\0" - + "\5\317\2\0\1\317\1\0\1\317\1\0\1\317\6\0" - + "\1\317\40\0\1\140\10\0\1\156\13\0\1\162\3\0" - + "\2\162\2\154\56\0\1\140\10\0\1\156\13\0\1\321" - + "\3\0\2\321\2\154\54\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\14\21\1\322\11\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\1\21\1\323\24\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\7\21\1\324\16\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\10\21\2\0\7\21\1\325" - + "\16\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\10\21\1\326\15\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\4\21\1\327\21\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\5\21\1\330\20\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\7\21\1\331\2\0\26\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\10\21\2\0\10\21\1\332\15\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\5\21\1\333\2\21\1\334\15\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\7\21\1\335\16\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\2\21" - + "\1\336\23\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\10\21\2\0\10\21\1\337\15\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\10\21\2\0\2\21\1\340\23\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\17\21\1\341\6\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\11\21" - + "\1\342\14\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\7\21\1\343\2\0\26\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\15\21\1\344\10\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\21\21\1\345\4\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\10\21\2\0\14\21\1\346" - + "\11\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\12\21\1\347\5\21\1\350" - + "\5\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\1\21\1\351\7\21\1\352" - + "\14\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\17\21\1\353\6\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\5\21\1\354\2\21\1\355\15\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\17\21\1\356\6\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\7\21\1\357" - + "\2\0\26\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\10\21\2\0\13\21\1\360\12\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\3\21\1\361\4\21\2\0\14\21\1\362\11\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\10\21\2\0\7\21\1\363\16\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\10\21\1\364\15\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\11\21" - + "\1\365\14\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\10\21\2\0\6\21\1\366\2\21" - + "\1\367\14\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\10\21\2\0\4\21\1\370\21\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\10\21\2\0\1\371\25\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\1\21\1\372\24\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\10\21\2\0\11\21\1\373" - + "\14\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\10\21\1\374\15\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\3\21\1\375\4\21\2\0\26\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\25\21\1\376\15\0\1\21\35\0\1\253\3\0\2\253" - + "\105\0\1\377\3\0\2\377\50\0\1\u0100\2\0\30\u0100" - + "\1\272\1\0\56\u0100\1\273\2\0\30\273\1\u0101\57\273" - + "\15\0\1\u0102\112\0\1\u0103\113\0\3\u0104\4\0\4\u0104" - + "\5\0\3\u0104\2\0\2\u0104\2\0\26\u0104\2\0\1\u0105" - + "\27\0\1\u0106\7\0\1\u0107\76\0\1\300\3\0\1\300" - + "\1\0\5\300\2\0\4\300\4\0\10\300\2\0\26\300" - + "\34\0\3\u0108\4\0\4\u0108\5\0\3\u0108\2\0\2\u0108" - + "\2\0\26\u0108\2\0\1\u0109\15\0\1\304\110\0\5\305" - + "\1\u010a\105\305\4\0\1\304\1\306\137\0\1\u010b\101\0" - + "\1\315\13\0\1\315\3\0\2\315\67\0\1\u010c\1\0" - + "\1\u010c\3\0\3\u010c\5\0\1\u010c\2\0\5\u010c\2\0" - + "\1\u010c\1\0\1\u010c\1\0\1\u010c\6\0\1\u010c\40\0" - + "\1\140\10\0\1\156\13\0\1\u010d\3\0\2\u010d\2\154" - + "\54\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\5\21\1\u010e\20\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\2\21" - + "\1\u010f\23\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\10\21\2\0\4\21\1\u0110\21\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\7\21\1\u0111\2\0\26\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\16\21\1\u0112\7\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\7\21\1\u0113\2\0\26\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\10\21\2\0\2\21\1\u0114\23\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\12\21\1\u0115\13\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\7\21\1\u0116\2\0" - + "\26\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\4\21\1\u0117\21\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\5\21\1\u0118\2\21\1\u0119\15\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\5\21\1\u011a\20\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\10\21\1\u011b\15\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\7\21\1\u011c\2\0\26\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\10\21\2\0\10\21\1\u011d\15\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\1\21\1\u011e\24\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\7\21\1\u011f\2\0" - + "\26\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\14\21\1\u0120\11\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\7\21\1\u0121\2\0\26\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\6\21" - + "\1\u0122\17\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\10\21\2\0\5\21\1\u0123\20\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\7\21\1\u0124\2\0\26\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\10\21\1\u0125\15\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\7\21\1\u0126\2\0\26\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\10\21\2\0\6\21\1\u0127\5\21\1\u0128\11\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\7\21\1\u0129\2\0\26\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\2\21\1\u012a\23\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\7\21\1\u012b\2\0\26\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\10\21\2\0\2\21\1\u012c\23\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\16\21\1\u012d\7\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\14\21" - + "\1\u012e\11\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\10\21\2\0\10\21\1\u012f\15\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\10\21\2\0\22\21\1\u0130\3\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\3\21\1\u0131\22\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\14\21" - + "\1\u0132\11\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\10\21\2\0\13\21\1\u0133\12\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\10\21\2\0\11\21\1\u0134\14\21\15\0\1\21" - + "\1\0\2\u0135\5\0\1\u0104\1\0\1\u0135\1\0\1\u0104" - + "\1\u0136\5\u0104\2\0\4\u0104\4\0\10\u0104\2\0\26\u0104" - + "\32\0\1\u0137\123\0\1\u0138\75\0\1\u0108\3\0\1\u0108" - + "\1\0\5\u0108\2\0\4\u0108\4\0\10\u0108\2\0\26\u0108" - + "\16\0\4\305\1\304\1\u010a\105\305\17\0\1\u0139\1\0" - + "\1\u0139\3\0\3\u0139\5\0\1\u0139\2\0\5\u0139\2\0" - + "\1\u0139\1\0\1\u0139\1\0\1\u0139\6\0\1\u0139\40\0" - + "\1\140\10\0\1\156\13\0\1\u013a\3\0\2\u013a\2\154" - + "\54\0\2\21\7\0\3\21\3\0\4\21\4\0\7\21" - + "\1\u013b\2\0\26\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\10\21\2\0\14\21\1\u013c" - + "\11\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\10\21\1\u013d\15\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\7\21\1\u013e\16\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\3\21\1\u013f\22\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\10\21\2\0\1\21\1\u0140" - + "\24\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\16\21\1\u0141\7\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\10\21\1\u0142\15\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\11\21\1\u0143\14\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\10\21\2\0\5\21\1\u0144" - + "\20\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\11\21\1\u0145\14\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\1\21\1\u0146\24\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\4\21\1\u0147\21\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\10\21\2\0\1\21\1\u0148" - + "\24\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\5\21\1\u0149\20\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\15\21\1\u014a\10\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\6\21\1\u014b\17\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\10\21\2\0\2\21\1\u014c" - + "\23\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\1\21\1\u014d\24\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\1\21\1\u014e\24\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\7\21\1\u014f" - + "\2\0\26\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\3\21\1\u0150\4\21\2\0\26\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\10\21\2\0\12\21\1\u0151\13\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\10\21\1\u0152\15\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\21\21" - + "\1\u0153\4\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\7\21\1\u0154\2\0\26\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\7\21\1\u0155\2\0\26\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\2\21" - + "\1\u0156\23\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\10\21\2\0\2\21\1\u0157\23\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\10\21\2\0\11\21\1\u0158\14\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\7\21\1\u0159\16\21\15\0\1\21\1\0\2\u0135" - + "\7\0\1\u0135\2\0\1\u0136\123\0\1\u015a\103\0\1\u015b" - + "\1\0\1\u015b\3\0\3\u015b\5\0\1\u015b\2\0\5\u015b" - + "\2\0\1\u015b\1\0\1\u015b\1\0\1\u015b\6\0\1\u015b" - + "\40\0\1\140\10\0\1\156\13\0\1\u015c\3\0\2\u015c" - + "\2\154\54\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\14\21\1\u015d\11\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\11\21\1\u015e\14\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\10\21\2\0\13\21\1\u015f" - + "\12\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\7\21\1\u0160\16\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\7\21\1\u0161\16\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\4\21\1\u0162\21\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\10\21\2\0\16\21\1\u0163" - + "\7\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\11\21\1\u0164\14\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\17\21\1\u0165\6\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\3\21\1\u0166" - + "\4\21\2\0\26\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\10\21\2\0\7\21\1\u0167" - + "\16\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\3\21\1\u0168\4\21\2\0\7\21\1\u0169" - + "\16\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\10\21\1\u016a\15\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\21\21\1\u016b\4\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\11\21\1\u016c\14\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\10\21\2\0\14\21\1\u016d" - + "\11\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\7\21\1\u016e\2\0\26\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\11\21\1\u016f\14\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\4\21" - + "\1\u0170\21\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\10\21\2\0\10\21\1\u0171\15\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\10\21\2\0\23\21\1\u0172\2\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\4\21\1\u0173\21\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\11\21" - + "\1\u0174\14\21\15\0\1\21\27\0\1\u0175\102\0\1\u0176" - + "\1\0\1\u0176\3\0\3\u0176\5\0\1\u0176\2\0\5\u0176" - + "\2\0\1\u0176\1\0\1\u0176\1\0\1\u0176\6\0\1\u0176" - + "\40\0\1\140\10\0\1\156\13\0\1\u0177\3\0\2\u0177" - + "\2\154\54\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\20\21\1\u0178\5\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\6\21\1\u0179\17\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\10\21\2\0\5\21\1\u017a" - + "\20\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\12\21\1\u017b\13\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\13\21\1\u017c\12\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\2\21\1\u017d\23\21\15\0\1\21\6\0\2\21\7\0" - + "\3\21\3\0\4\21\4\0\10\21\2\0\4\21\1\u017e" - + "\21\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\2\21\1\u017f\23\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\2\21\1\u0180\23\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\7\21\1\u0181" - + "\2\0\26\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\10\21\2\0\7\21\1\u0182\16\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\10\21\2\0\10\21\1\u0183\15\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\4\21\1\u0184\21\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\10\21" - + "\1\u0185\15\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\7\21\1\u0186\2\0\26\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\7\21\1\u0187\2\0\26\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\10\21" - + "\1\u0188\15\21\15\0\1\21\30\0\1\u0189\101\0\1\u018a" - + "\1\0\1\u018a\3\0\3\u018a\5\0\1\u018a\2\0\5\u018a" - + "\2\0\1\u018a\1\0\1\u018a\1\0\1\u018a\6\0\1\u018a" - + "\40\0\1\140\10\0\1\156\13\0\1\u018b\3\0\2\u018b" - + "\2\154\54\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\7\21\1\u018c\16\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\7\21\1\u018d" - + "\2\0\26\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\7\21\1\u018e\2\0\26\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\4\21\1\u018f\21\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\7\21\1\u0190" - + "\2\0\26\21\15\0\1\21\6\0\2\21\7\0\3\21" - + "\3\0\4\21\4\0\10\21\2\0\4\21\1\u0191\21\21" - + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\10\21\2\0\14\21\1\u0192\11\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\7\21\1\u0193\16\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\7\21\1\u0194\2\0" - + "\26\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\7\21\1\u0195\2\0\26\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\20\21\1\u0196\5\21\15\0\1\21\27\0\1\u0197" - + "\102\0\1\u0198\1\0\1\u0198\3\0\3\u0198\5\0\1\u0198" - + "\2\0\5\u0198\2\0\1\u0198\1\0\1\u0198\1\0\1\u0198" - + "\6\0\1\u0198\40\0\1\140\10\0\1\156\13\0\1\u0199" - + "\3\0\2\u0199\2\154\54\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\7\21\1\u019a\2\0\26\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\6\21\1\u019b\17\21\15\0\1\21\6\0\2\21" - + "\7\0\3\21\3\0\4\21\4\0\7\21\1\u019c\2\0" - + "\26\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" - + "\4\21\4\0\10\21\2\0\10\21\1\u019d\15\21\15\0" - + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" - + "\10\21\2\0\13\21\1\u019e\12\21\15\0\1\21\6\0" - + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" - + "\13\21\1\u019f\12\21\15\0\1\21\24\0\1\u01a0\105\0" - + "\1\u01a1\1\0\1\u01a1\3\0\3\u01a1\5\0\1\u01a1\2\0" - + "\5\u01a1\2\0\1\u01a1\1\0\1\u01a1\1\0\1\u01a1\6\0" - + "\1\u01a1\40\0\1\140\10\0\1\156\13\0\1\u01a2\3\0" - + "\2\u01a2\2\154\54\0\2\21\7\0\3\21\3\0\4\21" - + "\4\0\3\21\1\u01a3\4\21\2\0\26\21\15\0\1\21" - + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" - + "\2\0\5\21\1\u01a4\20\21\15\0\1\21\10\0\1\140" - + "\10\0\1\156\13\0\1\u01a5\3\0\2\u01a5\2\154\56\0" - + "\1\140\10\0\1\156\13\0\1\u01a6\3\0\2\u01a6\2\154" - + "\56\0\1\140\10\0\1\156\13\0\1\u01a7\3\0\2\u01a7" - + "\2\154\56\0\1\140\10\0\1\156\13\0\1\u01a8\3\0" - + "\2\u01a8\2\154\56\0\1\140\10\0\1\156\13\0\1\u01a9" - + "\3\0\2\u01a9\2\154\56\0\1\140\10\0\1\156\13\0" - + "\1\u01aa\3\0\2\u01aa\2\154\46\0"; - - private static int[] zzUnpackTrans() { - int[] result = new int[21825]; - 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; - - /* 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 - = "\12\0\1\11\1\1\1\11\13\1\3\11\1\1\2\11" - + "\25\1\7\11\4\1\1\11\2\1\2\11\3\1\1\11" - + "\2\1\1\11\1\1\1\11\1\1\1\11\2\1\1\11" - + "\1\1\2\11\1\1\1\11\2\1\1\11\1\1\1\0" - + "\2\11\1\1\1\11\1\1\1\11\2\1\2\11\1\1" - + "\2\11\1\1\2\11\1\0\3\1\1\0\11\1\2\11" - + "\44\1\11\11\1\1\1\11\1\1\6\11\1\0\1\11" - + "\1\0\1\11\1\0\2\11\1\0\1\1\5\0\1\1" - + "\1\0\1\11\1\1\1\11\2\0\3\11\1\1\1\11" - + "\1\0\1\1\1\11\60\1\1\11\1\0\3\11\1\0" - + "\1\11\2\0\1\1\1\11\1\0\1\11\51\1\1\0" - + "\2\11\1\0\41\1\1\0\32\1\1\0\23\1\1\0" - + "\15\1\1\0\10\1\2\11\11\1"; - - private static int[] zzUnpackAttribute() { - int[] result = new int[426]; - 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; - - /* user code: */ - private String sourceCode; - - public ActionScriptLexer(String sourceCode) { - this(new StringReader(sourceCode)); - this.sourceCode = sourceCode; - } - - public void yypushbackstr(String s, int state) { - sourceCode = s + sourceCode.substring(yychar + yylength()); - yyreset(new StringReader(sourceCode)); - yybegin(state); - } - - public void yypushbackstr(String s) { - yypushbackstr(s, YYINITIAL); - } - - StringBuffer string = new StringBuffer(); - - private static String xmlTagName = ""; - - public int yychar() { - return yychar; - } - - private Stack pushedBack = new Stack(); - - public int yyline() { - return yyline + 1; - } - private List listeners = new ArrayList<>(); - - public void addListener(LexListener listener) { - listeners.add(listener); - } - - public void removeListener(LexListener listener) { - listeners.remove(listener); - } - - public void informListenersLex(ParsedSymbol s) { - for (LexListener l : listeners) { - l.onLex(s); - } - } - - public void informListenersPushBack(ParsedSymbol s) { - for (LexListener l : listeners) { - l.onPushBack(s); - } - } - - public void pushback(ParsedSymbol symb) { - pushedBack.push(symb); - last = null; - informListenersPushBack(symb); - } - ParsedSymbol last; - - public ParsedSymbol lex() throws java.io.IOException, ParseException { - ParsedSymbol ret = null; - if (!pushedBack.isEmpty()) { - ret = last = pushedBack.pop(); - } else { - ret = last = yylex(); - } - informListenersLex(ret); - return ret; - } - - /** - * 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 ActionScriptLexer(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 ActionScriptLexer(java.io.InputStream in) { - this(new java.io.InputStreamReader(in, java.nio.charset.Charset.forName("UTF-8"))); - } - - /** - * 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 < 2280) { - 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 { - - /* 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; - } - - /* 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); - - 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; - return false; - } - } - - // numRead < 0 - return true; - } - - /** - * Closes the input stream. - * - * @throws java.io.IOException - */ - 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. - * - * Internal scan buffer is resized down to its initial length, if it has - * grown. - * - * @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; - if (zzBuffer.length > ZZ_BUFFERSIZE) { - zzBuffer = new char[ZZ_BUFFERSIZE]; - } - } - - /** - * Returns the current lexical state. - * - * @return - */ - 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. - * - * @return - */ - 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. - * - * @return - */ - 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 - * @throws com.jpexs.decompiler.flash.abc.avm2.parser.ParseException - */ - 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; - - zzAction = -1; - - zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; - - zzState = ZZ_LEXSTATE[zzLexicalState]; - - // set up zzAction for empty match case: - int zzAttributes = zzAttrL[zzState]; - if ((zzAttributes & 1) == 1) { - zzAction = zzState; - } - - 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; - - zzAttributes = zzAttrL[zzState]; - if ((zzAttributes & 1) == 1) { - zzAction = zzState; - zzMarkedPosL = zzCurrentPosL; - if ((zzAttributes & 8) == 8) { - break zzForAction; - } - } - - } - } - - // store back cached position - zzMarkedPos = zzMarkedPosL; - - switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { - case 1: { - } - case 158: - break; - case 2: { - yyline++; - } - case 159: - break; - case 3: { /*ignore*/ - - } - case 160: - break; - case 4: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.DIVIDE, yytext()); - } - case 161: - break; - case 5: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.MULTIPLY, yytext()); - } - case 162: - break; - case 6: { - return new ParsedSymbol(SymbolGroup.IDENTIFIER, SymbolType.IDENTIFIER, yytext()); - } - case 163: - break; - case 7: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.DOT, yytext()); - } - case 164: - break; - case 8: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.LOWER_THAN, yytext()); - } - case 165: - break; - case 9: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.NOT, yytext()); - } - case 166: - break; - case 10: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.MINUS, yytext()); - } - case 167: - break; - case 11: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.GREATER_THAN, yytext()); - } - case 168: - break; - case 12: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.COLON, yytext()); - } - case 169: - break; - case 13: { - return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, new Long(Long.parseLong((yytext())))); - } - case 170: - break; - case 14: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.TERNAR, yytext()); - } - case 171: - break; - case 15: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.BRACKET_OPEN, yytext()); - } - case 172: - break; - case 16: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.BRACKET_CLOSE, yytext()); - } - case 173: - break; - case 17: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN, yytext()); - } - case 174: - break; - case 18: { - string.setLength(0); - yybegin(STRING); - } - case 175: - break; - case 19: { - string.setLength(0); - yybegin(CHARLITERAL); - } - case 176: - break; - case 20: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.PLUS, yytext()); - } - case 177: - break; - case 21: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.PARENT_OPEN, yytext()); - } - case 178: - break; - case 22: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.PARENT_CLOSE, yytext()); - } - case 179: - break; - case 23: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.CURLY_OPEN, yytext()); - } - case 180: - break; - case 24: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.CURLY_CLOSE, yytext()); - } - case 181: - break; - case 25: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.SEMICOLON, yytext()); - } - case 182: - break; - case 26: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.COMMA, yytext()); - } - case 183: - break; - case 27: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.NEGATE, yytext()); - } - case 184: - break; - case 28: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.BITAND, yytext()); - } - case 185: - break; - case 29: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.BITOR, yytext()); - } - case 186: - break; - case 30: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.XOR, yytext()); - } - case 187: - break; - case 31: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.MODULO, yytext()); - } - case 188: - break; - case 32: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ATTRIBUTE, yytext()); - } - case 189: - break; - case 33: { - string.append(yytext()); - } - case 190: - break; - case 34: { - yybegin(YYINITIAL); - yyline++; - } - case 191: - break; - case 35: { - yybegin(YYINITIAL); - // length also includes the trailing quote - return new ParsedSymbol(SymbolGroup.STRING, SymbolType.STRING, string.toString()); - } - case 192: - break; - case 36: { - string.append(yytext()); - yyline++; - } - case 193: - break; - case 37: { - yybegin(XML); - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTTAG_END, yytext())); - if (string.length() > 0) { - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); - string.setLength(0); - } - return lex(); - } - case 194: - break; - case 38: { - yybegin(YYINITIAL); - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_ATTRNAMEVAR_BEGIN, yytext())); - if (string.length() > 0) { - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); - string.setLength(0); - } - return lex(); - } - case 195: - break; - case 39: { - yybegin(YYINITIAL); - return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_ATTRVALVAR_BEGIN, yytext()); - } - case 196: - break; - case 40: { - yybegin(YYINITIAL); - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_INSTRATTRNAMEVAR_BEGIN, yytext())); - if (string.length() > 0) { - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); - string.setLength(0); - } - return lex(); - } - case 197: - break; - case 41: { - yybegin(YYINITIAL); - return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_INSTRATTRVALVAR_BEGIN, yytext()); - } - case 198: - break; - case 42: { - string.append(yytext()); - } - case 199: - break; - case 43: { - yybegin(YYINITIAL); - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_VAR_BEGIN, yytext())); - if (string.length() > 0) { - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); - string.setLength(0); - } - return lex(); - } - case 200: - break; - case 44: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_DIVIDE, yytext()); - } - case 201: - break; - case 45: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_MULTIPLY, yytext()); - } - case 202: - break; - case 46: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.DESCENDANTS, yytext()); - } - case 203: - break; - case 47: { - return new ParsedSymbol(SymbolGroup.TYPENAME, SymbolType.TYPENAME, yytext()); - } - case 204: - break; - case 48: { - return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, new Double(Double.parseDouble((yytext())))); - } - case 205: - break; - case 49: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.FILTER, yytext()); - } - case 206: - break; - case 50: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.SHIFT_LEFT, yytext()); - } - case 207: - break; - case 51: { - yybegin(XMLOPENTAG); - string.setLength(0); - return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTTAG_BEGIN, yytext()); - } - case 208: - break; - case 52: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.LOWER_EQUAL, yytext()); - } - case 209: - break; - case 53: { - return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTVARTAG_BEGIN, yytext()); - } - case 210: - break; - case 54: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.NOT_EQUAL, yytext()); - } - case 211: - break; - case 55: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.DECREMENT, yytext()); - } - case 212: - break; - case 56: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_MINUS, yytext()); - } - case 213: - break; - case 57: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.SHIFT_RIGHT, yytext()); - } - case 214: - break; - case 58: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.GREATER_EQUAL, yytext()); - } - case 215: - break; - case 59: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.NAMESPACE_OP, yytext()); - } - case 216: - break; - case 60: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.EQUALS, yytext()); - } - case 217: - break; - case 61: { - return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, new Long(Long.parseLong(yytext(), 8))); - } - case 218: - break; - case 62: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_PLUS, yytext()); - } - case 219: - break; - case 63: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.INCREMENT, yytext()); - } - case 220: - break; - case 64: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.AS, yytext()); - } - case 221: - break; - case 65: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.IF, yytext()); - } - case 222: - break; - case 66: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.IS, yytext()); - } - case 223: - break; - case 67: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.IN, yytext()); - } - case 224: - break; - case 68: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.DO, yytext()); - } - case 225: - break; - case 69: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_BITAND, yytext()); - } - case 226: - break; - case 70: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.AND, yytext()); - } - case 227: - break; - case 71: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_BITOR, yytext()); - } - case 228: - break; - case 72: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.OR, yytext()); - } - case 229: - break; - case 73: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_XOR, yytext()); - } - case 230: - break; - case 74: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_MODULO, yytext()); - } - case 231: - break; - case 75: { - throw new ParseException("Illegal escape sequence \"" + yytext() + "\"", yyline + 1); - } - case 232: - break; - case 76: { - string.append('\"'); - } - case 233: - break; - case 77: { - string.append('\''); - } - case 234: - break; - case 78: { - char val = (char) Integer.parseInt(yytext().substring(1), 8); - string.append(val); - } - case 235: - break; - case 79: { - string.append('\f'); - } - case 236: - break; - case 80: { - string.append('\\'); - } - case 237: - break; - case 81: { - string.append('\b'); - } - case 238: - break; - case 82: { - string.append('\r'); - } - case 239: - break; - case 83: { - string.append('\n'); - } - case 240: - break; - case 84: { - string.append('\t'); - } - case 241: - break; - case 85: { - yybegin(XML); - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTFINISHTAG_END, yytext())); - if (string.length() > 0) { - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); - string.setLength(0); - } - return lex(); - } - case 242: - break; - case 86: { - yybegin(XMLOPENTAGATTRIB); - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_ATTRIBUTENAME, yytext())); - if (string.length() > 0) { - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); - string.setLength(0); - } - return lex(); - } - case 243: - break; - case 87: { - yybegin(XMLOPENTAG); - return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_ATTRIBUTEVALUE, yytext()); - } - case 244: - break; - case 88: { - yybegin(XMLINSTRATTRIB); - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_ATTRIBUTENAME, yytext())); - if (string.length() > 0) { - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); - string.setLength(0); - } - return lex(); - } - case 245: - break; - case 89: { - yybegin(XML); - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_INSTR_END, yytext())); - if (string.length() > 0) { - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); - string.setLength(0); - } - return lex(); - } - case 246: - break; - case 90: { - yybegin(XMLINSTROPENTAG); - return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_ATTRIBUTEVALUE, yytext()); - } - case 247: - break; - case 91: { - yybegin(XMLOPENTAG); - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTTAG_BEGIN, yytext())); - if (string.length() > 0) { - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); - string.setLength(0); - } - return lex(); - } - case 248: - break; - case 92: { - yybegin(YYINITIAL); - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTVARTAG_BEGIN, yytext())); - if (string.length() > 0) { - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); - string.setLength(0); - } - return lex(); - } - case 249: - break; - case 93: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.REST, yytext()); - } - case 250: - break; - case 94: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_SHIFT_LEFT, yytext()); - } - case 251: - break; - case 95: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.STRICT_NOT_EQUAL, yytext()); - } - case 252: - break; - case 96: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.USHIFT_RIGHT, yytext()); - } - case 253: - break; - case 97: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_SHIFT_RIGHT, yytext()); - } - case 254: - break; - case 98: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.STRICT_EQUALS, yytext()); - } - case 255: - break; - case 99: { - return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, new Long(Long.parseLong(yytext().substring(2), 16))); - } - case 256: - break; - case 100: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.FOR, yytext()); - } - case 257: - break; - case 101: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.SET, yytext()); - } - case 258: - break; - case 102: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.NEW, yytext()); - } - case 259: - break; - case 103: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.TRY, yytext()); - } - case 260: - break; - case 104: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.USE, yytext()); - } - case 261: - break; - case 105: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.VAR, yytext()); - } - case 262: - break; - case 106: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.GET, yytext()); - } - case 263: - break; - case 107: { - return new ParsedSymbol(SymbolGroup.GLOBALCONST, SymbolType.NAN, yytext()); - } - case 264: - break; - case 108: { - string.append(yytext()); - yybegin(XML); - String ret = string.toString(); - string.setLength(0); - return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_CDATA, ret); - } - case 265: - break; - case 109: { - string.append(yytext()); - yybegin(XML); - String ret = string.toString(); - string.setLength(0); - return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_COMMENT, ret); - } - case 266: - break; - case 110: { - yybegin(YYINITIAL); - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_FINISHVARTAG_BEGIN, yytext())); - if (string.length() > 0) { - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); - string.setLength(0); - } - return lex(); - } - case 267: - break; - case 111: { - yybegin(XMLINSTROPENTAG); - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_INSTR_BEGIN, yytext())); - if (string.length() > 0) { - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); - string.setLength(0); - } - return lex(); - } - case 268: - break; - case 112: { - yybegin(YYINITIAL); - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_INSTRVARTAG_BEGIN, yytext())); - if (string.length() > 0) { - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); - string.setLength(0); - } - return lex(); - } - case 269: - break; - case 113: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_USHIFT_RIGHT, yytext()); - } - case 270: - break; - case 114: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.EACH, yytext()); - } - case 271: - break; - case 115: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.ELSE, yytext()); - } - case 272: - break; - case 116: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.CASE, yytext()); - } - case 273: - break; - case 117: { - return new ParsedSymbol(SymbolGroup.GLOBALCONST, SymbolType.NULL, yytext()); - } - case 274: - break; - case 118: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.TRUE, yytext()); - } - case 275: - break; - case 119: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.THIS, yytext()); - } - case 276: - break; - case 120: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.WITH, yytext()); - } - case 277: - break; - case 121: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.VOID, yytext()); - } - case 278: - break; - case 122: { - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_FINISHTAG, yytext())); - if (string.length() > 0) { - pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); - string.setLength(0); - } - return lex(); - } - case 279: - break; - case 123: { - String ret = string.toString(); - string.setLength(0); - string.append(yytext()); - yybegin(XMLCOMMENT); - if (!ret.isEmpty()) { - return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, ret); - } - } - case 280: - break; - case 124: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.FALSE, yytext()); - } - case 281: - break; - case 125: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.FINAL, yytext()); - } - case 282: - break; - case 126: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.BREAK, yytext()); - } - case 283: - break; - case 127: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.CATCH, yytext()); - } - case 284: - break; - case 128: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.CONST, yytext()); - } - case 285: - break; - case 129: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.CLASS, yytext()); - } - case 286: - break; - case 130: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.SUPER, yytext()); - } - case 287: - break; - case 131: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.THROW, yytext()); - } - case 288: - break; - case 132: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.WHILE, yytext()); - } - case 289: - break; - case 133: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.RETURN, yytext()); - } - case 290: - break; - case 134: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.STATIC, yytext()); - } - case 291: - break; - case 135: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.SWITCH, yytext()); - } - case 292: - break; - case 136: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.TYPEOF, yytext()); - } - case 293: - break; - case 137: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.IMPORT, yytext()); - } - case 294: - break; - case 138: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.DELETE, yytext()); - } - case 295: - break; - case 139: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.PUBLIC, yytext()); - } - case 296: - break; - case 140: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.FINALLY, yytext()); - } - case 297: - break; - case 141: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.EXTENDS, yytext()); - } - case 298: - break; - case 142: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.DEFAULT, yytext()); - } - case 299: - break; - case 143: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.DYNAMIC, yytext()); - } - case 300: - break; - case 144: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.PRIVATE, yytext()); - } - case 301: - break; - case 145: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.PACKAGE, yytext()); - } - case 302: - break; - case 146: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.FUNCTION, yytext()); - } - case 303: - break; - case 147: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.CONTINUE, yytext()); - } - case 304: - break; - case 148: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.OVERRIDE, yytext()); - } - case 305: - break; - case 149: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.INTERNAL, yytext()); - } - case 306: - break; - case 150: { - return new ParsedSymbol(SymbolGroup.GLOBALCONST, SymbolType.INFINITY, yytext()); - } - case 307: - break; - case 151: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.NAMESPACE, yytext()); - } - case 308: - break; - case 152: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.INTERFACE, yytext()); - } - case 309: - break; - case 153: { - return new ParsedSymbol(SymbolGroup.GLOBALCONST, SymbolType.UNDEFINED, yytext()); - } - case 310: - break; - case 154: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.PROTECTED, yytext()); - } - case 311: - break; - case 155: { - String ret = string.toString(); - string.setLength(0); - string.append(yytext()); - yybegin(XMLCDATA); - if (!ret.isEmpty()) { - return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, ret); - } - } - case 312: - break; - case 156: { - return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.INSTANCEOF, yytext()); - } - case 313: - break; - case 157: { - return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.IMPLEMENTS, yytext()); - } - case 314: - break; - default: - if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { - zzAtEOF = true; - { - return new ParsedSymbol(SymbolGroup.EOF, SymbolType.EOF, null); - } - } else { - zzScanError(ZZ_NO_MATCH); - } - } - } - } - -} +/* The following code was generated by JFlex 1.5.0-SNAPSHOT */ + +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.abc.avm2.parser.script; + +import com.jpexs.decompiler.flash.abc.avm2.parser.ParseException; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; + +/** + * This class is a scanner generated by + * JFlex 1.5.0-SNAPSHOT from the + * specification file + * D:/Dropbox/Programovani/JavaSE/FFDec/trunk/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/actionscript.flex + */ +public final class ActionScriptLexer { + + /** + * 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 YYINITIAL = 0; + public static final int STRING = 2; + public static final int CHARLITERAL = 4; + public static final int XMLOPENTAG = 6; + public static final int XMLOPENTAGATTRIB = 8; + public static final int XMLINSTROPENTAG = 10; + public static final int XMLINSTRATTRIB = 12; + public static final int XMLCDATA = 14; + public static final int XMLCOMMENT = 16; + public static final int XML = 18; + + /** + * 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, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, + 8, 8, 9, 9 + }; + + /** + * Translates characters to character classes + */ + private static final String ZZ_CMAP_PACKED + = "\11\7\1\12\1\2\1\111\1\3\1\1\16\7\4\0\1\12\1\13" + + "\1\33\1\0\1\6\1\107\1\104\1\34\1\75\1\76\1\5\1\45" + + "\1\102\1\14\1\10\1\4\1\35\3\41\4\42\2\21\1\16\1\101" + + "\1\11\1\32\1\15\1\23\1\110\1\27\1\17\1\25\1\26\1\43" + + "\1\17\2\20\1\73\4\20\1\74\5\20\1\30\3\20\1\37\2\20" + + "\1\24\1\46\1\31\1\106\1\20\1\0\1\51\1\47\1\53\1\62" + + "\1\44\1\40\1\72\1\65\1\60\1\20\1\52\1\63\1\70\1\56" + + "\1\55\1\66\1\20\1\50\1\54\1\57\1\61\1\71\1\64\1\36" + + "\1\67\1\20\1\77\1\105\1\100\1\103\6\7\1\112\32\7\2\0" + + "\4\6\4\0\1\6\2\0\1\7\7\0\1\6\1\0\1\22\2\0" + + "\1\6\5\0\27\6\1\0\37\6\1\0\u01ca\6\4\0\14\6\16\0" + + "\5\6\7\0\1\6\1\0\1\6\21\0\160\7\5\6\1\0\2\6" + + "\2\0\4\6\1\0\7\0\1\6\1\0\3\6\1\0\1\6\1\0" + + "\24\6\1\0\123\6\1\0\213\6\1\0\5\7\2\0\236\6\11\0" + + "\46\6\2\0\1\6\7\0\47\6\11\0\55\7\1\0\1\7\1\0" + + "\2\7\1\0\2\7\1\0\1\7\10\0\33\6\5\0\3\6\15\0" + + "\4\7\7\0\1\6\4\0\13\7\5\0\53\6\37\7\4\0\2\6" + + "\1\7\143\6\1\0\1\6\10\7\1\0\6\7\2\6\2\7\1\0" + + "\4\7\2\6\12\7\3\6\2\0\1\6\17\0\1\7\1\6\1\7" + + "\36\6\33\7\2\0\131\6\13\7\1\6\16\0\12\7\41\6\11\7" + + "\2\6\4\0\1\6\5\0\26\6\4\7\1\6\11\7\1\6\3\7" + + "\1\6\5\7\22\0\31\6\3\7\244\0\4\7\66\6\3\7\1\6" + + "\22\7\1\6\7\7\12\6\2\7\2\0\12\7\1\0\7\6\1\0" + + "\7\6\1\0\3\7\1\0\10\6\2\0\2\6\2\0\26\6\1\0" + + "\7\6\1\0\1\6\3\0\4\6\2\0\1\7\1\6\7\7\2\0" + + "\2\7\2\0\3\7\1\6\10\0\1\7\4\0\2\6\1\0\3\6" + + "\2\7\2\0\12\7\4\6\7\0\1\6\5\0\3\7\1\0\6\6" + + "\4\0\2\6\2\0\26\6\1\0\7\6\1\0\2\6\1\0\2\6" + + "\1\0\2\6\2\0\1\7\1\0\5\7\4\0\2\7\2\0\3\7" + + "\3\0\1\7\7\0\4\6\1\0\1\6\7\0\14\7\3\6\1\7" + + "\13\0\3\7\1\0\11\6\1\0\3\6\1\0\26\6\1\0\7\6" + + "\1\0\2\6\1\0\5\6\2\0\1\7\1\6\10\7\1\0\3\7" + + "\1\0\3\7\2\0\1\6\17\0\2\6\2\7\2\0\12\7\1\0" + + "\1\6\17\0\3\7\1\0\10\6\2\0\2\6\2\0\26\6\1\0" + + "\7\6\1\0\2\6\1\0\5\6\2\0\1\7\1\6\7\7\2\0" + + "\2\7\2\0\3\7\10\0\2\7\4\0\2\6\1\0\3\6\2\7" + + "\2\0\12\7\1\0\1\6\20\0\1\7\1\6\1\0\6\6\3\0" + + "\3\6\1\0\4\6\3\0\2\6\1\0\1\6\1\0\2\6\3\0" + + "\2\6\3\0\3\6\3\0\14\6\4\0\5\7\3\0\3\7\1\0" + + "\4\7\2\0\1\6\6\0\1\7\16\0\12\7\11\0\1\6\7\0" + + "\3\7\1\0\10\6\1\0\3\6\1\0\27\6\1\0\12\6\1\0" + + "\5\6\3\0\1\6\7\7\1\0\3\7\1\0\4\7\7\0\2\7" + + "\1\0\2\6\6\0\2\6\2\7\2\0\12\7\22\0\2\7\1\0" + + "\10\6\1\0\3\6\1\0\27\6\1\0\12\6\1\0\5\6\2\0" + + "\1\7\1\6\7\7\1\0\3\7\1\0\4\7\7\0\2\7\7\0" + + "\1\6\1\0\2\6\2\7\2\0\12\7\1\0\2\6\17\0\2\7" + + "\1\0\10\6\1\0\3\6\1\0\51\6\2\0\1\6\7\7\1\0" + + "\3\7\1\0\4\7\1\6\10\0\1\7\10\0\2\6\2\7\2\0" + + "\12\7\12\0\6\6\2\0\2\7\1\0\22\6\3\0\30\6\1\0" + + "\11\6\1\0\1\6\2\0\7\6\3\0\1\7\4\0\6\7\1\0" + + "\1\7\1\0\10\7\22\0\2\7\15\0\60\6\1\7\2\6\7\7" + + "\4\0\10\6\10\7\1\0\12\7\47\0\2\6\1\0\1\6\2\0" + + "\2\6\1\0\1\6\2\0\1\6\6\0\4\6\1\0\7\6\1\0" + + "\3\6\1\0\1\6\1\0\1\6\2\0\2\6\1\0\4\6\1\7" + + "\2\6\6\7\1\0\2\7\1\6\2\0\5\6\1\0\1\6\1\0" + + "\6\7\2\0\12\7\2\0\2\6\42\0\1\6\27\0\2\7\6\0" + + "\12\7\13\0\1\7\1\0\1\7\1\0\1\7\4\0\2\7\10\6" + + "\1\0\44\6\4\0\24\7\1\0\2\7\5\6\13\7\1\0\44\7" + + "\11\0\1\7\71\0\53\6\24\7\1\6\12\7\6\0\6\6\4\7" + + "\4\6\3\7\1\6\3\7\2\6\7\7\3\6\4\7\15\6\14\7" + + "\1\6\17\7\2\0\46\6\12\0\53\6\1\0\1\6\3\0\u0149\6" + + "\1\0\4\6\2\0\7\6\1\0\1\6\1\0\4\6\2\0\51\6" + + "\1\0\4\6\2\0\41\6\1\0\4\6\2\0\7\6\1\0\1\6" + + "\1\0\4\6\2\0\17\6\1\0\71\6\1\0\4\6\2\0\103\6" + + "\2\0\3\7\40\0\20\6\20\0\125\6\14\0\u026c\6\2\0\21\6" + + "\1\0\32\6\5\0\113\6\3\0\3\6\17\0\15\6\1\0\4\6" + + "\3\7\13\0\22\6\3\7\13\0\22\6\2\7\14\0\15\6\1\0" + + "\3\6\1\0\2\7\14\0\64\6\40\7\3\0\1\6\3\0\2\6" + + "\1\7\2\0\12\7\41\0\3\7\2\0\12\7\6\0\130\6\10\0" + + "\51\6\1\7\1\6\5\0\106\6\12\0\35\6\3\0\14\7\4\0" + + "\14\7\12\0\12\7\36\6\2\0\5\6\13\0\54\6\4\0\21\7" + + "\7\6\2\7\6\0\12\7\46\0\27\6\5\7\4\0\65\6\12\7" + + "\1\0\35\7\2\0\13\7\6\0\12\7\15\0\1\6\130\0\5\7" + + "\57\6\21\7\7\6\4\0\12\7\21\0\11\7\14\0\3\7\36\6" + + "\12\7\3\0\2\6\12\7\6\0\46\6\16\7\14\0\44\6\24\7" + + "\10\0\12\7\3\0\3\6\12\7\44\6\122\0\3\7\1\0\25\7" + + "\4\6\1\7\4\6\1\7\15\0\300\6\47\7\25\0\4\7\u0116\6" + + "\2\0\6\6\2\0\46\6\2\0\6\6\2\0\10\6\1\0\1\6" + + "\1\0\1\6\1\0\1\6\1\0\37\6\2\0\65\6\1\0\7\6" + + "\1\0\1\6\3\0\3\6\1\0\7\6\3\0\4\6\2\0\6\6" + + "\4\0\15\6\5\0\3\6\1\0\7\6\3\0\13\0\1\7\2\7" + + "\2\7\30\0\1\111\1\111\5\7\20\0\2\6\23\0\1\6\13\0" + + "\5\7\5\0\6\7\1\0\1\6\15\0\1\6\20\0\15\6\3\0" + + "\32\6\26\0\15\7\4\0\1\7\3\0\14\7\21\0\1\6\4\0" + + "\1\6\2\0\12\6\1\0\1\6\3\0\5\6\6\0\1\6\1\0" + + "\1\6\1\0\1\6\1\0\4\6\1\0\13\6\2\0\4\6\5\0" + + "\5\6\4\0\1\6\21\0\51\6\7\0\u0a70\0\57\6\1\0\57\6" + + "\1\0\205\6\6\0\4\6\3\7\16\0\46\6\12\0\66\6\11\0" + + "\1\6\17\0\1\7\27\6\11\0\7\6\1\0\7\6\1\0\7\6" + + "\1\0\7\6\1\0\7\6\1\0\7\6\1\0\7\6\1\0\7\6" + + "\1\0\40\7\57\0\1\6\u01c0\0\21\0\4\0\3\6\31\0\11\6" + + "\6\7\1\0\5\6\2\0\5\6\4\0\126\6\2\0\2\7\2\0" + + "\3\6\1\0\132\6\1\0\4\6\5\0\51\6\3\0\136\6\21\0" + + "\33\6\65\0\20\6\u0200\0\u19b6\6\112\0\u51cc\6\64\0\u048d\6\103\0" + + "\56\6\2\0\u010d\6\3\0\20\6\12\7\2\6\24\0\57\6\1\7" + + "\14\0\2\7\1\0\31\6\10\0\120\6\2\7\45\0\11\6\2\0" + + "\147\6\2\0\4\6\1\0\2\6\16\0\12\6\120\0\10\6\1\7" + + "\3\6\1\7\4\6\1\7\27\6\5\7\20\0\1\6\7\0\64\6" + + "\14\0\2\7\62\6\21\7\13\0\12\7\6\0\22\7\6\6\3\0" + + "\1\6\4\0\12\7\34\6\10\7\2\0\27\6\15\7\14\0\35\6" + + "\3\0\4\7\57\6\16\7\16\0\1\6\12\7\46\0\51\6\16\7" + + "\11\0\3\6\1\7\10\6\2\7\2\0\12\7\6\0\27\6\3\0" + + "\1\6\1\7\4\0\60\6\1\7\1\6\3\7\2\6\2\7\5\6" + + "\2\7\1\6\1\7\1\6\30\0\3\6\43\0\6\6\2\0\6\6" + + "\2\0\6\6\11\0\7\6\1\0\7\6\221\0\43\6\10\7\1\0" + + "\2\7\2\0\12\7\6\0\u2ba4\6\14\0\27\6\4\0\61\6\4\0" + + "\u1800\0\u0900\0\u012e\6\2\0\76\6\2\0\152\6\46\0\7\6\14\0" + + "\5\6\5\0\1\6\1\7\12\6\1\0\15\6\1\0\5\6\1\0" + + "\1\6\1\0\2\6\1\0\2\6\1\0\154\6\41\0\u016b\6\22\0" + + "\100\6\2\0\66\6\10\0\40\0\15\6\3\0\20\7\20\0\7\7" + + "\14\0\2\6\30\0\3\6\31\0\1\6\6\0\5\6\1\0\207\6" + + "\2\0\1\7\4\0\1\6\13\0\12\7\7\0\32\6\4\0\1\6" + + "\1\0\32\6\13\0\131\6\3\0\6\6\2\0\6\6\2\0\6\6" + + "\2\0\3\6\3\0\2\6\3\0\2\6\22\0\3\7\2\0\2\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 + = "\12\0\1\1\2\2\1\3\1\4\1\5\1\6\1\7" + + "\1\10\1\11\1\12\1\13\1\14\1\15\1\16\1\17" + + "\1\20\1\21\1\22\1\23\1\15\2\6\1\24\21\6" + + "\1\25\1\26\1\27\1\30\1\31\1\32\1\33\1\34" + + "\1\35\1\36\1\37\1\40\1\41\2\42\1\43\1\1" + + "\1\41\2\44\1\41\1\1\1\45\1\1\1\46\1\1" + + "\1\47\2\1\1\50\1\1\1\51\2\41\2\52\1\41" + + "\1\53\1\3\1\0\1\54\1\55\1\56\1\57\1\60" + + "\1\61\1\62\1\63\1\64\1\65\1\66\1\67\1\70" + + "\1\71\1\72\1\73\1\0\1\74\1\60\1\75\1\0" + + "\2\75\7\6\1\76\1\77\2\6\1\100\16\6\1\101" + + "\1\102\1\103\4\6\1\104\13\6\1\105\1\106\1\107" + + "\1\110\1\111\1\112\1\113\1\114\1\115\1\116\1\117" + + "\1\116\1\120\1\121\1\122\1\123\1\124\1\125\1\0" + + "\1\126\1\0\1\127\1\0\1\130\1\131\1\0\1\132" + + "\5\0\1\133\1\0\1\134\2\3\2\0\1\135\1\136" + + "\1\137\1\140\1\141\1\0\1\60\1\142\2\143\1\75" + + "\1\6\1\144\13\6\1\145\4\6\1\146\3\6\1\147" + + "\6\6\1\150\12\6\1\151\1\6\1\152\1\6\1\153" + + "\1\116\1\0\1\132\1\154\1\155\1\0\1\156\2\0" + + "\1\157\1\160\1\0\1\161\1\143\1\75\4\6\1\162" + + "\1\163\2\6\1\164\11\6\1\165\1\166\1\6\1\167" + + "\11\6\1\170\5\6\1\171\1\6\1\0\1\172\1\173" + + "\1\0\1\143\1\75\1\174\1\175\2\6\1\176\1\6" + + "\1\177\1\200\1\6\1\201\1\6\1\202\3\6\1\203" + + "\11\6\1\204\5\6\1\0\1\143\1\75\3\6\1\205" + + "\1\6\1\206\1\207\2\6\1\210\3\6\1\211\3\6" + + "\1\212\4\6\1\213\1\6\1\0\1\143\1\75\1\214" + + "\1\6\1\215\10\6\1\216\1\217\1\6\1\220\1\221" + + "\1\6\1\0\1\143\1\75\1\222\1\223\1\224\3\6" + + "\1\225\3\6\1\226\1\0\1\143\1\75\1\227\1\6" + + "\1\230\1\6\1\231\1\232\1\233\1\143\1\75\1\234" + + "\1\235\6\75"; + + private static int[] zzUnpackAction() { + int[] result = new int[426]; + 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\113\0\226\0\341\0\u012c\0\u0177\0\u01c2\0\u020d" + + "\0\u0258\0\u02a3\0\u02ee\0\u0339\0\u02ee\0\u0384\0\u03cf\0\u041a" + + "\0\u0465\0\u04b0\0\u04fb\0\u0546\0\u0591\0\u05dc\0\u0627\0\u0672" + + "\0\u02ee\0\u02ee\0\u02ee\0\u06bd\0\u02ee\0\u02ee\0\u0708\0\u0753" + + "\0\u079e\0\u07e9\0\u0834\0\u087f\0\u08ca\0\u0915\0\u0960\0\u09ab" + + "\0\u09f6\0\u0a41\0\u0a8c\0\u0ad7\0\u0b22\0\u0b6d\0\u0bb8\0\u0c03" + + "\0\u0c4e\0\u0c99\0\u0ce4\0\u02ee\0\u02ee\0\u02ee\0\u02ee\0\u02ee" + + "\0\u02ee\0\u02ee\0\u0d2f\0\u0d7a\0\u0dc5\0\u0e10\0\u02ee\0\u0e5b" + + "\0\u0ea6\0\u02ee\0\u02ee\0\u0ef1\0\u0f3c\0\u0f87\0\u02ee\0\u0fd2" + + "\0\u101d\0\u02ee\0\u1068\0\u02ee\0\u10b3\0\u02ee\0\u10fe\0\u1149" + + "\0\u02ee\0\u1194\0\u02ee\0\u02ee\0\u11df\0\u02ee\0\u122a\0\u1275" + + "\0\u02ee\0\u12c0\0\u130b\0\u02ee\0\u02ee\0\u1356\0\u02ee\0\u13a1" + + "\0\u02ee\0\u13ec\0\u1437\0\u02ee\0\u02ee\0\u1482\0\u02ee\0\u02ee" + + "\0\u14cd\0\u02ee\0\u02ee\0\u1518\0\u1563\0\u15ae\0\u15f9\0\u1644" + + "\0\u168f\0\u16da\0\u1725\0\u1770\0\u17bb\0\u1806\0\u1851\0\u189c" + + "\0\u18e7\0\u02ee\0\u02ee\0\u1932\0\u197d\0\u0465\0\u19c8\0\u1a13" + + "\0\u1a5e\0\u1aa9\0\u1af4\0\u1b3f\0\u1b8a\0\u1bd5\0\u1c20\0\u1c6b" + + "\0\u1cb6\0\u1d01\0\u1d4c\0\u1d97\0\u0465\0\u0465\0\u1de2\0\u1e2d" + + "\0\u1e78\0\u1ec3\0\u1f0e\0\u0465\0\u1f59\0\u1fa4\0\u1fef\0\u203a" + + "\0\u2085\0\u20d0\0\u211b\0\u2166\0\u21b1\0\u21fc\0\u2247\0\u02ee" + + "\0\u02ee\0\u02ee\0\u02ee\0\u02ee\0\u02ee\0\u02ee\0\u02ee\0\u02ee" + + "\0\u2292\0\u02ee\0\u22dd\0\u02ee\0\u02ee\0\u02ee\0\u02ee\0\u02ee" + + "\0\u02ee\0\u1068\0\u02ee\0\u10b3\0\u02ee\0\u10fe\0\u02ee\0\u02ee" + + "\0\u1194\0\u2328\0\u2373\0\u23be\0\u2409\0\u2454\0\u249f\0\u24ea" + + "\0\u2535\0\u02ee\0\u2580\0\u02ee\0\u25cb\0\u2616\0\u02ee\0\u02ee" + + "\0\u02ee\0\u2661\0\u02ee\0\u26ac\0\u26ac\0\u02ee\0\u26f7\0\u1644" + + "\0\u2742\0\u278d\0\u0465\0\u27d8\0\u2823\0\u286e\0\u28b9\0\u2904" + + "\0\u294f\0\u299a\0\u29e5\0\u2a30\0\u2a7b\0\u2ac6\0\u0465\0\u2b11" + + "\0\u2b5c\0\u2ba7\0\u2bf2\0\u0465\0\u2c3d\0\u2c88\0\u2cd3\0\u0465" + + "\0\u2d1e\0\u2d69\0\u2db4\0\u2dff\0\u2e4a\0\u2e95\0\u0465\0\u2ee0" + + "\0\u2f2b\0\u2f76\0\u2fc1\0\u300c\0\u3057\0\u30a2\0\u30ed\0\u3138" + + "\0\u3183\0\u0465\0\u31ce\0\u0465\0\u3219\0\u0465\0\u02ee\0\u2328" + + "\0\u02ee\0\u02ee\0\u02ee\0\u3264\0\u02ee\0\u32af\0\u32fa\0\u3345" + + "\0\u02ee\0\u3390\0\u02ee\0\u33db\0\u3426\0\u3471\0\u34bc\0\u3507" + + "\0\u3552\0\u0465\0\u0465\0\u359d\0\u35e8\0\u0465\0\u3633\0\u367e" + + "\0\u36c9\0\u3714\0\u375f\0\u37aa\0\u37f5\0\u3840\0\u388b\0\u0465" + + "\0\u0465\0\u38d6\0\u0465\0\u3921\0\u396c\0\u39b7\0\u3a02\0\u3a4d" + + "\0\u3a98\0\u3ae3\0\u3b2e\0\u3b79\0\u0465\0\u3bc4\0\u3c0f\0\u3c5a" + + "\0\u3ca5\0\u3cf0\0\u0465\0\u3d3b\0\u3d86\0\u02ee\0\u02ee\0\u3dd1" + + "\0\u3e1c\0\u3e67\0\u0465\0\u3eb2\0\u3efd\0\u3f48\0\u0465\0\u3f93" + + "\0\u0465\0\u0465\0\u3fde\0\u0465\0\u4029\0\u0465\0\u4074\0\u40bf" + + "\0\u410a\0\u0465\0\u4155\0\u41a0\0\u41eb\0\u4236\0\u4281\0\u42cc" + + "\0\u4317\0\u4362\0\u43ad\0\u0465\0\u43f8\0\u4443\0\u448e\0\u44d9" + + "\0\u4524\0\u456f\0\u45ba\0\u4605\0\u4650\0\u469b\0\u46e6\0\u0465" + + "\0\u4731\0\u0465\0\u0465\0\u477c\0\u47c7\0\u0465\0\u4812\0\u485d" + + "\0\u48a8\0\u0465\0\u48f3\0\u493e\0\u4989\0\u0465\0\u49d4\0\u4a1f" + + "\0\u4a6a\0\u4ab5\0\u0465\0\u4b00\0\u4b4b\0\u4b96\0\u4be1\0\u0465" + + "\0\u4c2c\0\u0465\0\u4c77\0\u4cc2\0\u4d0d\0\u4d58\0\u4da3\0\u4dee" + + "\0\u4e39\0\u4e84\0\u0465\0\u0465\0\u4ecf\0\u0465\0\u0465\0\u4f1a" + + "\0\u4f65\0\u4fb0\0\u4ffb\0\u0465\0\u0465\0\u0465\0\u5046\0\u5091" + + "\0\u50dc\0\u0465\0\u5127\0\u5172\0\u51bd\0\u0465\0\u5208\0\u5253" + + "\0\u529e\0\u0465\0\u52e9\0\u0465\0\u5334\0\u0465\0\u0465\0\u02ee" + + "\0\u02ee\0\u537f\0\u0465\0\u0465\0\u53ca\0\u5415\0\u5460\0\u54ab" + + "\0\u54f6\0\u15ae"; + + private static int[] zzUnpackRowMap() { + int[] result = new int[426]; + 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 + = "\1\13\1\14\1\15\1\16\1\17\1\20\1\21\1\13" + + "\1\22\1\23\1\16\1\24\1\25\1\26\1\27\2\21" + + "\1\30\1\13\1\31\1\32\4\21\1\33\1\34\1\35" + + "\1\36\1\37\2\21\1\40\2\30\1\21\1\41\1\42" + + "\1\13\1\43\1\44\1\45\1\21\1\46\1\47\1\50" + + "\1\51\1\52\1\53\1\54\1\55\1\21\1\56\1\21" + + "\1\57\2\21\1\60\1\61\1\62\1\63\1\64\1\65" + + "\1\66\1\67\1\70\1\71\1\72\1\73\1\74\1\75" + + "\1\76\1\77\2\0\1\100\1\101\1\102\30\100\1\103" + + "\12\100\1\104\44\100\1\105\1\101\1\102\31\105\1\103" + + "\11\105\1\104\44\105\1\13\1\106\1\107\1\110\1\111" + + "\5\13\1\110\2\13\1\112\3\113\4\13\4\113\5\13" + + "\3\113\2\13\2\113\2\13\26\113\2\13\1\114\11\13" + + "\2\0\1\13\1\0\1\13\1\0\27\13\1\115\43\13" + + "\1\116\11\13\2\0\1\13\1\106\1\107\1\110\6\13" + + "\1\110\3\13\3\117\2\13\1\120\1\13\4\117\5\13" + + "\3\117\2\13\2\117\2\13\26\117\2\13\1\121\11\13" + + "\2\0\1\13\1\0\1\13\1\0\27\13\1\122\43\13" + + "\1\123\11\13\2\0\1\124\1\106\1\107\1\0\25\124" + + "\1\125\57\124\2\0\1\126\1\106\1\107\1\0\10\126" + + "\1\127\74\126\2\0\1\124\1\106\1\107\1\0\5\124" + + "\1\130\65\124\1\131\11\124\117\0\1\15\113\0\1\16" + + "\6\0\1\16\104\0\1\132\1\133\24\0\1\134\112\0" + + "\1\135\66\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\26\21\15\0\1\21\10\0\1\136\1\137" + + "\7\0\1\140\13\0\1\140\3\0\2\140\32\0\1\141" + + "\26\0\1\142\4\0\3\143\4\0\4\143\1\0\1\144" + + "\3\0\3\143\2\0\2\143\2\0\26\143\2\0\1\145" + + "\45\0\1\146\74\0\1\147\15\0\1\150\75\0\1\151" + + "\14\0\1\152\76\0\1\153\104\0\1\140\10\0\1\30" + + "\13\0\1\30\3\0\2\30\2\154\100\0\1\155\70\0" + + "\1\140\10\0\1\156\13\0\1\157\2\160\1\0\1\161" + + "\1\162\2\154\54\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\10\21\2\0\2\21\1\163\3\21\1\164\2\21" + + "\1\165\1\166\13\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\1\21\1\167\6\21\2\0" + + "\2\21\1\170\11\21\1\171\11\21\15\0\1\21\32\0" + + "\1\172\12\0\1\173\53\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\1\21\1\174\24\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\7\21\1\175\2\0\26\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\5\21" + + "\1\176\20\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\10\21\2\0\2\21\1\177\3\21" + + "\1\200\5\21\1\201\11\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\7\21\1\202\2\0" + + "\10\21\1\203\1\21\1\204\2\21\1\205\10\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\22\21\1\206\3\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\7\21\1\207" + + "\2\0\2\21\1\210\7\21\1\211\13\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\1\21\1\212\14\21\1\213\1\21\1\214\5\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\3\21\1\215\4\21\2\0\5\21\1\216\1\21" + + "\1\217\11\21\1\220\4\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\5\21" + + "\1\221\1\21\1\222\16\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\7\21\1\223\2\0" + + "\6\21\1\224\11\21\1\225\5\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\11\21\1\226\4\21\1\227\7\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\1\21\1\230\1\231\7\21\1\232\13\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\2\21\1\233\3\21\1\234\17\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\7\21" + + "\1\235\2\0\26\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\10\21\2\0\7\21\1\236" + + "\16\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\2\21\1\237\23\21\15\0" + + "\1\21\32\0\1\240\51\0\1\241\40\0\1\242\52\0" + + "\1\243\37\0\1\244\112\0\1\245\60\0\1\100\2\0" + + "\30\100\1\0\12\100\1\0\44\100\2\0\1\102\110\0" + + "\1\246\3\0\27\246\1\247\1\250\1\251\2\246\1\252" + + "\1\251\1\253\3\246\1\254\1\255\1\256\5\246\1\257" + + "\1\260\31\246\2\0\1\105\2\0\31\105\1\0\11\105" + + "\1\0\44\105\2\0\1\107\113\0\1\110\6\0\1\110" + + "\115\0\1\261\105\0\1\262\3\0\1\262\1\0\5\262" + + "\2\0\4\262\1\0\1\263\2\0\10\262\2\0\26\262" + + "\16\0\1\264\2\0\30\264\1\265\57\264\10\0\1\266" + + "\3\0\1\266\1\0\5\266\2\0\4\266\1\0\1\267" + + "\2\0\10\266\2\0\26\266\33\0\1\270\75\0\1\271" + + "\2\0\30\271\1\272\1\273\56\271\31\0\1\274\75\0" + + "\1\275\102\0\1\276\6\0\1\277\2\0\3\300\2\0" + + "\1\301\1\0\4\300\5\0\3\300\2\0\2\300\2\0" + + "\26\300\2\0\1\302\13\0\1\132\1\303\1\304\110\132" + + "\5\305\1\306\105\305\10\0\1\307\123\0\1\140\13\0" + + "\1\140\3\0\2\140\2\154\100\0\1\310\70\0\1\143" + + "\3\0\1\143\1\0\5\143\2\0\4\143\4\0\10\143" + + "\2\0\26\143\50\0\1\311\75\0\1\312\14\0\1\313" + + "\74\0\1\314\4\0\1\315\13\0\1\315\3\0\2\315" + + "\2\0\1\314\77\0\1\316\70\0\1\140\10\0\1\156" + + "\13\0\1\156\3\0\2\156\2\154\56\0\1\140\10\0" + + "\1\156\13\0\1\157\3\0\1\161\1\162\2\154\65\0" + + "\1\317\1\0\1\317\3\0\3\317\5\0\1\320\2\0" + + "\5\317\2\0\1\317\1\0\1\317\1\0\1\317\6\0" + + "\1\317\40\0\1\140\10\0\1\156\13\0\1\162\3\0" + + "\2\162\2\154\56\0\1\140\10\0\1\156\13\0\1\321" + + "\3\0\2\321\2\154\54\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\14\21\1\322\11\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\1\21\1\323\24\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\7\21\1\324\16\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\10\21\2\0\7\21\1\325" + + "\16\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\10\21\1\326\15\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\4\21\1\327\21\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\5\21\1\330\20\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\7\21\1\331\2\0\26\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\10\21\2\0\10\21\1\332\15\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\5\21\1\333\2\21\1\334\15\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\7\21\1\335\16\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\2\21" + + "\1\336\23\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\10\21\2\0\10\21\1\337\15\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\10\21\2\0\2\21\1\340\23\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\17\21\1\341\6\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\11\21" + + "\1\342\14\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\7\21\1\343\2\0\26\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\15\21\1\344\10\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\21\21\1\345\4\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\10\21\2\0\14\21\1\346" + + "\11\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\12\21\1\347\5\21\1\350" + + "\5\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\1\21\1\351\7\21\1\352" + + "\14\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\17\21\1\353\6\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\5\21\1\354\2\21\1\355\15\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\17\21\1\356\6\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\7\21\1\357" + + "\2\0\26\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\10\21\2\0\13\21\1\360\12\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\3\21\1\361\4\21\2\0\14\21\1\362\11\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\10\21\2\0\7\21\1\363\16\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\10\21\1\364\15\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\11\21" + + "\1\365\14\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\10\21\2\0\6\21\1\366\2\21" + + "\1\367\14\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\10\21\2\0\4\21\1\370\21\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\10\21\2\0\1\371\25\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\1\21\1\372\24\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\10\21\2\0\11\21\1\373" + + "\14\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\10\21\1\374\15\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\3\21\1\375\4\21\2\0\26\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\25\21\1\376\15\0\1\21\35\0\1\253\3\0\2\253" + + "\105\0\1\377\3\0\2\377\50\0\1\u0100\2\0\30\u0100" + + "\1\272\1\0\56\u0100\1\273\2\0\30\273\1\u0101\57\273" + + "\15\0\1\u0102\112\0\1\u0103\113\0\3\u0104\4\0\4\u0104" + + "\5\0\3\u0104\2\0\2\u0104\2\0\26\u0104\2\0\1\u0105" + + "\27\0\1\u0106\7\0\1\u0107\76\0\1\300\3\0\1\300" + + "\1\0\5\300\2\0\4\300\4\0\10\300\2\0\26\300" + + "\34\0\3\u0108\4\0\4\u0108\5\0\3\u0108\2\0\2\u0108" + + "\2\0\26\u0108\2\0\1\u0109\15\0\1\304\110\0\5\305" + + "\1\u010a\105\305\4\0\1\304\1\306\137\0\1\u010b\101\0" + + "\1\315\13\0\1\315\3\0\2\315\67\0\1\u010c\1\0" + + "\1\u010c\3\0\3\u010c\5\0\1\u010c\2\0\5\u010c\2\0" + + "\1\u010c\1\0\1\u010c\1\0\1\u010c\6\0\1\u010c\40\0" + + "\1\140\10\0\1\156\13\0\1\u010d\3\0\2\u010d\2\154" + + "\54\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\5\21\1\u010e\20\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\2\21" + + "\1\u010f\23\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\10\21\2\0\4\21\1\u0110\21\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\7\21\1\u0111\2\0\26\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\16\21\1\u0112\7\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\7\21\1\u0113\2\0\26\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\10\21\2\0\2\21\1\u0114\23\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\12\21\1\u0115\13\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\7\21\1\u0116\2\0" + + "\26\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\4\21\1\u0117\21\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\5\21\1\u0118\2\21\1\u0119\15\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\5\21\1\u011a\20\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\10\21\1\u011b\15\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\7\21\1\u011c\2\0\26\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\10\21\2\0\10\21\1\u011d\15\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\1\21\1\u011e\24\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\7\21\1\u011f\2\0" + + "\26\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\14\21\1\u0120\11\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\7\21\1\u0121\2\0\26\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\6\21" + + "\1\u0122\17\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\10\21\2\0\5\21\1\u0123\20\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\7\21\1\u0124\2\0\26\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\10\21\1\u0125\15\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\7\21\1\u0126\2\0\26\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\10\21\2\0\6\21\1\u0127\5\21\1\u0128\11\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\7\21\1\u0129\2\0\26\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\2\21\1\u012a\23\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\7\21\1\u012b\2\0\26\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\10\21\2\0\2\21\1\u012c\23\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\16\21\1\u012d\7\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\14\21" + + "\1\u012e\11\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\10\21\2\0\10\21\1\u012f\15\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\10\21\2\0\22\21\1\u0130\3\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\3\21\1\u0131\22\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\14\21" + + "\1\u0132\11\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\10\21\2\0\13\21\1\u0133\12\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\10\21\2\0\11\21\1\u0134\14\21\15\0\1\21" + + "\1\0\2\u0135\5\0\1\u0104\1\0\1\u0135\1\0\1\u0104" + + "\1\u0136\5\u0104\2\0\4\u0104\4\0\10\u0104\2\0\26\u0104" + + "\32\0\1\u0137\123\0\1\u0138\75\0\1\u0108\3\0\1\u0108" + + "\1\0\5\u0108\2\0\4\u0108\4\0\10\u0108\2\0\26\u0108" + + "\16\0\4\305\1\304\1\u010a\105\305\17\0\1\u0139\1\0" + + "\1\u0139\3\0\3\u0139\5\0\1\u0139\2\0\5\u0139\2\0" + + "\1\u0139\1\0\1\u0139\1\0\1\u0139\6\0\1\u0139\40\0" + + "\1\140\10\0\1\156\13\0\1\u013a\3\0\2\u013a\2\154" + + "\54\0\2\21\7\0\3\21\3\0\4\21\4\0\7\21" + + "\1\u013b\2\0\26\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\10\21\2\0\14\21\1\u013c" + + "\11\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\10\21\1\u013d\15\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\7\21\1\u013e\16\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\3\21\1\u013f\22\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\10\21\2\0\1\21\1\u0140" + + "\24\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\16\21\1\u0141\7\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\10\21\1\u0142\15\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\11\21\1\u0143\14\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\10\21\2\0\5\21\1\u0144" + + "\20\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\11\21\1\u0145\14\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\1\21\1\u0146\24\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\4\21\1\u0147\21\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\10\21\2\0\1\21\1\u0148" + + "\24\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\5\21\1\u0149\20\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\15\21\1\u014a\10\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\6\21\1\u014b\17\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\10\21\2\0\2\21\1\u014c" + + "\23\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\1\21\1\u014d\24\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\1\21\1\u014e\24\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\7\21\1\u014f" + + "\2\0\26\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\3\21\1\u0150\4\21\2\0\26\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\10\21\2\0\12\21\1\u0151\13\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\10\21\1\u0152\15\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\21\21" + + "\1\u0153\4\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\7\21\1\u0154\2\0\26\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\7\21\1\u0155\2\0\26\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\2\21" + + "\1\u0156\23\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\10\21\2\0\2\21\1\u0157\23\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\10\21\2\0\11\21\1\u0158\14\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\7\21\1\u0159\16\21\15\0\1\21\1\0\2\u0135" + + "\7\0\1\u0135\2\0\1\u0136\123\0\1\u015a\103\0\1\u015b" + + "\1\0\1\u015b\3\0\3\u015b\5\0\1\u015b\2\0\5\u015b" + + "\2\0\1\u015b\1\0\1\u015b\1\0\1\u015b\6\0\1\u015b" + + "\40\0\1\140\10\0\1\156\13\0\1\u015c\3\0\2\u015c" + + "\2\154\54\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\14\21\1\u015d\11\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\11\21\1\u015e\14\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\10\21\2\0\13\21\1\u015f" + + "\12\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\7\21\1\u0160\16\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\7\21\1\u0161\16\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\4\21\1\u0162\21\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\10\21\2\0\16\21\1\u0163" + + "\7\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\11\21\1\u0164\14\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\17\21\1\u0165\6\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\3\21\1\u0166" + + "\4\21\2\0\26\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\10\21\2\0\7\21\1\u0167" + + "\16\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\3\21\1\u0168\4\21\2\0\7\21\1\u0169" + + "\16\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\10\21\1\u016a\15\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\21\21\1\u016b\4\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\11\21\1\u016c\14\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\10\21\2\0\14\21\1\u016d" + + "\11\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\7\21\1\u016e\2\0\26\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\11\21\1\u016f\14\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\4\21" + + "\1\u0170\21\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\10\21\2\0\10\21\1\u0171\15\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\10\21\2\0\23\21\1\u0172\2\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\4\21\1\u0173\21\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\11\21" + + "\1\u0174\14\21\15\0\1\21\27\0\1\u0175\102\0\1\u0176" + + "\1\0\1\u0176\3\0\3\u0176\5\0\1\u0176\2\0\5\u0176" + + "\2\0\1\u0176\1\0\1\u0176\1\0\1\u0176\6\0\1\u0176" + + "\40\0\1\140\10\0\1\156\13\0\1\u0177\3\0\2\u0177" + + "\2\154\54\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\20\21\1\u0178\5\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\6\21\1\u0179\17\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\10\21\2\0\5\21\1\u017a" + + "\20\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\12\21\1\u017b\13\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\13\21\1\u017c\12\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\2\21\1\u017d\23\21\15\0\1\21\6\0\2\21\7\0" + + "\3\21\3\0\4\21\4\0\10\21\2\0\4\21\1\u017e" + + "\21\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\2\21\1\u017f\23\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\2\21\1\u0180\23\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\7\21\1\u0181" + + "\2\0\26\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\10\21\2\0\7\21\1\u0182\16\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\10\21\2\0\10\21\1\u0183\15\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\4\21\1\u0184\21\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\10\21" + + "\1\u0185\15\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\7\21\1\u0186\2\0\26\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\7\21\1\u0187\2\0\26\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\10\21\2\0\10\21" + + "\1\u0188\15\21\15\0\1\21\30\0\1\u0189\101\0\1\u018a" + + "\1\0\1\u018a\3\0\3\u018a\5\0\1\u018a\2\0\5\u018a" + + "\2\0\1\u018a\1\0\1\u018a\1\0\1\u018a\6\0\1\u018a" + + "\40\0\1\140\10\0\1\156\13\0\1\u018b\3\0\2\u018b" + + "\2\154\54\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\7\21\1\u018c\16\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\7\21\1\u018d" + + "\2\0\26\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\7\21\1\u018e\2\0\26\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\4\21\1\u018f\21\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\7\21\1\u0190" + + "\2\0\26\21\15\0\1\21\6\0\2\21\7\0\3\21" + + "\3\0\4\21\4\0\10\21\2\0\4\21\1\u0191\21\21" + + "\15\0\1\21\6\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\10\21\2\0\14\21\1\u0192\11\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\7\21\1\u0193\16\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\7\21\1\u0194\2\0" + + "\26\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\7\21\1\u0195\2\0\26\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\20\21\1\u0196\5\21\15\0\1\21\27\0\1\u0197" + + "\102\0\1\u0198\1\0\1\u0198\3\0\3\u0198\5\0\1\u0198" + + "\2\0\5\u0198\2\0\1\u0198\1\0\1\u0198\1\0\1\u0198" + + "\6\0\1\u0198\40\0\1\140\10\0\1\156\13\0\1\u0199" + + "\3\0\2\u0199\2\154\54\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\7\21\1\u019a\2\0\26\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\6\21\1\u019b\17\21\15\0\1\21\6\0\2\21" + + "\7\0\3\21\3\0\4\21\4\0\7\21\1\u019c\2\0" + + "\26\21\15\0\1\21\6\0\2\21\7\0\3\21\3\0" + + "\4\21\4\0\10\21\2\0\10\21\1\u019d\15\21\15\0" + + "\1\21\6\0\2\21\7\0\3\21\3\0\4\21\4\0" + + "\10\21\2\0\13\21\1\u019e\12\21\15\0\1\21\6\0" + + "\2\21\7\0\3\21\3\0\4\21\4\0\10\21\2\0" + + "\13\21\1\u019f\12\21\15\0\1\21\24\0\1\u01a0\105\0" + + "\1\u01a1\1\0\1\u01a1\3\0\3\u01a1\5\0\1\u01a1\2\0" + + "\5\u01a1\2\0\1\u01a1\1\0\1\u01a1\1\0\1\u01a1\6\0" + + "\1\u01a1\40\0\1\140\10\0\1\156\13\0\1\u01a2\3\0" + + "\2\u01a2\2\154\54\0\2\21\7\0\3\21\3\0\4\21" + + "\4\0\3\21\1\u01a3\4\21\2\0\26\21\15\0\1\21" + + "\6\0\2\21\7\0\3\21\3\0\4\21\4\0\10\21" + + "\2\0\5\21\1\u01a4\20\21\15\0\1\21\10\0\1\140" + + "\10\0\1\156\13\0\1\u01a5\3\0\2\u01a5\2\154\56\0" + + "\1\140\10\0\1\156\13\0\1\u01a6\3\0\2\u01a6\2\154" + + "\56\0\1\140\10\0\1\156\13\0\1\u01a7\3\0\2\u01a7" + + "\2\154\56\0\1\140\10\0\1\156\13\0\1\u01a8\3\0" + + "\2\u01a8\2\154\56\0\1\140\10\0\1\156\13\0\1\u01a9" + + "\3\0\2\u01a9\2\154\56\0\1\140\10\0\1\156\13\0" + + "\1\u01aa\3\0\2\u01aa\2\154\46\0"; + + private static int[] zzUnpackTrans() { + int[] result = new int[21825]; + 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; + + /* 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 + = "\12\0\1\11\1\1\1\11\13\1\3\11\1\1\2\11" + + "\25\1\7\11\4\1\1\11\2\1\2\11\3\1\1\11" + + "\2\1\1\11\1\1\1\11\1\1\1\11\2\1\1\11" + + "\1\1\2\11\1\1\1\11\2\1\1\11\1\1\1\0" + + "\2\11\1\1\1\11\1\1\1\11\2\1\2\11\1\1" + + "\2\11\1\1\2\11\1\0\3\1\1\0\11\1\2\11" + + "\44\1\11\11\1\1\1\11\1\1\6\11\1\0\1\11" + + "\1\0\1\11\1\0\2\11\1\0\1\1\5\0\1\1" + + "\1\0\1\11\1\1\1\11\2\0\3\11\1\1\1\11" + + "\1\0\1\1\1\11\60\1\1\11\1\0\3\11\1\0" + + "\1\11\2\0\1\1\1\11\1\0\1\11\51\1\1\0" + + "\2\11\1\0\41\1\1\0\32\1\1\0\23\1\1\0" + + "\15\1\1\0\10\1\2\11\11\1"; + + private static int[] zzUnpackAttribute() { + int[] result = new int[426]; + 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; + + /* user code: */ + private String sourceCode; + + public ActionScriptLexer(String sourceCode) { + this(new StringReader(sourceCode)); + this.sourceCode = sourceCode; + } + + public void yypushbackstr(String s, int state) { + sourceCode = s + sourceCode.substring(yychar + yylength()); + yyreset(new StringReader(sourceCode)); + yybegin(state); + } + + public void yypushbackstr(String s) { + yypushbackstr(s, YYINITIAL); + } + + StringBuffer string = new StringBuffer(); + + private static String xmlTagName = ""; + + public int yychar() { + return yychar; + } + + private Stack pushedBack = new Stack<>(); + + public int yyline() { + return yyline + 1; + } + private List listeners = new ArrayList<>(); + + public void addListener(LexListener listener) { + listeners.add(listener); + } + + public void removeListener(LexListener listener) { + listeners.remove(listener); + } + + public void informListenersLex(ParsedSymbol s) { + for (LexListener l : listeners) { + l.onLex(s); + } + } + + public void informListenersPushBack(ParsedSymbol s) { + for (LexListener l : listeners) { + l.onPushBack(s); + } + } + + public void pushback(ParsedSymbol symb) { + pushedBack.push(symb); + last = null; + informListenersPushBack(symb); + } + ParsedSymbol last; + + public ParsedSymbol lex() throws java.io.IOException, ParseException { + ParsedSymbol ret = null; + if (!pushedBack.isEmpty()) { + ret = last = pushedBack.pop(); + } else { + ret = last = yylex(); + } + informListenersLex(ret); + return ret; + } + + /** + * 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 ActionScriptLexer(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 ActionScriptLexer(java.io.InputStream in) { + this(new java.io.InputStreamReader(in, java.nio.charset.Charset.forName("UTF-8"))); + } + + /** + * 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 < 2280) { + 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 { + + /* 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; + } + + /* 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); + + 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; + return false; + } + } + + // numRead < 0 + return true; + } + + /** + * Closes the input stream. + * + * @throws java.io.IOException + */ + 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. + * + * Internal scan buffer is resized down to its initial length, if it has + * grown. + * + * @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; + if (zzBuffer.length > ZZ_BUFFERSIZE) { + zzBuffer = new char[ZZ_BUFFERSIZE]; + } + } + + /** + * Returns the current lexical state. + * + * @return + */ + 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. + * + * @return + */ + 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. + * + * @return + */ + 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 + * @throws com.jpexs.decompiler.flash.abc.avm2.parser.ParseException + */ + 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; + + zzAction = -1; + + zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL; + + zzState = ZZ_LEXSTATE[zzLexicalState]; + + // set up zzAction for empty match case: + int zzAttributes = zzAttrL[zzState]; + if ((zzAttributes & 1) == 1) { + zzAction = zzState; + } + + 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; + + zzAttributes = zzAttrL[zzState]; + if ((zzAttributes & 1) == 1) { + zzAction = zzState; + zzMarkedPosL = zzCurrentPosL; + if ((zzAttributes & 8) == 8) { + break zzForAction; + } + } + + } + } + + // store back cached position + zzMarkedPos = zzMarkedPosL; + + switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { + case 1: { + } + case 158: + break; + case 2: { + yyline++; + } + case 159: + break; + case 3: { /*ignore*/ + + } + case 160: + break; + case 4: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.DIVIDE, yytext()); + } + case 161: + break; + case 5: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.MULTIPLY, yytext()); + } + case 162: + break; + case 6: { + return new ParsedSymbol(SymbolGroup.IDENTIFIER, SymbolType.IDENTIFIER, yytext()); + } + case 163: + break; + case 7: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.DOT, yytext()); + } + case 164: + break; + case 8: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.LOWER_THAN, yytext()); + } + case 165: + break; + case 9: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.NOT, yytext()); + } + case 166: + break; + case 10: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.MINUS, yytext()); + } + case 167: + break; + case 11: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.GREATER_THAN, yytext()); + } + case 168: + break; + case 12: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.COLON, yytext()); + } + case 169: + break; + case 13: { + return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, new Long(Long.parseLong((yytext())))); + } + case 170: + break; + case 14: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.TERNAR, yytext()); + } + case 171: + break; + case 15: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.BRACKET_OPEN, yytext()); + } + case 172: + break; + case 16: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.BRACKET_CLOSE, yytext()); + } + case 173: + break; + case 17: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN, yytext()); + } + case 174: + break; + case 18: { + string.setLength(0); + yybegin(STRING); + } + case 175: + break; + case 19: { + string.setLength(0); + yybegin(CHARLITERAL); + } + case 176: + break; + case 20: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.PLUS, yytext()); + } + case 177: + break; + case 21: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.PARENT_OPEN, yytext()); + } + case 178: + break; + case 22: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.PARENT_CLOSE, yytext()); + } + case 179: + break; + case 23: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.CURLY_OPEN, yytext()); + } + case 180: + break; + case 24: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.CURLY_CLOSE, yytext()); + } + case 181: + break; + case 25: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.SEMICOLON, yytext()); + } + case 182: + break; + case 26: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.COMMA, yytext()); + } + case 183: + break; + case 27: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.NEGATE, yytext()); + } + case 184: + break; + case 28: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.BITAND, yytext()); + } + case 185: + break; + case 29: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.BITOR, yytext()); + } + case 186: + break; + case 30: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.XOR, yytext()); + } + case 187: + break; + case 31: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.MODULO, yytext()); + } + case 188: + break; + case 32: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ATTRIBUTE, yytext()); + } + case 189: + break; + case 33: { + string.append(yytext()); + } + case 190: + break; + case 34: { + yybegin(YYINITIAL); + yyline++; + } + case 191: + break; + case 35: { + yybegin(YYINITIAL); + // length also includes the trailing quote + return new ParsedSymbol(SymbolGroup.STRING, SymbolType.STRING, string.toString()); + } + case 192: + break; + case 36: { + string.append(yytext()); + yyline++; + } + case 193: + break; + case 37: { + yybegin(XML); + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTTAG_END, yytext())); + if (string.length() > 0) { + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); + string.setLength(0); + } + return lex(); + } + case 194: + break; + case 38: { + yybegin(YYINITIAL); + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_ATTRNAMEVAR_BEGIN, yytext())); + if (string.length() > 0) { + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); + string.setLength(0); + } + return lex(); + } + case 195: + break; + case 39: { + yybegin(YYINITIAL); + return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_ATTRVALVAR_BEGIN, yytext()); + } + case 196: + break; + case 40: { + yybegin(YYINITIAL); + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_INSTRATTRNAMEVAR_BEGIN, yytext())); + if (string.length() > 0) { + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); + string.setLength(0); + } + return lex(); + } + case 197: + break; + case 41: { + yybegin(YYINITIAL); + return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_INSTRATTRVALVAR_BEGIN, yytext()); + } + case 198: + break; + case 42: { + string.append(yytext()); + } + case 199: + break; + case 43: { + yybegin(YYINITIAL); + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_VAR_BEGIN, yytext())); + if (string.length() > 0) { + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); + string.setLength(0); + } + return lex(); + } + case 200: + break; + case 44: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_DIVIDE, yytext()); + } + case 201: + break; + case 45: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_MULTIPLY, yytext()); + } + case 202: + break; + case 46: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.DESCENDANTS, yytext()); + } + case 203: + break; + case 47: { + return new ParsedSymbol(SymbolGroup.TYPENAME, SymbolType.TYPENAME, yytext()); + } + case 204: + break; + case 48: { + return new ParsedSymbol(SymbolGroup.DOUBLE, SymbolType.DOUBLE, new Double(Double.parseDouble((yytext())))); + } + case 205: + break; + case 49: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.FILTER, yytext()); + } + case 206: + break; + case 50: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.SHIFT_LEFT, yytext()); + } + case 207: + break; + case 51: { + yybegin(XMLOPENTAG); + string.setLength(0); + return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTTAG_BEGIN, yytext()); + } + case 208: + break; + case 52: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.LOWER_EQUAL, yytext()); + } + case 209: + break; + case 53: { + return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTVARTAG_BEGIN, yytext()); + } + case 210: + break; + case 54: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.NOT_EQUAL, yytext()); + } + case 211: + break; + case 55: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.DECREMENT, yytext()); + } + case 212: + break; + case 56: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_MINUS, yytext()); + } + case 213: + break; + case 57: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.SHIFT_RIGHT, yytext()); + } + case 214: + break; + case 58: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.GREATER_EQUAL, yytext()); + } + case 215: + break; + case 59: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.NAMESPACE_OP, yytext()); + } + case 216: + break; + case 60: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.EQUALS, yytext()); + } + case 217: + break; + case 61: { + return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, new Long(Long.parseLong(yytext(), 8))); + } + case 218: + break; + case 62: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_PLUS, yytext()); + } + case 219: + break; + case 63: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.INCREMENT, yytext()); + } + case 220: + break; + case 64: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.AS, yytext()); + } + case 221: + break; + case 65: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.IF, yytext()); + } + case 222: + break; + case 66: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.IS, yytext()); + } + case 223: + break; + case 67: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.IN, yytext()); + } + case 224: + break; + case 68: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.DO, yytext()); + } + case 225: + break; + case 69: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_BITAND, yytext()); + } + case 226: + break; + case 70: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.AND, yytext()); + } + case 227: + break; + case 71: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_BITOR, yytext()); + } + case 228: + break; + case 72: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.OR, yytext()); + } + case 229: + break; + case 73: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_XOR, yytext()); + } + case 230: + break; + case 74: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_MODULO, yytext()); + } + case 231: + break; + case 75: { + throw new ParseException("Illegal escape sequence \"" + yytext() + "\"", yyline + 1); + } + case 232: + break; + case 76: { + string.append('\"'); + } + case 233: + break; + case 77: { + string.append('\''); + } + case 234: + break; + case 78: { + char val = (char) Integer.parseInt(yytext().substring(1), 8); + string.append(val); + } + case 235: + break; + case 79: { + string.append('\f'); + } + case 236: + break; + case 80: { + string.append('\\'); + } + case 237: + break; + case 81: { + string.append('\b'); + } + case 238: + break; + case 82: { + string.append('\r'); + } + case 239: + break; + case 83: { + string.append('\n'); + } + case 240: + break; + case 84: { + string.append('\t'); + } + case 241: + break; + case 85: { + yybegin(XML); + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTFINISHTAG_END, yytext())); + if (string.length() > 0) { + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); + string.setLength(0); + } + return lex(); + } + case 242: + break; + case 86: { + yybegin(XMLOPENTAGATTRIB); + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_ATTRIBUTENAME, yytext())); + if (string.length() > 0) { + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); + string.setLength(0); + } + return lex(); + } + case 243: + break; + case 87: { + yybegin(XMLOPENTAG); + return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_ATTRIBUTEVALUE, yytext()); + } + case 244: + break; + case 88: { + yybegin(XMLINSTRATTRIB); + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_ATTRIBUTENAME, yytext())); + if (string.length() > 0) { + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); + string.setLength(0); + } + return lex(); + } + case 245: + break; + case 89: { + yybegin(XML); + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_INSTR_END, yytext())); + if (string.length() > 0) { + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); + string.setLength(0); + } + return lex(); + } + case 246: + break; + case 90: { + yybegin(XMLINSTROPENTAG); + return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_ATTRIBUTEVALUE, yytext()); + } + case 247: + break; + case 91: { + yybegin(XMLOPENTAG); + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTTAG_BEGIN, yytext())); + if (string.length() > 0) { + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); + string.setLength(0); + } + return lex(); + } + case 248: + break; + case 92: { + yybegin(YYINITIAL); + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_STARTVARTAG_BEGIN, yytext())); + if (string.length() > 0) { + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); + string.setLength(0); + } + return lex(); + } + case 249: + break; + case 93: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.REST, yytext()); + } + case 250: + break; + case 94: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_SHIFT_LEFT, yytext()); + } + case 251: + break; + case 95: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.STRICT_NOT_EQUAL, yytext()); + } + case 252: + break; + case 96: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.USHIFT_RIGHT, yytext()); + } + case 253: + break; + case 97: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_SHIFT_RIGHT, yytext()); + } + case 254: + break; + case 98: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.STRICT_EQUALS, yytext()); + } + case 255: + break; + case 99: { + return new ParsedSymbol(SymbolGroup.INTEGER, SymbolType.INTEGER, new Long(Long.parseLong(yytext().substring(2), 16))); + } + case 256: + break; + case 100: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.FOR, yytext()); + } + case 257: + break; + case 101: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.SET, yytext()); + } + case 258: + break; + case 102: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.NEW, yytext()); + } + case 259: + break; + case 103: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.TRY, yytext()); + } + case 260: + break; + case 104: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.USE, yytext()); + } + case 261: + break; + case 105: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.VAR, yytext()); + } + case 262: + break; + case 106: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.GET, yytext()); + } + case 263: + break; + case 107: { + return new ParsedSymbol(SymbolGroup.GLOBALCONST, SymbolType.NAN, yytext()); + } + case 264: + break; + case 108: { + string.append(yytext()); + yybegin(XML); + String ret = string.toString(); + string.setLength(0); + return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_CDATA, ret); + } + case 265: + break; + case 109: { + string.append(yytext()); + yybegin(XML); + String ret = string.toString(); + string.setLength(0); + return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_COMMENT, ret); + } + case 266: + break; + case 110: { + yybegin(YYINITIAL); + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_FINISHVARTAG_BEGIN, yytext())); + if (string.length() > 0) { + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); + string.setLength(0); + } + return lex(); + } + case 267: + break; + case 111: { + yybegin(XMLINSTROPENTAG); + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_INSTR_BEGIN, yytext())); + if (string.length() > 0) { + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); + string.setLength(0); + } + return lex(); + } + case 268: + break; + case 112: { + yybegin(YYINITIAL); + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_INSTRVARTAG_BEGIN, yytext())); + if (string.length() > 0) { + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); + string.setLength(0); + } + return lex(); + } + case 269: + break; + case 113: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.ASSIGN_USHIFT_RIGHT, yytext()); + } + case 270: + break; + case 114: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.EACH, yytext()); + } + case 271: + break; + case 115: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.ELSE, yytext()); + } + case 272: + break; + case 116: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.CASE, yytext()); + } + case 273: + break; + case 117: { + return new ParsedSymbol(SymbolGroup.GLOBALCONST, SymbolType.NULL, yytext()); + } + case 274: + break; + case 118: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.TRUE, yytext()); + } + case 275: + break; + case 119: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.THIS, yytext()); + } + case 276: + break; + case 120: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.WITH, yytext()); + } + case 277: + break; + case 121: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.VOID, yytext()); + } + case 278: + break; + case 122: { + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_FINISHTAG, yytext())); + if (string.length() > 0) { + pushback(new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, string.toString())); + string.setLength(0); + } + return lex(); + } + case 279: + break; + case 123: { + String ret = string.toString(); + string.setLength(0); + string.append(yytext()); + yybegin(XMLCOMMENT); + if (!ret.isEmpty()) { + return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, ret); + } + } + case 280: + break; + case 124: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.FALSE, yytext()); + } + case 281: + break; + case 125: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.FINAL, yytext()); + } + case 282: + break; + case 126: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.BREAK, yytext()); + } + case 283: + break; + case 127: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.CATCH, yytext()); + } + case 284: + break; + case 128: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.CONST, yytext()); + } + case 285: + break; + case 129: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.CLASS, yytext()); + } + case 286: + break; + case 130: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.SUPER, yytext()); + } + case 287: + break; + case 131: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.THROW, yytext()); + } + case 288: + break; + case 132: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.WHILE, yytext()); + } + case 289: + break; + case 133: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.RETURN, yytext()); + } + case 290: + break; + case 134: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.STATIC, yytext()); + } + case 291: + break; + case 135: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.SWITCH, yytext()); + } + case 292: + break; + case 136: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.TYPEOF, yytext()); + } + case 293: + break; + case 137: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.IMPORT, yytext()); + } + case 294: + break; + case 138: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.DELETE, yytext()); + } + case 295: + break; + case 139: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.PUBLIC, yytext()); + } + case 296: + break; + case 140: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.FINALLY, yytext()); + } + case 297: + break; + case 141: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.EXTENDS, yytext()); + } + case 298: + break; + case 142: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.DEFAULT, yytext()); + } + case 299: + break; + case 143: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.DYNAMIC, yytext()); + } + case 300: + break; + case 144: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.PRIVATE, yytext()); + } + case 301: + break; + case 145: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.PACKAGE, yytext()); + } + case 302: + break; + case 146: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.FUNCTION, yytext()); + } + case 303: + break; + case 147: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.CONTINUE, yytext()); + } + case 304: + break; + case 148: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.OVERRIDE, yytext()); + } + case 305: + break; + case 149: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.INTERNAL, yytext()); + } + case 306: + break; + case 150: { + return new ParsedSymbol(SymbolGroup.GLOBALCONST, SymbolType.INFINITY, yytext()); + } + case 307: + break; + case 151: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.NAMESPACE, yytext()); + } + case 308: + break; + case 152: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.INTERFACE, yytext()); + } + case 309: + break; + case 153: { + return new ParsedSymbol(SymbolGroup.GLOBALCONST, SymbolType.UNDEFINED, yytext()); + } + case 310: + break; + case 154: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.PROTECTED, yytext()); + } + case 311: + break; + case 155: { + String ret = string.toString(); + string.setLength(0); + string.append(yytext()); + yybegin(XMLCDATA); + if (!ret.isEmpty()) { + return new ParsedSymbol(SymbolGroup.XML, SymbolType.XML_TEXT, ret); + } + } + case 312: + break; + case 156: { + return new ParsedSymbol(SymbolGroup.OPERATOR, SymbolType.INSTANCEOF, yytext()); + } + case 313: + break; + case 157: { + return new ParsedSymbol(SymbolGroup.KEYWORD, SymbolType.IMPLEMENTS, yytext()); + } + case 314: + break; + default: + if (zzInput == YYEOF && zzStartRead == zzCurrentPos) { + zzAtEOF = true; + { + return new ParsedSymbol(SymbolGroup.EOF, SymbolType.EOF, null); + } + } else { + zzScanError(ZZ_NO_MATCH); + } + } + } + } + +} diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java b/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java index de0850bc7..cf495c625 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptParser.java @@ -490,7 +490,7 @@ public class ActionScriptParser { paramTypes.add(new UnboundedTypeItem()); } if (s.type == SymbolType.ASSIGN) { - paramValues.add(expression(pkg, new Reference(false), importedClasses, openedNamespaces, null, isMethod, isMethod, isMethod, variables)); + paramValues.add(expression(pkg, new Reference<>(false), importedClasses, openedNamespaces, null, isMethod, isMethod, isMethod, variables)); s = lex(); } else { if (!paramValues.isEmpty()) { @@ -671,13 +671,13 @@ public class ActionScriptParser { GraphTargetItem extendsTypeStr = null; s = lex(); if (s.type == SymbolType.EXTENDS) { - extendsTypeStr = type(pkg, new Reference(false), importedClasses, subNamespaces, new ArrayList()); + extendsTypeStr = type(pkg, new Reference<>(false), importedClasses, subNamespaces, new ArrayList()); s = lex(); } List implementsTypeStrs = new ArrayList<>(); if (s.type == SymbolType.IMPLEMENTS) { do { - GraphTargetItem implementsTypeStr = type(pkg, new Reference(false), importedClasses, subNamespaces, new ArrayList()); + GraphTargetItem implementsTypeStr = type(pkg, new Reference<>(false), importedClasses, subNamespaces, new ArrayList()); implementsTypeStrs.add(implementsTypeStr); s = lex(); } while (s.type == SymbolType.COMMA); @@ -711,7 +711,7 @@ public class ActionScriptParser { if (s.type == SymbolType.EXTENDS) { do { - GraphTargetItem intExtendsTypeStr = type(pkg, new Reference(false), importedClasses, openedNamespaces, new ArrayList()); + GraphTargetItem intExtendsTypeStr = type(pkg, new Reference<>(false), importedClasses, openedNamespaces, new ArrayList()); intExtendsTypeStrs.add(intExtendsTypeStr); s = lex(); } while (s.type == SymbolType.COMMA); @@ -762,9 +762,9 @@ public class ActionScriptParser { if (isInterface) { throw new ParseException("Interface cannot have constructor", lexer.yyline()); } - constr = (method(pkg, false, customAccess, new Reference(false), importedClasses, false, false, thisType, openedNamespaces, false, namespace, "", true, constrVariables)); + constr = (method(pkg, false, customAccess, new Reference<>(false), importedClasses, false, false, thisType, openedNamespaces, false, namespace, "", true, constrVariables)); } else { - MethodAVM2Item ft = method(pkg, isInterface, customAccess, new Reference(false), importedClasses, isOverride, isFinal, thisType, openedNamespaces, isStatic, namespace, fname, true, new ArrayList()); + MethodAVM2Item ft = method(pkg, isInterface, customAccess, new Reference<>(false), importedClasses, isOverride, isFinal, thisType, openedNamespaces, isStatic, namespace, fname, true, new ArrayList()); if (isGetter) { if (!ft.paramTypes.isEmpty()) { @@ -845,7 +845,7 @@ public class ActionScriptParser { s = lex(); GraphTargetItem type = null; if (s.type == SymbolType.COLON) { - type = type(pkg, new Reference(false), importedClasses, openedNamespaces, new ArrayList()); + type = type(pkg, new Reference<>(false), importedClasses, openedNamespaces, new ArrayList()); s = lex(); } else { type = TypeItem.UNBOUNDED; @@ -854,7 +854,7 @@ public class ActionScriptParser { GraphTargetItem value = null; if (s.type == SymbolType.ASSIGN) { - value = expression(pkg, new Reference(false), importedClasses, openedNamespaces, new HashMap(), false, false, true, isStatic || isConst ? sinitVariables : constrVariables); + value = expression(pkg, new Reference<>(false), importedClasses, openedNamespaces, new HashMap(), false, false, true, isStatic || isConst ? sinitVariables : constrVariables); s = lex(); } GraphTargetItem tar; @@ -1174,7 +1174,7 @@ public class ActionScriptParser { List openedTags = new ArrayList<>(); int closedVarTags = 0; - GraphTargetItem ret = add(xmltag(pkg, new Reference(false), openedTags, new Reference(closedVarTags), needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables)); + GraphTargetItem ret = add(xmltag(pkg, new Reference<>(false), openedTags, new Reference<>(closedVarTags), needsActivation, importedClasses, openedNamespaces, registerVars, inFunction, inMethod, variables)); ret = new XMLAVM2Item(ret); lexer.yybegin(ActionScriptLexer.YYINITIAL); //TODO: Order of additions as in official compiler diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PackageAVM2Item.java b/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PackageAVM2Item.java index 7dea854e7..5a9f7b1e3 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PackageAVM2Item.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PackageAVM2Item.java @@ -32,7 +32,7 @@ public class PackageAVM2Item extends AVM2Item { public List items; public String packageName; - public List importedClasses = new ArrayList(); + public List importedClasses = new ArrayList<>(); public int publicNs = 0; public PackageAVM2Item(int publicNs, List importedClasses, String packageName, List items) { diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java b/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java index 14cbd0243..eec9d57db 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/PropertyAVM2Item.java @@ -66,7 +66,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item { public List otherABCs; private final List openedNamespaces; private final List callStack; - public List scopeStack = new ArrayList(); + public List scopeStack = new ArrayList<>(); @Override public AssignableAVM2Item copy() { diff --git a/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java b/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java index 9de173dc1..fd084a73b 100644 --- a/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java +++ b/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/UnresolvedAVM2Item.java @@ -60,7 +60,7 @@ public class UnresolvedAVM2Item extends AssignableAVM2Item { public GraphTargetItem resolvedRoot; private final boolean mustBeType; public List importedClasses; - public List scopeStack = new ArrayList(); + public List scopeStack = new ArrayList<>(); public List subtypes; @Override diff --git a/src/com/jpexs/decompiler/flash/action/Action.java b/src/com/jpexs/decompiler/flash/action/Action.java index 689d587c0..da60374d1 100644 --- a/src/com/jpexs/decompiler/flash/action/Action.java +++ b/src/com/jpexs/decompiler/flash/action/Action.java @@ -1,1324 +1,1324 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action; - -import com.jpexs.decompiler.flash.AppStrings; -import com.jpexs.decompiler.flash.BaseLocalData; -import com.jpexs.decompiler.flash.DisassemblyListener; -import com.jpexs.decompiler.flash.SWF; -import com.jpexs.decompiler.flash.SWFInputStream; -import com.jpexs.decompiler.flash.SWFOutputStream; -import com.jpexs.decompiler.flash.action.model.ActionItem; -import com.jpexs.decompiler.flash.action.model.ConstantPool; -import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; -import com.jpexs.decompiler.flash.action.model.ExtendsActionItem; -import com.jpexs.decompiler.flash.action.model.FunctionActionItem; -import com.jpexs.decompiler.flash.action.model.GetMemberActionItem; -import com.jpexs.decompiler.flash.action.model.GetPropertyActionItem; -import com.jpexs.decompiler.flash.action.model.GetVariableActionItem; -import com.jpexs.decompiler.flash.action.model.ImplementsOpActionItem; -import com.jpexs.decompiler.flash.action.model.NewObjectActionItem; -import com.jpexs.decompiler.flash.action.model.SetMemberActionItem; -import com.jpexs.decompiler.flash.action.model.SetPropertyActionItem; -import com.jpexs.decompiler.flash.action.model.SetVariableActionItem; -import com.jpexs.decompiler.flash.action.model.StoreRegisterActionItem; -import com.jpexs.decompiler.flash.action.model.TemporaryRegister; -import com.jpexs.decompiler.flash.action.model.UnsupportedActionItem; -import com.jpexs.decompiler.flash.action.model.clauses.ClassActionItem; -import com.jpexs.decompiler.flash.action.model.clauses.InterfaceActionItem; -import com.jpexs.decompiler.flash.action.parser.ParseException; -import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol; -import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser; -import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; -import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem; -import com.jpexs.decompiler.flash.action.special.ActionEnd; -import com.jpexs.decompiler.flash.action.special.ActionStore; -import com.jpexs.decompiler.flash.action.swf4.ActionEquals; -import com.jpexs.decompiler.flash.action.swf4.ActionIf; -import com.jpexs.decompiler.flash.action.swf4.ActionJump; -import com.jpexs.decompiler.flash.action.swf4.ActionNot; -import com.jpexs.decompiler.flash.action.swf4.ActionPush; -import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; -import com.jpexs.decompiler.flash.action.swf5.ActionDefineFunction; -import com.jpexs.decompiler.flash.action.swf5.ActionEquals2; -import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2; -import com.jpexs.decompiler.flash.configuration.Configuration; -import com.jpexs.decompiler.flash.ecma.Null; -import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; -import com.jpexs.decompiler.flash.helpers.GraphTextWriter; -import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; -import com.jpexs.decompiler.flash.helpers.NulWriter; -import com.jpexs.decompiler.flash.helpers.collections.MyEntry; -import com.jpexs.decompiler.flash.tags.base.ASMSource; -import com.jpexs.decompiler.graph.Graph; -import com.jpexs.decompiler.graph.GraphSource; -import com.jpexs.decompiler.graph.GraphSourceItem; -import com.jpexs.decompiler.graph.GraphSourceItemContainer; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.TranslateException; -import com.jpexs.decompiler.graph.model.CommentItem; -import com.jpexs.decompiler.graph.model.IfItem; -import com.jpexs.decompiler.graph.model.LocalData; -import com.jpexs.decompiler.graph.model.NotItem; -import com.jpexs.decompiler.graph.model.ScriptEndItem; -import com.jpexs.helpers.CancellableWorker; -import com.jpexs.helpers.Helper; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.EmptyStackException; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Represents one ACTIONRECORD, also has some static method to work with Actions - */ -public class Action implements GraphSourceItem { - - public Action replaceWith; - private boolean ignored = false; - /** - * Action type identifier - */ - public int actionCode; - /** - * Length of action data - */ - public int actionLength; - private long address; - - 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 boolean isReservedWord(String s) { - if (s == null) { - return false; - } - for (String rw : reservedWords) { - if (rw.equals(s.trim())) { - return true; - } - } - return false; - } - - - /** - * 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" - }; - public static final List propertyNamesList = Arrays.asList(propertyNames); - private static final 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; - } - - public Action() { - } - - /** - * Returns address of this action - * - * @return address of this action - */ - 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 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 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, false); - ret.addAll(a.replaceWith.getAllRefs(version)); - } - List part = a.getAllRefs(version); - ret.addAll(part); - } - return ret; - } - - /** - * Sets address of this instruction - * - * @param address Address - * @param version SWF version - */ - public final void setAddress(long address, int version) { - setAddress(address, version, true); - } - - public void setAddress(long address, int version, boolean recursive) { - 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 { - ASMParsedSymbol symb = lex.yylex(); - if (symb.type != ASMParsedSymbol.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 { - ASMParsedSymbol symb = lex.yylex(); - if (symb.type != ASMParsedSymbol.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 { - ASMParsedSymbol symb = lex.yylex(); - if (symb.type != ASMParsedSymbol.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 { - ASMParsedSymbol symb = lex.yylex(); - if (symb.type != ASMParsedSymbol.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 { - ASMParsedSymbol symb = lex.yylex(); - if (symb.type != ASMParsedSymbol.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) { - return surroundWithAction(new byte[0], 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); - if (actionCode >= 0x80) { - 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(); - Action lastAction = null; - for (Action a : list) { - try { - lastAction = a; - baos.write(a.getBytes(version)); - } catch (IOException e) { - } - } - if (addZero && (lastAction == null || !(lastAction instanceof ActionEnd))) { - 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 listeners - * @param address - * @param list List of actions - * @param importantOffsets List of important offsets to mark as labels - * @param version SWF version - * @param exportMode PCode or hex? - * @param writer - * @param path - * @return HilightedTextWriter - */ - public static GraphTextWriter actionsToString(List listeners, long address, List list, List importantOffsets, int version, ScriptExportMode exportMode, GraphTextWriter writer, String path) { - return actionsToString(listeners, address, list, importantOffsets, new ArrayList(), version, exportMode, writer, path); - } - - /** - * Converts list of actions to ASM source - * - * @param listeners - * @param address - * @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? - * @param path - * @return HilightedTextWriter - */ - private static GraphTextWriter actionsToString(List listeners, long address, List list, List importantOffsets, List constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer, String path) { - long offset; - if (importantOffsets == null) { - //setActionsAddresses(list, 0, version); - importantOffsets = getActionsAllRefs(list, version); - } - /*List cps = SWFInputStream.getConstantPool(new ArrayList(), new ActionGraphSource(list, version, new HashMap(), new HashMap(), new HashMap()), 0, version, path); - if (!cps.isEmpty()) { - setConstantPool(list, cps.get(cps.size() - 1)); - }*/ - HashMap> containers = new HashMap<>(); - HashMap containersPos = new HashMap<>(); - offset = address; - int pos = -1; - boolean lastPush = false; - for (GraphSourceItem s : list) { - for (int i = 0; i < listeners.size(); i++) { - listeners.get(i).progress(AppStrings.translate("disassemblingProgress.toString"), pos + 2, list.size()); - } - Action a = null; - if (s instanceof Action) { - a = (Action) s; - } - pos++; - if (exportMode == ScriptExportMode.PCODE_HEX) { - if (lastPush) { - writer.newLine(); - lastPush = false; - } - writer.appendNoHilight("; "); - writer.appendNoHilight(Helper.bytesToHexString(a.getBytes(version))); - writer.newLine(); - } - offset = a.getAddress(); - - if ((!(a.isIgnored())) && (a instanceof GraphSourceItemContainer)) { - GraphSourceItemContainer cnt = (GraphSourceItemContainer) a; - containersPos.put(cnt, 0); - List sizes = cnt.getContainerSizes(); - long addr = ((Action) cnt).getAddress() + cnt.getHeaderSize(); - for (Long size : sizes) { - addr += size; - if (size == 0) { - continue; - } - if (!containers.containsKey(addr)) { - containers.put(addr, new ArrayList()); - } - containers.get(addr).add(cnt); - } - } - - if (containers.containsKey(offset)) { - for (int i = 0; i < containers.get(offset).size(); i++) { - writer.appendNoHilight("}").newLine(); - GraphSourceItemContainer cnt = containers.get(offset).get(i); - int cntPos = containersPos.get(cnt); - writer.appendNoHilight(cnt.getASMSourceBetween(cntPos)); - cntPos++; - containersPos.put(cnt, cntPos); - } - } - - if (Configuration.showAllAddresses.get() || importantOffsets.contains(offset)) { - if (lastPush) { - writer.newLine(); - lastPush = false; - } - writer.appendNoHilight("loc"); - writer.appendNoHilight(Helper.formatAddress(offset)); - writer.appendNoHilight(":"); - } - - if (a.replaceWith != null) { - if (lastPush) { - writer.newLine(); - lastPush = false; - } - writer.append("", offset); - writer.appendNoHilight(a.replaceWith.getASMSource(list, importantOffsets, constantPool, version, exportMode)); - writer.newLine(); - } else if (a.isIgnored()) { - if (lastPush) { - writer.newLine(); - lastPush = false; - } - int len = 0; - if (pos + 1 < list.size()) { - len = (int) (((Action) (list.get(pos + 1))).getAddress() - a.getAddress()); - } else { - len = a.getBytes(version).length; - } - if (!(a instanceof ActionEnd)) { - for (int i = 0; i < len; i++) { - writer.appendNoHilight("Nop").newLine(); - } - } - } else { - //if (!(a instanceof ActionNop)) { - String add = ""; - if (a instanceof ActionIf) { - add = " change: " + ((ActionIf) a).getJumpOffset(); - } - if (a instanceof ActionJump) { - add = " change: " + ((ActionJump) a).getJumpOffset(); - } - add = "; ofs" + Helper.formatAddress(offset) + add; - add = ""; - if ((a instanceof ActionPush) && lastPush) { - writer.appendNoHilight(" "); - ((ActionPush) a).paramsToStringReplaced(list, importantOffsets, constantPool, version, exportMode, writer); - } else { - if (lastPush) { - writer.newLine(); - lastPush = false; - } - - writer.append("", offset); - - int fixBranch = -1; - if (a instanceof ActionIf) { - ActionIf aif = (ActionIf) a; - if (aif.jumpUsed && !aif.ignoreUsed) { - fixBranch = 0; - } - if (!aif.jumpUsed && aif.ignoreUsed) { - fixBranch = 1; - } - } - - if (fixBranch > -1) { - writer.appendNoHilight("FFDec_DeobfuscatePop").newLine(); - if (fixBranch == 0) { //jump - writer.appendNoHilight("Jump loc"); - writer.appendNoHilight(Helper.formatAddress(a.getAddress() + a.getBytes(version).length + ((ActionIf) a).getJumpOffset())); - } else { - //nojump, ignore - } - } else { - a.getASMSourceReplaced(list, importantOffsets, constantPool, version, exportMode, writer); - } - writer.appendNoHilight(a.isIgnored() ? "; ignored" : ""); - writer.appendNoHilight(add); - if (!(a instanceof ActionPush)) { - writer.newLine(); - } - } - if (a instanceof ActionPush) { - lastPush = true; - } else { - lastPush = false; - } - //} - } - offset += a.getBytes(version).length; - } - if (lastPush) { - writer.newLine(); - } - if (containers.containsKey(offset)) { - for (int i = 0; i < containers.get(offset).size(); i++) { - writer.appendNoHilight("}"); - writer.newLine(); - GraphSourceItemContainer cnt = containers.get(offset).get(i); - int cntPos = containersPos.get(cnt); - writer.appendNoHilight(cnt.getASMSourceBetween(cntPos)); - cntPos++; - containersPos.put(cnt, cntPos); - } - } - if (importantOffsets.contains(offset)) { - writer.appendNoHilight("loc"); - writer.appendNoHilight(Helper.formatAddress(offset)); - writer.appendNoHilight(":"); - writer.newLine(); - } - return writer; - } - - /** - * Convert action to ASM source - * - * @param container - * @param knownAddreses List of important offsets to mark as labels - * @param constantPool Constant pool - * @param version SWF version - * @param exportMode PCode or hex? - * @return String of P-code source - */ - public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { - return toString(); - } - - /** - * Translates this function to stack and output. - * - * @param stack Stack - * @param output Output - * @param regNames Register names - * @param variables Variables - * @param functions Functions - * @param staticOperation the value of staticOperation - * @param path the value of path - * @throws java.lang.InterruptedException - */ - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) throws InterruptedException { - } - - /** - * Pops long value off the stack - * - * @param stack Stack - * @return long value - */ - protected long popLong(Stack stack) { - GraphTargetItem item = stack.pop(); - if (item instanceof DirectValueActionItem) { - if (((DirectValueActionItem) item).value instanceof Long) { - return (long) (Long) ((DirectValueActionItem) 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) { - /* List actions=new ArrayList(); - for(GraphSourceItem s:sources){ - if(s instanceof Action){ - actions.add((Action)s); - } - }*/ - 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; - } - - public static List actionsToTree(List actions, int version, int staticOperation, String path) throws InterruptedException { - return actionsToTree(new HashMap(), new HashMap(), new HashMap(), actions, version, staticOperation, path); - } - - /** - * Converts list of actions to ActionScript source code - * - * @param asm - * @param actions List of actions - * @param path - * @param writer - * @throws java.lang.InterruptedException - */ - public static void actionsToSource(final ASMSource asm, final List actions, final String path, GraphTextWriter writer) throws InterruptedException { - writer.suspendMeasure(); - List tree = null; - Throwable convertException = null; - int timeout = Configuration.decompilationTimeoutSingleMethod.get(); - try { - tree = CancellableWorker.call(new Callable>() { - @Override - public List call() throws Exception { - int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC; - List tree = actionsToTree(new HashMap(), new HashMap(), new HashMap(), actions, asm.getSwf().version, staticOperation, path); - Graph.graphToString(tree, new NulWriter(), new LocalData()); - return tree; - } - }, timeout, TimeUnit.SECONDS); - } catch (TimeoutException | ExecutionException | OutOfMemoryError | TranslateException | StackOverflowError ex) { - Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error", ex); - convertException = ex; - if (ex instanceof ExecutionException && ex.getCause() instanceof Exception) { - convertException = (Exception) ex.getCause(); - } - } - writer.continueMeasure(); - - asm.getActionSourcePrefix(writer); - if (convertException == null) { - Graph.graphToString(tree, writer, new LocalData()); - } else if (convertException instanceof TimeoutException) { - Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error", convertException); - Helper.appendTimeoutComment(writer, timeout); - } else { - Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error", convertException); - Helper.appendErrorComment(writer, convertException); - } - asm.getActionSourceSuffix(writer); - } - - /** - * Converts list of actions to List of treeItems - * - * @param regNames Register names - * @param variables - * @param functions - * @param actions List of actions - * @param version SWF version - * @param staticOperation - * @param path - * @return List of treeItems - * @throws java.lang.InterruptedException - */ - public static List actionsToTree(HashMap regNames, HashMap variables, HashMap functions, List actions, int version, int staticOperation, String path) throws InterruptedException { - //Stack stack = new Stack(); - return ActionGraph.translateViaGraph(regNames, variables, functions, actions, version, staticOperation, path); - //return actionsToTree(regNames, stack, actions, 0, actions.size() - 1, version); - } - - @Override - public void translate(BaseLocalData localData, Stack stack, List output, int staticOperation, String path) throws InterruptedException { - ActionLocalData aLocalData = (ActionLocalData) localData; - translate(stack, output, aLocalData.regNames, aLocalData.variables, aLocalData.functions, staticOperation, path); - } - - @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, int pos) { - 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, int staticOperation, String path) throws InterruptedException { - 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) + ")") : "")); - } - ActionLocalData localData = new ActionLocalData(registerNames, variables, functions); - List output = new ArrayList<>(); - int ip = start; - boolean isWhile = false; - boolean isForIn = false; - GraphTargetItem inItem = null; - int loopStart = 0; - loopip: - while (ip <= end) { - - long addr = ip2adr(actions, ip, version); - if (ip > end) { - break; - } - if (ip >= actions.size()) { - output.add(new ScriptEndItem()); - break; - } - Action action = actions.get(ip); - if (action.isIgnored()) { - ip++; - continue; - } - if (action instanceof GraphSourceItemContainer) { - GraphSourceItemContainer cnt = (GraphSourceItemContainer) action; - //List out=actionsPartToTree(new HashMap(), new HashMap(),new HashMap(), new Stack(), src, ip+1,endip-1 , version); - long endAddr = action.getAddress() + cnt.getHeaderSize(); - String cntName = cnt.getName(); - List> outs = new ArrayList<>(); - HashMap variables2 = Helper.deepCopy(variables); - if (cnt instanceof ActionDefineFunction || cnt instanceof ActionDefineFunction2) { - for (int r = 0; r < 256; r++) { - if (variables2.containsKey("__register" + r)) { - variables2.remove("__register" + r); - } - } - } - for (long size : cnt.getContainerSizes()) { - if (size == 0) { - outs.add(new ArrayList()); - continue; - } - List out; - try { - out = ActionGraph.translateViaGraph(cnt.getRegNames(), variables2, functions, actions.subList(adr2ip(actions, endAddr, version), adr2ip(actions, endAddr + size, version)), version, staticOperation, path + (cntName == null ? "" : "/" + cntName)); - } catch (OutOfMemoryError | TranslateException | StackOverflowError ex2) { - Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error in: " + path, ex2); - if (ex2 instanceof OutOfMemoryError) { - Helper.freeMem(); - } - out = new ArrayList<>(); - out.add(new CommentItem(new String[]{ - "", - " * " + AppStrings.translate("decompilationError"), - " * " + AppStrings.translate("decompilationError.obfuscated"), - " * " + AppStrings.translate("decompilationError.errorType") + ": " - + ex2.getClass().getSimpleName(), - ""})); - } - outs.add(out); - endAddr += size; - } - ((GraphSourceItemContainer) action).translateContainer(outs, stack, output, registerNames, variables, functions); - ip = adr2ip(actions, endAddr, version); - continue; - } - - //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.getJumpOffset(), 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); - EnumerateActionItem en = (EnumerateActionItem) 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); - ActionItem catchName; - if (atry.catchInRegisterFlag) { - catchName = new DirectValueActionItem(atry, -1, new RegisterNumber(atry.catchRegister), new ArrayList()); - } else { - catchName = new DirectValueActionItem(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 TryActionItem(tryCommands, catchExceptions, catchCommands, finallyCommands)); - } else if (action instanceof ActionWith) { - ActionWith awith = (ActionWith) action; - List withCommands = ActionGraph.translateViaGraph(registerNames, variables, functions,new ArrayList() , version); //TODO:parse with actions - output.add(new WithActionItem(action, stack.pop(), withCommands)); - } else */ if (false) { - } /*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()); - ActionItem switchedObject = stack.pop(); - if (output.size() > 0) { - if (output.get(output.size() - 1) instanceof StoreRegisterActionItem) { - 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 SwitchActionItem(action, defaultAddr, switchedObject, caseValues, caseCommands, null)); - continue; - } else { - action.translate(stack, constants, output, registerNames); - } - } */ else { - - if (action instanceof ActionStore) { - ActionStore store = (ActionStore) action; - store.setStore(actions.subList(ip + 1, ip + 1 + store.getStoreSize())); - ip = ip + 1 + store.getStoreSize() - 1/*ip++ will be next*/; - } - - try { - action.translate(localData, stack, output, staticOperation, path); - } catch (EmptyStackException ese) { - Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error in: " + path, ese); - output.add(new UnsupportedActionItem(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 GetMemberActionItem)) { - return ti; - } - GetMemberActionItem lastMember = null; - while (((GetMemberActionItem) t).object instanceof GetMemberActionItem) { - lastMember = (GetMemberActionItem) t; - t = ((GetMemberActionItem) t).object; - } - if (((GetMemberActionItem) t).object instanceof GetVariableActionItem) { - GetVariableActionItem v = (GetVariableActionItem) ((GetMemberActionItem) t).object; - if (v.name instanceof DirectValueActionItem) { - if (((DirectValueActionItem) v.name).value instanceof String) { - if (((DirectValueActionItem) v.name).value.equals("_global")) { - GetVariableActionItem gvt = new GetVariableActionItem(null, ((GetMemberActionItem) t).memberName); - if (lastMember == null) { - return gvt; - } else { - lastMember.object = gvt; - } - } - } - } - } - return ti; - } - - public static List checkClass(List output) { - if (true) { - //return output; - } - List ret = new ArrayList<>(); - List functions = new ArrayList<>(); - List staticFunctions = new ArrayList<>(); - List> vars = new ArrayList<>(); - List> staticVars = new ArrayList<>(); - 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 GetMemberActionItem) || (nti.value instanceof GetVariableActionItem)) { - if (true) { //it.onFalse.isEmpty()){ //||(it.onFalse.get(0) instanceof UnsupportedActionItem)) { - if ((it.onTrue.size() == 1) && (it.onTrue.get(0) instanceof SetMemberActionItem) && (((SetMemberActionItem) it.onTrue.get(0)).value instanceof NewObjectActionItem)) { - //ignore - } else { - List parts = it.onTrue; - className = getWithoutGlobal(nti.value); - if (parts.size() >= 1) { - int ipos = 0; - while ((parts.get(ipos) instanceof IfItem) - && ((((IfItem) parts.get(ipos)).onTrue.size() == 1) && (((IfItem) parts.get(ipos)).onTrue.get(0) instanceof SetMemberActionItem) && (((SetMemberActionItem) ((IfItem) parts.get(ipos)).onTrue.get(0)).value instanceof NewObjectActionItem))) { - - ipos++; - } - if (parts.get(ipos) instanceof ExtendsActionItem) { - ExtendsActionItem et = (ExtendsActionItem) parts.get(ipos); - extendsOp = getWithoutGlobal(et.superclass); - ipos++; - } - if (parts.get(ipos) instanceof StoreRegisterActionItem) { - StoreRegisterActionItem sr = (StoreRegisterActionItem) parts.get(ipos); - int instanceReg = sr.register.number; - if (sr.value instanceof GetMemberActionItem) { - GetMemberActionItem gm = (GetMemberActionItem) sr.value; - //gm.memberName should be "prototype" - if (gm.object instanceof TemporaryRegister) { - TemporaryRegister tm = (TemporaryRegister) gm.object; - int classReg = tm.getRegId(); - if (tm.value instanceof SetMemberActionItem) { - SetMemberActionItem sm = (SetMemberActionItem) tm.value; - if (sm.value instanceof StoreRegisterActionItem) { - sr = (StoreRegisterActionItem) sm.value; - if (sr.value instanceof FunctionActionItem) { - ((FunctionActionItem) (sr.value)).calculatedFunctionName = (className instanceof GetMemberActionItem) ? ((GetMemberActionItem) className).memberName : className; - functions.add((FunctionActionItem) sr.value); - - for (; ipos < parts.size(); ipos++) { - if (parts.get(ipos) instanceof ImplementsOpActionItem) { - ImplementsOpActionItem io = (ImplementsOpActionItem) parts.get(ipos); - implementsOp = io.superclasses; - continue; - } - if (parts.get(ipos) instanceof SetMemberActionItem) { - sm = (SetMemberActionItem) parts.get(ipos); - int rnum = -1; - if (sm.object instanceof DirectValueActionItem) { - DirectValueActionItem dv = (DirectValueActionItem) sm.object; - if (dv.value instanceof RegisterNumber) { - RegisterNumber rn = (RegisterNumber) dv.value; - rnum = rn.number; - } - } - if (sm.object instanceof TemporaryRegister) { - rnum = ((TemporaryRegister) sm.object).getRegId(); - } - if (rnum == instanceReg) { - if (sm.value instanceof FunctionActionItem) { - ((FunctionActionItem) sm.value).calculatedFunctionName = sm.objectName; - functions.add((FunctionActionItem) sm.value); - } else { - vars.add(new MyEntry<>(sm.objectName, sm.value)); - } - } else if (rnum == classReg) { - if (sm.value instanceof FunctionActionItem) { - ((FunctionActionItem) sm.value).calculatedFunctionName = sm.objectName; - staticFunctions.add((FunctionActionItem) sm.value); - } else { - staticVars.add(new MyEntry<>(sm.objectName, sm.value)); - } - } - - } - } - - } - - } - } - List output2 = new ArrayList<>(); - for (int i = 0; i < prevCount; i++) { - output2.add(output.get(i)); - } - output2.add(new ClassActionItem(className, extendsOp, implementsOp, null/*FIXME*/, functions, vars, staticFunctions, staticVars)); - return output2; - } - } - } else if (parts.get(ipos) instanceof SetMemberActionItem) { - SetMemberActionItem sm = (SetMemberActionItem) parts.get(0); - if (sm.value instanceof FunctionActionItem) { - FunctionActionItem f = (FunctionActionItem) sm.value; - if (f.actions.isEmpty()) { - if (parts.size() == 2) { - if (parts.get(1) instanceof ImplementsOpActionItem) { - ImplementsOpActionItem iot = (ImplementsOpActionItem) 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 InterfaceActionItem(sm.objectName, implementsOp)); - return output2; - } - } - } - } - } - } 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(long address, List actions, int version, String path) { - List ret = actions; - if (true) { - //return ret; - } - String s = null; - try { - HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); - Action.actionsToString(new ArrayList(), address, ret, null, version, ScriptExportMode.PCODE, writer, path); - s = writer.toString(); - ret = ASMParser.parse(address, true, s, SWF.DEFAULT_VERSION, false); - } catch (IOException | ParseException ex) { - Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "parsing error. path: " + path, ex); - } - return ret; - } - - public static void setConstantPool(List actions, ConstantPool cpool) { - for (GraphSourceItem 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,actions); - } - } - if (a instanceof ActionDefineFunction2) { - if (cpool != null) { - //((ActionDefineFunction2) a).setConstantPool(cpool.constants,actions); - } - } - } - } - - public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer) { - writer.appendNoHilight(getASMSource(container, knownAddreses, constantPool, version, exportMode)); - return writer; - } - - public static double toFloatPoint(Object o) { - if (o instanceof Double) { - return (Double) o; - } - if (o instanceof Integer) { - return (Integer) o; - } - if (o instanceof Long) { - return (Long) o; - } - if (o instanceof String) { - try { - return Double.parseDouble((String) o); - } catch (NumberFormatException nfe) { - return 0; - } - } - return 0; - } - - public static GraphTargetItem gettoset(GraphTargetItem get, GraphTargetItem value, List variables) { - GraphTargetItem ret = get; - boolean boxed = false; - if (get instanceof VariableActionItem) { - boxed = true; - ret = ((VariableActionItem) ret).getBoxedValue(); - } - if (ret instanceof GetVariableActionItem) { - GetVariableActionItem gv = (GetVariableActionItem) ret; - ret = new SetVariableActionItem(null, gv.name, value); - } else if (ret instanceof GetMemberActionItem) { - GetMemberActionItem mem = (GetMemberActionItem) ret; - ret = new SetMemberActionItem(null, mem.object, mem.memberName, value); - } else if ((ret instanceof DirectValueActionItem) && ((DirectValueActionItem) ret).value instanceof RegisterNumber) { - ret = new StoreRegisterActionItem(null, (RegisterNumber) ((DirectValueActionItem) ret).value, value, false); - } else if (ret instanceof GetPropertyActionItem) { - GetPropertyActionItem gp = (GetPropertyActionItem) ret; - ret = new SetPropertyActionItem(null, gp.target, gp.propertyIndex, value); - } - if (boxed) { - GraphTargetItem b = ret; - ret = new VariableActionItem(((VariableActionItem) get).getVariableName(), value, ((VariableActionItem) get).isDefinition()); - ((VariableActionItem) ret).setBoxedValue((ActionItem) b); - variables.remove((VariableActionItem) get); - variables.add((VariableActionItem) ret); - } - return ret; - } - - @Override - public boolean isDeobfuscatePop() { - return false; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action; + +import com.jpexs.decompiler.flash.AppStrings; +import com.jpexs.decompiler.flash.BaseLocalData; +import com.jpexs.decompiler.flash.DisassemblyListener; +import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.SWFInputStream; +import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.action.model.ActionItem; +import com.jpexs.decompiler.flash.action.model.ConstantPool; +import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.flash.action.model.ExtendsActionItem; +import com.jpexs.decompiler.flash.action.model.FunctionActionItem; +import com.jpexs.decompiler.flash.action.model.GetMemberActionItem; +import com.jpexs.decompiler.flash.action.model.GetPropertyActionItem; +import com.jpexs.decompiler.flash.action.model.GetVariableActionItem; +import com.jpexs.decompiler.flash.action.model.ImplementsOpActionItem; +import com.jpexs.decompiler.flash.action.model.NewObjectActionItem; +import com.jpexs.decompiler.flash.action.model.SetMemberActionItem; +import com.jpexs.decompiler.flash.action.model.SetPropertyActionItem; +import com.jpexs.decompiler.flash.action.model.SetVariableActionItem; +import com.jpexs.decompiler.flash.action.model.StoreRegisterActionItem; +import com.jpexs.decompiler.flash.action.model.TemporaryRegister; +import com.jpexs.decompiler.flash.action.model.UnsupportedActionItem; +import com.jpexs.decompiler.flash.action.model.clauses.ClassActionItem; +import com.jpexs.decompiler.flash.action.model.clauses.InterfaceActionItem; +import com.jpexs.decompiler.flash.action.parser.ParseException; +import com.jpexs.decompiler.flash.action.parser.pcode.ASMParsedSymbol; +import com.jpexs.decompiler.flash.action.parser.pcode.ASMParser; +import com.jpexs.decompiler.flash.action.parser.pcode.FlasmLexer; +import com.jpexs.decompiler.flash.action.parser.script.VariableActionItem; +import com.jpexs.decompiler.flash.action.special.ActionEnd; +import com.jpexs.decompiler.flash.action.special.ActionStore; +import com.jpexs.decompiler.flash.action.swf4.ActionEquals; +import com.jpexs.decompiler.flash.action.swf4.ActionIf; +import com.jpexs.decompiler.flash.action.swf4.ActionJump; +import com.jpexs.decompiler.flash.action.swf4.ActionNot; +import com.jpexs.decompiler.flash.action.swf4.ActionPush; +import com.jpexs.decompiler.flash.action.swf4.RegisterNumber; +import com.jpexs.decompiler.flash.action.swf5.ActionDefineFunction; +import com.jpexs.decompiler.flash.action.swf5.ActionEquals2; +import com.jpexs.decompiler.flash.action.swf7.ActionDefineFunction2; +import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.ecma.Null; +import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; +import com.jpexs.decompiler.flash.helpers.GraphTextWriter; +import com.jpexs.decompiler.flash.helpers.HilightedTextWriter; +import com.jpexs.decompiler.flash.helpers.NulWriter; +import com.jpexs.decompiler.flash.helpers.collections.MyEntry; +import com.jpexs.decompiler.flash.tags.base.ASMSource; +import com.jpexs.decompiler.graph.Graph; +import com.jpexs.decompiler.graph.GraphSource; +import com.jpexs.decompiler.graph.GraphSourceItem; +import com.jpexs.decompiler.graph.GraphSourceItemContainer; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.TranslateException; +import com.jpexs.decompiler.graph.model.CommentItem; +import com.jpexs.decompiler.graph.model.IfItem; +import com.jpexs.decompiler.graph.model.LocalData; +import com.jpexs.decompiler.graph.model.NotItem; +import com.jpexs.decompiler.graph.model.ScriptEndItem; +import com.jpexs.helpers.CancellableWorker; +import com.jpexs.helpers.Helper; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.EmptyStackException; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents one ACTIONRECORD, also has some static method to work with Actions + */ +public class Action implements GraphSourceItem { + + public Action replaceWith; + private boolean ignored = false; + /** + * Action type identifier + */ + public int actionCode; + /** + * Length of action data + */ + public int actionLength; + private long address; + + 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 boolean isReservedWord(String s) { + if (s == null) { + return false; + } + for (String rw : reservedWords) { + if (rw.equals(s.trim())) { + return true; + } + } + return false; + } + + + /** + * 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" + }; + public static final List propertyNamesList = Arrays.asList(propertyNames); + private static final 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; + } + + public Action() { + } + + /** + * Returns address of this action + * + * @return address of this action + */ + 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 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 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, false); + ret.addAll(a.replaceWith.getAllRefs(version)); + } + List part = a.getAllRefs(version); + ret.addAll(part); + } + return ret; + } + + /** + * Sets address of this instruction + * + * @param address Address + * @param version SWF version + */ + public final void setAddress(long address, int version) { + setAddress(address, version, true); + } + + public void setAddress(long address, int version, boolean recursive) { + 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 { + ASMParsedSymbol symb = lex.yylex(); + if (symb.type != ASMParsedSymbol.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 { + ASMParsedSymbol symb = lex.yylex(); + if (symb.type != ASMParsedSymbol.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 { + ASMParsedSymbol symb = lex.yylex(); + if (symb.type != ASMParsedSymbol.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 { + ASMParsedSymbol symb = lex.yylex(); + if (symb.type != ASMParsedSymbol.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 { + ASMParsedSymbol symb = lex.yylex(); + if (symb.type != ASMParsedSymbol.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) { + return surroundWithAction(new byte[0], 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); + if (actionCode >= 0x80) { + 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(); + Action lastAction = null; + for (Action a : list) { + try { + lastAction = a; + baos.write(a.getBytes(version)); + } catch (IOException e) { + } + } + if (addZero && (lastAction == null || !(lastAction instanceof ActionEnd))) { + 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 listeners + * @param address + * @param list List of actions + * @param importantOffsets List of important offsets to mark as labels + * @param version SWF version + * @param exportMode PCode or hex? + * @param writer + * @param path + * @return HilightedTextWriter + */ + public static GraphTextWriter actionsToString(List listeners, long address, List list, List importantOffsets, int version, ScriptExportMode exportMode, GraphTextWriter writer, String path) { + return actionsToString(listeners, address, list, importantOffsets, new ArrayList(), version, exportMode, writer, path); + } + + /** + * Converts list of actions to ASM source + * + * @param listeners + * @param address + * @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? + * @param path + * @return HilightedTextWriter + */ + private static GraphTextWriter actionsToString(List listeners, long address, List list, List importantOffsets, List constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer, String path) { + long offset; + if (importantOffsets == null) { + //setActionsAddresses(list, 0, version); + importantOffsets = getActionsAllRefs(list, version); + } + /*List cps = SWFInputStream.getConstantPool(new ArrayList(), new ActionGraphSource(list, version, new HashMap(), new HashMap(), new HashMap()), 0, version, path); + if (!cps.isEmpty()) { + setConstantPool(list, cps.get(cps.size() - 1)); + }*/ + HashMap> containers = new HashMap<>(); + HashMap containersPos = new HashMap<>(); + offset = address; + int pos = -1; + boolean lastPush = false; + for (GraphSourceItem s : list) { + for (int i = 0; i < listeners.size(); i++) { + listeners.get(i).progress(AppStrings.translate("disassemblingProgress.toString"), pos + 2, list.size()); + } + Action a = null; + if (s instanceof Action) { + a = (Action) s; + } + pos++; + if (exportMode == ScriptExportMode.PCODE_HEX) { + if (lastPush) { + writer.newLine(); + lastPush = false; + } + writer.appendNoHilight("; "); + writer.appendNoHilight(Helper.bytesToHexString(a.getBytes(version))); + writer.newLine(); + } + offset = a.getAddress(); + + if ((!(a.isIgnored())) && (a instanceof GraphSourceItemContainer)) { + GraphSourceItemContainer cnt = (GraphSourceItemContainer) a; + containersPos.put(cnt, 0); + List sizes = cnt.getContainerSizes(); + long addr = ((Action) cnt).getAddress() + cnt.getHeaderSize(); + for (Long size : sizes) { + addr += size; + if (size == 0) { + continue; + } + if (!containers.containsKey(addr)) { + containers.put(addr, new ArrayList()); + } + containers.get(addr).add(cnt); + } + } + + if (containers.containsKey(offset)) { + for (int i = 0; i < containers.get(offset).size(); i++) { + writer.appendNoHilight("}").newLine(); + GraphSourceItemContainer cnt = containers.get(offset).get(i); + int cntPos = containersPos.get(cnt); + writer.appendNoHilight(cnt.getASMSourceBetween(cntPos)); + cntPos++; + containersPos.put(cnt, cntPos); + } + } + + if (Configuration.showAllAddresses.get() || importantOffsets.contains(offset)) { + if (lastPush) { + writer.newLine(); + lastPush = false; + } + writer.appendNoHilight("loc"); + writer.appendNoHilight(Helper.formatAddress(offset)); + writer.appendNoHilight(":"); + } + + if (a.replaceWith != null) { + if (lastPush) { + writer.newLine(); + lastPush = false; + } + writer.append("", offset); + writer.appendNoHilight(a.replaceWith.getASMSource(list, importantOffsets, constantPool, version, exportMode)); + writer.newLine(); + } else if (a.isIgnored()) { + if (lastPush) { + writer.newLine(); + lastPush = false; + } + int len = 0; + if (pos + 1 < list.size()) { + len = (int) (((Action) (list.get(pos + 1))).getAddress() - a.getAddress()); + } else { + len = a.getBytes(version).length; + } + if (!(a instanceof ActionEnd)) { + for (int i = 0; i < len; i++) { + writer.appendNoHilight("Nop").newLine(); + } + } + } else { + //if (!(a instanceof ActionNop)) { + String add = ""; + if (a instanceof ActionIf) { + add = " change: " + ((ActionIf) a).getJumpOffset(); + } + if (a instanceof ActionJump) { + add = " change: " + ((ActionJump) a).getJumpOffset(); + } + add = "; ofs" + Helper.formatAddress(offset) + add; + add = ""; + if ((a instanceof ActionPush) && lastPush) { + writer.appendNoHilight(" "); + ((ActionPush) a).paramsToStringReplaced(list, importantOffsets, constantPool, version, exportMode, writer); + } else { + if (lastPush) { + writer.newLine(); + lastPush = false; + } + + writer.append("", offset); + + int fixBranch = -1; + if (a instanceof ActionIf) { + ActionIf aif = (ActionIf) a; + if (aif.jumpUsed && !aif.ignoreUsed) { + fixBranch = 0; + } + if (!aif.jumpUsed && aif.ignoreUsed) { + fixBranch = 1; + } + } + + if (fixBranch > -1) { + writer.appendNoHilight("FFDec_DeobfuscatePop").newLine(); + if (fixBranch == 0) { //jump + writer.appendNoHilight("Jump loc"); + writer.appendNoHilight(Helper.formatAddress(a.getAddress() + a.getBytes(version).length + ((ActionIf) a).getJumpOffset())); + } else { + //nojump, ignore + } + } else { + a.getASMSourceReplaced(list, importantOffsets, constantPool, version, exportMode, writer); + } + writer.appendNoHilight(a.isIgnored() ? "; ignored" : ""); + writer.appendNoHilight(add); + if (!(a instanceof ActionPush)) { + writer.newLine(); + } + } + if (a instanceof ActionPush) { + lastPush = true; + } else { + lastPush = false; + } + //} + } + offset += a.getBytes(version).length; + } + if (lastPush) { + writer.newLine(); + } + if (containers.containsKey(offset)) { + for (int i = 0; i < containers.get(offset).size(); i++) { + writer.appendNoHilight("}"); + writer.newLine(); + GraphSourceItemContainer cnt = containers.get(offset).get(i); + int cntPos = containersPos.get(cnt); + writer.appendNoHilight(cnt.getASMSourceBetween(cntPos)); + cntPos++; + containersPos.put(cnt, cntPos); + } + } + if (importantOffsets.contains(offset)) { + writer.appendNoHilight("loc"); + writer.appendNoHilight(Helper.formatAddress(offset)); + writer.appendNoHilight(":"); + writer.newLine(); + } + return writer; + } + + /** + * Convert action to ASM source + * + * @param container + * @param knownAddreses List of important offsets to mark as labels + * @param constantPool Constant pool + * @param version SWF version + * @param exportMode PCode or hex? + * @return String of P-code source + */ + public String getASMSource(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode) { + return toString(); + } + + /** + * Translates this function to stack and output. + * + * @param stack Stack + * @param output Output + * @param regNames Register names + * @param variables Variables + * @param functions Functions + * @param staticOperation the value of staticOperation + * @param path the value of path + * @throws java.lang.InterruptedException + */ + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) throws InterruptedException { + } + + /** + * Pops long value off the stack + * + * @param stack Stack + * @return long value + */ + protected long popLong(Stack stack) { + GraphTargetItem item = stack.pop(); + if (item instanceof DirectValueActionItem) { + if (((DirectValueActionItem) item).value instanceof Long) { + return (long) (Long) ((DirectValueActionItem) 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) { + /* List actions=new ArrayList(); + for(GraphSourceItem s:sources){ + if(s instanceof Action){ + actions.add((Action)s); + } + }*/ + 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; + } + + public static List actionsToTree(List actions, int version, int staticOperation, String path) throws InterruptedException { + return actionsToTree(new HashMap(), new HashMap(), new HashMap(), actions, version, staticOperation, path); + } + + /** + * Converts list of actions to ActionScript source code + * + * @param asm + * @param actions List of actions + * @param path + * @param writer + * @throws java.lang.InterruptedException + */ + public static void actionsToSource(final ASMSource asm, final List actions, final String path, GraphTextWriter writer) throws InterruptedException { + writer.suspendMeasure(); + List tree = null; + Throwable convertException = null; + int timeout = Configuration.decompilationTimeoutSingleMethod.get(); + try { + tree = CancellableWorker.call(new Callable>() { + @Override + public List call() throws Exception { + int staticOperation = Graph.SOP_USE_STATIC; //(Boolean) Configuration.getConfig("autoDeobfuscate", true) ? Graph.SOP_SKIP_STATIC : Graph.SOP_USE_STATIC; + List tree = actionsToTree(new HashMap(), new HashMap(), new HashMap(), actions, asm.getSwf().version, staticOperation, path); + Graph.graphToString(tree, new NulWriter(), new LocalData()); + return tree; + } + }, timeout, TimeUnit.SECONDS); + } catch (TimeoutException | ExecutionException | OutOfMemoryError | TranslateException | StackOverflowError ex) { + Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error", ex); + convertException = ex; + if (ex instanceof ExecutionException && ex.getCause() instanceof Exception) { + convertException = (Exception) ex.getCause(); + } + } + writer.continueMeasure(); + + asm.getActionSourcePrefix(writer); + if (convertException == null) { + Graph.graphToString(tree, writer, new LocalData()); + } else if (convertException instanceof TimeoutException) { + Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error", convertException); + Helper.appendTimeoutComment(writer, timeout); + } else { + Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error", convertException); + Helper.appendErrorComment(writer, convertException); + } + asm.getActionSourceSuffix(writer); + } + + /** + * Converts list of actions to List of treeItems + * + * @param regNames Register names + * @param variables + * @param functions + * @param actions List of actions + * @param version SWF version + * @param staticOperation + * @param path + * @return List of treeItems + * @throws java.lang.InterruptedException + */ + public static List actionsToTree(HashMap regNames, HashMap variables, HashMap functions, List actions, int version, int staticOperation, String path) throws InterruptedException { + //Stack stack = new Stack(); + return ActionGraph.translateViaGraph(regNames, variables, functions, actions, version, staticOperation, path); + //return actionsToTree(regNames, stack, actions, 0, actions.size() - 1, version); + } + + @Override + public void translate(BaseLocalData localData, Stack stack, List output, int staticOperation, String path) throws InterruptedException { + ActionLocalData aLocalData = (ActionLocalData) localData; + translate(stack, output, aLocalData.regNames, aLocalData.variables, aLocalData.functions, staticOperation, path); + } + + @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, int pos) { + 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, int staticOperation, String path) throws InterruptedException { + 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) + ")") : "")); + } + ActionLocalData localData = new ActionLocalData(registerNames, variables, functions); + List output = new ArrayList<>(); + int ip = start; + boolean isWhile = false; + boolean isForIn = false; + GraphTargetItem inItem = null; + int loopStart = 0; + loopip: + while (ip <= end) { + + long addr = ip2adr(actions, ip, version); + if (ip > end) { + break; + } + if (ip >= actions.size()) { + output.add(new ScriptEndItem()); + break; + } + Action action = actions.get(ip); + if (action.isIgnored()) { + ip++; + continue; + } + if (action instanceof GraphSourceItemContainer) { + GraphSourceItemContainer cnt = (GraphSourceItemContainer) action; + //List out=actionsPartToTree(new HashMap(), new HashMap(),new HashMap(), new Stack(), src, ip+1,endip-1 , version); + long endAddr = action.getAddress() + cnt.getHeaderSize(); + String cntName = cnt.getName(); + List> outs = new ArrayList<>(); + HashMap variables2 = Helper.deepCopy(variables); + if (cnt instanceof ActionDefineFunction || cnt instanceof ActionDefineFunction2) { + for (int r = 0; r < 256; r++) { + if (variables2.containsKey("__register" + r)) { + variables2.remove("__register" + r); + } + } + } + for (long size : cnt.getContainerSizes()) { + if (size == 0) { + outs.add(new ArrayList()); + continue; + } + List out; + try { + out = ActionGraph.translateViaGraph(cnt.getRegNames(), variables2, functions, actions.subList(adr2ip(actions, endAddr, version), adr2ip(actions, endAddr + size, version)), version, staticOperation, path + (cntName == null ? "" : "/" + cntName)); + } catch (OutOfMemoryError | TranslateException | StackOverflowError ex2) { + Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error in: " + path, ex2); + if (ex2 instanceof OutOfMemoryError) { + Helper.freeMem(); + } + out = new ArrayList<>(); + out.add(new CommentItem(new String[]{ + "", + " * " + AppStrings.translate("decompilationError"), + " * " + AppStrings.translate("decompilationError.obfuscated"), + " * " + AppStrings.translate("decompilationError.errorType") + ": " + + ex2.getClass().getSimpleName(), + ""})); + } + outs.add(out); + endAddr += size; + } + ((GraphSourceItemContainer) action).translateContainer(outs, stack, output, registerNames, variables, functions); + ip = adr2ip(actions, endAddr, version); + continue; + } + + //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.getJumpOffset(), 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); + EnumerateActionItem en = (EnumerateActionItem) 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); + ActionItem catchName; + if (atry.catchInRegisterFlag) { + catchName = new DirectValueActionItem(atry, -1, new RegisterNumber(atry.catchRegister), new ArrayList()); + } else { + catchName = new DirectValueActionItem(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 TryActionItem(tryCommands, catchExceptions, catchCommands, finallyCommands)); + } else if (action instanceof ActionWith) { + ActionWith awith = (ActionWith) action; + List withCommands = ActionGraph.translateViaGraph(registerNames, variables, functions,new ArrayList() , version); //TODO:parse with actions + output.add(new WithActionItem(action, stack.pop(), withCommands)); + } else */ if (false) { + } /*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()); + ActionItem switchedObject = stack.pop(); + if (output.size() > 0) { + if (output.get(output.size() - 1) instanceof StoreRegisterActionItem) { + 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 SwitchActionItem(action, defaultAddr, switchedObject, caseValues, caseCommands, null)); + continue; + } else { + action.translate(stack, constants, output, registerNames); + } + } */ else { + + if (action instanceof ActionStore) { + ActionStore store = (ActionStore) action; + store.setStore(actions.subList(ip + 1, ip + 1 + store.getStoreSize())); + ip = ip + 1 + store.getStoreSize() - 1/*ip++ will be next*/; + } + + try { + action.translate(localData, stack, output, staticOperation, path); + } catch (EmptyStackException ese) { + Logger.getLogger(Action.class.getName()).log(Level.SEVERE, "Decompilation error in: " + path, ese); + output.add(new UnsupportedActionItem(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 GetMemberActionItem)) { + return ti; + } + GetMemberActionItem lastMember = null; + while (((GetMemberActionItem) t).object instanceof GetMemberActionItem) { + lastMember = (GetMemberActionItem) t; + t = ((GetMemberActionItem) t).object; + } + if (((GetMemberActionItem) t).object instanceof GetVariableActionItem) { + GetVariableActionItem v = (GetVariableActionItem) ((GetMemberActionItem) t).object; + if (v.name instanceof DirectValueActionItem) { + if (((DirectValueActionItem) v.name).value instanceof String) { + if (((DirectValueActionItem) v.name).value.equals("_global")) { + GetVariableActionItem gvt = new GetVariableActionItem(null, ((GetMemberActionItem) t).memberName); + if (lastMember == null) { + return gvt; + } else { + lastMember.object = gvt; + } + } + } + } + } + return ti; + } + + public static List checkClass(List output) { + if (true) { + //return output; + } + List ret = new ArrayList<>(); + List functions = new ArrayList<>(); + List staticFunctions = new ArrayList<>(); + List> vars = new ArrayList<>(); + List> staticVars = new ArrayList<>(); + 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 GetMemberActionItem) || (nti.value instanceof GetVariableActionItem)) { + if (true) { //it.onFalse.isEmpty()){ //||(it.onFalse.get(0) instanceof UnsupportedActionItem)) { + if ((it.onTrue.size() == 1) && (it.onTrue.get(0) instanceof SetMemberActionItem) && (((SetMemberActionItem) it.onTrue.get(0)).value instanceof NewObjectActionItem)) { + //ignore + } else { + List parts = it.onTrue; + className = getWithoutGlobal(nti.value); + if (parts.size() >= 1) { + int ipos = 0; + while ((parts.get(ipos) instanceof IfItem) + && ((((IfItem) parts.get(ipos)).onTrue.size() == 1) && (((IfItem) parts.get(ipos)).onTrue.get(0) instanceof SetMemberActionItem) && (((SetMemberActionItem) ((IfItem) parts.get(ipos)).onTrue.get(0)).value instanceof NewObjectActionItem))) { + + ipos++; + } + if (parts.get(ipos) instanceof ExtendsActionItem) { + ExtendsActionItem et = (ExtendsActionItem) parts.get(ipos); + extendsOp = getWithoutGlobal(et.superclass); + ipos++; + } + if (parts.get(ipos) instanceof StoreRegisterActionItem) { + StoreRegisterActionItem sr = (StoreRegisterActionItem) parts.get(ipos); + int instanceReg = sr.register.number; + if (sr.value instanceof GetMemberActionItem) { + GetMemberActionItem gm = (GetMemberActionItem) sr.value; + //gm.memberName should be "prototype" + if (gm.object instanceof TemporaryRegister) { + TemporaryRegister tm = (TemporaryRegister) gm.object; + int classReg = tm.getRegId(); + if (tm.value instanceof SetMemberActionItem) { + SetMemberActionItem sm = (SetMemberActionItem) tm.value; + if (sm.value instanceof StoreRegisterActionItem) { + sr = (StoreRegisterActionItem) sm.value; + if (sr.value instanceof FunctionActionItem) { + ((FunctionActionItem) (sr.value)).calculatedFunctionName = (className instanceof GetMemberActionItem) ? ((GetMemberActionItem) className).memberName : className; + functions.add((FunctionActionItem) sr.value); + + for (; ipos < parts.size(); ipos++) { + if (parts.get(ipos) instanceof ImplementsOpActionItem) { + ImplementsOpActionItem io = (ImplementsOpActionItem) parts.get(ipos); + implementsOp = io.superclasses; + continue; + } + if (parts.get(ipos) instanceof SetMemberActionItem) { + sm = (SetMemberActionItem) parts.get(ipos); + int rnum = -1; + if (sm.object instanceof DirectValueActionItem) { + DirectValueActionItem dv = (DirectValueActionItem) sm.object; + if (dv.value instanceof RegisterNumber) { + RegisterNumber rn = (RegisterNumber) dv.value; + rnum = rn.number; + } + } + if (sm.object instanceof TemporaryRegister) { + rnum = ((TemporaryRegister) sm.object).getRegId(); + } + if (rnum == instanceReg) { + if (sm.value instanceof FunctionActionItem) { + ((FunctionActionItem) sm.value).calculatedFunctionName = sm.objectName; + functions.add((FunctionActionItem) sm.value); + } else { + vars.add(new MyEntry<>(sm.objectName, sm.value)); + } + } else if (rnum == classReg) { + if (sm.value instanceof FunctionActionItem) { + ((FunctionActionItem) sm.value).calculatedFunctionName = sm.objectName; + staticFunctions.add((FunctionActionItem) sm.value); + } else { + staticVars.add(new MyEntry<>(sm.objectName, sm.value)); + } + } + + } + } + + } + + } + } + List output2 = new ArrayList<>(); + for (int i = 0; i < prevCount; i++) { + output2.add(output.get(i)); + } + output2.add(new ClassActionItem(className, extendsOp, implementsOp, null/*FIXME*/, functions, vars, staticFunctions, staticVars)); + return output2; + } + } + } else if (parts.get(ipos) instanceof SetMemberActionItem) { + SetMemberActionItem sm = (SetMemberActionItem) parts.get(0); + if (sm.value instanceof FunctionActionItem) { + FunctionActionItem f = (FunctionActionItem) sm.value; + if (f.actions.isEmpty()) { + if (parts.size() == 2) { + if (parts.get(1) instanceof ImplementsOpActionItem) { + ImplementsOpActionItem iot = (ImplementsOpActionItem) 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 InterfaceActionItem(sm.objectName, implementsOp)); + return output2; + } + } + } + } + } + } 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(long address, List actions, int version, String path) { + List ret = actions; + if (true) { + //return ret; + } + String s = null; + try { + HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), false); + Action.actionsToString(new ArrayList(), address, ret, null, version, ScriptExportMode.PCODE, writer, path); + s = writer.toString(); + ret = ASMParser.parse(address, true, s, SWF.DEFAULT_VERSION, false); + } catch (IOException | ParseException ex) { + Logger.getLogger(SWFInputStream.class.getName()).log(Level.SEVERE, "parsing error. path: " + path, ex); + } + return ret; + } + + public static void setConstantPool(List actions, ConstantPool cpool) { + for (GraphSourceItem 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,actions); + } + } + if (a instanceof ActionDefineFunction2) { + if (cpool != null) { + //((ActionDefineFunction2) a).setConstantPool(cpool.constants,actions); + } + } + } + } + + public GraphTextWriter getASMSourceReplaced(List container, List knownAddreses, List constantPool, int version, ScriptExportMode exportMode, GraphTextWriter writer) { + writer.appendNoHilight(getASMSource(container, knownAddreses, constantPool, version, exportMode)); + return writer; + } + + public static double toFloatPoint(Object o) { + if (o instanceof Double) { + return (Double) o; + } + if (o instanceof Integer) { + return (Integer) o; + } + if (o instanceof Long) { + return (Long) o; + } + if (o instanceof String) { + try { + return Double.parseDouble((String) o); + } catch (NumberFormatException nfe) { + return 0; + } + } + return 0; + } + + public static GraphTargetItem gettoset(GraphTargetItem get, GraphTargetItem value, List variables) { + GraphTargetItem ret = get; + boolean boxed = false; + if (get instanceof VariableActionItem) { + boxed = true; + ret = ((VariableActionItem) ret).getBoxedValue(); + } + if (ret instanceof GetVariableActionItem) { + GetVariableActionItem gv = (GetVariableActionItem) ret; + ret = new SetVariableActionItem(null, gv.name, value); + } else if (ret instanceof GetMemberActionItem) { + GetMemberActionItem mem = (GetMemberActionItem) ret; + ret = new SetMemberActionItem(null, mem.object, mem.memberName, value); + } else if ((ret instanceof DirectValueActionItem) && ((DirectValueActionItem) ret).value instanceof RegisterNumber) { + ret = new StoreRegisterActionItem(null, (RegisterNumber) ((DirectValueActionItem) ret).value, value, false); + } else if (ret instanceof GetPropertyActionItem) { + GetPropertyActionItem gp = (GetPropertyActionItem) ret; + ret = new SetPropertyActionItem(null, gp.target, gp.propertyIndex, value); + } + if (boxed) { + GraphTargetItem b = ret; + ret = new VariableActionItem(((VariableActionItem) get).getVariableName(), value, ((VariableActionItem) get).isDefinition()); + ((VariableActionItem) ret).setBoxedValue((ActionItem) b); + variables.remove((VariableActionItem) get); + variables.add((VariableActionItem) ret); + } + return ret; + } + + @Override + public boolean isDeobfuscatePop() { + return false; + } +} diff --git a/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java b/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java index 4fb8f657f..69fdc5511 100644 --- a/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java +++ b/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java @@ -1,48 +1,48 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.flashlite; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.FSCommand2ActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionFSCommand2 extends Action { - - public ActionFSCommand2() { - super(0x2D, 0); - } - - @Override - public String toString() { - return "FSCommand2"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - 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 FSCommand2ActionItem(this, command, args)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.flashlite; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.FSCommand2ActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionFSCommand2 extends Action { + + public ActionFSCommand2() { + super(0x2D, 0); + } + + @Override + public String toString() { + return "FSCommand2"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + 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 FSCommand2ActionItem(this, command, args)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java b/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java index 3da86c4c1..e6a055de6 100644 --- a/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java +++ b/src/com/jpexs/decompiler/flash/action/flashlite/ActionStrictMode.java @@ -61,7 +61,7 @@ public class ActionStrictMode extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { output.add(new StrictModeActionItem(this, mode)); } } diff --git a/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptLexer.java b/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptLexer.java index a1ef4635b..39178d6c7 100644 --- a/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptLexer.java +++ b/src/com/jpexs/decompiler/flash/action/parser/script/ActionScriptLexer.java @@ -1203,7 +1203,7 @@ public final class ActionScriptLexer { return yychar; } - private Stack pushedBack = new Stack(); + private Stack pushedBack = new Stack<>(); public int yyline() { return yyline + 1; diff --git a/src/com/jpexs/decompiler/flash/action/special/ActionEnd.java b/src/com/jpexs/decompiler/flash/action/special/ActionEnd.java index d2449211f..f993cf2b3 100644 --- a/src/com/jpexs/decompiler/flash/action/special/ActionEnd.java +++ b/src/com/jpexs/decompiler/flash/action/special/ActionEnd.java @@ -1,46 +1,46 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.special; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionEnd extends Action { - - public ActionEnd() { - super(0, 0); - setIgnored(true, 0); - } - - @Override - public String toString() { - return "End"; - } - - @Override - public boolean isExit() { - return true; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - //output.add(new SimpleActionTreeItem(this, "end()")); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.special; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionEnd extends Action { + + public ActionEnd() { + super(0, 0); + setIgnored(true, 0); + } + + @Override + public String toString() { + return "End"; + } + + @Override + public boolean isExit() { + return true; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + //output.add(new SimpleActionTreeItem(this, "end()")); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/special/ActionNop.java b/src/com/jpexs/decompiler/flash/action/special/ActionNop.java index 3f9212ca3..f0eebdc5f 100644 --- a/src/com/jpexs/decompiler/flash/action/special/ActionNop.java +++ b/src/com/jpexs/decompiler/flash/action/special/ActionNop.java @@ -1,40 +1,40 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.special; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionNop extends Action { - - public ActionNop() { - super(-1, 0); - } - - @Override - public String toString() { - return "Nop"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - //output.add(new SimpleActionTreeItem(this, "nop();")); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.special; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionNop extends Action { + + public ActionNop() { + super(-1, 0); + } + + @Override + public String toString() { + return "Nop"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + //output.add(new SimpleActionTreeItem(this, "nop();")); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java index 8e459ca2c..4180ce4ca 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionGetURL.java @@ -80,7 +80,7 @@ public class ActionGetURL extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { String fsCommandPrefix = "FSCommand:"; if (urlString.startsWith(fsCommandPrefix) && targetString.isEmpty()) { String command = urlString.substring(fsCommandPrefix.length()); diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java index 060690c57..73d400d51 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionGoToLabel.java @@ -69,7 +69,7 @@ public class ActionGoToLabel extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { output.add(new GotoLabelActionItem(this, label)); } } diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionGotoFrame.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionGotoFrame.java index 93a98086d..1fa2f3fff 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionGotoFrame.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionGotoFrame.java @@ -66,7 +66,7 @@ public class ActionGotoFrame extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { output.add(new GotoFrameActionItem(this, frame)); } } diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionNextFrame.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionNextFrame.java index 0a1083f25..9a6c5a467 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionNextFrame.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionNextFrame.java @@ -1,41 +1,41 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf3; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.NextFrameActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionNextFrame extends Action { - - public ActionNextFrame() { - super(0x04, 0); - } - - @Override - public String toString() { - return "NextFrame"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - output.add(new NextFrameActionItem(this)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf3; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.NextFrameActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionNextFrame extends Action { + + public ActionNextFrame() { + super(0x04, 0); + } + + @Override + public String toString() { + return "NextFrame"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + output.add(new NextFrameActionItem(this)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionPlay.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionPlay.java index 3e1f49ddd..ab3794fab 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionPlay.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionPlay.java @@ -38,7 +38,7 @@ public class ActionPlay extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { if (!output.isEmpty() && (output.get(output.size() - 1) instanceof GotoFrameActionItem)) { GotoFrameActionItem gta = (GotoFrameActionItem) output.remove(output.size() - 1); output.add(new GotoFrame2ActionItem(this, new DirectValueActionItem(gta.frame + 1), false, true, 0)); diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionPrevFrame.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionPrevFrame.java index 1cb0949d6..149f55875 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionPrevFrame.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionPrevFrame.java @@ -1,41 +1,41 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf3; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.PrevFrameActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionPrevFrame extends Action { - - public ActionPrevFrame() { - super(0x05, 0); - } - - @Override - public String toString() { - return "PrevFrame"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - output.add(new PrevFrameActionItem(this)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf3; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.PrevFrameActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionPrevFrame extends Action { + + public ActionPrevFrame() { + super(0x05, 0); + } + + @Override + public String toString() { + return "PrevFrame"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + output.add(new PrevFrameActionItem(this)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java index 137fc9a90..42968eadb 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionSetTarget.java @@ -69,7 +69,7 @@ public class ActionSetTarget extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { output.add(new SetTargetActionItem(this, targetName)); } } diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionStop.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionStop.java index 7b9fbd434..4f91c2043 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionStop.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionStop.java @@ -1,41 +1,41 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf3; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.StopActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionStop extends Action { - - public ActionStop() { - super(0x07, 0); - } - - @Override - public String toString() { - return "Stop"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - output.add(new StopActionItem(this)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf3; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.StopActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionStop extends Action { + + public ActionStop() { + super(0x07, 0); + } + + @Override + public String toString() { + return "Stop"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + output.add(new StopActionItem(this)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionStopSounds.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionStopSounds.java index d9bdb99fb..badf7908a 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionStopSounds.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionStopSounds.java @@ -1,41 +1,41 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf3; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.StopAllSoundsActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionStopSounds extends Action { - - public ActionStopSounds() { - super(0x09, 0); - } - - @Override - public String toString() { - return "StopSounds"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - output.add(new StopAllSoundsActionItem(this)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf3; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.StopAllSoundsActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionStopSounds extends Action { + + public ActionStopSounds() { + super(0x09, 0); + } + + @Override + public String toString() { + return "StopSounds"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + output.add(new StopAllSoundsActionItem(this)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionToggleQuality.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionToggleQuality.java index eb5af7482..34737382f 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionToggleQuality.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionToggleQuality.java @@ -1,41 +1,41 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf3; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.ToggleHighQualityActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionToggleQuality extends Action { - - public ActionToggleQuality() { - super(0x08, 0); - } - - @Override - public String toString() { - return "ToggleQuality"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - output.add(new ToggleHighQualityActionItem(this)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf3; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.ToggleHighQualityActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionToggleQuality extends Action { + + public ActionToggleQuality() { + super(0x08, 0); + } + + @Override + public String toString() { + return "ToggleQuality"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + output.add(new ToggleHighQualityActionItem(this)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java b/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java index 0378aa329..4fe1c6804 100644 --- a/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java +++ b/src/com/jpexs/decompiler/flash/action/swf3/ActionWaitForFrame.java @@ -82,7 +82,7 @@ public class ActionWaitForFrame extends Action implements ActionStore { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) throws InterruptedException { + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) throws InterruptedException { GraphTargetItem frameTi = new DirectValueActionItem(null, 0, new Long(frame), new ArrayList()); List body = ActionGraph.translateViaGraph(regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path); output.add(new IfFrameLoadedActionItem(frameTi, body, this)); diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionAdd.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionAdd.java index e18f4c789..86404f8b5 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionAdd.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionAdd.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.AddActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionAdd extends Action { - - public ActionAdd() { - super(0x0A, 0); - } - - @Override - public String toString() { - return "Add"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new AddActionItem(this, b, a, false)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.AddActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionAdd extends Action { + + public ActionAdd() { + super(0x0A, 0); + } + + @Override + public String toString() { + return "Add"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new AddActionItem(this, b, a, false)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionAnd.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionAnd.java index 4525c77cf..8e85084cb 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionAnd.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionAnd.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.AndActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionAnd extends Action { - - public ActionAnd() { - super(0x10, 0); - } - - @Override - public String toString() { - return "And"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new AndActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.AndActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionAnd extends Action { + + public ActionAnd() { + super(0x10, 0); + } + + @Override + public String toString() { + return "And"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new AndActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionAsciiToChar.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionAsciiToChar.java index 520bdb35d..77fc9f270 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionAsciiToChar.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionAsciiToChar.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.AsciiToCharActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionAsciiToChar extends Action { - - public ActionAsciiToChar() { - super(0x33, 0); - } - - @Override - public String toString() { - return "AsciiToChar"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - stack.push(new AsciiToCharActionItem(this, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.AsciiToCharActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionAsciiToChar extends Action { + + public ActionAsciiToChar() { + super(0x33, 0); + } + + @Override + public String toString() { + return "AsciiToChar"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + stack.push(new AsciiToCharActionItem(this, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionCall.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionCall.java index ca7e83c7e..849b13cf3 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionCall.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionCall.java @@ -1,45 +1,45 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.CallActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionCall extends Action { - - public ActionCall() { - super(0x9E, 0); - } - - public ActionCall(int actionLength) { - super(0x9E, actionLength); - } - - @Override - public String toString() { - return "Call"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - output.add(new CallActionItem(this, stack.pop())); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.CallActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionCall extends Action { + + public ActionCall() { + super(0x9E, 0); + } + + public ActionCall(int actionLength) { + super(0x9E, actionLength); + } + + @Override + public String toString() { + return "Call"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + output.add(new CallActionItem(this, stack.pop())); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionCharToAscii.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionCharToAscii.java index 31764a41f..8a1812ac2 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionCharToAscii.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionCharToAscii.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.CharToAsciiActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionCharToAscii extends Action { - - public ActionCharToAscii() { - super(0x32, 0); - } - - @Override - public String toString() { - return "CharToAscii"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - stack.push(new CharToAsciiActionItem(this, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.CharToAsciiActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionCharToAscii extends Action { + + public ActionCharToAscii() { + super(0x32, 0); + } + + @Override + public String toString() { + return "CharToAscii"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + stack.push(new CharToAsciiActionItem(this, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionCloneSprite.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionCloneSprite.java index a3b5efc7c..ade72a29b 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionCloneSprite.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionCloneSprite.java @@ -1,44 +1,44 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.CloneSpriteActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionCloneSprite extends Action { - - public ActionCloneSprite() { - super(0x24, 0); - } - - @Override - public String toString() { - return "CloneSprite"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem depth = stack.pop(); - GraphTargetItem source = stack.pop(); - GraphTargetItem target = stack.pop(); - output.add(new CloneSpriteActionItem(this, source, target, depth)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.CloneSpriteActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionCloneSprite extends Action { + + public ActionCloneSprite() { + super(0x24, 0); + } + + @Override + public String toString() { + return "CloneSprite"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem depth = stack.pop(); + GraphTargetItem source = stack.pop(); + GraphTargetItem target = stack.pop(); + output.add(new CloneSpriteActionItem(this, source, target, depth)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionDivide.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionDivide.java index 5494803c3..aa2ba21be 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionDivide.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionDivide.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.DivideActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionDivide extends Action { - - public ActionDivide() { - super(0x0D, 0); - } - - @Override - public String toString() { - return "Divide"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new DivideActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.DivideActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionDivide extends Action { + + public ActionDivide() { + super(0x0D, 0); + } + + @Override + public String toString() { + return "Divide"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new DivideActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionEndDrag.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionEndDrag.java index 7e88af695..a7b5c890d 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionEndDrag.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionEndDrag.java @@ -1,41 +1,41 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.StopDragActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionEndDrag extends Action { - - public ActionEndDrag() { - super(0x28, 0); - } - - @Override - public String toString() { - return "EndDrag"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - output.add(new StopDragActionItem(this)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.StopDragActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionEndDrag extends Action { + + public ActionEndDrag() { + super(0x28, 0); + } + + @Override + public String toString() { + return "EndDrag"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + output.add(new StopDragActionItem(this)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionEquals.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionEquals.java index 4e2787733..6a4896308 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionEquals.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionEquals.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.EqActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionEquals extends Action { - - public ActionEquals() { - super(0x0E, 0); - } - - @Override - public String toString() { - return "Equals"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new EqActionItem(this, b, a, false)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.EqActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionEquals extends Action { + + public ActionEquals() { + super(0x0E, 0); + } + + @Override + public String toString() { + return "Equals"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new EqActionItem(this, b, a, false)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java index fa2d11642..09a16cadf 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java @@ -1,54 +1,54 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; -import com.jpexs.decompiler.flash.action.model.GetPropertyActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionGetProperty extends Action { - - public ActionGetProperty() { - super(0x22, 0); - } - - @Override - public String toString() { - return "GetProperty"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem index = stack.pop(); - GraphTargetItem target = stack.pop(); - int indexInt = 0; - if (index instanceof DirectValueActionItem) { - if (((DirectValueActionItem) index).value instanceof Long) { - indexInt = (int) (long) (Long) ((DirectValueActionItem) index).value; - } else if (((DirectValueActionItem) index).value instanceof Double) { - indexInt = (int) Math.round((Double) ((DirectValueActionItem) index).value); - } else if (((DirectValueActionItem) index).value instanceof Float) { - indexInt = (int) Math.round((Float) ((DirectValueActionItem) index).value); - } - } - stack.push(new GetPropertyActionItem(this, target, indexInt)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.flash.action.model.GetPropertyActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionGetProperty extends Action { + + public ActionGetProperty() { + super(0x22, 0); + } + + @Override + public String toString() { + return "GetProperty"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem index = stack.pop(); + GraphTargetItem target = stack.pop(); + int indexInt = 0; + if (index instanceof DirectValueActionItem) { + if (((DirectValueActionItem) index).value instanceof Long) { + indexInt = (int) (long) (Long) ((DirectValueActionItem) index).value; + } else if (((DirectValueActionItem) index).value instanceof Double) { + indexInt = (int) Math.round((Double) ((DirectValueActionItem) index).value); + } else if (((DirectValueActionItem) index).value instanceof Float) { + indexInt = (int) Math.round((Float) ((DirectValueActionItem) index).value); + } + } + stack.push(new GetPropertyActionItem(this, target, indexInt)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java index 4c7383a19..499c78140 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java @@ -1,41 +1,41 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.GetTimeActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionGetTime extends Action { - - public ActionGetTime() { - super(0x34, 0); - } - - @Override - public String toString() { - return "GetTime"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - stack.push(new GetTimeActionItem(this)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.GetTimeActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionGetTime extends Action { + + public ActionGetTime() { + super(0x34, 0); + } + + @Override + public String toString() { + return "GetTime"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + stack.push(new GetTimeActionItem(this)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java index c81180876..a91448ca3 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java @@ -93,7 +93,7 @@ public class ActionGetURL2 extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem targetString = stack.pop(); GraphTargetItem urlString = stack.pop(); Integer num = null; diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetVariable.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetVariable.java index 799187252..34f5d1f43 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionGetVariable.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionGetVariable.java @@ -1,55 +1,55 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; -import com.jpexs.decompiler.flash.action.model.EvalActionItem; -import com.jpexs.decompiler.flash.action.model.GetVariableActionItem; -import com.jpexs.decompiler.flash.action.model.GetVersionActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.model.LocalData; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionGetVariable extends Action { - - public ActionGetVariable() { - super(0x1C, 0); - } - - @Override - public String toString() { - return "GetVariable"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem name = stack.pop(); - GraphTargetItem computedVal = variables.get(name.toStringNoQuotes(LocalData.empty)); - if (name instanceof DirectValueActionItem && ((DirectValueActionItem) name).value.equals("/:$version")) { - stack.push(new GetVersionActionItem(this)); - } else if (!(name instanceof DirectValueActionItem) && !(name instanceof GetVariableActionItem)) { - stack.push(new EvalActionItem(this, name)); - } else { - GetVariableActionItem gvt = new GetVariableActionItem(this, name); - gvt.setComputedValue(computedVal); - stack.push(gvt); - } - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.flash.action.model.EvalActionItem; +import com.jpexs.decompiler.flash.action.model.GetVariableActionItem; +import com.jpexs.decompiler.flash.action.model.GetVersionActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.model.LocalData; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionGetVariable extends Action { + + public ActionGetVariable() { + super(0x1C, 0); + } + + @Override + public String toString() { + return "GetVariable"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem name = stack.pop(); + GraphTargetItem computedVal = variables.get(name.toStringNoQuotes(LocalData.empty)); + if (name instanceof DirectValueActionItem && ((DirectValueActionItem) name).value.equals("/:$version")) { + stack.push(new GetVersionActionItem(this)); + } else if (!(name instanceof DirectValueActionItem) && !(name instanceof GetVariableActionItem)) { + stack.push(new EvalActionItem(this, name)); + } else { + GetVariableActionItem gvt = new GetVariableActionItem(this, name); + gvt.setComputedValue(computedVal); + stack.push(gvt); + } + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java index a35d71757..ad1e9c714 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java @@ -85,7 +85,7 @@ public class ActionGotoFrame2 extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem frame = stack.pop(); output.add(new GotoFrame2ActionItem(this, frame, sceneBiasFlag, playFlag, sceneBias)); } diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionLess.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionLess.java index 278987f6a..82c81d6cc 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionLess.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionLess.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.LtActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionLess extends Action { - - public ActionLess() { - super(0x0F, 0); - } - - @Override - public String toString() { - return "Less"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new LtActionItem(this, b, a, false)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.LtActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionLess extends Action { + + public ActionLess() { + super(0x0F, 0); + } + + @Override + public String toString() { + return "Less"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new LtActionItem(this, b, a, false)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionMBAsciiToChar.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionMBAsciiToChar.java index e02ac48c1..12886323a 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionMBAsciiToChar.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionMBAsciiToChar.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.MBAsciiToCharActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionMBAsciiToChar extends Action { - - public ActionMBAsciiToChar() { - super(0x37, 0); - } - - @Override - public String toString() { - return "MBAsciiToChar"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - stack.push(new MBAsciiToCharActionItem(this, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.MBAsciiToCharActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionMBAsciiToChar extends Action { + + public ActionMBAsciiToChar() { + super(0x37, 0); + } + + @Override + public String toString() { + return "MBAsciiToChar"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + stack.push(new MBAsciiToCharActionItem(this, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionMBCharToAscii.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionMBCharToAscii.java index e13323be4..0ab3e4533 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionMBCharToAscii.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionMBCharToAscii.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.MBCharToAsciiActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionMBCharToAscii extends Action { - - public ActionMBCharToAscii() { - super(0x36, 0); - } - - @Override - public String toString() { - return "MBCharToAscii"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - stack.push(new MBCharToAsciiActionItem(this, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.MBCharToAsciiActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionMBCharToAscii extends Action { + + public ActionMBCharToAscii() { + super(0x36, 0); + } + + @Override + public String toString() { + return "MBCharToAscii"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + stack.push(new MBCharToAsciiActionItem(this, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringExtract.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringExtract.java index 5fdc831de..f5bb13c6f 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringExtract.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringExtract.java @@ -1,44 +1,44 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.MBStringExtractActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionMBStringExtract extends Action { - - public ActionMBStringExtract() { - super(0x35, 0); - } - - @Override - public String toString() { - return "MBStringExtract"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem count = stack.pop(); - GraphTargetItem index = stack.pop(); - GraphTargetItem value = stack.pop(); - stack.push(new MBStringExtractActionItem(this, value, index, count)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.MBStringExtractActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionMBStringExtract extends Action { + + public ActionMBStringExtract() { + super(0x35, 0); + } + + @Override + public String toString() { + return "MBStringExtract"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem count = stack.pop(); + GraphTargetItem index = stack.pop(); + GraphTargetItem value = stack.pop(); + stack.push(new MBStringExtractActionItem(this, value, index, count)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringLength.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringLength.java index 8e1897adf..03a6febb0 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringLength.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringLength.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.MBStringLengthActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionMBStringLength extends Action { - - public ActionMBStringLength() { - super(0x31, 0); - } - - @Override - public String toString() { - return "MBStringLength"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - stack.push(new MBStringLengthActionItem(this, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.MBStringLengthActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionMBStringLength extends Action { + + public ActionMBStringLength() { + super(0x31, 0); + } + + @Override + public String toString() { + return "MBStringLength"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + stack.push(new MBStringLengthActionItem(this, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionMultiply.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionMultiply.java index 222b3c7f8..3be11ecae 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionMultiply.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionMultiply.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.MultiplyActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionMultiply extends Action { - - public ActionMultiply() { - super(0x0C, 0); - } - - @Override - public String toString() { - return "Multiply"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new MultiplyActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.MultiplyActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionMultiply extends Action { + + public ActionMultiply() { + super(0x0C, 0); + } + + @Override + public String toString() { + return "Multiply"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new MultiplyActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionNot.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionNot.java index 8bcb35316..e1ecec0b8 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionNot.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionNot.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.model.NotItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionNot extends Action { - - public ActionNot() { - super(0x12, 0); - } - - @Override - public String toString() { - return "Not"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - stack.push(new NotItem(this, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.model.NotItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionNot extends Action { + + public ActionNot() { + super(0x12, 0); + } + + @Override + public String toString() { + return "Not"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + stack.push(new NotItem(this, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionOr.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionOr.java index f74082d86..3bc12c513 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionOr.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionOr.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.OrActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionOr extends Action { - - public ActionOr() { - super(0x11, 0); - } - - @Override - public String toString() { - return "Or"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new OrActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.OrActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionOr extends Action { + + public ActionOr() { + super(0x11, 0); + } + + @Override + public String toString() { + return "Or"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new OrActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionPop.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionPop.java index 777115328..d42940615 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionPop.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionPop.java @@ -1,48 +1,48 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionPop extends Action { - - public ActionPop() { - super(0x17, 0); - } - - @Override - public String toString() { - return "Pop"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - if (stack.isEmpty()) { - return; - } - GraphTargetItem val = stack.pop(); - if (val instanceof DirectValueActionItem) { - return; - } - output.add(val); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionPop extends Action { + + public ActionPop() { + super(0x17, 0); + } + + @Override + public String toString() { + return "Pop"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + if (stack.isEmpty()) { + return; + } + GraphTargetItem val = stack.pop(); + if (val instanceof DirectValueActionItem) { + return; + } + output.add(val); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java index 1678949f3..cdb6d8683 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java @@ -309,7 +309,7 @@ public class ActionPush extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { int pos = 0; for (Object o : values) { if (ignoredParts.contains(pos)) { diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionRandomNumber.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionRandomNumber.java index 7b32b4c19..37cd3a283 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionRandomNumber.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionRandomNumber.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.RandomNumberActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionRandomNumber extends Action { - - public ActionRandomNumber() { - super(0x30, 0); - } - - @Override - public String toString() { - return "RandomNumber"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem maximum = stack.pop(); - stack.push(new RandomNumberActionItem(this, maximum)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.RandomNumberActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionRandomNumber extends Action { + + public ActionRandomNumber() { + super(0x30, 0); + } + + @Override + public String toString() { + return "RandomNumber"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem maximum = stack.pop(); + stack.push(new RandomNumberActionItem(this, maximum)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionRemoveSprite.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionRemoveSprite.java index 1844c9fc1..aa380e8f4 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionRemoveSprite.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionRemoveSprite.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.RemoveSpriteActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionRemoveSprite extends Action { - - public ActionRemoveSprite() { - super(0x25, 0); - } - - @Override - public String toString() { - return "RemoveSprite"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem target = stack.pop(); - output.add(new RemoveSpriteActionItem(this, target)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.RemoveSpriteActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionRemoveSprite extends Action { + + public ActionRemoveSprite() { + super(0x25, 0); + } + + @Override + public String toString() { + return "RemoveSprite"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem target = stack.pop(); + output.add(new RemoveSpriteActionItem(this, target)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java index 288d85107..11d1e4549 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java @@ -1,112 +1,112 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.DecrementActionItem; -import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; -import com.jpexs.decompiler.flash.action.model.GetPropertyActionItem; -import com.jpexs.decompiler.flash.action.model.IncrementActionItem; -import com.jpexs.decompiler.flash.action.model.PostDecrementActionItem; -import com.jpexs.decompiler.flash.action.model.PostIncrementActionItem; -import com.jpexs.decompiler.flash.action.model.SetPropertyActionItem; -import com.jpexs.decompiler.flash.action.model.StoreRegisterActionItem; -import com.jpexs.decompiler.flash.action.model.TemporaryRegister; -import com.jpexs.decompiler.flash.action.model.operations.PreDecrementActionItem; -import com.jpexs.decompiler.flash.action.model.operations.PreIncrementActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionSetProperty extends Action { - - public ActionSetProperty() { - super(0x23, 0); - } - - @Override - public String toString() { - return "SetProperty"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem value = stack.pop().getThroughDuplicate(); - GraphTargetItem index = stack.pop().getThroughDuplicate(); - GraphTargetItem target = stack.pop().getThroughDuplicate(); - int indexInt = 0; - if (index instanceof DirectValueActionItem) { - if (((DirectValueActionItem) index).value instanceof Long) { - indexInt = (int) (long) (Long) ((DirectValueActionItem) index).value; - } else if (((DirectValueActionItem) index).value instanceof Double) { - indexInt = (int) Math.round((Double) ((DirectValueActionItem) index).value); - } else if (((DirectValueActionItem) index).value instanceof Float) { - indexInt = (int) Math.round((Float) ((DirectValueActionItem) index).value); - } - } - if (value.getThroughDuplicate() instanceof IncrementActionItem) { - GraphTargetItem obj = ((IncrementActionItem) value).object; - if (!stack.isEmpty()) { - if (stack.peek().valueEquals(obj)) { - stack.pop(); - stack.push(new PostIncrementActionItem(this, obj)); - return; - } - } - } - if (value.getThroughDuplicate() instanceof DecrementActionItem) { - GraphTargetItem obj = ((DecrementActionItem) value).object; - if (!stack.isEmpty()) { - if (stack.peek().valueEquals(obj)) { - stack.pop(); - stack.push(new PostDecrementActionItem(this, obj)); - return; - } - } - } - - GraphTargetItem ret = new SetPropertyActionItem(this, target, indexInt, value); - - if (value instanceof StoreRegisterActionItem) { - StoreRegisterActionItem sr = (StoreRegisterActionItem) value; - if (sr.define) { - value = sr.getValue(); - ((SetPropertyActionItem) ret).setValue(value); - if (value instanceof IncrementActionItem) { - if (((IncrementActionItem) value).object instanceof GetPropertyActionItem) { - if (((GetPropertyActionItem) ((IncrementActionItem) value).object).valueEquals(((SetPropertyActionItem) ret).getObject())) { - ret = new PreIncrementActionItem(this, ((IncrementActionItem) value).object); - } - } - } else if (value instanceof DecrementActionItem) { - if (((DecrementActionItem) value).object instanceof GetPropertyActionItem) { - if (((GetPropertyActionItem) ((DecrementActionItem) value).object).valueEquals(((SetPropertyActionItem) ret).getObject())) { - ret = new PreDecrementActionItem(this, ((DecrementActionItem) value).object); - } - } - } else { - sr.temporary = true; - ((SetPropertyActionItem) ret).setValue(sr); - } - variables.put("__register" + sr.register.number, new TemporaryRegister(sr.register.number, ret)); - return; - } - } - output.add(ret); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.DecrementActionItem; +import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.flash.action.model.GetPropertyActionItem; +import com.jpexs.decompiler.flash.action.model.IncrementActionItem; +import com.jpexs.decompiler.flash.action.model.PostDecrementActionItem; +import com.jpexs.decompiler.flash.action.model.PostIncrementActionItem; +import com.jpexs.decompiler.flash.action.model.SetPropertyActionItem; +import com.jpexs.decompiler.flash.action.model.StoreRegisterActionItem; +import com.jpexs.decompiler.flash.action.model.TemporaryRegister; +import com.jpexs.decompiler.flash.action.model.operations.PreDecrementActionItem; +import com.jpexs.decompiler.flash.action.model.operations.PreIncrementActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionSetProperty extends Action { + + public ActionSetProperty() { + super(0x23, 0); + } + + @Override + public String toString() { + return "SetProperty"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem value = stack.pop().getThroughDuplicate(); + GraphTargetItem index = stack.pop().getThroughDuplicate(); + GraphTargetItem target = stack.pop().getThroughDuplicate(); + int indexInt = 0; + if (index instanceof DirectValueActionItem) { + if (((DirectValueActionItem) index).value instanceof Long) { + indexInt = (int) (long) (Long) ((DirectValueActionItem) index).value; + } else if (((DirectValueActionItem) index).value instanceof Double) { + indexInt = (int) Math.round((Double) ((DirectValueActionItem) index).value); + } else if (((DirectValueActionItem) index).value instanceof Float) { + indexInt = (int) Math.round((Float) ((DirectValueActionItem) index).value); + } + } + if (value.getThroughDuplicate() instanceof IncrementActionItem) { + GraphTargetItem obj = ((IncrementActionItem) value).object; + if (!stack.isEmpty()) { + if (stack.peek().valueEquals(obj)) { + stack.pop(); + stack.push(new PostIncrementActionItem(this, obj)); + return; + } + } + } + if (value.getThroughDuplicate() instanceof DecrementActionItem) { + GraphTargetItem obj = ((DecrementActionItem) value).object; + if (!stack.isEmpty()) { + if (stack.peek().valueEquals(obj)) { + stack.pop(); + stack.push(new PostDecrementActionItem(this, obj)); + return; + } + } + } + + GraphTargetItem ret = new SetPropertyActionItem(this, target, indexInt, value); + + if (value instanceof StoreRegisterActionItem) { + StoreRegisterActionItem sr = (StoreRegisterActionItem) value; + if (sr.define) { + value = sr.getValue(); + ((SetPropertyActionItem) ret).setValue(value); + if (value instanceof IncrementActionItem) { + if (((IncrementActionItem) value).object instanceof GetPropertyActionItem) { + if (((GetPropertyActionItem) ((IncrementActionItem) value).object).valueEquals(((SetPropertyActionItem) ret).getObject())) { + ret = new PreIncrementActionItem(this, ((IncrementActionItem) value).object); + } + } + } else if (value instanceof DecrementActionItem) { + if (((DecrementActionItem) value).object instanceof GetPropertyActionItem) { + if (((GetPropertyActionItem) ((DecrementActionItem) value).object).valueEquals(((SetPropertyActionItem) ret).getObject())) { + ret = new PreDecrementActionItem(this, ((DecrementActionItem) value).object); + } + } + } else { + sr.temporary = true; + ((SetPropertyActionItem) ret).setValue(sr); + } + variables.put("__register" + sr.register.number, new TemporaryRegister(sr.register.number, ret)); + return; + } + } + output.add(ret); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionSetTarget2.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionSetTarget2.java index 261189c61..68e90b77b 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionSetTarget2.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionSetTarget2.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.SetTarget2ActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionSetTarget2 extends Action { - - public ActionSetTarget2() { - super(0x20, 0); - } - - @Override - public String toString() { - return "SetTarget2"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem target = stack.pop(); - output.add(new SetTarget2ActionItem(this, target)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.SetTarget2ActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionSetTarget2 extends Action { + + public ActionSetTarget2() { + super(0x20, 0); + } + + @Override + public String toString() { + return "SetTarget2"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem target = stack.pop(); + output.add(new SetTarget2ActionItem(this, target)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java index 42d8b9ecb..ce7c789b4 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java @@ -1,130 +1,130 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.StoreTypeAction; -import com.jpexs.decompiler.flash.action.model.ConstantPool; -import com.jpexs.decompiler.flash.action.model.DecrementActionItem; -import com.jpexs.decompiler.flash.action.model.GetVariableActionItem; -import com.jpexs.decompiler.flash.action.model.IncrementActionItem; -import com.jpexs.decompiler.flash.action.model.PostDecrementActionItem; -import com.jpexs.decompiler.flash.action.model.PostIncrementActionItem; -import com.jpexs.decompiler.flash.action.model.SetVariableActionItem; -import com.jpexs.decompiler.flash.action.model.StoreRegisterActionItem; -import com.jpexs.decompiler.flash.action.model.TemporaryRegister; -import com.jpexs.decompiler.flash.action.model.operations.PreDecrementActionItem; -import com.jpexs.decompiler.flash.action.model.operations.PreIncrementActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.model.LocalData; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionSetVariable extends Action implements StoreTypeAction { - - public ActionSetVariable() { - super(0x1D, 0); - } - - @Override - public String toString() { - return "SetVariable"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem value = stack.pop().getThroughDuplicate(); - GraphTargetItem name = stack.pop(); - variables.put(name.toStringNoQuotes(LocalData.empty), value); - if (value instanceof IncrementActionItem) { - GraphTargetItem obj = ((IncrementActionItem) value).object; - if (!stack.isEmpty()) { - if (stack.peek().valueEquals(obj)) { - stack.pop(); - stack.push(new PostIncrementActionItem(this, obj)); - return; - } - } - } - if (value instanceof DecrementActionItem) { - GraphTargetItem obj = ((DecrementActionItem) value).object; - if (!stack.isEmpty()) { - if (stack.peek().valueEquals(obj)) { - stack.pop(); - stack.push(new PostDecrementActionItem(this, obj)); - return; - } - } - } - if (value instanceof IncrementActionItem) { - if (((IncrementActionItem) value).object instanceof GetVariableActionItem) { - if (((GetVariableActionItem) ((IncrementActionItem) value).object).name.valueEquals(name)) { - output.add(new PostIncrementActionItem(this, ((IncrementActionItem) value).object)); - return; - } - } - } - if (value instanceof DecrementActionItem) { - if (((DecrementActionItem) value).object instanceof GetVariableActionItem) { - if (((GetVariableActionItem) ((DecrementActionItem) value).object).name.valueEquals(name)) { - output.add(new PostDecrementActionItem(this, ((DecrementActionItem) value).object)); - return; - } - } - } - - GraphTargetItem ret = new SetVariableActionItem(this, name, value); - - if (value instanceof StoreRegisterActionItem) { - StoreRegisterActionItem sr = (StoreRegisterActionItem) value; - if (sr.define) { - value = sr.getValue(); - ((SetVariableActionItem) ret).setValue(value); - if (value instanceof IncrementActionItem) { - if (((IncrementActionItem) value).object instanceof GetVariableActionItem) { - if (((GetVariableActionItem) ((IncrementActionItem) value).object).name.valueEquals(name)) { - ret = new PreIncrementActionItem(this, ((IncrementActionItem) value).object); - } - } - } else if (value instanceof DecrementActionItem) { - if (((DecrementActionItem) value).object instanceof GetVariableActionItem) { - if (((GetVariableActionItem) ((DecrementActionItem) value).object).name.valueEquals(name)) { - ret = new PreDecrementActionItem(this, ((DecrementActionItem) value).object); - } - } - } else { - sr.temporary = true; - ((SetVariableActionItem) ret).setValue(sr); - } - - variables.put("__register" + sr.register.number, new TemporaryRegister(sr.register.number, ret)); - return; - } - } - - output.add(ret); - } - - @Override - public String getVariableName(Stack stack, ConstantPool cpool) { - if (stack.size() < 2) { - return null; - } - return stack.get(stack.size() - 2).toStringNoQuotes(LocalData.create(cpool)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.StoreTypeAction; +import com.jpexs.decompiler.flash.action.model.ConstantPool; +import com.jpexs.decompiler.flash.action.model.DecrementActionItem; +import com.jpexs.decompiler.flash.action.model.GetVariableActionItem; +import com.jpexs.decompiler.flash.action.model.IncrementActionItem; +import com.jpexs.decompiler.flash.action.model.PostDecrementActionItem; +import com.jpexs.decompiler.flash.action.model.PostIncrementActionItem; +import com.jpexs.decompiler.flash.action.model.SetVariableActionItem; +import com.jpexs.decompiler.flash.action.model.StoreRegisterActionItem; +import com.jpexs.decompiler.flash.action.model.TemporaryRegister; +import com.jpexs.decompiler.flash.action.model.operations.PreDecrementActionItem; +import com.jpexs.decompiler.flash.action.model.operations.PreIncrementActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.model.LocalData; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionSetVariable extends Action implements StoreTypeAction { + + public ActionSetVariable() { + super(0x1D, 0); + } + + @Override + public String toString() { + return "SetVariable"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem value = stack.pop().getThroughDuplicate(); + GraphTargetItem name = stack.pop(); + variables.put(name.toStringNoQuotes(LocalData.empty), value); + if (value instanceof IncrementActionItem) { + GraphTargetItem obj = ((IncrementActionItem) value).object; + if (!stack.isEmpty()) { + if (stack.peek().valueEquals(obj)) { + stack.pop(); + stack.push(new PostIncrementActionItem(this, obj)); + return; + } + } + } + if (value instanceof DecrementActionItem) { + GraphTargetItem obj = ((DecrementActionItem) value).object; + if (!stack.isEmpty()) { + if (stack.peek().valueEquals(obj)) { + stack.pop(); + stack.push(new PostDecrementActionItem(this, obj)); + return; + } + } + } + if (value instanceof IncrementActionItem) { + if (((IncrementActionItem) value).object instanceof GetVariableActionItem) { + if (((GetVariableActionItem) ((IncrementActionItem) value).object).name.valueEquals(name)) { + output.add(new PostIncrementActionItem(this, ((IncrementActionItem) value).object)); + return; + } + } + } + if (value instanceof DecrementActionItem) { + if (((DecrementActionItem) value).object instanceof GetVariableActionItem) { + if (((GetVariableActionItem) ((DecrementActionItem) value).object).name.valueEquals(name)) { + output.add(new PostDecrementActionItem(this, ((DecrementActionItem) value).object)); + return; + } + } + } + + GraphTargetItem ret = new SetVariableActionItem(this, name, value); + + if (value instanceof StoreRegisterActionItem) { + StoreRegisterActionItem sr = (StoreRegisterActionItem) value; + if (sr.define) { + value = sr.getValue(); + ((SetVariableActionItem) ret).setValue(value); + if (value instanceof IncrementActionItem) { + if (((IncrementActionItem) value).object instanceof GetVariableActionItem) { + if (((GetVariableActionItem) ((IncrementActionItem) value).object).name.valueEquals(name)) { + ret = new PreIncrementActionItem(this, ((IncrementActionItem) value).object); + } + } + } else if (value instanceof DecrementActionItem) { + if (((DecrementActionItem) value).object instanceof GetVariableActionItem) { + if (((GetVariableActionItem) ((DecrementActionItem) value).object).name.valueEquals(name)) { + ret = new PreDecrementActionItem(this, ((DecrementActionItem) value).object); + } + } + } else { + sr.temporary = true; + ((SetVariableActionItem) ret).setValue(sr); + } + + variables.put("__register" + sr.register.number, new TemporaryRegister(sr.register.number, ret)); + return; + } + } + + output.add(ret); + } + + @Override + public String getVariableName(Stack stack, ConstantPool cpool) { + if (stack.size() < 2) { + return null; + } + return stack.get(stack.size() - 2).toStringNoQuotes(LocalData.create(cpool)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java index 6ad66a3f7..5d0019ee4 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java @@ -1,63 +1,63 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; -import com.jpexs.decompiler.flash.action.model.StartDragActionItem; -import com.jpexs.decompiler.flash.ecma.EcmaScript; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionStartDrag extends Action { - - public ActionStartDrag() { - super(0x27, 0); - } - - @Override - public String toString() { - return "StartDrag"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem target = stack.pop(); - GraphTargetItem lockCenter = stack.pop(); - GraphTargetItem constrain = stack.pop(); - - boolean hasConstrains = true; - if (constrain instanceof DirectValueActionItem) { - if (Double.compare(EcmaScript.toNumber(constrain.getResult()), 0) == 0) { - hasConstrains = false; - } - } - GraphTargetItem x1 = null; - GraphTargetItem y1 = null; - GraphTargetItem x2 = null; - GraphTargetItem y2 = null; - if (hasConstrains) { - y2 = stack.pop(); - x2 = stack.pop(); - y1 = stack.pop(); - x1 = stack.pop(); - } - output.add(new StartDragActionItem(this, target, lockCenter, constrain, x1, y1, x2, y2)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.flash.action.model.StartDragActionItem; +import com.jpexs.decompiler.flash.ecma.EcmaScript; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionStartDrag extends Action { + + public ActionStartDrag() { + super(0x27, 0); + } + + @Override + public String toString() { + return "StartDrag"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem target = stack.pop(); + GraphTargetItem lockCenter = stack.pop(); + GraphTargetItem constrain = stack.pop(); + + boolean hasConstrains = true; + if (constrain instanceof DirectValueActionItem) { + if (Double.compare(EcmaScript.toNumber(constrain.getResult()), 0) == 0) { + hasConstrains = false; + } + } + GraphTargetItem x1 = null; + GraphTargetItem y1 = null; + GraphTargetItem x2 = null; + GraphTargetItem y2 = null; + if (hasConstrains) { + y2 = stack.pop(); + x2 = stack.pop(); + y1 = stack.pop(); + x1 = stack.pop(); + } + output.add(new StartDragActionItem(this, target, lockCenter, constrain, x1, y1, x2, y2)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringAdd.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringAdd.java index 1ff6464b5..c74b61116 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringAdd.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringAdd.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.StringAddActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionStringAdd extends Action { - - public ActionStringAdd() { - super(0x21, 0); - } - - @Override - public String toString() { - return "StringAdd"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new StringAddActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.StringAddActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionStringAdd extends Action { + + public ActionStringAdd() { + super(0x21, 0); + } + + @Override + public String toString() { + return "StringAdd"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new StringAddActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringEquals.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringEquals.java index 91952ffed..e2ffa6f37 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringEquals.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringEquals.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.StringEqActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionStringEquals extends Action { - - public ActionStringEquals() { - super(0x13, 0); - } - - @Override - public String toString() { - return "StringEquals"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new StringEqActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.StringEqActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionStringEquals extends Action { + + public ActionStringEquals() { + super(0x13, 0); + } + + @Override + public String toString() { + return "StringEquals"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new StringEqActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringExtract.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringExtract.java index fc072946f..37ba9e233 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringExtract.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringExtract.java @@ -1,44 +1,44 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.StringExtractActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionStringExtract extends Action { - - public ActionStringExtract() { - super(0x15, 0); - } - - @Override - public String toString() { - return "StringExtract"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem count = stack.pop(); - GraphTargetItem index = stack.pop(); - GraphTargetItem value = stack.pop(); - stack.push(new StringExtractActionItem(this, value, index, count)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.StringExtractActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionStringExtract extends Action { + + public ActionStringExtract() { + super(0x15, 0); + } + + @Override + public String toString() { + return "StringExtract"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem count = stack.pop(); + GraphTargetItem index = stack.pop(); + GraphTargetItem value = stack.pop(); + stack.push(new StringExtractActionItem(this, value, index, count)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLength.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLength.java index d2784e7eb..98ca04cd0 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLength.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLength.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.StringLengthActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionStringLength extends Action { - - public ActionStringLength() { - super(0x14, 0); - } - - @Override - public String toString() { - return "StringLength"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - stack.push(new StringLengthActionItem(this, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.StringLengthActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionStringLength extends Action { + + public ActionStringLength() { + super(0x14, 0); + } + + @Override + public String toString() { + return "StringLength"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + stack.push(new StringLengthActionItem(this, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLess.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLess.java index c17d55d3a..2c9586113 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLess.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLess.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.StringLtActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionStringLess extends Action { - - public ActionStringLess() { - super(0x29, 0); - } - - @Override - public String toString() { - return "StringLess"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new StringLtActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.StringLtActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionStringLess extends Action { + + public ActionStringLess() { + super(0x29, 0); + } + + @Override + public String toString() { + return "StringLess"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new StringLtActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionSubtract.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionSubtract.java index b11fdafbb..53e26d44b 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionSubtract.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionSubtract.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.SubtractActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionSubtract extends Action { - - public ActionSubtract() { - super(0x0B, 0); - } - - @Override - public String toString() { - return "Subtract"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new SubtractActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.SubtractActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionSubtract extends Action { + + public ActionSubtract() { + super(0x0B, 0); + } + + @Override + public String toString() { + return "Subtract"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new SubtractActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionToInteger.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionToInteger.java index d135d0ebc..8bd46046c 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionToInteger.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionToInteger.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.ToIntegerActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionToInteger extends Action { - - public ActionToInteger() { - super(0x18, 0); - } - - @Override - public String toString() { - return "ToInteger"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - stack.push(new ToIntegerActionItem(this, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.ToIntegerActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionToInteger extends Action { + + public ActionToInteger() { + super(0x18, 0); + } + + @Override + public String toString() { + return "ToInteger"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + stack.push(new ToIntegerActionItem(this, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionTrace.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionTrace.java index f5efa7710..1616214d3 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionTrace.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionTrace.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf4; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.TraceActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionTrace extends Action { - - public ActionTrace() { - super(0x26, 0); - } - - @Override - public String toString() { - return "Trace"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem value = stack.pop(); - output.add(new TraceActionItem(this, value)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf4; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.TraceActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionTrace extends Action { + + public ActionTrace() { + super(0x26, 0); + } + + @Override + public String toString() { + return "Trace"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem value = stack.pop(); + output.add(new TraceActionItem(this, value)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java b/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java index d29fa6b53..33f6958fe 100644 --- a/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java +++ b/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java @@ -128,7 +128,7 @@ public class ActionWaitForFrame2 extends Action implements ActionStore { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) throws InterruptedException { + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) throws InterruptedException { GraphTargetItem frame = stack.pop(); List body = ActionGraph.translateViaGraph(regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path); output.add(new IfFrameLoadedActionItem(frame, body, this)); diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionAdd2.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionAdd2.java index 7d33637cf..af27cbbe9 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionAdd2.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionAdd2.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.AddActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionAdd2 extends Action { - - public ActionAdd2() { - super(0x47, 0); - } - - @Override - public String toString() { - return "Add2"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new AddActionItem(this, b, a, true)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.AddActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionAdd2 extends Action { + + public ActionAdd2() { + super(0x47, 0); + } + + @Override + public String toString() { + return "Add2"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new AddActionItem(this, b, a, true)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitAnd.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitAnd.java index ae40a01ab..5745e8766 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitAnd.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitAnd.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.BitAndActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionBitAnd extends Action { - - public ActionBitAnd() { - super(0x60, 0); - } - - @Override - public String toString() { - return "BitAnd"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new BitAndActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.BitAndActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionBitAnd extends Action { + + public ActionBitAnd() { + super(0x60, 0); + } + + @Override + public String toString() { + return "BitAnd"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new BitAndActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitLShift.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitLShift.java index 45f5d9768..d964ea1d1 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitLShift.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitLShift.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.LShiftActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionBitLShift extends Action { - - public ActionBitLShift() { - super(0x63, 0); - } - - @Override - public String toString() { - return "BitLShift"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new LShiftActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.LShiftActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionBitLShift extends Action { + + public ActionBitLShift() { + super(0x63, 0); + } + + @Override + public String toString() { + return "BitLShift"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new LShiftActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitOr.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitOr.java index 02b206757..bc37878f6 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitOr.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitOr.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.BitOrActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionBitOr extends Action { - - public ActionBitOr() { - super(0x61, 0); - } - - @Override - public String toString() { - return "BitOr"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new BitOrActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.BitOrActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionBitOr extends Action { + + public ActionBitOr() { + super(0x61, 0); + } + + @Override + public String toString() { + return "BitOr"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new BitOrActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitRShift.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitRShift.java index 534159899..a7bc9d623 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitRShift.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitRShift.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.RShiftActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionBitRShift extends Action { - - public ActionBitRShift() { - super(0x64, 0); - } - - @Override - public String toString() { - return "BitRShift"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new RShiftActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.RShiftActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionBitRShift extends Action { + + public ActionBitRShift() { + super(0x64, 0); + } + + @Override + public String toString() { + return "BitRShift"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new RShiftActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitURShift.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitURShift.java index eac6c81ce..c97ba68e2 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitURShift.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitURShift.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.URShiftActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionBitURShift extends Action { - - public ActionBitURShift() { - super(0x65, 0); - } - - @Override - public String toString() { - return "BitURShift"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new URShiftActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.URShiftActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionBitURShift extends Action { + + public ActionBitURShift() { + super(0x65, 0); + } + + @Override + public String toString() { + return "BitURShift"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new URShiftActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitXor.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitXor.java index 90bd3031f..afa02d6e3 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionBitXor.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionBitXor.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.BitXorActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionBitXor extends Action { - - public ActionBitXor() { - super(0x62, 0); - } - - @Override - public String toString() { - return "BitXor"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new BitXorActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.BitXorActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionBitXor extends Action { + + public ActionBitXor() { + super(0x62, 0); + } + + @Override + public String toString() { + return "BitXor"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new BitXorActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionCallFunction.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionCallFunction.java index f258fdf04..5fa0865aa 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionCallFunction.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionCallFunction.java @@ -1,51 +1,51 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.CallFunctionActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.model.LocalData; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionCallFunction extends Action { - - public ActionCallFunction() { - super(0x3D, 0); - } - - @Override - public String toString() { - return "CallFunction"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem functionName = stack.pop(); - long numArgs = popLong(stack); - List args = new ArrayList<>(); - for (long l = 0; l < numArgs; l++) { - args.add(stack.pop()); - } - CallFunctionActionItem cft = new CallFunctionActionItem(this, functionName, args); - cft.calculatedFunction = functions.get(functionName.toStringNoQuotes(LocalData.empty)); - stack.push(cft); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.CallFunctionActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.model.LocalData; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionCallFunction extends Action { + + public ActionCallFunction() { + super(0x3D, 0); + } + + @Override + public String toString() { + return "CallFunction"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem functionName = stack.pop(); + long numArgs = popLong(stack); + List args = new ArrayList<>(); + for (long l = 0; l < numArgs; l++) { + args.add(stack.pop()); + } + CallFunctionActionItem cft = new CallFunctionActionItem(this, functionName, args); + cft.calculatedFunction = functions.get(functionName.toStringNoQuotes(LocalData.empty)); + stack.push(cft); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionCallMethod.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionCallMethod.java index 082c60f87..ce242e360 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionCallMethod.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionCallMethod.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.CallMethodActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionCallMethod extends Action { - - public ActionCallMethod() { - super(0x52, 0); - } - - @Override - public String toString() { - return "CallMethod"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem methodName = stack.pop(); - GraphTargetItem scriptObject = stack.pop(); - long numArgs = popLong(stack); - List args = new ArrayList<>(); - for (long l = 0; l < numArgs; l++) { - args.add(stack.pop()); - } - stack.push(new CallMethodActionItem(this, scriptObject, methodName, args)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.CallMethodActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionCallMethod extends Action { + + public ActionCallMethod() { + super(0x52, 0); + } + + @Override + public String toString() { + return "CallMethod"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem methodName = stack.pop(); + GraphTargetItem scriptObject = stack.pop(); + long numArgs = popLong(stack); + List args = new ArrayList<>(); + for (long l = 0; l < numArgs; l++) { + args.add(stack.pop()); + } + stack.push(new CallMethodActionItem(this, scriptObject, methodName, args)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java index 9cd23e5bd..18df6997b 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionConstantPool.java @@ -90,6 +90,6 @@ public class ActionConstantPool extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { } } diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionDecrement.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionDecrement.java index 17d006fc1..89c74f2db 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionDecrement.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionDecrement.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.DecrementActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionDecrement extends Action { - - public ActionDecrement() { - super(0x51, 0); - } - - @Override - public String toString() { - return "Decrement"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - stack.push(new DecrementActionItem(this, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.DecrementActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionDecrement extends Action { + + public ActionDecrement() { + super(0x51, 0); + } + + @Override + public String toString() { + return "Decrement"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + stack.push(new DecrementActionItem(this, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal.java index 0e20b42a6..7055fd611 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal.java @@ -1,45 +1,45 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.DefineLocalActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import com.jpexs.decompiler.graph.model.LocalData; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionDefineLocal extends Action { - - public ActionDefineLocal() { - super(0x3C, 0); - } - - @Override - public String toString() { - return "DefineLocal"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem value = stack.pop(); - GraphTargetItem name = stack.pop(); - variables.put(name.toStringNoQuotes(LocalData.empty), value); - output.add(new DefineLocalActionItem(this, name, value)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.DefineLocalActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import com.jpexs.decompiler.graph.model.LocalData; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionDefineLocal extends Action { + + public ActionDefineLocal() { + super(0x3C, 0); + } + + @Override + public String toString() { + return "DefineLocal"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem value = stack.pop(); + GraphTargetItem name = stack.pop(); + variables.put(name.toStringNoQuotes(LocalData.empty), value); + output.add(new DefineLocalActionItem(this, name, value)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal2.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal2.java index a6646aa2b..c301ef54f 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal2.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal2.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.DefineLocalActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionDefineLocal2 extends Action { - - public ActionDefineLocal2() { - super(0x41, 0); - } - - @Override - public String toString() { - return "DefineLocal2"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem name = stack.pop(); - output.add(new DefineLocalActionItem(this, name, null)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.DefineLocalActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionDefineLocal2 extends Action { + + public ActionDefineLocal2() { + super(0x41, 0); + } + + @Override + public String toString() { + return "DefineLocal2"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem name = stack.pop(); + output.add(new DefineLocalActionItem(this, name, null)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete.java index a9f80a10f..e23ac10c1 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete.java @@ -1,44 +1,44 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.DeleteActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionDelete extends Action { - - public ActionDelete() { - super(0x3A, 0); - } - - @Override - public String toString() { - return "Delete"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem propertyName = stack.pop(); - GraphTargetItem object = stack.pop(); - - stack.push(new DeleteActionItem(this, object, propertyName)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.DeleteActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionDelete extends Action { + + public ActionDelete() { + super(0x3A, 0); + } + + @Override + public String toString() { + return "Delete"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem propertyName = stack.pop(); + GraphTargetItem object = stack.pop(); + + stack.push(new DeleteActionItem(this, object, propertyName)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete2.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete2.java index e7dd9ab3d..d3112d2bf 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete2.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete2.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.DeleteActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionDelete2 extends Action { - - public ActionDelete2() { - super(0x3B, 0); - } - - @Override - public String toString() { - return "Delete2"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem propertyName = stack.pop(); - - stack.push(new DeleteActionItem(this, null, propertyName)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.DeleteActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionDelete2 extends Action { + + public ActionDelete2() { + super(0x3B, 0); + } + + @Override + public String toString() { + return "Delete2"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem propertyName = stack.pop(); + + stack.push(new DeleteActionItem(this, null, propertyName)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionEnumerate.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionEnumerate.java index 622c9c174..e539d8ba7 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionEnumerate.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionEnumerate.java @@ -1,46 +1,46 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; -import com.jpexs.decompiler.flash.action.model.EnumerateActionItem; -import com.jpexs.decompiler.flash.ecma.Null; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionEnumerate extends Action { - - public ActionEnumerate() { - super(0x46, 0); - } - - @Override - public String toString() { - return "Enumerate"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem object = stack.pop(); - stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList())); - stack.push(new EnumerateActionItem(this, object)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.flash.action.model.EnumerateActionItem; +import com.jpexs.decompiler.flash.ecma.Null; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionEnumerate extends Action { + + public ActionEnumerate() { + super(0x46, 0); + } + + @Override + public String toString() { + return "Enumerate"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem object = stack.pop(); + stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList())); + stack.push(new EnumerateActionItem(this, object)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionEquals2.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionEquals2.java index 34f243e43..c84fb850d 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionEquals2.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionEquals2.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.EqActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionEquals2 extends Action { - - public ActionEquals2() { - super(0x49, 0); - } - - @Override - public String toString() { - return "Equals2"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new EqActionItem(this, b, a, true)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.EqActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionEquals2 extends Action { + + public ActionEquals2() { + super(0x49, 0); + } + + @Override + public String toString() { + return "Equals2"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new EqActionItem(this, b, a, true)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionGetMember.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionGetMember.java index 723774543..49866b85d 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionGetMember.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionGetMember.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.GetMemberActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionGetMember extends Action { - - public ActionGetMember() { - super(0x4E, 0); - } - - @Override - public String toString() { - return "GetMember"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem functionName = stack.pop(); - GraphTargetItem object = stack.pop(); - stack.push(new GetMemberActionItem(this, object, functionName)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.GetMemberActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionGetMember extends Action { + + public ActionGetMember() { + super(0x4E, 0); + } + + @Override + public String toString() { + return "GetMember"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem functionName = stack.pop(); + GraphTargetItem object = stack.pop(); + stack.push(new GetMemberActionItem(this, object, functionName)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionIncrement.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionIncrement.java index 252dfc6ab..de5d67a4e 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionIncrement.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionIncrement.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.IncrementActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionIncrement extends Action { - - public ActionIncrement() { - super(0x50, 0); - } - - @Override - public String toString() { - return "Increment"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - stack.push(new IncrementActionItem(this, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.IncrementActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionIncrement extends Action { + + public ActionIncrement() { + super(0x50, 0); + } + + @Override + public String toString() { + return "Increment"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + stack.push(new IncrementActionItem(this, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionInitArray.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionInitArray.java index b4961df50..c298a84e8 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionInitArray.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionInitArray.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.InitArrayActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionInitArray extends Action { - - public ActionInitArray() { - super(0x42, 0); - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - long numArgs = popLong(stack); - List args = new ArrayList<>(); - for (int l = 0; l < numArgs; l++) { - args.add(stack.pop()); - } - stack.push(new InitArrayActionItem(this, args)); - } - - @Override - public String toString() { - return "InitArray"; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.InitArrayActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionInitArray extends Action { + + public ActionInitArray() { + super(0x42, 0); + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + long numArgs = popLong(stack); + List args = new ArrayList<>(); + for (int l = 0; l < numArgs; l++) { + args.add(stack.pop()); + } + stack.push(new InitArrayActionItem(this, args)); + } + + @Override + public String toString() { + return "InitArray"; + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java index 3059e4564..36613cf2a 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.InitObjectActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionInitObject extends Action { - - public ActionInitObject() { - super(0x43, 0); - } - - @Override - public String toString() { - return "InitObject"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - long numArgs = popLong(stack); - List values = new ArrayList<>(); - List names = new ArrayList<>(); - for (long l = 0; l < numArgs; l++) { - values.add(stack.pop()); - names.add(stack.pop()); - } - stack.push(new InitObjectActionItem(this, names, values)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.InitObjectActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionInitObject extends Action { + + public ActionInitObject() { + super(0x43, 0); + } + + @Override + public String toString() { + return "InitObject"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + long numArgs = popLong(stack); + List values = new ArrayList<>(); + List names = new ArrayList<>(); + for (long l = 0; l < numArgs; l++) { + values.add(stack.pop()); + names.add(stack.pop()); + } + stack.push(new InitObjectActionItem(this, names, values)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionLess2.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionLess2.java index a213f8e6d..41767dae7 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionLess2.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionLess2.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.LtActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionLess2 extends Action { - - public ActionLess2() { - super(0x48, 0); - } - - @Override - public String toString() { - return "Less2"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new LtActionItem(this, b, a, true)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.LtActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionLess2 extends Action { + + public ActionLess2() { + super(0x48, 0); + } + + @Override + public String toString() { + return "Less2"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new LtActionItem(this, b, a, true)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionModulo.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionModulo.java index 5c6264919..5c982679d 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionModulo.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionModulo.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.ModuloActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionModulo extends Action { - - public ActionModulo() { - super(0x3F, 0); - } - - @Override - public String toString() { - return "Modulo"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new ModuloActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.ModuloActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionModulo extends Action { + + public ActionModulo() { + super(0x3F, 0); + } + + @Override + public String toString() { + return "Modulo"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new ModuloActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionNewMethod.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionNewMethod.java index dbcd997c6..917e82343 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionNewMethod.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionNewMethod.java @@ -1,49 +1,49 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.NewMethodActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionNewMethod extends Action { - - public ActionNewMethod() { - super(0x53, 0); - } - - @Override - public String toString() { - return "NewMethod"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem methodName = stack.pop(); - GraphTargetItem scriptObject = stack.pop(); - long numArgs = popLong(stack); - List args = new ArrayList<>(); - for (long l = 0; l < numArgs; l++) { - args.add(stack.pop()); - } - stack.push(new NewMethodActionItem(this, scriptObject, methodName, args)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.NewMethodActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionNewMethod extends Action { + + public ActionNewMethod() { + super(0x53, 0); + } + + @Override + public String toString() { + return "NewMethod"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem methodName = stack.pop(); + GraphTargetItem scriptObject = stack.pop(); + long numArgs = popLong(stack); + List args = new ArrayList<>(); + for (long l = 0; l < numArgs; l++) { + args.add(stack.pop()); + } + stack.push(new NewMethodActionItem(this, scriptObject, methodName, args)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java index f18ce09d7..fee61c908 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java @@ -1,48 +1,48 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.NewObjectActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionNewObject extends Action { - - public ActionNewObject() { - super(0x40, 0); - } - - @Override - public String toString() { - return "NewObject"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem objectName = stack.pop(); - long numArgs = popLong(stack); - List args = new ArrayList<>(); - for (long l = 0; l < numArgs; l++) { - args.add(stack.pop()); - } - stack.push(new NewObjectActionItem(this, objectName, args)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.NewObjectActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionNewObject extends Action { + + public ActionNewObject() { + super(0x40, 0); + } + + @Override + public String toString() { + return "NewObject"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem objectName = stack.pop(); + long numArgs = popLong(stack); + List args = new ArrayList<>(); + for (long l = 0; l < numArgs; l++) { + args.add(stack.pop()); + } + stack.push(new NewObjectActionItem(this, objectName, args)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionPushDuplicate.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionPushDuplicate.java index 3f6854992..2e429d695 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionPushDuplicate.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionPushDuplicate.java @@ -1,44 +1,44 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.graph.GraphSourceItemPos; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionPushDuplicate extends Action { - - public ActionPushDuplicate() { - super(0x4C, 0); - } - - @Override - public String toString() { - return "PushDuplicate"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem value = stack.pop(); - stack.push(value); - stack.push(value); - value.moreSrc.add(new GraphSourceItemPos(this, 0)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.graph.GraphSourceItemPos; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionPushDuplicate extends Action { + + public ActionPushDuplicate() { + super(0x4C, 0); + } + + @Override + public String toString() { + return "PushDuplicate"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem value = stack.pop(); + stack.push(value); + stack.push(value); + value.moreSrc.add(new GraphSourceItemPos(this, 0)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionReturn.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionReturn.java index 8f26368ad..b642bc2e4 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionReturn.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionReturn.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.ReturnActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionReturn extends Action { - - public ActionReturn() { - super(0x3E, 0); - } - - @Override - public String toString() { - return "Return"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem value = stack.pop(); - output.add(new ReturnActionItem(this, value)); - } - - @Override - public boolean isExit() { - return true; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.ReturnActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionReturn extends Action { + + public ActionReturn() { + super(0x3E, 0); + } + + @Override + public String toString() { + return "Return"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem value = stack.pop(); + output.add(new ReturnActionItem(this, value)); + } + + @Override + public boolean isExit() { + return true; + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java index e24385b0b..b2864a81f 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java @@ -1,120 +1,120 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.DecrementActionItem; -import com.jpexs.decompiler.flash.action.model.GetMemberActionItem; -import com.jpexs.decompiler.flash.action.model.IncrementActionItem; -import com.jpexs.decompiler.flash.action.model.PostDecrementActionItem; -import com.jpexs.decompiler.flash.action.model.PostIncrementActionItem; -import com.jpexs.decompiler.flash.action.model.SetMemberActionItem; -import com.jpexs.decompiler.flash.action.model.StoreRegisterActionItem; -import com.jpexs.decompiler.flash.action.model.TemporaryRegister; -import com.jpexs.decompiler.flash.action.model.operations.PreDecrementActionItem; -import com.jpexs.decompiler.flash.action.model.operations.PreIncrementActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionSetMember extends Action { - - public ActionSetMember() { - super(0x4F, 0); - } - - @Override - public String toString() { - return "SetMember"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem value = stack.pop().getThroughDuplicate(); - GraphTargetItem memberName = stack.pop(); - GraphTargetItem object = stack.pop(); - if (value instanceof IncrementActionItem) { - GraphTargetItem obj = ((IncrementActionItem) value).object; - if (!stack.isEmpty()) { - if (stack.peek().valueEquals(obj)) { - stack.pop(); - stack.push(new PostIncrementActionItem(this, obj)); - return; - } - } - } - if (value instanceof DecrementActionItem) { - GraphTargetItem obj = ((DecrementActionItem) value).object; - if (!stack.isEmpty()) { - if (stack.peek().valueEquals(obj)) { - stack.pop(); - stack.push(new PostDecrementActionItem(this, obj)); - return; - } - } - } - - if (value instanceof IncrementActionItem) { - if (((IncrementActionItem) value).object instanceof GetMemberActionItem) { - if (((GetMemberActionItem) ((IncrementActionItem) value).object).object.equals(object)) { - if (((GetMemberActionItem) ((IncrementActionItem) value).object).memberName.equals(memberName)) { - output.add(new PostIncrementActionItem(this, ((IncrementActionItem) value).object)); - return; - } - } - } - } - if (value instanceof DecrementActionItem) { - if (((DecrementActionItem) value).object instanceof GetMemberActionItem) { - if (((GetMemberActionItem) ((DecrementActionItem) value).object).object.valueEquals(object)) { - if (((GetMemberActionItem) ((DecrementActionItem) value).object).memberName.equals(memberName)) { - output.add(new PostDecrementActionItem(this, ((DecrementActionItem) value).object)); - return; - } - } - } - } - GraphTargetItem ret = new SetMemberActionItem(this, object, memberName, value); - if (value instanceof StoreRegisterActionItem) { - StoreRegisterActionItem sr = (StoreRegisterActionItem) value; - if (sr.define) { - value = sr.getValue(); - ((SetMemberActionItem) ret).setValue(value); - if (value instanceof IncrementActionItem) { - if (((IncrementActionItem) value).object instanceof GetMemberActionItem) { - if (((GetMemberActionItem) ((IncrementActionItem) value).object).valueEquals(((SetMemberActionItem) ret).getObject())) { - ret = new PreIncrementActionItem(this, ((IncrementActionItem) value).object); - } - } - } else if (value instanceof DecrementActionItem) { - if (((DecrementActionItem) value).object instanceof GetMemberActionItem) { - if (((GetMemberActionItem) ((DecrementActionItem) value).object).valueEquals(((SetMemberActionItem) ret).getObject())) { - ret = new PreDecrementActionItem(this, ((DecrementActionItem) value).object); - } - } - } else { - sr.temporary = true; - ((SetMemberActionItem) ret).setValue(sr); - } - variables.put("__register" + sr.register.number, new TemporaryRegister(sr.register.number, ret)); - return; - } - } - output.add(ret); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.DecrementActionItem; +import com.jpexs.decompiler.flash.action.model.GetMemberActionItem; +import com.jpexs.decompiler.flash.action.model.IncrementActionItem; +import com.jpexs.decompiler.flash.action.model.PostDecrementActionItem; +import com.jpexs.decompiler.flash.action.model.PostIncrementActionItem; +import com.jpexs.decompiler.flash.action.model.SetMemberActionItem; +import com.jpexs.decompiler.flash.action.model.StoreRegisterActionItem; +import com.jpexs.decompiler.flash.action.model.TemporaryRegister; +import com.jpexs.decompiler.flash.action.model.operations.PreDecrementActionItem; +import com.jpexs.decompiler.flash.action.model.operations.PreIncrementActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionSetMember extends Action { + + public ActionSetMember() { + super(0x4F, 0); + } + + @Override + public String toString() { + return "SetMember"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem value = stack.pop().getThroughDuplicate(); + GraphTargetItem memberName = stack.pop(); + GraphTargetItem object = stack.pop(); + if (value instanceof IncrementActionItem) { + GraphTargetItem obj = ((IncrementActionItem) value).object; + if (!stack.isEmpty()) { + if (stack.peek().valueEquals(obj)) { + stack.pop(); + stack.push(new PostIncrementActionItem(this, obj)); + return; + } + } + } + if (value instanceof DecrementActionItem) { + GraphTargetItem obj = ((DecrementActionItem) value).object; + if (!stack.isEmpty()) { + if (stack.peek().valueEquals(obj)) { + stack.pop(); + stack.push(new PostDecrementActionItem(this, obj)); + return; + } + } + } + + if (value instanceof IncrementActionItem) { + if (((IncrementActionItem) value).object instanceof GetMemberActionItem) { + if (((GetMemberActionItem) ((IncrementActionItem) value).object).object.equals(object)) { + if (((GetMemberActionItem) ((IncrementActionItem) value).object).memberName.equals(memberName)) { + output.add(new PostIncrementActionItem(this, ((IncrementActionItem) value).object)); + return; + } + } + } + } + if (value instanceof DecrementActionItem) { + if (((DecrementActionItem) value).object instanceof GetMemberActionItem) { + if (((GetMemberActionItem) ((DecrementActionItem) value).object).object.valueEquals(object)) { + if (((GetMemberActionItem) ((DecrementActionItem) value).object).memberName.equals(memberName)) { + output.add(new PostDecrementActionItem(this, ((DecrementActionItem) value).object)); + return; + } + } + } + } + GraphTargetItem ret = new SetMemberActionItem(this, object, memberName, value); + if (value instanceof StoreRegisterActionItem) { + StoreRegisterActionItem sr = (StoreRegisterActionItem) value; + if (sr.define) { + value = sr.getValue(); + ((SetMemberActionItem) ret).setValue(value); + if (value instanceof IncrementActionItem) { + if (((IncrementActionItem) value).object instanceof GetMemberActionItem) { + if (((GetMemberActionItem) ((IncrementActionItem) value).object).valueEquals(((SetMemberActionItem) ret).getObject())) { + ret = new PreIncrementActionItem(this, ((IncrementActionItem) value).object); + } + } + } else if (value instanceof DecrementActionItem) { + if (((DecrementActionItem) value).object instanceof GetMemberActionItem) { + if (((GetMemberActionItem) ((DecrementActionItem) value).object).valueEquals(((SetMemberActionItem) ret).getObject())) { + ret = new PreDecrementActionItem(this, ((DecrementActionItem) value).object); + } + } + } else { + sr.temporary = true; + ((SetMemberActionItem) ret).setValue(sr); + } + variables.put("__register" + sr.register.number, new TemporaryRegister(sr.register.number, ret)); + return; + } + } + output.add(ret); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionStackSwap.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionStackSwap.java index b2eb39166..d1a5bb2cf 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionStackSwap.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionStackSwap.java @@ -1,46 +1,46 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.graph.GraphSourceItemPos; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionStackSwap extends Action { - - public ActionStackSwap() { - super(0x4D, 0); - } - - @Override - public String toString() { - return "StackSwap"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(a); - stack.push(b); - a.moreSrc.add(new GraphSourceItemPos(this, 0)); - b.moreSrc.add(new GraphSourceItemPos(this, 0)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.graph.GraphSourceItemPos; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionStackSwap extends Action { + + public ActionStackSwap() { + super(0x4D, 0); + } + + @Override + public String toString() { + return "StackSwap"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(a); + stack.push(b); + a.moreSrc.add(new GraphSourceItemPos(this, 0)); + b.moreSrc.add(new GraphSourceItemPos(this, 0)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java index 23af6ebb9..ffedde4de 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java @@ -76,7 +76,7 @@ public class ActionStoreRegister extends Action implements StoreTypeAction { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem value = stack.pop(); RegisterNumber rn = new RegisterNumber(registerNumber); if (regNames.containsKey(registerNumber)) { diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionTargetPath.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionTargetPath.java index 19e01a1bd..4f9818ed7 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionTargetPath.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionTargetPath.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.TargetPathActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionTargetPath extends Action { - - public ActionTargetPath() { - super(0x45, 0); - } - - @Override - public String toString() { - return "TargetPath"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem object = stack.pop(); - stack.push(new TargetPathActionItem(this, object)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.TargetPathActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionTargetPath extends Action { + + public ActionTargetPath() { + super(0x45, 0); + } + + @Override + public String toString() { + return "TargetPath"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem object = stack.pop(); + stack.push(new TargetPathActionItem(this, object)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionToNumber.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionToNumber.java index 1671cc1a8..484876423 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionToNumber.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionToNumber.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.ToNumberActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionToNumber extends Action { - - public ActionToNumber() { - super(0x4A, 0); - } - - @Override - public String toString() { - return "ToNumber"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem object = stack.pop(); - stack.push(new ToNumberActionItem(this, object)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.ToNumberActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionToNumber extends Action { + + public ActionToNumber() { + super(0x4A, 0); + } + + @Override + public String toString() { + return "ToNumber"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem object = stack.pop(); + stack.push(new ToNumberActionItem(this, object)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionToString.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionToString.java index f72580c87..bd8045f0b 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionToString.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionToString.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.ToStringActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionToString extends Action { - - public ActionToString() { - super(0x4B, 0); - } - - @Override - public String toString() { - return "ToString"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem object = stack.pop(); - stack.push(new ToStringActionItem(this, object)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.ToStringActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionToString extends Action { + + public ActionToString() { + super(0x4B, 0); + } + + @Override + public String toString() { + return "ToString"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem object = stack.pop(); + stack.push(new ToStringActionItem(this, object)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf5/ActionTypeOf.java b/src/com/jpexs/decompiler/flash/action/swf5/ActionTypeOf.java index b67803573..a0a00a11e 100644 --- a/src/com/jpexs/decompiler/flash/action/swf5/ActionTypeOf.java +++ b/src/com/jpexs/decompiler/flash/action/swf5/ActionTypeOf.java @@ -1,42 +1,42 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf5; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.TypeOfActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionTypeOf extends Action { - - public ActionTypeOf() { - super(0x44, 0); - } - - @Override - public String toString() { - return "TypeOf"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem object = stack.pop(); - stack.push(new TypeOfActionItem(this, object)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf5; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.TypeOfActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionTypeOf extends Action { + + public ActionTypeOf() { + super(0x44, 0); + } + + @Override + public String toString() { + return "TypeOf"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem object = stack.pop(); + stack.push(new TypeOfActionItem(this, object)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf6/ActionEnumerate2.java b/src/com/jpexs/decompiler/flash/action/swf6/ActionEnumerate2.java index f588f8da7..e98dbea05 100644 --- a/src/com/jpexs/decompiler/flash/action/swf6/ActionEnumerate2.java +++ b/src/com/jpexs/decompiler/flash/action/swf6/ActionEnumerate2.java @@ -1,46 +1,46 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf6; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; -import com.jpexs.decompiler.flash.action.model.EnumerateActionItem; -import com.jpexs.decompiler.flash.ecma.Null; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionEnumerate2 extends Action { - - public ActionEnumerate2() { - super(0x55, 0); - } - - @Override - public String toString() { - return "Enumerate2"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem object = stack.pop(); - stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList())); - stack.push(new EnumerateActionItem(this, object)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf6; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; +import com.jpexs.decompiler.flash.action.model.EnumerateActionItem; +import com.jpexs.decompiler.flash.ecma.Null; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionEnumerate2 extends Action { + + public ActionEnumerate2() { + super(0x55, 0); + } + + @Override + public String toString() { + return "Enumerate2"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem object = stack.pop(); + stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList())); + stack.push(new EnumerateActionItem(this, object)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf6/ActionGreater.java b/src/com/jpexs/decompiler/flash/action/swf6/ActionGreater.java index 1fcdd0359..e889bfedf 100644 --- a/src/com/jpexs/decompiler/flash/action/swf6/ActionGreater.java +++ b/src/com/jpexs/decompiler/flash/action/swf6/ActionGreater.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf6; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.GtActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionGreater extends Action { - - public ActionGreater() { - super(0x67, 0); - } - - @Override - public String toString() { - return "Greater"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new GtActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf6; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.GtActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionGreater extends Action { + + public ActionGreater() { + super(0x67, 0); + } + + @Override + public String toString() { + return "Greater"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new GtActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf6/ActionInstanceOf.java b/src/com/jpexs/decompiler/flash/action/swf6/ActionInstanceOf.java index 449c5f481..4c359d85b 100644 --- a/src/com/jpexs/decompiler/flash/action/swf6/ActionInstanceOf.java +++ b/src/com/jpexs/decompiler/flash/action/swf6/ActionInstanceOf.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf6; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.InstanceOfActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionInstanceOf extends Action { - - public ActionInstanceOf() { - super(0x54, 0); - } - - @Override - public String toString() { - return "InstanceOf"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new InstanceOfActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf6; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.InstanceOfActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionInstanceOf extends Action { + + public ActionInstanceOf() { + super(0x54, 0); + } + + @Override + public String toString() { + return "InstanceOf"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new InstanceOfActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf6/ActionStrictEquals.java b/src/com/jpexs/decompiler/flash/action/swf6/ActionStrictEquals.java index c9ec1b102..bbe18998b 100644 --- a/src/com/jpexs/decompiler/flash/action/swf6/ActionStrictEquals.java +++ b/src/com/jpexs/decompiler/flash/action/swf6/ActionStrictEquals.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf6; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.operations.StrictEqActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionStrictEquals extends Action { - - public ActionStrictEquals() { - super(0x66, 0); - } - - @Override - public String toString() { - return "StrictEquals"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem a = stack.pop(); - GraphTargetItem b = stack.pop(); - stack.push(new StrictEqActionItem(this, b, a)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf6; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.operations.StrictEqActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionStrictEquals extends Action { + + public ActionStrictEquals() { + super(0x66, 0); + } + + @Override + public String toString() { + return "StrictEquals"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem a = stack.pop(); + GraphTargetItem b = stack.pop(); + stack.push(new StrictEqActionItem(this, b, a)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java b/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java index 2c8ce0033..285807605 100644 --- a/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java +++ b/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java @@ -35,7 +35,7 @@ public class ActionStringGreater extends Action { } @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { GraphTargetItem a = stack.pop(); GraphTargetItem b = stack.pop(); stack.push(new StringGtActionItem(this, b, a)); diff --git a/src/com/jpexs/decompiler/flash/action/swf7/ActionCastOp.java b/src/com/jpexs/decompiler/flash/action/swf7/ActionCastOp.java index c4146d808..7d983d311 100644 --- a/src/com/jpexs/decompiler/flash/action/swf7/ActionCastOp.java +++ b/src/com/jpexs/decompiler/flash/action/swf7/ActionCastOp.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf7; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.CastOpActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionCastOp extends Action { - - public ActionCastOp() { - super(0x2B, 0); - } - - @Override - public String toString() { - return "CastOp"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem object = stack.pop(); - GraphTargetItem constructor = stack.pop(); - stack.push(new CastOpActionItem(this, constructor, object)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf7; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.CastOpActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionCastOp extends Action { + + public ActionCastOp() { + super(0x2B, 0); + } + + @Override + public String toString() { + return "CastOp"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem object = stack.pop(); + GraphTargetItem constructor = stack.pop(); + stack.push(new CastOpActionItem(this, constructor, object)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf7/ActionExtends.java b/src/com/jpexs/decompiler/flash/action/swf7/ActionExtends.java index d01ae0bd1..446565c8a 100644 --- a/src/com/jpexs/decompiler/flash/action/swf7/ActionExtends.java +++ b/src/com/jpexs/decompiler/flash/action/swf7/ActionExtends.java @@ -1,43 +1,43 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf7; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.ExtendsActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionExtends extends Action { - - public ActionExtends() { - super(0x69, 0); - } - - @Override - public String toString() { - return "Extends"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem superclass = stack.pop(); - GraphTargetItem subclass = stack.pop(); - output.add(new ExtendsActionItem(this, subclass, superclass)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf7; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.ExtendsActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionExtends extends Action { + + public ActionExtends() { + super(0x69, 0); + } + + @Override + public String toString() { + return "Extends"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem superclass = stack.pop(); + GraphTargetItem subclass = stack.pop(); + output.add(new ExtendsActionItem(this, subclass, superclass)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf7/ActionImplementsOp.java b/src/com/jpexs/decompiler/flash/action/swf7/ActionImplementsOp.java index 79343e2b4..1127050f4 100644 --- a/src/com/jpexs/decompiler/flash/action/swf7/ActionImplementsOp.java +++ b/src/com/jpexs/decompiler/flash/action/swf7/ActionImplementsOp.java @@ -1,48 +1,48 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf7; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.ImplementsOpActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionImplementsOp extends Action { - - public ActionImplementsOp() { - super(0x2C, 0); - } - - @Override - public String toString() { - return "ImplementsOp"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem subclass = stack.pop(); - long inCount = popLong(stack); - List superclasses = new ArrayList<>(); - for (long l = 0; l < inCount; l++) { - superclasses.add(stack.pop()); - } - output.add(new ImplementsOpActionItem(this, subclass, superclasses)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf7; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.ImplementsOpActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionImplementsOp extends Action { + + public ActionImplementsOp() { + super(0x2C, 0); + } + + @Override + public String toString() { + return "ImplementsOp"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem subclass = stack.pop(); + long inCount = popLong(stack); + List superclasses = new ArrayList<>(); + for (long l = 0; l < inCount; l++) { + superclasses.add(stack.pop()); + } + output.add(new ImplementsOpActionItem(this, subclass, superclasses)); + } +} diff --git a/src/com/jpexs/decompiler/flash/action/swf7/ActionThrow.java b/src/com/jpexs/decompiler/flash/action/swf7/ActionThrow.java index b6cd381fa..ad3e3d4a5 100644 --- a/src/com/jpexs/decompiler/flash/action/swf7/ActionThrow.java +++ b/src/com/jpexs/decompiler/flash/action/swf7/ActionThrow.java @@ -1,47 +1,47 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.action.swf7; - -import com.jpexs.decompiler.flash.action.Action; -import com.jpexs.decompiler.flash.action.model.ThrowActionItem; -import com.jpexs.decompiler.graph.GraphTargetItem; -import java.util.HashMap; -import java.util.List; -import java.util.Stack; - -public class ActionThrow extends Action { - - public ActionThrow() { - super(0x2A, 0); - } - - @Override - public String toString() { - return "Throw"; - } - - @Override - public void translate(Stack stack, List output, java.util.HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { - GraphTargetItem object = stack.pop(); - output.add(new ThrowActionItem(this, object)); - } - - @Override - public boolean isExit() { - return true; - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.action.swf7; + +import com.jpexs.decompiler.flash.action.Action; +import com.jpexs.decompiler.flash.action.model.ThrowActionItem; +import com.jpexs.decompiler.graph.GraphTargetItem; +import java.util.HashMap; +import java.util.List; +import java.util.Stack; + +public class ActionThrow extends Action { + + public ActionThrow() { + super(0x2A, 0); + } + + @Override + public String toString() { + return "Throw"; + } + + @Override + public void translate(Stack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { + GraphTargetItem object = stack.pop(); + output.add(new ThrowActionItem(this, object)); + } + + @Override + public boolean isExit() { + return true; + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index a698d8a27..fbd4a0c1a 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -383,7 +383,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec cl2.show(detailPanel, DETAILCARDEMPTYPANEL); UIManager.getDefaults().put("TreeUI", BasicTreeUI.class.getName()); - tagTree = new TagTree((TagTreeModel) null, this); + tagTree = new TagTree(null, this); tagTree.addTreeSelectionListener(this); DragSource dragSource = DragSource.getDefaultDragSource(); @@ -467,7 +467,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec tagTree.createContextMenu(swfs); - dumpTree = new DumpTree((DumpTreeModel) null, this); + dumpTree = new DumpTree(null, this); dumpTree.addTreeSelectionListener(this); dumpTree.createContextMenu(); diff --git a/src/com/jpexs/decompiler/flash/gui/QuickFindPanel.java b/src/com/jpexs/decompiler/flash/gui/QuickFindPanel.java index 5c41ea3be..948de4e7a 100644 --- a/src/com/jpexs/decompiler/flash/gui/QuickFindPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/QuickFindPanel.java @@ -165,7 +165,7 @@ public class QuickFindPanel extends JPanel implements ActionListener, jsyntaxpan @Override public void showQuickFind(final JTextComponent t, DocumentSearchData ds) { - dsd = new WeakReference(ds); + dsd = new WeakReference<>(ds); oldCaretPosition = t.getCaretPosition(); Container view = t.getParent(); Dimension wd = getSize(); diff --git a/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java b/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java index e9527330b..6fe32a88a 100644 --- a/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java +++ b/src/com/jpexs/decompiler/flash/gui/TagTreeModel.java @@ -336,21 +336,20 @@ public class TagTreeModel implements TreeModel { return newPath; } } - if (n instanceof TreeNode) { - TreeNode nd = (TreeNode) n; - if (obj instanceof StringItem && nd.getItem() instanceof StringItem) { - // StringItems are always recreated, so compare them by name - StringItem nds = (StringItem) nd.getItem(); - StringItem objs = (StringItem) obj; - if (objs.getName().equals(nds.getName())) { - return newPath; - } - } else { - if (nd.getItem() == obj) { - return newPath; - } + + if (obj instanceof StringItem && n.getItem() instanceof StringItem) { + // StringItems are always recreated, so compare them by name + StringItem nds = (StringItem) n.getItem(); + StringItem objs = (StringItem) obj; + if (objs.getName().equals(nds.getName())) { + return newPath; + } + } else { + if (n.getItem() == obj) { + return newPath; } } + ret = searchTag(obj, n, newPath); if (ret != null) { return ret; diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java index 831e804f6..5439ba10f 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java @@ -62,7 +62,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL private final Cache cache = Cache.getInstance(true); private Trait currentTrait = null; - private final List scriptListeners = new ArrayList(); + private final List scriptListeners = new ArrayList<>(); public void addScriptListener(Runnable l) { scriptListeners.add(l); diff --git a/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java b/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java index 182be5672..5d1305b17 100644 --- a/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java +++ b/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java @@ -1,424 +1,424 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.decompiler.flash.gui.proxy; - -import com.jpexs.decompiler.flash.configuration.Configuration; -import com.jpexs.decompiler.flash.gui.AppFrame; -import com.jpexs.decompiler.flash.gui.Main; -import com.jpexs.decompiler.flash.gui.MainFrame; -import com.jpexs.decompiler.flash.gui.View; -import com.jpexs.proxy.CatchedListener; -import com.jpexs.proxy.ReplacedListener; -import com.jpexs.proxy.Replacement; -import com.jpexs.proxy.Server; -import java.awt.BorderLayout; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.Image; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextField; - -/** - * Frame with Proxy - * - * @author JPEXS - */ -public class ProxyFrame extends AppFrame implements ActionListener, CatchedListener, MouseListener, ReplacedListener { - - static final String ACTION_SWITCH_STATE = "SWITCHSTATE"; - static final String ACTION_OPEN = "OPEN"; - static final String ACTION_CLEAR = "CLEAR"; - static final String ACTION_RENAME = "RENAME"; - static final String ACTION_REMOVE = "REMOVE"; - - private MainFrame mainFrame; - private JList swfList; - private SWFListModel listModel; - private JButton switchButton = new JButton(translate("proxy.start")); - private boolean started = false; - private JTextField portField = new JTextField("55555"); - private JCheckBox sniffSWFCheckBox = new JCheckBox("SWF", false); - private JCheckBox sniffOSCheckBox = new JCheckBox("OctetStream", false); - private JCheckBox sniffJSCheckBox = new JCheckBox("JS", false); - private JCheckBox sniffXMLCheckBox = new JCheckBox("XML", false); - - /** - * Is server running - * - * @return True when running - */ - public boolean isRunning() { - return started; - } - - /** - * Sets port for the proxy - * - * @param port Port number - */ - public void setPort(int port) { - portField.setText("" + port); - } - - /** - * Constructor - * - * @param mainFrame - */ - public ProxyFrame(final MainFrame mainFrame) { - - this.mainFrame = mainFrame; - listModel = new SWFListModel(Configuration.getReplacements()); - swfList = new JList<>(listModel); - swfList.addMouseListener(this); - swfList.setFont(new Font("Monospaced", Font.PLAIN, 12)); - switchButton.addActionListener(this); - switchButton.setActionCommand(ACTION_SWITCH_STATE); - Container cnt = getContentPane(); - cnt.setLayout(new BorderLayout()); - cnt.add(new JScrollPane(swfList), BorderLayout.CENTER); - - portField.setPreferredSize(new Dimension(80, portField.getPreferredSize().height)); - JPanel buttonsPanel = new JPanel(); - buttonsPanel.setLayout(new FlowLayout()); - buttonsPanel.add(new JLabel(translate("port"))); - buttonsPanel.add(portField); - buttonsPanel.add(switchButton); - cnt.add(buttonsPanel, BorderLayout.NORTH); - - JPanel buttonsPanel23 = new JPanel(); - buttonsPanel23.setLayout(new BoxLayout(buttonsPanel23, BoxLayout.Y_AXIS)); - - JPanel buttonsPanel2 = new JPanel(); - buttonsPanel2.setLayout(new FlowLayout()); - JButton openButton = new JButton(translate("open")); - openButton.setActionCommand(ACTION_OPEN); - openButton.addActionListener(this); - buttonsPanel2.add(openButton); - JButton clearButton = new JButton(translate("clear")); - clearButton.setActionCommand(ACTION_CLEAR); - clearButton.addActionListener(this); - buttonsPanel2.add(clearButton); - JButton renameButton = new JButton(translate("rename")); - renameButton.setActionCommand(ACTION_RENAME); - renameButton.addActionListener(this); - buttonsPanel2.add(renameButton); - JButton removeButton = new JButton(translate("remove")); - removeButton.setActionCommand(ACTION_REMOVE); - removeButton.addActionListener(this); - buttonsPanel2.add(removeButton); - - JPanel buttonsPanel3 = new JPanel(); - buttonsPanel3.setLayout(new FlowLayout()); - buttonsPanel3.add(new JLabel(translate("sniff"))); - buttonsPanel3.add(sniffSWFCheckBox); - buttonsPanel3.add(sniffOSCheckBox); - //buttonsPanel3.add(sniffJSCheckBox); - //buttonsPanel3.add(sniffXMLCheckBox); - - buttonsPanel23.add(buttonsPanel2); - buttonsPanel23.add(buttonsPanel3); - - cnt.add(buttonsPanel23, BorderLayout.SOUTH); - setSize(400, 300); - View.centerScreen(this); - View.setWindowIcon(this); - setTitle(translate("dialog.title")); - this.addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - setVisible(false); - Main.removeTrayIcon(); - if (mainFrame != null) { - if (mainFrame.isVisible()) { - return; - } - } - Main.showModeFrame(); - } - - /** - * Invoked when a window is iconified. - */ - @Override - public void windowIconified(WindowEvent e) { - setVisible(false); - } - }); - java.util.List images = new ArrayList<>(); - images.add(View.loadImage("proxy16")); - images.add(View.loadImage("proxy32")); - setIconImages(images); - } - - private void open() { - if (swfList.getSelectedIndex() > -1) { - Replacement r = (Replacement) listModel.getElementAt(swfList.getSelectedIndex()); - Main.openFile(r.targetFile, r.urlPattern); - } - } - - /** - * Method handling actions from buttons - * - * @param e event - */ - @Override - public void actionPerformed(ActionEvent e) { - switch (e.getActionCommand()) { - case ACTION_OPEN: - open(); - break; - case ACTION_RENAME: - if (swfList.getSelectedIndex() > -1) { - Replacement r = (Replacement) listModel.getElementAt(swfList.getSelectedIndex()); - String s = View.showInputDialog("URL", r.urlPattern); - r.urlPattern = s; - listModel.dataChanged(swfList.getSelectedIndex()); - } - break; - case ACTION_CLEAR: - for (int i = 0; i < listModel.getSize(); i++) { - Replacement r = (Replacement) listModel.getElementAt(i); - File f; - try { - f = (new File(Main.tempFile(r.targetFile))); - if (f.exists()) { - f.delete(); - } - } catch (IOException ex) { - Logger.getLogger(ProxyFrame.class.getName()).log(Level.SEVERE, null, ex); - } - - } - listModel.clear(); - break; - case ACTION_REMOVE: - int lastIndex = -1; - for (int k = listModel.getSize() - 1; k >= 0; k--) { - if (swfList.isSelectedIndex(k)) { - Replacement r = listModel.removeURL(k); - File f = (new File(r.targetFile)); - if (f.exists()) { - f.delete(); - } - lastIndex = k; - } - } - if (lastIndex >= listModel.getSize()) { - lastIndex--; - } - if (lastIndex > -1) { - swfList.setSelectedIndex(lastIndex); - } - break; - case ACTION_SWITCH_STATE: - Main.switchProxy(); - break; - } - } - - /** - * Switch proxy state - */ - public void switchState() { - started = !started; - if (started) { - int port = 0; - try { - port = Integer.parseInt(portField.getText()); - } catch (NumberFormatException nfe) { - } - if ((port <= 0) || (port > 65535)) { - View.showMessageDialog(this, translate("error.port"), translate("error"), JOptionPane.ERROR_MESSAGE); - started = false; - return; - } - java.util.List catchedContentTypes = new ArrayList<>(); - catchedContentTypes.add("application/x-shockwave-flash"); - catchedContentTypes.add("application/x-javascript"); - catchedContentTypes.add("application/javascript"); - catchedContentTypes.add("text/javascript"); - catchedContentTypes.add("application/json"); - catchedContentTypes.add("text/xml"); - catchedContentTypes.add("application/xml"); - catchedContentTypes.add("application/octet-stream"); - Server.startServer(port, Configuration.getReplacements(), catchedContentTypes, this, this); - switchButton.setText(translate("proxy.stop")); - portField.setEditable(false); - } else { - Server.stopServer(); - switchButton.setText(translate("proxy.start")); - portField.setEditable(true); - } - } - - /** - * Mouse clicked event - * - * @param e event - */ - @Override - public void mouseClicked(MouseEvent e) { - if (e.getSource() == swfList) { - if (e.getClickCount() == 2) { - open(); - } - } - } - - /** - * Mouse pressed event - * - * @param e event - */ - @Override - public void mousePressed(MouseEvent e) { - } - - /** - * Mouse released event - * - * @param e event - */ - @Override - public void mouseReleased(MouseEvent e) { - } - - /** - * Mouse entered event - * - * @param e event - */ - @Override - public void mouseEntered(MouseEvent e) { - } - - /** - * Mouse exited event - * - * @param e event - */ - @Override - public void mouseExited(MouseEvent e) { - } - - /** - * Method called when specified contentType is received - * - * @param contentType Content type - * @param url URL of the method - * @param data Data stream - */ - @Override - public void catched(String contentType, String url, InputStream data) { - boolean swfOnly = false; - if (contentType.contains(";")) { - contentType = contentType.substring(0, contentType.indexOf(';')); - } - if ((!sniffSWFCheckBox.isSelected()) && (contentType.equals("application/x-shockwave-flash"))) { - return; - } - if ((!sniffJSCheckBox.isSelected()) && (contentType.equals("application/javascript") || contentType.equals("application/x-javascript") || contentType.equals("text/javascript") || contentType.equals("application/json"))) { - return; - } - if ((!sniffXMLCheckBox.isSelected()) && (contentType.equals("application/xml") || contentType.equals("text/xml"))) { - return; - } - if ((!sniffOSCheckBox.isSelected()) && (contentType.equals("application/octet-stream"))) { - return; - } - if (!listModel.contains(url)) { - try { - byte[] hdr = new byte[3]; - data.read(hdr); - String shdr = new String(hdr); - if ((swfOnly) && ((!shdr.equals("FWS")) && (!shdr.equals("CWS")))) { - return; //NOT SWF - } - - File f = new File(Main.tempFile(url)); - try (FileOutputStream fos = new FileOutputStream(f)) { - fos.write(hdr); - byte[] buf = new byte[2048]; - int count; - while ((count = data.read(buf)) > 0) { - fos.write(buf, 0, count); - } - } - Replacement r = new Replacement(url, Main.tempFile(url)); - r.lastAccess = Calendar.getInstance(); - listModel.addURL(r); - } catch (IOException e) { - } - - } - } - - /** - * Shows or hides this {@code Window} depending on the value of parameter - * {@code b}. - * - * @param b if {@code true}, makes the {@code Window} visible, otherwise - * hides the {@code Window}. If the {@code Window} and/or its owner are not - * yet displayable, both are made displayable. The {@code Window} will be - * validated prior to being made visible. If the {@code Window} is already - * visible, this will bring the {@code Window} to the front.

- * If {@code false}, hides this {@code Window}, its subcomponents, and all - * of its owned children. The {@code Window} and its subcomponents can be - * made visible again with a call to {@code #setVisible(true)}. - * @see java.awt.Component#isDisplayable - * @see java.awt.Component#setVisible - * @see java.awt.Window#toFront - * @see java.awt.Window#dispose - */ - @Override - public void setVisible(boolean b) { - if (b == true) { - Main.addTrayIcon(); - } - super.setVisible(b); - } - - @Override - public void replaced(Replacement replacement, String url, String contentType) { - listModel.dataChanged(listModel.indexOf(replacement)); - } -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.decompiler.flash.gui.proxy; + +import com.jpexs.decompiler.flash.configuration.Configuration; +import com.jpexs.decompiler.flash.gui.AppFrame; +import com.jpexs.decompiler.flash.gui.Main; +import com.jpexs.decompiler.flash.gui.MainFrame; +import com.jpexs.decompiler.flash.gui.View; +import com.jpexs.proxy.CatchedListener; +import com.jpexs.proxy.ReplacedListener; +import com.jpexs.proxy.Replacement; +import com.jpexs.proxy.Server; +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Image; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +/** + * Frame with Proxy + * + * @author JPEXS + */ +public class ProxyFrame extends AppFrame implements ActionListener, CatchedListener, MouseListener, ReplacedListener { + + static final String ACTION_SWITCH_STATE = "SWITCHSTATE"; + static final String ACTION_OPEN = "OPEN"; + static final String ACTION_CLEAR = "CLEAR"; + static final String ACTION_RENAME = "RENAME"; + static final String ACTION_REMOVE = "REMOVE"; + + private MainFrame mainFrame; + private JList swfList; + private SWFListModel listModel; + private JButton switchButton = new JButton(translate("proxy.start")); + private boolean started = false; + private JTextField portField = new JTextField("55555"); + private JCheckBox sniffSWFCheckBox = new JCheckBox("SWF", false); + private JCheckBox sniffOSCheckBox = new JCheckBox("OctetStream", false); + private JCheckBox sniffJSCheckBox = new JCheckBox("JS", false); + private JCheckBox sniffXMLCheckBox = new JCheckBox("XML", false); + + /** + * Is server running + * + * @return True when running + */ + public boolean isRunning() { + return started; + } + + /** + * Sets port for the proxy + * + * @param port Port number + */ + public void setPort(int port) { + portField.setText("" + port); + } + + /** + * Constructor + * + * @param mainFrame + */ + public ProxyFrame(final MainFrame mainFrame) { + + this.mainFrame = mainFrame; + listModel = new SWFListModel(Configuration.getReplacements()); + swfList = new JList<>(listModel); + swfList.addMouseListener(this); + swfList.setFont(new Font("Monospaced", Font.PLAIN, 12)); + switchButton.addActionListener(this); + switchButton.setActionCommand(ACTION_SWITCH_STATE); + Container cnt = getContentPane(); + cnt.setLayout(new BorderLayout()); + cnt.add(new JScrollPane(swfList), BorderLayout.CENTER); + + portField.setPreferredSize(new Dimension(80, portField.getPreferredSize().height)); + JPanel buttonsPanel = new JPanel(); + buttonsPanel.setLayout(new FlowLayout()); + buttonsPanel.add(new JLabel(translate("port"))); + buttonsPanel.add(portField); + buttonsPanel.add(switchButton); + cnt.add(buttonsPanel, BorderLayout.NORTH); + + JPanel buttonsPanel23 = new JPanel(); + buttonsPanel23.setLayout(new BoxLayout(buttonsPanel23, BoxLayout.Y_AXIS)); + + JPanel buttonsPanel2 = new JPanel(); + buttonsPanel2.setLayout(new FlowLayout()); + JButton openButton = new JButton(translate("open")); + openButton.setActionCommand(ACTION_OPEN); + openButton.addActionListener(this); + buttonsPanel2.add(openButton); + JButton clearButton = new JButton(translate("clear")); + clearButton.setActionCommand(ACTION_CLEAR); + clearButton.addActionListener(this); + buttonsPanel2.add(clearButton); + JButton renameButton = new JButton(translate("rename")); + renameButton.setActionCommand(ACTION_RENAME); + renameButton.addActionListener(this); + buttonsPanel2.add(renameButton); + JButton removeButton = new JButton(translate("remove")); + removeButton.setActionCommand(ACTION_REMOVE); + removeButton.addActionListener(this); + buttonsPanel2.add(removeButton); + + JPanel buttonsPanel3 = new JPanel(); + buttonsPanel3.setLayout(new FlowLayout()); + buttonsPanel3.add(new JLabel(translate("sniff"))); + buttonsPanel3.add(sniffSWFCheckBox); + buttonsPanel3.add(sniffOSCheckBox); + //buttonsPanel3.add(sniffJSCheckBox); + //buttonsPanel3.add(sniffXMLCheckBox); + + buttonsPanel23.add(buttonsPanel2); + buttonsPanel23.add(buttonsPanel3); + + cnt.add(buttonsPanel23, BorderLayout.SOUTH); + setSize(400, 300); + View.centerScreen(this); + View.setWindowIcon(this); + setTitle(translate("dialog.title")); + this.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + setVisible(false); + Main.removeTrayIcon(); + if (mainFrame != null) { + if (mainFrame.isVisible()) { + return; + } + } + Main.showModeFrame(); + } + + /** + * Invoked when a window is iconified. + */ + @Override + public void windowIconified(WindowEvent e) { + setVisible(false); + } + }); + java.util.List images = new ArrayList<>(); + images.add(View.loadImage("proxy16")); + images.add(View.loadImage("proxy32")); + setIconImages(images); + } + + private void open() { + if (swfList.getSelectedIndex() > -1) { + Replacement r = listModel.getElementAt(swfList.getSelectedIndex()); + Main.openFile(r.targetFile, r.urlPattern); + } + } + + /** + * Method handling actions from buttons + * + * @param e event + */ + @Override + public void actionPerformed(ActionEvent e) { + switch (e.getActionCommand()) { + case ACTION_OPEN: + open(); + break; + case ACTION_RENAME: + if (swfList.getSelectedIndex() > -1) { + Replacement r = listModel.getElementAt(swfList.getSelectedIndex()); + String s = View.showInputDialog("URL", r.urlPattern); + r.urlPattern = s; + listModel.dataChanged(swfList.getSelectedIndex()); + } + break; + case ACTION_CLEAR: + for (int i = 0; i < listModel.getSize(); i++) { + Replacement r = listModel.getElementAt(i); + File f; + try { + f = (new File(Main.tempFile(r.targetFile))); + if (f.exists()) { + f.delete(); + } + } catch (IOException ex) { + Logger.getLogger(ProxyFrame.class.getName()).log(Level.SEVERE, null, ex); + } + + } + listModel.clear(); + break; + case ACTION_REMOVE: + int lastIndex = -1; + for (int k = listModel.getSize() - 1; k >= 0; k--) { + if (swfList.isSelectedIndex(k)) { + Replacement r = listModel.removeURL(k); + File f = (new File(r.targetFile)); + if (f.exists()) { + f.delete(); + } + lastIndex = k; + } + } + if (lastIndex >= listModel.getSize()) { + lastIndex--; + } + if (lastIndex > -1) { + swfList.setSelectedIndex(lastIndex); + } + break; + case ACTION_SWITCH_STATE: + Main.switchProxy(); + break; + } + } + + /** + * Switch proxy state + */ + public void switchState() { + started = !started; + if (started) { + int port = 0; + try { + port = Integer.parseInt(portField.getText()); + } catch (NumberFormatException nfe) { + } + if ((port <= 0) || (port > 65535)) { + View.showMessageDialog(this, translate("error.port"), translate("error"), JOptionPane.ERROR_MESSAGE); + started = false; + return; + } + java.util.List catchedContentTypes = new ArrayList<>(); + catchedContentTypes.add("application/x-shockwave-flash"); + catchedContentTypes.add("application/x-javascript"); + catchedContentTypes.add("application/javascript"); + catchedContentTypes.add("text/javascript"); + catchedContentTypes.add("application/json"); + catchedContentTypes.add("text/xml"); + catchedContentTypes.add("application/xml"); + catchedContentTypes.add("application/octet-stream"); + Server.startServer(port, Configuration.getReplacements(), catchedContentTypes, this, this); + switchButton.setText(translate("proxy.stop")); + portField.setEditable(false); + } else { + Server.stopServer(); + switchButton.setText(translate("proxy.start")); + portField.setEditable(true); + } + } + + /** + * Mouse clicked event + * + * @param e event + */ + @Override + public void mouseClicked(MouseEvent e) { + if (e.getSource() == swfList) { + if (e.getClickCount() == 2) { + open(); + } + } + } + + /** + * Mouse pressed event + * + * @param e event + */ + @Override + public void mousePressed(MouseEvent e) { + } + + /** + * Mouse released event + * + * @param e event + */ + @Override + public void mouseReleased(MouseEvent e) { + } + + /** + * Mouse entered event + * + * @param e event + */ + @Override + public void mouseEntered(MouseEvent e) { + } + + /** + * Mouse exited event + * + * @param e event + */ + @Override + public void mouseExited(MouseEvent e) { + } + + /** + * Method called when specified contentType is received + * + * @param contentType Content type + * @param url URL of the method + * @param data Data stream + */ + @Override + public void catched(String contentType, String url, InputStream data) { + boolean swfOnly = false; + if (contentType.contains(";")) { + contentType = contentType.substring(0, contentType.indexOf(';')); + } + if ((!sniffSWFCheckBox.isSelected()) && (contentType.equals("application/x-shockwave-flash"))) { + return; + } + if ((!sniffJSCheckBox.isSelected()) && (contentType.equals("application/javascript") || contentType.equals("application/x-javascript") || contentType.equals("text/javascript") || contentType.equals("application/json"))) { + return; + } + if ((!sniffXMLCheckBox.isSelected()) && (contentType.equals("application/xml") || contentType.equals("text/xml"))) { + return; + } + if ((!sniffOSCheckBox.isSelected()) && (contentType.equals("application/octet-stream"))) { + return; + } + if (!listModel.contains(url)) { + try { + byte[] hdr = new byte[3]; + data.read(hdr); + String shdr = new String(hdr); + if ((swfOnly) && ((!shdr.equals("FWS")) && (!shdr.equals("CWS")))) { + return; //NOT SWF + } + + File f = new File(Main.tempFile(url)); + try (FileOutputStream fos = new FileOutputStream(f)) { + fos.write(hdr); + byte[] buf = new byte[2048]; + int count; + while ((count = data.read(buf)) > 0) { + fos.write(buf, 0, count); + } + } + Replacement r = new Replacement(url, Main.tempFile(url)); + r.lastAccess = Calendar.getInstance(); + listModel.addURL(r); + } catch (IOException e) { + } + + } + } + + /** + * Shows or hides this {@code Window} depending on the value of parameter + * {@code b}. + * + * @param b if {@code true}, makes the {@code Window} visible, otherwise + * hides the {@code Window}. If the {@code Window} and/or its owner are not + * yet displayable, both are made displayable. The {@code Window} will be + * validated prior to being made visible. If the {@code Window} is already + * visible, this will bring the {@code Window} to the front.

+ * If {@code false}, hides this {@code Window}, its subcomponents, and all + * of its owned children. The {@code Window} and its subcomponents can be + * made visible again with a call to {@code #setVisible(true)}. + * @see java.awt.Component#isDisplayable + * @see java.awt.Component#setVisible + * @see java.awt.Window#toFront + * @see java.awt.Window#dispose + */ + @Override + public void setVisible(boolean b) { + if (b == true) { + Main.addTrayIcon(); + } + super.setVisible(b); + } + + @Override + public void replaced(Replacement replacement, String url, String contentType) { + listModel.dataChanged(listModel.indexOf(replacement)); + } +} diff --git a/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java b/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java index ce01b5e72..ebbae3fbe 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineButton2Tag.java @@ -201,7 +201,7 @@ public class DefineButton2Tag extends ButtonTag implements Container { @Override public RECT getRect() { if (rectCache.contains(this)) { - return (RECT) rectCache.get(this); + return rectCache.get(this); } RECT rect = new RECT(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE); for (BUTTONRECORD r : characters) { diff --git a/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java b/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java index 12b68fb03..93c307795 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineButtonTag.java @@ -239,7 +239,7 @@ public class DefineButtonTag extends ButtonTag implements ASMSource { @Override public RECT getRect() { if (rectCache.contains(this)) { - return (RECT) rectCache.get(this); + return rectCache.get(this); } RECT rect = new RECT(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE); for (BUTTONRECORD r : characters) { diff --git a/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java b/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java index d9fa4c551..b3caaf9d9 100644 --- a/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java +++ b/src/com/jpexs/decompiler/flash/tags/DefineSpriteTag.java @@ -126,7 +126,7 @@ public class DefineSpriteTag extends CharacterTag implements Container, Drawable @Override public RECT getRect() { if (rectCache.contains(this)) { - return (RECT) rectCache.get(this); + return rectCache.get(this); } RECT emptyRet = new RECT(); RECT ret = new RECT(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE); diff --git a/src/com/jpexs/helpers/SoundPlayer.java b/src/com/jpexs/helpers/SoundPlayer.java index d6cb39d94..429550091 100644 --- a/src/com/jpexs/helpers/SoundPlayer.java +++ b/src/com/jpexs/helpers/SoundPlayer.java @@ -1,100 +1,104 @@ -/* - * Copyright (C) 2010-2014 JPEXS - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.jpexs.helpers; - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.Clip; -import javax.sound.sampled.Line; -import javax.sound.sampled.LineEvent; -import javax.sound.sampled.LineListener; -import javax.sound.sampled.LineUnavailableException; -import javax.sound.sampled.UnsupportedAudioFileException; - -/** - * - * @author JPEXS - */ -public class SoundPlayer { - - private final Clip clip; - - public SoundPlayer(InputStream is) throws LineUnavailableException, IOException, UnsupportedAudioFileException { - clip = (Clip) AudioSystem.getLine(new Line.Info(Clip.class)); - clip.open(AudioSystem.getAudioInputStream(new BufferedInputStream(is))); - } - - public long samplesCount() { - return clip.getMicrosecondLength(); - } - - public void play() { - - final SoundPlayer t = this; - clip.addLineListener(new LineListener() { - - @Override - public void update(LineEvent event) { - if (event.getType() == LineEvent.Type.STOP) { - //clip.close(); - - synchronized (t) { - t.notifyAll(); - } - } - } - }); - clip.start(); - try { - synchronized (this) { - wait(); - } - } catch (InterruptedException ex) { - //Ignore - } - } - - public long getSamplePosition() { - return clip.getMicrosecondPosition(); - } - - public void setPosition(long frames) { - clip.setMicrosecondPosition(frames); - } - - public void stop() { - clip.stop(); - } - - public boolean isPlaying() { - return clip.isActive(); - } - - public long getFrameRate() { - return 1000000L; - } - - @Override - protected void finalize() throws Throwable { - if (clip != null) { - clip.close(); - } - } - -} +/* + * Copyright (C) 2010-2014 JPEXS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.jpexs.helpers; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Clip; +import javax.sound.sampled.Line; +import javax.sound.sampled.LineEvent; +import javax.sound.sampled.LineListener; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.UnsupportedAudioFileException; + +/** + * + * @author JPEXS + */ +public class SoundPlayer { + + private final Clip clip; + + public SoundPlayer(InputStream is) throws LineUnavailableException, IOException, UnsupportedAudioFileException { + clip = (Clip) AudioSystem.getLine(new Line.Info(Clip.class)); + clip.open(AudioSystem.getAudioInputStream(new BufferedInputStream(is))); + } + + public long samplesCount() { + return clip.getMicrosecondLength(); + } + + public void play() { + + final SoundPlayer t = this; + clip.addLineListener(new LineListener() { + + @Override + public void update(LineEvent event) { + if (event.getType() == LineEvent.Type.STOP) { + //clip.close(); + + synchronized (t) { + t.notifyAll(); + } + } + } + }); + clip.start(); + try { + synchronized (this) { + wait(); + } + } catch (InterruptedException ex) { + //Ignore + } + } + + public long getSamplePosition() { + return clip.getMicrosecondPosition(); + } + + public void setPosition(long frames) { + clip.setMicrosecondPosition(frames); + } + + public void stop() { + clip.stop(); + } + + public boolean isPlaying() { + return clip.isActive(); + } + + public long getFrameRate() { + return 1000000L; + } + + @Override + protected void finalize() throws Throwable { + try { + if (clip != null) { + clip.close(); + } + } finally { + super.finalize(); + } + } + +}