@@ -4418,50 +4418,62 @@ void smt2_convt::convert_with(const with_exprt &expr)
4418
4418
}
4419
4419
else
4420
4420
{
4421
+ auto convert_operand = [this ](const exprt &op) {
4422
+ // may need to flatten array-theory arrays in there
4423
+ if (op.type ().id () == ID_array && use_array_theory (op))
4424
+ flatten_array (op);
4425
+ else if (op.type ().id () == ID_bool)
4426
+ flatten2bv (op);
4427
+ else
4428
+ convert_expr (op);
4429
+ };
4430
+
4421
4431
std::size_t struct_width=boolbv_width (struct_type);
4422
4432
4423
4433
// figure out the offset and width of the member
4424
4434
const boolbv_widtht::membert &m =
4425
4435
boolbv_width.get_member (struct_type, component_name);
4426
4436
4427
- out << " (let ((?withop " ;
4428
- convert_expr (expr.old ());
4429
- out << " )) " ;
4430
-
4431
4437
if (m.width ==struct_width)
4432
4438
{
4433
- // the struct is the same as the member, no concat needed,
4434
- // ?withop won't be used
4435
- convert_expr (value);
4436
- }
4437
- else if (m.offset ==0 )
4438
- {
4439
- // the member is at the beginning
4440
- out << " (concat "
4441
- << " ((_ extract " << (struct_width-1 ) << " "
4442
- << m.width << " ) ?withop) " ;
4443
- convert_expr (value);
4444
- out << " )" ; // concat
4445
- }
4446
- else if (m.offset +m.width ==struct_width)
4447
- {
4448
- // the member is at the end
4449
- out << " (concat " ;
4450
- convert_expr (value);
4451
- out << " ((_ extract " << (m.offset - 1 ) << " 0) ?withop))" ;
4439
+ // the struct is the same as the member, no concat needed
4440
+ convert_operand (value);
4452
4441
}
4453
4442
else
4454
4443
{
4455
- // most general case, need two concat-s
4456
- out << " (concat (concat "
4457
- << " ((_ extract " << (struct_width-1 ) << " "
4458
- << (m.offset +m.width ) << " ) ?withop) " ;
4459
- convert_expr (value);
4460
- out << " ) ((_ extract " << (m.offset -1 ) << " 0) ?withop)" ;
4461
- out << " )" ; // concat
4462
- }
4444
+ out << " (let ((?withop " ;
4445
+ convert_operand (expr.old ());
4446
+ out << " )) " ;
4447
+
4448
+ if (m.offset ==0 )
4449
+ {
4450
+ // the member is at the beginning
4451
+ out << " (concat "
4452
+ << " ((_ extract " << (struct_width-1 ) << " "
4453
+ << m.width << " ) ?withop) " ;
4454
+ convert_operand (value);
4455
+ out << " )" ; // concat
4456
+ }
4457
+ else if (m.offset +m.width ==struct_width)
4458
+ {
4459
+ // the member is at the end
4460
+ out << " (concat " ;
4461
+ convert_operand (value);
4462
+ out << " ((_ extract " << (m.offset - 1 ) << " 0) ?withop))" ;
4463
+ }
4464
+ else
4465
+ {
4466
+ // most general case, need two concat-s
4467
+ out << " (concat (concat "
4468
+ << " ((_ extract " << (struct_width-1 ) << " "
4469
+ << (m.offset +m.width ) << " ) ?withop) " ;
4470
+ convert_operand (value);
4471
+ out << " ) ((_ extract " << (m.offset -1 ) << " 0) ?withop)" ;
4472
+ out << " )" ; // concat
4473
+ }
4463
4474
4464
- out << " )" ; // let ?withop
4475
+ out << " )" ; // let ?withop
4476
+ }
4465
4477
}
4466
4478
}
4467
4479
else if (expr_type.id () == ID_union || expr_type.id () == ID_union_tag)
0 commit comments