AS3 instruction execution fixes

This commit is contained in:
honfika@gmail.com
2015-11-05 08:53:57 +01:00
parent 5e077eb024
commit e62b886a09
108 changed files with 620 additions and 428 deletions

View File

@@ -25,6 +25,8 @@ import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorGetSet;
import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorJumps;
import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorRegisters;
import com.jpexs.decompiler.flash.abc.avm2.deobfuscation.AVM2DeobfuscatorSimple;
import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2ExecutionException;
import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2VerifyErrorException;
import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2Graph;
import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2GraphSource;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;

View File

@@ -95,10 +95,10 @@ public class AVM2DeobfuscatorGetSet implements SWFDecompilerListener {
}
return new AVM2Instruction(0, AVM2Instructions.PushFalse, null);
}
if (ovalue instanceof Null) {
if (ovalue == Null.INSTANCE) {
return new AVM2Instruction(0, AVM2Instructions.PushNull, null);
}
if (ovalue instanceof Undefined) {
if (ovalue == Undefined.INSTANCE) {
return new AVM2Instruction(0, AVM2Instructions.PushUndefined, null);
}
return null;
@@ -281,5 +281,4 @@ public class AVM2DeobfuscatorGetSet implements SWFDecompilerListener {
removeUnreachableInstructions(code, body);
removeObfuscationGetSets(classIndex, isStatic, scriptIndex, abc, body, new ArrayList<>());
}
}

View File

@@ -13,7 +13,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. */
package com.jpexs.decompiler.flash.abc.avm2;
package com.jpexs.decompiler.flash.abc.avm2.exceptions;
/**
*

View File

@@ -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.exceptions;
/**
*
* @author JPEXS
*/
public class AVM2RangeErrorException extends AVM2ExecutionException {
public AVM2RangeErrorException(int code) {
super(codeToMessage(code, null));
}
public AVM2RangeErrorException(int code, Object[] params) {
super(codeToMessage(code, params));
}
private static String codeToMessage(int code, Object[] params) {
String msg = null;
switch (code) {
}
String result = "RangeError: Error #" + code;
/*if (msg != null) {
result += ": " + msg;
}*/
return result;
}
}

View File

@@ -13,7 +13,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. */
package com.jpexs.decompiler.flash.abc.avm2;
package com.jpexs.decompiler.flash.abc.avm2.exceptions;
/**
*

View File

@@ -13,7 +13,7 @@
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. */
package com.jpexs.decompiler.flash.abc.avm2;
package com.jpexs.decompiler.flash.abc.avm2.exceptions;
/**
*

View File

@@ -20,8 +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.exceptions.AVM2ExecutionException;
import com.jpexs.decompiler.flash.abc.avm2.exceptions.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;

View File

@@ -17,7 +17,7 @@
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.exceptions.AVM2ExecutionException;
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
/**

View File

@@ -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.AlchemyLoadAVM2Item;
@@ -39,10 +40,15 @@ public class Lf32Ins extends InstructionDefinition implements AlchemyTypeIns {
}
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
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);
}
// todo: get 32 bits float
lda.operandStack.push((Double) (double) (lda.getDomainMemory()[addr]));
lda.operandStack.push((Double) (double) (domainMemory[addr]));
return true;
}

View File

@@ -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.AlchemyLoadAVM2Item;
@@ -39,10 +40,15 @@ public class Lf64Ins extends InstructionDefinition implements AlchemyTypeIns {
}
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
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);
}
// todo: get 64 bits float
lda.operandStack.push((Double) (double) (lda.getDomainMemory()[addr]));
lda.operandStack.push((Double) (double) (domainMemory[addr]));
return true;
}

View File

@@ -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.AlchemyLoadAVM2Item;
@@ -39,10 +40,15 @@ public class Li16Ins extends InstructionDefinition implements AlchemyTypeIns {
}
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
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);
}
// todo: get 16 bits
lda.operandStack.push((Double) (double) (lda.getDomainMemory()[addr]));
lda.operandStack.push((Double) (double) (domainMemory[addr]));
return true;
}

View File

@@ -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.AlchemyLoadAVM2Item;
@@ -39,10 +40,15 @@ public class Li32Ins extends InstructionDefinition implements AlchemyTypeIns {
}
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
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);
}
// todo: get 32 bits
lda.operandStack.push((Double) (double) (lda.getDomainMemory()[addr]));
lda.operandStack.push((Double) (double) (domainMemory[addr]));
return true;
}

View File

@@ -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.AlchemyLoadAVM2Item;
@@ -39,9 +40,14 @@ public class Li8Ins extends InstructionDefinition implements AlchemyTypeIns {
}
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2RangeErrorException {
int addr = (int) (double) EcmaScript.toNumber(lda.operandStack.pop());
lda.operandStack.push((Double) (double) (lda.getDomainMemory()[addr]));
byte[] domainMemory = lda.getDomainMemory();
if (addr < 0 || addr >= domainMemory.length) {
throw new AVM2RangeErrorException(1506);
}
lda.operandStack.push((Double) (double) (domainMemory[addr]));
return true;
}

View File

@@ -18,17 +18,36 @@ 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.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;
public class AddIIns extends AddIns {
public class AddIIns extends InstructionDefinition {
public AddIIns() {
instructionName = "add_i";
instructionCode = 0xc5;
super(0xc5, "add_i", new int[]{}, true);
}
@Override
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);
}
return true;
}
@Override

View File

@@ -37,7 +37,7 @@ public class DecrementIIns extends InstructionDefinition {
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object obj = lda.operandStack.pop();
lda.operandStack.push(EcmaScript.toNumber(obj) - 1);
lda.operandStack.push(EcmaScript.toInt32(obj) - 1);
return true;
}

View File

@@ -37,7 +37,7 @@ public class DecrementIns extends InstructionDefinition {
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object obj = lda.operandStack.pop();
lda.operandStack.push(EcmaScript.toInt32(obj) - 1);
lda.operandStack.push(EcmaScript.toNumber(obj) - 1);
return true;
}

View File

@@ -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.DivideAVM2Item;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.List;
@@ -35,31 +36,10 @@ public class DivideIns extends InstructionDefinition {
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object o2 = lda.operandStack.pop();
Object o1 = lda.operandStack.pop();
if ((o1 instanceof Long) && ((o2 instanceof Long))) {
Long l1 = (Long) o1;
Long l2 = (Long) o2;
if (l1 % l2 == 0) {
Long ret = l1 / l2;
lda.operandStack.push(ret);
} else {
Double ret = l1.doubleValue() / l2.doubleValue();
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);
lda.operandStack.push(ret);
} else {
lda.executionException = "Cannot divide";
return false;
}
Object right = lda.operandStack.pop();
Object left = lda.operandStack.pop();
Double ret = EcmaScript.toNumber(left) / EcmaScript.toNumber(right);
lda.operandStack.push(ret);
return true;
}

View File

@@ -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.ModuloAVM2Item;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.List;
@@ -35,16 +36,10 @@ public class ModuloIns 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) o2) % ((Long) o1);
lda.operandStack.push(ret);
} else {
lda.executionException = "Cannot modulo";
return false;
}
Object right = lda.operandStack.pop();
Object left = lda.operandStack.pop();
Double ret = EcmaScript.toNumber(left) % EcmaScript.toNumber(right);
lda.operandStack.push(ret);
return true;
}

View File

@@ -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.MultiplyAVM2Item;
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 MultiplyIIns extends InstructionDefinition {
super(0xc7, "multiply_i", new int[]{}, true);
}
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object right = lda.operandStack.pop();
Object left = lda.operandStack.pop();
int ret = EcmaScript.toInt32(left) * EcmaScript.toInt32(right);
lda.operandStack.push(ret);
return true;
}
@Override
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
GraphTargetItem v2 = stack.pop();

View File

@@ -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.MultiplyAVM2Item;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.List;
@@ -35,24 +36,10 @@ public class MultiplyIns 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);
lda.operandStack.push(ret);
} else {
lda.executionException = "Cannot multiply";
return false;
}
Object right = lda.operandStack.pop();
Object left = lda.operandStack.pop();
Double ret = EcmaScript.toNumber(left) * EcmaScript.toNumber(right);
lda.operandStack.push(ret);
return true;
}

View File

@@ -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,15 @@ public class SubtractIIns extends InstructionDefinition {
super(0xc6, "subtract_i", new int[]{}, true);
}
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object right = lda.operandStack.pop();
Object left = lda.operandStack.pop();
int ret = EcmaScript.toInt32(left) - EcmaScript.toInt32(right);
lda.operandStack.push(ret);
return true;
}
@Override
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
GraphTargetItem v2 = stack.pop();

View File

@@ -40,7 +40,6 @@ public class SubtractIns extends InstructionDefinition {
Object left = lda.operandStack.pop();
Double ret = EcmaScript.toNumber(left) - EcmaScript.toNumber(right);
lda.operandStack.push(ret);
return true;
}

View File

@@ -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.LShiftAVM2Item;
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 LShiftIns extends InstructionDefinition {
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
int value2 = (int) ((Long) lda.operandStack.pop() & 0x1F);
int value1 = ((Long) lda.operandStack.pop()).intValue();
Long value3 = (long) (value1 << value2);
int value2 = EcmaScript.toInt32(lda.operandStack.pop()) & 0x1F;
long value1 = EcmaScript.toInt32(lda.operandStack.pop());
long value3 = value1 << value2;
lda.operandStack.push(value3);
return true;
}

View File

@@ -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.RShiftAVM2Item;
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 RShiftIns extends InstructionDefinition {
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
int value2 = (int) ((Long) lda.operandStack.pop() & 0x1F);
int value1 = ((Long) lda.operandStack.pop()).intValue();
Long value3 = (long) (value1 >> value2);
int value2 = EcmaScript.toInt32(lda.operandStack.pop()) & 0x1F;
long value1 = EcmaScript.toInt32(lda.operandStack.pop());
long value3 = value1 >> value2;
lda.operandStack.push(value3);
return true;
}

View File

@@ -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.URShiftAVM2Item;
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 URShiftIns extends InstructionDefinition {
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Long value2 = ((Long) lda.operandStack.pop() & 0x1F);
Long value1 = (Long) lda.operandStack.pop();
Long value3 = value1 >>> value2;
int value2 = EcmaScript.toInt32(lda.operandStack.pop()) & 0x1F;
long value1 = EcmaScript.toInt32(lda.operandStack.pop());
long value3 = value1 >>> value2;
lda.operandStack.push(value3);
return true;
}

View File

@@ -40,10 +40,10 @@ public class IfEqIns extends InstructionDefinition implements IfTypeIns {
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Double right = EcmaScript.toNumber(lda.operandStack.pop());
Double left = EcmaScript.toNumber(lda.operandStack.pop());
Object rightObj = lda.operandStack.pop();
Object leftObj = lda.operandStack.pop();
if (left == right) {
if (EcmaScript.equals(leftObj, rightObj)) {
lda.jump = ins.getParamAsLong(constants, 0);
}

View File

@@ -27,6 +27,7 @@ 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.flash.ecma.Undefined;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
@@ -40,10 +41,11 @@ public class IfGeIns extends InstructionDefinition implements IfTypeIns {
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Double right = EcmaScript.toNumber(lda.operandStack.pop());
Double left = EcmaScript.toNumber(lda.operandStack.pop());
Object rightObj = lda.operandStack.pop();
Object leftObj = lda.operandStack.pop();
if (left >= right) {
Object cmp = EcmaScript.compare(leftObj, rightObj);
if (cmp != Undefined.INSTANCE && ((int) cmp) != -1) {
lda.jump = ins.getParamAsLong(constants, 0);
}

View File

@@ -27,6 +27,7 @@ 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.flash.ecma.Undefined;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
@@ -40,10 +41,11 @@ public class IfGtIns extends InstructionDefinition implements IfTypeIns {
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Double right = EcmaScript.toNumber(lda.operandStack.pop());
Double left = EcmaScript.toNumber(lda.operandStack.pop());
Object rightObj = lda.operandStack.pop();
Object leftObj = lda.operandStack.pop();
if (left > right) {
Object cmp = EcmaScript.compare(leftObj, rightObj);
if (cmp != Undefined.INSTANCE && ((int) cmp) == 1) {
lda.jump = ins.getParamAsLong(constants, 0);
}

View File

@@ -27,6 +27,7 @@ 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.flash.ecma.Undefined;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
@@ -40,10 +41,11 @@ public class IfLeIns extends InstructionDefinition implements IfTypeIns {
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Double right = EcmaScript.toNumber(lda.operandStack.pop());
Double left = EcmaScript.toNumber(lda.operandStack.pop());
Object rightObj = lda.operandStack.pop();
Object leftObj = lda.operandStack.pop();
if (left <= right) {
Object cmp = EcmaScript.compare(leftObj, rightObj);
if (cmp != Undefined.INSTANCE && ((int) cmp) != 1) {
lda.jump = ins.getParamAsLong(constants, 0);
}

View File

@@ -27,6 +27,7 @@ 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.flash.ecma.Undefined;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
@@ -40,10 +41,11 @@ public class IfLtIns extends InstructionDefinition implements IfTypeIns {
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Double right = EcmaScript.toNumber(lda.operandStack.pop());
Double left = EcmaScript.toNumber(lda.operandStack.pop());
Object rightObj = lda.operandStack.pop();
Object leftObj = lda.operandStack.pop();
if (left < right) {
Object cmp = EcmaScript.compare(leftObj, rightObj);
if (cmp != Undefined.INSTANCE && ((int) cmp) == -1) {
lda.jump = ins.getParamAsLong(constants, 0);
}

View File

@@ -27,6 +27,7 @@ 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.flash.ecma.Undefined;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
@@ -40,10 +41,11 @@ public class IfNGeIns extends InstructionDefinition implements IfTypeIns {
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Double right = EcmaScript.toNumber(lda.operandStack.pop());
Double left = EcmaScript.toNumber(lda.operandStack.pop());
Object rightObj = lda.operandStack.pop();
Object leftObj = lda.operandStack.pop();
if (!(left >= right)) {
Object cmp = EcmaScript.compare(leftObj, rightObj);
if (cmp == Undefined.INSTANCE || ((int) cmp) == -1) {
lda.jump = ins.getParamAsLong(constants, 0);
}

View File

@@ -27,6 +27,7 @@ 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.flash.ecma.Undefined;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
@@ -40,10 +41,11 @@ public class IfNGtIns extends InstructionDefinition implements IfTypeIns {
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Double right = EcmaScript.toNumber(lda.operandStack.pop());
Double left = EcmaScript.toNumber(lda.operandStack.pop());
Object rightObj = lda.operandStack.pop();
Object leftObj = lda.operandStack.pop();
if (!(left > right)) {
Object cmp = EcmaScript.compare(leftObj, rightObj);
if (cmp == Undefined.INSTANCE || ((int) cmp) != 1) {
lda.jump = ins.getParamAsLong(constants, 0);
}

View File

@@ -27,6 +27,7 @@ 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.flash.ecma.Undefined;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
@@ -40,10 +41,11 @@ public class IfNLeIns extends InstructionDefinition implements IfTypeIns {
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Double right = EcmaScript.toNumber(lda.operandStack.pop());
Double left = EcmaScript.toNumber(lda.operandStack.pop());
Object rightObj = lda.operandStack.pop();
Object leftObj = lda.operandStack.pop();
if (!(left <= right)) {
Object cmp = EcmaScript.compare(leftObj, rightObj);
if (cmp == Undefined.INSTANCE || ((int) cmp) == 1) {
lda.jump = ins.getParamAsLong(constants, 0);
}

View File

@@ -27,6 +27,7 @@ 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.flash.ecma.Undefined;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.HashMap;
@@ -40,10 +41,11 @@ public class IfNLtIns extends InstructionDefinition implements IfTypeIns {
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Double right = EcmaScript.toNumber(lda.operandStack.pop());
Double left = EcmaScript.toNumber(lda.operandStack.pop());
Object rightObj = lda.operandStack.pop();
Object leftObj = lda.operandStack.pop();
if (!(left < right)) {
Object cmp = EcmaScript.compare(leftObj, rightObj);
if (cmp == Undefined.INSTANCE || ((int) cmp) != -1) {
lda.jump = ins.getParamAsLong(constants, 0);
}

View File

@@ -40,10 +40,10 @@ public class IfNeIns extends InstructionDefinition implements IfTypeIns {
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Double right = EcmaScript.toNumber(lda.operandStack.pop());
Double left = EcmaScript.toNumber(lda.operandStack.pop());
Object rightObj = lda.operandStack.pop();
Object leftObj = lda.operandStack.pop();
if (left != right) {
if (!EcmaScript.equals(leftObj, rightObj)) {
lda.jump = ins.getParamAsLong(constants, 0);
}

View File

@@ -19,7 +19,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -17,7 +17,7 @@
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.exceptions.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;

View File

@@ -17,6 +17,10 @@
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.exceptions.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 BkptLineIns extends InstructionDefinition {
@@ -24,4 +28,10 @@ public class BkptLineIns extends InstructionDefinition {
public BkptLineIns() {
super(0xF2, "bkptline", new int[]{AVM2Code.OPT_U30}, false /*?*/);
}
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2ExecutionException {
// do nothing
return true;
}
}

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -17,7 +17,7 @@
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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -38,7 +38,7 @@ public class CoerceOIns extends InstructionDefinition implements CoerceOrConvert
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) {
if (value == Undefined.INSTANCE) {
value = Null.INSTANCE;
}

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -19,7 +19,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -19,7 +19,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -19,7 +19,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -17,7 +17,7 @@
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.exceptions.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;

View File

@@ -17,7 +17,7 @@
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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -19,7 +19,7 @@ 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.exceptions.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;

View File

@@ -19,7 +19,7 @@ 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.exceptions.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;

View File

@@ -19,7 +19,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -19,7 +19,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -19,7 +19,7 @@ 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.exceptions.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;

View File

@@ -17,7 +17,7 @@
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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -17,7 +17,7 @@
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.exceptions.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;

View File

@@ -19,7 +19,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -18,7 +18,7 @@ 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.exceptions.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;

View File

@@ -20,8 +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.AVM2TypeErrorException;
import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2ExecutionException;
import com.jpexs.decompiler.flash.abc.avm2.exceptions.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;
@@ -30,6 +30,8 @@ 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.flash.ecma.Null;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
import java.util.List;
@@ -48,6 +50,10 @@ public class CoerceIns extends InstructionDefinition implements CoerceOrConvertT
}
Object value = lda.operandStack.pop();
if (value == Undefined.INSTANCE) {
value = Null.INSTANCE;
}
EcmaType type = EcmaScript.type(value);
if (type != EcmaType.NULL && type != EcmaType.OBJECT) {
throw new AVM2TypeErrorException(1034);

View File

@@ -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.CoerceAVM2Item;
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.TranslateStack;
@@ -37,8 +39,17 @@ public class CoerceSIns extends InstructionDefinition implements CoerceOrConvert
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object obj = lda.operandStack.pop();
lda.operandStack.push(obj.toString());
Object value = lda.operandStack.pop();
if (value == Undefined.INSTANCE) {
value = Null.INSTANCE;
}
if (value == Null.INSTANCE) {
lda.operandStack.push(value);
} else {
lda.operandStack.push(value.toString());
}
return true;
}

