cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
boolbv_array.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
#include <
util/invariant.h
>
12
16
bvt
boolbvt::convert_array
(
const
exprt
&expr)
17
{
18
const
std::size_t width =
boolbv_width
(expr.
type
());
19
const
exprt::operandst
&operands = expr.
operands
();
20
21
if
(operands.empty() && width == 0)
22
return
bvt
();
23
24
if
(expr.
type
().
id
()==ID_array)
25
{
26
DATA_INVARIANT
(
27
expr.
has_operands
(),
28
"the bit width being nonzero implies that the array has a nonzero size "
29
"in which case the array shall have operands"
);
30
const
std::size_t op_width = width / operands.size();
31
32
bvt
bv;
33
bv.reserve(width);
34
35
for
(
const
auto
&op : operands)
36
{
37
const
bvt
&tmp =
convert_bv
(op, op_width);
38
39
bv.insert(bv.end(), tmp.begin(), tmp.end());
40
}
41
42
return
bv;
43
}
44
45
return
conversion_failed
(expr);
46
}
boolbv.h
boolbvt::convert_array
virtual bvt convert_array(const exprt &expr)
Flatten array.
Definition
boolbv_array.cpp:16
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::conversion_failed
bvt conversion_failed(const exprt &expr)
Print that the expression of x has failed conversion, then return a vector of x's width.
Definition
boolbv.cpp:95
boolbvt::boolbv_width
virtual std::size_t boolbv_width(const typet &type) const
Definition
boolbv.h:106
exprt
Base class for all expressions.
Definition
expr.h:57
exprt::operandst
std::vector< exprt > operandst
Definition
expr.h:59
exprt::has_operands
bool has_operands() const
Return true if there is at least one operand.
Definition
expr.h:92
exprt::type
typet & type()
Return the type of the expression.
Definition
expr.h:85
exprt::operands
operandst & operands()
Definition
expr.h:95
irept::id
const irep_idt & id() const
Definition
irep.h:388
bvt
std::vector< literalt > bvt
Definition
literal.h:201
invariant.h
DATA_INVARIANT
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
Definition
invariant.h:534
solvers
flattening
boolbv_array.cpp
Generated by
1.17.0