mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-06 12:08:46 +00:00
ActionScript 3 parser and generator uses decimal.
Instructions with numbecontext parameters have translate method - use standard GraphTarget items.
This commit is contained in:
@@ -58,6 +58,7 @@ public class DecLocalIns extends InstructionDefinition {
|
||||
return true;
|
||||
}
|
||||
|
||||
//same for declocal and declocalp (decimal)
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
int regId = ins.operands[0];
|
||||
@@ -77,8 +78,6 @@ public class DecLocalIns extends InstructionDefinition {
|
||||
}
|
||||
if (localData.localRegs.containsKey(regId)) {
|
||||
localData.localRegs.put(regId, new SubtractAVM2Item(ins, localData.lineStartInstruction, localData.localRegs.get(regId), new IntegerValueAVM2Item(ins, localData.lineStartInstruction, 1)));
|
||||
} else {
|
||||
//localRegs.put(regIndex, new SubtractAVM2Item(ins, localData.lineStartInstruction, new IntegerValueAVM2Item(ins, localData.lineStartInstruction, new Long(0)), new IntegerValueAVM2Item(ins, localData.lineStartInstruction, new Long(1))));
|
||||
}
|
||||
if (!localData.localRegAssignmentIps.containsKey(regId)) {
|
||||
localData.localRegAssignmentIps.put(regId, 0);
|
||||
|
||||
@@ -58,6 +58,7 @@ public class IncLocalIns extends InstructionDefinition {
|
||||
return true;
|
||||
}
|
||||
|
||||
//same for inclocal and inclocalp (decimal)
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
int regId = ins.operands[0];
|
||||
@@ -77,8 +78,6 @@ public class IncLocalIns extends InstructionDefinition {
|
||||
}
|
||||
if (localData.localRegs.containsKey(regId)) {
|
||||
localData.localRegs.put(regId, new AddAVM2Item(ins, localData.lineStartInstruction, localData.localRegs.get(regId), new IntegerValueAVM2Item(ins, localData.lineStartInstruction, 1)));
|
||||
} else {
|
||||
//localRegs.put(regIndex, new AddAVM2Item(ins, localData.lineStartInstruction, null, new IntegerValueAVM2Item(ins, localData.lineStartInstruction, new Long(1))));
|
||||
}
|
||||
if (!localData.localRegAssignmentIps.containsKey(regId)) {
|
||||
localData.localRegAssignmentIps.put(regId, 0);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.other.decimalsupport;
|
||||
|
||||
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.AVM2Runtime;
|
||||
@@ -24,6 +25,10 @@ import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2VerifyErrorException;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2InstructionFlag;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* add_p instruction - add two numbers with number context.
|
||||
@@ -47,4 +52,11 @@ public class AddPIns extends InstructionDefinition {
|
||||
|
||||
super.verify(lda, constants, ins);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new AddAVM2Item(ins, localData.lineStartInstruction, v1, v2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.other.decimalsupport;
|
||||
|
||||
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.AVM2Runtime;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.LocalDataArea;
|
||||
@@ -24,13 +25,20 @@ import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2VerifyErrorException;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2InstructionFlag;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceOrConvertTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* convert_m instruction - convert to decimal.
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ConvertMIns extends InstructionDefinition {
|
||||
public class ConvertMIns extends InstructionDefinition implements CoerceOrConvertTypeIns {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -57,4 +65,14 @@ public class ConvertMIns extends InstructionDefinition {
|
||||
public int getStackPushCount(AVM2Instruction ins, ABC abc) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem(DottedChain.DECIMAL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.other.decimalsupport;
|
||||
|
||||
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.AVM2Runtime;
|
||||
@@ -25,13 +26,20 @@ import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2VerifyErrorException;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2InstructionFlag;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.types.CoerceOrConvertTypeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ConvertAVM2Item;
|
||||
import com.jpexs.decompiler.graph.DottedChain;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* convert_m_p instruction - convert to decimal with number context.
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ConvertMPIns extends InstructionDefinition {
|
||||
public class ConvertMPIns extends InstructionDefinition implements CoerceOrConvertTypeIns {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -58,4 +66,14 @@ public class ConvertMPIns extends InstructionDefinition {
|
||||
public int getStackPushCount(AVM2Instruction ins, ABC abc) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new ConvertAVM2Item(ins, localData.lineStartInstruction, stack.pop(), getTargetType(localData.getConstants(), ins)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem getTargetType(AVM2ConstantPool constants, AVM2Instruction ins) {
|
||||
return new TypeItem(DottedChain.DECIMAL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.other.decimalsupport;
|
||||
|
||||
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.AVM2Runtime;
|
||||
@@ -25,6 +26,14 @@ import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2VerifyErrorException;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2InstructionFlag;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.DecLocalAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.PostDecrementAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* declocal_p instruction - decrement local register with number context.
|
||||
@@ -58,4 +67,31 @@ public class DecLocalPIns extends InstructionDefinition {
|
||||
public int getStackPushCount(AVM2Instruction ins, ABC abc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//same for declocal and declocalp (decimal)
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
int regId = ins.operands[0];
|
||||
boolean isPostDec = false;
|
||||
if (!stack.isEmpty()) {
|
||||
GraphTargetItem stackTop = stack.peek();
|
||||
if (stackTop instanceof LocalRegAVM2Item) {
|
||||
if (regId == ((LocalRegAVM2Item) stackTop).regIndex) {
|
||||
stack.pop();
|
||||
stack.push(new PostDecrementAVM2Item(ins, localData.lineStartInstruction, stackTop));
|
||||
isPostDec = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isPostDec) {
|
||||
output.add(new DecLocalAVM2Item(ins, localData.lineStartInstruction, regId));
|
||||
}
|
||||
if (localData.localRegs.containsKey(regId)) {
|
||||
localData.localRegs.put(regId, new SubtractAVM2Item(ins, localData.lineStartInstruction, localData.localRegs.get(regId), new IntegerValueAVM2Item(ins, localData.lineStartInstruction, 1)));
|
||||
}
|
||||
if (!localData.localRegAssignmentIps.containsKey(regId)) {
|
||||
localData.localRegAssignmentIps.put(regId, 0);
|
||||
}
|
||||
localData.localRegAssignmentIps.put(regId, localData.localRegAssignmentIps.get(regId) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.other.decimalsupport;
|
||||
|
||||
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.AVM2Runtime;
|
||||
@@ -25,6 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2VerifyErrorException;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2InstructionFlag;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.DecrementAVM2Item;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* decrement_p instruction - decrement a number with number context.
|
||||
@@ -58,4 +63,9 @@ public class DecrementPIns extends InstructionDefinition {
|
||||
public int getStackPushCount(AVM2Instruction ins, ABC abc) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new DecrementAVM2Item(ins, localData.lineStartInstruction, stack.pop()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.other.decimalsupport;
|
||||
|
||||
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.AVM2Runtime;
|
||||
@@ -25,6 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2VerifyErrorException;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2InstructionFlag;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.DivideAVM2Item;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* divide_p instruction - divide two numbers with number context.
|
||||
@@ -58,4 +63,11 @@ public class DividePIns extends InstructionDefinition {
|
||||
public int getStackPushCount(AVM2Instruction ins, ABC abc) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new DivideAVM2Item(ins, localData.lineStartInstruction, v1, v2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.other.decimalsupport;
|
||||
|
||||
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.AVM2Runtime;
|
||||
@@ -25,6 +26,14 @@ import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2VerifyErrorException;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2InstructionFlag;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IncLocalAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.PostIncrementAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.AddAVM2Item;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* inclocal_p instruction - increment a local register with number context.
|
||||
@@ -58,4 +67,31 @@ public class IncLocalPIns extends InstructionDefinition {
|
||||
public int getStackPushCount(AVM2Instruction ins, ABC abc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//same for inclocal and inclocalp (decimal)
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
int regId = ins.operands[0];
|
||||
boolean isPostInc = false;
|
||||
if (!stack.isEmpty()) {
|
||||
GraphTargetItem stackTop = stack.peek();
|
||||
if (stackTop instanceof LocalRegAVM2Item) {
|
||||
if (regId == ((LocalRegAVM2Item) stackTop).regIndex) {
|
||||
stack.pop();
|
||||
stack.push(new PostIncrementAVM2Item(ins, localData.lineStartInstruction, stackTop));
|
||||
isPostInc = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isPostInc) {
|
||||
output.add(new IncLocalAVM2Item(ins, localData.lineStartInstruction, regId));
|
||||
}
|
||||
if (localData.localRegs.containsKey(regId)) {
|
||||
localData.localRegs.put(regId, new AddAVM2Item(ins, localData.lineStartInstruction, localData.localRegs.get(regId), new IntegerValueAVM2Item(ins, localData.lineStartInstruction, 1)));
|
||||
}
|
||||
if (!localData.localRegAssignmentIps.containsKey(regId)) {
|
||||
localData.localRegAssignmentIps.put(regId, 0);
|
||||
}
|
||||
localData.localRegAssignmentIps.put(regId, localData.localRegAssignmentIps.get(regId) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.other.decimalsupport;
|
||||
|
||||
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.AVM2Runtime;
|
||||
@@ -25,6 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2VerifyErrorException;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2InstructionFlag;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IncrementAVM2Item;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* increment_p instruction - increment a number with number context.
|
||||
@@ -58,4 +63,9 @@ public class IncrementPIns extends InstructionDefinition {
|
||||
public int getStackPushCount(AVM2Instruction ins, ABC abc) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
stack.push(new IncrementAVM2Item(ins, localData.lineStartInstruction, stack.pop()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.other.decimalsupport;
|
||||
|
||||
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.AVM2Runtime;
|
||||
@@ -25,6 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2VerifyErrorException;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2InstructionFlag;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.ModuloAVM2Item;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* modulo_p instruction - modulo with number context.
|
||||
@@ -58,4 +63,11 @@ public class ModuloPIns extends InstructionDefinition {
|
||||
public int getStackPushCount(AVM2Instruction ins, ABC abc) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new ModuloAVM2Item(ins, localData.lineStartInstruction, v1, v2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.other.decimalsupport;
|
||||
|
||||
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.AVM2Runtime;
|
||||
@@ -25,6 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2VerifyErrorException;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2InstructionFlag;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.MultiplyAVM2Item;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* multiply_p instruction - multiply two numbers with number context.
|
||||
@@ -58,4 +63,11 @@ public class MultiplyPIns extends InstructionDefinition {
|
||||
public int getStackPushCount(AVM2Instruction ins, ABC abc) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new MultiplyAVM2Item(ins, localData.lineStartInstruction, v1, v2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.other.decimalsupport;
|
||||
|
||||
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.AVM2Runtime;
|
||||
@@ -25,6 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2VerifyErrorException;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2InstructionFlag;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.NegAVM2Item;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* negate_p instruction - negate with number context.
|
||||
@@ -58,4 +63,10 @@ public class NegatePIns extends InstructionDefinition {
|
||||
public int getStackPushCount(AVM2Instruction ins, ABC abc) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
GraphTargetItem v = stack.pop();
|
||||
stack.push(new NegAVM2Item(ins, localData.lineStartInstruction, v));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.jpexs.decompiler.flash.abc.avm2.instructions.other.decimalsupport;
|
||||
|
||||
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.AVM2Runtime;
|
||||
@@ -25,6 +26,10 @@ import com.jpexs.decompiler.flash.abc.avm2.exceptions.AVM2VerifyErrorException;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2InstructionFlag;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.operations.SubtractAVM2Item;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.TranslateStack;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* subtract_p instruction - subtract a number with number context.
|
||||
@@ -58,4 +63,11 @@ public class SubtractPIns extends InstructionDefinition {
|
||||
public int getStackPushCount(AVM2Instruction ins, ABC abc) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translate(AVM2LocalData localData, TranslateStack stack, AVM2Instruction ins, List<GraphTargetItem> output, String path) {
|
||||
GraphTargetItem v2 = stack.pop();
|
||||
GraphTargetItem v1 = stack.pop();
|
||||
stack.push(new SubtractAVM2Item(ins, localData.lineStartInstruction, v1, v2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.parser.script.AVM2SourceGenerator;
|
||||
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;
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2024 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.model;
|
||||
|
||||
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.parser.script.AVM2SourceGenerator;
|
||||
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;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.decompiler.graph.SourceGenerator;
|
||||
import com.jpexs.decompiler.graph.TypeItem;
|
||||
import com.jpexs.decompiler.graph.model.LocalData;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Float value.
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class FloatValueAVM2Item extends NumberValueAVM2Item {
|
||||
|
||||
/**
|
||||
* Value
|
||||
*/
|
||||
public Float value;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param instruction Instruction
|
||||
* @param lineStartIns Line start instruction
|
||||
* @param value Value
|
||||
*/
|
||||
public FloatValueAVM2Item(GraphSourceItem instruction, GraphSourceItem lineStartIns, Float value) {
|
||||
super(instruction, lineStartIns);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTextWriter appendTo(GraphTextWriter writer, LocalData localData) {
|
||||
return writer.append(EcmaScript.toString(value)).append("f");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResult() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompileTime(Set<GraphTargetItem> dependencies) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GraphSourceItem> toSource(SourceGeneratorLocalData localData, SourceGenerator generator) throws CompilationException {
|
||||
return toSourceMerge(localData, generator,
|
||||
new AVM2Instruction(0, AVM2Instructions.PushFloat, new int[]{((AVM2SourceGenerator) generator).abcIndex.getSelectedAbc().constants.getFloatId(value, true)})
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GraphTargetItem returnType() {
|
||||
return TypeItem.NUMBER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasReturnValue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 53 * hash + Objects.hashCode(this.value);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final FloatValueAVM2Item other = (FloatValueAVM2Item) obj;
|
||||
if (!Objects.equals(this.value, other.value)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.AVM2Instruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.DeobfuscatePopIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.InstructionDefinition;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.UnknownInstruction;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PushShortIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.AVM2ParseException;
|
||||
import com.jpexs.decompiler.flash.abc.types.ABCException;
|
||||
import com.jpexs.decompiler.flash.abc.types.Float4;
|
||||
|
||||
@@ -32,7 +32,9 @@ import com.jpexs.decompiler.flash.abc.avm2.instructions.stack.PopScopeIns;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.AVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ApplyTypeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.BooleanAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.DecimalValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.DoubleValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FloatValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GetDescendantsAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.IntegerValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.LocalRegAVM2Item;
|
||||
@@ -1549,6 +1551,12 @@ public class AVM2SourceGenerator implements SourceGenerator {
|
||||
if (val instanceof DoubleValueAVM2Item) {
|
||||
return new ValueKind(abcIndex.getSelectedAbc().constants.getDoubleId(((DoubleValueAVM2Item) val).value, true), ValueKind.CONSTANT_Double);
|
||||
}
|
||||
if (val instanceof DecimalValueAVM2Item) {
|
||||
return new ValueKind(abcIndex.getSelectedAbc().constants.getDecimalId(((DecimalValueAVM2Item) val).value, true), ValueKind.CONSTANT_DecimalOrFloat);
|
||||
}
|
||||
if (val instanceof FloatValueAVM2Item) {
|
||||
return new ValueKind(abcIndex.getSelectedAbc().constants.getFloatId(((FloatValueAVM2Item) val).value, true), ValueKind.CONSTANT_DecimalOrFloat);
|
||||
}
|
||||
if (val instanceof NanAVM2Item) {
|
||||
return new ValueKind(abcIndex.getSelectedAbc().constants.getDoubleId(Double.NaN, true), ValueKind.CONSTANT_Double);
|
||||
}
|
||||
|
||||
@@ -23,10 +23,12 @@ import com.jpexs.decompiler.flash.abc.avm2.model.ApplyTypeAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.BooleanAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.CoerceAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.ConstructSuperAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.DecimalValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.DefaultXMLNamespace;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.EscapeXAttrAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.EscapeXElemAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.DoubleValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.FloatValueAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GetDescendantsAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.GetPropertyAVM2Item;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.model.HasNextAVM2Item;
|
||||
@@ -129,6 +131,7 @@ import java.util.Map;
|
||||
import java.util.Stack;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import macromedia.asc.util.Decimal128;
|
||||
|
||||
/**
|
||||
* ActionScript 3 parser.
|
||||
@@ -2337,10 +2340,12 @@ public class ActionScript3Parser {
|
||||
s = lex();
|
||||
if (s.isType(SymbolType.DOUBLE)) {
|
||||
ret = new DoubleValueAVM2Item(null, null, -(Double) s.value);
|
||||
|
||||
} else if (s.isType(SymbolType.INTEGER)) {
|
||||
ret = new IntegerValueAVM2Item(null, null, -(Integer) s.value);
|
||||
|
||||
} else if (s.isType(SymbolType.DECIMAL)) {
|
||||
ret = new DecimalValueAVM2Item(null, null, ((Decimal128) s.value).multiply(Decimal128.NEG1));
|
||||
} else if (s.isType(SymbolType.FLOAT)) {
|
||||
ret = new FloatValueAVM2Item(null, null, -(Float) s.value);
|
||||
} else {
|
||||
lexer.pushback(s);
|
||||
GraphTargetItem num = expressionPrimary(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, false, registerVars, inFunction, inMethod, true, variables);
|
||||
@@ -2446,6 +2451,14 @@ public class ActionScript3Parser {
|
||||
ret = new DoubleValueAVM2Item(null, null, (Double) s.value);
|
||||
allowMemberOrCall = true; // 5.2.toString();
|
||||
break;
|
||||
case DECIMAL:
|
||||
ret = new DecimalValueAVM2Item(null, null, (Decimal128) s.value);
|
||||
allowMemberOrCall = true;
|
||||
break;
|
||||
case FLOAT:
|
||||
ret = new FloatValueAVM2Item(null, null, (Float) s.value);
|
||||
allowMemberOrCall = true;
|
||||
break;
|
||||
case DELETE:
|
||||
GraphTargetItem varDel = expressionPrimary(allOpenedNamespaces, thisType, pkg, needsActivation, importedClasses, openedNamespaces, false, registerVars, inFunction, inMethod, true, variables);
|
||||
if (!isNameOrProp(varDel)) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -55,6 +55,14 @@ public enum SymbolGroup {
|
||||
* Double
|
||||
*/
|
||||
DOUBLE,
|
||||
/**
|
||||
* Decimal
|
||||
*/
|
||||
DECIMAL,
|
||||
/**
|
||||
* Float
|
||||
*/
|
||||
FLOAT,
|
||||
/**
|
||||
* Type name
|
||||
*/
|
||||
|
||||
@@ -467,6 +467,14 @@ public enum SymbolType {
|
||||
* Other: Double
|
||||
*/
|
||||
DOUBLE(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Other: Decimal
|
||||
*/
|
||||
DECIMAL(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Other: Float
|
||||
*/
|
||||
FLOAT(GraphTargetItem.PRECEDENCE_PRIMARY, false),
|
||||
/**
|
||||
* Other: Type name
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user