Skip to content

Commit 026c4ca

Browse files
Declare an array_list_exprt class
1 parent 50a2696 commit 026c4ca

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

src/solvers/flattening/boolbv_get.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ exprt boolbvt::bv_get_unbounded_array(const exprt &expr) const
375375

376376
if(size_mpint>100 || size.id()==ID_infinity)
377377
{
378-
result = exprt(ID_array_list, type);
378+
result = array_list_exprt(to_array_type(type));
379379
result.type().set(ID_size, integer2string(size_mpint));
380380

381381
result.operands().reserve(values.size()*2);

src/solvers/smt1/smt1_conv.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ exprt smt1_convt::ce_value(
219219
if(index_expr.is_nil())
220220
return nil_exprt();
221221

222-
exprt array_list(ID_array_list, type);
222+
array_list_exprt array_list(array_type);
223223
array_list.copy_to_operands(index_expr, value_expr);
224224

225225
return array_list;

src/util/std_expr.h

+21
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,27 @@ template<> inline bool can_cast_expr<array_exprt>(const exprt &base)
16491649
return base.id()==ID_array;
16501650
}
16511651

1652+
/// Array constructor from a list of index-element pairs
1653+
/// Operands are index/value pairs, alternating.
1654+
class array_list_exprt : public exprt
1655+
{
1656+
public:
1657+
explicit array_list_exprt(const array_typet &_type)
1658+
: exprt(ID_array_list, _type)
1659+
{
1660+
}
1661+
};
1662+
1663+
template <>
1664+
inline bool can_cast_expr<array_list_exprt>(const exprt &base)
1665+
{
1666+
return base.id() == ID_array_list;
1667+
}
1668+
1669+
inline void validate_expr(const array_list_exprt &value)
1670+
{
1671+
PRECONDITION(value.operands().size() % 2 == 0);
1672+
}
16521673

16531674
/*! \brief vector constructor from list of elements
16541675
*/

unit/solvers/refinement/string_refinement/substitute_array_list.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ SCENARIO("substitute_array_list",
2020
{
2121
const typet char_type=unsignedbv_typet(16);
2222
const typet int_type=signedbv_typet(32);
23-
exprt arr(ID_array_list);
23+
const array_typet array_type(char_type, infinity_exprt(int_type));
24+
array_list_exprt arr(array_type);
2425
const exprt index0=from_integer(0, int_type);
2526
const exprt charx=from_integer('x', char_type);
2627
const exprt index1=from_integer(1, int_type);

0 commit comments

Comments
 (0)