1 package com.sun.org.apache.bcel.internal.generic; 2 3 56 57 65 public class LDC2_W extends CPInstruction 66 implements PushInstruction, TypedInstruction { 67 71 LDC2_W() {} 72 73 public LDC2_W(int index) { 74 super(com.sun.org.apache.bcel.internal.Constants.LDC2_W, index); 75 } 76 77 public Type getType(ConstantPoolGen cpg) { 78 switch(cpg.getConstantPool().getConstant(index).getTag()) { 79 case com.sun.org.apache.bcel.internal.Constants.CONSTANT_Long: return Type.LONG; 80 case com.sun.org.apache.bcel.internal.Constants.CONSTANT_Double: return Type.DOUBLE; 81 default: throw new RuntimeException ("Unknown constant type " + opcode); 83 } 84 } 85 86 public Number getValue(ConstantPoolGen cpg) { 87 com.sun.org.apache.bcel.internal.classfile.Constant c = cpg.getConstantPool().getConstant(index); 88 89 switch(c.getTag()) { 90 case com.sun.org.apache.bcel.internal.Constants.CONSTANT_Long: 91 return new Long (((com.sun.org.apache.bcel.internal.classfile.ConstantLong)c).getBytes()); 92 93 case com.sun.org.apache.bcel.internal.Constants.CONSTANT_Double: 94 return new Double (((com.sun.org.apache.bcel.internal.classfile.ConstantDouble)c).getBytes()); 95 96 default: throw new RuntimeException ("Unknown or invalid constant type at " + index); 98 } 99 } 100 101 109 public void accept(Visitor v) { 110 v.visitStackProducer(this); 111 v.visitPushInstruction(this); 112 v.visitTypedInstruction(this); 113 v.visitCPInstruction(this); 114 v.visitLDC2_W(this); 115 } 116 } 117 | Popular Tags |