public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final byte value) { super(type, cpGen); idx = getConstantPool().addInteger(value); }
public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final int value) { super(type, cpGen); idx = getConstantPool().addInteger(value); }
public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final short value) { super(type, cpGen); idx = getConstantPool().addInteger(value); }
public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final boolean value) { super(type, cpGen); if (value) { idx = getConstantPool().addInteger(1); } else { idx = getConstantPool().addInteger(0); } }
public SimpleElementValueGen(final int type, final ConstantPoolGen cpGen, final char value) { super(type, cpGen); idx = getConstantPool().addInteger(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()); } }
/** * This constructor also applies for values of type short, char, byte * * @param cp Constant pool * @param value to be pushed */ public PUSH(ConstantPoolGen cp, int value) { if((value >= -1) && (value <= 5)) // Use ICONST_n instruction = INSTRUCTIONS[Constants.ICONST_0 + value]; else if((value >= -128) && (value <= 127)) // Use BIPUSH instruction = new BIPUSH((byte)value); else if((value >= -32768) && (value <= 32767)) // Use SIPUSH instruction = new SIPUSH((short)value); else // If everything fails create a Constant pool entry instruction = new LDC(cp.addInteger(value)); }
break; case PRIMITIVE_INT: idx = cpool.addInteger(value.getValueInt()); break; case PRIMITIVE_BYTE: idx = cpool.addInteger(value.getValueByte()); break; case PRIMITIVE_CHAR: idx = cpool.addInteger(value.getValueChar()); break; case PRIMITIVE_LONG: if (value.getValueBoolean()) idx = cpool.addInteger(1); idx = cpool.addInteger(0); idx = cpool.addInteger(value.getValueShort()); break; default:
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 } }
/** * This constructor also applies for values of type short, char, byte * * @param cp Constant pool * @param value to be pushed */ public PUSH(final ConstantPoolGen cp, final int value) { if ((value >= -1) && (value <= 5)) { instruction = InstructionConst.getInstruction(Const.ICONST_0 + value); } else if (Instruction.isValidByte(value)) { instruction = new BIPUSH((byte) value); } else if (Instruction.isValidShort(value)) { instruction = new SIPUSH((short) value); } else { instruction = new LDC(cp.addInteger(value)); } }
return addLong(((ConstantLong) c).getBytes()); case Const.CONSTANT_Integer: return addInteger(((ConstantInteger) c).getBytes()); case Const.CONSTANT_InterfaceMethodref: case Const.CONSTANT_Methodref:
return addInteger(((ConstantInteger)c).getBytes());