01: package net.sf.jdec.jvminstructions.commands;
02:
03: import net.sf.jdec.commonutil.Numbers;
04: import net.sf.jdec.constantpool.ClassDescription;
05: import net.sf.jdec.constantpool.FloatPrimitive;
06: import net.sf.jdec.constantpool.IntPrimitive;
07: import net.sf.jdec.constantpool.CPString;
08: import net.sf.jdec.core.Operand;
09: import net.sf.jdec.core.OperandStack;
10: import net.sf.jdec.reflection.Behaviour;
11: import net.sf.jdec.ui.util.UIUtil;
12: import net.sf.jdec.util.Constants;
13: import net.sf.jdec.util.Util;
14:
15: public class Ldc_wCommand extends AbstractInstructionCommand {
16:
17: public Ldc_wCommand(Behaviour context) {
18: super (context);
19:
20: }
21:
22: public int getSkipBytes() {
23: return 2;
24: }
25:
26: public void execute() {
27: int i = getCurrentInstPosInCode();
28: int opValueI = getGenericFinder().getOffset(i);
29: i += 2;
30: ClassDescription cd = getContext().getClassRef().getCd();
31: IntPrimitive constInt = null;
32: FloatPrimitive constFloat = null;
33: java.lang.String stringLiteral = "";
34: int type = -1;
35: constInt = cd.getINTPrimitiveAtCPoolPosition(opValueI);
36: if (constInt == null) {
37: constFloat = cd.getFloatPrimitiveAtCPoolPosition(opValueI);
38: if (constFloat == null) {
39: CPString constString = cd
40: .getStringsAtCPoolPosition(opValueI);
41: if (constString != null)
42: stringLiteral = cd.getUTF8String(constString
43: .getUtf8pointer());
44: if (stringLiteral == null
45: || stringLiteral.length() == 0) {
46: // ERROR CONDITION
47: } else {
48: type = Constants.IS_OBJECT_REF;
49: }
50: } else {
51: type = Constants.IS_CONSTANT_FLOAT;
52: }
53: } else {
54: type = Constants.IS_CONSTANT_INT;
55: }
56: Operand op = new Operand();
57: op.setOperandType(type);
58: if (type == Constants.IS_CONSTANT_INT) {
59: op.setOperandValue(new Integer(constInt.getValue()));
60: op.setClassType("int");
61: }
62: if (type == Constants.IS_CONSTANT_FLOAT) {
63: op.setOperandValue(constFloat.getValue() + "f ");
64: op.setClassType("float");
65: }
66: if (type == Constants.IS_OBJECT_REF) {
67: java.lang.String nonascii = UIUtil.getUIUtil()
68: .getInterpretNonAscii();
69: if (nonascii.equals("true")) {
70: StringBuffer tp = new StringBuffer("");
71: boolean sf = Numbers.shouldValueBeFormattedForNonAscii(
72: stringLiteral, "String", tp);
73: if (sf) {
74:
75: stringLiteral = Util.formatForUTF(stringLiteral,
76: "String", tp);
77:
78: }
79: } else {
80: stringLiteral = Util
81: .returnUnInterpretedNonAscii(stringLiteral);
82: }
83: op.setOperandValue("\"" + stringLiteral + "\"");
84: op.setClassType("java.lang.String");
85: }
86: boolean r = false;//checkIFLoadInstIsPartOFTernaryCond(currentForIndex);
87: OperandStack opStack = getStack();
88: if (r) {
89: if (opStack.size() > 0) {
90: java.lang.String str = opStack.getTopOfStack()
91: .getOperandValue();
92: str = str + op.getOperandValue();
93: op.setOperandValue(str);
94: }
95: }
96: opStack.push(op);
97: }
98:
99: }
|