2 * This file is part of cparser.
3 * Copyright (C) 2007-2008 Matthias Braun <matze@braunis.de>
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.
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.
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
28 /* note that the constant values represent the rank of the types as defined
31 ATOMIC_TYPE_INVALID = 0,
43 ATOMIC_TYPE_ULONGLONG,
46 ATOMIC_TYPE_LONG_DOUBLE,
49 ATOMIC_TYPE_LAST = ATOMIC_TYPE_BOOL
53 ATOMIC_TYPE_FLAG_NONE = 0,
54 ATOMIC_TYPE_FLAG_SIGNED = 1 << 0,
55 ATOMIC_TYPE_FLAG_INTEGER = 1 << 1,
56 ATOMIC_TYPE_FLAG_FLOAT = 1 << 2,
57 ATOMIC_TYPE_FLAG_ARITHMETIC = 1 << 3,
58 ATOMIC_TYPE_FLAG_COMPLEX = 1 << 4,
61 typedef struct type_base_t type_base_t;
62 typedef struct atomic_type_t atomic_type_t;
63 typedef struct complex_type_t complex_type_t;
64 typedef struct imaginary_type_t imaginary_type_t;
65 typedef struct pointer_type_t pointer_type_t;
66 typedef struct function_parameter_t function_parameter_t;
67 typedef struct function_type_t function_type_t;
68 typedef struct compound_type_t compound_type_t;
69 typedef struct enum_type_t enum_type_t;
70 typedef struct builtin_type_t builtin_type_t;
71 typedef struct array_type_t array_type_t;
72 typedef struct typedef_type_t typedef_type_t;
73 typedef struct bitfield_type_t bitfield_type_t;
74 typedef struct typeof_type_t typeof_type_t;
75 typedef union type_t type_t;
77 void init_types(void);
78 void exit_types(void);
80 void print_type(const type_t *type);
83 * prints a human readable form of @p type. prints an abstract typename
86 void print_type_ext(const type_t *type, const symbol_t *symbol,
87 const scope_t *scope);
89 void print_type_qualifiers(unsigned qualifiers);
91 void print_enum_definition(const declaration_t *declaration);
92 void print_compound_definition(const declaration_t *declaration);
95 * set output stream for the type printer
97 void type_set_output(FILE *out);
99 void inc_type_visited(void);
102 * returns true if type contains integer numbers
104 bool is_type_integer(const type_t *type);
107 * return true if type contains signed numbers
109 bool is_type_signed(const type_t *type);
112 * returns true if type contains floating point numbers
114 bool is_type_float(const type_t *type);
117 * returns true if the type is valid. A type is valid if it contains no
118 * unresolved references anymore and is not of TYPE_INVALID.
120 bool type_valid(const type_t *type);
123 * returns true if the type is an arithmetic type (6.2.18)
125 bool is_type_arithmetic(const type_t *type);
128 * returns true if the type is a scalar type (6.2.21)
130 bool is_type_scalar(const type_t *type);
132 bool is_type_incomplete(const type_t *type);
134 bool types_compatible(const type_t *type1, const type_t *type2);
136 bool pointers_compatible(const type_t *type1, const type_t *type2);
138 type_t *get_unqualified_type(type_t *type);
139 type_t *skip_typeref(type_t *type);
142 * returns size of an atomic type kind in bytes
144 unsigned get_atomic_type_size(atomic_type_kind_t kind);
147 * returns alignment of an atomic type kind in bytes
149 unsigned get_atomic_type_alignment(atomic_type_kind_t kind);
152 * returns flags of an atomic type kind
154 unsigned get_atomic_type_flags(atomic_type_kind_t kind);
156 atomic_type_kind_t get_intptr_kind(void);
157 atomic_type_kind_t get_uintptr_kind(void);
160 * Find the atomic type kind representing a given size (signed).
162 atomic_type_kind_t find_signed_int_atomic_type_kind_for_size(unsigned size);
165 * Find the atomic type kind representing a given size (unsigned).
167 atomic_type_kind_t find_unsigned_int_atomic_type_kind_for_size(unsigned size);