@@ -652,34 +652,35 @@ static smt_termt convert_expr_to_smt(const index_exprt &index)
652
652
" Generation of SMT formula for index expression: " + index .pretty ());
653
653
}
654
654
655
- static smt_termt convert_expr_to_smt (const shift_exprt &shift)
655
+ template <typename factoryt, typename shiftt>
656
+ static smt_termt
657
+ convert_to_smt_shift (const factoryt &factory, const shiftt &shift)
656
658
{
657
- // TODO: Dispatch into different types of shifting
658
- const auto &first_operand = shift.op0 ();
659
- const auto &second_operand = shift.op1 ();
659
+ const smt_termt first_operand = convert_expr_to_smt (shift.op0 ());
660
+ const smt_termt second_operand = convert_expr_to_smt (shift.op1 ());
661
+ return factory (first_operand, second_operand);
662
+ }
660
663
664
+ static smt_termt convert_expr_to_smt (const shift_exprt &shift)
665
+ {
666
+ // TODO: Dispatch for rotation expressions. A `shift_exprt` can be a rotation.
661
667
if (const auto left_shift = expr_try_dynamic_cast<shl_exprt>(shift))
662
668
{
663
- return smt_bit_vector_theoryt::shift_left (
664
- convert_expr_to_smt (first_operand), convert_expr_to_smt (second_operand) );
669
+ return convert_to_smt_shift (
670
+ smt_bit_vector_theoryt::shift_left, *left_shift );
665
671
}
666
- else if (
667
- const auto right_logical_shift = expr_try_dynamic_cast<lshr_exprt>(shift))
672
+ if (const auto right_logical_shift = expr_try_dynamic_cast<lshr_exprt>(shift))
668
673
{
669
- return smt_bit_vector_theoryt::logical_shift_right (
670
- convert_expr_to_smt (first_operand), convert_expr_to_smt (second_operand) );
674
+ return convert_to_smt_shift (
675
+ smt_bit_vector_theoryt::logical_shift_right, *right_logical_shift );
671
676
}
672
- else if (
673
- const auto right_arith_shift = expr_try_dynamic_cast<ashr_exprt>(shift))
677
+ if (const auto right_arith_shift = expr_try_dynamic_cast<ashr_exprt>(shift))
674
678
{
675
- return smt_bit_vector_theoryt::arithmetic_shift_right (
676
- convert_expr_to_smt (first_operand), convert_expr_to_smt (second_operand));
677
- }
678
- else
679
- {
680
- UNIMPLEMENTED_FEATURE (
681
- " Generation of SMT formula for shift expression: " + shift.pretty ());
679
+ return convert_to_smt_shift (
680
+ smt_bit_vector_theoryt::arithmetic_shift_right, *right_arith_shift);
682
681
}
682
+ UNIMPLEMENTED_FEATURE (
683
+ " Generation of SMT formula for shift expression: " + shift.pretty ());
683
684
}
684
685
685
686
static smt_termt convert_expr_to_smt (const with_exprt &with)
0 commit comments