1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.bcel.generic;
18
19 /***
20 * Super class for instructions dealing with array access such as IALOAD.
21 *
22 * @version $Id: ArrayInstruction.java 386056 2006-03-15 11:31:56Z tcurdt $
23 * @author <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
24 */
25 public abstract class ArrayInstruction extends Instruction implements ExceptionThrower,
26 TypedInstruction {
27
28 /***
29 * Empty constructor needed for the Class.newInstance() statement in
30 * Instruction.readInstruction(). Not to be used otherwise.
31 */
32 ArrayInstruction() {
33 }
34
35
36 /***
37 * @param opcode of instruction
38 */
39 protected ArrayInstruction(short opcode) {
40 super(opcode, (short) 1);
41 }
42
43
44 public Class[] getExceptions() {
45 return org.apache.bcel.ExceptionConstants.EXCS_ARRAY_EXCEPTION;
46 }
47
48
49 /*** @return type associated with the instruction
50 */
51 public Type getType( ConstantPoolGen cp ) {
52 switch (opcode) {
53 case org.apache.bcel.Constants.IALOAD:
54 case org.apache.bcel.Constants.IASTORE:
55 return Type.INT;
56 case org.apache.bcel.Constants.CALOAD:
57 case org.apache.bcel.Constants.CASTORE:
58 return Type.CHAR;
59 case org.apache.bcel.Constants.BALOAD:
60 case org.apache.bcel.Constants.BASTORE:
61 return Type.BYTE;
62 case org.apache.bcel.Constants.SALOAD:
63 case org.apache.bcel.Constants.SASTORE:
64 return Type.SHORT;
65 case org.apache.bcel.Constants.LALOAD:
66 case org.apache.bcel.Constants.LASTORE:
67 return Type.LONG;
68 case org.apache.bcel.Constants.DALOAD:
69 case org.apache.bcel.Constants.DASTORE:
70 return Type.DOUBLE;
71 case org.apache.bcel.Constants.FALOAD:
72 case org.apache.bcel.Constants.FASTORE:
73 return Type.FLOAT;
74 case org.apache.bcel.Constants.AALOAD:
75 case org.apache.bcel.Constants.AASTORE:
76 return Type.OBJECT;
77 default:
78 throw new ClassGenException("Oops: unknown case in switch" + opcode);
79 }
80 }
81 }