Skip to content

Commit 290f022

Browse files
committed
Move dispatch of relational operators to their own dispatch functions.
So that top-level `convert_expr_to_smt` can be kept as clean as possible.
1 parent e167b10 commit 290f022

File tree

1 file changed

+38
-16
lines changed

1 file changed

+38
-16
lines changed

src/solvers/smt2_incremental/convert_expr_to_smt.cpp

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,40 @@ convert_expr_to_smt(const count_trailing_zeros_exprt &count_trailing_zeros)
556556
count_trailing_zeros.pretty());
557557
}
558558

559+
static smt_termt convert_expr_to_smt(const greater_than_exprt &greater_than)
560+
{
561+
return convert_relational_to_smt(
562+
greater_than,
563+
smt_bit_vector_theoryt::unsigned_greater_than,
564+
smt_bit_vector_theoryt::signed_greater_than);
565+
}
566+
567+
static smt_termt
568+
convert_expr_to_smt(const greater_than_or_equal_exprt &greater_than_or_equal)
569+
{
570+
return convert_relational_to_smt(
571+
greater_than_or_equal,
572+
smt_bit_vector_theoryt::unsigned_greater_than_or_equal,
573+
smt_bit_vector_theoryt::signed_greater_than_or_equal);
574+
}
575+
576+
static smt_termt convert_expr_to_smt(const less_than_exprt &less_than)
577+
{
578+
return convert_relational_to_smt(
579+
less_than,
580+
smt_bit_vector_theoryt::unsigned_less_than,
581+
smt_bit_vector_theoryt::signed_less_than);
582+
}
583+
584+
static smt_termt
585+
convert_expr_to_smt(const less_than_or_equal_exprt &less_than_or_equal)
586+
{
587+
return convert_relational_to_smt(
588+
less_than_or_equal,
589+
smt_bit_vector_theoryt::unsigned_less_than_or_equal,
590+
smt_bit_vector_theoryt::signed_less_than_or_equal);
591+
}
592+
559593
smt_termt convert_expr_to_smt(const exprt &expr)
560594
{
561595
if(const auto symbol = expr_try_dynamic_cast<symbol_exprt>(expr))
@@ -704,35 +738,23 @@ smt_termt convert_expr_to_smt(const exprt &expr)
704738
#endif
705739
if(const auto &greater_than = expr_try_dynamic_cast<greater_than_exprt>(expr))
706740
{
707-
return convert_relational_to_smt(
708-
*greater_than,
709-
smt_bit_vector_theoryt::unsigned_greater_than,
710-
smt_bit_vector_theoryt::signed_greater_than);
741+
return convert_expr_to_smt(*greater_than);
711742
}
712743
if(
713744
const auto &greater_than_or_equal =
714745
expr_try_dynamic_cast<greater_than_or_equal_exprt>(expr))
715746
{
716-
return convert_relational_to_smt(
717-
*greater_than_or_equal,
718-
smt_bit_vector_theoryt::unsigned_greater_than_or_equal,
719-
smt_bit_vector_theoryt::signed_greater_than_or_equal);
747+
return convert_expr_to_smt(*greater_than_or_equal);
720748
}
721749
if(const auto &less_than = expr_try_dynamic_cast<less_than_exprt>(expr))
722750
{
723-
return convert_relational_to_smt(
724-
*less_than,
725-
smt_bit_vector_theoryt::unsigned_less_than,
726-
smt_bit_vector_theoryt::signed_less_than);
751+
return convert_expr_to_smt(*less_than);
727752
}
728753
if(
729754
const auto &less_than_or_equal =
730755
expr_try_dynamic_cast<less_than_or_equal_exprt>(expr))
731756
{
732-
return convert_relational_to_smt(
733-
*less_than_or_equal,
734-
smt_bit_vector_theoryt::unsigned_less_than_or_equal,
735-
smt_bit_vector_theoryt::signed_less_than_or_equal);
757+
return convert_expr_to_smt(*less_than_or_equal);
736758
}
737759
if(const auto address_of = expr_try_dynamic_cast<address_of_exprt>(expr))
738760
{

0 commit comments

Comments
 (0)