2 * Copyright 2013 Ecole Normale Superieure
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege,
7 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
10 #include <isl/space.h>
13 #include <isl_multi_macro.h>
15 /* This function is called for each element in a tuple inside
16 * isl_stream_read_multi_*.
17 * Read an EL from "s" and add it to *list.
19 static __isl_give isl_space
*FN(read_el
,BASE
)(__isl_keep isl_stream
*s
,
20 struct vars
*v
, __isl_take isl_space
*space
, int rational
, void *user
)
22 LIST(EL
) **list
= (LIST(EL
) **) user
;
25 el
= FN(isl_stream_read
,BASE
)(s
);
26 *list
= FN(LIST(EL
),add
)(*list
, el
);
28 return isl_space_free(space
);
33 /* Read a multi expression from "s".
35 * We first read a tuple space, collecting the element values in a list.
36 * Then we create an isl_multi_* from the space and the isl_*_list.
38 __isl_give
MULTI(BASE
) *FN(isl_stream_read_multi
,BASE
)(
39 __isl_keep isl_stream
*s
)
44 MULTI(BASE
) *multi
= NULL
;
51 dom
= isl_set_universe(isl_space_params_alloc(s
->ctx
, 0));
52 if (next_is_tuple(s
)) {
53 dom
= read_map_tuple(s
, dom
, isl_dim_param
, v
, 0);
54 if (isl_stream_eat(s
, ISL_TOKEN_TO
))
57 if (!isl_set_plain_is_universe(dom
))
58 isl_die(s
->ctx
, isl_error_invalid
,
59 "expecting universe parameter domain", goto error
);
60 if (isl_stream_eat(s
, '{'))
63 space
= isl_set_get_space(dom
);
65 list
= FN(LIST(EL
),alloc
)(s
->ctx
, 0);
66 space
= read_tuple_space(s
, v
, space
, 1, 0, &FN(read_el
,BASE
), &list
);
67 multi
= FN(FN(MULTI(BASE
),from
),LIST(BASE
))(space
, list
);
69 if (isl_stream_eat(s
, '}'))
78 FN(MULTI(BASE
),free
)(multi
);
83 #define TYPE_BASE CAT(multi_,BASE)
84 #include "isl_read_from_str_templ.c"