01: package net.sf.jdec.jvminstructions.commands;
02:
03: import net.sf.jdec.constantpool.ClassDescription;
04: import net.sf.jdec.constantpool.DoublePrimitive;
05: import net.sf.jdec.constantpool.LongPrimitive;
06: import net.sf.jdec.core.Operand;
07: import net.sf.jdec.core.OperandStack;
08: import net.sf.jdec.reflection.Behaviour;
09: import net.sf.jdec.util.Constants;
10:
11: public class Ldc2_wCommand extends AbstractInstructionCommand {
12:
13: public Ldc2_wCommand(Behaviour context) {
14: super (context);
15:
16: }
17:
18: public int getSkipBytes() {
19: return 2;
20: }
21:
22: public void execute() {
23: int i = getCurrentInstPosInCode();
24: int opValueI = getGenericFinder().getOffset(i);
25: i += 2;
26: LongPrimitive constLong = null;
27: DoublePrimitive constDouble = null;
28: int type = -1;
29: ClassDescription cd = getContext().getClassRef().getCd();
30: constLong = cd.getLongPrimitiveAtCPoolPosition(opValueI);
31: if (constLong == null) {
32: constDouble = cd
33: .getDoublePrimitiveAtCPoolPosition(opValueI);
34: if (constDouble == null) {
35: // ERROR CONDITION
36: } else {
37: type = Constants.IS_CONSTANT_DOUBLE;
38: }
39: } else {
40: type = Constants.IS_CONSTANT_LONG;
41: }
42: Operand op = new Operand();
43: op.setOperandType(type);
44: if (type == Constants.IS_CONSTANT_DOUBLE) {
45: op.setOperandValue(new Double(constDouble.getValue()));
46: }
47: if (type == Constants.IS_CONSTANT_LONG) {
48: op.setOperandValue(new Long(constLong.getValue()) + "L ");
49: }
50: OperandStack opStack = getStack();
51: boolean r = false;// checkIFLoadInstIsPartOFTernaryCond(currentForIndex);
52: if (r) {
53: if (opStack.size() > 0) {
54: java.lang.String str = opStack.getTopOfStack()
55: .getOperandValue();
56: str = str + op.getOperandValue();
57: op.setOperandValue(str);
58: }
59: }
60: opStack.push(op);
61:
62: }
63:
64: }
|