4 #include <libfirm/firm_types.h>
13 extern struct obstack ast_obstack;
39 declaration_t *declarations;
43 expresion_type_t type;
45 source_position_t source_position;
49 expression_t expression;
52 long double float_value;
56 struct string_literal_t {
57 expression_t expression;
61 struct builtin_symbol_expression_t {
62 expression_t expression;
66 struct reference_expression_t {
67 expression_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_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_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_t expression;
140 binary_expression_type_t type;
145 struct select_expression_t {
146 expression_t expression;
147 expression_t *compound;
150 declaration_t *compound_entry;
153 struct array_access_expression_t {
154 expression_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_t expression;
163 expression_t *size_expression;
166 struct designator_t {
168 expression_t *array_access;
172 struct offsetof_expression_t {
173 expression_t expression;
175 designator_t *designator;
178 struct va_arg_expression_t {
179 expression_t expression;
184 struct conditional_expression_t {
185 expression_t expression;
186 expression_t *condition;
187 expression_t *true_expression;
188 expression_t *false_expression;
191 struct statement_expression_t {
192 expression_t expression;
193 statement_t *statement;
196 struct classify_type_expression_t {
197 expression_t expression;
198 expression_t *type_expression;
203 STORAGE_CLASS_TYPEDEF,
204 STORAGE_CLASS_EXTERN,
205 STORAGE_CLASS_STATIC,
207 STORAGE_CLASS_REGISTER,
208 STORAGE_CLASS_ENUM_ENTRY
224 } initializer_type_t;
226 struct initializer_base_t {
227 initializer_type_t type;
230 struct initializer_value_t {
231 initializer_base_t initializer;
235 struct initializer_list_t {
236 initializer_base_t initializer;
238 initializer_t *initializers[];
241 struct initializer_string_t {
242 initializer_base_t initializer;
246 union initializer_t {
247 initializer_type_t type;
248 initializer_base_t base;
249 initializer_value_t value;
250 initializer_list_t list;
251 initializer_string_t string;
254 struct declaration_t {
255 unsigned char namespc;
256 unsigned char storage_class;
257 unsigned int address_taken : 1;
258 unsigned int is_inline : 1;
261 source_position_t source_position;
264 statement_t *statement;
265 initializer_t *initializer;
266 expression_t *enum_value;
269 context_t *parent_context;
271 /** next declaration in a context */
273 /** next declaration with same symbol */
274 declaration_t *symbol_next;
276 unsigned char declaration_type; /* used in ast2firm module */
278 unsigned int value_number; /* used in ast2firm module */
279 ir_entity *entity; /* used in ast2firm module */
280 ir_node *block; /* used in ast2firm module */
281 tarval *enum_val; /* used in ast2firm module */
289 STATEMENT_DECLARATION,
292 STATEMENT_EXPRESSION,
297 STATEMENT_CASE_LABEL,
304 statement_type_t type;
306 source_position_t source_position;
309 struct return_statement_t {
310 statement_t statement;
311 expression_t *return_value;
314 struct compound_statement_t {
315 statement_t statement;
316 statement_t *statements;
320 struct declaration_statement_t {
321 statement_t statement;
322 declaration_t *declarations_begin;
323 declaration_t *declarations_end;
326 struct if_statement_t {
327 statement_t statement;
328 expression_t *condition;
329 statement_t *true_statement;
330 statement_t *false_statement;
333 struct switch_statement_t {
334 statement_t statement;
335 expression_t *expression;
339 struct goto_statement_t {
340 statement_t statement;
341 declaration_t *label;
344 struct case_label_statement_t {
345 statement_t statement;
346 expression_t *expression;
347 statement_t *label_statement;
350 struct label_statement_t {
351 statement_t statement;
352 declaration_t *label;
353 statement_t *label_statement;
356 struct expression_statement_t {
357 statement_t statement;
358 expression_t *expression;
361 struct while_statement_t {
362 statement_t statement;
363 expression_t *condition;
367 struct do_while_statement_t {
368 statement_t statement;
369 expression_t *condition;
373 struct for_statement_t {
374 statement_t statement;
375 expression_t *initialisation;
376 expression_t *condition;
382 struct translation_unit_t {
387 void *_allocate_ast(size_t size)
389 return obstack_alloc(&ast_obstack, size);
392 #define allocate_ast(size) _allocate_ast(size)