1 package com.sun.org.apache.bcel.internal.generic; 2 3 56 57 65 public class FCONST extends Instruction 66 implements ConstantPushInstruction, TypedInstruction { 67 private float value; 68 69 73 FCONST() {} 74 75 public FCONST(float f) { 76 super(com.sun.org.apache.bcel.internal.Constants.FCONST_0, (short)1); 77 78 if(f == 0.0) 79 opcode = com.sun.org.apache.bcel.internal.Constants.FCONST_0; 80 else if(f == 1.0) 81 opcode = com.sun.org.apache.bcel.internal.Constants.FCONST_1; 82 else if(f == 2.0) 83 opcode = com.sun.org.apache.bcel.internal.Constants.FCONST_2; 84 else 85 throw new ClassGenException("FCONST can be used only for 0.0, 1.0 and 2.0: " + f); 86 87 value = f; 88 } 89 90 public Number getValue() { return new Float (value); } 91 92 94 public Type getType(ConstantPoolGen cp) { 95 return Type.FLOAT; 96 } 97 98 99 107 public void accept(Visitor v) { 108 v.visitPushInstruction(this); 109 v.visitStackProducer(this); 110 v.visitTypedInstruction(this); 111 v.visitConstantPushInstruction(this); 112 v.visitFCONST(this); 113 } 114 } 115 | Popular Tags |