small improvements, little bit faster decompilation by caching the number values of the strings

This commit is contained in:
honfika@gmail.com
2015-10-23 12:56:27 +02:00
parent cbb3b1bff2
commit a4f4dd3604
120 changed files with 291 additions and 288 deletions

View File

@@ -648,13 +648,13 @@ public class AVM2Code implements Cloneable {
while (true) {
AVM2Instruction ins = code.get(pos);
if (ins.definition instanceof JumpIns) {
pos = adr2pos((Long) ins.getParamsAsList(constants).get(0));
pos = adr2pos(ins.getParamAsLong(constants, 0));
continue;
}
if (ins.definition instanceof IfFalseIns) {
Boolean b = (Boolean) lda.operandStack.pop();
if (b == false) {
pos = adr2pos((Long) ins.getParamsAsList(constants).get(0));
pos = adr2pos(ins.getParamAsLong(constants, 0));
} else {
pos++;
}
@@ -663,7 +663,7 @@ public class AVM2Code implements Cloneable {
if (ins.definition instanceof IfTrueIns) {
Boolean b = (Boolean) lda.operandStack.pop();
if (b == true) {
pos = adr2pos((Long) ins.getParamsAsList(constants).get(0));
pos = adr2pos(ins.getParamAsLong(constants, 0));
} else {
pos++;
}
@@ -675,7 +675,7 @@ public class AVM2Code implements Cloneable {
if (ins.definition instanceof ReturnVoidIns) {
return null;
}
ins.definition.execute(lda, constants, ins.getParamsAsList(constants));
ins.definition.execute(lda, constants, ins);
pos++;
}
} catch (ConvertException e) {
@@ -853,7 +853,7 @@ public class AVM2Code implements Cloneable {
if (instr != null) {
int[] actualOperands = null;
if (instructionCode == 0x1b) { // switch
if (instructionCode == AVM2Instructions.LookupSwitch) { // switch
int firstOperand = ais.readS24("default_offset");
int case_count = ais.readU30("case_count");
long afterCasePos = ais.getPosition() + 3 * (case_count + 1);

View File

@@ -155,7 +155,7 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener {
return makePush(fv.value, cpool);
} else if (graphTargetItem instanceof StringAVM2Item) {
StringAVM2Item fv = (StringAVM2Item) graphTargetItem;
return makePush(fv.value, cpool);
return makePush(fv.getValue(), cpool);
} else if (graphTargetItem instanceof TrueItem) {
return makePush(Boolean.TRUE, cpool);
} else if (graphTargetItem instanceof FalseItem) {
@@ -335,8 +335,8 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener {
|| def instanceof SubtractIIns
|| def instanceof ModuloIns
|| def instanceof MultiplyIns
|| def instanceof MultiplyIIns
|| def instanceof DivideIns
|| def instanceof MultiplyIIns//
|| def instanceof DivideIns//
|| def instanceof BitAndIns
|| def instanceof BitXorIns
|| def instanceof BitOrIns
@@ -345,12 +345,12 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener {
|| def instanceof URShiftIns
|| def instanceof EqualsIns
|| def instanceof NotIns
|| def instanceof NegateIns
|| def instanceof NegateIIns
|| def instanceof IncrementIns
|| def instanceof IncrementIIns
|| def instanceof DecrementIns
|| def instanceof DecrementIIns
|| def instanceof NegateIns//
|| def instanceof NegateIIns//
|| def instanceof IncrementIns//
|| def instanceof IncrementIIns//
|| def instanceof DecrementIns//
|| def instanceof DecrementIIns //
|| def instanceof IfTypeIns
|| def instanceof JumpIns
|| def instanceof EqualsIns

View File

@@ -55,7 +55,6 @@ import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictEqAVM2Item;
import com.jpexs.decompiler.flash.abc.avm2.model.operations.StrictNeqAVM2Item;
import com.jpexs.decompiler.flash.abc.types.ABCException;
import com.jpexs.decompiler.flash.abc.types.MethodBody;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.graph.DottedChain;
import com.jpexs.decompiler.graph.Graph;
import com.jpexs.decompiler.graph.GraphPart;
@@ -673,7 +672,7 @@ public class AVM2Graph extends Graph {
if (stack != null && swip != -1) {
AVM2Instruction swIns = avm2code.code.get(swip);
GraphTargetItem t = stack.pop();
Double dval = EcmaScript.toNumber(t.getResult());
Double dval = t.getResultAsNumber();
int val = (int) (double) dval;
if (swIns.definition instanceof LookupSwitchIns) {
List<Integer> branches = swIns.getBranches(code);

View File

@@ -171,48 +171,40 @@ public class AVM2Instruction implements Cloneable, GraphSourceItem {
}
break;
}
}
return ret;
}
public List<Object> getParamsAsList(AVM2ConstantPool constants) {
List<Object> s = new ArrayList<>();
for (int i = 0; i < definition.operands.length; i++) {
switch (definition.operands[i]) {
case AVM2Code.DAT_MULTINAME_INDEX:
s.add(constants.getMultiname(operands[i]));
break;
case AVM2Code.DAT_STRING_INDEX:
s.add(constants.getString(operands[i]));
break;
case AVM2Code.DAT_INT_INDEX:
s.add(constants.getInt(operands[i]));
break;
case AVM2Code.DAT_UINT_INDEX:
s.add(constants.getUInt(operands[i]));
break;
case AVM2Code.DAT_DOUBLE_INDEX:
s.add(constants.getDouble(operands[i]));
break;
case AVM2Code.DAT_OFFSET:
s.add(offset + operands[i] + getBytesLength());
break;
case AVM2Code.DAT_CASE_BASEOFFSET:
s.add(offset + operands[i]);
break;
case AVM2Code.OPT_CASE_OFFSETS:
s.add((long) operands[i]);
for (int j = i + 1; j < operands.length; j++) {
s.add(offset + operands[j]);
}
break;
default:
s.add((long) operands[i]);
}
public Object getParam(AVM2ConstantPool constants, int idx) {
//if (idx < 0 || idx >= definition.operands.length) {
// return null;
//}
switch (definition.operands[idx]) {
case AVM2Code.DAT_MULTINAME_INDEX:
return constants.getMultiname(operands[idx]);
case AVM2Code.DAT_STRING_INDEX:
return constants.getString(operands[idx]);
case AVM2Code.DAT_INT_INDEX:
return constants.getInt(operands[idx]);
case AVM2Code.DAT_UINT_INDEX:
return constants.getUInt(operands[idx]);
case AVM2Code.DAT_DOUBLE_INDEX:
return constants.getDouble(operands[idx]);
case AVM2Code.DAT_OFFSET:
return offset + operands[idx] + getBytesLength();
case AVM2Code.DAT_CASE_BASEOFFSET:
return offset + operands[idx];
case AVM2Code.OPT_CASE_OFFSETS:
return (long) operands[idx]; // offsets: offset + operands[i];
default:
return (long) operands[idx];
}
return s;
}
public Long getParamAsLong(AVM2ConstantPool constants, int idx) {
return (Long) getParam(constants, idx);
}
public String getParams(AVM2ConstantPool constants, List<DottedChain> fullyQualifiedNames) {

View File

@@ -84,7 +84,7 @@ public abstract class InstructionDefinition implements Serializable {
return s.toString();
}
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
throw new UnsupportedOperationException("Instruction " + instructionName + " not implemented");
}

View File

@@ -34,7 +34,7 @@ public class AddIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object o1 = lda.operandStack.pop();
Object o2 = lda.operandStack.pop();
if ((o1 instanceof Long) && ((o2 instanceof Long))) {

View File

@@ -34,7 +34,7 @@ public class DecrementIIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object obj = lda.operandStack.pop();
if (obj instanceof Long) {
Long obj2 = ((Long) obj) - 1;

View File

@@ -34,7 +34,7 @@ public class DecrementIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object obj = lda.operandStack.pop();
if (obj instanceof Long) {
Long obj2 = ((Long) obj) - 1;

View File

@@ -34,7 +34,7 @@ public class DivideIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object o2 = lda.operandStack.pop();
Object o1 = lda.operandStack.pop();
if ((o1 instanceof Long) && ((o2 instanceof Long))) {

View File

@@ -34,7 +34,7 @@ public class ModuloIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object o1 = lda.operandStack.pop();
Object o2 = lda.operandStack.pop();

View File

@@ -34,7 +34,7 @@ public class MultiplyIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object o1 = lda.operandStack.pop();
Object o2 = lda.operandStack.pop();
if ((o1 instanceof Long) && ((o2 instanceof Long))) {

View File

@@ -34,7 +34,7 @@ public class BitAndIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Long value2 = (Long) lda.operandStack.pop();
Long value1 = (Long) lda.operandStack.pop();
Long value3 = value1 & value2;

View File

@@ -34,7 +34,7 @@ public class BitNotIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Long value = (Long) lda.operandStack.pop();
Long ret = -value;
lda.operandStack.push(ret);

View File

@@ -34,7 +34,7 @@ public class BitOrIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Long value2 = (Long) lda.operandStack.pop();
Long value1 = (Long) lda.operandStack.pop();
Long value3 = value1 | value2;

View File

@@ -34,7 +34,7 @@ public class BitXorIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Long value2 = (Long) lda.operandStack.pop();
Long value1 = (Long) lda.operandStack.pop();
Long value3 = value1 ^ value2;

View File

@@ -34,7 +34,7 @@ public class LShiftIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void 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);

View File

@@ -34,7 +34,7 @@ public class RShiftIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void 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);

View File

@@ -34,7 +34,7 @@ public class URShiftIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Long value2 = ((Long) lda.operandStack.pop() & 0x1F);
Long value1 = (Long) lda.operandStack.pop();
Long value3 = value1 >>> value2;

View File

@@ -34,7 +34,7 @@ public class EqualsIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object obj1 = lda.operandStack.pop();
Object obj2 = lda.operandStack.pop();
Boolean res = obj1.equals(obj2);

View File

@@ -45,8 +45,8 @@ public class ConstructIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
/*int argCount = (int) ((Long) arguments.get(0)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
/*int argCount = ins.getParamAsLong(constants, 0).intValue();
List<Object> passArguments = new ArrayList<Object>();
for (int i = argCount - 1; i >= 0; i--) {
passArguments.set(i, lda.operandStack.pop());

View File

@@ -38,9 +38,9 @@ public class ConstructPropIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
/*int multinameIndex = (int) ((Long) arguments.get(0)).longValue();
int argCount = (int) ((Long) arguments.get(1)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
/*int multinameIndex = ins.getParamAsLong(constants, 0).intValue();
int argCount = ins.getParamAsLong(constants, 1).intValue();
List<Object> passArguments = new ArrayList<Object>();
for (int i = argCount - 1; i >= 0; i--) {
passArguments.set(i, lda.operandStack.pop());

View File

@@ -36,8 +36,8 @@ public class ConstructSuperIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
/*int argCount = (int) ((Long) arguments.get(0)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
/*int argCount = ins.getParamAsLong(constants, 0).intValue();
List<Object> passArguments = new ArrayList<Object>();
for (int i = argCount - 1; i >= 0; i--) {
passArguments.set(i, lda.operandStack.pop());

View File

@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.debug;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import java.util.List;
@@ -29,6 +30,6 @@ public class DebugFileIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
}
}

View File

@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.debug;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import java.util.List;
@@ -29,6 +30,6 @@ public class DebugIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
}
}

View File

@@ -19,6 +19,7 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.debug;
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
import java.util.List;
@@ -29,6 +30,6 @@ public class DebugLineIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
}
}

View File

@@ -36,8 +36,8 @@ public class CallIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
/*int argCount = (int) ((Long) arguments.get(0)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
/*int argCount = ins.getParamAsLong(constants, 0).intValue();
List<Object> passArguments = new ArrayList<Object>();
for (int i = argCount - 1; i >= 0; i--) {
passArguments.set(i, lda.operandStack.pop());

View File

@@ -36,9 +36,9 @@ public class CallMethodIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
/*int methodIndex = (int) ((Long) arguments.get(0)).longValue(); //index of object's method
int argCount = (int) ((Long) arguments.get(1)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
/*int methodIndex = ins.getParamAsLong(constants, 0).intValue(); //index of object's method
int argCount = ins.getParamAsLong(constants, 1).intValue();
List<Object> passArguments = new ArrayList<Object>();
for (int i = argCount - 1; i >= 0; i--) {
passArguments.set(i, lda.operandStack.pop());

View File

@@ -37,11 +37,11 @@ public class CallPropVoidIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
//same as callproperty
/*
int multinameIndex = (int) ((Long) arguments.get(0)).longValue();
int argCount = (int) ((Long) arguments.get(1)).longValue();
int multinameIndex = ins.getParamAsLong(constants, 0).intValue();
int argCount = ins.getParamAsLong(constants, 1).intValue();
List<Object> passArguments = new ArrayList<Object>();
for (int i = argCount - 1; i >= 0; i--) {
passArguments.set(i, lda.operandStack.pop());

View File

@@ -37,9 +37,9 @@ public class CallPropertyIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
/*int multinameIndex = (int) ((Long) arguments.get(0)).longValue();
int argCount = (int) ((Long) arguments.get(1)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
/*int multinameIndex = ins.getParamAsLong(constants, 0).intValue();
int argCount = ins.getParamAsLong(constants, 1).intValue();
List<Object> passArguments = new ArrayList<Object>();
for (int i = argCount - 1; i >= 0; i--) {
passArguments.set(i, lda.operandStack.pop());

View File

@@ -36,9 +36,9 @@ public class CallStaticIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
/*int methodIndex = (int) ((Long) arguments.get(0)).longValue(); //index of method_info
int argCount = (int) ((Long) arguments.get(1)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
/*int methodIndex = ins.getParamAsLong(constants, 0).intValue(); //index of method_info
int argCount = ins.getParamAsLong(constants, 1).intValue();
List<Object> passArguments = new ArrayList<Object>();
for (int i = argCount - 1; i >= 0; i--) {
passArguments.set(i, lda.operandStack.pop());

View File

@@ -37,9 +37,9 @@ public class CallSuperIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
/*int multinameIndex = (int) ((Long) arguments.get(0)).longValue();
int argCount = (int) ((Long) arguments.get(1)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
/*int multinameIndex = ins.getParamAsLong(constants, 0).intValue();
int argCount = ins.getParamAsLong(constants, 1).intValue();
List<Object> passArguments = new ArrayList<Object>();
for (int i = argCount - 1; i >= 0; i--) {
passArguments.set(i, lda.operandStack.pop());

View File

@@ -37,9 +37,9 @@ public class CallSuperVoidIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
/*int multinameIndex = (int) ((Long) arguments.get(0)).longValue();
int argCount = (int) ((Long) arguments.get(1)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
/*int multinameIndex = ins.getParamAsLong(constants, 0).intValue();
int argCount = ins.getParamAsLong(constants, 1).intValue();
List<Object> passArguments = new ArrayList<Object>();
for (int i = argCount - 1; i >= 0; i--) {
passArguments.set(i, lda.operandStack.pop());

View File

@@ -36,8 +36,8 @@ public class DecLocalIIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
int locRegIndex = (int) ((Long) arguments.get(0)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
int locRegIndex = ins.getParamAsLong(constants, 0).intValue();
Object obj = lda.localRegisters.get(locRegIndex);
if (obj instanceof Long) {
Long obj2 = ((Long) obj) - 1;

View File

@@ -36,8 +36,8 @@ public class DecLocalIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
int locRegIndex = (int) ((Long) arguments.get(0)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
int locRegIndex = ins.getParamAsLong(constants, 0).intValue();
Object obj = lda.localRegisters.get(locRegIndex);
if (obj instanceof Long) {
Long obj2 = ((Long) obj) - 1;

View File

@@ -28,7 +28,7 @@ public class GetLocal0Ins extends GetLocalTypeIns {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.operandStack.push(lda.localRegisters.get(0));
}

View File

@@ -28,7 +28,7 @@ public class GetLocal1Ins extends GetLocalTypeIns {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.operandStack.push(lda.localRegisters.get(1));
}

View File

@@ -28,7 +28,7 @@ public class GetLocal2Ins extends GetLocalTypeIns {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.operandStack.push(lda.localRegisters.get(2));
}

View File

@@ -28,7 +28,7 @@ public class GetLocal3Ins extends GetLocalTypeIns {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.operandStack.push(lda.localRegisters.get(3));
}

View File

@@ -20,7 +20,6 @@ import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
import com.jpexs.decompiler.flash.abc.avm2.AVM2ConstantPool;
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import java.util.List;
public class GetLocalIns extends GetLocalTypeIns {
@@ -29,8 +28,8 @@ public class GetLocalIns extends GetLocalTypeIns {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
lda.operandStack.push(lda.localRegisters.get((int) (long) (Long) arguments.get(0)));
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.operandStack.push(lda.localRegisters.get(ins.getParamAsLong(constants, 0).intValue()));
}
@Override

View File

@@ -36,8 +36,8 @@ public class DeletePropertyIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
/*int multiIndex = (int) ((Long) arguments.get(0)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
/*int multiIndex = ins.getParamAsLong(constants, 0).intValue();
//if multiname[multinameIndex] is runtime
//pop(name) pop(ns)
Object obj = lda.operandStack.pop();

View File

@@ -36,8 +36,8 @@ public class FindPropertyIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
//int multiIndex = (int) ((Long) arguments.get(0)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
//int multiIndex = ins.getParamAsLong(constants, 0).intValue();
//if is runtime
//pop(name), pop(ns)
throw new RuntimeException("Cannot find property");

View File

@@ -36,8 +36,8 @@ public class FindPropertyStrictIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
//int multiIndex = (int) ((Long) arguments.get(0)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
//int multiIndex = ins.getParamAsLong(constants, 0).intValue();
//if is runtime
//pop(name), pop(ns)
throw new RuntimeException("Cannot find property");

View File

@@ -36,8 +36,8 @@ public class GetDescendantsIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
/*int multiIndex = (int) ((Long) arguments.get(0)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
/*int multiIndex = ins.getParamAsLong(constants, 0).intValue();
//if is runtime
//pop(name), pop(ns)
Object obj = lda.operandStack.pop();*/

View File

@@ -35,7 +35,7 @@ public class GetGlobalScopeIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
throw new RuntimeException("getglobalscope not working");
}

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other;
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 java.util.List;
@@ -29,6 +30,6 @@ public class LabelIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
}
}

View File

@@ -18,6 +18,7 @@ package com.jpexs.decompiler.flash.abc.avm2.instructions.other;
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 java.util.List;
@@ -28,6 +29,6 @@ public class NopIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
}
}

View File

@@ -34,7 +34,7 @@ public class DupIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object obj = lda.operandStack.pop();
lda.operandStack.push(obj);
lda.operandStack.push(obj);

View File

@@ -34,7 +34,7 @@ public class PopIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.operandStack.pop();
}

View File

@@ -35,7 +35,7 @@ public class PopScopeIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.scopeStack.pop();
}

View File

@@ -35,8 +35,8 @@ public class PushByteIns extends InstructionDefinition implements PushIntegerTyp
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
lda.operandStack.push(arguments.get(0));
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.operandStack.push(ins.getParam(constants, 0));
}
@Override

View File

@@ -35,8 +35,8 @@ public class PushDoubleIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
lda.operandStack.push(arguments.get(0));
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.operandStack.push(ins.getParam(constants, 0));
}
@Override

View File

@@ -34,7 +34,7 @@ public class PushFalseIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.operandStack.push(Boolean.FALSE);
}

View File

@@ -35,8 +35,8 @@ public class PushIntIns extends InstructionDefinition implements PushIntegerType
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
lda.operandStack.push(arguments.get(0));
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.operandStack.push(ins.getParam(constants, 0));
}
@Override

View File

@@ -33,7 +33,7 @@ public class PushScopeIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.scopeStack.push(lda.operandStack.pop());
}

View File

@@ -35,8 +35,8 @@ public class PushShortIns extends InstructionDefinition implements PushIntegerTy
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
lda.operandStack.push((long) ((Number) arguments.get(0)).shortValue());
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.operandStack.push(((Number) ins.getParam(constants, 0)).longValue());
}
@Override

View File

@@ -35,8 +35,8 @@ public class PushStringIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
lda.operandStack.push(arguments.get(0));
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.operandStack.push(ins.getParam(constants, 0));
}
@Override

View File

@@ -34,7 +34,7 @@ public class PushTrueIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.operandStack.push(Boolean.TRUE);
}

View File

@@ -35,8 +35,8 @@ public class PushUIntIns extends InstructionDefinition implements PushIntegerTyp
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
lda.operandStack.push(arguments.get(0));
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
lda.operandStack.push(ins.getParam(constants, 0));
}
@Override

View File

@@ -34,7 +34,7 @@ public class SwapIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object obj1 = lda.operandStack.pop();
Object obj2 = lda.operandStack.pop();
lda.operandStack.push(obj1);

View File

@@ -37,8 +37,8 @@ public class ApplyTypeIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
int argCount = (int) ((Long) arguments.get(0)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
int argCount = ins.getParamAsLong(constants, 0).intValue();
List<Object> params = new ArrayList<>();
for (int i = 0; i < argCount; i++) {
params.add(lda.operandStack.pop());

View File

@@ -36,8 +36,8 @@ public class AsTypeIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
//Long typeIndex = (Long) arguments.get(0);
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
//Long typeIndex = ins.getParamAsLong(constants, 0);
Object obj = lda.operandStack.pop();
//if multiname[typeIndex]==obj
lda.operandStack.push(obj);

View File

@@ -34,7 +34,7 @@ public class AsTypeLateIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
//Object objClass = lda.operandStack.pop();
Object obj = lda.operandStack.pop();
//if obj.class=objClass

View File

@@ -39,7 +39,7 @@ public class CoerceAIns extends InstructionDefinition implements CoerceOrConvert
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
//coerce any type
}

View File

@@ -36,8 +36,8 @@ public class CoerceIns extends InstructionDefinition implements CoerceOrConvertT
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
//int multinameIndex = (int) ((Long) arguments.get(0)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
//int multinameIndex = ins.getParamAsLong(constants, 0).intValue();
//push and pop coerced value to specified type
}

View File

@@ -36,7 +36,7 @@ public class CoerceSIns extends InstructionDefinition implements CoerceOrConvert
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object obj = lda.operandStack.pop();
lda.operandStack.push(obj.toString());
}

