dump keepalive edges
[cparser] / ast_t.h
diff --git a/ast_t.h b/ast_t.h
index 415bbc6..6b922bc 100644 (file)
--- a/ast_t.h
+++ b/ast_t.h
@@ -1,9 +1,11 @@
 #ifndef AST_T_H
 #define AST_T_H
 
+#include <libfirm/firm_types.h>
+
 #include "ast.h"
 #include "symbol.h"
-#include "lexer_t.h"
+#include "token_t.h"
 #include "type.h"
 #include "adt/obst.h"
 
@@ -17,11 +19,23 @@ typedef enum {
        EXPR_CALL,
        EXPR_UNARY,
        EXPR_BINARY,
+       EXPR_CONDITIONAL,
        EXPR_SELECT,
        EXPR_ARRAY_ACCESS,
        EXPR_SIZEOF,
+
+       EXPR_FUNCTION,
+       EXPR_PRETTY_FUNCTION,
+       EXPR_BUILTIN_SYMBOL,
+       EXPR_OFFSETOF,
+       EXPR_VA_ARG,
+       EXPR_STATEMENT
 } expresion_type_t;
 
+struct context_t {
+       declaration_t   *declarations;
+};
+
 struct expression_t {
        expresion_type_t   type;
        type_t            *datatype;
@@ -30,7 +44,10 @@ struct expression_t {
 
 struct const_t {
        expression_t  expression;
-       int           value;
+       union {
+               int         int_value;
+               long double float_value;
+       } v;
 };
 
 struct string_literal_t {
@@ -38,15 +55,15 @@ struct string_literal_t {
        const char   *value;
 };
 
+struct builtin_symbol_expression_t {
+       expression_t  expression;
+       symbol_t     *symbol;
+};
+
 struct reference_expression_t {
-       expression_t                      expression;
-       symbol_t                         *symbol;
-       union {
-               variable_declaration_statement_t *variable;
-               method_t                         *method;
-               global_variable_t                *global_variable;
-               method_parameter_t               *method_parameter;
-       } r;
+       expression_t   expression;
+       symbol_t      *symbol;
+       declaration_t *declaration;
 };
 
 struct call_argument_t {
@@ -56,13 +73,14 @@ struct call_argument_t {
 
 struct call_expression_t {
        expression_t     expression;
-       expression_t    *method;
+       expression_t    *function;
        call_argument_t *arguments;
 };
 
 typedef enum {
        UNEXPR_INVALID = 0,
        UNEXPR_NEGATE,
+       UNEXPR_PLUS,
        UNEXPR_BITWISE_NEGATE,
        UNEXPR_NOT,
        UNEXPR_DEREFERENCE,
@@ -95,7 +113,7 @@ typedef enum {
        BINEXPR_GREATEREQUAL,
        BINEXPR_BITWISE_AND,
        BINEXPR_BITWISE_OR,
-       BINEXPR_BITWSIE_XOR,
+       BINEXPR_BITWISE_XOR,
        BINEXPR_LOGICAL_AND,
        BINEXPR_LOGICAL_OR,
        BINEXPR_SHIFTLEFT,
@@ -110,7 +128,8 @@ typedef enum {
        BINEXPR_SHIFTRIGHT_ASSIGN,
        BINEXPR_BITWISE_AND_ASSIGN,
        BINEXPR_BITWISE_XOR_ASSIGN,
-       BINEXPR_BITWISE_OR_ASSIGN
+       BINEXPR_BITWISE_OR_ASSIGN,
+       BINEXPR_COMMA
 } binary_expression_type_t;
 
 struct binary_expression_t {
@@ -121,11 +140,11 @@ struct binary_expression_t {
 };
 
 struct select_expression_t {
-       expression_t      expression;
-       expression_t     *compound;
-       symbol_t         *symbol;
+       expression_t   expression;
+       expression_t  *compound;
+       symbol_t      *symbol;
 
-       compound_entry_t *compound_entry;
+       declaration_t *compound_entry;
 };
 
 struct array_access_expression_t {
@@ -136,10 +155,26 @@ struct array_access_expression_t {
 
 struct sizeof_expression_t {
        expression_t  expression;
-       union {
-               type_t       *type;
-               expression_t *size_expression;
-       } v;
+       type_t       *type;
+       expression_t *size_expression;
+};
+
+struct designator_t {
+       symbol_t     *symbol;
+       expression_t *array_access;
+       designator_t *next;
+};
+
+struct offsetof_expression_t {
+       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 {
@@ -149,25 +184,86 @@ struct conditional_expression_t {
        expression_t *false_expression;
 };
 
-struct expression_list_element_t {
-       expression_t *expression;
-       expression_t *next;
+struct statement_expression_t {
+       expression_t  expression;
+       statement_t  *statement;
 };
 
-struct comma_expression_t {
-       expression_t               expression;
-       expression_list_element_t *expressions;
+typedef enum {
+       STORAGE_CLASS_NONE,
+       STORAGE_CLASS_TYPEDEF,
+       STORAGE_CLASS_EXTERN,
+       STORAGE_CLASS_STATIC,
+       STORAGE_CLASS_AUTO,
+       STORAGE_CLASS_REGISTER,
+       STORAGE_CLASS_ENUM_ENTRY
+} storage_class_t;
+
+typedef enum {
+       NAMESPACE_NORMAL,
+       NAMESPACE_STRUCT,
+       NAMESPACE_UNION,
+       NAMESPACE_ENUM
+} namespace_t;
+
+typedef enum {
+       INITIALIZER_VALUE,
+       INITIALIZER_LIST,
+} initializer_type_t;
+
+struct initializer_t {
+       initializer_type_t type;
+       designator_t      *designator;
+       union {
+               initializer_t *list;
+               expression_t  *value;
+       } v;
+       initializer_t *next;
+};
+
+struct declaration_t {
+       unsigned char       namespace;
+       unsigned char       storage_class;
+       unsigned int        address_taken : 1;
+       type_t             *type;
+       symbol_t           *symbol;
+       source_position_t   source_position;
+       union {
+               bool            is_defined;
+               statement_t    *statement;
+               initializer_t  *initializer;
+       } 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 */
+       } v;
 };
 
 typedef enum {
        STATEMENT_INVALID,
-       STATEMENT_BLOCK,
+       STATEMENT_COMPOUND,
        STATEMENT_RETURN,
-       STATEMENT_VARIABLE_DECLARATION,
+       STATEMENT_DECLARATION,
        STATEMENT_IF,
+       STATEMENT_SWITCH,
        STATEMENT_EXPRESSION,
+       STATEMENT_CONTINUE,
+       STATEMENT_BREAK,
        STATEMENT_GOTO,
-       STATEMENT_LABEL
+       STATEMENT_LABEL,
+       STATEMENT_CASE_LABEL,
+       STATEMENT_WHILE,
+       STATEMENT_DO_WHILE,
+       STATEMENT_FOR
 } statement_type_t;
 
 struct statement_t {
@@ -181,18 +277,16 @@ struct return_statement_t {
        expression_t *return_value;
 };
 
-struct block_statement_t {
+struct compound_statement_t {
        statement_t  statement;
-       statement_t *first_statement;
+       statement_t *statements;
+       context_t    context;
 };
 
-struct variable_declaration_statement_t {
-       statement_t  statement;
-       type_t      *type;
-       symbol_t    *symbol;
-
-       int          value_number; /**< filled in by semantic phase */
-       int          refs;
+struct declaration_statement_t {
+       statement_t    statement;
+       declaration_t *declarations_begin;
+       declaration_t *declarations_end;
 };
 
 struct if_statement_t {
@@ -202,12 +296,23 @@ struct if_statement_t {
        statement_t  *false_statement;
 };
 
+struct switch_statement_t {
+       statement_t   statement;
+       expression_t *expression;
+       statement_t  *body;
+};
+
 struct goto_statement_t {
        statement_t        statement;
        symbol_t          *label_symbol;
        label_statement_t *label;
 };
 
+struct case_label_statement_t {
+       statement_t   statement;
+       expression_t *expression;
+};
+
 struct label_statement_t {
        statement_t        statement;
        symbol_t          *symbol;
@@ -218,42 +323,29 @@ struct expression_statement_t {
        expression_t *expression;
 };
 
-enum namespace_entry_type_t {
-       NAMESPACE_ENTRY_INVALID,
-       NAMESPACE_ENTRY_METHOD,
-       NAMESPACE_ENTRY_VARIABLE,
-};
-
-struct namespace_entry_t {
-       namespace_entry_type_t  type;
-       namespace_entry_t      *next;
-       source_position_t       source_position;
-};
-
-struct method_parameter_t {
-       method_parameter_t *next;
-       symbol_t           *symbol;
-       type_t             *type;
-       int                 num;
+struct while_statement_t {
+       statement_t   statement;
+       expression_t *condition;
+       statement_t  *body;
 };
 
-struct method_t {
-       namespace_entry_t   namespace_entry;
-       symbol_t           *symbol;
-       method_type_t      *type;
-       method_parameter_t *parameters;
-
-       statement_t        *statement;
+struct do_while_statement_t {
+       statement_t   statement;
+       expression_t *condition;
+       statement_t  *body;
 };
 
-struct global_variable_t {
-       namespace_entry_t  namespace_entry;
-       symbol_t          *symbol;
-       type_t            *type;
+struct for_statement_t {
+       statement_t   statement;
+       expression_t  *initialisation;
+       expression_t  *condition;
+       expression_t  *step;
+       statement_t   *body;
+       context_t      context;
 };
 
-struct namespace_t {
-       namespace_entry_t *entries;
+struct translation_unit_t {
+       context_t context;
 };
 
 static inline