1 17 package org.apache.bcel.generic; 18 19 27 public class FCONST extends Instruction implements ConstantPushInstruction, TypedInstruction { 28 29 private float value; 30 31 32 36 FCONST() { 37 } 38 39 40 public FCONST(float f) { 41 super(org.apache.bcel.Constants.FCONST_0, (short) 1); 42 if (f == 0.0) { 43 opcode = org.apache.bcel.Constants.FCONST_0; 44 } else if (f == 1.0) { 45 opcode = org.apache.bcel.Constants.FCONST_1; 46 } else if (f == 2.0) { 47 opcode = org.apache.bcel.Constants.FCONST_2; 48 } else { 49 throw new ClassGenException("FCONST can be used only for 0.0, 1.0 and 2.0: " + f); 50 } 51 value = f; 52 } 53 54 55 public Number getValue() { 56 return new Float (value); 57 } 58 59 60 62 public Type getType( ConstantPoolGen cp ) { 63 return Type.FLOAT; 64 } 65 66 67 75 public void accept( Visitor v ) { 76 v.visitPushInstruction(this); 77 v.visitStackProducer(this); 78 v.visitTypedInstruction(this); 79 v.visitConstantPushInstruction(this); 80 v.visitFCONST(this); 81 } 82 } 83 | Popular Tags |