View File

@@ -36,7 +36,7 @@ public class ConvertBIns extends InstructionDefinition implements CoerceOrConver
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object value = lda.operandStack.pop();
boolean bval;
if (value instanceof Boolean) {

View File

@@ -36,7 +36,7 @@ public class ConvertDIns extends InstructionDefinition implements CoerceOrConver
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object value = lda.operandStack.pop();
double ret;
if (value == null) {

View File

@@ -36,7 +36,7 @@ public class ConvertIIns extends InstructionDefinition implements CoerceOrConver
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object value = lda.operandStack.pop();
long ret;
if (value == null) {

View File

@@ -36,7 +36,7 @@ public class ConvertOIns extends InstructionDefinition implements CoerceOrConver
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
//throw if pop is not object
}

View File

@@ -36,7 +36,7 @@ public class ConvertSIns extends InstructionDefinition implements CoerceOrConver
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
Object obj = lda.operandStack.pop();
lda.operandStack.push(obj.toString());
}

View File

@@ -36,7 +36,7 @@ public class ConvertUIns extends InstructionDefinition implements CoerceOrConver
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
throw new UnsupportedOperationException("Cannot convert to uint ");
}

View File

@@ -34,7 +34,7 @@ public class CheckFilterIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
//if pop() is not XML|XMLList throw
}

