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 @@ -172,3 +172,26 @@ const smt_optiont &smt_set_option_commandt::option() const
172
172
{
173
173
return downcast (find (ID_value));
174
174
}
175
+
176
+ template <typename visitort>
177
+ void accept (const smt_commandt &command, const irep_idt &id, visitort &&visitor)
178
+ {
179
+ #define COMMAND_ID (the_id ) \
180
+ if (id == ID_smt_##the_id##_command) \
181
+ return visitor.visit (static_cast <const smt_##the_id##_commandt &>(command));
182
+ // The include below is marked as nolint because including the same file
183
+ // multiple times is required as part of the x macro pattern.
184
+ #include < solvers/smt2_incremental/smt_commands.def> // NOLINT(build/include)
185
+ #undef COMMAND_ID
186
+ UNREACHABLE;
187
+ }
188
+
189
+ void smt_commandt::accept (smt_command_const_downcast_visitort &visitor) const
190
+ {
191
+ ::accept (*this , id(), visitor);
192
+ }
193
+
194
+ void smt_commandt::accept (smt_command_const_downcast_visitort &&visitor) const
195
+ {
196
+ ::accept (*this , id(), std::move(visitor));
197
+ }
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