01: /* Soot - a J*va Optimization Framework
02: * Copyright (C) 1997 Clark Verbrugge
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the
16: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17: * Boston, MA 02111-1307, USA.
18: */
19:
20: /*
21: * Modified by the Sable Research Group and others 1997-1999.
22: * See the 'credits' file distributed with Soot for the complete list of
23: * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
24: */
25:
26: package soot.coffi;
27:
28: /** Instruction subclasses are used to represent parsed bytecode; each
29: * bytecode operation has a corresponding subclass of Instruction.
30: * <p>
31: * Each subclass is derived from one of
32: * <ul><li>Instruction</li>
33: * <li>Instruction_noargs (an Instruction with no embedded arguments)</li>
34: * <li>Instruction_byte (an Instruction with a single byte data argument)</li>
35: * <li>Instruction_bytevar (a byte argument specifying a local variable)</li>
36: * <li>Instruction_byteindex (a byte argument specifying a constant pool index)</li>
37: * <li>Instruction_int (an Instruction with a single short data argument)</li>
38: * <li>Instruction_intvar (a short argument specifying a local variable)</li>
39: * <li>Instruction_intindex (a short argument specifying a constant pool index)</li>
40: * <li>Instruction_intbranch (a short argument specifying a code offset)</li>
41: * <li>Instruction_longbranch (an int argument specifying a code offset)</li>
42: * </ul>
43: * @author Clark Verbrugge
44: * @see Instruction
45: * @see Instruction_noargs
46: * @see Instruction_byte
47: * @see Instruction_bytevar
48: * @see Instruction_byteindex
49: * @see Instruction_int
50: * @see Instruction_intvar
51: * @see Instruction_intindex
52: * @see Instruction_intbranch
53: * @see Instruction_longbranch
54: * @see Instruction_Unknown
55: */
56: class Instruction_intindex extends Instruction {
57: public int arg_i;
58:
59: public Instruction_intindex(byte c) {
60: super (c);
61: }
62:
63: public String toString(cp_info constant_pool[]) {
64: return super .toString(constant_pool) + argsep + "["
65: + constant_pool[arg_i].toString(constant_pool) + "]";
66: }
67:
68: public int nextOffset(int curr) {
69: return curr + 3;
70: }
71:
72: public void markCPRefs(boolean[] refs) {
73: refs[arg_i] = true;
74: }
75:
76: public void redirectCPRefs(short redirect[]) {
77: arg_i = redirect[arg_i];
78: }
79:
80: public int parse(byte bc[], int index) {
81: arg_i = getShort(bc, index);
82: return index + 2;
83: }
84:
85: public int compile(byte bc[], int index) {
86: bc[index++] = code;
87: shortToBytes((short) arg_i, bc, index);
88: return index + 2;
89: }
90: }
|