View File

@@ -19,10 +19,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.exceptions.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.ConvertAVM2Item;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.ecma.EcmaType;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TranslateStack;
@@ -36,7 +39,12 @@ public class ConvertOIns extends InstructionDefinition implements CoerceOrConver
}
@Override
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
public boolean execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) throws AVM2TypeErrorException {
Object obj = lda.operandStack.peek();
if (EcmaScript.type(obj) == EcmaType.UNDEFINED) {
throw new AVM2TypeErrorException(1010);
}
//throw if pop is not object
return true;
}

View File

@@ -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.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;
@@ -38,34 +37,7 @@ public class TypeOfIns extends InstructionDefinition {
@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;
}
String typeStr = EcmaScript.typeString(res);
lda.operandStack.push(typeStr);
return true;
}

View File

@@ -78,10 +78,10 @@ public class CoerceAVM2Item extends AVM2Item {
Object ret = value.getResult();
switch (typeObj.toString()) {
case "String":
if (ret instanceof Null) {
if (ret == Null.INSTANCE) {
return ret;
}
if (ret instanceof Undefined) {
if (ret == Undefined.INSTANCE) {
return Null.INSTANCE;
}
return ret.toString();

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -54,13 +55,12 @@ public class GeAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi
@Override
public Object getResult() {
Object ret = EcmaScript.compare(leftSide.getResult(), rightSide.getResult());
if (ret == Boolean.TRUE) {
return Boolean.FALSE;
if (ret == Undefined.INSTANCE) {
return ret;
}
if (ret == Boolean.FALSE) {
return Boolean.TRUE;
}
return ret;//undefined
int reti = (int) ret;
return reti != -1;
}
@Override

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -53,7 +54,13 @@ public class GtAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi
@Override
public Object getResult() {
return EcmaScript.compare(rightSide.getResult(), leftSide.getResult());
Object ret = EcmaScript.compare(rightSide.getResult(), leftSide.getResult());
if (ret == Undefined.INSTANCE) {
return ret;
}
int reti = (int) ret;
return reti == -1;
}
@Override

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -54,13 +55,12 @@ public class LeAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi
@Override
public Object getResult() {
Object ret = EcmaScript.compare(rightSide.getResult(), leftSide.getResult());
if (ret == Boolean.TRUE) {
return Boolean.FALSE;
if (ret == Undefined.INSTANCE) {
return ret;
}
if (ret == Boolean.FALSE) {
return Boolean.TRUE;
}
return ret;//undefined
int reti = (int) ret;
return reti != -1;
}
@Override

View File

@@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instructions;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -53,7 +54,13 @@ public class LtAVM2Item extends BinaryOpItem implements LogicalOpItem, IfConditi
@Override
public Object getResult() {
return EcmaScript.compare(leftSide.getResult(), rightSide.getResult());
Object ret = EcmaScript.compare(leftSide.getResult(), rightSide.getResult());
if (ret == Undefined.INSTANCE) {
return ret;
}
int reti = (int) ret;
return reti == -1;
}
@Override

View File

@@ -737,7 +737,7 @@ public abstract class Action implements GraphSourceItem {
protected long popLong(TranslateStack stack) {
GraphTargetItem item = stack.pop();
if (item instanceof DirectValueActionItem) {
return (long) (double) EcmaScript.toNumber(((DirectValueActionItem) item).value);
return (long) (double) EcmaScript.toNumberAs2(((DirectValueActionItem) item).value);
}
return 0;
@@ -1021,7 +1021,7 @@ public abstract class Action implements GraphSourceItem {
}
//return in for..in
if ((action instanceof ActionPush) && (((ActionPush) action).values.size() == 1) && (((ActionPush) action).values.get(0) instanceof Null)) {
if ((action instanceof ActionPush) && (((ActionPush) action).values.size() == 1) && (((ActionPush) action).values.get(0) == Null.INSTANCE)) {
if (ip + 3 <= end) {
if ((actions.get(ip + 1) instanceof ActionEquals) || (actions.get(ip + 1) instanceof ActionEquals2)) {
if (actions.get(ip + 2) instanceof ActionNot) {
@@ -1355,10 +1355,10 @@ public abstract class Action implements GraphSourceItem {
if (o instanceof Long) {
return (Long) o;
}
if (o instanceof Null) {
if (o == Null.INSTANCE) {
return Double.NaN;
}
if (o instanceof Undefined) {
if (o == Undefined.INSTANCE) {
return Double.NaN;
}
if (o instanceof Boolean) {

View File

@@ -168,7 +168,7 @@ public class ActionGraph extends Graph {
NeqActionItem ne = (NeqActionItem) wi.expression.get(wi.expression.size() - 1);
if (ne.rightSide instanceof DirectValueActionItem) {
DirectValueActionItem dv = (DirectValueActionItem) ne.rightSide;
if (dv.value instanceof Null) {
if (dv.value == Null.INSTANCE) {
GraphTargetItem en = list.get(t - 1);
if (en instanceof EnumerateActionItem) {
EnumerateActionItem eti = (EnumerateActionItem) en;
@@ -467,7 +467,7 @@ public class ActionGraph extends Graph {
int oldIp = ip;
//return in for..in
GraphSourceItem action = code.get(ip);
if ((action instanceof ActionPush) && (((ActionPush) action).values.size() == 1) && (((ActionPush) action).values.get(0) instanceof Null)) {
if ((action instanceof ActionPush) && (((ActionPush) action).values.size() == 1) && (((ActionPush) action).values.get(0) == Null.INSTANCE)) {
if (ip + 4 < code.size()) {
if ((code.get(ip + 1) instanceof ActionEquals) || (code.get(ip + 1) instanceof ActionEquals2)) {
if (code.get(ip + 2) instanceof ActionNot) {

View File

@@ -59,6 +59,6 @@ public class LocalDataArea {
}
public Double popAsNumber() {
return EcmaScript.toNumber(stack.pop());
return EcmaScript.toNumberAs2(stack.pop());
}
}

View File

@@ -58,7 +58,7 @@ public class CallMethodActionItem extends ActionItem {
boolean blankMethod = false;
boolean dvai = methodName instanceof DirectValueActionItem;
if (dvai) {
if (((DirectValueActionItem) methodName).value instanceof Undefined) {
if (((DirectValueActionItem) methodName).value == Undefined.INSTANCE) {
blankMethod = true;
}
if (((DirectValueActionItem) methodName).value instanceof String) {

View File

@@ -188,7 +188,7 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue {
}
dependencies.add(computedRegValue);
}
return (value instanceof Double) || (value instanceof Float) || (value instanceof Boolean) || (value instanceof Long) || (value instanceof Null) || (computedRegValue != null && computedRegValue.isCompileTime(dependencies)) || (value instanceof String) || (value instanceof ConstantIndex);
return (value instanceof Double) || (value instanceof Float) || (value instanceof Boolean) || (value instanceof Long) || (value == Null.INSTANCE) || (computedRegValue != null && computedRegValue.isCompileTime(dependencies)) || (value instanceof String) || (value instanceof ConstantIndex);
}
@Override

View File

@@ -80,10 +80,10 @@ public class MBStringExtractActionItem extends ActionItem {
public static String getResult(Object count, Object index, Object value) {
String str = EcmaScript.toString(value);
int idx = (int) (double) EcmaScript.toNumber(index);
int idx = (int) (double) EcmaScript.toNumberAs2(index);
idx--; // index seems to be 1 based
int cnt = (int) (double) EcmaScript.toNumber(count);
int cnt = (int) (double) EcmaScript.toNumberAs2(count);
/*if (idx < 0) {
idx = str.length() + idx;

View File

@@ -63,7 +63,7 @@ public class MBStringLengthActionItem extends ActionItem {
}
public static Double getResult(Object obj) {
return EcmaScript.toNumber(EcmaScript.toString(obj).length());
return EcmaScript.toNumberAs2(EcmaScript.toString(obj).length());
}
@Override

View File

@@ -56,7 +56,7 @@ public class NewMethodActionItem extends ActionItem {
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
boolean blankMethod = false;
if (methodName instanceof DirectValueActionItem) {
if (((DirectValueActionItem) methodName).value instanceof Undefined) {
if (((DirectValueActionItem) methodName).value == Undefined.INSTANCE) {
blankMethod = true;
} else if (((DirectValueActionItem) methodName).value instanceof String) {
if (((DirectValueActionItem) methodName).value.equals("")) {
@@ -71,7 +71,7 @@ public class NewMethodActionItem extends ActionItem {
if (!blankMethod) {
writer.append(".");
if (methodName instanceof DirectValueActionItem) {
if (((DirectValueActionItem) methodName).value instanceof Undefined) {
if (((DirectValueActionItem) methodName).value == Undefined.INSTANCE) {
} else if (((DirectValueActionItem) methodName).value instanceof String) {
((DirectValueActionItem) methodName).toStringNoQuotes(writer, localData);
} else {

View File

@@ -69,10 +69,10 @@ public class StringExtractActionItem extends ActionItem {
public static String getResult(Object count, Object index, Object value) {
String str = EcmaScript.toString(value);
int idx = (int) (double) EcmaScript.toNumber(index);
int idx = (int) (double) EcmaScript.toNumberAs2(index);
idx--; // index seems to be 1 based
int cnt = (int) (double) EcmaScript.toNumber(count);
int cnt = (int) (double) EcmaScript.toNumberAs2(count);
/*if (idx < 0) {
idx = str.length() + idx;

View File

@@ -55,7 +55,7 @@ public class StringLengthActionItem extends ActionItem {
}
public static Double getResult(Object obj) {
return EcmaScript.toNumber(EcmaScript.toString(obj).length());
return EcmaScript.toNumberAs2(EcmaScript.toString(obj).length());
}
@Override

View File

@@ -71,7 +71,7 @@ public class AddActionItem extends BinaryOpItem {
if (EcmaScript.type(leftResult) == EcmaType.STRING || EcmaScript.type(rightResult) == EcmaType.STRING) {
return EcmaScript.toString(leftResult) + EcmaScript.toString(rightResult);
}
return EcmaScript.toNumber(leftResult) + EcmaScript.toNumber(rightResult);
return EcmaScript.toNumberAs2(leftResult) + EcmaScript.toNumberAs2(rightResult);
} else {
return Action.toFloatPoint(leftResult) + Action.toFloatPoint(rightResult);
}

View File

@@ -23,6 +23,7 @@ import com.jpexs.decompiler.flash.action.swf4.ActionLess;
import com.jpexs.decompiler.flash.action.swf4.ActionNot;
import com.jpexs.decompiler.flash.action.swf5.ActionLess2;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.ecma.Undefined;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -44,14 +45,13 @@ public class GeActionItem extends BinaryOpItem implements LogicalOpItem, Inverte
@Override
public Object getResult() {
if (version2) {
Object ret = EcmaScript.compare(leftSide.getResult(), rightSide.getResult());
if (ret == Boolean.TRUE) {
return Boolean.FALSE;
Object ret = EcmaScript.compare(leftSide.getResult(), rightSide.getResult(), true);
if (ret == Undefined.INSTANCE) {
return ret;
}
if (ret == Boolean.FALSE) {
return Boolean.TRUE;
}
return ret;//undefined
int reti = (int) ret;
return reti != -1;
} else {
//For SWF 4 and older, it should return 1 or 0
return Action.toFloatPoint(leftSide.getResult()) >= Action.toFloatPoint(rightSide.getResult());

Some files were not shown because too many files have changed in this diff Show More