File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed
src/solvers/smt2_incremental Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -143,3 +143,26 @@ size_t smt_pop_commandt::levels() const
143
143
{
144
144
return get_size_t (ID_value);
145
145
}
146
+
147
+ template <typename visitort>
148
+ void accept (const smt_commandt &command, const irep_idt &id, visitort &&visitor)
149
+ {
150
+ #define COMMAND_ID (the_id ) \
151
+ if (id == ID_smt_##the_id##_command) \
152
+ return visitor.visit (static_cast <const smt_##the_id##_commandt &>(command));
153
+ // The include below is marked as nolint because including the same file
154
+ // multiple times is required as part of the x macro pattern.
155
+ #include < solvers/smt2_incremental/smt_commands.def> // NOLINT(build/include)
156
+ #undef COMMAND_ID
157
+ UNREACHABLE;
158
+ }
159
+
160
+ void smt_commandt::accept (smt_command_const_downcast_visitort &visitor) const
161
+ {
162
+ ::accept (*this , id(), visitor);
163
+ }
164
+
165
+ void smt_commandt::accept (smt_command_const_downcast_visitort &&visitor) const
166
+ {
167
+ ::accept (*this , id(), std::move(visitor));
168
+ }
Original file line number Diff line number Diff line change 4
4
/// set of commands which are implemented and it is used to automate repetitive
5
5
/// parts of the implementation. These include -
6
6
/// * The constant `irep_idt`s used to identify each of the command classes.
7
+ /// * The member functions of the `smt_command_const_downcast_visitort` class.
8
+ /// * The type of command checks required to implement `smt_commandt::accept`.
7
9
COMMAND_ID(assert)
8
10
COMMAND_ID(check_sat)
9
11
COMMAND_ID(declare_function)
Original file line number Diff line number Diff line change 6
6
#include < solvers/smt2_incremental/smt_terms.h>
7
7
#include < util/irep.h>
8
8
9
+ class smt_command_const_downcast_visitort ;
10
+
9
11
class smt_commandt : protected irept
10
12
{
11
13
public:
@@ -18,6 +20,9 @@ class smt_commandt : protected irept
18
20
bool operator ==(const smt_commandt &) const ;
19
21
bool operator !=(const smt_commandt &) const ;
20
22
23
+ void accept (smt_command_const_downcast_visitort &) const ;
24
+ void accept (smt_command_const_downcast_visitort &&) const ;
25
+
21
26
protected:
22
27
using irept::irept;
23
28
};
@@ -103,4 +108,13 @@ class smt_set_option_commandt : public smt_commandt
103
108
public:
104
109
};
105
110
111
+ class smt_command_const_downcast_visitort
112
+ {
113
+ public:
114
+ #define COMMAND_ID (the_id ) \
115
+ virtual void visit (const smt_##the_id##_commandt &) = 0;
116
+ #include " smt_commands.def"
117
+ #undef COMMAND_ID
118
+ };
119
+
106
120
#endif // CPROVER_SOLVERS_SMT2_INCREMENTAL_SMT_COMMANDS_H
You can’t perform that action at this time.
0 commit comments