19
19
20
20
#include < stack>
21
21
22
+ // / Move the given argument to the end of `exprt`'s operands.
23
+ // / The argument is destroyed and mutated to a reference to a nil `irept`.
24
+ // / \param expr: `exprt` to append to the operands
22
25
void exprt::move_to_operands (exprt &expr)
23
26
{
24
27
operandst &op=operands ();
25
28
op.push_back (static_cast <const exprt &>(get_nil_irep ()));
26
29
op.back ().swap (expr);
27
30
}
28
31
32
+ // / Move the given arguments to the end of `exprt`'s operands.
33
+ // / The argument is destroyed and mutated to a reference to a nil `irept`.
34
+ // / \param e1: first `exprt` to append to the operands
35
+ // / \param e2: second `exprt` to append to the operands
29
36
void exprt::move_to_operands (exprt &e1 , exprt &e2 )
30
37
{
31
38
operandst &op=operands ();
@@ -38,6 +45,11 @@ void exprt::move_to_operands(exprt &e1, exprt &e2)
38
45
op.back ().swap (e2 );
39
46
}
40
47
48
+ // / Move the given arguments to the end of `exprt`'s operands.
49
+ // / The argument is destroyed and mutated to a reference to a nil `irept`.
50
+ // / \param e1: first `exprt` to append to the operands
51
+ // / \param e2: second `exprt` to append to the operands
52
+ // / \param e3: second `exprt` to append to the operands
41
53
void exprt::move_to_operands (exprt &e1 , exprt &e2 , exprt &e3 )
42
54
{
43
55
operandst &op=operands ();
@@ -52,11 +64,16 @@ void exprt::move_to_operands(exprt &e1, exprt &e2, exprt &e3)
52
64
op.back ().swap (e3 );
53
65
}
54
66
67
+ // / Copy the given argument to the end of `exprt`'s operands.
68
+ // / \param expr: `exprt` to append to the operands
55
69
void exprt::copy_to_operands (const exprt &expr)
56
70
{
57
71
operands ().push_back (expr);
58
72
}
59
73
74
+ // / Copy the given argument to the end of `exprt`'s operands.
75
+ // / \param e1: first `exprt` to append to the operands
76
+ // / \param e2: second `exprt` to append to the operands
60
77
void exprt::copy_to_operands (const exprt &e1 , const exprt &e2 )
61
78
{
62
79
operandst &op=operands ();
@@ -67,6 +84,10 @@ void exprt::copy_to_operands(const exprt &e1, const exprt &e2)
67
84
op.push_back (e2 );
68
85
}
69
86
87
+ // / Copy the given argument to the end of `exprt`'s operands.
88
+ // / \param e1: first `exprt` to append to the operands
89
+ // / \param e2: second `exprt` to append to the operands
90
+ // / \param e3: second `exprt` to append to the operands
70
91
void exprt::copy_to_operands (
71
92
const exprt &e1 ,
72
93
const exprt &e2 ,
@@ -81,13 +102,21 @@ void exprt::copy_to_operands(
81
102
op.push_back (e3 );
82
103
}
83
104
105
+ // / Create a \ref typecast_exprt to the given type.
106
+ // / \param _type: cast destination type
107
+ // / \deprecated use constructors instead
84
108
void exprt::make_typecast (const typet &_type)
85
109
{
86
110
typecast_exprt new_expr (*this , _type);
87
111
88
112
swap (new_expr);
89
113
}
90
114
115
+ // / Negate the expression.
116
+ // / Simplifications:
117
+ // / - If the expression is trivially true, make it false, and vice versa.
118
+ // / - If the expression is an `ID_not`, remove the not.
119
+ // / \deprecated use constructors instead
91
120
void exprt::make_not ()
92
121
{
93
122
if (is_true ())
@@ -116,48 +145,71 @@ void exprt::make_not()
116
145
swap (new_expr);
117
146
}
118
147
148
+ // / Return whether the expression is a constant.
149
+ // / \return True if is a constant, false otherwise
119
150
bool exprt::is_constant () const
120
151
{
121
152
return id ()==ID_constant;
122
153
}
123
154
155
+ // / Return whether the expression is a constant representing `true`.
156
+ // / \return True if is a boolean constant representing `true`, false otherwise.
124
157
bool exprt::is_true () const
125
158
{
126
159
return is_constant () &&
127
160
type ().id ()==ID_bool &&
128
161
get (ID_value)!=ID_false;
129
162
}
130
163
164
+ // / Return whether the expression is a constant representing `false`.
165
+ // / \return True if is a boolean constant representing `false`, false otherwise.
131
166
bool exprt::is_false () const
132
167
{
133
168
return is_constant () &&
134
169
type ().id ()==ID_bool &&
135
170
get (ID_value)==ID_false;
136
171
}
137
172
173
+ // / Replace the expression by a boolean expression representing \p value.
174
+ // / \param value: the boolean value to give to the expression
175
+ // / \deprecated use constructors instead
138
176
void exprt::make_bool (bool value)
139
177
{
140
178
*this =exprt (ID_constant, typet (ID_bool));
141
179
set (ID_value, value?ID_true:ID_false);
142
180
}
143
181
182
+ // / Replace the expression by a boolean expression representing true.
183
+ // / \deprecated use constructors instead
144
184
void exprt::make_true ()
145
185
{
146
186
*this =exprt (ID_constant, typet (ID_bool));
147
187
set (ID_value, ID_true);
148
188
}
149
189
190
+ // / Replace the expression by a boolean expression representing false.
191
+ // / \deprecated use constructors instead
150
192
void exprt::make_false ()
151
193
{
152
194
*this =exprt (ID_constant, typet (ID_bool));
153
195
set (ID_value, ID_false);
154
196
}
155
197
198
+ // / Return whether the expression represents a boolean.
199
+ // / \return True if is a boolean, false otherwise.
156
200
bool exprt::is_boolean () const
157
201
{
158
202
return type ().id ()==ID_bool;
159
203
}
160
204
205
+ // / Return whether the expression is a constant representing 0.
206
+ // / Will consider the following types: ID_integer, ID_natural, ID_rational,
207
+ // / ID_unsignedbv, ID_signedbv, ID_c_bool, ID_c_bit_field, ID_fixedbv,
208
+ // / ID_floatbv, ID_pointer.<br>
209
+ // / For ID_pointer, returns true iff the value is a zero string or a null
210
+ // / pointer.
211
+ // / For all other types, return false.
212
+ // / \return True if has value 0, false otherwise.
161
213
bool exprt::is_zero () const
162
214
{
163
215
if (is_constant ())
@@ -202,6 +254,12 @@ bool exprt::is_zero() const
202
254
return false ;
203
255
}
204
256
257
+ // / Return whether the expression is a constant representing 1.
258
+ // / Will consider the following types: ID_integer, ID_natural, ID_rational,
259
+ // / ID_unsignedbv, ID_signedbv, ID_c_bool, ID_c_bit_field, ID_fixedbv,
260
+ // / ID_floatbv.<br>
261
+ // / For all other types, return false.
262
+ // / \return True if has value 1, false otherwise.
205
263
bool exprt::is_one () const
206
264
{
207
265
if (is_constant ())
@@ -243,6 +301,11 @@ bool exprt::is_one() const
243
301
return false ;
244
302
}
245
303
304
+ // / Get a \ref source_locationt from the expression or from its operands
305
+ // / (non-recursively).
306
+ // / If no source location is found, a nil `source_locationt` is returned.
307
+ // / \return A source location if found in the expression or its operands, nil
308
+ // / otherwise.
246
309
const source_locationt &exprt::find_source_location () const
247
310
{
248
311
const source_locationt &l=source_location ();
0 commit comments