more work on firm backend
[cparser] / type_t.h
index 5fc4a3e..eb072e6 100644 (file)
--- a/type_t.h
+++ b/type_t.h
@@ -1,6 +1,10 @@
 #ifndef TYPE_T_H
 #define TYPE_T_H
 
+#include <stdbool.h>
+
+#include <libfirm/firm_types.h>
+
 #include "type.h"
 #include "symbol.h"
 #include "token_t.h"
@@ -17,7 +21,10 @@ typedef enum {
        TYPE_ENUM,
        TYPE_METHOD,
        TYPE_POINTER,
-       TYPE_BUILTIN
+       TYPE_ARRAY,
+       TYPE_BUILTIN,
+       TYPE_TYPEDEF,
+       TYPE_TYPEOF
 } type_type_t;
 
 typedef enum {
@@ -58,8 +65,10 @@ typedef enum {
 } type_qualifier_t;
 
 struct type_t {
-       type_type_t  type;
-       unsigned     qualifiers;
+       type_type_t       type;
+       type_qualifier_t  qualifiers;
+
+       ir_type          *firm_type;
 };
 
 struct atomic_type_t {
@@ -70,20 +79,7 @@ struct atomic_type_t {
 struct builtin_type_t {
        type_t    type;
        symbol_t *symbol;
-};
-
-struct enum_entry_t {
-       symbol_t     *symbol;
-       expression_t *value;
-       enum_entry_t *next;
-};
-
-struct enum_type_t {
-       type_t             type;
-       symbol_t          *symbol;
-       enum_entry_t      *entries;
-       source_position_t  source_position;
-       enum_type_t       *next;
+       type_t   *real_type;
 };
 
 struct pointer_type_t {
@@ -91,6 +87,14 @@ struct pointer_type_t {
        type_t  *points_to;
 };
 
+struct array_type_t {
+       type_t        type;
+       type_t       *element_type;
+       bool          is_static;
+       bool          is_variable;
+       expression_t *size;
+};
+
 struct method_parameter_t {
        type_t             *type;
        method_parameter_t *next;
@@ -100,17 +104,37 @@ struct method_type_t {
        type_t              type;
        type_t             *result_type;
        method_parameter_t *parameters;
-       int                 variadic;
-       int                 unspecified_parameters;
+       bool                variadic;
+       bool                unspecified_parameters;
 };
 
 struct compound_type_t {
-       type_t             type;
-       symbol_t          *symbol;
-       context_t          context;
-       source_position_t  source_position;
-       int                defined;
-       compound_type_t   *next;
+       type_t         type;
+       /** the declaration of the compound type, it's context field
+        * contains the compound entries. */
+       declaration_t *declaration;
 };
 
+struct enum_type_t {
+       type_t         type;
+       /** the declaration of the enum type. You can find the enum entries by
+        * walking the declaration->context_next list until you don't find
+        * STORAGE_CLASS_ENUM_ENTRY declarations anymore */
+       declaration_t *declaration;
+};
+
+struct typedef_type_t {
+       type_t         type;
+       declaration_t *declaration;
+};
+
+struct typeof_type_t {
+       type_t        type;
+       expression_t *expression;
+       type_t       *typeof_type;
+};
+
+type_t *make_atomic_type(atomic_type_type_t type, type_qualifier_t qualifiers);
+type_t *make_pointer_type(type_t *points_to, type_qualifier_t qualifiers);
+
 #endif