KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > jclasslib > bytecode > InvokeInterfaceInstruction


1 /*
2     This library is free software; you can redistribute it and/or
3     modify it under the terms of the GNU General Public
4     License as published by the Free Software Foundation; either
5     version 2 of the license, or (at your option) any later version.
6 */

7
8 package org.gjt.jclasslib.bytecode;
9
10 import org.gjt.jclasslib.io.ByteCodeInput;
11 import org.gjt.jclasslib.io.ByteCodeOutput;
12
13 import java.io.IOException JavaDoc;
14
15 /**
16     Describes the <tt>invokeinterface</tt> instruction.
17  
18     @author <a HREF="mailto:jclasslib@ej-technologies.com">Ingo Kegel</a>
19     @version $Revision: 1.5 $ $Date: 2003/08/18 07:58:35 $
20 */

21 public class InvokeInterfaceInstruction extends ImmediateShortInstruction {
22
23     private int count;
24     
25     /**
26         Constructor.
27         @param opcode the opcode.
28      */

29     public InvokeInterfaceInstruction(int opcode) {
30         super(opcode);
31     }
32     
33     /**
34         Constructor.
35         @param opcode the opcode
36         @param immediateShort the immediate short value.
37         @param count the argument count.
38      */

39     public InvokeInterfaceInstruction(int opcode, int immediateShort, int count) {
40         super(opcode, immediateShort);
41         this.count = count;
42     }
43     
44     
45     public int getSize() {
46         return super.getSize() + 2;
47     }
48
49     /**
50         Get the argument count of this instruction.
51         @return the argument count
52      */

53     public int getCount() {
54         return count;
55     }
56
57     /**
58         Set the argument count of this instruction.
59         @param count the argument count
60      */

61     public void setCount(int count) {
62         this.count = count;
63     }
64
65     public void read(ByteCodeInput in) throws IOException JavaDoc {
66         super.read(in);
67
68         count = in.readUnsignedByte();
69         // Next byte is always 0 and thus discarded
70
in.readByte();
71     }
72
73     public void write(ByteCodeOutput out) throws IOException JavaDoc {
74         super.write(out);
75
76         out.writeByte(count);
77         out.writeByte(0);
78     }
79     
80 }
81
Popular Tags