1 17 package org.apache.bcel.generic; 18 19 27 public class LDC2_W extends CPInstruction implements PushInstruction, TypedInstruction { 28 29 33 LDC2_W() { 34 } 35 36 37 public LDC2_W(int index) { 38 super(org.apache.bcel.Constants.LDC2_W, index); 39 } 40 41 42 public Type getType( ConstantPoolGen cpg ) { 43 switch (cpg.getConstantPool().getConstant(index).getTag()) { 44 case org.apache.bcel.Constants.CONSTANT_Long: 45 return Type.LONG; 46 case org.apache.bcel.Constants.CONSTANT_Double: 47 return Type.DOUBLE; 48 default: throw new RuntimeException ("Unknown constant type " + opcode); 50 } 51 } 52 53 54 public Number getValue( ConstantPoolGen cpg ) { 55 org.apache.bcel.classfile.Constant c = cpg.getConstantPool().getConstant(index); 56 switch (c.getTag()) { 57 case org.apache.bcel.Constants.CONSTANT_Long: 58 return new Long (((org.apache.bcel.classfile.ConstantLong) c).getBytes()); 59 case org.apache.bcel.Constants.CONSTANT_Double: 60 return new Double (((org.apache.bcel.classfile.ConstantDouble) c).getBytes()); 61 default: throw new RuntimeException ("Unknown or invalid constant type at " + index); 63 } 64 } 65 66 67 75 public void accept( Visitor v ) { 76 v.visitStackProducer(this); 77 v.visitPushInstruction(this); 78 v.visitTypedInstruction(this); 79 v.visitCPInstruction(this); 80 v.visitLDC2_W(this); 81 } 82 } 83 | Popular Tags |