KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > coffi > Code_attribute


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 1997 Clark Verbrugge
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * 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
27
28
29
30
31
32 package soot.coffi;
33
34 import java.io.*;
35
36 /** There should be exactly one code attribute in every method; there
37  * may also be a code attribute associated with a field (as an
38  * initializer).
39  * @see attribute_info
40  * @see method_info#attributes
41  * @see field_info#attributes
42  * @see ClassFile@attributes
43  * @author Clark Verbrugge
44  */

45 class Code_attribute extends attribute_info {
46    /** Maximum size of the operand stack. */
47    public int max_stack;
48    /** Maximum number of locals required. */
49
50    public int max_locals;
51    /** Length of code array. */
52    public long code_length;
53    /** Actual array of bytecode. */
54    public byte code[];
55    /** Length of exception table array. */
56    public int exception_table_length;
57    /** Exception table array.
58     * @see exception_table_entry
59     */

60    public exception_table_entry exception_table[];
61    /** Length of attributes array. */
62    int attributes_count;
63    /** Array of attributes.
64     * @see attribute_info
65     */

66    attribute_info attributes[];
67
68    /** Locates the LocalVariableTable attribute, if one is present.
69     * @return the local variable table attribute, or <i>null</i> if not found.
70     * @see LocalVariableTable_attribute
71     * @see method_info#makeLocals
72     */

73    public LocalVariableTable_attribute findLocalVariableTable() {
74       int i;
75       for (i=0;i<attributes_count;i++) {
76          if (attributes[i] instanceof LocalVariableTable_attribute)
77             return (LocalVariableTable_attribute)(attributes[i]);
78       }
79       return null;
80    }
81    
82    /** Locates the LocalVariableTypeTable attribute, if one is present.
83     * @return the local variable type table attribute, or <i>null</i>
84     * if not found.
85     * @see LocalVariableTypeTable_attribute
86     * @see method_info#makeLocals
87     */

88    public LocalVariableTypeTable_attribute findLocalVariableTypeTable() {
89       int i;
90       for (i=0;i<attributes_count;i++) {
91          if (attributes[i] instanceof LocalVariableTypeTable_attribute)
92             return (LocalVariableTypeTable_attribute)(attributes[i]);
93       }
94       return null;
95    }
96 }
97
Popular Tags