started working on bitfields
[cparser] / type.h
1 #ifndef TYPE_H
2 #define TYPE_H
3
4 #include <stdio.h>
5 #include <stdbool.h>
6 #include "symbol.h"
7
8 typedef struct type_base_t           type_base_t;
9 typedef struct atomic_type_t         atomic_type_t;
10 typedef struct pointer_type_t        pointer_type_t;
11 typedef struct function_parameter_t  function_parameter_t;
12 typedef struct function_type_t       function_type_t;
13 typedef struct compound_type_t       compound_type_t;
14 typedef struct enum_type_t           enum_type_t;
15 typedef struct builtin_type_t        builtin_type_t;
16 typedef struct array_type_t          array_type_t;
17 typedef struct typedef_type_t        typedef_type_t;
18 typedef struct bitfield_type_t       bitfield_type_t;
19 typedef struct typeof_type_t         typeof_type_t;
20 typedef union  type_t                type_t;
21
22 void init_types(void);
23 void exit_types(void);
24
25 void print_type(const type_t *type);
26
27 /**
28  * prints a human readable form of @p type. prints an abstract typename
29  * if symbol is NULL
30  */
31 void print_type_ext(const type_t *type, const symbol_t *symbol,
32                     const context_t *context);
33
34 void print_type_qualifiers(unsigned qualifiers);
35
36 void print_enum_definition(const declaration_t *declaration);
37 void print_compound_definition(const declaration_t *declaration);
38
39 /**
40  * set output stream for the type printer
41  */
42 void type_set_output(FILE *out);
43
44 void inc_type_visited(void);
45
46 /**
47  * returns true if type contains integer numbers
48  */
49 bool is_type_integer(const type_t *type);
50
51 /**
52  * return true if type contains signed numbers
53  */
54 bool is_type_signed(const type_t *type);
55
56 /**
57  * returns true if type contains floating point numbers
58  */
59 bool is_type_floating(const type_t *type);
60
61 /**
62  * returns true if the type is valid. A type is valid if it contains no
63  * unresolved references anymore and is not of TYPE_INVALID.
64  */
65 bool type_valid(const type_t *type);
66
67 /**
68  * returns true if the type is an arithmetic type (6.2.18)
69  */
70 bool is_type_arithmetic(const type_t *type);
71
72 /**
73  * returns true if the type is a scalar type (6.2.21)
74  */
75 bool is_type_scalar(const type_t *type);
76
77 bool is_type_incomplete(const type_t *type);
78
79 bool types_compatible(const type_t *type1, const type_t *type2);
80
81 bool pointers_compatible(const type_t *type1, const type_t *type2);
82
83 type_t *get_unqualified_type(type_t *type);
84 type_t *skip_typeref(type_t *type);
85
86 #endif