public FCONST(final float f) { super(org.apache.bcel.Const.FCONST_0, (short) 1); if (f == 0.0) { super.setOpcode(org.apache.bcel.Const.FCONST_0); } else if (f == 1.0) { super.setOpcode(org.apache.bcel.Const.FCONST_1); } else if (f == 2.0) { super.setOpcode(org.apache.bcel.Const.FCONST_2); } else { throw new ClassGenException("FCONST can be used only for 0.0, 1.0 and 2.0: " + f); } value = f; }
public LCONST(final long l) { super(org.apache.bcel.Const.LCONST_0, (short) 1); if (l == 0) { super.setOpcode(org.apache.bcel.Const.LCONST_0); } else if (l == 1) { super.setOpcode(org.apache.bcel.Const.LCONST_1); } else { throw new ClassGenException("LCONST can be used only for 0 and 1: " + l); } value = l; }
public DCONST(final double f) { super(org.apache.bcel.Const.DCONST_0, (short) 1); if (f == 0.0) { super.setOpcode(org.apache.bcel.Const.DCONST_0); } else if (f == 1.0) { super.setOpcode(org.apache.bcel.Const.DCONST_1); } else { throw new ClassGenException("DCONST can be used only for 0.0 and 1.0: " + f); } value = f; }
public ICONST(final int i) { super(org.apache.bcel.Const.ICONST_0, (short) 1); if ((i >= -1) && (i <= 5)) { super.setOpcode((short) (org.apache.bcel.Const.ICONST_0 + i)); // Even works for i == -1 } else { throw new ClassGenException("ICONST can be used only for value between -1 and 5: " + i); } value = i; }
/** * Set the local variable index. * also updates opcode and length * TODO Why? * @see #setIndexOnly(int) */ @Override public void setIndex( final int n ) { // TODO could be package-protected? if ((n < 0) || (n > Const.MAX_SHORT)) { throw new ClassGenException("Illegal value: " + n); } this.n = n; // Cannot be < 0 as this is checked above if (n <= 3) { // Use more compact instruction xLOAD_n super.setOpcode((short) (c_tag + n)); super.setLength(1); } else { super.setOpcode(canon_tag); if (wide()) { super.setLength(4); } else { super.setLength(2); } } }
throw new Exception("Illegal opcode after wide: " + opcode); obj.setOpcode(opcode);
throw new ClassGenException("Illegal opcode after wide: " + opcode); obj.setOpcode(opcode);