#include <isl/ast.h>
int isl_ast_expr_get_int(__isl_keep isl_ast_expr *expr,
isl_int *v);
+ __isl_give isl_val *isl_ast_expr_get_val(
+ __isl_keep isl_ast_expr *expr);
Return the integer represented by the AST expression.
-Note that the integer is returned through the C<v> argument.
-The return value of the function itself indicates whether the
+Note that the integer is returned by C<isl_ast_expr_get_int>
+through the C<v> argument.
+The return value of this function itself indicates whether the
operation was performed successfully.
=head3 Manipulating and printing the AST
#include <isl/ctx.h>
#include <isl/id.h>
+#include <isl/val.h>
#include <isl/list.h>
#include <isl/printer.h>
isl_ctx *isl_ast_expr_get_ctx(__isl_keep isl_ast_expr *expr);
enum isl_ast_expr_type isl_ast_expr_get_type(__isl_keep isl_ast_expr *expr);
int isl_ast_expr_get_int(__isl_keep isl_ast_expr *expr, isl_int *v);
+__isl_give isl_val *isl_ast_expr_get_val(__isl_keep isl_ast_expr *expr);
__isl_give isl_id *isl_ast_expr_get_id(__isl_keep isl_ast_expr *expr);
enum isl_ast_op_type isl_ast_expr_get_op_type(__isl_keep isl_ast_expr *expr);
#include <isl_ast_private.h>
+#include <isl/val_int.h>
#undef BASE
#define BASE ast_expr
return 0;
}
+/* Return the integer value represented by "expr".
+ */
+__isl_give isl_val *isl_ast_expr_get_val(__isl_keep isl_ast_expr *expr)
+{
+ isl_ctx *ctx;
+
+ if (!expr)
+ return NULL;
+ ctx = isl_ast_expr_get_ctx(expr);
+ if (expr->type != isl_ast_expr_int)
+ isl_die(ctx, isl_error_invalid,
+ "expression not an int", return NULL);
+ return isl_val_int_from_isl_int(ctx, expr->u.i);
+}
+
__isl_give isl_id *isl_ast_expr_get_id(__isl_keep isl_ast_expr *expr)
{
if (!expr)