ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
type.h
Go to the documentation of this file.
1#ifndef CPROVER_TYPE_H
2#define CPROVER_TYPE_H
3
4#include <list>
5#include <util/irep/irep.h>
7
8class typet : public irept
9{
10public:
11 typet() = default;
12
13 explicit typet(const irep_idt &_id) : irept(_id)
14 {
15 }
16
17 const typet &subtype() const
18 {
19 return (typet &)find(f_subtype);
20 }
21
23 {
24 return (typet &)add(f_subtype);
25 }
26
27 typedef std::vector<typet> subtypest;
28
30 {
31 return (subtypest &)add(f_subtypes).get_sub();
32 }
33
34 const subtypest &subtypes() const
35 {
36 return (const subtypest &)find(f_subtypes).get_sub();
37 }
38
39 bool has_subtypes() const
40 {
41 return !find(f_subtypes).is_nil();
42 }
43
44 bool has_subtype() const
45 {
46 return !find(f_subtype).is_nil();
47 }
48
49 void move_to_subtypes(typet &type); // destroys expr
50
51 const locationt &location() const
52 {
53 return (const locationt &)find(f_location);
54 }
55
57 {
58 return (locationt &)add(f_location);
59 }
60
61 typet &add_type(const std::string &name)
62 {
63 return (typet &)add(name);
64 }
65
66 const typet &find_type(const std::string &name) const
67 {
68 return (const typet &)find(name);
69 }
70
72 {
74 }
75
76 void can_carry_provenance(bool yes)
77 {
79 }
80
92 static irep_idt t_symbol; // There're expressions of id "symbol" and types
93 // of id "symbol".
103
107
117 static irep_idt a_f;
118
119protected:
124};
125
126typedef std::list<typet> type_listt;
127
128#define forall_type_list(it, type) \
129 for (type_listt::const_iterator it = (type).begin(); it != (type).end(); it++)
130
131#define Forall_type_list(it, type) \
132 for (type_listt::iterator it = (type).begin(); it != (type).end(); it++)
133
134#define forall_subtypes(it, type) \
135 if ((type).has_subtypes()) \
136 for (typet::subtypest::const_iterator it = (type).subtypes().begin(); \
137 it != (type).subtypes().end(); \
138 it++)
139
140#define Forall_subtypes(it, type) \
141 if ((type).has_subtypes()) \
142 for (typet::subtypest::iterator it = (type).subtypes().begin(); \
143 it != (type).subtypes().end(); \
144 it++)
145
146/*
147
148pre-defined types:
149 universe // super type
150 type // another type
151 predicate // predicate expression (subtype and predicate)
152 uninterpreted // uninterpreted type with identifier
153 empty // void
154 bool // true or false
155 abstract // abstract super type
156 struct // with components: each component has name and type
157 // the ordering matters
158 rational
159 real
160 integer
161 complex
162 string
163 enum // with elements
164 // the ordering does not matter
165 tuple // with components: each component has type
166 // the ordering matters
167 mapping // domain -> range
168 bv // no interpretation
169 unsignedbv
170 signedbv // two's complement
171 floatbv // IEEE floating point format
172 code
173 pointer // for ANSI-C (subtype)
174 symbol // look in symbol table (identifier)
175 number // generic number super type
176
177*/
178
179bool is_number(const typet &type);
180// rational, real, integer, complex, unsignedbv, signedbv, floatbv
190bool is_array_like(const typet &type);
193bool is_decaying_array(const typet &type);
194
195#endif
Definition irep_idt.h:12
bool get_bool(const irep_idt &name) const
Definition irep.cpp:142
const irept & find(const irep_idt &name) const
Definition irep.cpp:167
irept(const irep_idt &_id)
Definition irep.cpp:31
void set(const irep_idt &name, const irep_idt &value)
Definition irep.h:141
subt & get_sub()
Definition irep.h:1242
typet & type()
Definition irep.h:153
irept & add(const irep_idt &name)
Definition irep.cpp:179
bool is_nil() const
Definition irep.h:46
const irep_idt & name() const
Definition irep.h:182
Definition location.h:7
Definition type.h:9
const typet & find_type(const std::string &name) const
Definition type.h:66
static irep_idt a_name
Definition type.h:109
static irep_idt t_bool
Definition type.h:90
static irep_idt a_integer_bits
Definition type.h:116
static irep_idt t_ptrmem
Definition type.h:106
static irep_idt t_intcap
Definition type.h:104
typet(const irep_idt &_id)
Definition type.h:13
static irep_idt a_identifier
Definition type.h:108
static irep_idt t_struct
Definition type.h:94
void move_to_subtypes(typet &type)
Definition type.cpp:3
static irep_idt t_reference
Definition type.h:100
static irep_idt t_vector
Definition type.h:102
static irep_idt t_union
Definition type.h:95
static irep_idt f_can_carry_provenance
Definition type.h:123
static irep_idt t_array
Definition type.h:98
const typet & subtype() const
Definition type.h:17
static irep_idt t_unsignedbv
Definition type.h:83
static irep_idt f_subtype
Definition type.h:120
std::vector< typet > subtypest
Definition type.h:27
bool has_subtypes() const
Definition type.h:39
static irep_idt f_subtypes
Definition type.h:121
static irep_idt t_symbol
Definition type.h:92
bool can_carry_provenance() const
Definition type.h:71
static irep_idt t_fixedbv
Definition type.h:89
subtypest & subtypes()
Definition type.h:29
typet & subtype()
Definition type.h:22
locationt & location()
Definition type.h:56
const subtypest & subtypes() const
Definition type.h:34
static irep_idt t_uintcap
Definition type.h:105
static irep_idt t_class
Definition type.h:96
bool has_subtype() const
Definition type.h:44
static irep_idt t_real
Definition type.h:85
static irep_idt a_arguments
Definition type.h:112
static irep_idt t_integer
Definition type.h:81
static irep_idt a_methods
Definition type.h:111
static irep_idt a_size
Definition type.h:114
static irep_idt t_complex
Definition type.h:87
static irep_idt a_width
Definition type.h:115
const locationt & location() const
Definition type.h:51
static irep_idt t_floatbv
Definition type.h:88
void can_carry_provenance(bool yes)
Definition type.h:76
static irep_idt t_signedbv
Definition type.h:82
typet & add_type(const std::string &name)
Definition type.h:61
static irep_idt a_return_type
Definition type.h:113
typet()=default
static irep_idt t_empty
Definition type.h:91
static irep_idt t_bv
Definition type.h:101
static irep_idt a_components
Definition type.h:110
static irep_idt t_natural
Definition type.h:86
static irep_idt t_code
Definition type.h:97
static irep_idt t_rational
Definition type.h:84
static irep_idt a_f
Definition type.h:117
static irep_idt t_pointer
Definition type.h:99
static irep_idt f_location
Definition type.h:122
constexpr bool is_number
Definition toml.hpp:2394
bool is_array_like(const typet &type)
Returns wether the type behaves similarly to an array.
Definition type.cpp:17
bool is_decaying_array(const typet &type)
Types that decay to a pointer in C11 6.3.2.1p3 – an array, but not a vector, which is a value.
Definition type.cpp:22
std::list< typet > type_listt
Definition type.h:126