#include <isl_map_private.h>
#include <isl/set.h>
#include <isl/seq.h>
-#include <isl/div.h>
#include <isl_stream_private.h>
#include <isl/obj.h>
#include "isl_polynomial_private.h"
}
static __isl_give isl_pw_aff *accept_affine(struct isl_stream *s,
- __isl_take isl_dim *dim, struct vars *v);
+ __isl_take isl_space *dim, struct vars *v);
static __isl_give isl_pw_aff_list *accept_affine_list(struct isl_stream *s,
- __isl_take isl_dim *dim, struct vars *v);
+ __isl_take isl_space *dim, struct vars *v);
static __isl_give isl_pw_aff *accept_minmax(struct isl_stream *s,
- __isl_take isl_dim *dim, struct vars *v)
+ __isl_take isl_space *dim, struct vars *v)
{
struct isl_token *tok;
isl_pw_aff_list *list = NULL;
if (isl_stream_eat(s, '('))
goto error;
- list = accept_affine_list(s, isl_dim_copy(dim), v);
+ list = accept_affine_list(s, isl_space_copy(dim), v);
if (!list)
goto error;
if (isl_stream_eat(s, ')'))
goto error;
- isl_dim_free(dim);
+ isl_space_free(dim);
return min ? isl_pw_aff_list_min(list) : isl_pw_aff_list_max(list);
error:
- isl_dim_free(dim);
+ isl_space_free(dim);
isl_pw_aff_list_free(list);
return NULL;
}
static __isl_give isl_pw_aff *accept_div(struct isl_stream *s,
- __isl_take isl_dim *dim, struct vars *v)
+ __isl_take isl_space *dim, struct vars *v)
{
struct isl_token *tok;
int seen_paren = 0;
seen_paren = 1;
}
- pwaff = accept_affine(s, isl_dim_copy(dim), v);
+ pwaff = accept_affine(s, isl_space_copy(dim), v);
if (f || c) {
if (isl_stream_eat(s, ','))
goto error;
}
- isl_dim_free(dim);
+ isl_space_free(dim);
return pwaff;
error:
- isl_dim_free(dim);
+ isl_space_free(dim);
isl_pw_aff_free(pwaff);
return NULL;
}
static __isl_give isl_pw_aff *accept_affine_factor(struct isl_stream *s,
- __isl_take isl_dim *dim, struct vars *v)
+ __isl_take isl_space *dim, struct vars *v)
{
struct isl_token *tok = NULL;
isl_pw_aff *res = NULL;
goto error;
}
- aff = isl_aff_zero(isl_local_space_from_dim(isl_dim_copy(dim)));
+ aff = isl_aff_zero_on_domain(isl_local_space_from_space(isl_space_copy(dim)));
if (!aff)
goto error;
isl_int_set_si(aff->v->el[2 + pos], 1);
isl_token_free(tok);
} else if (tok->type == ISL_TOKEN_VALUE) {
if (isl_stream_eat_if_available(s, '*')) {
- res = accept_affine_factor(s, isl_dim_copy(dim), v);
+ res = accept_affine_factor(s, isl_space_copy(dim), v);
res = isl_pw_aff_scale(res, tok->u.v);
} else {
isl_local_space *ls;
isl_aff *aff;
- ls = isl_local_space_from_dim(isl_dim_copy(dim));
- aff = isl_aff_zero(ls);
+ ls = isl_local_space_from_space(isl_space_copy(dim));
+ aff = isl_aff_zero_on_domain(ls);
aff = isl_aff_add_constant(aff, tok->u.v);
res = isl_pw_aff_from_aff(aff);
}
} else if (tok->type == '(') {
isl_token_free(tok);
tok = NULL;
- res = accept_affine(s, isl_dim_copy(dim), v);
+ res = accept_affine(s, isl_space_copy(dim), v);
if (!res)
goto error;
if (isl_stream_eat(s, ')'))
tok->type == ISL_TOKEN_CEILD) {
isl_stream_push_token(s, tok);
tok = NULL;
- res = accept_div(s, isl_dim_copy(dim), v);
+ res = accept_div(s, isl_space_copy(dim), v);
} else if (tok->type == ISL_TOKEN_MIN || tok->type == ISL_TOKEN_MAX) {
isl_stream_push_token(s, tok);
tok = NULL;
- res = accept_minmax(s, isl_dim_copy(dim), v);
+ res = accept_minmax(s, isl_space_copy(dim), v);
} else {
isl_stream_error(s, tok, "expecting factor");
goto error;
}
if (isl_stream_eat_if_available(s, '%') ||
isl_stream_eat_if_available(s, ISL_TOKEN_MOD)) {
- isl_dim_free(dim);
+ isl_space_free(dim);
return affine_mod(s, v, res);
}
if (isl_stream_eat_if_available(s, '*')) {
isl_int_clear(f);
}
- isl_dim_free(dim);
+ isl_space_free(dim);
return res;
error:
isl_token_free(tok);
error2:
isl_pw_aff_free(res);
- isl_dim_free(dim);
+ isl_space_free(dim);
return NULL;
}
static __isl_give isl_pw_aff *add_cst(__isl_take isl_pw_aff *pwaff, isl_int v)
{
isl_aff *aff;
+ isl_space *space;
- aff = isl_aff_zero(isl_local_space_from_dim(isl_pw_aff_get_dim(pwaff)));
+ space = isl_pw_aff_get_domain_space(pwaff);
+ aff = isl_aff_zero_on_domain(isl_local_space_from_space(space));
aff = isl_aff_add_constant(aff, v);
return isl_pw_aff_add(pwaff, isl_pw_aff_from_aff(aff));
}
static __isl_give isl_pw_aff *accept_affine(struct isl_stream *s,
- __isl_take isl_dim *dim, struct vars *v)
+ __isl_take isl_space *dim, struct vars *v)
{
struct isl_token *tok = NULL;
isl_local_space *ls;
isl_pw_aff *res;
int sign = 1;
- ls = isl_local_space_from_dim(isl_dim_copy(dim));
- res = isl_pw_aff_from_aff(isl_aff_zero(ls));
+ ls = isl_local_space_from_space(isl_space_copy(dim));
+ res = isl_pw_aff_from_aff(isl_aff_zero_on_domain(ls));
if (!res)
goto error;
isl_pw_aff *term;
isl_stream_push_token(s, tok);
tok = NULL;
- term = accept_affine_factor(s, isl_dim_copy(dim), v);
+ term = accept_affine_factor(s, isl_space_copy(dim), v);
if (sign < 0)
res = isl_pw_aff_sub(res, term);
else
isl_stream_next_token_is(s, ISL_TOKEN_IDENT)) {
isl_pw_aff *term;
term = accept_affine_factor(s,
- isl_dim_copy(dim), v);
+ isl_space_copy(dim), v);
term = isl_pw_aff_scale(term, tok->u.v);
res = isl_pw_aff_add(res, term);
if (!res)
isl_stream_error(s, tok, "unexpected isl_token");
isl_stream_push_token(s, tok);
isl_pw_aff_free(res);
- isl_dim_free(dim);
+ isl_space_free(dim);
return NULL;
}
isl_token_free(tok);
}
}
- isl_dim_free(dim);
+ isl_space_free(dim);
return res;
error:
- isl_dim_free(dim);
+ isl_space_free(dim);
isl_token_free(tok);
isl_pw_aff_free(res);
return NULL;
static struct isl_map *read_disjuncts(struct isl_stream *s,
struct vars *v, __isl_take isl_map *map);
static __isl_give isl_pw_aff *accept_extended_affine(struct isl_stream *s,
- __isl_take isl_dim *dim, struct vars *v);
+ __isl_take isl_space *dim, struct vars *v);
/* Accept a ternary operator, given the first argument.
*/
static __isl_give isl_pw_aff *accept_ternary(struct isl_stream *s,
__isl_take isl_map *cond, struct vars *v)
{
- isl_dim *dim;
+ isl_space *dim;
isl_pw_aff *pwaff1 = NULL, *pwaff2 = NULL;
if (!cond)
if (isl_stream_eat(s, '?'))
goto error;
- dim = isl_dim_wrap(isl_map_get_dim(cond));
+ dim = isl_space_wrap(isl_map_get_space(cond));
pwaff1 = accept_extended_affine(s, dim, v);
if (!pwaff1)
goto error;
if (isl_stream_eat(s, ':'))
goto error;
- pwaff2 = accept_extended_affine(s, isl_pw_aff_get_dim(pwaff1), v);
+ dim = isl_pw_aff_get_domain_space(pwaff1);
+ pwaff2 = accept_extended_affine(s, dim, v);
if (!pwaff1)
goto error;
* argument of a ternary operator and try to parse that.
*/
static __isl_give isl_pw_aff *accept_extended_affine(struct isl_stream *s,
- __isl_take isl_dim *dim, struct vars *v)
+ __isl_take isl_space *dim, struct vars *v)
{
+ isl_space *space;
isl_map *cond;
isl_pw_aff *pwaff;
struct isl_token *tok;
tok->type = ISL_TOKEN_AFF;
tok->u.pwaff = pwaff;
- cond = isl_map_universe(isl_dim_unwrap(isl_pw_aff_get_dim(pwaff)));
+ space = isl_pw_aff_get_domain_space(pwaff);
+ cond = isl_map_universe(isl_space_unwrap(space));
isl_stream_push_token(s, tok);
int pos;
isl_map *def_map;
- pos = isl_map_dim(map, isl_dim_in);
- if (type == isl_dim_out)
- pos += isl_map_dim(map, isl_dim_out);
+ if (type == isl_dim_param)
+ pos = isl_map_dim(map, isl_dim_param);
+ else {
+ pos = isl_map_dim(map, isl_dim_in);
+ if (type == isl_dim_out)
+ pos += isl_map_dim(map, isl_dim_out);
+ type = isl_dim_in;
+ }
--pos;
- def = accept_extended_affine(s, isl_dim_wrap(isl_map_get_dim(map)), v);
+ def = accept_extended_affine(s, isl_space_wrap(isl_map_get_space(map)), v);
def_map = isl_map_from_pw_aff(def);
- def_map = isl_map_equate(def_map, isl_dim_in, pos, isl_dim_out, 0);
+ def_map = isl_map_equate(def_map, type, pos, isl_dim_out, 0);
def_map = isl_set_unwrap(isl_map_domain(def_map));
map = isl_map_intersect(map, def_map);
struct isl_token *tok;
if (isl_stream_next_token_is(s, ']'))
- return map;
+ return isl_map_add_dims(map, type, 0);
while ((tok = next_token(s)) != NULL) {
int new_name = 0;
map = isl_map_add_dims(map, type, 1);
map = set_name(map, type, i, v->v->name);
isl_token_free(tok);
+ if (isl_stream_eat_if_available(s, '='))
+ map = read_var_def(s, map, type, v);
} else {
if (type == isl_dim_param) {
isl_stream_error(s, tok,
}
static __isl_give isl_pw_aff_list *accept_affine_list(struct isl_stream *s,
- __isl_take isl_dim *dim, struct vars *v)
+ __isl_take isl_space *dim, struct vars *v)
{
isl_pw_aff *pwaff;
isl_pw_aff_list *list;
struct isl_token *tok = NULL;
- pwaff = accept_affine(s, isl_dim_copy(dim), v);
+ pwaff = accept_affine(s, isl_space_copy(dim), v);
list = isl_pw_aff_list_from_pw_aff(pwaff);
if (!list)
goto error;
}
isl_token_free(tok);
- pwaff = accept_affine(s, isl_dim_copy(dim), v);
+ pwaff = accept_affine(s, isl_space_copy(dim), v);
list = isl_pw_aff_list_concat(list,
isl_pw_aff_list_from_pw_aff(pwaff));
if (!list)
return NULL;
}
- isl_dim_free(dim);
+ isl_space_free(dim);
return list;
error:
- isl_dim_free(dim);
+ isl_space_free(dim);
isl_pw_aff_list_free(list);
return NULL;
}
static __isl_give isl_map *read_tuple(struct isl_stream *s,
__isl_take isl_map *map, enum isl_dim_type type, struct vars *v);
-static __isl_give isl_map *read_nested_tuple(struct isl_stream *s,
+static __isl_give isl_set *read_nested_tuple(struct isl_stream *s,
__isl_take isl_map *map, struct vars *v)
{
map = read_tuple(s, map, isl_dim_in, v);
if (isl_stream_eat(s, ISL_TOKEN_TO))
goto error;
map = read_tuple(s, map, isl_dim_out, v);
- map = isl_map_from_range(isl_map_wrap(map));
- return map;
+ return isl_map_wrap(map);
error:
isl_map_free(map);
return NULL;
}
isl_token_free(tok);
if (type != isl_dim_param && next_is_tuple(s)) {
- isl_dim *dim = isl_map_get_dim(map);
- int nparam = isl_dim_size(dim, isl_dim_param);
- int n_in = isl_dim_size(dim, isl_dim_in);
- isl_map *nested;
- if (type == isl_dim_out)
- dim = isl_dim_move(dim, isl_dim_param, nparam,
+ isl_space *dim = isl_map_get_space(map);
+ int nparam = isl_space_dim(dim, isl_dim_param);
+ int n_in = isl_space_dim(dim, isl_dim_in);
+ isl_set *nested;
+ if (type == isl_dim_out) {
+ dim = isl_space_move_dims(dim, isl_dim_param, nparam,
isl_dim_in, 0, n_in);
- nested = isl_map_universe(dim);
- nested = read_nested_tuple(s, nested, v);
+ dim = isl_space_params(dim);
+ }
+ nested = read_nested_tuple(s, isl_map_universe(dim), v);
if (type == isl_dim_in) {
nested = isl_map_reverse(nested);
map = isl_map_intersect(nested, map);
} else {
isl_set *set;
- dim = isl_dim_range(isl_map_get_dim(nested));
- dim = isl_dim_drop(dim, isl_dim_param, nparam, n_in);
- dim = isl_dim_join(isl_map_get_dim(map), dim);
+ dim = isl_set_get_space(nested);
+ dim = isl_space_drop_dims(dim, isl_dim_param, nparam, n_in);
+ dim = isl_space_join(isl_map_get_space(map), dim);
set = isl_map_domain(map);
- nested = isl_map_reset_dim(nested, dim);
+ nested = isl_map_reset_space(nested, dim);
map = isl_map_intersect_domain(nested, set);
}
} else
isl_set *set;
set = isl_map_wrap(map);
- list1 = accept_affine_list(s, isl_set_get_dim(set), v);
+ list1 = accept_affine_list(s, isl_set_get_space(set), v);
if (!list1)
goto error;
tok = isl_stream_next_token(s);
goto error;
}
for (;;) {
- list2 = accept_affine_list(s, isl_set_get_dim(set), v);
+ list2 = accept_affine_list(s, isl_set_get_space(set), v);
if (!list2)
goto error;
col = tok2->col;
isl_stream_push_token(s, tok2);
- pwaff = accept_affine(s, isl_dim_wrap(isl_map_get_dim(map)), v);
+ pwaff = accept_affine(s, isl_space_wrap(isl_map_get_space(map)), v);
if (!pwaff)
goto error;
return map;
if (isl_stream_eat_if_available(s, ISL_TOKEN_FALSE)) {
- isl_dim *dim = isl_map_get_dim(map);
+ isl_space *dim = isl_map_get_space(map);
isl_map_free(map);
return isl_map_empty(dim);
}
isl_map *res;
if (isl_stream_next_token_is(s, '}')) {
- isl_dim *dim = isl_map_get_dim(map);
+ isl_space *dim = isl_map_get_space(map);
isl_map_free(map);
return isl_map_universe(dim);
}
return NULL;
}
-static __isl_give isl_basic_map *basic_map_read_polylib(struct isl_stream *s,
- int nparam)
+static __isl_give isl_basic_map *basic_map_read_polylib(struct isl_stream *s)
{
int i;
struct isl_token *tok;
int on_new_line;
unsigned in = 0, out, local = 0;
struct isl_basic_map *bmap = NULL;
-
- if (nparam < 0)
- nparam = 0;
+ int nparam = 0;
tok = isl_stream_next_token(s);
if (!tok) {
return NULL;
}
-static struct isl_map *map_read_polylib(struct isl_stream *s, int nparam)
+static struct isl_map *map_read_polylib(struct isl_stream *s)
{
struct isl_token *tok;
struct isl_token *tok2;
if (tok2 && tok2->type == ISL_TOKEN_VALUE) {
isl_stream_push_token(s, tok2);
isl_stream_push_token(s, tok);
- return isl_map_from_basic_map(basic_map_read_polylib(s, nparam));
+ return isl_map_from_basic_map(basic_map_read_polylib(s));
}
if (tok2) {
isl_stream_error(s, tok2, "unexpected token");
isl_assert(s->ctx, n >= 1, return NULL);
- map = isl_map_from_basic_map(basic_map_read_polylib(s, nparam));
+ map = isl_map_from_basic_map(basic_map_read_polylib(s));
for (i = 1; map && i < n; ++i)
map = isl_map_union(map,
- isl_map_from_basic_map(basic_map_read_polylib(s, nparam)));
+ isl_map_from_basic_map(basic_map_read_polylib(s)));
return map;
}
isl_token_free(tok2);
return NULL;
}
- qp = isl_qpolynomial_rat_cst(isl_map_get_dim(map),
+ qp = isl_qpolynomial_rat_cst_on_domain(isl_map_get_space(map),
tok->u.v, tok2->u.v);
isl_token_free(tok2);
} else {
isl_stream_push_token(s, tok2);
- qp = isl_qpolynomial_cst(isl_map_get_dim(map),
+ qp = isl_qpolynomial_cst_on_domain(isl_map_get_space(map),
tok->u.v);
}
isl_token_free(tok);
} else if (tok->type == ISL_TOKEN_INFTY) {
isl_qpolynomial *qp;
isl_token_free(tok);
- qp = isl_qpolynomial_infty(isl_map_get_dim(map));
+ qp = isl_qpolynomial_infty_on_domain(isl_map_get_space(map));
pwqp = isl_pw_qpolynomial_from_qpolynomial(qp);
} else if (tok->type == ISL_TOKEN_NAN) {
isl_qpolynomial *qp;
isl_token_free(tok);
- qp = isl_qpolynomial_nan(isl_map_get_dim(map));
+ qp = isl_qpolynomial_nan_on_domain(isl_map_get_space(map));
pwqp = isl_pw_qpolynomial_from_qpolynomial(qp);
} else if (tok->type == ISL_TOKEN_IDENT) {
int n = v->n;
}
isl_token_free(tok);
pow = optional_power(s);
- qp = isl_qpolynomial_var_pow(isl_map_get_dim(map), pos, pow);
+ qp = isl_qpolynomial_var_pow_on_domain(isl_map_get_space(map), pos, pow);
pwqp = isl_pw_qpolynomial_from_qpolynomial(qp);
} else if (tok->type == '[') {
isl_pw_aff *pwaff;
int pow;
isl_stream_push_token(s, tok);
- pwaff = accept_affine(s, isl_map_get_dim(map), v);
+ pwaff = accept_affine(s, isl_map_get_space(map), v);
pow = optional_power(s);
pwqp = isl_pw_qpolynomial_from_pw_aff(pwaff);
pwqp = isl_pw_qpolynomial_pow(pwqp, pow);
}
static struct isl_obj obj_read_poly_or_fold(struct isl_stream *s,
- __isl_take isl_map *map, struct vars *v, int n)
+ __isl_take isl_set *set, struct vars *v, int n)
{
struct isl_obj obj = { isl_obj_pw_qpolynomial_fold, NULL };
isl_pw_qpolynomial *pwqp;
isl_pw_qpolynomial_fold *pwf = NULL;
- isl_set *set;
if (!isl_stream_eat_if_available(s, ISL_TOKEN_MAX))
- return obj_read_poly(s, map, v, n);
+ return obj_read_poly(s, set, v, n);
if (isl_stream_eat(s, '('))
goto error;
- pwqp = read_term(s, map, v);
+ pwqp = read_term(s, set, v);
pwf = isl_pw_qpolynomial_fold_from_pw_qpolynomial(isl_fold_max, pwqp);
while (isl_stream_eat_if_available(s, ',')) {
isl_pw_qpolynomial_fold *pwf_i;
- pwqp = read_term(s, map, v);
+ pwqp = read_term(s, set, v);
pwf_i = isl_pw_qpolynomial_fold_from_pw_qpolynomial(isl_fold_max,
pwqp);
pwf = isl_pw_qpolynomial_fold_fold(pwf, pwf_i);
if (isl_stream_eat(s, ')'))
goto error;
- map = read_optional_disjuncts(s, map, v);
- set = isl_map_range(map);
+ set = read_optional_disjuncts(s, set, v);
pwf = isl_pw_qpolynomial_fold_intersect_domain(pwf, set);
vars_drop(v, v->n - n);
obj.v = pwf;
return obj;
error:
- isl_map_free(map);
+ isl_set_free(set);
isl_pw_qpolynomial_fold_free(pwf);
obj.type = isl_obj_none;
return obj;
if (is_rational(s))
map = isl_map_set_rational(map);
+ if (isl_stream_next_token_is(s, ':')) {
+ obj.type = isl_obj_set;
+ obj.v = read_optional_disjuncts(s, map, v);
+ return obj;
+ }
+
if (!next_is_tuple(s))
return obj_read_poly_or_fold(s, map, v, n);
obj.type = isl_obj_map;
isl_token_free(tok);
if (!next_is_tuple(s)) {
- map = isl_map_reverse(map);
- return obj_read_poly_or_fold(s, map, v, n);
+ isl_set *set = isl_map_domain(map);
+ return obj_read_poly_or_fold(s, set, v, n);
}
map = read_tuple(s, map, isl_dim_out, v);
if (!map)
obj2.type == isl_obj_pw_qpolynomial_fold)
obj2 = to_union(ctx, obj2);
isl_assert(ctx, obj1.type == obj2.type, goto error);
- if (obj1.type == isl_obj_map && !isl_map_has_equal_dim(obj1.v, obj2.v)) {
+ if (obj1.type == isl_obj_map && !isl_map_has_equal_space(obj1.v, obj2.v)) {
obj1 = to_union(ctx, obj1);
obj2 = to_union(ctx, obj2);
}
- if (obj1.type == isl_obj_set && !isl_set_has_equal_dim(obj1.v, obj2.v)) {
+ if (obj1.type == isl_obj_set && !isl_set_has_equal_space(obj1.v, obj2.v)) {
obj1 = to_union(ctx, obj1);
obj2 = to_union(ctx, obj2);
}
if (obj1.type == isl_obj_pw_qpolynomial &&
- !isl_pw_qpolynomial_has_equal_dim(obj1.v, obj2.v)) {
+ !isl_pw_qpolynomial_has_equal_space(obj1.v, obj2.v)) {
obj1 = to_union(ctx, obj1);
obj2 = to_union(ctx, obj2);
}
if (obj1.type == isl_obj_pw_qpolynomial_fold &&
- !isl_pw_qpolynomial_fold_has_equal_dim(obj1.v, obj2.v)) {
+ !isl_pw_qpolynomial_fold_has_equal_space(obj1.v, obj2.v)) {
obj1 = to_union(ctx, obj1);
obj2 = to_union(ctx, obj2);
}
return obj1;
}
-static struct isl_obj obj_read(struct isl_stream *s, int nparam)
+static struct isl_obj obj_read(struct isl_stream *s)
{
isl_map *map = NULL;
struct isl_token *tok;
}
isl_stream_push_token(s, tok2);
isl_stream_push_token(s, tok);
- map = map_read_polylib(s, nparam);
+ map = map_read_polylib(s);
if (!map)
goto error;
- if (isl_map_dim(map, isl_dim_in) > 0)
+ if (isl_map_may_be_set(map))
+ obj.v = isl_map_range(map);
+ else {
obj.type = isl_obj_map;
- obj.v = map;
+ obj.v = map;
+ }
return obj;
}
v = vars_new(s->ctx);
isl_stream_push_token(s, tok);
goto error;
}
- map = isl_map_universe(isl_dim_alloc(s->ctx, 0, 0, 0));
+ map = isl_map_universe(isl_space_params_alloc(s->ctx, 0));
if (tok->type == '[') {
isl_stream_push_token(s, tok);
map = read_tuple(s, map, isl_dim_param, v);
if (!map)
goto error;
- if (nparam >= 0)
- isl_assert(s->ctx, nparam == v->n, goto error);
tok = isl_stream_next_token(s);
if (!tok || tok->type != ISL_TOKEN_TO) {
isl_stream_error(s, tok, "expecting '->'");
}
isl_token_free(tok);
tok = isl_stream_next_token(s);
- } else if (nparam > 0)
- map = isl_map_add_dims(map, isl_dim_param, nparam);
+ }
if (!tok || tok->type != '{') {
isl_stream_error(s, tok, "expecting '{'");
if (tok)
map = read_tuple(s, map, isl_dim_param, v);
if (!map)
goto error;
- if (nparam >= 0)
- isl_assert(s->ctx, nparam == v->n, goto error);
} else if (tok->type == '}') {
obj.type = isl_obj_union_set;
- obj.v = isl_union_set_empty(isl_map_get_dim(map));
+ obj.v = isl_union_set_empty(isl_map_get_space(map));
isl_token_free(tok);
goto done;
} else
struct isl_obj isl_stream_read_obj(struct isl_stream *s)
{
- return obj_read(s, -1);
+ return obj_read(s);
}
-__isl_give isl_map *isl_stream_read_map(struct isl_stream *s, int nparam)
+__isl_give isl_map *isl_stream_read_map(struct isl_stream *s)
{
struct isl_obj obj;
- obj = obj_read(s, nparam);
+ obj = obj_read(s);
if (obj.v)
isl_assert(s->ctx, obj.type == isl_obj_map ||
obj.type == isl_obj_set, goto error);
return NULL;
}
-__isl_give isl_set *isl_stream_read_set(struct isl_stream *s, int nparam)
+__isl_give isl_set *isl_stream_read_set(struct isl_stream *s)
{
struct isl_obj obj;
- obj = obj_read(s, nparam);
- if (obj.v)
+ obj = obj_read(s);
+ if (obj.v) {
+ if (obj.type == isl_obj_map && isl_map_may_be_set(obj.v)) {
+ obj.v = isl_map_range(obj.v);
+ obj.type = isl_obj_set;
+ }
isl_assert(s->ctx, obj.type == isl_obj_set, goto error);
+ }
return obj.v;
error:
{
struct isl_obj obj;
- obj = obj_read(s, -1);
+ obj = obj_read(s);
if (obj.type == isl_obj_map) {
obj.type = isl_obj_union_map;
obj.v = isl_union_map_from_map(obj.v);
{
struct isl_obj obj;
- obj = obj_read(s, -1);
+ obj = obj_read(s);
if (obj.type == isl_obj_set) {
obj.type = isl_obj_union_set;
obj.v = isl_union_set_from_set(obj.v);
return NULL;
}
-static struct isl_basic_map *basic_map_read(struct isl_stream *s, int nparam)
+static __isl_give isl_basic_map *basic_map_read(struct isl_stream *s)
{
struct isl_obj obj;
struct isl_map *map;
struct isl_basic_map *bmap;
- obj = obj_read(s, nparam);
+ obj = obj_read(s);
map = obj.v;
if (!map)
return NULL;
return NULL;
}
+static __isl_give isl_basic_set *basic_set_read(struct isl_stream *s)
+{
+ isl_basic_map *bmap;
+ bmap = basic_map_read(s);
+ if (!bmap)
+ return NULL;
+ if (!isl_basic_map_may_be_set(bmap))
+ isl_die(s->ctx, isl_error_invalid,
+ "input is not a set", goto error);
+ return isl_basic_map_range(bmap);
+error:
+ isl_basic_map_free(bmap);
+ return NULL;
+}
+
__isl_give isl_basic_map *isl_basic_map_read_from_file(isl_ctx *ctx,
- FILE *input, int nparam)
+ FILE *input)
{
struct isl_basic_map *bmap;
struct isl_stream *s = isl_stream_new_file(ctx, input);
if (!s)
return NULL;
- bmap = basic_map_read(s, nparam);
+ bmap = basic_map_read(s);
isl_stream_free(s);
return bmap;
}
__isl_give isl_basic_set *isl_basic_set_read_from_file(isl_ctx *ctx,
- FILE *input, int nparam)
+ FILE *input)
{
- struct isl_basic_map *bmap;
- bmap = isl_basic_map_read_from_file(ctx, input, nparam);
- if (!bmap)
+ isl_basic_set *bset;
+ struct isl_stream *s = isl_stream_new_file(ctx, input);
+ if (!s)
return NULL;
- isl_assert(ctx, isl_basic_map_n_in(bmap) == 0, goto error);
- return (struct isl_basic_set *)bmap;
-error:
- isl_basic_map_free(bmap);
- return NULL;
+ bset = basic_set_read(s);
+ isl_stream_free(s);
+ return bset;
}
struct isl_basic_map *isl_basic_map_read_from_str(struct isl_ctx *ctx,
- const char *str, int nparam)
+ const char *str)
{
struct isl_basic_map *bmap;
struct isl_stream *s = isl_stream_new_str(ctx, str);
if (!s)
return NULL;
- bmap = basic_map_read(s, nparam);
+ bmap = basic_map_read(s);
isl_stream_free(s);
return bmap;
}
struct isl_basic_set *isl_basic_set_read_from_str(struct isl_ctx *ctx,
- const char *str, int nparam)
+ const char *str)
{
- struct isl_basic_map *bmap;
- bmap = isl_basic_map_read_from_str(ctx, str, nparam);
- if (!bmap)
+ isl_basic_set *bset;
+ struct isl_stream *s = isl_stream_new_str(ctx, str);
+ if (!s)
return NULL;
- isl_assert(ctx, isl_basic_map_n_in(bmap) == 0, goto error);
- return (struct isl_basic_set *)bmap;
-error:
- isl_basic_map_free(bmap);
- return NULL;
+ bset = basic_set_read(s);
+ isl_stream_free(s);
+ return bset;
}
__isl_give isl_map *isl_map_read_from_file(struct isl_ctx *ctx,
- FILE *input, int nparam)
+ FILE *input)
{
struct isl_map *map;
struct isl_stream *s = isl_stream_new_file(ctx, input);
if (!s)
return NULL;
- map = isl_stream_read_map(s, nparam);
+ map = isl_stream_read_map(s);
isl_stream_free(s);
return map;
}
__isl_give isl_map *isl_map_read_from_str(struct isl_ctx *ctx,
- const char *str, int nparam)
+ const char *str)
{
struct isl_map *map;
struct isl_stream *s = isl_stream_new_str(ctx, str);
if (!s)
return NULL;
- map = isl_stream_read_map(s, nparam);
+ map = isl_stream_read_map(s);
isl_stream_free(s);
return map;
}
__isl_give isl_set *isl_set_read_from_file(struct isl_ctx *ctx,
- FILE *input, int nparam)
+ FILE *input)
{
- struct isl_map *map;
- map = isl_map_read_from_file(ctx, input, nparam);
- if (!map)
+ isl_set *set;
+ struct isl_stream *s = isl_stream_new_file(ctx, input);
+ if (!s)
return NULL;
- isl_assert(ctx, isl_map_n_in(map) == 0, goto error);
- return (struct isl_set *)map;
-error:
- isl_map_free(map);
- return NULL;
+ set = isl_stream_read_set(s);
+ isl_stream_free(s);
+ return set;
}
struct isl_set *isl_set_read_from_str(struct isl_ctx *ctx,
- const char *str, int nparam)
+ const char *str)
{
- struct isl_map *map;
- map = isl_map_read_from_str(ctx, str, nparam);
- if (!map)
+ isl_set *set;
+ struct isl_stream *s = isl_stream_new_str(ctx, str);
+ if (!s)
return NULL;
- isl_assert(ctx, isl_map_n_in(map) == 0, goto error);
- return (struct isl_set *)map;
-error:
- isl_map_free(map);
- return NULL;
+ set = isl_stream_read_set(s);
+ isl_stream_free(s);
+ return set;
}
__isl_give isl_union_map *isl_union_map_read_from_file(isl_ctx *ctx,
{
struct isl_obj obj;
- obj = obj_read(s, -1);
+ obj = obj_read(s);
if (obj.v)
isl_assert(s->ctx, obj.type == isl_obj_pw_qpolynomial,
goto error);