File tree Expand file tree Collapse file tree 5 files changed +75
-0
lines changed Expand file tree Collapse file tree 5 files changed +75
-0
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,7 @@ SRC = $(BOOLEFORCE_SRC) \
193
193
smt2/smt2_tokenizer.cpp \
194
194
smt2/smt2irep.cpp \
195
195
smt2_incremental/smt_sorts.cpp \
196
+ smt2_incremental/smt_to_string.cpp \
196
197
smt2_incremental/smt2_incremental_decision_procedure.cpp \
197
198
# Empty last line
198
199
Original file line number Diff line number Diff line change
1
+ // Author: Diffblue Ltd.
2
+
3
+ #include < solvers/smt2_incremental/smt_to_string.h>
4
+
5
+ #include < solvers/smt2_incremental/smt_sorts.h>
6
+
7
+ #include < iostream>
8
+ #include < sstream>
9
+ #include < string>
10
+
11
+ class smt_sort_output_visitort : public smt_sort_const_downcast_visitort
12
+ {
13
+ protected:
14
+ std::ostream &os;
15
+
16
+ public:
17
+ explicit smt_sort_output_visitort (std::ostream &os) : os(os)
18
+ {
19
+ }
20
+
21
+ void visit (const smt_bool_sortt &) override
22
+ {
23
+ os << " Bool" ;
24
+ }
25
+
26
+ void visit (const smt_bit_vector_sortt &bit_vec) override
27
+ {
28
+ os << " (_ BitVec " << bit_vec.bit_width () << " )" ;
29
+ }
30
+ };
31
+
32
+ std::ostream &operator <<(std::ostream &os, const smt_sortt &sort)
33
+ {
34
+ sort.accept (smt_sort_output_visitort{os});
35
+ return os;
36
+ }
37
+
38
+ std::string smt_to_string (const smt_sortt &sort)
39
+ {
40
+ std::stringstream ss;
41
+ ss << sort;
42
+ return ss.str ();
43
+ }
Original file line number Diff line number Diff line change
1
+ // Author: Diffblue Ltd.
2
+
3
+ // / \file
4
+ // / Streaming SMT data structures to a string based output stream.
5
+
6
+ #ifndef CPROVER_SOLVERS_SMT2_INCREMENTAL_SMT_TO_STRING_H
7
+ #define CPROVER_SOLVERS_SMT2_INCREMENTAL_SMT_TO_STRING_H
8
+
9
+ class smt_sortt ;
10
+
11
+ #include < iosfwd>
12
+ #include < string>
13
+
14
+ std::ostream &operator <<(std::ostream &os, const smt_sortt &sort);
15
+
16
+ std::string smt_to_string (const smt_sortt &sort);
17
+
18
+ #endif // CPROVER_SOLVERS_SMT2_INCREMENTAL_SMT_TO_STRING_H
Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ SRC += analyses/ai/ai.cpp \
77
77
solvers/sat/satcheck_cadical.cpp \
78
78
solvers/sat/satcheck_minisat2.cpp \
79
79
solvers/smt2_incremental/smt_sorts.cpp \
80
+ solvers/smt2_incremental/smt_to_string.cpp \
80
81
solvers/strings/array_pool/array_pool.cpp \
81
82
solvers/strings/string_constraint_generator_valueof/calculate_max_string_length.cpp \
82
83
solvers/strings/string_constraint_generator_valueof/get_numeric_value_from_character.cpp \
Original file line number Diff line number Diff line change
1
+ // Author: Diffblue Ltd.
2
+
3
+ #include < testing-utils/use_catch.h>
4
+
5
+ #include < solvers/smt2_incremental/smt_sorts.h>
6
+ #include < solvers/smt2_incremental/smt_to_string.h>
7
+
8
+ TEST_CASE (" Test smt_sortt to string conversion" , " [core][smt2_incremental]" )
9
+ {
10
+ CHECK (smt_to_string (smt_bool_sortt{}) == " Bool" );
11
+ CHECK (smt_to_string (smt_bit_vector_sortt{16 }) == " (_ BitVec 16)" );
12
+ }
You can’t perform that action at this time.
0 commit comments