* src/vm/class.c (vm/suck.h): Added.
[cacao.git] / src / vm / stackmap.h
1 /* src/vm/stackmap.h - class attribute StackMapTable
2
3    Copyright (C) 2006 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    Contact: cacao@cacaojvm.org
26
27    Authors: Christian Thalinger
28
29    $Id: utf8.h 5920 2006-11-05 21:23:09Z twisti $
30
31 */
32
33
34 #ifndef _STACKMAP_H
35 #define _STACKMAP_H
36
37 /* forward typedefs ***********************************************************/
38
39 typedef struct stack_map_t                       stack_map_t;
40 typedef union  stack_map_frame_t                 stack_map_frame_t;
41 typedef struct same_locals_1_stack_item_frame_t  same_locals_1_stack_item_frame_t;
42 typedef struct same_locals_1_stack_item_frame_extended_t same_locals_1_stack_item_frame_extended_t;
43 typedef struct chop_frame_t                      chop_frame_t;
44 typedef struct same_frame_extended_t             same_frame_extended_t;
45 typedef struct append_frame_t                    append_frame_t;
46 typedef struct full_frame_t                      full_frame_t;
47
48 typedef union  verification_type_info_t          verification_type_info_t;
49 typedef struct Top_variable_info_t                   Top_variable_info_t;
50 typedef struct Integer_variable_info_t           Integer_variable_info_t;
51 typedef struct Float_variable_info_t             Float_variable_info_t;
52 typedef struct Long_variable_info_t              Long_variable_info_t;
53 typedef struct Double_variable_info_t            Double_variable_info_t;
54 typedef struct Null_variable_info_t              Null_variable_info_t;
55 typedef struct UninitializedThis_variable_info_t UninitializedThis_variable_info_t;
56 typedef struct Object_variable_info_t            Object_variable_info_t;
57 typedef struct Uninitialized_variable_info_t     Uninitialized_variable_info_t;
58
59
60 #include "config.h"
61 #include "vm/types.h"
62
63 #include "vm/global.h"
64 #include "vm/loader.h"
65 #include "vm/method.h"
66
67
68 /* verification_type_info *****************************************************/
69
70 #define ITEM_Top                  0
71 #define ITEM_Integer              1
72 #define ITEM_Float                2
73 #define ITEM_Double               3
74 #define ITEM_Long                 4
75 #define ITEM_Null                 5
76 #define ITEM_UninitializedThis    6
77 #define ITEM_Object               7
78 #define ITEM_Uninitialized        8
79
80 struct Top_variable_info_t {
81         u1 tag;
82 };
83
84 struct Integer_variable_info_t {
85         u1 tag;
86 };
87
88 struct Float_variable_info_t {
89         u1 tag;
90 };
91
92 struct Long_variable_info_t {
93         u1 tag;
94 };
95
96 struct Double_variable_info_t {
97         u1 tag;
98 };
99
100 struct Null_variable_info_t {
101         u1 tag;
102 };
103
104 struct UninitializedThis_variable_info_t {
105         u1 tag;
106 };
107
108 struct Object_variable_info_t {
109         u1 tag;
110         u2 cpool_index;
111 };
112
113 struct Uninitialized_variable_info_t {
114         u1 tag;
115         u2 offset;
116 };
117
118 union verification_type_info_t {
119         u1 tag;
120         Top_variable_info_t                   Top_variable_info;
121         Integer_variable_info_t           Integer_variable_info;
122         Float_variable_info_t             Float_variable_info;
123         Long_variable_info_t              Long_variable_info;
124         Double_variable_info_t            Double_variable_info;
125         Null_variable_info_t              Null_variable_info;
126         UninitializedThis_variable_info_t UninitializedThis_variable_info;
127         Object_variable_info_t            Object_variable_info;
128         Uninitialized_variable_info_t     Uninitialized_variable_info;
129 };
130
131
132 /* stack_map_t ****************************************************************/
133
134 struct stack_map_t {
135         u2                 attribute_name_index;
136         u4                 attribute_length;
137         u2                 number_of_entries;
138         stack_map_frame_t *entries;
139 };
140
141
142 /* same_locals_1_stack_item_frame_t *******************************************/
143
144 struct same_locals_1_stack_item_frame_t {
145         u1                       frame_type;
146         verification_type_info_t stack[1];
147 };
148
149
150 /* same_locals_1_stack_item_frame_extended_t **********************************/
151
152 struct same_locals_1_stack_item_frame_extended_t {
153         u1                       frame_type;
154         u2                       offset_delta;
155         verification_type_info_t stack[1];
156 };
157
158
159 /* chop_frame_t ***************************************************************/
160
161 struct chop_frame_t {
162         u1 frame_type;
163         u2 offset_delta;
164 };
165
166
167 /* same_frame_extended_t ******************************************************/
168
169 struct same_frame_extended_t {
170         u1 frame_type;
171         u2 offset_delta;
172 };
173
174
175 /* append_frame_t *************************************************************/
176
177 struct append_frame_t {
178         u1                        frame_type;
179         u2                        offset_delta;
180         verification_type_info_t *locals;
181 };
182
183
184 /* full_frame_t ***************************************************************/
185
186 struct full_frame_t {
187         u1                        frame_type;
188         u2                        offset_delta;
189         u2                        number_of_locals;
190         verification_type_info_t *locals;
191         u2                        number_of_stack_items;
192         verification_type_info_t *stack;
193 };
194
195
196 /* stack_map_frame_t **********************************************************/
197
198 #define FRAME_TYPE_SAME                                 63   /* 0-63          */
199 #define FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM             127  /* 0-127         */
200 #define FRAME_TYPE_RESERVED                             246  /* 128-246       */
201 #define FRAME_TYPE_SAME_LOCALS_1_STACK_ITEM_EXTENDED    247  /* 247           */
202 #define FRAME_TYPE_CHOP                                 250  /* 248-250       */
203 #define FRAME_TYPE_SAME_FRAME_EXTENDED                  251  /* 251           */
204 #define FRAME_TYPE_APPEND                               254  /* 252-254       */
205 #define FRAME_TYPE_FULL_FRAME                           255  /* 255           */
206
207 union stack_map_frame_t {
208         u1                                        frame_type;
209         same_locals_1_stack_item_frame_t          same_locals_1_stack_item_frame;
210         same_locals_1_stack_item_frame_extended_t same_locals_1_stack_item_frame_extended;
211         chop_frame_t                              chop_frame;
212         same_frame_extended_t                     same_frame_extended;
213         append_frame_t                            append_frame;
214         full_frame_t                              full_frame;
215 };
216
217
218 /* function prototypes ********************************************************/
219
220 bool stackmap_load_attribute_stackmaptable(classbuffer *cb, methodinfo *m);
221
222 #endif /* _STACKMAP_H */
223
224
225 /*
226  * These are local overrides for various environment variables in Emacs.
227  * Please do not remove this and leave it at the end of the file, where
228  * Emacs will automagically detect them.
229  * ---------------------------------------------------------------------
230  * Local variables:
231  * mode: c
232  * indent-tabs-mode: t
233  * c-basic-offset: 4
234  * tab-width: 4
235  * End:
236  * vim:noexpandtab:sw=4:ts=4:
237  */