avoid throwing EmptyStackExceptions in as2 deobfuscation

This commit is contained in:
2015-08-26 20:50:22 +02:00
parent 5465043ec0
commit 696ee04cb4
104 changed files with 1451 additions and 469 deletions
@@ -175,6 +175,7 @@ public class AVM2DeobfuscatorRegisters extends AVM2DeobfuscatorSimple {
toVisit.add(idx);
List<TranslateStack> 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))
@@ -331,6 +331,7 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
@Override
public void translate(BaseLocalData localData, TranslateStack stack, List<GraphTargetItem> 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);
@@ -711,6 +711,16 @@ public abstract class Action implements GraphSourceItem {
public void translate(TranslateStack stack, List<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> 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<GraphTargetItem> 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
@@ -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));
@@ -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));
@@ -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;
}
}
@@ -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
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
output.add(new CallActionItem(this, stack.pop()));
}
@Override
public int getStackPopCount(BaseLocalData localData, TranslateStack stack) {
return 1;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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<GraphTargetItem> output, HashMap<Integer, String> regNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, int staticOperation, String path) {
stack.push(new GetTimeActionItem(this));
}
@Override
public int getStackPushCount(BaseLocalData localData, TranslateStack stack) {
return 1;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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();
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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) {
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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<GraphTargetItem> 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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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<String>()));
output.add(new EnumerateActionItem(this, object));
}
@Override
public int getStackPopCount(BaseLocalData localData, TranslateStack stack) {
return 1;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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";
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
@@ -25,6 +25,10 @@ public interface GraphSourceItem extends Serializable, Cloneable {
public void translate(BaseLocalData localData, TranslateStack stack, List<GraphTargetItem> 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();
@@ -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;
}
}
@@ -69,6 +69,16 @@ public class TranslateStack extends Stack<GraphTargetItem> {
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) {