@@ -4445,15 +4445,22 @@ void smt2_convt::convert_member(const member_exprt &expr)
4445
4445
CHECK_RETURN_WITH_DIAGNOSTICS (
4446
4446
width != 0 , " failed to get union member width" );
4447
4447
4448
- unflatten (wheret::BEGIN, expr.type ());
4448
+ if (use_datatypes)
4449
+ {
4450
+ unflatten (wheret::BEGIN, expr.type ());
4449
4451
4450
- out << " ((_ extract "
4451
- << (width-1 )
4452
- << " 0) " ;
4453
- convert_expr (struct_op);
4454
- out << " )" ;
4452
+ out << " ((_ extract " << (width - 1 ) << " 0) " ;
4453
+ convert_expr (struct_op);
4454
+ out << " )" ;
4455
4455
4456
- unflatten (wheret::END, expr.type ());
4456
+ unflatten (wheret::END, expr.type ());
4457
+ }
4458
+ else
4459
+ {
4460
+ out << " ((_ extract " << (width - 1 ) << " 0) " ;
4461
+ convert_expr (struct_op);
4462
+ out << " )" ;
4463
+ }
4457
4464
}
4458
4465
else
4459
4466
UNEXPECTEDCASE (
@@ -4565,57 +4572,50 @@ void smt2_convt::unflatten(
4565
4572
}
4566
4573
else if (type.id () == ID_array)
4567
4574
{
4568
- if (use_datatypes)
4575
+ PRECONDITION (use_as_const);
4576
+
4577
+ if (where == wheret::BEGIN)
4578
+ out << " (let ((?ufop" << nesting << " " ;
4579
+ else
4569
4580
{
4570
- PRECONDITION (use_as_const) ;
4581
+ out << " )) " ;
4571
4582
4572
- if (where == wheret::BEGIN)
4573
- out << " (let ((?ufop" << nesting << " " ;
4574
- else
4575
- {
4576
- out << " )) " ;
4583
+ const array_typet &array_type = to_array_type (type);
4577
4584
4578
- const array_typet &array_type = to_array_type (type );
4585
+ std:: size_t subtype_width = boolbv_width (array_type. element_type () );
4579
4586
4580
- std::size_t subtype_width = boolbv_width (array_type.element_type ());
4587
+ DATA_INVARIANT (
4588
+ array_type.size ().is_constant (),
4589
+ " cannot unflatten arrays of non-constant size" );
4590
+ mp_integer size =
4591
+ numeric_cast_v<mp_integer>(to_constant_expr (array_type.size ()));
4581
4592
4582
- DATA_INVARIANT (
4583
- array_type.size ().is_constant (),
4584
- " cannot unflatten arrays of non-constant size" );
4585
- mp_integer size =
4586
- numeric_cast_v<mp_integer>(to_constant_expr (array_type.size ()));
4593
+ for (mp_integer i = 1 ; i < size; ++i)
4594
+ out << " (store " ;
4587
4595
4588
- for (mp_integer i = 1 ; i < size; ++i)
4589
- out << " (store " ;
4596
+ out << " ((as const " ;
4597
+ convert_type (array_type);
4598
+ out << " ) " ;
4599
+ // use element at index 0 as default value
4600
+ unflatten (wheret::BEGIN, array_type.element_type (), nesting + 1 );
4601
+ out << " ((_ extract " << subtype_width - 1 << " "
4602
+ << " 0) ?ufop" << nesting << " )" ;
4603
+ unflatten (wheret::END, array_type.element_type (), nesting + 1 );
4604
+ out << " ) " ;
4590
4605
4591
- out << " ((as const " ;
4592
- convert_type (array_type);
4593
- out << " ) " ;
4594
- // use element at index 0 as default value
4606
+ std::size_t offset = subtype_width;
4607
+ for (mp_integer i = 1 ; i < size; ++i, offset += subtype_width)
4608
+ {
4609
+ convert_expr (from_integer (i, array_type.index_type ()));
4610
+ out << ' ' ;
4595
4611
unflatten (wheret::BEGIN, array_type.element_type (), nesting + 1 );
4596
- out << " ((_ extract " << subtype_width - 1 << " "
4597
- << " 0 ) ?ufop" << nesting << " )" ;
4612
+ out << " ((_ extract " << offset + subtype_width - 1 << " " << offset
4613
+ << " ) ?ufop" << nesting << " )" ;
4598
4614
unflatten (wheret::END, array_type.element_type (), nesting + 1 );
4599
- out << " ) " ;
4600
-
4601
- std::size_t offset = subtype_width;
4602
- for (mp_integer i = 1 ; i < size; ++i, offset += subtype_width)
4603
- {
4604
- convert_expr (from_integer (i, array_type.index_type ()));
4605
- out << ' ' ;
4606
- unflatten (wheret::BEGIN, array_type.element_type (), nesting + 1 );
4607
- out << " ((_ extract " << offset + subtype_width - 1 << " " << offset
4608
- << " ) ?ufop" << nesting << " )" ;
4609
- unflatten (wheret::END, array_type.element_type (), nesting + 1 );
4610
- out << " )" ; // store
4611
- }
4612
-
4613
- out << " )" ; // let
4615
+ out << " )" ; // store
4614
4616
}
4615
- }
4616
- else
4617
- {
4618
- // nop, already a bv
4617
+
4618
+ out << " )" ; // let
4619
4619
}
4620
4620
}
4621
4621
else if (type.id () == ID_struct || type.id () == ID_struct_tag)
@@ -4767,19 +4767,22 @@ void smt2_convt::set_to(const exprt &expr, bool value)
4767
4767
{
4768
4768
out << " (define-fun " << smt2_identifier;
4769
4769
out << " () " ;
4770
+ convert_type (equal_expr.lhs ().type ());
4771
+ out << ' ' ;
4770
4772
if (
4771
4773
equal_expr.lhs ().type ().id () != ID_array ||
4772
4774
use_array_theory (prepared_rhs))
4773
4775
{
4774
- convert_type (equal_expr. lhs (). type () );
4776
+ convert_expr (prepared_rhs );
4775
4777
}
4776
4778
else
4777
4779
{
4778
- std::size_t width = boolbv_width (equal_expr.lhs ().type ());
4779
- out << " (_ BitVec " << width << " )" ;
4780
+ unflatten (wheret::BEGIN, equal_expr.lhs ().type ());
4781
+
4782
+ convert_expr (prepared_rhs);
4783
+
4784
+ unflatten (wheret::END, equal_expr.lhs ().type ());
4780
4785
}
4781
- out << ' ' ;
4782
- convert_expr (prepared_rhs);
4783
4786
out << ' )' << ' \n ' ;
4784
4787
}
4785
4788
0 commit comments