@@ -49,6 +49,19 @@ static smt_termt convert_multiary_operator_to_terms(
49
49
factory);
50
50
}
51
51
52
+ // / \brief Ensures that all operands of the argument expression have related
53
+ // / types.
54
+ // / \param expr: The expression of which the operands we evaluate for type
55
+ // / equality.
56
+ template <typename target_typet>
57
+ static bool operands_are_of_type (const exprt &expr)
58
+ {
59
+ return std::all_of (
60
+ expr.operands ().cbegin (), expr.operands ().cend (), [](const exprt &operand) {
61
+ return can_cast_type<target_typet>(operand.type ());
62
+ });
63
+ }
64
+
52
65
static smt_sortt convert_type_to_smt_sort (const bool_typet &type)
53
66
{
54
67
return smt_bool_sortt{};
@@ -154,12 +167,7 @@ static smt_termt convert_expr_to_smt(const concatenation_exprt &concatenation)
154
167
155
168
static smt_termt convert_expr_to_smt (const bitand_exprt &bitwise_and_expr)
156
169
{
157
- if (std::all_of (
158
- bitwise_and_expr.operands ().cbegin (),
159
- bitwise_and_expr.operands ().cend (),
160
- [](exprt operand) {
161
- return can_cast_type<integer_bitvector_typet>(operand.type ());
162
- }))
170
+ if (operands_are_of_type<integer_bitvector_typet>(bitwise_and_expr))
163
171
{
164
172
return convert_multiary_operator_to_terms (
165
173
bitwise_and_expr, smt_bit_vector_theoryt::make_and);
@@ -174,12 +182,7 @@ static smt_termt convert_expr_to_smt(const bitand_exprt &bitwise_and_expr)
174
182
175
183
static smt_termt convert_expr_to_smt (const bitor_exprt &bitwise_or_expr)
176
184
{
177
- if (std::all_of (
178
- bitwise_or_expr.operands ().cbegin (),
179
- bitwise_or_expr.operands ().cend (),
180
- [](exprt operand) {
181
- return can_cast_type<integer_bitvector_typet>(operand.type ());
182
- }))
185
+ if (operands_are_of_type<integer_bitvector_typet>(bitwise_or_expr))
183
186
{
184
187
return convert_multiary_operator_to_terms (
185
188
bitwise_or_expr, smt_bit_vector_theoryt::make_or);
@@ -194,12 +197,7 @@ static smt_termt convert_expr_to_smt(const bitor_exprt &bitwise_or_expr)
194
197
195
198
static smt_termt convert_expr_to_smt (const bitxor_exprt &bitwise_xor)
196
199
{
197
- if (std::all_of (
198
- bitwise_xor.operands ().cbegin (),
199
- bitwise_xor.operands ().cend (),
200
- [](exprt operand) {
201
- return can_cast_type<integer_bitvector_typet>(operand.type ());
202
- }))
200
+ if (operands_are_of_type<integer_bitvector_typet>(bitwise_xor))
203
201
{
204
202
return convert_multiary_operator_to_terms (
205
203
bitwise_xor, smt_bit_vector_theoryt::make_xor);
0 commit comments