File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -69,8 +69,37 @@ class ternary_exprt : public expr_protectedt
69
69
70
70
const exprt &op3 () const = delete;
71
71
exprt &op3 () = delete;
72
+
73
+ static void check (
74
+ const exprt &expr,
75
+ const validation_modet vm = validation_modet::INVARIANT)
76
+ {
77
+ DATA_CHECK (
78
+ vm,
79
+ expr.operands ().size () == 3 ,
80
+ " ternary expression must have three operands" );
81
+ }
72
82
};
73
83
84
+ // / \brief Cast an exprt to a \ref ternary_exprt
85
+ // /
86
+ // / \a expr must be known to be \ref ternary_exprt.
87
+ // /
88
+ // / \param expr: Source expression
89
+ // / \return Object of type \ref ternary_exprt
90
+ inline const ternary_exprt &to_ternary_expr (const exprt &expr)
91
+ {
92
+ ternary_exprt::check (expr);
93
+ return static_cast <const ternary_exprt &>(expr);
94
+ }
95
+
96
+ // / \copydoc to_ternary_expr(const exprt &)
97
+ inline ternary_exprt &to_ternary_expr (exprt &expr)
98
+ {
99
+ ternary_exprt::check (expr);
100
+ return static_cast <ternary_exprt &>(expr);
101
+ }
102
+
74
103
// / Expression to hold a symbol (variable)
75
104
class symbol_exprt : public nullary_exprt
76
105
{
You can’t perform that action at this time.
0 commit comments