cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
boolbv_union.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module:
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
9
#include "
boolbv.h
"
10
11
bvt
boolbvt::convert_union
(
const
union_exprt
&expr)
12
{
13
std::size_t width=
boolbv_width
(expr.
type
());
14
15
const
bvt
&op_bv=
convert_bv
(expr.
op
());
16
17
INVARIANT
(
18
op_bv.size() <= width,
19
"operand bitvector width shall not be larger than the width indicated by "
20
"the union type"
);
21
22
bvt
bv;
23
bv.resize(width);
24
25
endianness_mapt
map_u =
endianness_map
(expr.
type
());
26
endianness_mapt
map_op =
endianness_map
(expr.
op
().
type
());
27
28
for
(std::size_t i = 0; i < op_bv.size(); i++)
29
bv[map_u.
map_bit
(i)] = op_bv[map_op.
map_bit
(i)];
30
31
// pad with nondets
32
for
(std::size_t i = op_bv.size(); i < bv.size(); i++)
33
bv[map_u.
map_bit
(i)] =
prop
.new_variable();
34
35
return
bv;
36
}
37
38
bvt
boolbvt::convert_empty_union
(
const
empty_union_exprt
&expr)
39
{
40
return
{};
41
}
boolbv.h
boolbvt::convert_bv
virtual const bvt & convert_bv(const exprt &expr, const std::optional< std::size_t > expected_width={})
Convert expression to vector of literalts, using an internal cache to speed up conversion if availabl...
Definition
boolbv.cpp:40
boolbvt::convert_empty_union
virtual bvt convert_empty_union(const empty_union_exprt &expr)
Definition
boolbv_union.cpp:38
boolbvt::convert_union
virtual bvt convert_union(const union_exprt &expr)
Definition
boolbv_union.cpp:11
boolbvt::endianness_map
virtual endianness_mapt endianness_map(const typet &type, bool little_endian) const
Definition
boolbv.h:112
boolbvt::boolbv_width
virtual std::size_t boolbv_width(const typet &type) const
Definition
boolbv.h:106
empty_union_exprt
Union constructor to support unions without any member (a GCC/Clang feature).
Definition
std_expr.h:1773
endianness_mapt
Maps a big-endian offset to a little-endian offset.
Definition
endianness_map.h:31
endianness_mapt::map_bit
size_t map_bit(size_t bit) const
Definition
endianness_map.h:47
exprt::type
typet & type()
Return the type of the expression.
Definition
expr.h:85
prop_conv_solvert::prop
propt & prop
Definition
prop_conv_solver.h:130
unary_exprt::op
const exprt & op() const
Definition
std_expr.h:384
union_exprt
Union constructor from single element.
Definition
std_expr.h:1714
bvt
std::vector< literalt > bvt
Definition
literal.h:201
INVARIANT
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
Definition
invariant.h:423
solvers
flattening
boolbv_union.cpp
Generated by
1.17.0