public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final float value) { super(type, cpGen); idx = getConstantPool().addFloat(value); }
/** * @param cp Constant pool * @param value to be pushed */ public PUSH(ConstantPoolGen cp, float value) { if(value == 0.0) instruction = FCONST_0; else if(value == 1.0) instruction = FCONST_1; else if(value == 2.0) instruction = FCONST_2; else // Create a Constant pool entry instruction = new LDC(cp.addFloat(value)); }
/** * @param cp Constant pool * @param value to be pushed */ public PUSH(final ConstantPoolGen cp, final float value) { if (value == 0.0) { instruction = InstructionConst.FCONST_0; } else if (value == 1.0) { instruction = InstructionConst.FCONST_1; } else if (value == 2.0) { instruction = InstructionConst.FCONST_2; } else { instruction = new LDC(cp.addFloat(value)); } }
private int addConstant() { switch(type.getType()) { case Constants.T_INT: case Constants.T_CHAR: case Constants.T_BYTE: case Constants.T_BOOLEAN: case Constants.T_SHORT: return cp.addInteger(((Integer)value).intValue()); case Constants.T_FLOAT: return cp.addFloat(((Float)value).floatValue()); case Constants.T_DOUBLE: return cp.addDouble(((Double)value).doubleValue()); case Constants.T_LONG: return cp.addLong(((Long)value).longValue()); case Constants.T_REFERENCE: return cp.addString(((String)value)); default: throw new RuntimeException("Oops: Unhandled : " + type.getType()); } }
private int addConstant() { switch (super.getType().getType()) { // sic case Const.T_INT: case Const.T_CHAR: case Const.T_BYTE: case Const.T_BOOLEAN: case Const.T_SHORT: return super.getConstantPool().addInteger(((Integer) value).intValue()); case Const.T_FLOAT: return super.getConstantPool().addFloat(((Float) value).floatValue()); case Const.T_DOUBLE: return super.getConstantPool().addDouble(((Double) value).doubleValue()); case Const.T_LONG: return super.getConstantPool().addLong(((Long) value).longValue()); case Const.T_REFERENCE: return super.getConstantPool().addString((String) value); default: throw new RuntimeException("Oops: Unhandled : " + super.getType().getType()); // sic } }
return addDouble(((ConstantDouble) c).getBytes()); case Const.CONSTANT_Float: return addFloat(((ConstantFloat) c).getBytes()); case Const.CONSTANT_Long: return addLong(((ConstantLong) c).getBytes());
return addFloat(((ConstantFloat)c).getBytes());
break; case PRIMITIVE_FLOAT: idx = cpool.addFloat(value.getValueFloat()); break; case PRIMITIVE_DOUBLE: