add isl_token_get_val
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 9 Apr 2013 13:56:10 +0000 (15:56 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 28 May 2013 18:42:48 +0000 (20:42 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
include/isl/stream.h
isl_stream.c

index 3706bcd..58c03cc 100644 (file)
@@ -14,6 +14,7 @@
 #include <isl/hash.h>
 #include <isl/aff_type.h>
 #include <isl/obj.h>
+#include <isl/val.h>
 
 #if defined(__cplusplus)
 extern "C" {
@@ -52,6 +53,7 @@ struct isl_token {
        } u;
 };
 
+__isl_give isl_val *isl_token_get_val(isl_ctx *ctx, struct isl_token *tok);
 void isl_token_free(struct isl_token *tok);
 
 struct isl_stream {
index 68f6e52..7ead411 100644 (file)
@@ -14,6 +14,7 @@
 #include <isl_stream_private.h>
 #include <isl/map.h>
 #include <isl/aff.h>
+#include <isl_val_private.h>
 
 struct isl_keyword {
        char                    *name;
@@ -80,6 +81,19 @@ struct isl_token *isl_token_new(isl_ctx *ctx,
        return tok;
 }
 
+/* Given a token of type ISL_TOKEN_VALUE, return the value it represents.
+ */
+__isl_give isl_val *isl_token_get_val(isl_ctx *ctx, struct isl_token *tok)
+{
+       if (!tok)
+               return NULL;
+       if (tok->type != ISL_TOKEN_VALUE)
+               isl_die(ctx, isl_error_invalid, "not a value token",
+                       return NULL);
+
+       return isl_val_int_from_isl_int(ctx, tok->u.v);
+}
+
 void isl_token_free(struct isl_token *tok)
 {
        if (!tok)