#ifndef AST_T_H
#define AST_T_H
+#include <libfirm/firm_types.h>
+#include <assert.h>
+
#include "ast.h"
#include "symbol.h"
#include "token_t.h"
extern struct obstack ast_obstack;
typedef enum {
- EXPR_INVALID = 0,
+ EXPR_UNKNOWN = 0,
+ EXPR_INVALID,
EXPR_REFERENCE,
EXPR_CONST,
EXPR_STRING_LITERAL,
EXPR_CALL,
EXPR_UNARY,
EXPR_BINARY,
+ EXPR_CONDITIONAL,
EXPR_SELECT,
EXPR_ARRAY_ACCESS,
EXPR_SIZEOF,
+ EXPR_CLASSIFY_TYPE,
EXPR_FUNCTION,
EXPR_PRETTY_FUNCTION,
EXPR_BUILTIN_SYMBOL,
EXPR_OFFSETOF,
+ EXPR_VA_ARG,
EXPR_STATEMENT
} expresion_type_t;
struct context_t {
declaration_t *declarations;
- compound_type_t *structs;
- compound_type_t *unions;
- enum_type_t *enums;
};
struct expression_t {
struct const_t {
expression_t expression;
- int value;
+ union {
+ long long int_value;
+ long double float_value;
+ } v;
};
struct string_literal_t {
};
struct builtin_symbol_expression_t {
- symbol_t *symbol;
expression_t expression;
+ symbol_t *symbol;
};
struct reference_expression_t {
struct call_expression_t {
expression_t expression;
- expression_t *method;
+ expression_t *function;
call_argument_t *arguments;
};
expression_t expression;
expression_t *array_ref;
expression_t *index;
+ bool flipped; /* index/ref was written in a 5[a] way */
};
struct sizeof_expression_t {
expression_t *size_expression;
};
-struct member_designator_t {
- symbol_t *symbol;
- expression_t *array_access;
- member_designator_t *next;
+struct designator_t {
+ symbol_t *symbol;
+ expression_t *array_access;
+ designator_t *next;
};
struct offsetof_expression_t {
- expression_t expression;
- type_t *type;
- member_designator_t *member_designators;
+ expression_t expression;
+ type_t *type;
+ designator_t *designator;
+};
+
+struct va_arg_expression_t {
+ expression_t expression;
+ expression_t *arg;
+ type_t *type;
};
struct conditional_expression_t {
statement_t *statement;
};
+struct classify_type_expression_t {
+ expression_t expression;
+ expression_t *type_expression;
+};
+
typedef enum {
STORAGE_CLASS_NONE,
STORAGE_CLASS_TYPEDEF,
STORAGE_CLASS_ENUM_ENTRY
} storage_class_t;
+typedef enum {
+ NAMESPACE_NORMAL,
+ NAMESPACE_STRUCT,
+ NAMESPACE_UNION,
+ NAMESPACE_ENUM,
+ NAMESPACE_LABEL
+} namespace_t;
+
+typedef enum {
+ INITIALIZER_VALUE,
+ INITIALIZER_LIST,
+ INITIALIZER_STRING,
+ INITIALIZER_COUNT
+} initializer_type_t;
+
+struct initializer_base_t {
+ initializer_type_t type;
+};
+
+struct initializer_value_t {
+ initializer_base_t initializer;
+ expression_t *value;
+};
+
+struct initializer_list_t {
+ initializer_base_t initializer;
+ size_t len;
+ initializer_t *initializers[];
+};
+
+struct initializer_string_t {
+ initializer_base_t initializer;
+ const char *string;
+};
+
+union initializer_t {
+ initializer_type_t type;
+ initializer_base_t base;
+ initializer_value_t value;
+ initializer_list_t list;
+ initializer_string_t string;
+};
+
struct declaration_t {
- storage_class_t storage_class;
+ unsigned char namespc;
+ unsigned char storage_class;
+ unsigned int address_taken : 1;
+ unsigned int is_inline : 1;
type_t *type;
symbol_t *symbol;
- statement_t *statement;
- expression_t *initializer;
source_position_t source_position;
+ union {
+ bool is_defined;
+ statement_t *statement;
+ initializer_t *initializer;
+ expression_t *enum_value;
+ } init;
context_t context;
+ context_t *parent_context;
+ /** next declaration in a context */
declaration_t *next;
+ /** next declaration with same symbol */
+ declaration_t *symbol_next;
+
+ unsigned char declaration_type; /* used in ast2firm module */
+ union {
+ unsigned int value_number; /* used in ast2firm module */
+ ir_entity *entity; /* used in ast2firm module */
+ ir_node *block; /* used in ast2firm module */
+ tarval *enum_val; /* used in ast2firm module */
+ } v;
};
typedef enum {
statement_t statement;
declaration_t *declarations_begin;
declaration_t *declarations_end;
-
- int value_number; /**< filled in by semantic phase */
- int refs;
};
struct if_statement_t {
};
struct goto_statement_t {
- statement_t statement;
- symbol_t *label_symbol;
- label_statement_t *label;
+ statement_t statement;
+ declaration_t *label;
};
struct case_label_statement_t {
statement_t statement;
expression_t *expression;
+ statement_t *label_statement;
};
struct label_statement_t {
- statement_t statement;
- symbol_t *symbol;
+ statement_t statement;
+ declaration_t *label;
+ statement_t *label_statement;
};
struct expression_statement_t {