more work on local variable support
[cparser] / type_t.h
index 6e05d31..efc97b6 100644 (file)
--- a/type_t.h
+++ b/type_t.h
@@ -1,9 +1,14 @@
 #ifndef TYPE_T_H
 #define TYPE_T_H
 
+#include <stdbool.h>
+
+#include <libfirm/firm_types.h>
+
 #include "type.h"
 #include "symbol.h"
-#include "lexer_t.h"
+#include "token_t.h"
+#include "ast_t.h"
 #include "adt/obst.h"
 
 struct obstack *type_obst;
@@ -14,9 +19,12 @@ typedef enum {
        TYPE_COMPOUND_STRUCT,
        TYPE_COMPOUND_UNION,
        TYPE_ENUM,
+       TYPE_FUNCTION,
+       TYPE_POINTER,
+       TYPE_ARRAY,
+       TYPE_BUILTIN,
        TYPE_TYPEDEF,
-       TYPE_METHOD,
-       TYPE_POINTER
+       TYPE_TYPEOF
 } type_type_t;
 
 typedef enum {
@@ -49,8 +57,18 @@ typedef enum {
 #endif
 } atomic_type_type_t;
 
+typedef enum {
+       TYPE_QUALIFIER_CONST    = 1 << 0,
+       TYPE_QUALIFIER_RESTRICT = 1 << 1,
+       TYPE_QUALIFIER_VOLATILE = 1 << 2,
+       TYPE_QUALIFIER_INLINE   = 1 << 3,
+} type_qualifier_t;
+
 struct type_t {
-       type_type_t  type;
+       type_type_t       type;
+       type_qualifier_t  qualifiers;
+
+       ir_type          *firm_type;
 };
 
 struct atomic_type_t {
@@ -58,35 +76,65 @@ struct atomic_type_t {
        atomic_type_type_t  atype;
 };
 
+struct builtin_type_t {
+       type_t    type;
+       symbol_t *symbol;
+       type_t   *real_type;
+};
+
 struct pointer_type_t {
        type_t   type;
        type_t  *points_to;
 };
 
-struct method_parameter_type_t {
-       type_t                  *type;
-       method_parameter_type_t *next;
+struct array_type_t {
+       type_t        type;
+       type_t       *element_type;
+       bool          is_static;
+       bool          is_variable;
+       expression_t *size;
 };
 
-struct method_type_t {
-       type_t                   type;
-       type_t                  *result_type;
-       method_parameter_type_t *parameter_types;
-       const char              *abi_style;
+struct function_parameter_t {
+       type_t               *type;
+       function_parameter_t *next;
 };
 
-struct compound_entry_t {
-       type_t            *type;
-       symbol_t          *symbol;
-       compound_entry_t  *next;
-       source_position_t  source_position;
+struct function_type_t {
+       type_t               type;
+       type_t              *result_type;
+       function_parameter_t *parameters;
+       bool                 variadic;
+       bool                 unspecified_parameters;
 };
 
 struct compound_type_t {
-       type_t             type;
-       compound_entry_t  *entries;
-       symbol_t          *symbol;
-       source_position_t  source_position;
+       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