KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > bcel > generic > ReturnInstruction


1 /*
2  * Copyright 2000-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
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: // Never reached
62
throw new ClassGenException("Unknown type " + opcode);
63         }
64     }
65
66
67     public Class JavaDoc[] getExceptions() {
68         return new Class JavaDoc[] {
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 }
80
Popular Tags