@@ -4400,50 +4400,63 @@ void smt2_convt::convert_with(const with_exprt &expr)
4400
4400
}
4401
4401
else
4402
4402
{
4403
+ auto convert_operand = [this ](const exprt &op)
4404
+ {
4405
+ // may need to flatten array-theory arrays in there
4406
+ if (op.type ().id () == ID_array && use_array_theory (op))
4407
+ flatten_array (op);
4408
+ else if (op.type ().id () == ID_bool)
4409
+ flatten2bv (op);
4410
+ else
4411
+ convert_expr (op);
4412
+ };
4413
+
4403
4414
std::size_t struct_width=boolbv_width (struct_type);
4404
4415
4405
4416
// figure out the offset and width of the member
4406
4417
const boolbv_widtht::membert &m =
4407
4418
boolbv_width.get_member (struct_type, component_name);
4408
4419
4409
- out << " (let ((?withop " ;
4410
- convert_expr (expr.old ());
4411
- out << " )) " ;
4412
-
4413
4420
if (m.width ==struct_width)
4414
4421
{
4415
- // the struct is the same as the member, no concat needed,
4416
- // ?withop won't be used
4417
- convert_expr (value);
4418
- }
4419
- else if (m.offset ==0 )
4420
- {
4421
- // the member is at the beginning
4422
- out << " (concat "
4423
- << " ((_ extract " << (struct_width-1 ) << " "
4424
- << m.width << " ) ?withop) " ;
4425
- convert_expr (value);
4426
- out << " )" ; // concat
4427
- }
4428
- else if (m.offset +m.width ==struct_width)
4429
- {
4430
- // the member is at the end
4431
- out << " (concat " ;
4432
- convert_expr (value);
4433
- out << " ((_ extract " << (m.offset - 1 ) << " 0) ?withop))" ;
4422
+ // the struct is the same as the member, no concat needed
4423
+ convert_operand (value);
4434
4424
}
4435
4425
else
4436
4426
{
4437
- // most general case, need two concat-s
4438
- out << " (concat (concat "
4439
- << " ((_ extract " << (struct_width-1 ) << " "
4440
- << (m.offset +m.width ) << " ) ?withop) " ;
4441
- convert_expr (value);
4442
- out << " ) ((_ extract " << (m.offset -1 ) << " 0) ?withop)" ;
4443
- out << " )" ; // concat
4444
- }
4427
+ out << " (let ((?withop " ;
4428
+ convert_operand (expr.old ());
4429
+ out << " )) " ;
4430
+
4431
+ if (m.offset == 0 )
4432
+ {
4433
+ // the member is at the beginning
4434
+ out << " (concat "
4435
+ << " ((_ extract " << (struct_width - 1 ) << " " << m.width
4436
+ << " ) ?withop) " ;
4437
+ convert_operand (value);
4438
+ out << " )" ; // concat
4439
+ }
4440
+ else if (m.offset + m.width == struct_width)
4441
+ {
4442
+ // the member is at the end
4443
+ out << " (concat " ;
4444
+ convert_operand (value);
4445
+ out << " ((_ extract " << (m.offset - 1 ) << " 0) ?withop))" ;
4446
+ }
4447
+ else
4448
+ {
4449
+ // most general case, need two concat-s
4450
+ out << " (concat (concat "
4451
+ << " ((_ extract " << (struct_width - 1 ) << " "
4452
+ << (m.offset + m.width ) << " ) ?withop) " ;
4453
+ convert_operand (value);
4454
+ out << " ) ((_ extract " << (m.offset - 1 ) << " 0) ?withop)" ;
4455
+ out << " )" ; // concat
4456
+ }
4445
4457
4446
- out << " )" ; // let ?withop
4458
+ out << " )" ; // let ?withop
4459
+ }
4447
4460
}
4448
4461
}
4449
4462
else if (expr_type.id () == ID_union || expr_type.id () == ID_union_tag)
0 commit comments