add license comments
[cparser] / type.h
1 /*
2  * This file is part of cparser.
3  * Copyright (C) 2007-2008 Matthias Braun <matze@braunis.de>
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18  * 02111-1307, USA.
19  */
20 #ifndef TYPE_H
21 #define TYPE_H
22
23 #include <stdio.h>
24 #include <stdbool.h>
25 #include "symbol.h"
26
27 typedef struct type_base_t           type_base_t;
28 typedef struct atomic_type_t         atomic_type_t;
29 typedef struct pointer_type_t        pointer_type_t;
30 typedef struct function_parameter_t  function_parameter_t;
31 typedef struct function_type_t       function_type_t;
32 typedef struct compound_type_t       compound_type_t;
33 typedef struct enum_type_t           enum_type_t;
34 typedef struct builtin_type_t        builtin_type_t;
35 typedef struct array_type_t          array_type_t;
36 typedef struct typedef_type_t        typedef_type_t;
37 typedef struct bitfield_type_t       bitfield_type_t;
38 typedef struct typeof_type_t         typeof_type_t;
39 typedef union  type_t                type_t;
40
41 void init_types(void);
42 void exit_types(void);
43
44 void print_type(const type_t *type);
45
46 /**
47  * prints a human readable form of @p type. prints an abstract typename
48  * if symbol is NULL
49  */
50 void print_type_ext(const type_t *type, const symbol_t *symbol,
51                     const scope_t *scope);
52
53 void print_type_qualifiers(unsigned qualifiers);
54
55 void print_enum_definition(const declaration_t *declaration);
56 void print_compound_definition(const declaration_t *declaration);
57
58 /**
59  * set output stream for the type printer
60  */
61 void type_set_output(FILE *out);
62
63 void inc_type_visited(void);
64
65 /**
66  * returns true if type contains integer numbers
67  */
68 bool is_type_integer(const type_t *type);
69
70 /**
71  * return true if type contains signed numbers
72  */
73 bool is_type_signed(const type_t *type);
74
75 /**
76  * returns true if type contains floating point numbers
77  */
78 bool is_type_float(const type_t *type);
79
80 /**
81  * returns true if the type is valid. A type is valid if it contains no
82  * unresolved references anymore and is not of TYPE_INVALID.
83  */
84 bool type_valid(const type_t *type);
85
86 /**
87  * returns true if the type is an arithmetic type (6.2.18)
88  */
89 bool is_type_arithmetic(const type_t *type);
90
91 /**
92  * returns true if the type is a scalar type (6.2.21)
93  */
94 bool is_type_scalar(const type_t *type);
95
96 bool is_type_incomplete(const type_t *type);
97
98 bool types_compatible(const type_t *type1, const type_t *type2);
99
100 bool pointers_compatible(const type_t *type1, const type_t *type2);
101
102 type_t *get_unqualified_type(type_t *type);
103 type_t *skip_typeref(type_t *type);
104
105 #endif