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