Skip to content

Commit 498c2e3

Browse files
Declare an array_list_exprt class
1 parent ede560a commit 498c2e3

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/solvers/flattening/boolbv_get.cpp

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 21 additions & 0 deletions
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
*/

0 commit comments

Comments
 (0)