added is_type_complex()
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Fri, 12 Sep 2008 22:54:57 +0000 (22:54 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Fri, 12 Sep 2008 22:54:57 +0000 (22:54 +0000)
[r21917]

type.c
type.h

diff --git a/type.c b/type.c
index bd8b50c..f5a98e1 100644 (file)
--- a/type.c
+++ b/type.c
@@ -828,6 +828,22 @@ bool is_type_float(const type_t *type)
        return test_atomic_type_flag(type->atomic.akind, ATOMIC_TYPE_FLAG_FLOAT);
 }
 
+/**
+ * Returns true if the given type is an complex type.
+ *
+ * @param type  The type to check.
+ * @return True if type is a complex type.
+ */
+bool is_type_complex(const type_t *type)
+{
+       assert(!is_typeref(type));
+
+       if (type->kind != TYPE_ATOMIC)
+               return false;
+
+       return test_atomic_type_flag(type->atomic.akind, ATOMIC_TYPE_FLAG_COMPLEX);
+}
+
 /**
  * Returns true if the given type is a signed type.
  *
diff --git a/type.h b/type.h
index 1e6f13b..fd039a7 100644 (file)
--- a/type.h
+++ b/type.h
@@ -132,6 +132,11 @@ bool is_type_signed(const type_t *type);
  */
 bool is_type_float(const type_t *type);
 
+/**
+ * returns true if type contains complex numbers
+ */
+bool is_type_complex(const type_t *type);
+
 bool is_type_real(const type_t *type);
 
 /**