KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > api > persistence > enhancer > classfile > InsnInterfaceInvoke


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24
25 package com.sun.jdo.api.persistence.enhancer.classfile;
26
27 import java.io.PrintStream JavaDoc;
28
29 /**
30  * Special instruction form for the opc_invokeinterface instruction
31  */

32
33 public class InsnInterfaceInvoke extends InsnConstOp {
34   /* The number of arguments to the interface method */
35   private int nArgsOp;
36
37   /* public accessors */
38
39   public int nStackArgs() {
40     return super.nStackArgs();
41   }
42
43   public int nStackResults() {
44     return super.nStackResults();
45   }
46
47   /**
48    * What are the types of the stack operands ?
49    */

50   public String JavaDoc argTypes() {
51     return super.argTypes();
52   }
53
54   /**
55    * What are the types of the stack results?
56    */

57   public String JavaDoc resultTypes() {
58     return super.resultTypes();
59   }
60
61   public boolean branches() {
62     return false;
63   }
64
65   /**
66    * Return the interface to be invoked
67    */

68   public ConstInterfaceMethodRef method() {
69     return (ConstInterfaceMethodRef) value();
70   }
71
72   /**
73    * Return the number of arguments to the interface
74    */

75   public int nArgs() {
76     return nArgsOp;
77   }
78
79   /**
80    * constructor for opc_invokeinterface
81    */

82   public InsnInterfaceInvoke (ConstInterfaceMethodRef methodRefOp,
83                   int nArgsOp) {
84     this(methodRefOp, nArgsOp, NO_OFFSET);
85   }
86
87   /* package local methods */
88
89   InsnInterfaceInvoke (ConstInterfaceMethodRef methodRefOp, int nArgsOp,
90                int offset) {
91     super(opc_invokeinterface, methodRefOp, offset);
92
93     this.nArgsOp = nArgsOp;
94
95     if (methodRefOp == null || nArgsOp < 0)
96     throw new InsnError ("attempt to create an opc_invokeinterface" +//NOI18N
97
" with invalid operands");//NOI18N
98
}
99
100   void print (PrintStream JavaDoc out, int indent) {
101     ClassPrint.spaces(out, indent);
102     out.println(offset() + " opc_invokeinterface " + //NOI18N
103
"pool(" + method().getIndex() + ")," + nArgsOp);//NOI18N
104
}
105
106   int store(byte[] buf, int index) {
107     buf[index++] = (byte) opcode();
108     index = storeShort(buf, index, (short)method().getIndex());
109     buf[index++] = (byte) nArgsOp;
110     buf[index++] = (byte) 0;
111     return index;
112   }
113
114   int size() {
115     return 5;
116   }
117
118   static InsnInterfaceInvoke read(InsnReadEnv insnEnv, int myPC) {
119     ConstInterfaceMethodRef iface = (ConstInterfaceMethodRef)
120       insnEnv.pool().constantAt(insnEnv.getUShort());
121     int nArgs = insnEnv.getUByte();
122     insnEnv.getByte(); // eat reserved arg
123
return new InsnInterfaceInvoke(iface, nArgs, myPC);
124   }
125 }
126
Popular Tags