4 #include <libfirm/firm_types.h>
13 extern struct obstack ast_obstack;
39 declaration_t *declarations;
42 struct expression_base_t {
43 expression_type_t type;
45 source_position_t source_position;
48 struct const_expression_t {
49 expression_base_t expression;
52 long double float_value;
56 struct string_literal_expression_t {
57 expression_base_t expression;
61 struct builtin_symbol_expression_t {
62 expression_base_t expression;
66 struct reference_expression_t {
67 expression_base_t expression;
69 declaration_t *declaration;
72 struct call_argument_t {
73 expression_t *expression;
74 call_argument_t *next;
77 struct call_expression_t {
78 expression_base_t expression;
79 expression_t *function;
80 call_argument_t *arguments;
87 UNEXPR_BITWISE_NEGATE,
91 UNEXPR_POSTFIX_INCREMENT,
92 UNEXPR_POSTFIX_DECREMENT,
93 UNEXPR_PREFIX_INCREMENT,
94 UNEXPR_PREFIX_DECREMENT,
96 } unary_expression_type_t;
98 struct unary_expression_t {
99 expression_base_t expression;
100 unary_expression_type_t type;
116 BINEXPR_GREATEREQUAL,
130 BINEXPR_SHIFTLEFT_ASSIGN,
131 BINEXPR_SHIFTRIGHT_ASSIGN,
132 BINEXPR_BITWISE_AND_ASSIGN,
133 BINEXPR_BITWISE_XOR_ASSIGN,
134 BINEXPR_BITWISE_OR_ASSIGN,
136 } binary_expression_type_t;
138 struct binary_expression_t {
139 expression_base_t expression;
140 binary_expression_type_t type;
145 struct select_expression_t {
146 expression_base_t expression;
147 expression_t *compound;
150 declaration_t *compound_entry;
153 struct array_access_expression_t {
154 expression_base_t expression;
155 expression_t *array_ref;
157 bool flipped; /* index/ref was written in a 5[a] way */
160 struct sizeof_expression_t {
161 expression_base_t expression;
163 expression_t *size_expression;
166 struct designator_t {
168 expression_t *array_access;
172 struct offsetof_expression_t {
173 expression_base_t expression;
175 designator_t *designator;
178 struct va_arg_expression_t {
179 expression_base_t expression;
184 struct conditional_expression_t {
185 expression_base_t expression;
186 expression_t *condition;
187 expression_t *true_expression;
188 expression_t *false_expression;
191 struct statement_expression_t {
192 expression_base_t expression;
193 statement_t *statement;
196 struct classify_type_expression_t {
197 expression_base_t expression;
198 expression_t *type_expression;
202 expression_type_t type;
203 expression_base_t base;
204 const_expression_t conste;
205 string_literal_expression_t string;
206 builtin_symbol_expression_t builtin_symbol;
207 reference_expression_t reference;
208 call_expression_t call;
209 unary_expression_t unary;
210 binary_expression_t binary;
211 select_expression_t select;
212 array_access_expression_t array_access;
213 sizeof_expression_t sizeofe;
214 offsetof_expression_t offsetofe;
215 va_arg_expression_t va_arge;
216 conditional_expression_t conditional;
217 statement_expression_t statement;
218 classify_type_expression_t classify_type;
223 STORAGE_CLASS_TYPEDEF,
224 STORAGE_CLASS_EXTERN,
225 STORAGE_CLASS_STATIC,
227 STORAGE_CLASS_REGISTER,
228 STORAGE_CLASS_ENUM_ENTRY,
229 STORAGE_CLASS_THREAD,
230 STORAGE_CLASS_THREAD_EXTERN,
231 STORAGE_CLASS_THREAD_STATIC
232 } storage_class_tag_t;
247 } initializer_type_t;
249 struct initializer_base_t {
250 initializer_type_t type;
253 struct initializer_value_t {
254 initializer_base_t initializer;
258 struct initializer_list_t {
259 initializer_base_t initializer;
261 initializer_t *initializers[];
264 struct initializer_string_t {
265 initializer_base_t initializer;
269 union initializer_t {
270 initializer_type_t type;
271 initializer_base_t base;
272 initializer_value_t value;
273 initializer_list_t list;
274 initializer_string_t string;
277 struct declaration_t {
278 unsigned char namespc;
279 unsigned char storage_class;
280 unsigned int address_taken : 1;
281 unsigned int is_inline : 1;
284 source_position_t source_position;
287 statement_t *statement;
288 initializer_t *initializer;
289 expression_t *enum_value;
292 context_t *parent_context;
294 /** next declaration in a context */
296 /** next declaration with same symbol */
297 declaration_t *symbol_next;
299 unsigned char declaration_type; /* used in ast2firm module */
301 unsigned int value_number; /* used in ast2firm module */
302 ir_entity *entity; /* used in ast2firm module */
303 ir_node *block; /* used in ast2firm module */
304 tarval *enum_val; /* used in ast2firm module */
312 STATEMENT_DECLARATION,
315 STATEMENT_EXPRESSION,
320 STATEMENT_CASE_LABEL,
326 struct statement_base_t {
327 statement_type_t type;
329 source_position_t source_position;
332 struct return_statement_t {
333 statement_base_t statement;
334 expression_t *return_value;
337 struct compound_statement_t {
338 statement_base_t statement;
339 statement_t *statements;
343 struct declaration_statement_t {
344 statement_base_t statement;
345 declaration_t *declarations_begin;
346 declaration_t *declarations_end;
349 struct if_statement_t {
350 statement_base_t statement;
351 expression_t *condition;
352 statement_t *true_statement;
353 statement_t *false_statement;
356 struct switch_statement_t {
357 statement_base_t statement;
358 expression_t *expression;
362 struct goto_statement_t {
363 statement_base_t statement;
364 declaration_t *label;
367 struct case_label_statement_t {
368 statement_base_t statement;
369 expression_t *expression;
370 statement_t *label_statement;
373 struct label_statement_t {
374 statement_base_t statement;
375 declaration_t *label;
376 statement_t *label_statement;
379 struct expression_statement_t {
380 statement_base_t statement;
381 expression_t *expression;
384 struct while_statement_t {
385 statement_base_t statement;
386 expression_t *condition;
390 struct do_while_statement_t {
391 statement_base_t statement;
392 expression_t *condition;
396 struct for_statement_t {
397 statement_base_t statement;
398 expression_t *initialisation;
399 expression_t *condition;
406 statement_type_t type;
407 statement_base_t base;
408 return_statement_t returns;
409 compound_statement_t compound;
410 declaration_statement_t declaration;
412 switch_statement_t switchs;
413 goto_statement_t gotos;
414 case_label_statement_t case_label;
415 label_statement_t label;
416 expression_statement_t expression;
417 while_statement_t whiles;
418 do_while_statement_t do_while;
419 for_statement_t fors;
422 struct translation_unit_t {
427 void *_allocate_ast(size_t size)
429 return obstack_alloc(&ast_obstack, size);
432 #define allocate_ast(size) _allocate_ast(size)