X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ast_t.h;h=6b922bcd7ef6f3446f89f4f1a1a955733dade8f0;hb=4d58018b7aec14df0a55975e959db73005fb648f;hp=fadd2702b19a507b23024e03c6230b6de8fe4b36;hpb=6734a093fb9d14f6a626293849de8a38b39b9457;p=cparser diff --git a/ast_t.h b/ast_t.h index fadd270..6b922bc 100644 --- a/ast_t.h +++ b/ast_t.h @@ -1,6 +1,8 @@ #ifndef AST_T_H #define AST_T_H +#include + #include "ast.h" #include "symbol.h" #include "token_t.h" @@ -26,14 +28,12 @@ typedef enum { 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 { @@ -44,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 { @@ -53,8 +56,8 @@ struct string_literal_t { }; struct builtin_symbol_expression_t { - symbol_t *symbol; expression_t expression; + symbol_t *symbol; }; struct reference_expression_t { @@ -70,7 +73,7 @@ struct call_argument_t { struct call_expression_t { expression_t expression; - expression_t *method; + expression_t *function; call_argument_t *arguments; }; @@ -156,16 +159,22 @@ 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 { @@ -190,16 +199,53 @@ typedef enum { 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 { - storage_class_t storage_class; + unsigned char namespace; + unsigned char storage_class; + unsigned int address_taken : 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; + } 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 { @@ -241,9 +287,6 @@ struct declaration_statement_t { 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 {