cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
smt_sorts.cpp
Go to the documentation of this file.
1
// Author: Diffblue Ltd.
2
3
#include "
smt_sorts.h
"
4
5
#include <
util/invariant.h
>
6
7
// Define the irep_idts for sorts.
8
#define SORT_ID(the_id) \
9
const irep_idt ID_smt_##the_id##_sort{"smt_" #the_id "_sort"};
10
#include "smt_sorts.def"
11
12
#undef SORT_ID
13
14
#define SORT_ID(the_id) \
15
template <> \
16
const smt_##the_id##_sortt *smt_sortt::cast<smt_##the_id##_sortt>() const & \
17
{ \
18
return id() == ID_smt_##the_id##_sort \
19
? static_cast<const smt_##the_id##_sortt *>(this) \
20
: nullptr; \
21
}
22
#include "smt_sorts.def"
// NOLINT(build/include)
23
#undef SORT_ID
24
25
#define SORT_ID(the_id) \
26
template <> \
27
std::optional<smt_##the_id##_sortt> smt_sortt::cast<smt_##the_id##_sortt>() \
28
&& \
29
{ \
30
if(id() == ID_smt_##the_id##_sort) \
31
return {std::move(*static_cast<const smt_##the_id##_sortt *>(this))}; \
32
else \
33
return {}; \
34
}
35
#include "smt_sorts.def"
// NOLINT(build/include)
36
#undef SORT_ID
37
38
bool
smt_sortt::operator==
(
const
smt_sortt
&other)
const
39
{
40
return
irept::operator==
(other);
41
}
42
43
bool
smt_sortt::operator!=
(
const
smt_sortt
&other)
const
44
{
45
return
!(*
this
== other);
46
}
47
48
smt_bool_sortt::smt_bool_sortt
() :
smt_sortt
{ID_smt_bool_sort}
49
{
50
}
51
52
smt_bit_vector_sortt::smt_bit_vector_sortt
(
const
std::size_t
bit_width
)
53
:
smt_sortt
{ID_smt_bit_vector_sort}
54
{
55
INVARIANT
(
56
bit_width
> 0,
57
"The definition of SMT2 bit vector theory requires the number of "
58
"bits to be greater than 0."
);
59
set_size_t
(ID_width,
bit_width
);
60
}
61
62
std::size_t
smt_bit_vector_sortt::bit_width
()
const
63
{
64
return
get_size_t
(ID_width);
65
}
66
67
smt_array_sortt::smt_array_sortt
(
68
const
smt_sortt
&
index_sort
,
69
const
smt_sortt
&
element_sort
)
70
:
smt_sortt
{ID_smt_array_sort}
71
{
72
add
(ID_index,
index_sort
);
73
add
(ID_value,
element_sort
);
74
}
75
76
const
smt_sortt
&
smt_array_sortt::index_sort
()
const
77
{
78
return
static_cast<
const
smt_sortt
&
>
(
find
(ID_index));
79
}
80
81
const
smt_sortt
&
smt_array_sortt::element_sort
()
const
82
{
83
return
static_cast<
const
smt_sortt
&
>
(
find
(ID_value));
84
}
85
86
template
<
typename
visitort>
87
void
accept(
const
smt_sortt
&sort,
const
irep_idt
&
id
, visitort &&visitor)
88
{
89
#define SORT_ID(the_id) \
90
if(id == ID_smt_##the_id##_sort) \
91
return visitor.visit(static_cast<const smt_##the_id##_sortt &>(sort));
92
#include "smt_sorts.def"
93
#undef SORT_ID
94
UNREACHABLE
;
95
}
96
97
void
smt_sortt::accept
(
smt_sort_const_downcast_visitort
&visitor)
const
98
{
99
::accept
(*
this
,
id
(), visitor);
100
}
101
102
void
smt_sortt::accept
(
smt_sort_const_downcast_visitort
&&visitor)
const
103
{
104
::accept
(*
this
,
id
(), std::move(visitor));
105
}
irept::operator==
bool operator==(const irept &other) const
Definition
irep.cpp:133
irept::get_size_t
std::size_t get_size_t(const irep_idt &name) const
Definition
irep.cpp:67
irept::find
const irept & find(const irep_idt &name) const
Definition
irep.cpp:93
irept::set_size_t
void set_size_t(const irep_idt &name, const std::size_t value)
Definition
irep.cpp:82
irept::add
irept & add(const irep_idt &name)
Definition
irep.cpp:103
smt_array_sortt::element_sort
const smt_sortt & element_sort() const
Definition
smt_sorts.cpp:81
smt_array_sortt::index_sort
const smt_sortt & index_sort() const
Definition
smt_sorts.cpp:76
smt_array_sortt::smt_array_sortt
smt_array_sortt(const smt_sortt &index_sort, const smt_sortt &element_sort)
Definition
smt_sorts.cpp:67
smt_bit_vector_sortt::bit_width
std::size_t bit_width() const
Definition
smt_sorts.cpp:62
smt_bit_vector_sortt::smt_bit_vector_sortt
smt_bit_vector_sortt(std::size_t bit_width)
Definition
smt_sorts.cpp:52
smt_bool_sortt::smt_bool_sortt
smt_bool_sortt()
Definition
smt_sorts.cpp:48
smt_sort_const_downcast_visitort
Definition
smt_sorts.h:101
smt_sortt
Definition
smt_sorts.h:18
smt_sortt::operator==
bool operator==(const smt_sortt &) const
Definition
smt_sorts.cpp:38
smt_sortt::operator!=
bool operator!=(const smt_sortt &) const
Definition
smt_sorts.cpp:43
smt_sortt::smt_sortt
smt_sortt()=delete
smt_sortt::accept
void accept(smt_sort_const_downcast_visitort &) const
Definition
smt_sorts.cpp:97
smt_sorts.h
Data structure for smt sorts.
invariant.h
UNREACHABLE
#define UNREACHABLE
This should be used to mark dead code.
Definition
invariant.h:525
INVARIANT
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
Definition
invariant.h:423
irep_idt
dstringt irep_idt
Definition
verification_result.h:16
solvers
smt2_incremental
ast
smt_sorts.cpp
Generated by
1.17.0