diff --git a/ffdec-findbugs-config.fbp b/ffdec-findbugs-config.fbp new file mode 100644 index 000000000..6772511f4 --- /dev/null +++ b/ffdec-findbugs-config.fbp @@ -0,0 +1,9 @@ + + .\dist\ffdec.jar + .\dist\lib + .\src + .\libsrc + + + + diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegisters.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegisters.java index 6fe54caf3..6a48688c0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegisters.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/deobfuscation/AVM2DeobfuscatorRegisters.java @@ -175,6 +175,7 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple { toVisit.add(idx); List toVisitStacks = new ArrayList<>(); toVisitStacks.add(stack); + outer: while (!toVisit.isEmpty()) { idx = toVisit.remove(0); stack = toVisitStacks.remove(0); @@ -192,6 +193,12 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple { InstructionDefinition def = ins.definition; //System.err.println("" + idx + ": " + ins + " stack:" + stack.size()); + // do not throw EmptyStackException, much faster + int requiredStackSize = ins.getStackPopCount(localData); + if (stack.size() < requiredStackSize) { + continue outer; + } + ins.translate(localData, stack, output, Graph.SOP_USE_STATIC, ""); //if (!(def instanceof KillIns)) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java index 7a8cfcb5e..55380c886 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/AVM2Instruction.java @@ -331,6 +331,7 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem { @Override public void translate(BaseLocalData localData, TranslateStack stack, List output, int staticOperation, String path) throws InterruptedException { AVM2LocalData aLocalData = (AVM2LocalData) localData; + //int expectedSize = stack.size() - getStackPopCount(localData, stack) + getStackPushCount(localData, stack); definition.translate(aLocalData.isStatic, aLocalData.scriptIndex, aLocalData.classIndex, @@ -338,12 +339,31 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem { stack, aLocalData.scopeStack, aLocalData.constants, this, aLocalData.methodInfo, output, aLocalData.methodBody, aLocalData.abc, aLocalData.localRegNames, aLocalData.fullyQualifiedNames, null, aLocalData.localRegAssignmentIps, aLocalData.ip, aLocalData.refs, aLocalData.code); + /*if (stack.size() != expectedSize) { + throw new Error("HONFIKA stack size mismatch"); + }*/ + } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + AVM2LocalData aLocalData = (AVM2LocalData) localData; + return getStackPopCount(aLocalData); + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + AVM2LocalData aLocalData = (AVM2LocalData) localData; + return getStackPushCount(aLocalData); } public int getStackPopCount(AVM2LocalData aLocalData) { return definition.getStackPopCount(this, aLocalData.abc); } + public int getStackPushCount(AVM2LocalData aLocalData) { + return definition.getStackPushCount(this, aLocalData.abc); + } + @Override public boolean isJump() { return (definition instanceof JumpIns) || (fixedBranch > -1); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java index 2776eabdc..32f418247 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/Action.java @@ -711,6 +711,16 @@ public abstract class Action implements GraphSourceItem { public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) throws InterruptedException { } + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 0; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 0; + } + /** * Pops long value off the stack * @@ -870,7 +880,16 @@ public abstract class Action implements GraphSourceItem { @Override public void translate(BaseLocalData localData, TranslateStack stack, List output, int staticOperation, String path) throws InterruptedException { ActionLocalData aLocalData = (ActionLocalData) localData; + /*int expectedSize = stack.size() - getStackPopCount(localData, stack); + if (expectedSize < 0) { + expectedSize = 0; + } + expectedSize += getStackPushCount(localData, stack);*/ + translate(stack, output, aLocalData.regNames, aLocalData.variables, aLocalData.functions, staticOperation, path); + /*if (stack.size() != expectedSize && !(this instanceof ActionPushDuplicate)) { + throw new Error("HONFIKA stack size mismatch"); + }*/ } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java index 9bbf3fd9c..9738030c1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscator.java @@ -257,13 +257,19 @@ public class ActionDeobfuscator extends ActionDeobfuscatorSimple { } if (action instanceof ActionDefineLocal) { - GraphTargetItem top = stack.pop(); - String variableName = stack.peek().getResult().toString(); + if (stack.size() < 2) { + return; + } + + String variableName = stack.peek(2).getResult().toString(); result.defines.add(variableName); - stack.push(top); } if (action instanceof ActionGetVariable) { + if (stack.isEmpty()) { + return; + } + String variableName = stack.peek().getResult().toString(); if (!localData.variables.containsKey(variableName)) { break; @@ -271,6 +277,10 @@ public class ActionDeobfuscator extends ActionDeobfuscatorSimple { } if (action instanceof ActionCallFunction) { + if (stack.isEmpty()) { + return; + } + String functionName = stack.pop().getResult().toString(); long numArgs = EcmaScript.toUint32(stack.pop().getResult()); if (numArgs == 0) { @@ -283,6 +293,12 @@ public class ActionDeobfuscator extends ActionDeobfuscatorSimple { break; } } else { + // do not throw EmptyStackException, much faster + int requiredStackSize = action.getStackPopCount(localData, stack); + if (stack.size() < requiredStackSize) { + return; + } + action.translate(localData, stack, output, Graph.SOP_USE_STATIC, ""); } @@ -348,6 +364,10 @@ public class ActionDeobfuscator extends ActionDeobfuscatorSimple { if (action instanceof ActionIf) { ActionIf aif = (ActionIf) action; + if (stack.isEmpty()) { + return; + } + if (EcmaScript.toBoolean(stack.pop().getResult())) { long address = aif.getAddress() + aif.getTotalActionLength() + aif.getJumpOffset(); idx = actions.indexOf(actions.getByAddress(address)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimple.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimple.java index 9299c7658..ae8f731b3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimple.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/deobfuscation/ActionDeobfuscatorSimple.java @@ -291,6 +291,12 @@ public class ActionDeobfuscatorSimple implements SWFDecompilerListener { System.out.print(" '" + stack.get(j).getResult() + "'"); } System.out.println();*/ + // do not throw EmptyStackException, much faster + int requiredStackSize = action.getStackPopCount(localData, stack); + if (stack.size() < requiredStackSize) { + return; + } + action.translate(localData, stack, output, Graph.SOP_USE_STATIC, ""); if (!(action instanceof ActionPush @@ -341,6 +347,10 @@ public class ActionDeobfuscatorSimple implements SWFDecompilerListener { if (action instanceof ActionIf) { ActionIf aif = (ActionIf) action; + if (stack.isEmpty()) { + return; + } + if (EcmaScript.toBoolean(stack.pop().getResult())) { long address = aif.getAddress() + aif.getTotalActionLength() + aif.getJumpOffset(); idx = actions.indexOf(actions.getByAddress(address)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java index 3b69d92c4..2e4dbbf09 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/flashlite/ActionFSCommand2.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.flashlite; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.FSCommand2ActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -44,4 +46,19 @@ public class ActionFSCommand2 extends Action { } stack.push(new FSCommand2ActionItem(this, command, args)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + int result = 2; + if (!stack.isEmpty()) { + result += stack.peek().getAsLong(); + } + + return result; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/special/ActionDeobfuscatePop.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/special/ActionDeobfuscatePop.java index 994f9592f..9261d7f8e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/special/ActionDeobfuscatePop.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/special/ActionDeobfuscatePop.java @@ -1,18 +1,19 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.special; import com.jpexs.decompiler.flash.BaseLocalData; @@ -40,7 +41,8 @@ public class ActionDeobfuscatePop extends ActionPop { if (stack.isEmpty()) { return; } - GraphTargetItem val = stack.pop(); + + stack.pop(); //Just ignore the value } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionAdd.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionAdd.java index 5fba71696..a01bc2a99 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionAdd.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionAdd.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.AddActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionAdd extends Action { GraphTargetItem b = stack.pop(); stack.push(new AddActionItem(this, b, a, false)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionAnd.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionAnd.java index a1adefc8c..ebf84766a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionAnd.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionAnd.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.AndActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionAnd extends Action { GraphTargetItem b = stack.pop(); stack.push(new AndActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionAsciiToChar.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionAsciiToChar.java index bdedb4447..724bda0f5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionAsciiToChar.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionAsciiToChar.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.AsciiToCharActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,14 @@ public class ActionAsciiToChar extends Action { GraphTargetItem a = stack.pop(); stack.push(new AsciiToCharActionItem(this, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionCall.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionCall.java index ca8f20a1a..56850b771 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionCall.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionCall.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.CallActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -41,4 +43,9 @@ public class ActionCall extends Action { public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { output.add(new CallActionItem(this, stack.pop())); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionCharToAscii.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionCharToAscii.java index 54b10bbad..8191b9c90 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionCharToAscii.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionCharToAscii.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.CharToAsciiActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,14 @@ public class ActionCharToAscii extends Action { GraphTargetItem a = stack.pop(); stack.push(new CharToAsciiActionItem(this, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionCloneSprite.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionCloneSprite.java index db22302f5..a460466fe 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionCloneSprite.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionCloneSprite.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.CloneSpriteActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -40,4 +42,9 @@ public class ActionCloneSprite extends Action { GraphTargetItem target = stack.pop(); output.add(new CloneSpriteActionItem(this, source, target, depth)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 3; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionDivide.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionDivide.java index d7f9f7fe4..60a5aa79c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionDivide.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionDivide.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.DivideActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionDivide extends Action { GraphTargetItem b = stack.pop(); stack.push(new DivideActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionEquals.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionEquals.java index 9624748b4..1af100205 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionEquals.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionEquals.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.EqActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionEquals extends Action { GraphTargetItem b = stack.pop(); stack.push(new EqActionItem(this, b, a, false)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java index 6e1ade87d..8202587c8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetProperty.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; import com.jpexs.decompiler.flash.action.model.GetPropertyActionItem; @@ -51,4 +53,14 @@ public class ActionGetProperty extends Action { } stack.push(new GetPropertyActionItem(this, target, indexInt)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java index cd5e7adcc..7826a1ec5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetTime.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.GetTimeActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -37,4 +39,9 @@ public class ActionGetTime extends Action { public void translate(TranslateStack stack, List output, HashMap regNames, HashMap variables, HashMap functions, int staticOperation, String path) { stack.push(new GetTimeActionItem(this)); } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java index 55d96db47..a20285cc6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetURL2.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; @@ -161,4 +162,9 @@ public class ActionGetURL2 extends Action { } } } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetVariable.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetVariable.java index 9b96896a6..cafbf3c10 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetVariable.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGetVariable.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; import com.jpexs.decompiler.flash.action.model.EvalActionItem; @@ -51,4 +53,14 @@ public class ActionGetVariable extends Action { stack.push(gvt); } } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java index 94314c2a7..a55df60c0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionGotoFrame2.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; @@ -101,4 +102,9 @@ public class ActionGotoFrame2 extends Action { GraphTargetItem frame = stack.pop(); output.add(new GotoFrame2ActionItem(this, frame, sceneBiasFlag, playFlag, sceneBias)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionLess.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionLess.java index 6679d6731..d52262e83 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionLess.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionLess.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.LtActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionLess extends Action { GraphTargetItem b = stack.pop(); stack.push(new LtActionItem(this, b, a, false)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMBAsciiToChar.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMBAsciiToChar.java index 00609fdde..22d710389 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMBAsciiToChar.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMBAsciiToChar.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.MBAsciiToCharActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,14 @@ public class ActionMBAsciiToChar extends Action { GraphTargetItem a = stack.pop(); stack.push(new MBAsciiToCharActionItem(this, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMBCharToAscii.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMBCharToAscii.java index bb4b87ed4..7afb9f510 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMBCharToAscii.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMBCharToAscii.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.MBCharToAsciiActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,14 @@ public class ActionMBCharToAscii extends Action { GraphTargetItem a = stack.pop(); stack.push(new MBCharToAsciiActionItem(this, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringExtract.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringExtract.java index f26199bda..2ad4cac36 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringExtract.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringExtract.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.MBStringExtractActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -40,4 +42,14 @@ public class ActionMBStringExtract extends Action { GraphTargetItem value = stack.pop(); stack.push(new MBStringExtractActionItem(this, value, index, count)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 3; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringLength.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringLength.java index 1657c6e92..781fb8cbf 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringLength.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMBStringLength.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.MBStringLengthActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,14 @@ public class ActionMBStringLength extends Action { GraphTargetItem a = stack.pop(); stack.push(new MBStringLengthActionItem(this, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMultiply.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMultiply.java index 6db9ee728..677bc408d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMultiply.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionMultiply.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.MultiplyActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionMultiply extends Action { GraphTargetItem b = stack.pop(); stack.push(new MultiplyActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionNot.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionNot.java index b6dc4df8f..81d28f19e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionNot.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionNot.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; @@ -38,4 +39,14 @@ public class ActionNot extends Action { GraphTargetItem a = stack.pop(); stack.push(a.invert(this)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionOr.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionOr.java index c83c96400..f6a049648 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionOr.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionOr.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.OrActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionOr extends Action { GraphTargetItem b = stack.pop(); stack.push(new OrActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPop.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPop.java index 064bf26ae..7eeb06b91 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPop.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPop.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; @@ -38,4 +39,9 @@ public class ActionPop extends Action { GraphTargetItem val = stack.pop(); output.add(val); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java index 70c327738..8060af533 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionPush.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.EndOfStreamException; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; @@ -442,4 +443,9 @@ public class ActionPush extends Action { pos++; } } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return values.size(); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionRandomNumber.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionRandomNumber.java index bec7e9068..0c102428c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionRandomNumber.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionRandomNumber.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.RandomNumberActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,14 @@ public class ActionRandomNumber extends Action { GraphTargetItem maximum = stack.pop(); stack.push(new RandomNumberActionItem(this, maximum)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionRemoveSprite.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionRemoveSprite.java index 86de43f33..61d8f8aa9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionRemoveSprite.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionRemoveSprite.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.RemoveSpriteActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,9 @@ public class ActionRemoveSprite extends Action { GraphTargetItem target = stack.pop(); output.add(new RemoveSpriteActionItem(this, target)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java index a94c4ad80..096904898 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetProperty.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DecrementActionItem; import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; @@ -60,22 +62,18 @@ public class ActionSetProperty extends Action { } 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 (!stack.isEmpty() && 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; - } + if (!stack.isEmpty() && stack.peek().valueEquals(obj)) { + stack.pop(); + stack.push(new PostDecrementActionItem(this, obj)); + return; } } @@ -108,4 +106,9 @@ public class ActionSetProperty extends Action { } output.add(ret); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 3; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetTarget2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetTarget2.java index 85bef0c96..d99970c3b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetTarget2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetTarget2.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.SetTarget2ActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,9 @@ public class ActionSetTarget2 extends Action { GraphTargetItem target = stack.pop(); output.add(new SetTarget2ActionItem(this, target)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java index 782c08c88..bfe7ca5ab 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSetVariable.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.StoreTypeAction; import com.jpexs.decompiler.flash.action.model.ConstantPool; @@ -52,22 +54,18 @@ public class ActionSetVariable extends Action implements StoreTypeAction { 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 (!stack.isEmpty() && 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 (!stack.isEmpty() && stack.peek().valueEquals(obj)) { + stack.pop(); + stack.push(new PostDecrementActionItem(this, obj)); + return; } } if (value instanceof IncrementActionItem) { @@ -119,6 +117,11 @@ public class ActionSetVariable extends Action implements StoreTypeAction { output.add(ret); } + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + @Override public String getVariableName(TranslateStack stack, ConstantPool cpool) { if (stack.size() < 2) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java index f9b7e01ff..e9b4a6000 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStartDrag.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; import com.jpexs.decompiler.flash.action.model.StartDragActionItem; @@ -47,6 +49,7 @@ public class ActionStartDrag extends Action { hasConstrains = false; } } + GraphTargetItem x1 = null; GraphTargetItem y1 = null; GraphTargetItem x2 = null; @@ -57,6 +60,25 @@ public class ActionStartDrag extends Action { y1 = stack.pop(); x1 = stack.pop(); } + output.add(new StartDragActionItem(this, target, lockCenter, constrain, x1, y1, x2, y2)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + if (stack.size() >= 3) { + GraphTargetItem constrain = stack.peek(3); + boolean hasConstrains = true; + if (constrain instanceof DirectValueActionItem) { + if (Double.compare(EcmaScript.toNumber(constrain.getResult()), 0) == 0) { + hasConstrains = false; + } + } + if (hasConstrains) { + return 7; + } + } + + return 3; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringAdd.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringAdd.java index 7092d0213..37b4b7352 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringAdd.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringAdd.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.StringAddActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionStringAdd extends Action { GraphTargetItem b = stack.pop(); stack.push(new StringAddActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringEquals.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringEquals.java index 6fc9ace3b..990d1322c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringEquals.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringEquals.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.StringEqActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionStringEquals extends Action { GraphTargetItem b = stack.pop(); stack.push(new StringEqActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringExtract.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringExtract.java index 8f6e6c3e0..11d2bf9e6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringExtract.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringExtract.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.StringExtractActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -40,4 +42,14 @@ public class ActionStringExtract extends Action { GraphTargetItem value = stack.pop(); stack.push(new StringExtractActionItem(this, value, index, count)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 3; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLength.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLength.java index f38a4a6b5..7931857b7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLength.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLength.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.StringLengthActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,14 @@ public class ActionStringLength extends Action { GraphTargetItem a = stack.pop(); stack.push(new StringLengthActionItem(this, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLess.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLess.java index 83f022a08..0b6d6cb63 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLess.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionStringLess.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.StringLtActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionStringLess extends Action { GraphTargetItem b = stack.pop(); stack.push(new StringLtActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSubtract.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSubtract.java index 6f842bf18..319bc5786 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSubtract.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionSubtract.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.SubtractActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionSubtract extends Action { GraphTargetItem b = stack.pop(); stack.push(new SubtractActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionToInteger.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionToInteger.java index 22034ff3e..3a81c76bc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionToInteger.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionToInteger.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.ToIntegerActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,14 @@ public class ActionToInteger extends Action { GraphTargetItem a = stack.pop(); stack.push(new ToIntegerActionItem(this, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionTrace.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionTrace.java index 04a6a2ee7..44ea459be 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionTrace.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionTrace.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.TraceActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,9 @@ public class ActionTrace extends Action { GraphTargetItem value = stack.pop(); output.add(new TraceActionItem(this, value)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java index eedc9bd2d..72b90ec78 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf4/ActionWaitForFrame2.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.action.swf4; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; @@ -136,4 +137,9 @@ public class ActionWaitForFrame2 extends Action implements ActionStore { List body = ActionGraph.translateViaGraph(regNames, variables, functions, skipped, SWF.DEFAULT_VERSION, staticOperation, path); output.add(new IfFrameLoadedActionItem(frame, body, this)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionAdd2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionAdd2.java index 3189a2cb6..1f0bc0c17 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionAdd2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionAdd2.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.AddActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionAdd2 extends Action { GraphTargetItem b = stack.pop(); stack.push(new AddActionItem(this, b, a, true)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitAnd.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitAnd.java index e14615c1f..2b712b644 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitAnd.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitAnd.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.BitAndActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionBitAnd extends Action { GraphTargetItem b = stack.pop(); stack.push(new BitAndActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitLShift.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitLShift.java index 8bd5fd290..165445f22 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitLShift.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitLShift.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.LShiftActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionBitLShift extends Action { GraphTargetItem b = stack.pop(); stack.push(new LShiftActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitOr.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitOr.java index 5290a6100..420abc0ca 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitOr.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitOr.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.BitOrActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionBitOr extends Action { GraphTargetItem b = stack.pop(); stack.push(new BitOrActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitRShift.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitRShift.java index d2b21cae6..c278a9cd6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitRShift.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitRShift.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.RShiftActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionBitRShift extends Action { GraphTargetItem b = stack.pop(); stack.push(new RShiftActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitURShift.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitURShift.java index 256f8b9a8..e2ddb9bf6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitURShift.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitURShift.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.URShiftActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionBitURShift extends Action { GraphTargetItem b = stack.pop(); stack.push(new URShiftActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitXor.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitXor.java index b7efe2684..ec08f1249 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitXor.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionBitXor.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.BitXorActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionBitXor extends Action { GraphTargetItem b = stack.pop(); stack.push(new BitXorActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionCallFunction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionCallFunction.java index f9247654c..9fc0db7d7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionCallFunction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionCallFunction.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.CallFunctionActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -47,4 +49,19 @@ public class ActionCallFunction extends Action { cft.calculatedFunction = functions.get(functionName.toStringNoQuotes(LocalData.empty)); stack.push(cft); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + int result = 2; + if (stack.size() >= 2) { + result += stack.peek(2).getAsLong(); + } + + return result; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionCallMethod.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionCallMethod.java index ec57396d8..c92e41784 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionCallMethod.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionCallMethod.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.CallMethodActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -45,4 +47,19 @@ public class ActionCallMethod extends Action { } stack.push(new CallMethodActionItem(this, scriptObject, methodName, args)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + int result = 3; + if (stack.size() >= 3) { + result += stack.peek(3).getAsLong(); + } + + return result; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDecrement.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDecrement.java index 3cb4dd804..d3ad096eb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDecrement.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDecrement.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DecrementActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,14 @@ public class ActionDecrement extends Action { GraphTargetItem a = stack.pop(); stack.push(new DecrementActionItem(this, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal.java index bdd7d01e8..917e3610c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DefineLocalActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -41,4 +43,9 @@ public class ActionDefineLocal extends Action { variables.put(name.toStringNoQuotes(LocalData.empty), value); output.add(new DefineLocalActionItem(this, name, value)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal2.java index 9d053195a..814536cab 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDefineLocal2.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DefineLocalActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,9 @@ public class ActionDefineLocal2 extends Action { GraphTargetItem name = stack.pop(); output.add(new DefineLocalActionItem(this, name, null)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete.java index 845f85dfc..f7a1db6e9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DeleteActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -40,4 +42,14 @@ public class ActionDelete extends Action { stack.push(new DeleteActionItem(this, object, propertyName)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete2.java index 7a8924ba2..a77458e5f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionDelete2.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DeleteActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionDelete2 extends Action { stack.push(new DeleteActionItem(this, null, propertyName)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionEnumerate.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionEnumerate.java index 83742a7bd..9eff7da10 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionEnumerate.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionEnumerate.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.EnumerateActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -40,4 +41,9 @@ public class ActionEnumerate extends Action { //stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList())); output.add(new EnumerateActionItem(this, object)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionEquals2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionEquals2.java index b58052d31..f66f2e1cb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionEquals2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionEquals2.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.EqActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionEquals2 extends Action { GraphTargetItem b = stack.pop(); stack.push(new EqActionItem(this, b, a, true)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionGetMember.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionGetMember.java index 593168cea..f030ad228 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionGetMember.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionGetMember.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.GetMemberActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionGetMember extends Action { GraphTargetItem object = stack.pop(); stack.push(new GetMemberActionItem(this, object, functionName)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionIncrement.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionIncrement.java index 135677086..e8bfb2153 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionIncrement.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionIncrement.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.IncrementActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,14 @@ public class ActionIncrement extends Action { GraphTargetItem a = stack.pop(); stack.push(new IncrementActionItem(this, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionInitArray.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionInitArray.java index 6c1adcf87..3b4b5497f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionInitArray.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionInitArray.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.InitArrayActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,6 +41,21 @@ public class ActionInitArray extends Action { stack.push(new InitArrayActionItem(this, args)); } + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + int result = 1; + if (!stack.isEmpty()) { + result += stack.peek().getAsLong(); + } + + return result; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + @Override public String toString() { return "InitArray"; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java index e99ed1122..fcb67f039 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionInitObject.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.InitObjectActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -45,4 +47,19 @@ public class ActionInitObject extends Action { } stack.push(new InitObjectActionItem(this, names, values)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + int result = 1; + if (!stack.isEmpty()) { + result += 2 * stack.peek().getAsLong(); + } + + return result; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionLess2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionLess2.java index 2cb00eac9..b33fbce96 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionLess2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionLess2.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.LtActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionLess2 extends Action { GraphTargetItem b = stack.pop(); stack.push(new LtActionItem(this, b, a, true)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionModulo.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionModulo.java index 75ecef128..174525c25 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionModulo.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionModulo.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.ModuloActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionModulo extends Action { GraphTargetItem b = stack.pop(); stack.push(new ModuloActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionNewMethod.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionNewMethod.java index a50cfbd9b..4dc5e51af 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionNewMethod.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionNewMethod.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.NewMethodActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -45,4 +47,19 @@ public class ActionNewMethod extends Action { } stack.push(new NewMethodActionItem(this, scriptObject, methodName, args)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + int result = 3; + if (stack.size() >= 3) { + result += stack.peek(3).getAsLong(); + } + + return result; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java index 9aa6d701b..485a368ee 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionNewObject.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.NewObjectActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -44,4 +46,19 @@ public class ActionNewObject extends Action { } stack.push(new NewObjectActionItem(this, objectName, args)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + int result = 2; + if (stack.size() >= 2) { + result += stack.peek(2).getAsLong(); + } + + return result; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionPushDuplicate.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionPushDuplicate.java index 81c19a86e..7ee61818f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionPushDuplicate.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionPushDuplicate.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -41,4 +42,14 @@ public class ActionPushDuplicate extends Action { stack.push(new DuplicateItem(this, value)); value.getMoreSrc().add(new GraphSourceItemPos(this, 0)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionReturn.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionReturn.java index 9237d09b7..5e3d2fa13 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionReturn.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionReturn.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.ReturnActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,6 +41,11 @@ public class ActionReturn extends Action { output.add(new ReturnActionItem(this, value)); } + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + @Override public boolean isExit() { return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java index a144def5a..82b87343f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionSetMember.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.DecrementActionItem; import com.jpexs.decompiler.flash.action.model.GetMemberActionItem; @@ -49,22 +51,18 @@ public class ActionSetMember extends Action { 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 (!stack.isEmpty() && 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 (!stack.isEmpty() && stack.peek().valueEquals(obj)) { + stack.pop(); + stack.push(new PostDecrementActionItem(this, obj)); + return; } } @@ -116,4 +114,9 @@ public class ActionSetMember extends Action { } output.add(ret); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 3; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionStackSwap.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionStackSwap.java index 7805d3583..579850203 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionStackSwap.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionStackSwap.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.graph.GraphSourceItemPos; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -43,4 +44,14 @@ public class ActionStackSwap extends Action { a.getMoreSrc().add(new GraphSourceItemPos(this, 0)); b.getMoreSrc().add(new GraphSourceItemPos(this, 0)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java index 5433078c7..20d304d46 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionStoreRegister.java @@ -16,6 +16,7 @@ */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; import com.jpexs.decompiler.flash.action.Action; @@ -112,29 +113,35 @@ public class ActionStoreRegister extends Action implements StoreTypeAction { 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)); - stack.push(obj); - return; - } + if (!stack.isEmpty() && stack.peek().valueEquals(obj)) { + stack.pop(); + stack.push(new PostIncrementActionItem(this, obj)); + stack.push(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)); - stack.push(obj); - return; - } + if (!stack.isEmpty() && stack.peek().valueEquals(obj)) { + stack.pop(); + stack.push(new PostDecrementActionItem(this, obj)); + stack.push(obj); + return; } } stack.push(new StoreRegisterActionItem(this, rn, value, define)); } + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + @Override public String getVariableName(TranslateStack stack, ConstantPool cpool) { return "__register" + registerNumber; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionTargetPath.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionTargetPath.java index d284e0420..9d2578e91 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionTargetPath.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionTargetPath.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.TargetPathActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,14 @@ public class ActionTargetPath extends Action { GraphTargetItem object = stack.pop(); stack.push(new TargetPathActionItem(this, object)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionToNumber.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionToNumber.java index b3387d1e0..4db13e82b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionToNumber.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionToNumber.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.ToNumberActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,14 @@ public class ActionToNumber extends Action { GraphTargetItem object = stack.pop(); stack.push(new ToNumberActionItem(this, object)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionToString.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionToString.java index f077250ea..1ce28f627 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionToString.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionToString.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.ToStringActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,14 @@ public class ActionToString extends Action { GraphTargetItem object = stack.pop(); stack.push(new ToStringActionItem(this, object)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionTypeOf.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionTypeOf.java index 0949e8296..b7299c3be 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionTypeOf.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf5/ActionTypeOf.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf5; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.TypeOfActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -38,4 +40,14 @@ public class ActionTypeOf extends Action { GraphTargetItem object = stack.pop(); stack.push(new TypeOfActionItem(this, object)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionEnumerate2.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionEnumerate2.java index 9e56b1868..790d2e01a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionEnumerate2.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionEnumerate2.java @@ -1,21 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library. */ package com.jpexs.decompiler.flash.action.swf6; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.EnumerateActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +40,9 @@ public class ActionEnumerate2 extends Action { GraphTargetItem object = stack.pop(); output.add(new EnumerateActionItem(this, object)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionGreater.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionGreater.java index 919e7004d..19240c716 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionGreater.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionGreater.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf6; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.GtActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionGreater extends Action { GraphTargetItem b = stack.pop(); stack.push(new GtActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionInstanceOf.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionInstanceOf.java index a4b58e54b..b214f2e2c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionInstanceOf.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionInstanceOf.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf6; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.InstanceOfActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionInstanceOf extends Action { GraphTargetItem b = stack.pop(); stack.push(new InstanceOfActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionStrictEquals.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionStrictEquals.java index f3ea6d4c1..46259c31f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionStrictEquals.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionStrictEquals.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf6; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.StrictEqActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionStrictEquals extends Action { GraphTargetItem b = stack.pop(); stack.push(new StrictEqActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java index 6e25bfd21..c80293138 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf6/ActionStringGreater.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf6; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.operations.StringGtActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionStringGreater extends Action { GraphTargetItem b = stack.pop(); stack.push(new StringGtActionItem(this, b, a)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionCastOp.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionCastOp.java index b26beaeb0..f26e5d129 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionCastOp.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionCastOp.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf7; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.CastOpActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,14 @@ public class ActionCastOp extends Action { GraphTargetItem constructor = stack.pop(); stack.push(new CastOpActionItem(this, constructor, object)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } + + @Override + public int getStackPushCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionExtends.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionExtends.java index 489111b01..dc73cf89d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionExtends.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionExtends.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf7; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.ExtendsActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,4 +41,9 @@ public class ActionExtends extends Action { GraphTargetItem subclass = stack.pop(); output.add(new ExtendsActionItem(this, subclass, superclass)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 2; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionImplementsOp.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionImplementsOp.java index 79f118cb5..15294c830 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionImplementsOp.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionImplementsOp.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf7; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.ImplementsOpActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -44,4 +46,14 @@ public class ActionImplementsOp extends Action { } output.add(new ImplementsOpActionItem(this, subclass, superclasses)); } + + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + int result = 2; + if (stack.size() >= 2) { + result += stack.peek(2).getAsLong(); + } + + return result; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionThrow.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionThrow.java index a9d18d23a..227b0da67 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionThrow.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/action/swf7/ActionThrow.java @@ -1,20 +1,22 @@ /* * Copyright (C) 2010-2015 JPEXS, All rights reserved. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.action.swf7; +import com.jpexs.decompiler.flash.BaseLocalData; import com.jpexs.decompiler.flash.action.Action; import com.jpexs.decompiler.flash.action.model.ThrowActionItem; import com.jpexs.decompiler.graph.GraphTargetItem; @@ -39,6 +41,11 @@ public class ActionThrow extends Action { output.add(new ThrowActionItem(this, object)); } + @Override + public int getStackPopCount(BaseLocalData localData, TranslateStack stack) { + return 1; + } + @Override public boolean isExit() { return true; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphSourceItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphSourceItem.java index e01f6a868..eb22fd127 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphSourceItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphSourceItem.java @@ -25,6 +25,10 @@ public interface GraphSourceItem extends Serializable, Cloneable { public void translate(BaseLocalData localData, TranslateStack stack, List output, int staticOperation, String path) throws InterruptedException; + public int getStackPopCount(BaseLocalData localData, TranslateStack stack); + + public int getStackPushCount(BaseLocalData localData, TranslateStack stack); + public boolean isJump(); public boolean isBranch(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java index 7181adccb..b81f8dd38 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/GraphTargetItem.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.graph; import com.jpexs.decompiler.flash.SourceGeneratorLocalData; +import com.jpexs.decompiler.flash.action.model.DirectValueActionItem; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; @@ -375,4 +376,15 @@ public abstract class GraphTargetItem implements Serializable, Cloneable { writer.endBlock(); return writer; } + + public long getAsLong() { + if (this instanceof DirectValueActionItem) { + DirectValueActionItem dvai = (DirectValueActionItem) this; + if (dvai.value instanceof Long) { + return (long) (Long) dvai.value; + } + } + + return 0; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TranslateStack.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TranslateStack.java index 5614a4b04..b3df69b39 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TranslateStack.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/graph/TranslateStack.java @@ -69,6 +69,16 @@ public class TranslateStack extends Stack { return super.peek(); } + public synchronized GraphTargetItem peek(int index) { + if (path != null) { + if (index > this.size()) { + Logger.getLogger(TranslateStack.class.getName()).log(Level.FINE, "{0}: Attemp to Peek item from stack", path); + return getPop(); + } + } + return super.get(size() - index); + } + @Override public synchronized GraphTargetItem pop() { if (path != null) { diff --git a/src/com/jpexs/browsers/cache/chrome/EntryStore.java b/src/com/jpexs/browsers/cache/chrome/EntryStore.java index 098c6b084..f6934eb43 100644 --- a/src/com/jpexs/browsers/cache/chrome/EntryStore.java +++ b/src/com/jpexs/browsers/cache/chrome/EntryStore.java @@ -135,7 +135,7 @@ public class EntryStore extends CacheEntry { if (key_len < 0) { return null; } - return new String(key, 0, key_len > key.length || key_len < 0 ? key.length : key_len); + return new String(key, 0, key_len > key.length ? key.length : key_len); } @Override diff --git a/src/com/jpexs/decompiler/flash/gui/FontEmbedDialog.java b/src/com/jpexs/decompiler/flash/gui/FontEmbedDialog.java index d7f609ee6..ef9ffb2fa 100644 --- a/src/com/jpexs/decompiler/flash/gui/FontEmbedDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/FontEmbedDialog.java @@ -322,17 +322,17 @@ public class FontEmbedDialog extends AppDialog { rangeNames[i] = CharacterRanges.rangeName(i); int codes[] = CharacterRanges.rangeCodes(i); int avail = 0; - String sample = ""; + StringBuilder sample = new StringBuilder(); for (int c = 0; c < codes.length; c++) { if (f.canDisplay(codes[c])) { allChars.add(codes[c]); if (avail < SAMPLE_MAX_LENGTH) { - sample += "" + (char) codes[c]; + sample.append((char) codes[c]); } avail++; } } - rangeSamples[i].setText(sample); + rangeSamples[i].setText(sample.toString()); rangeSamples[i].setFont(f); rangeCheckboxes[i].setText(translate("range.description").replace("%available%", Integer.toString(avail)).replace("%name%", rangeNames[i]).replace("%total%", Integer.toString(codes.length))); } diff --git a/src/com/jpexs/decompiler/flash/gui/GenericTagPanel.java b/src/com/jpexs/decompiler/flash/gui/GenericTagPanel.java index 458b74bc9..faadd7a7c 100644 --- a/src/com/jpexs/decompiler/flash/gui/GenericTagPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/GenericTagPanel.java @@ -169,17 +169,17 @@ public class GenericTagPanel extends JPanel implements ChangeListener { private void setTagText(Tag tag) { clear(); generateEditControls(tag, true); - String val = ""; + StringBuilder val = new StringBuilder(); for (String key : keys) { GenericTagEditor ed = editors.get(key); if (((Component) ed).isVisible()) { - val += key + " : " + ed.getReadOnlyValue() + "
"; + val.append(key).append(" : ").append(ed.getReadOnlyValue()).append("
"); } } //HTML for colors: - val = "" + val + ""; + val.insert(0, "").append(""); genericTagPropertiesEditorPane.setContentType("text/html"); - genericTagPropertiesEditorPane.setText(val); + genericTagPropertiesEditorPane.setText(val.toString()); genericTagPropertiesEditorPane.setCaretPosition(0); hdr.setText(tag.toString()); } diff --git a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java index 0a0284a15..ff095acc8 100644 --- a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java @@ -492,30 +492,31 @@ public class GenericTagTreePanel extends GenericTagPanel { */ @Override public String toString() { - String ret = ""; + StringBuilder ret = new StringBuilder(); if (index > -1) { for (int i = 0; i < fieldSet.size(); i++) { if (i > 0) { - ret += ", "; + ret.append(", "); } - ret += toString(i); + ret.append(toString(i)); } - return ret; + return ret.toString(); } if (fieldSet.size() == 1) { - ret = toString(0); + ret.append(toString(0)); } else { - ret = fieldSet.name; + ret.append(fieldSet.name); SWFArray t = fieldSet.get(0).getAnnotation(SWFArray.class); if (t != null) { - ret += " [" + t.countField() + "]"; + ret.append(" [").append(t.countField()).append("]"); } else { - ret += " []"; + ret.append(" []"); } } - return "" + ret + ""; + ret.insert(0, "").append(""); + return ret.toString(); } public String toString(int fieldIndex) { @@ -820,7 +821,6 @@ public class GenericTagTreePanel extends GenericTagPanel { tag = this.tag; } this.tag = tag; - SWF swf = tag.getSwf(); try { editedTag = tag.cloneTag(); } catch (InterruptedException ex) { diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 424f222e6..68f0f9e6c 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -487,8 +487,8 @@ public final class ImagePanel extends JPanel implements MediaDisplay { @Override public synchronized double getZoomToFit() { - if (timelined instanceof BoundedTag) { - RECT bounds = ((BoundedTag) timelined).getRect(); + if (timelined != null) { + RECT bounds = timelined.getRect(); double w1 = bounds.getWidth() / SWF.unitDivisor; double h1 = bounds.getHeight() / SWF.unitDivisor; @@ -727,64 +727,61 @@ public final class ImagePanel extends JPanel implements MediaDisplay { SerializableImage img = swf.getFromCache(key); if (img == null) { boolean shouldCache = timeline.isSingleFrame(frame); - if (drawable instanceof BoundedTag) { - BoundedTag bounded = (BoundedTag) drawable; - RECT rect = bounded.getRect(); + RECT rect = drawable.getRect(); - int width = (int) (rect.getWidth() * zoom); - int height = (int) (rect.getHeight() * zoom); - SerializableImage image = new SerializableImage((int) Math.ceil(width / SWF.unitDivisor), - (int) Math.ceil(height / SWF.unitDivisor), SerializableImage.TYPE_INT_ARGB); - image.fillTransparent(); - Matrix m = new Matrix(); - m.translate(-rect.Xmin * zoom, -rect.Ymin * zoom); - m.scale(zoom); - RenderContext renderContext = new RenderContext(); - renderContext.stateUnderCursor = stateUnderCursor; - renderContext.mouseButton = mouseButton; - timeline.toImage(frame, time, frame, renderContext, image, m, new ColorTransform()); + int width = (int) (rect.getWidth() * zoom); + int height = (int) (rect.getHeight() * zoom); + SerializableImage image = new SerializableImage((int) Math.ceil(width / SWF.unitDivisor), + (int) Math.ceil(height / SWF.unitDivisor), SerializableImage.TYPE_INT_ARGB); + image.fillTransparent(); + Matrix m = new Matrix(); + m.translate(-rect.Xmin * zoom, -rect.Ymin * zoom); + m.scale(zoom); + RenderContext renderContext = new RenderContext(); + renderContext.stateUnderCursor = stateUnderCursor; + renderContext.mouseButton = mouseButton; + timeline.toImage(frame, time, frame, renderContext, image, m, new ColorTransform()); - Graphics2D gg = (Graphics2D) image.getGraphics(); - gg.setStroke(new BasicStroke(3)); - gg.setPaint(Color.green); - gg.setTransform(AffineTransform.getTranslateInstance(0, 0)); - List dss = new ArrayList<>(); - List os = new ArrayList<>(); - DepthState ds = null; - if (timeline.getFrameCount() > frame) { - ds = timeline.getFrame(frame).layers.get(selectedDepth); - } + Graphics2D gg = (Graphics2D) image.getGraphics(); + gg.setStroke(new BasicStroke(3)); + gg.setPaint(Color.green); + gg.setTransform(AffineTransform.getTranslateInstance(0, 0)); + List dss = new ArrayList<>(); + List os = new ArrayList<>(); + DepthState ds = null; + if (timeline.getFrameCount() > frame) { + ds = timeline.getFrame(frame).layers.get(selectedDepth); + } - if (ds != null) { - CharacterTag cht = swf.getCharacter(ds.characterId); - if (cht != null) { - if (cht instanceof DrawableTag) { - DrawableTag dt = (DrawableTag) cht; - Shape outline = dt.getOutline(0, ds.time, ds.ratio, renderContext, new Matrix(ds.matrix)); - Rectangle bounds = outline.getBounds(); - bounds.x *= zoom; - bounds.y *= zoom; - bounds.width *= zoom; - bounds.height *= zoom; - bounds.x /= 20; - bounds.y /= 20; - bounds.width /= 20; - bounds.height /= 20; - bounds.x -= rect.Xmin / 20; - bounds.y -= rect.Ymin / 20; - gg.setStroke(new BasicStroke(2.0f, - BasicStroke.CAP_BUTT, - BasicStroke.JOIN_MITER, - 10.0f, new float[]{10.0f}, 0.0f)); - gg.setPaint(Color.red); - gg.draw(bounds); - } + if (ds != null) { + CharacterTag cht = swf.getCharacter(ds.characterId); + if (cht != null) { + if (cht instanceof DrawableTag) { + DrawableTag dt = (DrawableTag) cht; + Shape outline = dt.getOutline(0, ds.time, ds.ratio, renderContext, new Matrix(ds.matrix)); + Rectangle bounds = outline.getBounds(); + bounds.x *= zoom; + bounds.y *= zoom; + bounds.width *= zoom; + bounds.height *= zoom; + bounds.x /= 20; + bounds.y /= 20; + bounds.width /= 20; + bounds.height /= 20; + bounds.x -= rect.Xmin / 20; + bounds.y -= rect.Ymin / 20; + gg.setStroke(new BasicStroke(2.0f, + BasicStroke.CAP_BUTT, + BasicStroke.JOIN_MITER, + 10.0f, new float[]{10.0f}, 0.0f)); + gg.setPaint(Color.red); + gg.draw(bounds); } } - - img = image; } + img = image; + if (shouldCache) { swf.putToCache(key, img); } diff --git a/src/com/jpexs/decompiler/flash/gui/LoadingPanel.java b/src/com/jpexs/decompiler/flash/gui/LoadingPanel.java index e643e452a..c2fa4d013 100644 --- a/src/com/jpexs/decompiler/flash/gui/LoadingPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/LoadingPanel.java @@ -96,11 +96,10 @@ public class LoadingPanel extends JPanel { lastImage = bi; lastSize = size; drawTimer = new Timer(); - int timeSpin = 1000; - double delay = timeSpin / o; - while (delay < 10) { + double timeSpin = 1000; + double delay; + while ((delay = timeSpin / o) < 10) { o--; - delay = timeSpin / o; } final int segments = o; int idelay = (int) Math.round(delay); diff --git a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java index ad5d12866..6ade11fd5 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/MainFrameMenu.java @@ -812,7 +812,7 @@ public abstract class MainFrameMenu implements MenuBuilder { addToggleMenuItem("/settings/deobfuscation/new", translate("menu.file.deobfuscation.new"), "deobfuscation", "deobfuscatenew16", (ActionEvent e) -> { deobfuscationMode(e, 1); }, 0); - + finishMenu("/settings/deobfuscation");*/ addMenuItem("/settings/advancedSettings", translate("menu.advancedsettings.advancedsettings"), null, null, 0, null, false); addMenuItem("/settings/advancedSettings/advancedSettings", translate("menu.advancedsettings.advancedsettings"), "settings32", this::advancedSettingsActionPerformed, PRIORITY_TOP, null, true); @@ -951,9 +951,7 @@ public abstract class MainFrameMenu implements MenuBuilder { switchDebugger(); mainFrame.getPanel().refreshDecompiled(); } else { - if (debuggerOn) { - setMenuChecked("/tools/debugger/debuggerSwitch", false); - } + setMenuChecked("/tools/debugger/debuggerSwitch", false); } setMenuEnabled("/tools/debugger/debuggerReplaceTrace", isMenuChecked("/tools/debugger/debuggerSwitch")); } diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 67f50872b..7222fb24e 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -3141,7 +3141,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se } showCard(CARDPREVIEWPANEL); - } else if ((treeItem instanceof Frame) || ((treeItem instanceof CharacterTag) || (treeItem instanceof FontTag)) && (treeItem instanceof Tag) || (treeItem instanceof SoundStreamHeadTypeTag)) { + } else if ((treeItem instanceof Frame) || (treeItem instanceof CharacterTag) || (treeItem instanceof FontTag) || (treeItem instanceof SoundStreamHeadTypeTag)) { previewPanel.createAndShowTempSwf(treeItem); if (treeItem instanceof TextTag) { @@ -3280,11 +3280,12 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se @Override public Timeline getTimeline() { - if (tim != null) { - return tim; + if (tim == null) { + Timeline timeline = new Timeline(tag.getSwf(), null, new ArrayList<>(), ((CharacterTag) tag).getCharacterId(), getRect()); + initTimeline(timeline); + tim = timeline; } - tim = new Timeline(tag.getSwf(), null, new ArrayList<>(), ((CharacterTag) tag).getCharacterId(), getRect()); - initTimeline(tim); + return tim; } @@ -3298,17 +3299,17 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se private void initTimeline(Timeline timeline) { if (tag instanceof MorphShapeTag) { - tim.frameRate = MORPH_SHAPE_ANIMATION_FRAME_RATE; - int framesCnt = (int) (tim.frameRate * MORPH_SHAPE_ANIMATION_LENGTH); + timeline.frameRate = MORPH_SHAPE_ANIMATION_FRAME_RATE; + int framesCnt = (int) (timeline.frameRate * MORPH_SHAPE_ANIMATION_LENGTH); for (int i = 0; i < framesCnt; i++) { - Frame f = new Frame(tim, i); + Frame f = new Frame(timeline, i); DepthState ds = new DepthState(tag.getSwf(), f); ds.characterId = ((CharacterTag) tag).getCharacterId(); ds.matrix = new MATRIX(); ds.ratio = i * 65535 / framesCnt; f.layers.put(1, ds); f.layersChanged = true; - tim.addFrame(f); + timeline.addFrame(f); } } else if (tag instanceof FontTag) { int pageCount = PreviewPanel.getFontPageCount((FontTag) tag); @@ -3317,23 +3318,23 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se frame = 0; } - Frame f = new Frame(tim, 0); + Frame f = new Frame(timeline, 0); DepthState ds = new DepthState(tag.getSwf(), f); ds.characterId = ((CharacterTag) tag).getCharacterId(); ds.matrix = new MATRIX(); f.layers.put(1, ds); f.layersChanged = true; - tim.addFrame(f); - tim.fontFrameNum = frame; + timeline.addFrame(f); + timeline.fontFrameNum = frame; } else { - Frame f = new Frame(tim, 0); + Frame f = new Frame(timeline, 0); DepthState ds = new DepthState(tag.getSwf(), f); ds.characterId = ((CharacterTag) tag).getCharacterId(); ds.matrix = new MATRIX(); f.layers.put(1, ds); - tim.addFrame(f); + timeline.addFrame(f); } - tim.displayRect = getRect(); + timeline.displayRect = getRect(); } @Override diff --git a/src/com/jpexs/decompiler/flash/gui/MyRibbonApplicationMenuButtonUI.java b/src/com/jpexs/decompiler/flash/gui/MyRibbonApplicationMenuButtonUI.java index 5f960a101..6839649a6 100644 --- a/src/com/jpexs/decompiler/flash/gui/MyRibbonApplicationMenuButtonUI.java +++ b/src/com/jpexs/decompiler/flash/gui/MyRibbonApplicationMenuButtonUI.java @@ -85,7 +85,7 @@ public class MyRibbonApplicationMenuButtonUI extends BasicRibbonApplicationMenuB g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); SubstanceSkin skin = SubstanceLookAndFeel.getCurrentSkin(); - g2.setPaint(new RadialGradientPaint(getIconWidth() / 2, getIconHeight() / 2, getIconWidth() / 2, new float[]{0.32f, 0.84f, 1f}, new Color[]{ + g2.setPaint(new RadialGradientPaint(getIconWidth() / 2.0f, getIconHeight() / 2.0f, getIconWidth() / 2.0f, new float[]{0.32f, 0.84f, 1f}, new Color[]{ skin.getColorScheme(DecorationAreaType.SECONDARY_TITLE_PANE, ColorSchemeAssociationKind.HIGHLIGHT, ComponentState.ENABLED).shiftBackground(Color.white, 0.5).getUltraLightColor(), skin.getColorScheme(DecorationAreaType.SECONDARY_TITLE_PANE, ColorSchemeAssociationKind.FILL, ComponentState.ENABLED).getMidColor(), skin.getColorScheme(DecorationAreaType.SECONDARY_TITLE_PANE, ColorSchemeAssociationKind.BORDER, ComponentState.ENABLED).getUltraDarkColor() diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java index ba0f080d4..d534e8e54 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java @@ -586,7 +586,7 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel } public void createAndShowTempSwf(TreeItem tagObj) { - SWF swf; + SWF swf = null; try { if (tempFile != null) { tempFile.delete(); @@ -597,11 +597,13 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel Color backgroundColor = View.getSwfBackgroundColor(); - if (tagObj instanceof FontTag) { //Fonts are always black on white - backgroundColor = View.getDefaultBackgroundColor(); - } - - if (tagObj instanceof Frame) { + if (tagObj instanceof Tag) { + Tag tag = (Tag) tagObj; + swf = tag.getSwf(); + if (tag instanceof FontTag) { //Fonts are always black on white + backgroundColor = View.getDefaultBackgroundColor(); + } + } else if (tagObj instanceof Frame) { Frame fn = (Frame) tagObj; swf = fn.getSwf(); if (fn.timeline.timelined == swf) { @@ -612,9 +614,6 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel } } } - } else { - Tag tag = (Tag) tagObj; - swf = tag.getSwf(); } int frameCount = 1; @@ -714,14 +713,9 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel mat = new MATRIX(); } mat = Helper.deepCopy(mat); - if (parent instanceof BoundedTag) { - RECT r = ((BoundedTag) parent).getRect(); - mat.translateX = mat.translateX + width / 2 - r.getWidth() / 2; - mat.translateY = mat.translateY + height / 2 - r.getHeight() / 2; - } else { - mat.translateX += width / 2; - mat.translateY += height / 2; - } + RECT r = parent.getRect(); + mat.translateX += width / 2 - r.getWidth() / 2; + mat.translateY += height / 2 - r.getHeight() / 2; new PlaceObject2Tag(swf, false, false, false, false, false, true, false, true, depth, chid, mat, null, 0, null, 0, null).writeTag(sos2); } diff --git a/src/com/jpexs/decompiler/flash/gui/controls/JRepeatButton.java b/src/com/jpexs/decompiler/flash/gui/controls/JRepeatButton.java index 089df0bf5..55cd82580 100644 --- a/src/com/jpexs/decompiler/flash/gui/controls/JRepeatButton.java +++ b/src/com/jpexs/decompiler/flash/gui/controls/JRepeatButton.java @@ -40,8 +40,6 @@ public class JRepeatButton extends JButton { public JRepeatButton(String text, ImageIcon icon) { super(text, icon); addMouseListener(new MouseAdapter() { - int counter = 0; - ScheduledFuture future; @Override diff --git a/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java b/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java index e79ceb5b4..ca9d30ea8 100644 --- a/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java +++ b/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java @@ -499,18 +499,18 @@ public class ProxyFrame extends AppFrame implements CatchedListener, MouseListen private void copyUrlButtonActionPerformed(ActionEvent evt) { int[] sel = getSelectedRows(); - String copyText = ""; + StringBuilder copyText = new StringBuilder(); for (int sc : sel) { Replacement r = replacements.get(sc); - if (!copyText.isEmpty()) { - copyText += System.lineSeparator(); + if (copyText.length() > 0) { + copyText.append(System.lineSeparator()); } - copyText += r.urlPattern; + copyText.append(r.urlPattern); } - if (!copyText.isEmpty()) { + if (copyText.length() > 0) { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); - StringSelection stringSelection = new StringSelection(copyText); + StringSelection stringSelection = new StringSelection(copyText.toString()); clipboard.setContents(stringSelection, null); } } diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java index ffd0ea4e4..da5d6108a 100644 --- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java +++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java @@ -370,7 +370,7 @@ public class TagTreeContextMenu extends JPopupMenu { } if (firstItem instanceof Tag) { - rawEditMenuItem.setVisible(firstItem instanceof Tag); + rawEditMenuItem.setVisible(true); } } @@ -565,17 +565,14 @@ public class TagTreeContextMenu extends JPopupMenu { // first add dependencies in reverse order for (int i = neededList.size() - 1; i >= 0; i--) { int characterId = neededList.get(i); - Tag neededTag = (Tag) sourceSwf.getCharacter(characterId); + CharacterTag neededTag = sourceSwf.getCharacter(characterId); if (!copiedTags.contains(neededTag)) { copyTag = neededTag.cloneTag(); copyTag.setSwf(targetSwf, true); targetSwf.tags.add(copyTag); - if (neededTag instanceof CharacterTag) { - CharacterTag characterTag = (CharacterTag) copyTag; - int oldCharacterId = characterTag.getCharacterId(); - int newCharacterId = chechUniqueCharacterId(copyTag); - changedCharacterIds.put(oldCharacterId, newCharacterId); - } + int oldCharacterId = neededTag.getCharacterId(); + int newCharacterId = chechUniqueCharacterId(copyTag); + changedCharacterIds.put(oldCharacterId, newCharacterId); targetSwf.updateCharacters(); targetSwf.getCharacters(); // force rebuild character id cache