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: /** There should be exactly one code attribute in every method; there
29: * may also be a code attribute associated with a field (as an
30: * initializer).
31: * @see attribute_info
32: * @see method_info#attributes
33: * @see field_info#attributes
34: * @see ClassFile@attributes
35: * @author Clark Verbrugge
36: */
37: class Code_attribute extends attribute_info {
38: /** Maximum size of the operand stack. */
39: public int max_stack;
40: /** Maximum number of locals required. */
41:
42: public int max_locals;
43: /** Length of code array. */
44: public long code_length;
45: /** Actual array of bytecode. */
46: public byte code[];
47: /** Length of exception table array. */
48: public int exception_table_length;
49: /** Exception table array.
50: * @see exception_table_entry
51: */
52: public exception_table_entry exception_table[];
53: /** Length of attributes array. */
54: int attributes_count;
55: /** Array of attributes.
56: * @see attribute_info
57: */
58: attribute_info attributes[];
59:
60: /** Locates the LocalVariableTable attribute, if one is present.
61: * @return the local variable table attribute, or <i>null</i> if not found.
62: * @see LocalVariableTable_attribute
63: * @see method_info#makeLocals
64: */
65: public LocalVariableTable_attribute findLocalVariableTable() {
66: int i;
67: for (i = 0; i < attributes_count; i++) {
68: if (attributes[i] instanceof LocalVariableTable_attribute)
69: return (LocalVariableTable_attribute) (attributes[i]);
70: }
71: return null;
72: }
73:
74: /** Locates the LocalVariableTypeTable attribute, if one is present.
75: * @return the local variable type table attribute, or <i>null</i>
76: * if not found.
77: * @see LocalVariableTypeTable_attribute
78: * @see method_info#makeLocals
79: */
80: public LocalVariableTypeTable_attribute findLocalVariableTypeTable() {
81: int i;
82: for (i = 0; i < attributes_count; i++) {
83: if (attributes[i] instanceof LocalVariableTypeTable_attribute)
84: return (LocalVariableTypeTable_attribute) (attributes[i]);
85: }
86: return null;
87: }
88: }
|