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 @@ -171,3 +171,26 @@ const smt_optiont &smt_set_option_commandt::option() const
171
171
{
172
172
return downcast (find (ID_value));
173
173
}
174
+
175
+ template <typename visitort>
176
+ void accept (const smt_commandt &command, const irep_idt &id, visitort &&visitor)
177
+ {
178
+ #define COMMAND_ID (the_id ) \
179
+ if (id == ID_smt_##the_id##_command) \
180
+ return visitor.visit (static_cast <const smt_##the_id##_commandt &>(command));
181
+ // The include below is marked as nolint because including the same file
182
+ // multiple times is required as part of the x macro pattern.
183
+ #include < solvers/smt2_incremental/smt_commands.def> // NOLINT(build/include)
184
+ #undef COMMAND_ID
185
+ UNREACHABLE;
186
+ }
187
+
188
+ void smt_commandt::accept (smt_command_const_downcast_visitort &visitor) const
189
+ {
190
+ ::accept (*this , id(), visitor);
191
+ }
192
+
193
+ void smt_commandt::accept (smt_command_const_downcast_visitort &&visitor) const
194
+ {
195
+ ::accept (*this , id(), std::move(visitor));
196
+ }
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 8
8
#include < solvers/smt2_incremental/smt_terms.h>
9
9
#include < util/irep.h>
10
10
11
+ class smt_command_const_downcast_visitort ;
12
+
11
13
class smt_commandt : protected irept
12
14
{
13
15
public:
@@ -20,6 +22,9 @@ class smt_commandt : protected irept
20
22
bool operator ==(const smt_commandt &) const ;
21
23
bool operator !=(const smt_commandt &) const ;
22
24
25
+ void accept (smt_command_const_downcast_visitort &) const ;
26
+ void accept (smt_command_const_downcast_visitort &&) const ;
27
+
23
28
protected:
24
29
using irept::irept;
25
30
};
@@ -118,4 +123,13 @@ class smt_set_option_commandt
118
123
const smt_optiont &option () const ;
119
124
};
120
125
126
+ class smt_command_const_downcast_visitort
127
+ {
128
+ public:
129
+ #define COMMAND_ID (the_id ) \
130
+ virtual void visit (const smt_##the_id##_commandt &) = 0;
131
+ #include " smt_commands.def"
132
+ #undef COMMAND_ID
133
+ };
134
+
121
135
#endif // CPROVER_SOLVERS_SMT2_INCREMENTAL_SMT_COMMANDS_H
You can’t perform that action at this time.
0 commit comments