15
15
#include " bitvector_expr.h"
16
16
#include " byte_operators.h"
17
17
#include " expr_util.h"
18
+ #include " floatbv_expr.h"
18
19
#include " format_type.h"
19
20
#include " ieee_float.h"
20
21
#include " mathematical_expr.h"
@@ -158,6 +159,14 @@ static std::ostream &format_rec(std::ostream &os, const unary_exprt &src)
158
159
return os << format (src.op ());
159
160
}
160
161
162
+ // / This formats a ternary expression
163
+ static std::ostream &format_rec (std::ostream &os, const ternary_exprt &src)
164
+ {
165
+ os << src.id () << ' (' << format (src.op0 ()) << " , " << format (src.op1 ())
166
+ << " , " << format (src.op2 ()) << ' )' ;
167
+ return os;
168
+ }
169
+
161
170
// / This formats a constant
162
171
static std::ostream &format_rec (std::ostream &os, const constant_exprt &src)
163
172
{
@@ -186,7 +195,9 @@ static std::ostream &format_rec(std::ostream &os, const constant_exprt &src)
186
195
{
187
196
if (is_null_pointer (src))
188
197
return os << ID_NULL;
189
- else if (has_prefix (id2string (src.get_value ()), " INVALID-" ))
198
+ else if (
199
+ src.get_value () == " INVALID" ||
200
+ has_prefix (id2string (src.get_value ()), " INVALID-" ))
190
201
{
191
202
return os << " INVALID-POINTER" ;
192
203
}
@@ -276,19 +287,30 @@ void format_expr_configt::setup()
276
287
expr_map[ID_or] = multi_ary_expr;
277
288
expr_map[ID_xor] = multi_ary_expr;
278
289
279
- auto binary_expr = [](std::ostream &os, const exprt &expr) -> std::ostream & {
290
+ auto binary_infix_expr =
291
+ [](std::ostream &os, const exprt &expr) -> std::ostream & {
280
292
return format_rec (os, to_binary_expr (expr));
281
293
};
282
294
283
- expr_map[ID_lt] = binary_expr;
284
- expr_map[ID_gt] = binary_expr;
285
- expr_map[ID_ge] = binary_expr;
286
- expr_map[ID_le] = binary_expr;
287
- expr_map[ID_div] = binary_expr;
288
- expr_map[ID_minus] = binary_expr;
289
- expr_map[ID_implies] = binary_expr;
290
- expr_map[ID_equal] = binary_expr;
291
- expr_map[ID_notequal] = binary_expr;
295
+ expr_map[ID_lt] = binary_infix_expr;
296
+ expr_map[ID_gt] = binary_infix_expr;
297
+ expr_map[ID_ge] = binary_infix_expr;
298
+ expr_map[ID_le] = binary_infix_expr;
299
+ expr_map[ID_div] = binary_infix_expr;
300
+ expr_map[ID_minus] = binary_infix_expr;
301
+ expr_map[ID_implies] = binary_infix_expr;
302
+ expr_map[ID_equal] = binary_infix_expr;
303
+ expr_map[ID_notequal] = binary_infix_expr;
304
+
305
+ auto binary_prefix_expr =
306
+ [](std::ostream &os, const exprt &expr) -> std::ostream & {
307
+ os << expr.id () << ' (' << format (to_binary_expr (expr).op0 ()) << " , "
308
+ << format (to_binary_expr (expr).op1 ()) << ' )' ;
309
+ return os;
310
+ };
311
+
312
+ expr_map[ID_ieee_float_equal] = binary_prefix_expr;
313
+ expr_map[ID_ieee_float_notequal] = binary_prefix_expr;
292
314
293
315
auto unary_expr = [](std::ostream &os, const exprt &expr) -> std::ostream & {
294
316
return format_rec (os, to_unary_expr (expr));
@@ -297,11 +319,38 @@ void format_expr_configt::setup()
297
319
expr_map[ID_not] = unary_expr;
298
320
expr_map[ID_unary_minus] = unary_expr;
299
321
322
+ auto unary_with_parentheses_expr =
323
+ [](std::ostream &os, const exprt &expr) -> std::ostream & {
324
+ return os << expr.id () << ' (' << format (to_unary_expr (expr).op ()) << ' )' ;
325
+ };
326
+
327
+ expr_map[ID_isnan] = unary_with_parentheses_expr;
328
+ expr_map[ID_isinf] = unary_with_parentheses_expr;
329
+ expr_map[ID_isfinite] = unary_with_parentheses_expr;
330
+ expr_map[ID_isnormal] = unary_with_parentheses_expr;
331
+
332
+ auto ternary_expr =
333
+ [](std::ostream &os, const exprt &expr) -> std::ostream & {
334
+ return format_rec (os, to_ternary_expr (expr));
335
+ };
336
+
337
+ expr_map[ID_floatbv_plus] = ternary_expr;
338
+ expr_map[ID_floatbv_minus] = ternary_expr;
339
+ expr_map[ID_floatbv_mult] = ternary_expr;
340
+ expr_map[ID_floatbv_div] = ternary_expr;
341
+ expr_map[ID_floatbv_mod] = ternary_expr;
342
+
300
343
expr_map[ID_constant] =
301
344
[](std::ostream &os, const exprt &expr) -> std::ostream & {
302
345
return format_rec (os, to_constant_expr (expr));
303
346
};
304
347
348
+ expr_map[ID_address_of] =
349
+ [](std::ostream &os, const exprt &expr) -> std::ostream & {
350
+ const auto &address_of = to_address_of_expr (expr);
351
+ return os << " address_of(" << format (address_of.object ()) << ' )' ;
352
+ };
353
+
305
354
expr_map[ID_annotated_pointer_constant] =
306
355
[](std::ostream &os, const exprt &expr) -> std::ostream & {
307
356
const auto &annotated_pointer = to_annotated_pointer_constant_expr (expr);
@@ -314,6 +363,14 @@ void format_expr_configt::setup()
314
363
<< format (expr.type ()) << ' )' ;
315
364
};
316
365
366
+ expr_map[ID_floatbv_typecast] =
367
+ [](std::ostream &os, const exprt &expr) -> std::ostream & {
368
+ const auto &floatbv_typecast_expr = to_floatbv_typecast_expr (expr);
369
+ return os << " floatbv_typecast(" << format (floatbv_typecast_expr.op ())
370
+ << " , " << format (floatbv_typecast_expr.type ()) << " , "
371
+ << format (floatbv_typecast_expr.rounding_mode ()) << ' )' ;
372
+ };
373
+
317
374
auto byte_extract =
318
375
[](std::ostream &os, const exprt &expr) -> std::ostream & {
319
376
const auto &byte_extract_expr = to_byte_extract_expr (expr);
@@ -454,6 +511,12 @@ void format_expr_configt::setup()
454
511
expr_map[ID_array] = compound ;
455
512
expr_map[ID_struct] = compound ;
456
513
514
+ expr_map[ID_array_of] =
515
+ [](std::ostream &os, const exprt &expr) -> std::ostream & {
516
+ const auto &array_of_expr = to_array_of_expr (expr);
517
+ return os << " array_of(" << format (array_of_expr.what ()) << ' )' ;
518
+ };
519
+
457
520
expr_map[ID_if] = [](std::ostream &os, const exprt &expr) -> std::ostream & {
458
521
const auto &if_expr = to_if_expr (expr);
459
522
return os << ' (' << format (if_expr.cond ()) << " ? "
0 commit comments