Home | History | Annotate | Line # | Download | only in dist
      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(data->p, "; ");
     27 	data->first = 0;
     28 
     29 	data->p = FN(print_body,BASE)(data->p, pw);
     30 	FN(PART,free)(pw);
     31 
     32 	return isl_stat_non_null(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_open_set[0]);
     44 	data.p = p;
     45 	data.first = 1;
     46 	if (FN(FN(UNION,foreach),BASE)(u, &FN(print_body_wrap,BASE), &data) < 0)
     47 		data.p = isl_printer_free(data.p);
     48 	p = data.p;
     49 	p = isl_printer_print_str(p, 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)(u);
     63 	p = print_param_tuple(p, space, &space_data);
     64 	isl_space_free(space);
     65 
     66 	p = FN(print_body_union,BASE)(p, u);
     67 
     68 	return p;
     69 }
     70