From 3508a67fc1b9b844f464873562a8f020c530f67d Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Wed, 4 Nov 2015 07:49:49 +0100 Subject: [PATCH] some AS3 instruction executions implemented --- .../decompiler/flash/abc/avm2/AVM2Code.java | 52 ++++--- ...ction.java => AVM2ExecutionException.java} | 13 +- .../flash/abc/avm2/AVM2Runtime.java | 25 ++++ .../abc/avm2/AVM2TypeErrorException.java | 44 ++++++ .../abc/avm2/AVM2VerifyErrorException.java | 60 ++++++++ .../flash/abc/avm2/LocalDataArea.java | 19 +++ .../instructions/InstructionDefinition.java | 8 +- .../avm2/instructions/UnknownInstruction.java | 38 ++++++ .../avm2/instructions/alchemy/Lf32Ins.java | 11 ++ .../avm2/instructions/alchemy/Lf64Ins.java | 11 ++ .../avm2/instructions/alchemy/Li16Ins.java | 11 ++ .../avm2/instructions/alchemy/Li32Ins.java | 11 ++ .../abc/avm2/instructions/alchemy/Li8Ins.java | 10 ++ .../avm2/instructions/alchemy/Sf32Ins.java | 12 ++ .../avm2/instructions/alchemy/Sf64Ins.java | 12 ++ .../avm2/instructions/alchemy/Si16Ins.java | 12 ++ .../avm2/instructions/alchemy/Si32Ins.java | 12 ++ .../abc/avm2/instructions/alchemy/Si8Ins.java | 12 ++ .../avm2/instructions/alchemy/Sxi16Ins.java | 11 ++ .../avm2/instructions/alchemy/Sxi1Ins.java | 11 ++ .../avm2/instructions/alchemy/Sxi8Ins.java | 11 ++ .../avm2/instructions/arithmetic/AddIns.java | 24 ++-- .../arithmetic/DecrementIIns.java | 16 +-- .../instructions/arithmetic/DecrementIns.java | 16 +-- .../arithmetic/IncrementIIns.java | 10 ++ .../instructions/arithmetic/IncrementIns.java | 10 ++ .../instructions/arithmetic/NegateIIns.java | 10 ++ .../instructions/arithmetic/NegateIns.java | 10 ++ .../avm2/instructions/arithmetic/NotIns.java | 10 ++ .../instructions/arithmetic/SubtractIns.java | 13 ++ .../avm2/instructions/bitwise/BitNotIns.java | 6 +- .../instructions/comparison/EqualsIns.java | 3 +- .../comparison/GreaterEqualsIns.java | 11 ++ .../comparison/GreaterThanIns.java | 11 ++ .../comparison/LessEqualsIns.java | 11 ++ .../instructions/comparison/LessThanIns.java | 11 ++ .../comparison/StrictEqualsIns.java | 12 ++ .../abc/avm2/instructions/jumps/IfEqIns.java | 15 ++ .../avm2/instructions/jumps/IfFalseIns.java | 3 +- .../abc/avm2/instructions/jumps/IfGeIns.java | 15 ++ .../abc/avm2/instructions/jumps/IfGtIns.java | 15 ++ .../abc/avm2/instructions/jumps/IfLeIns.java | 15 ++ .../abc/avm2/instructions/jumps/IfLtIns.java | 15 ++ .../abc/avm2/instructions/jumps/IfNGeIns.java | 15 ++ .../abc/avm2/instructions/jumps/IfNGtIns.java | 15 ++ .../abc/avm2/instructions/jumps/IfNLeIns.java | 15 ++ .../abc/avm2/instructions/jumps/IfNLtIns.java | 15 ++ .../abc/avm2/instructions/jumps/IfNeIns.java | 15 ++ .../instructions/jumps/IfStrictEqIns.java | 15 ++ .../instructions/jumps/IfStrictNeIns.java | 15 ++ .../avm2/instructions/jumps/IfTrueIns.java | 3 +- .../instructions/localregs/DecLocalIIns.java | 16 +-- .../instructions/localregs/DecLocalIns.java | 16 +-- .../instructions/localregs/GetLocal0Ins.java | 8 -- .../instructions/localregs/GetLocal1Ins.java | 8 -- .../instructions/localregs/GetLocal2Ins.java | 8 -- .../instructions/localregs/GetLocal3Ins.java | 8 -- .../instructions/localregs/GetLocalIns.java | 8 -- .../localregs/GetLocalTypeIns.java | 10 ++ .../instructions/localregs/IncLocalIIns.java | 11 ++ .../instructions/localregs/IncLocalIns.java | 11 ++ .../localregs/SetLocalTypeIns.java | 7 + .../instructions/other/GetDescendantsIns.java | 1 - .../instructions/other/GetGlobalScopeIns.java | 1 - .../abc/avm2/instructions/other/ThrowIns.java | 10 ++ .../avm2/instructions/other2/AbsJumpIns.java | 13 ++ .../abc/avm2/instructions/other2/AddDIns.java | 13 ++ .../abc/avm2/instructions/other2/AddPIns.java | 14 ++ .../avm2/instructions/other2/AllocIns.java | 13 ++ .../abc/avm2/instructions/other2/BkptIns.java | 10 ++ .../instructions/other2/CallInterfaceIns.java | 14 ++ .../instructions/other2/CallSuperIdIns.java | 14 ++ .../instructions/other2/CodeGenOpIns.java | 13 ++ .../avm2/instructions/other2/CoerceBIns.java | 9 ++ .../avm2/instructions/other2/CoerceDIns.java | 9 ++ .../avm2/instructions/other2/CoerceIIns.java | 9 ++ .../avm2/instructions/other2/CoerceOIns.java | 15 ++ .../avm2/instructions/other2/CoerceUIns.java | 9 ++ .../avm2/instructions/other2/ConcatIns.java | 13 ++ .../instructions/other2/ConvertF4Ins.java | 13 ++ .../avm2/instructions/other2/ConvertMIns.java | 13 ++ .../instructions/other2/ConvertMPIns.java | 13 ++ .../instructions/other2/DecLocalPIns.java | 14 ++ .../avm2/instructions/other2/DecodeIns.java | 13 ++ .../instructions/other2/DecrementPIns.java | 14 ++ .../other2/DelDescendantsIns.java | 13 ++ .../other2/DeletePropertyLateIns.java | 13 ++ .../avm2/instructions/other2/DividePIns.java | 13 ++ .../instructions/other2/DoubleToAtomIns.java | 13 ++ .../other2/FindPropGlobalIns.java | 13 ++ .../instructions/other2/IncLocalPIns.java | 14 ++ .../instructions/other2/IncrementPIns.java | 14 ++ .../avm2/instructions/other2/InvalidIns.java | 14 ++ .../avm2/instructions/other2/Lf32x4Ins.java | 14 ++ .../abc/avm2/instructions/other2/MarkIns.java | 13 ++ .../avm2/instructions/other2/ModuloPIns.java | 13 ++ .../instructions/other2/MultiplyPIns.java | 13 ++ .../avm2/instructions/other2/NegatePIns.java | 13 ++ .../avm2/instructions/other2/PrologueIns.java | 13 ++ .../instructions/other2/PushConstantIns.java | 13 ++ .../avm2/instructions/other2/PushDNanIns.java | 13 ++ .../instructions/other2/PushDecimalIns.java | 13 ++ .../instructions/other2/PushFloat4Ins.java | 14 ++ .../instructions/other2/SendEnterIns.java | 13 ++ .../other2/SetPropertyLateIns.java | 13 ++ .../avm2/instructions/other2/Sf32x4Ins.java | 14 ++ .../instructions/other2/SubtractPIns.java | 13 ++ .../avm2/instructions/other2/SweepIns.java | 13 ++ .../instructions/other2/TimestampIns.java | 9 ++ .../avm2/instructions/other2/VerifyOpIns.java | 13 ++ .../instructions/other2/VerifyPassIns.java | 13 ++ .../abc/avm2/instructions/other2/WbIns.java | 13 ++ .../avm2/instructions/stack/PushNanIns.java | 8 ++ .../avm2/instructions/stack/PushNullIns.java | 9 ++ .../instructions/stack/PushUndefinedIns.java | 9 ++ .../avm2/instructions/types/CoerceAIns.java | 2 +- .../avm2/instructions/types/CoerceIns.java | 20 ++- .../avm2/instructions/types/ConvertBIns.java | 13 +- .../avm2/instructions/types/ConvertDIns.java | 21 +-- .../avm2/instructions/types/ConvertIIns.java | 19 +-- .../avm2/instructions/types/ConvertUIns.java | 6 +- .../avm2/instructions/types/TypeOfIns.java | 39 ++++++ .../flash/abc/avm2/model/ConvertAVM2Item.java | 4 +- .../abc/avm2/parser/pcode/ASM3Parser.java | 3 +- .../decompiler/flash/ecma/EcmaScript.java | 21 ++- .../decompiler/flash/gui/FlashPlayerTest.java | 128 +++++++++++------- 126 files changed, 1546 insertions(+), 256 deletions(-) rename libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/{instructions/TagInstruction.java => AVM2ExecutionException.java} (69%) create mode 100644 libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Runtime.java create mode 100644 libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2TypeErrorException.java create mode 100644 libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2VerifyErrorException.java create mode 100644 libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/UnknownInstruction.java diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java index 23fb81c54..e225317c2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Code.java @@ -32,6 +32,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.instructions.DeobfuscatePopIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.instructions.UnknownInstruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Lf32Ins; import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Lf64Ins; import com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy.Li16Ins; @@ -275,6 +276,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Traits; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.dumpview.DumpInfo; import com.jpexs.decompiler.flash.ecma.EcmaScript; +import com.jpexs.decompiler.flash.ecma.Undefined; import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter; @@ -372,7 +374,7 @@ public class AVM2Code implements Cloneable { public static final int DAT_DECIMAL_PARAMS = OPT_U30 + 0x13; - public static InstructionDefinition[] instructionSet = new InstructionDefinition[]{ + public static final InstructionDefinition[] instructionSet = new InstructionDefinition[]{ /*0x00*/null, /*0x01*/ new BkptIns(), /*0x02*/ new NopIns(), @@ -633,6 +635,14 @@ public class AVM2Code implements Cloneable { /*0xFF*/ new DecodeIns(),}; // endoflist + static { + for (int i = 0; i < instructionSet.length; i++) { + if (instructionSet[i] == null) { + instructionSet[i] = new UnknownInstruction(i); + } + } + } + public boolean hideTemporaryRegisters = true; public static final String IDENTOPEN = "/*IDENTOPEN*/"; @@ -642,32 +652,40 @@ public class AVM2Code implements Cloneable { public AVM2Code() { } - public Object execute(HashMap arguments, AVM2ConstantPool constants) { + public Object execute(HashMap arguments, AVM2ConstantPool constants) throws AVM2ExecutionException { + return execute(arguments, constants, AVM2Runtime.UNKNOWN, 0); + } + + public Object execute(HashMap arguments, AVM2ConstantPool constants, AVM2Runtime runtime, int runtimeVersoin) throws AVM2ExecutionException { int pos = 0; LocalDataArea lda = new LocalDataArea(); + lda.methodName = "methodName"; // todo: needed for VerifyError exception message lda.localRegisters = arguments; - try { - while (pos < code.size()) { - AVM2Instruction ins = code.get(pos); - ins.definition.execute(lda, constants, ins); + lda.runtime = runtime; + lda.runtimeVersion = runtimeVersoin; + while (pos < code.size()) { + AVM2Instruction ins = code.get(pos); + if (!ins.definition.execute(lda, constants, ins)) { + return null; + } - if (lda.jump != null) { + if (lda.jump != null) { + try { pos = adr2pos(lda.jump); - lda.jump = null; - } else { - pos++; + } catch (ConvertException ex) { + throw new AVM2VerifyErrorException(AVM2VerifyErrorException.BRANCH_TARGET_INVALID_INSTRUCTION); } - - if (lda.returnValue != null) { - return lda.returnValue; - } - + lda.jump = null; + } else { pos++; } - } catch (ConvertException e) { + + if (lda.returnValue != null) { + return lda.returnValue; + } } - return null; + return Undefined.INSTANCE; } public void calculateDebugFileLine(ABC abc) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/TagInstruction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ExecutionException.java similarity index 69% rename from libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/TagInstruction.java rename to libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ExecutionException.java index a0a527233..4b6d1542a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/TagInstruction.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2ExecutionException.java @@ -12,19 +12,16 @@ * 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.abc.avm2.instructions; + * License along with this library. */ +package com.jpexs.decompiler.flash.abc.avm2; /** * * @author JPEXS */ -public class TagInstruction extends InstructionDefinition { +public class AVM2ExecutionException extends Exception { - public static final long serialVersionUID = 1L; - - public TagInstruction(String tagName) { - super(-1, tagName, new int[0], false /*?*/); + public AVM2ExecutionException(String message) { + super(message); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Runtime.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Runtime.java new file mode 100644 index 000000000..d089c5128 --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2Runtime.java @@ -0,0 +1,25 @@ +/* + * 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.abc.avm2; + +/** + * + * @author JPEXS + */ +public enum AVM2Runtime { + + UNKNOWN, ADOBE_FLASH +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2TypeErrorException.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2TypeErrorException.java new file mode 100644 index 000000000..ca9a9758c --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2TypeErrorException.java @@ -0,0 +1,44 @@ +/* + * 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.abc.avm2; + +/** + * + * @author JPEXS + */ +public class AVM2TypeErrorException extends AVM2ExecutionException { + + public AVM2TypeErrorException(int code) { + super(codeToMessage(code, null)); + } + + public AVM2TypeErrorException(int code, Object[] params) { + super(codeToMessage(code, params)); + } + + private static String codeToMessage(int code, Object[] params) { + String msg = null; + switch (code) { + } + + String result = "TypeError: Error #" + code; + /*if (msg != null) { + result += ": " + msg; + }*/ + + return result; + } +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2VerifyErrorException.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2VerifyErrorException.java new file mode 100644 index 000000000..190ab13b4 --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/AVM2VerifyErrorException.java @@ -0,0 +1,60 @@ +/* + * 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.abc.avm2; + +/** + * + * @author JPEXS + */ +public class AVM2VerifyErrorException extends AVM2ExecutionException { + + public static final int ILLEGAL_OPCODE = 1011; + + public static final int BRANCH_TARGET_INVALID_INSTRUCTION = 1021; + + public AVM2VerifyErrorException(int code) { + super(codeToMessage(code, null)); + } + + public AVM2VerifyErrorException(int code, Object[] params) { + super(codeToMessage(code, params)); + } + + private static String codeToMessage(int code, Object[] params) { + String msg = null; + switch (code) { + case ILLEGAL_OPCODE: + msg = "Method " + params[0] + " contained illegal opcode " + params[1] + " at offset " + params[2] + "."; + break; + case 1014: + msg = "class could not be found"; + break; + case 1021: + msg = "At least one branch target was not on a valid instruction in the method."; + break; + case 1030: + msg = "Stack depth is unbalanced"; + break; + } + + String result = "VerifyError: Error #" + code; + /*if (msg != null) { + result += ": " + msg; + }*/ + + return result; + } +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/LocalDataArea.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/LocalDataArea.java index f04fd44eb..b689c43cb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/LocalDataArea.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/LocalDataArea.java @@ -21,6 +21,8 @@ import java.util.Stack; public class LocalDataArea { + public String methodName; + public Stack operandStack = new Stack<>(); public Stack scopeStack = new Stack<>(); @@ -33,6 +35,23 @@ public class LocalDataArea { public String executionException; + public AVM2Runtime runtime; + + public int runtimeVersion; + + private byte[] domainMemory; + + public LocalDataArea() { + } + + public byte[] getDomainMemory() { + if (domainMemory == null) { + domainMemory = new byte[1024 * 1024]; + } + + return domainMemory; + } + public void clear() { operandStack.clear(); scopeStack.clear(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java index 73e76ffbd..4600f2614 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/InstructionDefinition.java @@ -20,6 +20,8 @@ import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2VerifyErrorException; import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.DecLocalIIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.localregs.DecLocalIns; @@ -87,11 +89,15 @@ public abstract class InstructionDefinition implements Serializable { return s.toString(); } - public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { //throw new UnsupportedOperationException("Instruction " + instructionName + " not implemented"); return false; } + protected void illegalOpCode(LocalDataArea lda, AVM2Instruction ins) throws AVM2VerifyErrorException { + throw new AVM2VerifyErrorException(AVM2VerifyErrorException.ILLEGAL_OPCODE, new Object[]{lda.methodName, instructionCode, ins.getOffset()}); + } + public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) throws InterruptedException { } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/UnknownInstruction.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/UnknownInstruction.java new file mode 100644 index 000000000..ffb0f4d8b --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/UnknownInstruction.java @@ -0,0 +1,38 @@ +/* + * 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.abc.avm2.instructions; + +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; + +/** + * + * @author JPEXS + */ +public class UnknownInstruction extends InstructionDefinition { + + public UnknownInstruction(int instructionCode) { + super(instructionCode, "instruction_" + Integer.toString(instructionCode), new int[0], false); + } + + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + illegalOpCode(lda, ins); + return false; + } +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Lf32Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Lf32Ins.java index 23612b3c8..45bfe2e29 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Lf32Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Lf32Ins.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -35,6 +38,14 @@ public class Lf32Ins extends InstructionDefinition implements AlchemyTypeIns { super(0x38, "lf32", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + int addr = (int) (double) EcmaScript.toNumber(lda.operandStack.pop()); + // todo: get 32 bits float + lda.operandStack.push((Double) (double) (lda.getDomainMemory()[addr])); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem ofs = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Lf64Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Lf64Ins.java index f230efaf4..c186dbd0d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Lf64Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Lf64Ins.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -35,6 +38,14 @@ public class Lf64Ins extends InstructionDefinition implements AlchemyTypeIns { super(0x39, "lf64", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + int addr = (int) (double) EcmaScript.toNumber(lda.operandStack.pop()); + // todo: get 64 bits float + lda.operandStack.push((Double) (double) (lda.getDomainMemory()[addr])); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem ofs = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li16Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li16Ins.java index 0db8cfc3f..af2c0a625 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li16Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li16Ins.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -35,6 +38,14 @@ public class Li16Ins extends InstructionDefinition implements AlchemyTypeIns { super(0x36, "li16", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + int addr = (int) (double) EcmaScript.toNumber(lda.operandStack.pop()); + // todo: get 16 bits + lda.operandStack.push((Double) (double) (lda.getDomainMemory()[addr])); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem ofs = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li32Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li32Ins.java index 507820bdd..6a36230dd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li32Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li32Ins.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -35,6 +38,14 @@ public class Li32Ins extends InstructionDefinition implements AlchemyTypeIns { super(0x37, "li32", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + int addr = (int) (double) EcmaScript.toNumber(lda.operandStack.pop()); + // todo: get 32 bits + lda.operandStack.push((Double) (double) (lda.getDomainMemory()[addr])); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem ofs = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li8Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li8Ins.java index 6284d0ff6..488199e50 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li8Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Li8Ins.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyLoadAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -35,6 +38,13 @@ public class Li8Ins extends InstructionDefinition implements AlchemyTypeIns { super(0x35, "li8", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + int addr = (int) (double) EcmaScript.toNumber(lda.operandStack.pop()); + lda.operandStack.push((Double) (double) (lda.getDomainMemory()[addr])); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem ofs = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sf32Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sf32Ins.java index 5fd42a7eb..392f9ce5f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sf32Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sf32Ins.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -35,6 +38,15 @@ public class Sf32Ins extends InstructionDefinition implements AlchemyTypeIns { super(0x3D, "sf32", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double value = (double) EcmaScript.toNumber(lda.operandStack.pop()); + int addr = (int) (double) EcmaScript.toNumber(lda.operandStack.pop()); + // todo: set domainMemory + //lda.getDomainMemory()[addr] = ... + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem ofs = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sf64Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sf64Ins.java index 02611f994..7d15fef35 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sf64Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sf64Ins.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -35,6 +38,15 @@ public class Sf64Ins extends InstructionDefinition implements AlchemyTypeIns { super(0x3E, "sf64", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double value = (double) EcmaScript.toNumber(lda.operandStack.pop()); + int addr = (int) (double) EcmaScript.toNumber(lda.operandStack.pop()); + // todo: set domainMemory + //lda.getDomainMemory()[addr] = ... + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem ofs = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si16Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si16Ins.java index 0c76adba5..ec95845d8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si16Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si16Ins.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -35,6 +38,15 @@ public class Si16Ins extends InstructionDefinition implements AlchemyTypeIns { super(0x3B, "si16", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double value = (double) EcmaScript.toNumber(lda.operandStack.pop()); + int addr = (int) (double) EcmaScript.toNumber(lda.operandStack.pop()); + // todo: set domainMemory + //lda.getDomainMemory()[addr] = ... + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem ofs = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si32Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si32Ins.java index 15f5e51e7..8cac96114 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si32Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si32Ins.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -35,6 +38,15 @@ public class Si32Ins extends InstructionDefinition implements AlchemyTypeIns { super(0x3C, "si32", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double value = (double) EcmaScript.toNumber(lda.operandStack.pop()); + int addr = (int) (double) EcmaScript.toNumber(lda.operandStack.pop()); + // todo: set domainMemory + //lda.getDomainMemory()[addr] = ... + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem ofs = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si8Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si8Ins.java index 75d015a57..fc8235118 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si8Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Si8Ins.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.AlchemyStoreAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -35,6 +38,15 @@ public class Si8Ins extends InstructionDefinition implements AlchemyTypeIns { super(0x3A, "si8", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double value = (double) EcmaScript.toNumber(lda.operandStack.pop()); + int addr = (int) (double) EcmaScript.toNumber(lda.operandStack.pop()); + // todo: set domainMemory + //lda.getDomainMemory()[addr] = ... + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem ofs = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi16Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi16Ins.java index 571c8b3cb..ae1ca23db 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi16Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi16Ins.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.AlchemySignExtendAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -35,6 +38,14 @@ public class Sxi16Ins extends InstructionDefinition implements AlchemyTypeIns { super(0x52, "sxi16", new int[]{}, false); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double value = (double) (((int) (double) EcmaScript.toNumber(lda.operandStack.pop())) & 0xffff); + // todo: extend value to 32 bits + lda.operandStack.push(value); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem value = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi1Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi1Ins.java index c4e938fa6..f59fdb5ae 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi1Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi1Ins.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.AlchemySignExtendAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -35,6 +38,14 @@ public class Sxi1Ins extends InstructionDefinition implements AlchemyTypeIns { super(0x50, "sxi1", new int[]{}, false); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double value = (double) (((int) (double) EcmaScript.toNumber(lda.operandStack.pop())) & 1); + // todo: extend value to 32 bits + lda.operandStack.push(value); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem value = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi8Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi8Ins.java index bebfcf4cd..cacc08159 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi8Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/alchemy/Sxi8Ins.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.alchemy; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.AlchemySignExtendAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -35,6 +38,14 @@ public class Sxi8Ins extends InstructionDefinition implements AlchemyTypeIns { super(0x51, "sxi8", new int[]{}, false); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double value = (double) (((int) (double) EcmaScript.toNumber(lda.operandStack.pop())) & 0xff); + // todo: extend value to 32 bits + lda.operandStack.push(value); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem value = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java index f91995a73..65fa86c3f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIns.java @@ -23,6 +23,8 @@ import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; +import com.jpexs.decompiler.flash.ecma.EcmaType; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -35,24 +37,16 @@ public class AddIns extends InstructionDefinition { @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - Object o1 = lda.operandStack.pop(); - Object o2 = lda.operandStack.pop(); - if ((o1 instanceof Long) && ((o2 instanceof Long))) { - Long ret = ((Long) o1) + ((Long) o2); - lda.operandStack.push(ret); - } else if ((o1 instanceof Double) && ((o2 instanceof Double))) { - Double ret = ((Double) o1) + ((Double) o2); - lda.operandStack.push(ret); - } else if ((o1 instanceof Long) && ((o2 instanceof Double))) { - Double ret = ((Long) o1) + ((Double) o2); - lda.operandStack.push(ret); - } else if ((o1 instanceof Double) && ((o2 instanceof Long))) { - Double ret = ((Double) o1) + ((Long) o2); + Object right = lda.operandStack.pop(); + Object left = lda.operandStack.pop(); + if (EcmaScript.type(left) == EcmaType.STRING || EcmaScript.type(right) == EcmaType.STRING) { + String ret = EcmaScript.toString(left) + EcmaScript.toString(right); lda.operandStack.push(ret); } else { - String s = o1.toString() + o2.toString(); - lda.operandStack.push(s); + Double ret = EcmaScript.toNumber(left) + EcmaScript.toNumber(right); + lda.operandStack.push(ret); } + return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java index aa7f916a2..158c94b88 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIIns.java @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.DecrementAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -36,20 +37,7 @@ public class DecrementIIns extends InstructionDefinition { @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { Object obj = lda.operandStack.pop(); - if (obj instanceof Long) { - Long obj2 = ((Long) obj) - 1; - lda.operandStack.push(obj2); - } else if (obj instanceof Double) { - Double obj2 = ((Double) obj) - 1; - lda.operandStack.push(obj2); - } - if (obj instanceof String) { - Double obj2 = Double.parseDouble((String) obj) - 1; - lda.operandStack.push(obj2); - } else { - lda.executionException = "Cannot decrement local register"; - return false; - } + lda.operandStack.push(EcmaScript.toNumber(obj) - 1); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java index c586a3306..c37677f15 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/DecrementIns.java @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.DecrementAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -36,20 +37,7 @@ public class DecrementIns extends InstructionDefinition { @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { Object obj = lda.operandStack.pop(); - if (obj instanceof Long) { - Long obj2 = ((Long) obj) - 1; - lda.operandStack.push(obj2); - } else if (obj instanceof Double) { - Double obj2 = ((Double) obj) - 1; - lda.operandStack.push(obj2); - } - if (obj instanceof String) { - Double obj2 = Double.parseDouble((String) obj) - 1; - lda.operandStack.push(obj2); - } else { - lda.executionException = "Cannot decrement local register"; - return false; - } + lda.operandStack.push(EcmaScript.toInt32(obj) - 1); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIIns.java index cabc723b2..2f6e6d111 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIIns.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.IncrementAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -31,6 +34,13 @@ public class IncrementIIns extends InstructionDefinition { super(0xc0, "increment_i", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Object obj = lda.operandStack.pop(); + lda.operandStack.push(EcmaScript.toInt32(obj) + 1); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { stack.push(new IncrementAVM2Item(ins, stack.pop())); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIns.java index d5a9b9789..fb046ccbb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/IncrementIns.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.IncrementAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -31,6 +34,13 @@ public class IncrementIns extends InstructionDefinition { super(0x91, "increment", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Object obj = lda.operandStack.pop(); + lda.operandStack.push(EcmaScript.toNumber(obj) + 1); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { stack.push(new IncrementAVM2Item(ins, stack.pop())); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIIns.java index 17242c788..4f450e1f9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIIns.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.NegAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -31,6 +34,13 @@ public class NegateIIns extends InstructionDefinition { super(0xc4, "negate_i", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Object value = lda.operandStack.pop(); + lda.operandStack.push(-EcmaScript.toInt32(value)); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIns.java index e16b1e6ab..47c8e9757 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NegateIns.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.NegAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -31,6 +34,13 @@ public class NegateIns extends InstructionDefinition { super(0x90, "negate", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Object value = lda.operandStack.pop(); + lda.operandStack.push(-EcmaScript.toNumber(value)); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NotIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NotIns.java index 84d8a7bf4..09ad81ce8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NotIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/NotIns.java @@ -18,8 +18,11 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -30,6 +33,13 @@ public class NotIns extends InstructionDefinition { super(0x96, "not", new int[]{}, false); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + boolean value = EcmaScript.toBoolean(lda.operandStack.pop()); + lda.operandStack.push(!value); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIns.java index 3b7dcc9c4..c04150d7e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/SubtractIns.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.arithmetic; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -31,6 +34,16 @@ public class SubtractIns extends InstructionDefinition { super(0xa1, "subtract", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Object right = lda.operandStack.pop(); + Object left = lda.operandStack.pop(); + Double ret = EcmaScript.toNumber(left) - EcmaScript.toNumber(right); + lda.operandStack.push(ret); + + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java index 791d8f098..22a1fcee4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitNotIns.java @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.BitNotAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -35,9 +36,8 @@ public class BitNotIns extends InstructionDefinition { @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - Long value = (Long) lda.operandStack.pop(); - Long ret = -value; - lda.operandStack.push(ret); + int value = EcmaScript.toInt32(lda.operandStack.pop()); + lda.operandStack.push(~value); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/EqualsIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/EqualsIns.java index 98411405d..3c8ec7a34 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/EqualsIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/EqualsIns.java @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.EqAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -37,7 +38,7 @@ public class EqualsIns extends InstructionDefinition { public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { Object obj1 = lda.operandStack.pop(); Object obj2 = lda.operandStack.pop(); - Boolean res = obj1.equals(obj2); + boolean res = EcmaScript.equals(obj1, obj2); lda.operandStack.push(res); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterEqualsIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterEqualsIns.java index 0891f944b..2ac856718 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterEqualsIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterEqualsIns.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -31,6 +34,14 @@ public class GreaterEqualsIns extends InstructionDefinition { super(0xb0, "greaterequals", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double right = EcmaScript.toNumber(lda.operandStack.pop()); + Double left = EcmaScript.toNumber(lda.operandStack.pop()); + lda.operandStack.push(left >= right); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterThanIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterThanIns.java index 8a5e6145f..5112f0abb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterThanIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/GreaterThanIns.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -31,6 +34,14 @@ public class GreaterThanIns extends InstructionDefinition { super(0xaf, "greaterthan", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double right = EcmaScript.toNumber(lda.operandStack.pop()); + Double left = EcmaScript.toNumber(lda.operandStack.pop()); + lda.operandStack.push(left > right); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessEqualsIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessEqualsIns.java index 86321dfcb..4207c2534 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessEqualsIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessEqualsIns.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -31,6 +34,14 @@ public class LessEqualsIns extends InstructionDefinition { super(0xae, "lessequals", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double right = EcmaScript.toNumber(lda.operandStack.pop()); + Double left = EcmaScript.toNumber(lda.operandStack.pop()); + lda.operandStack.push(left <= right); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessThanIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessThanIns.java index c7e136c90..2773e9683 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessThanIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/LessThanIns.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -31,6 +34,14 @@ public class LessThanIns extends InstructionDefinition { super(0xad, "lessthan", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double right = EcmaScript.toNumber(lda.operandStack.pop()); + Double left = EcmaScript.toNumber(lda.operandStack.pop()); + lda.operandStack.push(left < right); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/StrictEqualsIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/StrictEqualsIns.java index 576d8166d..d2e5e19a6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/StrictEqualsIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/comparison/StrictEqualsIns.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.comparison; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictEqAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -31,6 +34,15 @@ public class StrictEqualsIns extends InstructionDefinition { super(0xac, "strictequals", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Object obj1 = lda.operandStack.pop(); + Object obj2 = lda.operandStack.pop(); + boolean res = EcmaScript.strictEquals(obj1, obj2); + lda.operandStack.push(res); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfEqIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfEqIns.java index 0c1c4bfc2..2db2c36f9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfEqIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfEqIns.java @@ -19,11 +19,14 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.EqAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.operations.NeqAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; @@ -35,6 +38,18 @@ public class IfEqIns extends InstructionDefinition implements IfTypeIns { super(0x13, "ifeq", new int[]{AVM2Code.DAT_OFFSET}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double right = EcmaScript.toNumber(lda.operandStack.pop()); + Double left = EcmaScript.toNumber(lda.operandStack.pop()); + + if (left == right) { + lda.jump = ins.getParamAsLong(constants, 0); + } + + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfFalseIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfFalseIns.java index 9c65842ce..c9b0eaf47 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfFalseIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfFalseIns.java @@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; @@ -37,7 +38,7 @@ public class IfFalseIns extends InstructionDefinition implements IfTypeIns { @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - Boolean b = (Boolean) lda.operandStack.pop(); + boolean b = EcmaScript.toBoolean(lda.operandStack.pop()); if (b == false) { lda.jump = ins.getParamAsLong(constants, 0); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGeIns.java index c7d2d9f8c..dd33f2a54 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGeIns.java @@ -19,11 +19,14 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; @@ -35,6 +38,18 @@ public class IfGeIns extends InstructionDefinition implements IfTypeIns { super(0x18, "ifge", new int[]{AVM2Code.DAT_OFFSET}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double right = EcmaScript.toNumber(lda.operandStack.pop()); + Double left = EcmaScript.toNumber(lda.operandStack.pop()); + + if (left >= right) { + lda.jump = ins.getParamAsLong(constants, 0); + } + + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGtIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGtIns.java index 6c2137c42..7af0f20ac 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGtIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfGtIns.java @@ -19,11 +19,14 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; @@ -35,6 +38,18 @@ public class IfGtIns extends InstructionDefinition implements IfTypeIns { super(0x17, "ifgt", new int[]{AVM2Code.DAT_OFFSET}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double right = EcmaScript.toNumber(lda.operandStack.pop()); + Double left = EcmaScript.toNumber(lda.operandStack.pop()); + + if (left > right) { + lda.jump = ins.getParamAsLong(constants, 0); + } + + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLeIns.java index acc285452..94ed1bc62 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLeIns.java @@ -19,11 +19,14 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; @@ -35,6 +38,18 @@ public class IfLeIns extends InstructionDefinition implements IfTypeIns { super(0x16, "ifle", new int[]{AVM2Code.DAT_OFFSET}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double right = EcmaScript.toNumber(lda.operandStack.pop()); + Double left = EcmaScript.toNumber(lda.operandStack.pop()); + + if (left <= right) { + lda.jump = ins.getParamAsLong(constants, 0); + } + + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLtIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLtIns.java index 6062a3f67..c713e2592 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLtIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfLtIns.java @@ -19,11 +19,14 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; @@ -35,6 +38,18 @@ public class IfLtIns extends InstructionDefinition implements IfTypeIns { super(0x15, "iflt", new int[]{AVM2Code.DAT_OFFSET}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double right = EcmaScript.toNumber(lda.operandStack.pop()); + Double left = EcmaScript.toNumber(lda.operandStack.pop()); + + if (left < right) { + lda.jump = ins.getParamAsLong(constants, 0); + } + + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGeIns.java index b700d0a7c..0c632f238 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGeIns.java @@ -19,11 +19,14 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; @@ -35,6 +38,18 @@ public class IfNGeIns extends InstructionDefinition implements IfTypeIns { super(0x0f, "ifnge", new int[]{AVM2Code.DAT_OFFSET}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double right = EcmaScript.toNumber(lda.operandStack.pop()); + Double left = EcmaScript.toNumber(lda.operandStack.pop()); + + if (!(left >= right)) { + lda.jump = ins.getParamAsLong(constants, 0); + } + + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGtIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGtIns.java index abb2d4813..50e1f6a0f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGtIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNGtIns.java @@ -19,11 +19,14 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; @@ -35,6 +38,18 @@ public class IfNGtIns extends InstructionDefinition implements IfTypeIns { super(0x0e, "ifngt", new int[]{AVM2Code.DAT_OFFSET}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double right = EcmaScript.toNumber(lda.operandStack.pop()); + Double left = EcmaScript.toNumber(lda.operandStack.pop()); + + if (!(left > right)) { + lda.jump = ins.getParamAsLong(constants, 0); + } + + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLeIns.java index b522cf3fe..aaecf89cb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLeIns.java @@ -19,11 +19,14 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.GtAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.operations.LeAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; @@ -35,6 +38,18 @@ public class IfNLeIns extends InstructionDefinition implements IfTypeIns { super(0x0d, "ifnle", new int[]{AVM2Code.DAT_OFFSET}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double right = EcmaScript.toNumber(lda.operandStack.pop()); + Double left = EcmaScript.toNumber(lda.operandStack.pop()); + + if (!(left <= right)) { + lda.jump = ins.getParamAsLong(constants, 0); + } + + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLtIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLtIns.java index d38245ddb..80f5f12e7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLtIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNLtIns.java @@ -19,11 +19,14 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.GeAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.operations.LtAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; @@ -35,6 +38,18 @@ public class IfNLtIns extends InstructionDefinition implements IfTypeIns { super(0x0c, "ifnlt", new int[]{AVM2Code.DAT_OFFSET}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double right = EcmaScript.toNumber(lda.operandStack.pop()); + Double left = EcmaScript.toNumber(lda.operandStack.pop()); + + if (!(left < right)) { + lda.jump = ins.getParamAsLong(constants, 0); + } + + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNeIns.java index 8e4623aec..65da1e8f3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfNeIns.java @@ -19,11 +19,14 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.EqAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.operations.NeqAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; @@ -35,6 +38,18 @@ public class IfNeIns extends InstructionDefinition implements IfTypeIns { super(0x14, "ifne", new int[]{AVM2Code.DAT_OFFSET}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Double right = EcmaScript.toNumber(lda.operandStack.pop()); + Double left = EcmaScript.toNumber(lda.operandStack.pop()); + + if (left != right) { + lda.jump = ins.getParamAsLong(constants, 0); + } + + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictEqIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictEqIns.java index 06e5b2cbb..6beaa0142 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictEqIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictEqIns.java @@ -19,11 +19,14 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictEqAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictNeqAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; @@ -35,6 +38,18 @@ public class IfStrictEqIns extends InstructionDefinition implements IfTypeIns { super(0x19, "ifstricteq", new int[]{AVM2Code.DAT_OFFSET}, false); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Object rightObj = lda.operandStack.pop(); + Object leftObj = lda.operandStack.pop(); + + if (EcmaScript.strictEquals(leftObj, rightObj)) { + lda.jump = ins.getParamAsLong(constants, 0); + } + + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictNeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictNeIns.java index 9114b4da8..497a536dd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictNeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfStrictNeIns.java @@ -19,11 +19,14 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.jumps; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictEqAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictNeqAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; @@ -35,6 +38,18 @@ public class IfStrictNeIns extends InstructionDefinition implements IfTypeIns { super(0x1A, "ifstrictne", new int[]{AVM2Code.DAT_OFFSET}, false); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Object rightObj = lda.operandStack.pop(); + Object leftObj = lda.operandStack.pop(); + + if (!EcmaScript.strictEquals(leftObj, rightObj)) { + lda.jump = ins.getParamAsLong(constants, 0); + } + + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { GraphTargetItem v2 = stack.pop(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfTrueIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfTrueIns.java index 9a0787cb2..c2491ab3e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfTrueIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/jumps/IfTrueIns.java @@ -24,6 +24,7 @@ import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.HashMap; @@ -37,7 +38,7 @@ public class IfTrueIns extends InstructionDefinition implements IfTypeIns { @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - Boolean b = (Boolean) lda.operandStack.pop(); + boolean b = EcmaScript.toBoolean(lda.operandStack.pop()); if (b == true) { lda.jump = ins.getParamAsLong(constants, 0); } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java index 2db468c84..e7acea172 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIIns.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.DecLocalAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -39,20 +40,7 @@ public class DecLocalIIns extends InstructionDefinition { public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { int locRegIndex = ins.getParamAsLong(constants, 0).intValue(); Object obj = lda.localRegisters.get(locRegIndex); - if (obj instanceof Long) { - Long obj2 = ((Long) obj) - 1; - lda.localRegisters.put(locRegIndex, obj2); - } else if (obj instanceof Double) { - Double obj2 = ((Double) obj) - 1; - lda.localRegisters.put(locRegIndex, obj2); - } - if (obj instanceof String) { - Double obj2 = Double.parseDouble((String) obj) - 1; - lda.localRegisters.put(locRegIndex, obj2); - } else { - lda.executionException = "Cannot decrement local register"; - return false; - } + lda.localRegisters.put(locRegIndex, EcmaScript.toInt32(obj) - 1); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java index a4059a614..d4b6ee7ac 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/DecLocalIns.java @@ -25,6 +25,7 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.DecLocalAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -39,20 +40,7 @@ public class DecLocalIns extends InstructionDefinition { public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { int locRegIndex = ins.getParamAsLong(constants, 0).intValue(); Object obj = lda.localRegisters.get(locRegIndex); - if (obj instanceof Long) { - Long obj2 = ((Long) obj) - 1; - lda.localRegisters.put(locRegIndex, obj2); - } else if (obj instanceof Double) { - Double obj2 = ((Double) obj) - 1; - lda.localRegisters.put(locRegIndex, obj2); - } - if (obj instanceof String) { - Double obj2 = Double.parseDouble((String) obj) - 1; - lda.localRegisters.put(locRegIndex, obj2); - } else { - lda.executionException = "Cannot decrement local register"; - return false; - } + lda.localRegisters.put(locRegIndex, EcmaScript.toNumber(obj) - 1); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java index cf0046f04..348ab04d1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal0Ins.java @@ -16,8 +16,6 @@ */ package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; -import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; public class GetLocal0Ins extends GetLocalTypeIns { @@ -26,12 +24,6 @@ public class GetLocal0Ins extends GetLocalTypeIns { super(0xd0, "getlocal_0", new int[]{}, false); } - @Override - public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - lda.operandStack.push(lda.localRegisters.get(0)); - return true; - } - @Override public int getRegisterId(AVM2Instruction par0) { return 0; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal1Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal1Ins.java index 8a102715a..d44728dc4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal1Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal1Ins.java @@ -16,8 +16,6 @@ */ package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; -import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; public class GetLocal1Ins extends GetLocalTypeIns { @@ -26,12 +24,6 @@ public class GetLocal1Ins extends GetLocalTypeIns { super(0xd1, "getlocal_1", new int[]{}, false); } - @Override - public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - lda.operandStack.push(lda.localRegisters.get(1)); - return true; - } - @Override public int getRegisterId(AVM2Instruction par0) { return 1; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal2Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal2Ins.java index 12dd782d3..7972e4aa7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal2Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal2Ins.java @@ -16,8 +16,6 @@ */ package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; -import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; public class GetLocal2Ins extends GetLocalTypeIns { @@ -26,12 +24,6 @@ public class GetLocal2Ins extends GetLocalTypeIns { super(0xd2, "getlocal_2", new int[]{}, false); } - @Override - public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - lda.operandStack.push(lda.localRegisters.get(2)); - return true; - } - @Override public int getRegisterId(AVM2Instruction par0) { return 2; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal3Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal3Ins.java index 605295356..e9021c3c2 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal3Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocal3Ins.java @@ -16,8 +16,6 @@ */ package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; -import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; public class GetLocal3Ins extends GetLocalTypeIns { @@ -26,12 +24,6 @@ public class GetLocal3Ins extends GetLocalTypeIns { super(0xd3, "getlocal_3", new int[]{}, false); } - @Override - public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - lda.operandStack.push(lda.localRegisters.get(3)); - return true; - } - @Override public int getRegisterId(AVM2Instruction par0) { return 3; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalIns.java index 149bd9c47..be0cca6cf 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalIns.java @@ -17,8 +17,6 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; -import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; -import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; public class GetLocalIns extends GetLocalTypeIns { @@ -27,12 +25,6 @@ public class GetLocalIns extends GetLocalTypeIns { super(0x62, "getlocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}, false); } - @Override - public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - lda.operandStack.push(lda.localRegisters.get(ins.getParamAsLong(constants, 0).intValue())); - return true; - } - @Override public int getRegisterId(AVM2Instruction ins) { return ins.operands[0]; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java index bfe0af14c..a81ce8053 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/GetLocalTypeIns.java @@ -18,12 +18,15 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.ClassAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.ScriptAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.ThisAVM2Item; +import com.jpexs.decompiler.flash.ecma.Undefined; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.NotCompileTimeItem; import com.jpexs.decompiler.graph.TranslateStack; @@ -35,6 +38,13 @@ public abstract class GetLocalTypeIns extends InstructionDefinition { super(instructionCode, instructionName, operands, canThrow); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Object value = lda.localRegisters.get(getRegisterId(ins)); + lda.operandStack.push(value == null ? Undefined.INSTANCE : value); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java index abf49ab89..d08c202a9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIIns.java @@ -18,11 +18,14 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; import com.jpexs.decompiler.flash.abc.AVM2LocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.IncLocalAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -33,6 +36,14 @@ public class IncLocalIIns extends InstructionDefinition { super(0xc2, "inclocal_i", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + int locRegIndex = ins.getParamAsLong(constants, 0).intValue(); + Object obj = lda.localRegisters.get(locRegIndex); + lda.localRegisters.put(locRegIndex, EcmaScript.toInt32(obj) + 1); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int regId = ins.operands[0]; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java index c180702ed..fb735040e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/IncLocalIns.java @@ -18,11 +18,14 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; import com.jpexs.decompiler.flash.abc.AVM2LocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.IncLocalAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -33,6 +36,14 @@ public class IncLocalIns extends InstructionDefinition { super(0x92, "inclocal", new int[]{AVM2Code.DAT_LOCAL_REG_INDEX}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + int locRegIndex = ins.getParamAsLong(constants, 0).intValue(); + Object obj = lda.localRegisters.get(locRegIndex); + lda.localRegisters.put(locRegIndex, EcmaScript.toNumber(obj) - 1); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int regId = ins.operands[0]; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java index b898669b0..a4699b584 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/localregs/SetLocalTypeIns.java @@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.localregs; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.instructions.SetTypeIns; @@ -47,6 +48,12 @@ public abstract class SetLocalTypeIns extends InstructionDefinition implements S super(instructionCode, instructionName, operands, canThrow); } + @Override + public boolean execute(com.jpexs.decompiler.flash.abc.avm2.LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + lda.localRegisters.put(getRegisterId(ins), lda.operandStack.pop()); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { int regId = getRegisterId(ins); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java index ff0805d1d..4747f7fea 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetDescendantsIns.java @@ -41,7 +41,6 @@ public class GetDescendantsIns extends InstructionDefinition { //if is runtime //pop(name), pop(ns) Object obj = lda.operandStack.pop();*/ - lda.executionException = "getdescendants not working"; return false; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java index c83c8ceae..6f5f6952e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/GetGlobalScopeIns.java @@ -36,7 +36,6 @@ public class GetGlobalScopeIns extends InstructionDefinition { @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - lda.executionException = "getglobalscope not working"; return false; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ThrowIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ThrowIns.java index 05dcb1e6e..bcfee3e16 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ThrowIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other/ThrowIns.java @@ -18,9 +18,13 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.ThrowAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -31,6 +35,12 @@ public class ThrowIns extends InstructionDefinition { super(0x03, "throw", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + String msg = EcmaScript.toString(lda.operandStack.pop()); + throw new AVM2ExecutionException(msg); + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { output.add(new ThrowAVM2Item(ins, stack.pop())); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/AbsJumpIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/AbsJumpIns.java index 62133e6cc..9dd224041 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/AbsJumpIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/AbsJumpIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class AbsJumpIns extends InstructionDefinition { super(0xEE, "abs_jump", new int[]{}, false /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/AddDIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/AddDIns.java index 04d829ab9..612d0c4b5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/AddDIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/AddDIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class AddDIns extends InstructionDefinition { super(0x9B, "add_d", new int[]{}, true /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { return 2; // ? diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/AddPIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/AddPIns.java index c6a5da446..e68a02fac 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/AddPIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/AddPIns.java @@ -17,6 +17,11 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class AddPIns extends InstructionDefinition { @@ -24,4 +29,13 @@ public class AddPIns extends InstructionDefinition { public AddPIns() { super(0xB5, "add_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS}, true /*?*/); } + + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/AllocIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/AllocIns.java index 3dd625acd..b58e99b18 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/AllocIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/AllocIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class AllocIns extends InstructionDefinition { super(0xF6, "alloc", new int[]{}, true /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/BkptIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/BkptIns.java index e49ae83c5..01cb98e59 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/BkptIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/BkptIns.java @@ -16,6 +16,10 @@ */ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class BkptIns extends InstructionDefinition { @@ -23,4 +27,10 @@ public class BkptIns extends InstructionDefinition { public BkptIns() { super(0x01, "bkpt", new int[]{}, false); } + + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + // do nothing + return true; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CallInterfaceIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CallInterfaceIns.java index 2d0782890..362f66927 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CallInterfaceIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CallInterfaceIns.java @@ -17,6 +17,11 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class CallInterfaceIns extends InstructionDefinition { @@ -24,4 +29,13 @@ public class CallInterfaceIns extends InstructionDefinition { public CallInterfaceIns() { super(0x4D, "callinterface", new int[]{AVM2Code.OPT_U30}, true); } + + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CallSuperIdIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CallSuperIdIns.java index 830fa7b03..ee6863832 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CallSuperIdIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CallSuperIdIns.java @@ -16,6 +16,11 @@ */ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class CallSuperIdIns extends InstructionDefinition { @@ -23,4 +28,13 @@ public class CallSuperIdIns extends InstructionDefinition { public CallSuperIdIns() { super(0x4B, "callsuperid", new int[]{}, true); } + + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CodeGenOpIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CodeGenOpIns.java index 463b56c5a..e7f0479a5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CodeGenOpIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CodeGenOpIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class CodeGenOpIns extends InstructionDefinition { super(0xFD, "codegenop", new int[]{}, false /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceBIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceBIns.java index 7001bf0cd..9cf83759a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceBIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceBIns.java @@ -18,9 +18,11 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceOrConvertTypeIns; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TypeItem; @@ -31,6 +33,13 @@ public class CoerceBIns extends InstructionDefinition implements CoerceOrConvert super(0x81, "coerce_b", new int[]{}, true); // stack: -1+1 } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Object value = lda.operandStack.pop(); + lda.operandStack.push(EcmaScript.toBoolean(value)); + return true; + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { return 1; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceDIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceDIns.java index d59daa719..f3a60a933 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceDIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceDIns.java @@ -18,9 +18,11 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceOrConvertTypeIns; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TypeItem; @@ -31,6 +33,13 @@ public class CoerceDIns extends InstructionDefinition implements CoerceOrConvert super(0x84, "coerce_d", new int[]{}, true); // stack: -1+1 } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Object value = lda.operandStack.pop(); + lda.operandStack.push(EcmaScript.toNumber(value)); + return true; + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { return 1; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceIIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceIIns.java index 1339e5292..18de5a245 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceIIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceIIns.java @@ -18,9 +18,11 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceOrConvertTypeIns; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TypeItem; @@ -31,6 +33,13 @@ public class CoerceIIns extends InstructionDefinition implements CoerceOrConvert super(0x83, "coerce_i", new int[]{}, true); // stack: -1+1 } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Object value = lda.operandStack.pop(); + lda.operandStack.push(EcmaScript.toInt32(value)); + return true; + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { return 1; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceOIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceOIns.java index e58133790..4082ec60f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceOIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceOIns.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceOrConvertTypeIns; +import com.jpexs.decompiler.flash.ecma.Null; +import com.jpexs.decompiler.flash.ecma.Undefined; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TypeItem; @@ -31,6 +34,18 @@ public class CoerceOIns extends InstructionDefinition implements CoerceOrConvert super(0x89, "coerce_o", new int[]{}, true); // stack: -1+1 } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Object value = lda.operandStack.pop(); + // The only action appears to be to convert undefined to null. + if (value instanceof Undefined) { + value = Null.INSTANCE; + } + + lda.operandStack.push(value); + return true; + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { return 1; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceUIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceUIns.java index 53150b850..5464260a9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceUIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/CoerceUIns.java @@ -18,9 +18,11 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceOrConvertTypeIns; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TypeItem; @@ -31,6 +33,13 @@ public class CoerceUIns extends InstructionDefinition implements CoerceOrConvert super(0x88, "coerce_u", new int[]{}, true); // stack: -1+1 } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Object value = lda.operandStack.pop(); + lda.operandStack.push(EcmaScript.toUint32(value)); + return true; + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { return 1; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ConcatIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ConcatIns.java index 37224cc8a..c8c480300 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ConcatIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ConcatIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class ConcatIns extends InstructionDefinition { super(0x9A, "concat", new int[]{}, true /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { return 2; // ? diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ConvertF4Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ConvertF4Ins.java index 7fef971aa..7471d74df 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ConvertF4Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ConvertF4Ins.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class ConvertF4Ins extends InstructionDefinition { super(0x7B, "convert_f4", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { return 1; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ConvertMIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ConvertMIns.java index 882c50fbe..190d87fa8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ConvertMIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ConvertMIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class ConvertMIns extends InstructionDefinition { super(0x79, "convert_m", new int[]{}, true); // -1 +1 } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { return 1; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ConvertMPIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ConvertMPIns.java index ec3f24769..89dc899cc 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ConvertMPIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ConvertMPIns.java @@ -18,6 +18,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -27,6 +31,15 @@ public class ConvertMPIns extends InstructionDefinition { super(0x7A, "convert_m_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DecLocalPIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DecLocalPIns.java index 0745fc6e4..0324cb89a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DecLocalPIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DecLocalPIns.java @@ -17,6 +17,11 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class DecLocalPIns extends InstructionDefinition { @@ -24,4 +29,13 @@ public class DecLocalPIns extends InstructionDefinition { public DecLocalPIns() { super(0x9F, "declocal_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS, AVM2Code.DAT_REGISTER_INDEX}, false /*?*/); } + + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DecodeIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DecodeIns.java index 7cbb7a324..bbfe9bfdf 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DecodeIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DecodeIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class DecodeIns extends InstructionDefinition { super(0xFF, "decode", new int[]{}, false /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DecrementPIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DecrementPIns.java index f1b825b9f..645617fb6 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DecrementPIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DecrementPIns.java @@ -17,6 +17,11 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class DecrementPIns extends InstructionDefinition { @@ -24,4 +29,13 @@ public class DecrementPIns extends InstructionDefinition { public DecrementPIns() { super(0x9E, "decrement_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS}, true /*?*/); } + + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DelDescendantsIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DelDescendantsIns.java index 155dfe166..90386972e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DelDescendantsIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DelDescendantsIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class DelDescendantsIns extends InstructionDefinition { super(0x5B, "deldescendants", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DeletePropertyLateIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DeletePropertyLateIns.java index ac5ee68b7..4ef893580 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DeletePropertyLateIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DeletePropertyLateIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class DeletePropertyLateIns extends InstructionDefinition { super(0x6B, "deletepropertylate", new int[]{}, true /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DividePIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DividePIns.java index ce9b7a4d9..b3a50c806 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DividePIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DividePIns.java @@ -18,6 +18,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -27,6 +31,15 @@ public class DividePIns extends InstructionDefinition { super(0xB8, "divide_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS}, true /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { return 2; // ? diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DoubleToAtomIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DoubleToAtomIns.java index 15c109a07..af353255d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DoubleToAtomIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/DoubleToAtomIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class DoubleToAtomIns extends InstructionDefinition { super(0xFB, "doubletoatom", new int[]{}, true /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/FindPropGlobalIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/FindPropGlobalIns.java index 4f470be82..b8bd7fd33 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/FindPropGlobalIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/FindPropGlobalIns.java @@ -18,6 +18,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -27,6 +31,15 @@ public class FindPropGlobalIns extends InstructionDefinition { super(0x5C, "findpropglobal", new int[]{AVM2Code.DAT_MULTINAME_INDEX}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/IncLocalPIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/IncLocalPIns.java index a84c01546..bfbc9747f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/IncLocalPIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/IncLocalPIns.java @@ -17,6 +17,11 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class IncLocalPIns extends InstructionDefinition { @@ -24,4 +29,13 @@ public class IncLocalPIns extends InstructionDefinition { public IncLocalPIns() { super(0x9D, "inclocal_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS, AVM2Code.DAT_REGISTER_INDEX}, true /*?*/); } + + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/IncrementPIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/IncrementPIns.java index 9594e0152..70ee25de1 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/IncrementPIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/IncrementPIns.java @@ -17,6 +17,11 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class IncrementPIns extends InstructionDefinition { @@ -24,4 +29,13 @@ public class IncrementPIns extends InstructionDefinition { public IncrementPIns() { super(0x9C, "increment_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS}, true /*?*/); } + + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/InvalidIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/InvalidIns.java index 207be88ba..445a014ff 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/InvalidIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/InvalidIns.java @@ -16,6 +16,11 @@ */ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class InvalidIns extends InstructionDefinition { @@ -23,4 +28,13 @@ public class InvalidIns extends InstructionDefinition { public InvalidIns() { super(0xED, "invalid", new int[]{}, false); } + + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/Lf32x4Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/Lf32x4Ins.java index 2c98ef51e..6a40e0b65 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/Lf32x4Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/Lf32x4Ins.java @@ -16,6 +16,11 @@ */ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class Lf32x4Ins extends InstructionDefinition { @@ -23,4 +28,13 @@ public class Lf32x4Ins extends InstructionDefinition { public Lf32x4Ins() { super(0x0A, "lf32x4", new int[]{}, true); } + + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/MarkIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/MarkIns.java index 7eeac01fb..8546891aa 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/MarkIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/MarkIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class MarkIns extends InstructionDefinition { super(0xF7, "mark", new int[]{}, false /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ModuloPIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ModuloPIns.java index 77a65357a..57cc5443f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ModuloPIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/ModuloPIns.java @@ -18,6 +18,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -27,6 +31,15 @@ public class ModuloPIns extends InstructionDefinition { super(0xB9, "modulo_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS}, true /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { return 2; // ? diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/MultiplyPIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/MultiplyPIns.java index a475c6827..25c408f02 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/MultiplyPIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/MultiplyPIns.java @@ -18,6 +18,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -27,6 +31,15 @@ public class MultiplyPIns extends InstructionDefinition { super(0xB7, "multiply_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS}, true /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { return 2; // ? diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/NegatePIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/NegatePIns.java index c37c6b82f..209b3d1cf 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/NegatePIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/NegatePIns.java @@ -18,6 +18,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -27,6 +31,15 @@ public class NegatePIns extends InstructionDefinition { super(0x8F, "negate_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS}, true /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PrologueIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PrologueIns.java index 8c940ec1a..a82737919 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PrologueIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PrologueIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class PrologueIns extends InstructionDefinition { super(0xF9, "prologue", new int[]{}, false /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PushConstantIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PushConstantIns.java index 2eaaa5e92..c51b863f7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PushConstantIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PushConstantIns.java @@ -18,6 +18,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -27,6 +31,15 @@ public class PushConstantIns extends InstructionDefinition { super(0x22, "pushconstant", new int[]{AVM2Code.DAT_STRING_INDEX}, false /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPushCount(AVM2Instruction ins, ABC abc) { return 1; // ? diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PushDNanIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PushDNanIns.java index 9be061d82..dd643205c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PushDNanIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PushDNanIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class PushDNanIns extends InstructionDefinition { super(0x34, "pushdnan", new int[]{}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPushCount(AVM2Instruction ins, ABC abc) { return 1; // ? diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PushDecimalIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PushDecimalIns.java index dfa60ae4f..2bfce685a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PushDecimalIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PushDecimalIns.java @@ -18,6 +18,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -27,6 +31,15 @@ public class PushDecimalIns extends InstructionDefinition { super(0x33, "pushdecimal", new int[]{AVM2Code.DAT_DECIMAL_INDEX}, true); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPushCount(AVM2Instruction ins, ABC abc) { return 1; // ? diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PushFloat4Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PushFloat4Ins.java index aff5f8433..5ea663fb4 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PushFloat4Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/PushFloat4Ins.java @@ -16,6 +16,11 @@ */ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class PushFloat4Ins extends InstructionDefinition { @@ -23,4 +28,13 @@ public class PushFloat4Ins extends InstructionDefinition { public PushFloat4Ins() { super(0x54, "pushfloat4", new int[]{}, false); } + + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/SendEnterIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/SendEnterIns.java index 1fea7b855..c91446e83 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/SendEnterIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/SendEnterIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class SendEnterIns extends InstructionDefinition { super(0xFA, "sendenter", new int[]{}, false /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/SetPropertyLateIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/SetPropertyLateIns.java index 6fcf28f3b..7ff26a34e 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/SetPropertyLateIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/SetPropertyLateIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class SetPropertyLateIns extends InstructionDefinition { super(0x69, "setpropertylate", new int[]{}, true /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/Sf32x4Ins.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/Sf32x4Ins.java index 1df138d70..ec7a70e8d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/Sf32x4Ins.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/Sf32x4Ins.java @@ -16,6 +16,11 @@ */ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class Sf32x4Ins extends InstructionDefinition { @@ -23,4 +28,13 @@ public class Sf32x4Ins extends InstructionDefinition { public Sf32x4Ins() { super(0x0B, "sf32x4", new int[]{}, true); } + + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/SubtractPIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/SubtractPIns.java index 3fb4ce328..16eb64c6b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/SubtractPIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/SubtractPIns.java @@ -18,6 +18,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -27,6 +31,15 @@ public class SubtractPIns extends InstructionDefinition { super(0xB6, "subtract_p", new int[]{AVM2Code.DAT_DECIMAL_PARAMS}, true /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/SweepIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/SweepIns.java index 45e795978..2f277675f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/SweepIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/SweepIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class SweepIns extends InstructionDefinition { super(0xFC, "sweep", new int[]{}, false /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/TimestampIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/TimestampIns.java index de593af6f..9eafd12ae 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/TimestampIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/TimestampIns.java @@ -16,6 +16,9 @@ */ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; +import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; public class TimestampIns extends InstructionDefinition { @@ -23,4 +26,10 @@ public class TimestampIns extends InstructionDefinition { public TimestampIns() { super(0xF3, "timestamp", new int[]{}, false /*?*/); } + + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + // Appears to be a no-op. + return true; + } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/VerifyOpIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/VerifyOpIns.java index 652e3b759..916e1107b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/VerifyOpIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/VerifyOpIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class VerifyOpIns extends InstructionDefinition { super(0xFE, "verifyop", new int[]{}, false /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/VerifyPassIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/VerifyPassIns.java index 09e612a52..5656cf6ae 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/VerifyPassIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/VerifyPassIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class VerifyPassIns extends InstructionDefinition { super(0xF5, "verifypass", new int[]{}, false /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/WbIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/WbIns.java index a758fedfa..78def4ead 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/WbIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/other2/WbIns.java @@ -17,6 +17,10 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other2; import com.jpexs.decompiler.flash.abc.ABC; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; @@ -26,6 +30,15 @@ public class WbIns extends InstructionDefinition { super(0xF8, "wb", new int[]{}, false /*?*/); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + if (lda.runtime == AVM2Runtime.ADOBE_FLASH) { + illegalOpCode(lda, ins); + } + + return super.execute(lda, constants, ins); + } + @Override public int getStackPopCount(AVM2Instruction ins, ABC abc) { throw new UnsupportedOperationException(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNanIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNanIns.java index 995c6a0b8..58eb4d07d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNanIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNanIns.java @@ -18,6 +18,8 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.NanAVM2Item; @@ -31,6 +33,12 @@ public class PushNanIns extends InstructionDefinition { super(0x28, "pushnan", new int[]{}, false); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + lda.operandStack.push(Double.NaN); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { stack.push(new NanAVM2Item(ins)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNullIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNullIns.java index 24e4bc4c7..7ce77010c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNullIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushNullIns.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.NullAVM2Item; +import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -31,6 +34,12 @@ public class PushNullIns extends InstructionDefinition { super(0x20, "pushnull", new int[]{}, false); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + lda.operandStack.push(Null.INSTANCE); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { stack.push(new NullAVM2Item(ins)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUndefinedIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUndefinedIns.java index a6e7b1d86..a95e624d0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUndefinedIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/stack/PushUndefinedIns.java @@ -18,9 +18,12 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.stack; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.UndefinedAVM2Item; +import com.jpexs.decompiler.flash.ecma.Undefined; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -31,6 +34,12 @@ public class PushUndefinedIns extends InstructionDefinition { super(0x21, "pushundefined", new int[]{}, false); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + lda.operandStack.push(Undefined.INSTANCE); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { stack.push(new UndefinedAVM2Item(ins)); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java index 5d83aa6d4..2ea214fa5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceAIns.java @@ -40,7 +40,7 @@ public class CoerceAIns extends InstructionDefinition implements CoerceOrConvert @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - //coerce any type + // coerce any type return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java index 7d445528c..4008011fb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/CoerceIns.java @@ -20,11 +20,16 @@ import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2TypeErrorException; import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item; import com.jpexs.decompiler.flash.abc.avm2.parser.script.PropertyAVM2Item; +import com.jpexs.decompiler.flash.abc.types.Multiname; +import com.jpexs.decompiler.flash.ecma.EcmaScript; +import com.jpexs.decompiler.flash.ecma.EcmaType; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -36,9 +41,20 @@ public class CoerceIns extends InstructionDefinition implements CoerceOrConvertT } @Override - public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - //int multinameIndex = ins.getParamAsLong(constants, 0).intValue(); + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException { + Multiname multiname = (Multiname) ins.getParam(constants, 0); + if (multiname == null) { + throw new AVM2TypeErrorException(1034); + } + + Object value = lda.operandStack.pop(); + EcmaType type = EcmaScript.type(value); + if (type != EcmaType.NULL && type != EcmaType.OBJECT) { + throw new AVM2TypeErrorException(1034); + } + //push and pop coerced value to specified type + lda.operandStack.push(value); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java index 3e56a7a80..cc58ed17a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertBIns.java @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; @@ -38,17 +39,7 @@ public class ConvertBIns extends InstructionDefinition implements CoerceOrConver @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { Object value = lda.operandStack.pop(); - boolean bval; - if (value instanceof Boolean) { - bval = (Boolean) value; - } else if (value instanceof Long) { - bval = (Long) value != 0; - } else if (value instanceof String) { - bval = !((String) value).isEmpty(); - } else { - bval = true; - } - lda.operandStack.push((Boolean) bval); + lda.operandStack.push(EcmaScript.toBoolean(value)); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java index b1aebc850..0c27b9bc7 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertDIns.java @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; @@ -38,25 +39,7 @@ public class ConvertDIns extends InstructionDefinition implements CoerceOrConver @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { Object value = lda.operandStack.pop(); - double ret; - if (value == null) { - ret = 0; - } else if (value instanceof Boolean) { - if ((Boolean) value) { - ret = 1; - } else { - ret = 0; - } - } else if (value instanceof Long) { - ret = (Long) value; - } else if (value instanceof Double) { - ret = (Double) value; - } else if (value instanceof String) { - ret = Double.parseDouble((String) value); - } else { - ret = 1; //must call toPrimitive - } - lda.operandStack.push(ret); + lda.operandStack.push(EcmaScript.toNumber(value)); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java index 03ec7733a..d5102661d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertIIns.java @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; @@ -38,23 +39,7 @@ public class ConvertIIns extends InstructionDefinition implements CoerceOrConver @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { Object value = lda.operandStack.pop(); - long ret; - if (value == null) { - ret = 0; - } else if (value instanceof Boolean) { - if ((Boolean) value) { - ret = 1; - } else { - ret = 0; - } - } else if (value instanceof Long) { - ret = (Long) value; - } else if (value instanceof String) { - ret = Long.parseLong((String) value); - } else { - ret = 1; //must call toPrimitive - } - lda.operandStack.push(ret); + lda.operandStack.push(EcmaScript.toInt32(value)); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java index 46fcfcd27..f5bc477c3 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertUIns.java @@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.graph.DottedChain; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; @@ -37,8 +38,9 @@ public class ConvertUIns extends InstructionDefinition implements CoerceOrConver @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - //throw new UnsupportedOperationException("Cannot convert to uint "); - return false; + Object value = lda.operandStack.pop(); + lda.operandStack.push(EcmaScript.toUint32(value)); + return true; } @Override diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/TypeOfIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/TypeOfIns.java index f8068139b..05768bfb0 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/TypeOfIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/TypeOfIns.java @@ -18,9 +18,13 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.types; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.AVM2LocalData; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; +import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; import com.jpexs.decompiler.flash.abc.avm2.model.operations.TypeOfAVM2Item; +import com.jpexs.decompiler.flash.ecma.EcmaScript; +import com.jpexs.decompiler.flash.ecma.EcmaType; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -31,6 +35,41 @@ public class TypeOfIns extends InstructionDefinition { super(0x95, "typeof", new int[]{}, false); } + @Override + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { + Object res = lda.operandStack.pop(); + EcmaType type = EcmaScript.type(res); + String typeStr; + switch (type) { + case STRING: + typeStr = "string"; + break; + case BOOLEAN: + typeStr = "boolean"; + break; + case NUMBER: + typeStr = "number"; + break; + case OBJECT: + typeStr = "object"; + break; + case UNDEFINED: + typeStr = "undefined"; + break; + case NULL: + // note: null is object in AS3 + typeStr = "object"; + break; + default: + //TODO: function,movieclip + typeStr = "object"; + break; + } + + lda.operandStack.push(typeStr); + return true; + } + @Override public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List output, String path) { stack.push(new TypeOfAVM2Item(ins, stack.pop())); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConvertAVM2Item.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConvertAVM2Item.java index ad814fd7e..fe1b11eaa 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConvertAVM2Item.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/model/ConvertAVM2Item.java @@ -56,9 +56,9 @@ public class ConvertAVM2Item extends AVM2Item { case "Number": return value.getResultAsNumber(); case "int": - return (int) (double) value.getResultAsNumber(); + return EcmaScript.toInt32(value.getResultAsNumber()); case "uint": - return (int) (double) EcmaScript.toUint32(value.getResult()); + return EcmaScript.toUint32(value.getResult()); case "String": return value.getResult().toString(); case "Object": diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/pcode/ASM3Parser.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/pcode/ASM3Parser.java index d1be8a242..b7ef693a5 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/pcode/ASM3Parser.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/pcode/ASM3Parser.java @@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.DeobfuscatePopIns; import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition; +import com.jpexs.decompiler.flash.abc.avm2.instructions.UnknownInstruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushShortIns; import com.jpexs.decompiler.flash.abc.avm2.parser.AVM2ParseException; import com.jpexs.decompiler.flash.abc.types.ABCException; @@ -735,7 +736,7 @@ public class ASM3Parser { } boolean insFound = false; for (InstructionDefinition def : AVM2Code.instructionSet) { - if (def != null && def.instructionName.equals((String) symb.value)) { + if (def != null && !(def instanceof UnknownInstruction) && def.instructionName.equals((String) symb.value)) { insFound = true; List operandsList = new ArrayList<>(); diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/ecma/EcmaScript.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/ecma/EcmaScript.java index 5cece3602..c540f456b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/ecma/EcmaScript.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/ecma/EcmaScript.java @@ -54,7 +54,8 @@ public class EcmaScript { return Double.NaN; } } - //TODO:ToPrimitive + + // todo: ToPrimitive return 0.0; } @@ -159,6 +160,14 @@ public class EcmaScript { } } + public static boolean strictEquals(Object x, Object y) { + if (type(x) != type(y)) { + return false; + } + + return equals(x, y); + } + public static boolean equals(Object x, Object y) { EcmaType typeX = type(x); EcmaType typeY = type(y); @@ -276,7 +285,11 @@ public class EcmaScript { return true; //other Object } - public static Long toUint32(Object o) { + public static int toInt32(Object o) { + return (int) toUint32(o); + } + + public static long toUint32(Object o) { Double n = toNumber(o); if (n.isNaN()) { return 0L; @@ -290,8 +303,8 @@ public class EcmaScript { if (Double.isInfinite(n)) { return 0L; } - Long posInt = (long) (double) (Math.signum(n) * Math.floor(Math.abs(n))); - posInt %= (1 << 32); + long posInt = (long) (double) (Math.signum(n) * Math.floor(Math.abs(n))); + posInt %= (1L << 32); return posInt; } diff --git a/test/com/jpexs/decompiler/flash/gui/FlashPlayerTest.java b/test/com/jpexs/decompiler/flash/gui/FlashPlayerTest.java index e1779dfed..ee39aa6d1 100644 --- a/test/com/jpexs/decompiler/flash/gui/FlashPlayerTest.java +++ b/test/com/jpexs/decompiler/flash/gui/FlashPlayerTest.java @@ -19,6 +19,8 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.abc.ABC; import com.jpexs.decompiler.flash.abc.avm2.AVM2Code; +import com.jpexs.decompiler.flash.abc.avm2.AVM2ExecutionException; +import com.jpexs.decompiler.flash.abc.avm2.AVM2Runtime; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction; import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions; import com.jpexs.decompiler.flash.abc.avm2.instructions.IfTypeIns; @@ -69,6 +71,7 @@ import com.jpexs.decompiler.flash.action.swf5.ActionTypeOf; import com.jpexs.decompiler.flash.action.swf6.ActionGreater; import com.jpexs.decompiler.flash.action.swf6.ActionStrictEquals; import com.jpexs.decompiler.flash.action.swf6.ActionStringGreater; +import com.jpexs.decompiler.flash.ecma.EcmaScript; import com.jpexs.decompiler.flash.ecma.Null; import com.jpexs.decompiler.flash.ecma.Undefined; import com.jpexs.decompiler.flash.tags.DoABC2Tag; @@ -146,36 +149,79 @@ public class FlashPlayerTest { abc.constants.addDouble(111.11); MethodBody body = abc.findBodyByClassAndName("Run", "run"); body.max_stack = 20; + body.max_regs = 10; - for (int i = 0; i < 255; i++) { + for (int i = 0; i < 256; i++) { + if (i == AVM2Instructions.ReturnVoid) { + // todo: fails for some reason + continue; + } + + // todo: the following instructions are not implemented if (i == AVM2Instructions.GetSuper || i == AVM2Instructions.SetSuper || i == AVM2Instructions.DXNS || i == AVM2Instructions.DXNSLate || i == AVM2Instructions.Kill - || i == AVM2Instructions.Lf32x4 - || i == AVM2Instructions.Sf32x4 || i == AVM2Instructions.LookupSwitch || i == AVM2Instructions.PushWith || i == AVM2Instructions.NextName || i == AVM2Instructions.HasNext - || i == AVM2Instructions.PushConstant || i == AVM2Instructions.NextValue || i == AVM2Instructions.PushScope || i == AVM2Instructions.PushNamespace || i == AVM2Instructions.HasNext2 - || i == AVM2Instructions.PushDecimal - || i == AVM2Instructions.PushDNan - || i == AVM2Instructions.DXNS - || i == AVM2Instructions.DXNS - || i == AVM2Instructions.DXNS - || i == AVM2Instructions.DXNS - || i == AVM2Instructions.DXNS - || i == AVM2Instructions.DXNS) { + || i == AVM2Instructions.NewFunction + || i == AVM2Instructions.Call + || i == AVM2Instructions.Construct + || i == AVM2Instructions.CallMethod + || i == AVM2Instructions.CallStatic + || i == AVM2Instructions.CallSuper + || i == AVM2Instructions.CallProperty + || i == AVM2Instructions.ReturnVoid + || i == AVM2Instructions.ConstructSuper + || i == AVM2Instructions.ConstructProp + || i == AVM2Instructions.CallPropLex + || i == AVM2Instructions.CallSuperVoid + || i == AVM2Instructions.CallPropVoid + || i == AVM2Instructions.ApplyType + || i == AVM2Instructions.NewObject + || i == AVM2Instructions.NewArray + || i == AVM2Instructions.NewActivation + || i == AVM2Instructions.NewClass + || i == AVM2Instructions.GetDescendants + || i == AVM2Instructions.NewCatch + || i == AVM2Instructions.FindPropGlobal + || i == AVM2Instructions.FindPropertyStrict + || i == AVM2Instructions.FindProperty + || i == AVM2Instructions.FindDef + || i == AVM2Instructions.GetLex + || i == AVM2Instructions.SetProperty + || i == AVM2Instructions.GetGlobalScope + || i == AVM2Instructions.GetScopeObject + || i == AVM2Instructions.GetProperty + || i == AVM2Instructions.GetOuterScope + || i == AVM2Instructions.InitProperty + || i == AVM2Instructions.DeleteProperty + || i == AVM2Instructions.GetSlot + || i == AVM2Instructions.SetSlot + || i == AVM2Instructions.GetGlobalSlot + || i == AVM2Instructions.SetGlobalSlot + || i == AVM2Instructions.CheckFilter + || i == AVM2Instructions.AsType // todo: fix + || i == AVM2Instructions.AsTypeLate + || i == AVM2Instructions.InstanceOf + || i == AVM2Instructions.IsType + || i == AVM2Instructions.IsTypeLate + || i == AVM2Instructions.In + || i == AVM2Instructions.SubtractI // todo: implement + || i == AVM2Instructions.MultiplyI // todo: implement + || i == AVM2Instructions.BkptLine // todo: implement + ) { continue; } - System.out.println("Instruction code: " + Integer.toHexString(i) + " (" + i + ")"); + System.out.println("Instruction code: " + Integer.toHexString(i) + " (" + i + ") " + AVM2Code.instructionSet[i].instructionName); int j = 1; File f2 = new File("run_test_" + new Date().getTime() + "_" + i + "_" + j + ".swf"); f2.deleteOnExit(); @@ -185,6 +231,10 @@ public class FlashPlayerTest { List code = ccode.code; code.add(new AVM2Instruction(0, AVM2Instructions.GetLocal0, null)); code.add(new AVM2Instruction(0, AVM2Instructions.PushScope, null)); + code.add(new AVM2Instruction(0, AVM2Instructions.PushByte, new int[]{10})); + code.add(new AVM2Instruction(0, AVM2Instructions.SetLocal0, null)); + code.add(new AVM2Instruction(0, AVM2Instructions.PushByte, new int[]{11})); + code.add(new AVM2Instruction(0, AVM2Instructions.SetLocal1, null)); code.add(new AVM2Instruction(0, AVM2Instructions.PushByte, new int[]{0})); code.add(new AVM2Instruction(0, AVM2Instructions.PushByte, new int[]{1})); code.add(new AVM2Instruction(0, AVM2Instructions.PushByte, new int[]{2})); @@ -200,17 +250,16 @@ public class FlashPlayerTest { } } - ifType = false; // todo: ins instanceof IfTypeIns; + ifType = ins instanceof IfTypeIns; if (ifType) { - params[0] = 8; + params[0] = 3; } } - code.add(new AVM2Instruction(0, /*getOpIns(i)*/ ins, params)); + code.add(new AVM2Instruction(0, ins, params)); if (ifType) { - code.add(new AVM2Instruction(0, AVM2Instructions.PushByte, new int[]{3})); - code.add(new AVM2Instruction(0, AVM2Instructions.Jump, new int[]{2})); - code.add(new AVM2Instruction(0, AVM2Instructions.PushByte, new int[]{4})); + code.add(new AVM2Instruction(0, AVM2Instructions.PushString, new int[]{1})); + code.add(new AVM2Instruction(0, AVM2Instructions.ReturnValue, null)); } code.add(new AVM2Instruction(0, AVM2Instructions.Dup, null)); @@ -239,7 +288,13 @@ public class FlashPlayerTest { String flashResult = resultRef.getVal(); System.out.println("Flash result: " + flashResult); - String ffdecExecuteResult = (String) ccode.execute(new HashMap<>(), abc.constants); + String ffdecExecuteResult; + try { + ffdecExecuteResult = EcmaScript.toString(ccode.execute(new HashMap<>(), abc.constants, AVM2Runtime.ADOBE_FLASH, 19)); + } catch (AVM2ExecutionException ex) { + ffdecExecuteResult = ex.getMessage(); + } + System.out.println("FFDec execte result: " + ffdecExecuteResult); Assert.assertEquals(ffdecExecuteResult, flashResult); @@ -301,7 +356,7 @@ public class FlashPlayerTest { Action opAction = getOpAction(j); if (j >= 13 + 23) { - newActions.add(new ActionPush("mystring")); + newActions.add(new ActionPush("mystring_árvíztűrő_tükörfúrógép")); } if (j >= 13) { @@ -411,37 +466,6 @@ public class FlashPlayerTest { } } - private int getOpIns(int idx) { - switch (idx) { - case 0: - return AVM2Instructions.BitAnd; - case 1: - return AVM2Instructions.Add; - case 2: - return AVM2Instructions.LShift; - case 3: - return AVM2Instructions.BitOr; - case 4: - return AVM2Instructions.RShift; - case 5: - return AVM2Instructions.URShift; - case 6: - return AVM2Instructions.BitXor; - case 7: - return AVM2Instructions.Divide; - case 8: - return AVM2Instructions.Equals; - case 9: - return AVM2Instructions.Modulo; - case 10: - return AVM2Instructions.Multiply; - case 11: - return AVM2Instructions.Subtract; - } - - throw new Error("Invalid index"); - } - private Action getOpAction(int idx) { Action result; if (idx < 13) {