public static int getValueOfNumber(Instruction ins, ConstantPoolGen cpg) { if (ins instanceof BIPUSH) { return ((BIPUSH) ins).getValue().intValue(); } else if (ins instanceof SIPUSH) { return ((SIPUSH) ins).getValue().intValue(); } else if (ins instanceof ICONST) { return ((ICONST) ins).getValue().intValue(); } else if (ins instanceof LDC_W) { LDC_W ldcw = (LDC_W) ins; return Integer.valueOf(ldcw.getValue(cpg).toString()); } else { return -1; } }
/** Symbolically executes the corresponding Java Virtual Machine instruction. */ public void visitLDC_W(LDC_W o) { Constant c = cpg.getConstant(o.getIndex()); if (c instanceof ConstantInteger) { stack().push(Type.INT); } if (c instanceof ConstantFloat) { stack().push(Type.FLOAT); } if (c instanceof ConstantString) { stack().push(Type.STRING); } }