/** * Pushes the given primitive int on the stack in the most efficient way * (as an iconst, bipush, sipush, or ldc instruction). * * @param value the int value to be pushed. */ public CompactCodeAttributeComposer pushInt(int value) { return value >= -1 && value <= 5 ? iconst(value) : value == (byte)value ? bipush(value) : value == (short)value ? sipush(value) : ldc(value); }
/** * Pushes the given primitive int on the stack in the most efficient way * (as an iconst, bipush, sipush, or ldc instruction). * * @param value the int value to be pushed. */ public CompactCodeAttributeComposer pushInt(int value) { return value >= -1 && value <= 5 ? iconst(value) : value == (byte)value ? bipush(value) : value == (short)value ? sipush(value) : ldc(value); }
/** * Pushes the given primitive int on the stack in the most efficient way * (as an iconst, bipush, sipush, or ldc instruction). * * @param value the int value to be pushed. */ public CompactCodeAttributeComposer pushInt(int value) { return value >= -1 && value <= 5 ? iconst(value) : value == (byte)value ? bipush(value) : value == (short)value ? sipush(value) : ldc(value); }
/** * Pushes the given primitive value on the stack. * * Operand stack: * ... -> ..., value * * @param primitive the primitive value to be pushed - should never be null. * @param internalType the internal type of the primitive ('Z','B','I',...) */ public CompactCodeAttributeComposer pushPrimitive(Object primitive, char internalType) { switch (internalType) { case TYPE_BOOLEAN: return ((Boolean)primitive).booleanValue() ? iconst_1() : iconst_0(); case TYPE_BYTE: return bipush((Byte)primitive); case TYPE_CHAR: return ldc(((Character)primitive).charValue()); case TYPE_SHORT: return sipush((Short)primitive); case TYPE_INT: return ldc(((Integer)primitive).intValue()); case TYPE_LONG: return ldc2_w((Long)primitive); case TYPE_FLOAT: return ldc(((Float)primitive).floatValue()); case TYPE_DOUBLE: return ldc2_w((Double)primitive); default: throw new IllegalArgumentException(primitive.toString()); } }
/** * Pushes the given primitive value on the stack. * * Operand stack: * ... -> ..., value * * @param primitive the primitive value to be pushed - should never be null. * @param internalType the internal type of the primitive ('Z','B','I',...) */ public CompactCodeAttributeComposer pushPrimitive(Object primitive, char internalType) { switch (internalType) { case TYPE_BOOLEAN: return ((Boolean)primitive).booleanValue() ? iconst_1() : iconst_0(); case TYPE_BYTE: return bipush((Byte)primitive); case TYPE_CHAR: return ldc(((Character)primitive).charValue()); case TYPE_SHORT: return sipush((Short)primitive); case TYPE_INT: return ldc(((Integer)primitive).intValue()); case TYPE_LONG: return ldc2_w((Long)primitive); case TYPE_FLOAT: return ldc(((Float)primitive).floatValue()); case TYPE_DOUBLE: return ldc2_w((Double)primitive); default: throw new IllegalArgumentException(primitive.toString()); } }
/** * Pushes the given primitive value on the stack. * * Operand stack: * ... -> ..., value * * @param primitive the primitive value to be pushed - should never be null. * @param internalType the internal type of the primitive ('Z','B','I',...) */ public CompactCodeAttributeComposer pushPrimitive(Object primitive, char internalType) { switch (internalType) { case TYPE_BOOLEAN: return ((Boolean)primitive).booleanValue() ? iconst_1() : iconst_0(); case TYPE_BYTE: return bipush((Byte)primitive); case TYPE_CHAR: return ldc(((Character)primitive).charValue()); case TYPE_SHORT: return sipush((Short)primitive); case TYPE_INT: return ldc(((Integer)primitive).intValue()); case TYPE_LONG: return ldc2_w((Long)primitive); case TYPE_FLOAT: return ldc(((Float)primitive).floatValue()); case TYPE_DOUBLE: return ldc2_w((Double)primitive); default: throw new IllegalArgumentException(primitive.toString()); } }