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 392f9ce5f..386974843 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 @@ -20,6 +20,7 @@ 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.exceptions.AVM2RangeErrorException; 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; @@ -39,11 +40,16 @@ public class Sf32Ins extends InstructionDefinition implements AlchemyTypeIns { } @Override - public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - Double value = (double) EcmaScript.toNumber(lda.operandStack.pop()); + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2RangeErrorException { int addr = (int) (double) EcmaScript.toNumber(lda.operandStack.pop()); + byte[] domainMemory = lda.getDomainMemory(); + if (addr < 0 || addr >= domainMemory.length) { + throw new AVM2RangeErrorException(1506); + } + + Double value = (double) EcmaScript.toNumber(lda.operandStack.pop()); // todo: set domainMemory - //lda.getDomainMemory()[addr] = ... + //domainMemory[addr] = ... return true; } 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 7d15fef35..21d5e0ba2 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 @@ -20,6 +20,7 @@ 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.exceptions.AVM2RangeErrorException; 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; @@ -39,11 +40,16 @@ public class Sf64Ins extends InstructionDefinition implements AlchemyTypeIns { } @Override - public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - Double value = (double) EcmaScript.toNumber(lda.operandStack.pop()); + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2RangeErrorException { int addr = (int) (double) EcmaScript.toNumber(lda.operandStack.pop()); + byte[] domainMemory = lda.getDomainMemory(); + if (addr < 0 || addr >= domainMemory.length) { + throw new AVM2RangeErrorException(1506); + } + + Double value = (double) EcmaScript.toNumber(lda.operandStack.pop()); // todo: set domainMemory - //lda.getDomainMemory()[addr] = ... + //domainMemory[addr] = ... return true; } 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 ec95845d8..73ca565cf 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 @@ -20,6 +20,7 @@ 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.exceptions.AVM2RangeErrorException; 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; @@ -39,11 +40,16 @@ public class Si16Ins extends InstructionDefinition implements AlchemyTypeIns { } @Override - public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - Double value = (double) EcmaScript.toNumber(lda.operandStack.pop()); + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2RangeErrorException { int addr = (int) (double) EcmaScript.toNumber(lda.operandStack.pop()); + byte[] domainMemory = lda.getDomainMemory(); + if (addr < 0 || addr >= domainMemory.length) { + throw new AVM2RangeErrorException(1506); + } + + int value = EcmaScript.toInt32(lda.operandStack.pop()); // todo: set domainMemory - //lda.getDomainMemory()[addr] = ... + //domainMemory[addr] = ... return true; } 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 8cac96114..d25520798 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 @@ -20,6 +20,7 @@ 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.exceptions.AVM2RangeErrorException; 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; @@ -39,11 +40,16 @@ public class Si32Ins extends InstructionDefinition implements AlchemyTypeIns { } @Override - public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - Double value = (double) EcmaScript.toNumber(lda.operandStack.pop()); + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2RangeErrorException { int addr = (int) (double) EcmaScript.toNumber(lda.operandStack.pop()); + byte[] domainMemory = lda.getDomainMemory(); + if (addr < 0 || addr >= domainMemory.length) { + throw new AVM2RangeErrorException(1506); + } + + int value = EcmaScript.toInt32(lda.operandStack.pop()); // todo: set domainMemory - //lda.getDomainMemory()[addr] = ... + //domainMemory[addr] = ... return true; } 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 fc8235118..dfb9146cd 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 @@ -20,6 +20,7 @@ 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.exceptions.AVM2RangeErrorException; 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; @@ -39,11 +40,16 @@ public class Si8Ins extends InstructionDefinition implements AlchemyTypeIns { } @Override - public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - Double value = (double) EcmaScript.toNumber(lda.operandStack.pop()); + public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2RangeErrorException { int addr = (int) (double) EcmaScript.toNumber(lda.operandStack.pop()); + byte[] domainMemory = lda.getDomainMemory(); + if (addr < 0 || addr >= domainMemory.length) { + throw new AVM2RangeErrorException(1506); + } + + int value = EcmaScript.toInt32(lda.operandStack.pop()); // todo: set domainMemory - //lda.getDomainMemory()[addr] = ... + //domainMemory[addr] = ... return true; } 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 ae1ca23db..53d2c070f 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 @@ -40,8 +40,7 @@ public class Sxi16Ins extends InstructionDefinition implements AlchemyTypeIns { @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 + int value = (int) ((short) (EcmaScript.toInt32(lda.operandStack.pop()) & 0xffff)); lda.operandStack.push(value); return true; } 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 f59fdb5ae..1735d2a00 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 @@ -40,8 +40,7 @@ public class Sxi1Ins extends InstructionDefinition implements AlchemyTypeIns { @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 + int value = -(EcmaScript.toInt32(lda.operandStack.pop()) & 0x1); lda.operandStack.push(value); return true; } 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 cacc08159..db846ab8c 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 @@ -40,8 +40,7 @@ public class Sxi8Ins extends InstructionDefinition implements AlchemyTypeIns { @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 + int value = (int) ((byte) (EcmaScript.toInt32(lda.operandStack.pop()) & 0xff)); lda.operandStack.push(value); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java index 8ee36e9c3..d159a6a43 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/arithmetic/AddIIns.java @@ -24,7 +24,6 @@ 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; @@ -39,14 +38,8 @@ public class AddIIns extends InstructionDefinition { public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { 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 { - int ret = EcmaScript.toInt32(left) + EcmaScript.toInt32(right); - lda.operandStack.push(ret); - } - + int ret = EcmaScript.toInt32(left) + EcmaScript.toInt32(right); + lda.operandStack.push(ret); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitAndIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitAndIns.java index 70869c49d..5ddc8877b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitAndIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitAndIns.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.BitAndAVM2Item; +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,9 @@ public class BitAndIns extends InstructionDefinition { @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - Long value2 = (Long) lda.operandStack.pop(); - Long value1 = (Long) lda.operandStack.pop(); - Long value3 = value1 & value2; + long value2 = EcmaScript.toInt32(lda.operandStack.pop()); + long value1 = EcmaScript.toInt32(lda.operandStack.pop()); + long value3 = value1 & value2; lda.operandStack.push(value3); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitOrIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitOrIns.java index 143ce286b..91b3642d8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitOrIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitOrIns.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.BitOrAVM2Item; +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,9 @@ public class BitOrIns extends InstructionDefinition { @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - Long value2 = (Long) lda.operandStack.pop(); - Long value1 = (Long) lda.operandStack.pop(); - Long value3 = value1 | value2; + long value2 = EcmaScript.toInt32(lda.operandStack.pop()); + long value1 = EcmaScript.toInt32(lda.operandStack.pop()); + long value3 = value1 | value2; lda.operandStack.push(value3); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitXorIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitXorIns.java index 2500135bb..40a8ce98b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitXorIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/BitXorIns.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.BitXorAVM2Item; +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,9 @@ public class BitXorIns extends InstructionDefinition { @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - Long value2 = (Long) lda.operandStack.pop(); - Long value1 = (Long) lda.operandStack.pop(); - Long value3 = value1 ^ value2; + long value2 = EcmaScript.toInt32(lda.operandStack.pop()); + long value1 = EcmaScript.toInt32(lda.operandStack.pop()); + long value3 = value1 ^ value2; lda.operandStack.push(value3); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/LShiftIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/LShiftIns.java index 8a9f5c7bd..721786959 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/LShiftIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/LShiftIns.java @@ -37,8 +37,8 @@ public class LShiftIns extends InstructionDefinition { @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { int value2 = EcmaScript.toInt32(lda.operandStack.pop()) & 0x1F; - long value1 = EcmaScript.toInt32(lda.operandStack.pop()); - long value3 = value1 << value2; + int value1 = EcmaScript.toInt32(lda.operandStack.pop()); + int value3 = value1 << value2; lda.operandStack.push(value3); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/URShiftIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/URShiftIns.java index 2296bca3a..a30c26ba8 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/URShiftIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/bitwise/URShiftIns.java @@ -36,8 +36,8 @@ public class URShiftIns extends InstructionDefinition { @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) { - int value2 = EcmaScript.toInt32(lda.operandStack.pop()) & 0x1F; - long value1 = EcmaScript.toInt32(lda.operandStack.pop()); + long value2 = EcmaScript.toInt32(lda.operandStack.pop()) & 0x1F; + long value1 = EcmaScript.toInt32(lda.operandStack.pop()) & 0xffffffffL; long value3 = value1 >>> value2; lda.operandStack.push(value3); 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 2ac856718..b352054e3 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 @@ -24,6 +24,7 @@ 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.flash.ecma.Undefined; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -36,9 +37,11 @@ public class GreaterEqualsIns extends InstructionDefinition { @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); + Object rightObj = lda.operandStack.pop(); + Object leftObj = lda.operandStack.pop(); + + Object cmp = EcmaScript.compare(leftObj, rightObj); + lda.operandStack.push(cmp != Undefined.INSTANCE && ((int) cmp) != -1); return true; } 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 5112f0abb..94d957c0b 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 @@ -24,6 +24,7 @@ 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.flash.ecma.Undefined; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -36,9 +37,11 @@ public class GreaterThanIns extends InstructionDefinition { @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); + Object rightObj = lda.operandStack.pop(); + Object leftObj = lda.operandStack.pop(); + + Object cmp = EcmaScript.compare(leftObj, rightObj); + lda.operandStack.push(cmp != Undefined.INSTANCE && ((int) cmp) == 1); return true; } 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 4207c2534..6a3ca6671 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 @@ -24,6 +24,7 @@ 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.flash.ecma.Undefined; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -36,9 +37,11 @@ public class LessEqualsIns extends InstructionDefinition { @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); + Object rightObj = lda.operandStack.pop(); + Object leftObj = lda.operandStack.pop(); + + Object cmp = EcmaScript.compare(leftObj, rightObj); + lda.operandStack.push(cmp != Undefined.INSTANCE && ((int) cmp) != 1); return true; } 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 2773e9683..0145f71c6 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 @@ -24,6 +24,7 @@ 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.flash.ecma.Undefined; import com.jpexs.decompiler.graph.GraphTargetItem; import com.jpexs.decompiler.graph.TranslateStack; import java.util.List; @@ -36,9 +37,11 @@ public class LessThanIns extends InstructionDefinition { @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); + Object rightObj = lda.operandStack.pop(); + Object leftObj = lda.operandStack.pop(); + + Object cmp = EcmaScript.compare(leftObj, rightObj); + lda.operandStack.push(cmp != Undefined.INSTANCE && ((int) cmp) == -1); return true; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java index b721e5e9b..40539a81f 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/instructions/types/ConvertOIns.java @@ -19,8 +19,8 @@ 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.exceptions.AVM2TypeErrorException; import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea; +import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2TypeErrorException; 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; @@ -41,6 +41,10 @@ public class ConvertOIns extends InstructionDefinition implements CoerceOrConver @Override public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2TypeErrorException { Object obj = lda.operandStack.peek(); + if (EcmaScript.type(obj) == EcmaType.NULL) { + throw new AVM2TypeErrorException(1009); + } + if (EcmaScript.type(obj) == EcmaType.UNDEFINED) { throw new AVM2TypeErrorException(1010); } 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 67e491335..8482ecb5a 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 @@ -351,7 +351,7 @@ public class EcmaScript { return 0L; } long posInt = (long) (double) (Math.signum(n) * Math.floor(Math.abs(n))); - posInt %= (1L << 32); + posInt &= 0xffffffffL; return posInt; } diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2AssemblerTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2AssemblerTest.java index c23759bc3..71bec2e34 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2AssemblerTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2AssemblerTest.java @@ -38,7 +38,7 @@ import org.testng.annotations.Test; * * @author JPEXS */ -public class ActionScript2AssemblerTest extends ActionStript2TestBase { +public class ActionScript2AssemblerTest extends ActionScript2TestBase { @BeforeClass public void init() throws IOException, InterruptedException { diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java index 09482e810..8eada6b87 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2DeobfuscatorTest.java @@ -43,7 +43,7 @@ import org.testng.annotations.Test; * * @author JPEXS */ -public class ActionScript2DeobfuscatorTest extends ActionStript2TestBase { +public class ActionScript2DeobfuscatorTest extends ActionScript2TestBase { @BeforeClass public void init() throws IOException, InterruptedException { diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2ModificationTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2ModificationTest.java index fc1d272e3..e8e22ac2f 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2ModificationTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2ModificationTest.java @@ -41,7 +41,7 @@ import org.testng.annotations.Test; * * @author JPEXS */ -public class ActionScript2ModificationTest extends ActionStript2TestBase { +public class ActionScript2ModificationTest extends ActionScript2TestBase { @BeforeClass public void init() throws IOException, InterruptedException { diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2ParserTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2ParserTest.java index 946b2644b..ebf46f835 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2ParserTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2ParserTest.java @@ -28,7 +28,7 @@ import org.testng.annotations.Test; * * @author JPEXS */ -public class ActionScript2ParserTest extends ActionStript2TestBase { +public class ActionScript2ParserTest extends ActionScript2TestBase { @BeforeClass public void init() throws IOException, InterruptedException { diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java index afe5c4f7b..5ca1900b3 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2Test.java @@ -36,7 +36,7 @@ import org.testng.annotations.Test; * * @author JPEXS */ -public class ActionScript2Test extends ActionStript2TestBase { +public class ActionScript2Test extends ActionScript2TestBase { @BeforeClass public void init() throws IOException, InterruptedException { diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionStript2TestBase.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2TestBase.java similarity index 91% rename from libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionStript2TestBase.java rename to libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2TestBase.java index e2f1b4130..f1b89e932 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionStript2TestBase.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript2TestBase.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash; import com.jpexs.decompiler.flash.tags.DoActionTag; @@ -22,7 +23,7 @@ import com.jpexs.decompiler.flash.tags.Tag; * * @author JPEXS */ -public class ActionStript2TestBase extends ActionScriptTestBase { +public class ActionScript2TestBase extends ActionScriptTestBase { protected SWF swf; diff --git a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DeobfuscatorTest.java b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DeobfuscatorTest.java index e20343e45..d95ed7f62 100644 --- a/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DeobfuscatorTest.java +++ b/libsrc/ffdec_lib/test/com/jpexs/decompiler/flash/ActionScript3DeobfuscatorTest.java @@ -49,7 +49,7 @@ import org.testng.annotations.Test; * * @author JPEXS */ -public class ActionScript3DeobfuscatorTest extends ActionStript2TestBase { +public class ActionScript3DeobfuscatorTest extends ActionScript2TestBase { @BeforeClass public void init() throws IOException, InterruptedException { diff --git a/libsrc/ffdec_lib/testdata/run_as3/RunMain.as b/libsrc/ffdec_lib/testdata/run_as3/RunMain.as index 155ea8679..1d5839136 100644 --- a/libsrc/ffdec_lib/testdata/run_as3/RunMain.as +++ b/libsrc/ffdec_lib/testdata/run_as3/RunMain.as @@ -43,7 +43,7 @@ var result; try { - result = Run.run(); + result = testFunction(); } catch (e) { result = e.toString(); } @@ -55,7 +55,7 @@ try { var result = Run.run(); return "Result:" + result + " Type:" + typeof(result); - } catch (ex:Error) { + } catch (ex) { return "Error:" + ex; } }