View File

@@ -35,11 +35,10 @@ public class DXNSIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
int strIndex = (int) ((Long) arguments.get(0)).longValue();
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
int strIndex = ins.getParamAsLong(constants, 0).intValue();
String s = constants.getString(strIndex);
System.out.println("Set default XML space " + s);
}
@Override

View File

@@ -34,7 +34,7 @@ public class DXNSLateIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
String s = lda.operandStack.pop().toString();
System.out.println("Set default XML space " + s);
}

View File

@@ -34,7 +34,7 @@ public class EscXAttrIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
String s = lda.operandStack.pop().toString();
//escape
lda.operandStack.push(s);

View File

@@ -34,7 +34,7 @@ public class EscXElemIns extends InstructionDefinition {
}
@Override
public void execute(LocalDataArea lda, AVM2ConstantPool constants, List<Object> arguments) {
public void execute(LocalDataArea lda, AVM2ConstantPool constants, AVM2Instruction ins) {
String s = lda.operandStack.pop().toString();
//escape
lda.operandStack.push(s);

View File

@@ -54,9 +54,9 @@ public class ConvertAVM2Item extends AVM2Item {
case "Boolean":
return EcmaScript.toBoolean(value.getResult());
case "Number":
return EcmaScript.toNumber(value.getResult());
return value.getResultAsNumber();
case "int":
return (int) (double) EcmaScript.toNumber(value.getResult());
return (int) (double) value.getResultAsNumber();
case "uint":
return (int) (double) EcmaScript.toUint32(value.getResult());
case "String":

View File

@@ -17,7 +17,6 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TypeItem;
@@ -47,7 +46,7 @@ public class DecrementAVM2Item extends AVM2Item {
@Override
public Object getResult() {
return EcmaScript.toNumber(value.getResult()) - 1;
return value.getResultAsNumber() - 1;
}
@Override

View File

@@ -17,7 +17,6 @@
package com.jpexs.decompiler.flash.abc.avm2.model;
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.GraphTargetItem;
import com.jpexs.decompiler.graph.TypeItem;
@@ -47,7 +46,7 @@ public class IncrementAVM2Item extends AVM2Item {
@Override
public Object getResult() {
return EcmaScript.toNumber(value.getResult()) + 1;
return value.getResultAsNumber() + 1;
}
@Override

View File

@@ -80,6 +80,11 @@ public class LocalRegAVM2Item extends AVM2Item {
return computedValue.getResult();
}
@Override
public Double getResultAsNumber() {
return computedValue.getResultAsNumber();
}
@Override
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
return computedValue instanceof UndefinedAVM2Item;

View File

@@ -34,7 +34,9 @@ import java.util.Set;
public class StringAVM2Item extends AVM2Item implements SimpleValue {
public String value;
private String value;
private Double numberValue;
public StringAVM2Item(AVM2Instruction instruction, String value) {
super(instruction, PRECEDENCE_PRIMARY);
@@ -56,6 +58,15 @@ public class StringAVM2Item extends AVM2Item implements SimpleValue {
return value;
}
@Override
public Double getResultAsNumber() {
if (numberValue == null) {
numberValue = super.getResultAsNumber();
}
return numberValue;
}
@Override
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
return toSourceMerge(localData, generator,
@@ -77,4 +88,13 @@ public class StringAVM2Item extends AVM2Item implements SimpleValue {
public boolean isSimpleValue() {
return true;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
numberValue = null;
}
}

View File

@@ -41,7 +41,7 @@ public class XMLAVM2Item extends AVM2Item {
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) throws InterruptedException {
for (GraphTargetItem part : parts) {
if (part instanceof StringAVM2Item) {
writer.append(((StringAVM2Item) part).value);
writer.append(((StringAVM2Item) part).getValue());
} else {
part.toString(writer, localData);
}

View File

@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations;
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.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -36,7 +35,7 @@ public class BitAndAVM2Item extends BinaryOpItem {
@Override
public Object getResult() {
return ((long) (double) EcmaScript.toNumber(leftSide.getResult())) & ((long) (double) EcmaScript.toNumber(rightSide.getResult()));
return ((long) (double) leftSide.getResultAsNumber()) & ((long) (double) rightSide.getResultAsNumber());
}
@Override

View File

@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations;
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.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -36,7 +35,7 @@ public class BitNotAVM2Item extends UnaryOpItem {
@Override
public Object getResult() {
return ~((long) (double) EcmaScript.toNumber(value.getResult()));
return ~((long) (double) value.getResultAsNumber());
}
@Override

View File

@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations;
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.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -36,7 +35,7 @@ public class BitOrAVM2Item extends BinaryOpItem {
@Override
public Object getResult() {
return ((long) (double) EcmaScript.toNumber(leftSide.getResult())) | ((long) (double) EcmaScript.toNumber(rightSide.getResult()));
return ((long) (double) leftSide.getResultAsNumber()) | ((long) (double) rightSide.getResultAsNumber());
}
@Override

View File

@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations;
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.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -36,7 +35,7 @@ public class BitXorAVM2Item extends BinaryOpItem {
@Override
public Object getResult() {
return ((long) (double) EcmaScript.toNumber(leftSide.getResult())) ^ ((long) (double) EcmaScript.toNumber(rightSide.getResult()));
return ((long) (double) leftSide.getResultAsNumber()) ^ ((long) (double) rightSide.getResultAsNumber());
}
@Override

View File

@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations;
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.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -38,11 +37,13 @@ public class DivideAVM2Item extends BinaryOpItem {
@Override
public Object getResult() {
Object rightResult = rightSide.getResult();
if (Double.compare(EcmaScript.toNumber(rightResult), 0) == 0) {
return Double.NaN;
Double leftResult = leftSide.getResultAsNumber();
Double rightResult = rightSide.getResultAsNumber();
if (Double.compare(rightResult, 0) == 0) {
return leftResult < 0 ? Double.NEGATIVE_INFINITY
: leftResult > 0 ? Double.POSITIVE_INFINITY : Double.NaN;
}
return (EcmaScript.toNumber(leftSide.getResult())) / (EcmaScript.toNumber(rightResult));
return leftResult / rightResult;
}
@Override

View File

@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations;
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.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -36,7 +35,7 @@ public class LShiftAVM2Item extends BinaryOpItem {
@Override
public Object getResult() {
return ((int) (double) EcmaScript.toNumber(leftSide.getResult())) << ((int) (double) EcmaScript.toNumber(rightSide.getResult()));
return ((int) (double) leftSide.getResultAsNumber()) << ((int) (double) rightSide.getResultAsNumber());
}
@Override

View File

@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations;
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.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -38,11 +37,11 @@ public class ModuloAVM2Item extends BinaryOpItem {
@Override
public Object getResult() {
Object rightResult = rightSide.getResult();
if (Double.compare(EcmaScript.toNumber(rightResult), 0) == 0) {
Double rightResult = rightSide.getResultAsNumber();
if (Double.isNaN(rightResult) || Double.compare(rightResult, 0) == 0) {
return Double.NaN;
}
return ((long) (double) EcmaScript.toNumber(leftSide.getResult())) % ((long) (double) EcmaScript.toNumber(rightResult));
return ((long) (double) leftSide.getResultAsNumber()) % ((long) (double) rightResult);
}
@Override

View File

@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations;
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.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -38,7 +37,7 @@ public class MultiplyAVM2Item extends BinaryOpItem {
@Override
public Object getResult() {
return (EcmaScript.toNumber(leftSide.getResult())) * (EcmaScript.toNumber(rightSide.getResult()));
return leftSide.getResultAsNumber() * rightSide.getResultAsNumber();
}
@Override

View File

@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations;
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.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -36,7 +35,7 @@ public class NegAVM2Item extends UnaryOpItem {
@Override
public Object getResult() {
return -EcmaScript.toNumber(value.getResult());
return -value.getResultAsNumber();
}
@Override

View File

@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations;
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.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -36,7 +35,7 @@ public class RShiftAVM2Item extends BinaryOpItem {
@Override
public Object getResult() {
return ((long) (double) EcmaScript.toNumber(leftSide.getResult())) >> ((long) (double) EcmaScript.toNumber(rightSide.getResult()));
return ((long) (double) leftSide.getResultAsNumber()) >> ((long) (double) rightSide.getResultAsNumber());
}
@Override

View File

@@ -20,7 +20,6 @@ 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.abc.avm2.model.IntegerValueAVM2Item;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -39,7 +38,7 @@ public class SubtractAVM2Item extends BinaryOpItem {
@Override
public Object getResult() {
return EcmaScript.toNumber(leftSide.getResult()) - EcmaScript.toNumber(rightSide.getResult());
return leftSide.getResultAsNumber() - rightSide.getResultAsNumber();
}
@Override

View File

@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.abc.avm2.model.operations;
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.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
import com.jpexs.decompiler.graph.GraphTargetItem;
@@ -36,7 +35,7 @@ public class URShiftAVM2Item extends BinaryOpItem {
@Override
public Object getResult() {
return ((long) (double) EcmaScript.toNumber(leftSide.getResult())) >>> ((long) (double) EcmaScript.toNumber(rightSide.getResult()));
return ((long) (double) leftSide.getResultAsNumber()) >>> ((long) (double) rightSide.getResultAsNumber());
}
@Override

View File

@@ -1809,9 +1809,9 @@ public class AVM2SourceGenerator implements SourceGenerator {
if (val instanceof StringAVM2Item) {
StringAVM2Item sval = (StringAVM2Item) val;
if (isNs) {
return new ValueKind(namespace(Namespace.KIND_NAMESPACE, sval.value), ValueKind.CONSTANT_Namespace);
return new ValueKind(namespace(Namespace.KIND_NAMESPACE, sval.getValue()), ValueKind.CONSTANT_Namespace);
} else {
return new ValueKind(str(sval.value), ValueKind.CONSTANT_Utf8);
return new ValueKind(str(sval.getValue()), ValueKind.CONSTANT_Utf8);
}
}
if (val instanceof IntegerValueAVM2Item) {

View File

@@ -1074,7 +1074,8 @@ public class ActionScript3Parser {
private void addS(List<GraphTargetItem> rets, StringBuilder sb) {
if (sb.length() > 0) {
if (!rets.isEmpty() && (rets.get(rets.size() - 1) instanceof StringAVM2Item)) {
((StringAVM2Item) rets.get(rets.size() - 1)).value += sb.toString();
StringAVM2Item stringItem = ((StringAVM2Item) rets.get(rets.size() - 1));
stringItem.setValue(stringItem.getValue() + sb.toString());
} else {
rets.add(new StringAVM2Item(null, sb.toString()));
}

View File

@@ -18,7 +18,6 @@ package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.swf4.ActionAsciiToChar;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -52,7 +51,7 @@ public class AsciiToCharActionItem extends ActionItem {
@Override
public Object getResult() {
int res = (int) (double) (EcmaScript.toNumber(value.getResult()));
int res = (int) (double) (value.getResultAsNumber());
if (res == 0) {
return "";
}

View File

@@ -1,23 +1,23 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.swf5.ActionDecrement;
import com.jpexs.decompiler.flash.action.swf5.ActionDecrement;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -62,7 +62,7 @@ public class DecrementActionItem extends ActionItem {
@Override
public Object getResult() {
public Object getResult() {
return object.getResultAsNumber() - 1;
}
@Override

View File

@@ -1,23 +1,23 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.swf5.ActionIncrement;
import com.jpexs.decompiler.flash.action.swf5.ActionIncrement;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -62,7 +62,7 @@ public class IncrementActionItem extends ActionItem {
@Override
public Object getResult() {
public Object getResult() {
return object.getResultAsNumber() + 1;
}
@Override

View File

@@ -18,7 +18,6 @@ package com.jpexs.decompiler.flash.action.model;
import com.jpexs.decompiler.flash.SourceGeneratorLocalData;
import com.jpexs.decompiler.flash.action.swf4.ActionMBAsciiToChar;
import com.jpexs.decompiler.flash.ecma.EcmaScript;
import com.jpexs.decompiler.flash.helpers.GraphTextWriter;
import com.jpexs.decompiler.graph.CompilationException;
import com.jpexs.decompiler.graph.GraphSourceItem;
@@ -52,7 +51,7 @@ public class MBAsciiToCharActionItem extends ActionItem {
@Override
public Object getResult() {
int res = (int) (double) (EcmaScript.toNumber(value.getResult()));
int res = (int) (double) (value.getResultAsNumber());
if (res == 0) {
return "";
}

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