@@ -238,6 +238,70 @@ inline void validate_expr(const symbol_exprt &value)
238
238
}
239
239
240
240
241
+ /* ! \brief Expression to hold a nondeterministic choice
242
+ */
243
+ class nondet_symbol_exprt :public exprt
244
+ {
245
+ public:
246
+ /* ! \brief Constructor
247
+ * \param identifier Name of symbol
248
+ * \param type Type of symbol
249
+ */
250
+ nondet_symbol_exprt (
251
+ const irep_idt &identifier,
252
+ const typet &type):exprt(ID_nondet_symbol, type)
253
+ {
254
+ set_identifier (identifier);
255
+ }
256
+
257
+ void set_identifier (const irep_idt &identifier)
258
+ {
259
+ set (ID_identifier, identifier);
260
+ }
261
+
262
+ const irep_idt &get_identifier () const
263
+ {
264
+ return get (ID_identifier);
265
+ }
266
+ };
267
+
268
+ /* ! \brief Cast a generic exprt to a \ref nondet_symbol_exprt
269
+ *
270
+ * This is an unchecked conversion. \a expr must be known to be \ref
271
+ * nondet_symbol_exprt.
272
+ *
273
+ * \param expr Source expression
274
+ * \return Object of type \ref nondet_symbol_exprt
275
+ *
276
+ * \ingroup gr_std_expr
277
+ */
278
+ inline const nondet_symbol_exprt &to_nondet_symbol_expr (const exprt &expr)
279
+ {
280
+ PRECONDITION (expr.id ()==ID_nondet_symbol);
281
+ DATA_INVARIANT (!expr.has_operands (), " Symbols must not have operands" );
282
+ return static_cast <const nondet_symbol_exprt &>(expr);
283
+ }
284
+
285
+ /* ! \copydoc to_nondet_symbol_expr(const exprt &)
286
+ * \ingroup gr_std_expr
287
+ */
288
+ inline nondet_symbol_exprt &to_nondet_symbol_expr (exprt &expr)
289
+ {
290
+ PRECONDITION (expr.id ()==ID_symbol);
291
+ DATA_INVARIANT (!expr.has_operands (), " Symbols must not have operands" );
292
+ return static_cast <nondet_symbol_exprt &>(expr);
293
+ }
294
+
295
+ template <> inline bool can_cast_expr<nondet_symbol_exprt>(const exprt &base)
296
+ {
297
+ return base.id ()==ID_nondet_symbol;
298
+ }
299
+ inline void validate_expr (const nondet_symbol_exprt &value)
300
+ {
301
+ validate_operands (value, 0 , " Symbols must not have operands" );
302
+ }
303
+
304
+
241
305
/* ! \brief Generic base class for unary expressions
242
306
*/
243
307
class unary_exprt :public exprt
0 commit comments