00001 package de.fub.bytecode.generic;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 public class LDC2_W extends CPInstruction
00012 implements PushInstruction, TypedInstruction {
00013
00014
00015
00016
00017 LDC2_W() {}
00018 public LDC2_W(int index) {
00019 super(de.fub.bytecode.Constants.LDC2_W, index);
00020 }
00021
00022
00023
00024
00025
00026
00027
00028
00029 public void accept(Visitor v) {
00030 v.visitStackProducer(this);
00031 v.visitPushInstruction(this);
00032 v.visitTypedInstruction(this);
00033 v.visitCPInstruction(this);
00034 v.visitLDC2_W(this);
00035 }
00036 public Type getType(ConstantPoolGen cpg) {
00037 switch(cpg.getConstantPool().getConstant(index).getTag()) {
00038 case de.fub.bytecode.Constants.CONSTANT_Long: return Type.LONG;
00039 case de.fub.bytecode.Constants.CONSTANT_Double: return Type.DOUBLE;
00040 default:
00041 throw new RuntimeException("Unknown constant type " + tag);
00042 }
00043 }
00044 public Number getValue(ConstantPoolGen cpg) {
00045 de.fub.bytecode.classfile.Constant c = cpg.getConstantPool().getConstant(index);
00046
00047 switch(c.getTag()) {
00048 case de.fub.bytecode.Constants.CONSTANT_Long:
00049 return new Long(((de.fub.bytecode.classfile.ConstantLong)c).getBytes());
00050
00051 case de.fub.bytecode.Constants.CONSTANT_Double:
00052 return new Double(((de.fub.bytecode.classfile.ConstantDouble)c).getBytes());
00053
00054 default:
00055 throw new RuntimeException("Unknown or invalid constant type at " + index);
00056 }
00057 }
00058 }