1 | /* |
2 | * Copyright 2010 INRIA Saclay |
3 | * |
4 | * Use of this software is governed by the MIT license |
5 | * |
6 | * Written by Sven Verdoolaege, |
7 | * INRIA Saclay - Ile-de-France, Parc Club Orsay Universite, |
8 | * ZAC des vignes, 4 rue Jacques Monod, 91893 Orsay, France |
9 | */ |
10 | |
11 | #include "isl_union_macro.h" |
12 | |
13 | /* Print "pw" in a sequence of "PART" objects delimited by semicolons. |
14 | * Each "PART" object itself is also printed as a semicolon delimited |
15 | * sequence of pieces. |
16 | * If data->first = 1, then this is the first in the sequence. |
17 | * Update data->first to tell the next element that it is not the first. |
18 | */ |
19 | static isl_stat FN(print_body_wrap,BASE)(__isl_take PART *pw, |
20 | void *user) |
21 | { |
22 | struct isl_union_print_data *data; |
23 | data = (struct isl_union_print_data *) user; |
24 | |
25 | if (!data->first) |
26 | data->p = isl_printer_print_str(p: data->p, s: "; " ); |
27 | data->first = 0; |
28 | |
29 | data->p = FN(print_body,BASE)(p: data->p, map: pw); |
30 | FN(PART,free)(map: pw); |
31 | |
32 | return isl_stat_non_null(obj: data->p); |
33 | } |
34 | |
35 | /* Print the body of "u" (everything except the parameter declarations) |
36 | * to "p" in isl format. |
37 | */ |
38 | static __isl_give isl_printer *FN(print_body_union,BASE)( |
39 | __isl_take isl_printer *p, __isl_keep UNION *u) |
40 | { |
41 | struct isl_union_print_data data; |
42 | |
43 | p = isl_printer_print_str(p, s: s_open_set[0]); |
44 | data.p = p; |
45 | data.first = 1; |
46 | if (FN(FN(UNION,foreach),BASE)(umap: u, fn: &FN(print_body_wrap,BASE), user: &data) < 0) |
47 | data.p = isl_printer_free(printer: data.p); |
48 | p = data.p; |
49 | p = isl_printer_print_str(p, s: s_close_set[0]); |
50 | |
51 | return p; |
52 | } |
53 | |
54 | /* Print the "UNION" object "u" to "p" in isl format. |
55 | */ |
56 | static __isl_give isl_printer *FN(FN(print_union,BASE),isl)( |
57 | __isl_take isl_printer *p, __isl_keep UNION *u) |
58 | { |
59 | struct isl_print_space_data space_data = { 0 }; |
60 | isl_space *space; |
61 | |
62 | space = FN(UNION,get_space)(umap: u); |
63 | p = print_param_tuple(p, space, data: &space_data); |
64 | isl_space_free(space); |
65 | |
66 | p = FN(print_body_union,BASE)(p, u); |
67 | |
68 | return p; |
69 | } |
70 | |