2 * Copyright 2010-2011 INRIA Saclay
4 * Use of this software is governed by the GNU LGPLv2.1 license
6 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
7 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
11 #include "pet_printer.h"
14 static __isl_take isl_printer
*print_pet_expr_help(__isl_take isl_printer
*p
,
15 struct pet_expr
*expr
, int outer
,
16 __isl_take isl_printer
*(*print_access_fn
)(__isl_take isl_printer
*p
,
17 struct pet_expr
*expr
, void *usr
), void *usr
)
23 p
= isl_printer_print_str(p
, expr
->d
.s
);
26 p
= print_access_fn(p
, expr
, usr
);
30 p
= isl_printer_print_str(p
, "(");
31 p
= isl_printer_print_str(p
, " ");
32 p
= isl_printer_print_str(p
, pet_op_str(expr
->op
));
33 p
= isl_printer_print_str(p
, " ");
34 p
= print_pet_expr_help(p
, expr
->args
[pet_un_arg
], 0,
35 print_access_fn
, usr
);
37 p
= isl_printer_print_str(p
, ")");
41 p
= isl_printer_print_str(p
, "(");
42 p
= print_pet_expr_help(p
, expr
->args
[pet_bin_lhs
], 0,
43 print_access_fn
, usr
);
44 p
= isl_printer_print_str(p
, " ");
45 p
= isl_printer_print_str(p
, pet_op_str(expr
->op
));
46 p
= isl_printer_print_str(p
, " ");
47 p
= print_pet_expr_help(p
, expr
->args
[pet_bin_rhs
], 0,
48 print_access_fn
, usr
);
50 p
= isl_printer_print_str(p
, ")");
52 case pet_expr_ternary
:
54 p
= isl_printer_print_str(p
, "(");
55 p
= print_pet_expr_help(p
, expr
->args
[pet_ter_cond
], 0,
56 print_access_fn
, usr
);
57 p
= isl_printer_print_str(p
, " ? ");
58 p
= print_pet_expr_help(p
, expr
->args
[pet_ter_true
], 0,
59 print_access_fn
, usr
);
60 p
= isl_printer_print_str(p
, " : ");
61 p
= print_pet_expr_help(p
, expr
->args
[pet_ter_false
], 0,
62 print_access_fn
, usr
);
64 p
= isl_printer_print_str(p
, ")");
67 p
= isl_printer_print_str(p
, expr
->name
);
68 p
= isl_printer_print_str(p
, "(");
69 for (i
= 0; i
< expr
->n_arg
; ++i
) {
71 p
= isl_printer_print_str(p
, ", ");
72 p
= print_pet_expr_help(p
, expr
->args
[i
], 1,
73 print_access_fn
, usr
);
75 p
= isl_printer_print_str(p
, ")");
79 p
= isl_printer_print_str(p
, "(");
80 p
= isl_printer_print_str(p
, "(");
81 p
= isl_printer_print_str(p
, expr
->type_name
);
82 p
= isl_printer_print_str(p
, ") ");
83 p
= print_pet_expr_help(p
, expr
->args
[0], 0,
84 print_access_fn
, usr
);
86 p
= isl_printer_print_str(p
, ")");
93 __isl_give isl_printer
*print_pet_expr(__isl_take isl_printer
*p
,
94 struct pet_expr
*expr
,
95 __isl_give isl_printer
*(*print_access
)(__isl_take isl_printer
*p
,
96 struct pet_expr
*expr
, void *usr
), void *usr
)
98 return print_pet_expr_help(p
, expr
, 1, print_access
, usr
);