1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.bcel.generic;
20
21
22
23
24
25
26
27
28 public class LDC2_W extends CPInstruction implements PushInstruction {
29
30
31
32
33 LDC2_W() {
34 }
35
36 public LDC2_W(final int index) {
37 super(org.apache.bcel.Const.LDC2_W, index);
38 }
39
40
41
42
43
44
45
46 @Override
47 public void accept(final Visitor v) {
48 v.visitStackProducer(this);
49 v.visitPushInstruction(this);
50 v.visitTypedInstruction(this);
51 v.visitCPInstruction(this);
52 v.visitLDC2_W(this);
53 }
54
55 @Override
56 public Type getType(final ConstantPoolGen cpg) {
57 switch (cpg.getConstantPool().getConstant(super.getIndex()).getTag()) {
58 case org.apache.bcel.Const.CONSTANT_Long:
59 return Type.LONG;
60 case org.apache.bcel.Const.CONSTANT_Double:
61 return Type.DOUBLE;
62 default:
63 throw new IllegalArgumentException("Unknown constant type " + super.getOpcode());
64 }
65 }
66
67 public Number getValue(final ConstantPoolGen cpg) {
68 final org.apache.bcel.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex());
69 switch (c.getTag()) {
70 case org.apache.bcel.Const.CONSTANT_Long:
71 return Long.valueOf(((org.apache.bcel.classfile.ConstantLong) c).getBytes());
72 case org.apache.bcel.Const.CONSTANT_Double:
73 return Double.valueOf(((org.apache.bcel.classfile.ConstantDouble) c).getBytes());
74 default:
75 throw new IllegalArgumentException("Unknown or invalid constant type at " + super.getIndex());
76 }
77 }
78 }