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