* Removed all Id tags.
[cacao.git] / src / vmcore / stackmap.h
1 /* src/vmcore/stackmap.h - class attribute StackMapTable
2
3    Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25 */
26
27
28 #ifndef _STACKMAP_H
29 #define _STACKMAP_H
30
31 /* forward typedefs ***********************************************************/
32
33 typedef struct stack_map_t                       stack_map_t;
34 typedef union  stack_map_frame_t                 stack_map_frame_t;
35 typedef struct same_locals_1_stack_item_frame_t  same_locals_1_stack_item_frame_t;
36 typedef struct same_locals_1_stack_item_frame_extended_t same_locals_1_stack_item_frame_extended_t;
37 typedef struct chop_frame_t                      chop_frame_t;
38 typedef struct same_frame_extended_t             same_frame_extended_t;
39 typedef struct append_frame_t                    append_frame_t;
40 typedef struct full_frame_t                      full_frame_t;
41
42 typedef union  verification_type_info_t          verification_type_info_t;
43 typedef struct Top_variable_info_t                   Top_variable_info_t;
44 typedef struct Integer_variable_info_t           Integer_variable_info_t;
45 typedef struct Float_variable_info_t             Float_variable_info_t;
46 typedef struct Long_variable_info_t              Long_variable_info_t;
47 typedef struct Double_variable_info_t            Double_variable_info_t;
48 typedef struct Null_variable_info_t              Null_variable_info_t;
49 typedef struct UninitializedThis_variable_info_t UninitializedThis_variable_info_t;
50 typedef struct Object_variable_info_t            Object_variable_info_t;
51 typedef struct Uninitialized_variable_info_t     Uninitialized_variable_info_t;
52
53
54 #include "config.h"
55 #include "vm/types.h"
56
57 #include "vm/global.h"
58
59 #include "vmcore/loader.h"
60 #include "vmcore/method.h"
61
62
63 /* verification_type_info *****************************************************/
64
65 #define ITEM_Top                  0
66 #define ITEM_Integer              1
67 #define ITEM_Float                2
68 #define ITEM_Double               3
69 #define ITEM_Long                 4
70 #define ITEM_Null                 5
71 #define ITEM_UninitializedThis    6
72 #define ITEM_Object               7
73 #define ITEM_Uninitialized        8
74
75 struct Top_variable_info_t {
76         u1 tag;
77 };
78
79 struct Integer_variable_info_t {
80         u1 tag;
81 };
82
83 struct Float_variable_info_t {
84         u1 tag;
85 };
86
87 struct Long_variable_info_t {
88         u1 tag;
89 };
90
91 struct Double_variable_info_t {
92         u1 tag;
93 };
94
95 struct Null_variable_info_t {
96         u1 tag;
97 };
98
99 struct UninitializedThis_variable_info_t {
100         u1 tag;
101 };
102
103 struct Object_variable_info_t {
104         u1 tag;
105         u2 cpool_index;
106 };
107
108 struct Uninitialized_variable_info_t {
109         u1 tag;
110         u2 offset;
111 };
112
113 union verification_type_info_t {
114         u1 tag;
115         Top_variable_info_t                   Top_variable_info;
116         Integer_variable_info_t           Integer_variable_info;
117         Float_variable_info_t             Float_variable_info;
118         Long_variable_info_t              Long_variable_info;
119         Double_variable_info_t            Double_variable_info;
120         Null_variable_info_t              Null_variable_info;
121         UninitializedThis_variable_info_t UninitializedThis_variable_info;
122         Object_variable_info_t            Object_variable_info;
123         Uninitialized_variable_info_t     Uninitialized_variable_info;
124 };
125
126
127 /* stack_map_t ****************************************************************/
128
129 struct stack_map_t {
130         u2                 attribute_name_index;
131         u4                 attribute_length;
132         u2                 number_of_entries;
133         stack_map_frame_t *entries;
134 };
135
136
137 /* same_locals_1_stack_item_frame_t *******************************************/
138
139 struct same_locals_1_stack_item_frame_t {
140         u1                       frame_type;
141         verification_type_info_t stack[1];
142 };
143
144
145 /* same_locals_1_stack_item_frame_extended_t **********************************/
146
147 struct same_locals_1_stack_item_frame_extended_t {
148         u1                       frame_type;
149         u2                       offset_delta;
150         verification_type_info_t stack[1];
151 };
152
153
154 /* chop_frame_t ***************************************************************/
155
156 struct chop_frame_t {
157         u1 frame_type;
158         u2 offset_delta;
159 };
160
161
162 /* same_frame_extended_t ******************************************************/
163
164 struct same_frame_extended_t {
165         u1 frame_type;
166         u2 offset_delta;
167 };
168
169
170 /* append_frame_t *************************************************************/
171
172 struct append_frame_t {
173         u1                        frame_type;
174         u2                        offset_delta;
175         verification_type_info_t *locals;
176 };
177
178
179 /* full_frame_t ***************************************************************/
180
181 struct full_frame_t {
182         u1                        frame_type;
183         u2                        offset_delta;
184         u2                        number_of_locals;
185         verification_type_info_t *locals;
186         u2                        number_of_stack_items;
187         verification_type_info_t *stack;
188 };
189
190
191 /* stack_map_frame_t **********************************************************/
192
193 #define FRAME_TYPE_SAME                                 63   /* 0-63          */
194 #define FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM             127  /* 0-127         */
195 #define FRAME_TYPE_RESERVED                             246  /* 128-246       */
196 #define FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM_EXTENDED    247  /* 247           */
197 #define FRAME_TYPE_CHOP                                 250  /* 248-250       */
198 #define FRAME_TYPE_SAME_FRAME_EXTENDED                  251  /* 251           */
199 #define FRAME_TYPE_APPEND                               254  /* 252-254       */
200 #define FRAME_TYPE_FULL_FRAME                           255  /* 255           */
201
202 union stack_map_frame_t {
203         u1                                        frame_type;
204         same_locals_1_stack_item_frame_t          same_locals_1_stack_item_frame;
205         same_locals_1_stack_item_frame_extended_t same_locals_1_stack_item_frame_extended;
206         chop_frame_t                              chop_frame;
207         same_frame_extended_t                     same_frame_extended;
208         append_frame_t                            append_frame;
209         full_frame_t                              full_frame;
210 };
211
212
213 /* function prototypes ********************************************************/
214
215 bool stackmap_load_attribute_stackmaptable(classbuffer *cb, methodinfo *m);
216
217 #endif /* _STACKMAP_H */
218
219
220 /*
221  * These are local overrides for various environment variables in Emacs.
222  * Please do not remove this and leave it at the end of the file, where
223  * Emacs will automagically detect them.
224  * ---------------------------------------------------------------------
225  * Local variables:
226  * mode: c
227  * indent-tabs-mode: t
228  * c-basic-offset: 4
229  * tab-width: 4
230  * End:
231  * vim:noexpandtab:sw=4:ts=4:
232  */