changed __functions into more comfrom _functions
[libfirm] / ir / tr / type.c
index 77d7307..b913925 100644 (file)
@@ -348,6 +348,18 @@ set_type_alignment_bytes(type *tp, int align) {
   set_type_size_bits(tp, 8*align);
 }
 
+/* Returns a human readable string for the enum entry. */
+const char *get_type_state_name(type_state s) {
+#define X(a)    case a: return #a;
+  switch (s) {
+    X(layout_undefined);
+    X(layout_fixed);
+  }
+  return "<unknown>";
+#undef X
+}
+
+
 type_state (get_type_state)(const type *tp) {
   return _get_type_state(tp);
 }
@@ -914,21 +926,6 @@ int (is_Class_type)(const type *clss) {
   return _is_class_type(clss);
 }
 
-/* Returns true if low is subclass of high. */
-int is_subclass_of(type *low, type *high) {
-  int i;
-  assert(is_Class_type(low) && is_Class_type(high));
-  if (low == high) return 1;
-  /* depth first search from high downwards. */
-  for (i = 0; i < get_class_n_subtypes(high); i++) {
-    if (low == get_class_subtype(high, i))
-      return 1;
-    if (is_subclass_of(low, get_class_subtype(high, i)))
-      return 1;
-  }
-  return 0;
-}
-
 /*----------------------------------------------------------------**/
 /* TYPE_STRUCT                                                     */
 /*----------------------------------------------------------------**/
@@ -1341,8 +1338,7 @@ int (is_Union_type)(const type *uni) {
 
 
 /* create a new type array -- set dimension sizes independently */
-type *new_type_array         (ident *name, int n_dimensions,
-                  type *element_type) {
+type *new_type_array(ident *name, int n_dimensions, type *element_type) {
   type *res;
   int i;
   ir_graph *rem = current_ir_graph;
@@ -1356,9 +1352,9 @@ type *new_type_array         (ident *name, int n_dimensions,
 
   current_ir_graph = get_const_code_irg();
   for (i = 0; i < n_dimensions; i++) {
-    res->attr.aa.lower_bound[i]  = new_Unknown(mode_Iu);
-    res->attr.aa.upper_bound[i]  = new_Unknown(mode_Iu);
-    res->attr.aa.order[i] = i;
+    res->attr.aa.lower_bound[i] = new_Unknown(mode_Iu);
+    res->attr.aa.upper_bound[i] = new_Unknown(mode_Iu);
+    res->attr.aa.order[i]       = i;
   }
   current_ir_graph = rem;
 
@@ -1472,11 +1468,24 @@ void set_array_order (type *array, int dimension, int order) {
   assert(array && (array->type_op == type_array));
   array->attr.aa.order[dimension] = order;
 }
+
 int  get_array_order (const type *array, int dimension) {
   assert(array && (array->type_op == type_array));
   return array->attr.aa.order[dimension];
 }
 
+int find_array_dimension(const type *array, int order) {
+  int dim;
+
+  assert(array && (array->type_op == type_array));
+
+  for (dim = 0; dim < array->attr.aa.n_dimensions; ++dim) {
+    if (array->attr.aa.order[dim] == order)
+      return dim;
+  }
+  return -1;
+}
+
 void  set_array_element_type (type *array, type *tp) {
   assert(array && (array->type_op == type_array));
   assert(!is_Method_type(tp));