Skip to content

Commit 2f27da4

Browse files
committed
Use smt_logics.def to define printed strings
So that additional logics can be added based solely on updating the `.def` file.
1 parent d30aa73 commit 2f27da4

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

src/solvers/smt2_incremental/smt_logics.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <solvers/smt2_incremental/smt_logics.h>
44

55
// Define the irep_idts for logics.
6-
#define LOGIC_ID(the_id) \
6+
#define LOGIC_ID(the_id, the_name) \
77
const irep_idt ID_smt_logic_##the_id{"smt_logic_" #the_id};
88
#include <solvers/smt2_incremental/smt_logics.def>
99
#undef LOGIC_ID
@@ -21,7 +21,7 @@ bool smt_logict::operator!=(const smt_logict &other) const
2121
template <typename visitort>
2222
void accept(const smt_logict &logic, const irep_idt &id, visitort &&visitor)
2323
{
24-
#define LOGIC_ID(the_id) \
24+
#define LOGIC_ID(the_id, the_name) \
2525
if(id == ID_smt_logic_##the_id) \
2626
return visitor.visit(static_cast<const smt_logic_##the_id##t &>(logic));
2727
// The include below is marked as nolint because including the same file
@@ -41,7 +41,7 @@ void smt_logict::accept(smt_logic_const_downcast_visitort &&visitor) const
4141
::accept(*this, id(), std::move(visitor));
4242
}
4343

44-
#define LOGIC_ID(the_id) \
44+
#define LOGIC_ID(the_id, the_name) \
4545
smt_logic_##the_id##t::smt_logic_##the_id##t() \
4646
: smt_logict{ID_smt_logic_##the_id} \
4747
{ \

src/solvers/smt2_incremental/smt_logics.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
/// * The constant `irep_idt`s used to identify each of the logic classes.
77
/// * The member functions of the `smt_logic_const_downcast_visitort` class.
88
/// * The type of option checks required to implement `smt_logict::accept`.
9-
LOGIC_ID(quantifier_free_bit_vectors)
9+
LOGIC_ID(quantifier_free_bit_vectors, QF_BV)

src/solvers/smt2_incremental/smt_logics.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const smt_logict &smt_logict::storert<derivedt>::downcast(const irept &irep)
6161
return static_cast<const smt_logict &>(irep);
6262
}
6363

64-
#define LOGIC_ID(the_id) \
64+
#define LOGIC_ID(the_id, the_name) \
6565
/* NOLINTNEXTLINE(readability/identifiers) cpplint does not match the ## */ \
6666
class smt_logic_##the_id##t : public smt_logict \
6767
{ \
@@ -74,7 +74,8 @@ const smt_logict &smt_logict::storert<derivedt>::downcast(const irept &irep)
7474
class smt_logic_const_downcast_visitort
7575
{
7676
public:
77-
#define LOGIC_ID(the_id) virtual void visit(const smt_logic_##the_id##t &) = 0;
77+
#define LOGIC_ID(the_id, the_name) \
78+
virtual void visit(const smt_logic_##the_id##t &) = 0;
7879
#include "smt_logics.def"
7980
#undef LOGIC_ID
8081
};

src/solvers/smt2_incremental/smt_to_smt2_string.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,13 @@ class smt_logic_to_string_convertert : public smt_logic_const_downcast_visitort
265265
{
266266
}
267267

268-
void visit(const smt_logic_quantifier_free_bit_vectorst &) override
269-
{
270-
os << "QF_BV";
268+
#define LOGIC_ID(the_id, the_name) \
269+
void visit(const smt_logic_##the_id##t &) override \
270+
{ \
271+
os << #the_name; \
271272
}
273+
#include "smt_logics.def"
274+
#undef LOGIC_ID
272275
};
273276

274277
std::ostream &operator<<(std::ostream &os, const smt_logict &logic)

0 commit comments

Comments
 (0)