comments, freeing routine
[libfirm] / ir / tr / type.c
index 1402ec9..19bb13e 100644 (file)
@@ -86,12 +86,13 @@ void init_type(void) {
 }
 
 unsigned long type_visited;
-INLINE void set_master_type_visited(unsigned long val) { type_visited = val; }
-INLINE unsigned long get_master_type_visited() { return type_visited; }
-INLINE void inc_master_type_visited() { type_visited++; }
 
+void (set_master_type_visited)(unsigned long val) { __set_master_type_visited(val); }
+unsigned long (get_master_type_visited)(void)     { return __get_master_type_visited(); }
+void (inc_master_type_visited)(void)              { __inc_master_type_visited(); }
 
-INLINE type *
+
+type *
 new_type(tp_op *type_op, ir_mode *mode, ident* name) {
   type *res;
   int node_size ;
@@ -162,26 +163,22 @@ void free_type_attrs(type *tp) {
 }
 
 /* set/get the link field */
-void *get_type_link(type *tp)
+void *(get_type_link)(type *tp)
 {
-  assert(tp && tp->kind == k_type);
-  return(tp -> link);
+  return __get_type_link(tp);
 }
 
-void set_type_link(type *tp, void *l)
+void (set_type_link)(type *tp, void *l)
 {
-  assert(tp && tp->kind == k_type);
-  tp -> link = l;
+  __set_type_link(tp, l);
 }
 
-tp_op*      get_type_tpop(type *tp) {
-  assert(tp && tp->kind == k_type);
-  return tp->type_op;
+tp_op *(get_type_tpop)(type *tp) {
+  return __get_type_tpop(tp);
 }
 
-ident*      get_type_tpop_nameid(type *tp) {
-  assert(tp && tp->kind == k_type);
-  return tp->type_op->name;
+ident *(get_type_tpop_nameid)(type *tp) {
+  return __get_type_tpop_nameid(tp);
 }
 
 const char* get_type_tpop_name(type *tp) {
@@ -189,14 +186,12 @@ const char* get_type_tpop_name(type *tp) {
   return get_id_str(tp->type_op->name);
 }
 
-tp_opcode    get_type_tpop_code(type *tp) {
-  assert(tp && tp->kind == k_type);
-  return tp->type_op->code;
+tp_opcode (get_type_tpop_code)(type *tp) {
+  return __get_type_tpop_code(tp);
 }
 
-ir_mode*    get_type_mode(type *tp) {
-  assert(tp && tp->kind == k_type);
-  return tp->mode;
+ir_mode *(get_type_mode)(type *tp) {
+  return __get_type_mode(tp);
 }
 
 void        set_type_mode(type *tp, ir_mode* m) {
@@ -219,25 +214,17 @@ void        set_type_mode(type *tp, ir_mode* m) {
   }
 }
 
-ident*      get_type_ident(type *tp) {
-  assert(tp && tp->kind == k_type);
-  return tp->name;
+ident *(get_type_ident)(type *tp) {
+  return __get_type_ident(tp);
 }
 
-void        set_type_ident(type *tp, ident* id) {
-  assert(tp && tp->kind == k_type);
-  tp->name = id;
+void (set_type_ident)(type *tp, ident* id) {
+  __set_type_ident(tp, id);
 }
 
 /* Outputs a unique number for this node */
-INLINE long
-get_type_nr(type *tp) {
-  assert(tp);
-#ifdef DEBUG_libfirm
-  return tp->nr;
-#else
-  return (long)tp;
-#endif
+long (get_type_nr)(type *tp) {
+  return __get_type_nr(tp);
 }
 
 const char* get_type_name(type *tp) {
@@ -245,9 +232,8 @@ const char* get_type_name(type *tp) {
   return (get_id_str(tp->name));
 }
 
-int         get_type_size(type *tp) {
-  assert(tp && tp->kind == k_type);
-  return tp->size;
+int (get_type_size)(type *tp) {
+  return __get_type_size(tp);
 }
 
 void
@@ -260,10 +246,8 @@ set_type_size(type *tp, int size) {
     tp->size = size;
 }
 
-type_state
-get_type_state(type *tp) {
-  assert(tp && tp->kind == k_type);
-  return tp->state;
+type_state (get_type_state)(type *tp) {
+  return __get_type_state(tp);
 }
 
 void
@@ -320,40 +304,31 @@ set_type_state(type *tp, type_state state) {
   tp->state = state;
 }
 
-unsigned long get_type_visited(type *tp) {
-  assert(tp && tp->kind == k_type);
-  return tp->visit;
+unsigned long (get_type_visited)(type *tp) {
+  return __get_type_visited(tp);
 }
 
-void        set_type_visited(type *tp, unsigned long num) {
-  assert(tp && tp->kind == k_type);
-  tp->visit = num;
+void (set_type_visited)(type *tp, unsigned long num) {
+  __set_type_visited(tp, num);
 }
+
 /* Sets visited field in type to type_visited. */
-void        mark_type_visited(type *tp) {
-  assert(tp && tp->kind == k_type);
-  assert(tp->visit < type_visited);
-  tp->visit = type_visited;
-}
-/* @@@ name clash with master flag
-bool          type_visited(type *tp) {
-  assert(tp && tp->kind == k_type);
-  return tp->visit >= type_visited;
-  }*/
-bool          type_not_visited(type *tp) {
-  assert(tp && tp->kind == k_type);
-  return tp->visit  < type_visited;
+void (mark_type_visited)(type *tp) {
+  __mark_type_visited(tp);
 }
 
+/* @@@ name clash with master flag
+int (type_visited)(type *tp) {
+  return __type_visited(tp);
+}*/
 
-int is_type            (void *thing) {
-  assert(thing);
-  if (get_kind(thing) == k_type)
-    return 1;
-  else
-    return 0;
+int (type_not_visited)(type *tp) {
+  return __type_not_visited(tp);
 }
 
+int (is_type)(void *thing) {
+  return __is_type(thing);
+}
 
 bool equal_type(type *typ1, type *typ2) {
   entity **m;
@@ -432,10 +407,23 @@ bool equal_type(type *typ1, type *typ2) {
     }
   } break;
   case tpo_method:      {
+    int n_param1, n_param2;
+
     if (get_method_variadicity(typ1) != get_method_variadicity(typ2)) return false;
-    if (get_method_n_params(typ1) != get_method_n_params(typ2)) return false;
-    if (get_method_n_ress(typ1) != get_method_n_ress(typ2)) return false;
-    for (i = 0; i < get_method_n_params(typ1); i++) {
+    if (get_method_n_ress(typ1)      != get_method_n_ress(typ2)) return false;
+
+    if (get_method_variadicity(typ1) == variadicity_non_variadic) {
+      n_param1 = get_method_n_params(typ1);
+      n_param2 = get_method_n_params(typ2);
+    }
+    else {
+      n_param1 = get_method_first_variadic_param_index(typ1);
+      n_param2 = get_method_first_variadic_param_index(typ2);
+    }
+
+    if (n_param1 != n_param2) return false;
+
+    for (i = 0; i < n_param1; i++) {
       if (!equal_type(get_method_param_type(typ1, i), get_method_param_type(typ2, i)))
        return false;
     }
@@ -524,6 +512,7 @@ bool smaller_type (type *st, type *lt) {
     }
   } break;
   case tpo_method:      {
+    /** FIXME: is this still true? */
     if (get_method_variadicity(st) != get_method_variadicity(lt)) return false;
     if (get_method_n_params(st) != get_method_n_params(lt)) return false;
     if (get_method_n_ress(st) != get_method_n_ress(lt)) return false;
@@ -600,12 +589,12 @@ bool smaller_type (type *st, type *lt) {
   return true;
 }
 
-/*******************************************************************/
-/** TYPE_CLASS                                                    **/
-/*******************************************************************/
+/*-----------------------------------------------------------------*/
+/* TYPE_CLASS                                                      */
+/*-----------------------------------------------------------------*/
 
 /* create a new class type */
-INLINE type   *new_type_class (ident *name) {
+type   *new_type_class (ident *name) {
   type *res;
 
   res = new_type(type_class, NULL, name);
@@ -624,14 +613,14 @@ type   *new_d_type_class (ident *name, dbg_info* db) {
   return res;
 }
 
-INLINE void free_class_entities(type *clss) {
+void free_class_entities(type *clss) {
   int i;
   assert(clss && (clss->type_op == type_class));
   for (i = get_class_n_members(clss)-1; i >= 0; --i)
     free_entity(get_class_member(clss, i));
 }
 
-INLINE void free_class_attrs(type *clss) {
+void free_class_attrs(type *clss) {
   assert(clss && (clss->type_op == type_class));
   DEL_ARR_F(clss->attr.ca.members);
   DEL_ARR_F(clss->attr.ca.subtypes);
@@ -643,10 +632,12 @@ void    add_class_member   (type *clss, entity *member) {
   assert(clss && (clss->type_op == type_class));
   ARR_APP1 (entity *, clss->attr.ca.members, member);
 }
+
 int     get_class_n_members (type *clss) {
   assert(clss && (clss->type_op == type_class));
   return (ARR_LEN (clss->attr.ca.members))-1;
 }
+
 int     get_class_member_index(type *clss, entity *mem) {
   int i;
   assert(clss && (clss->type_op == type_class));
@@ -655,11 +646,13 @@ int     get_class_member_index(type *clss, entity *mem) {
       return i;
   return -1;
 }
+
 entity *get_class_member   (type *clss, int pos) {
   assert(clss && (clss->type_op == type_class));
   assert(pos >= 0 && pos < get_class_n_members(clss));
   return clss->attr.ca.members[pos+1];
 }
+
 entity *get_class_member_by_name(type *clss, ident *name) {
   int i, n_mem;
   assert(clss && (clss->type_op == type_class));
@@ -789,11 +782,11 @@ char *get_peculiarity_string(peculiarity p) {
   return "peculiarity_existent";
 }
 
-INLINE peculiarity get_class_peculiarity (type *clss) {
+peculiarity get_class_peculiarity (type *clss) {
   assert(clss && (clss->type_op == type_class));
   return clss->attr.ca.peculiarity;
 }
-INLINE void        set_class_peculiarity (type *clss, peculiarity pec) {
+void        set_class_peculiarity (type *clss, peculiarity pec) {
   assert(clss && (clss->type_op == type_class));
   assert(pec != peculiarity_inherited);  /* There is no inheritance of types in libFirm. */
   clss->attr.ca.peculiarity = pec;
@@ -810,9 +803,8 @@ int get_class_dfn (type *clss)
 }
 
 /* typecheck */
-bool    is_class_type(type *clss) {
-  assert(clss);
-  if (clss->type_op == type_class) return 1; else return 0;
+int (is_class_type)(type *clss) {
+  return __is_class_type(clss);
 }
 
 bool is_subclass_of(type *low, type *high) {
@@ -829,12 +821,12 @@ bool is_subclass_of(type *low, type *high) {
   return false;
 }
 
-/*******************************************************************/
-/** TYPE_STRUCT                                                   **/
-/*******************************************************************/
+/*----------------------------------------------------------------**/
+/* TYPE_STRUCT                                                     */
+/*----------------------------------------------------------------**/
 
 /* create a new type struct */
-INLINE type   *new_type_struct (ident *name) {
+type   *new_type_struct (ident *name) {
   type *res;
   res = new_type(type_struct, NULL, name);
   res->attr.sa.members = NEW_ARR_F (entity *, 1);
@@ -845,13 +837,13 @@ type   *new_d_type_struct (ident *name, dbg_info* db) {
   set_type_dbg_info(res, db);
   return res;
 }
-INLINE void free_struct_entities (type *strct) {
+void free_struct_entities (type *strct) {
   int i;
   assert(strct && (strct->type_op == type_struct));
   for (i = get_struct_n_members(strct)-1; i >= 0; --i)
     free_entity(get_struct_member(strct, i));
 }
-INLINE void free_struct_attrs (type *strct) {
+void free_struct_attrs (type *strct) {
   assert(strct && (strct->type_op == type_struct));
   DEL_ARR_F(strct->attr.sa.members);
 }
@@ -861,17 +853,29 @@ int     get_struct_n_members (type *strct) {
   assert(strct && (strct->type_op == type_struct));
   return (ARR_LEN (strct->attr.sa.members))-1;
 }
+
 void    add_struct_member   (type *strct, entity *member) {
   assert(strct && (strct->type_op == type_struct));
   assert(get_type_tpop(get_entity_type(member)) != type_method);
     /*    @@@ lowerfirm geht nicht durch */
   ARR_APP1 (entity *, strct->attr.sa.members, member);
 }
+
 entity *get_struct_member   (type *strct, int pos) {
   assert(strct && (strct->type_op == type_struct));
   assert(pos >= 0 && pos < get_struct_n_members(strct));
   return strct->attr.sa.members[pos+1];
 }
+
+int     get_struct_member_index(type *strct, entity *mem) {
+  int i;
+  assert(strct && (strct->type_op == type_struct));
+  for (i = 0; i < get_struct_n_members(strct); i++)
+    if (get_struct_member(strct, i) == mem)
+      return i;
+  return -1;
+}
+
 void    set_struct_member   (type *strct, int pos, entity *member) {
   assert(strct && (strct->type_op == type_struct));
   assert(pos >= 0 && pos < get_struct_n_members(strct));
@@ -891,16 +895,23 @@ void    remove_struct_member(type *strct, entity *member) {
 }
 
 /* typecheck */
-bool    is_struct_type(type *strct) {
-  assert(strct);
-  if (strct->type_op == type_struct) return 1; else return 0;
+int (is_struct_type)(type *strct) {
+  return __is_struct_type(strct);
 }
 
 /*******************************************************************/
 /** TYPE_METHOD                                                   **/
 /*******************************************************************/
 
-/* Lazy construction of value argument / result representation. */
+/**
+ * Lazy construction of value argument / result representation.
+ * Constructs a struct type and its member.  The types of the members
+ * are passed in the argument list.
+ *
+ * @param name    name of the type constructed
+ * @param len     number of fields
+ * @param tps     array of field types with length len
+ */
 static INLINE type *
 build_value_type(ident *name, int len, type **tps) {
   int i;
@@ -917,19 +928,21 @@ build_value_type(ident *name, int len, type **tps) {
 
 /* Create a new method type.
    N_param is the number of parameters, n_res the number of results.  */
-INLINE type *new_type_method (ident *name, int n_param, int n_res) {
+type *new_type_method (ident *name, int n_param, int n_res) {
   type *res;
-  res = new_type(type_method, mode_P_mach, name);
-  res->state = layout_fixed;
+
   assert((get_mode_size_bytes(mode_P_mach) != -1) && "unorthodox modes not implemented");
-  res->size = get_mode_size_bytes(mode_P_mach);
-  res->attr.ma.n_params     = n_param;
-  res->attr.ma.param_type   = (type **) xmalloc (sizeof (type *) * n_param);
-  res->attr.ma.value_params = NULL;
-  res->attr.ma.n_res        = n_res;
-  res->attr.ma.res_type     = (type **) xmalloc (sizeof (type *) * n_res);
-  res->attr.ma.value_ress   = NULL;
-  res->attr.ma.variadicity  = variadicity_non_variadic;
+  res = new_type(type_method, mode_P_mach, name);
+  res->state                        = layout_fixed;
+  res->size                         = get_mode_size_bytes(mode_P_mach);
+  res->attr.ma.n_params             = n_param;
+  res->attr.ma.param_type           = (type **) xmalloc (sizeof (type *) * n_param);
+  res->attr.ma.value_params         = NULL;
+  res->attr.ma.n_res                = n_res;
+  res->attr.ma.res_type             = (type **) xmalloc (sizeof (type *) * n_res);
+  res->attr.ma.value_ress           = NULL;
+  res->attr.ma.variadicity          = variadicity_non_variadic;
+  res->attr.ma.first_variadic_param = -1;
 
   return res;
 }
@@ -940,11 +953,12 @@ type *new_d_type_method (ident *name, int n_param, int n_res, dbg_info* db) {
   return res;
 }
 
-INLINE void free_method_entities(type *method) {
+void free_method_entities(type *method) {
   assert(method && (method->type_op == type_method));
 }
+
 /* Attention: also frees entities in value parameter subtypes! */
-INLINE void free_method_attrs(type *method) {
+void free_method_attrs(type *method) {
   assert(method && (method->type_op == type_method));
   free(method->attr.ma.param_type);
   free(method->attr.ma.res_type);
@@ -963,6 +977,7 @@ int   get_method_n_params  (type *method) {
   assert(method && (method->type_op == type_method));
   return method->attr.ma.n_params;
 }
+
 type *get_method_param_type(type *method, int pos) {
   type *res;
   assert(method && (method->type_op == type_method));
@@ -971,6 +986,7 @@ type *get_method_param_type(type *method, int pos) {
   assert(res != NULL && "empty method param type");
   return method->attr.ma.param_type[pos] = skip_tid(res);
 }
+
 void  set_method_param_type(type *method, int pos, type* tp) {
   assert(method && (method->type_op == type_method));
   assert(pos >= 0 && pos < get_method_n_params(method));
@@ -981,6 +997,7 @@ void  set_method_param_type(type *method, int pos, type* tp) {
     set_entity_type(get_struct_member(method->attr.ma.value_params, pos), tp);
   }
 }
+
 /* Returns an entity that represents the copied value argument.  Only necessary
    for compounds passed by value. */
 entity *get_method_value_param_ent(type *method, int pos) {
@@ -996,16 +1013,20 @@ entity *get_method_value_param_ent(type *method, int pos) {
   return get_struct_member(method->attr.ma.value_params, pos);
 }
 
-type *get_method_value_res_type(type *method) {
+/*
+ * Returns a type that represents the copied value arguments.
+ */
+type *get_method_value_param_type(type *method)
+{
   assert(method && (method->type_op == type_method));
   return method->attr.ma.value_params;
 }
 
-
 int   get_method_n_ress   (type *method) {
   assert(method && (method->type_op == type_method));
   return method->attr.ma.n_res;
 }
+
 type *get_method_res_type(type *method, int pos) {
   type *res;
   assert(method && (method->type_op == type_method));
@@ -1014,6 +1035,7 @@ type *get_method_res_type(type *method, int pos) {
   assert(res != NULL && "empty method return type");
   return method->attr.ma.res_type[pos] = skip_tid(res);
 }
+
 void  set_method_res_type(type *method, int pos, type* tp) {
   assert(method && (method->type_op == type_method));
   assert(pos >= 0 && pos < get_method_n_ress(method));
@@ -1025,6 +1047,7 @@ void  set_method_res_type(type *method, int pos, type* tp) {
     set_entity_type(get_struct_member(method->attr.ma.value_ress, pos), tp);
   }
 }
+
 /* Returns an entity that represents the copied value result.  Only necessary
    for compounds passed by value. */
 entity *get_method_value_res_ent(type *method, int pos) {
@@ -1039,6 +1062,14 @@ entity *get_method_value_res_ent(type *method, int pos) {
   return get_struct_member(method->attr.ma.value_ress, pos);
 }
 
+/*
+ * Returns a type that represents the copied value results.
+ */
+type *get_method_value_res_type(type *method) {
+  assert(method && (method->type_op == type_method));
+  return method->attr.ma.value_ress;
+}
+
 /* Returns the null-terminated name of this variadicity. */
 const char *get_variadicity_name(variadicity vari)
 {
@@ -1064,18 +1095,49 @@ void set_method_variadicity(type *method, variadicity vari)
   method->attr.ma.variadicity = vari;
 }
 
+/*
+ * Returns the first variadic parameter index of a type.
+ * If this index was NOT set, the index of the last parameter
+ * of the method type plus one is returned for variadic functions.
+ * Non-variadic function types always return -1 here.
+ */
+int get_method_first_variadic_param_index(type *method)
+{
+  assert(method && (method->type_op == type_method));
+
+  if (method->attr.ma.variadicity == variadicity_non_variadic)
+    return -1;
+
+  if (method->attr.ma.first_variadic_param == -1)
+    return get_method_n_params(method);
+  return method->attr.ma.first_variadic_param;
+}
+
+/*
+ * Sets the first variadic parameter index. This allows to specify
+ * a complete call type (containing the type of all parameters)
+ * but still have the knowledge, which parameter must be passed as
+ * variadic one.
+ */
+void set_method_first_variadic_param_index(type *method, int index)
+{
+  assert(method && (method->type_op == type_method));
+  assert(index >= 0 && index <= get_method_n_params(method));
+
+  method->attr.ma.first_variadic_param = index;
+}
+
 /* typecheck */
-bool  is_method_type     (type *method) {
-  assert(method);
-  if (method->type_op == type_method) return 1; else return 0;
+int (is_method_type)(type *method) {
+  return __is_method_type(method);
 }
 
-/*******************************************************************/
-/** TYPE_UNION                                                    **/
-/*******************************************************************/
+/*-----------------------------------------------------------------*/
+/* TYPE_UNION                                                      */
+/*-----------------------------------------------------------------*/
 
 /* create a new type uni */
-INLINE type  *new_type_union (ident *name) {
+type  *new_type_union (ident *name) {
   type *res;
   res = new_type(type_union, NULL, name);
   /*res->attr.ua.unioned_type = (type **)  xmalloc (sizeof (type *)  * n_types);
@@ -1088,13 +1150,13 @@ type  *new_d_type_union (ident *name, dbg_info* db) {
   set_type_dbg_info(res, db);
   return res;
 }
-INLINE void free_union_entities (type *uni) {
+void free_union_entities (type *uni) {
   int i;
   assert(uni && (uni->type_op == type_union));
   for (i = get_union_n_members(uni)-1; i >= 0; --i)
     free_entity(get_union_member(uni, i));
 }
-INLINE void free_union_attrs (type *uni) {
+void free_union_attrs (type *uni) {
   assert(uni && (uni->type_op == type_union));
   DEL_ARR_F(uni->attr.ua.members);
 }
@@ -1161,18 +1223,17 @@ void   remove_union_member(type *uni, entity *member) {
 }
 
 /* typecheck */
-bool   is_union_type         (type *uni) {
-  assert(uni);
-  if (uni->type_op == type_union) return 1; else return 0;
+int (is_union_type)(type *uni) {
+  return __is_union_type(uni);
 }
 
-/*******************************************************************/
-/** TYPE_ARRAY                                                    **/
-/*******************************************************************/
+/*-----------------------------------------------------------------*/
+/* TYPE_ARRAY                                                      */
+/*-----------------------------------------------------------------*/
 
 
 /* create a new type array -- set dimension sizes independently */
-INLINE type *new_type_array         (ident *name, int n_dimensions,
+type *new_type_array         (ident *name, int n_dimensions,
                              type *element_type) {
   type *res;
   int i;
@@ -1198,6 +1259,7 @@ INLINE type *new_type_array         (ident *name, int n_dimensions,
 
   return res;
 }
+
 type *new_d_type_array (ident *name, int n_dimensions,
                        type *element_type, dbg_info* db) {
   type *res = new_type_array (name, n_dimensions, element_type);
@@ -1205,10 +1267,11 @@ type *new_d_type_array (ident *name, int n_dimensions,
   return res;
 }
 
-INLINE void free_array_entities (type *array) {
+void free_array_entities (type *array) {
   assert(array && (array->type_op == type_array));
 }
-INLINE void free_array_attrs (type *array) {
+
+void free_array_attrs (type *array) {
   assert(array && (array->type_op == type_array));
   free(array->attr.aa.lower_bound);
   free(array->attr.aa.upper_bound);
@@ -1220,7 +1283,7 @@ int   get_array_n_dimensions (type *array) {
   return array->attr.aa.n_dimensions;
 }
 
-INLINE void
+void
 set_array_bounds (type *array, int dimension, ir_node * lower_bound,
                  ir_node * upper_bound) {
   assert(array && (array->type_op == type_array));
@@ -1240,7 +1303,7 @@ set_array_bounds_int (type *array, int dimension, int lower_bound,
                    new_Const(mode_Iu, new_tarval_from_long (upper_bound, mode_Iu )));
   current_ir_graph = rem;
 }
-INLINE void
+void
 set_array_lower_bound  (type *array, int dimension, ir_node * lower_bound) {
   assert(array && (array->type_op == type_array));
   assert(lower_bound && "lower_bound node may not be NULL.");
@@ -1253,7 +1316,7 @@ void  set_array_lower_bound_int (type *array, int dimension, int lower_bound) {
                          new_Const(mode_Iu, new_tarval_from_long (lower_bound, mode_Iu)));
   current_ir_graph = rem;
 }
-INLINE void
+void
 set_array_upper_bound  (type *array, int dimension, ir_node * upper_bound) {
   assert(array && (array->type_op == type_array));
   assert(upper_bound && "upper_bound node may not be NULL.");
@@ -1314,17 +1377,16 @@ entity *get_array_element_entity (type *array) {
 }
 
 /* typecheck */
-bool   is_array_type         (type *array) {
-  assert(array);
-  if (array->type_op == type_array) return 1; else return 0;
+int (is_array_type)(type *array) {
+  return __is_array_type(array);
 }
 
-/*******************************************************************/
-/** TYPE_ENUMERATION                                              **/
-/*******************************************************************/
+/*-----------------------------------------------------------------*/
+/* TYPE_ENUMERATION                                                */
+/*-----------------------------------------------------------------*/
 
 /* create a new type enumeration -- set the enumerators independently */
-INLINE type   *new_type_enumeration    (ident *name, int n_enums) {
+type   *new_type_enumeration    (ident *name, int n_enums) {
   type *res;
   res = new_type(type_enumeration, NULL, name);
   res->attr.ea.n_enums     = n_enums;
@@ -1340,10 +1402,10 @@ type   *new_d_type_enumeration    (ident *name, int n_enums, dbg_info* db) {
   return res;
 }
 
-INLINE void free_enumeration_entities(type *enumeration) {
+void free_enumeration_entities(type *enumeration) {
   assert(enumeration && (enumeration->type_op == type_enumeration));
 }
-INLINE void free_enumeration_attrs(type *enumeration) {
+void free_enumeration_attrs(type *enumeration) {
   assert(enumeration && (enumeration->type_op == type_enumeration));
   free(enumeration->attr.ea.enumer);
   free(enumeration->attr.ea.enum_nameid);
@@ -1381,17 +1443,16 @@ const char *get_enumeration_name(type *enumeration, int pos) {
 }
 
 /* typecheck */
-bool    is_enumeration_type     (type *enumeration) {
-  assert(enumeration);
-  if (enumeration->type_op == type_enumeration) return 1; else return 0;
+int (is_enumeration_type)(type *enumeration) {
+  return __is_enumeration_type(enumeration);
 }
 
-/*******************************************************************/
-/** TYPE_POINTER                                                  **/
-/*******************************************************************/
+/*-----------------------------------------------------------------*/
+/* TYPE_POINTER                                                    */
+/*-----------------------------------------------------------------*/
 
 /* Create a new type pointer */
-INLINE type *new_type_pointer_mode (ident *name, type *points_to, ir_mode *ptr_mode) {
+type *new_type_pointer_mode (ident *name, type *points_to, ir_mode *ptr_mode) {
   type *res;
   assert(mode_is_reference(ptr_mode));
   res = new_type(type_pointer, ptr_mode, name);
@@ -1406,10 +1467,10 @@ type *new_d_type_pointer (ident *name, type *points_to, ir_mode *ptr_mode, dbg_i
   set_type_dbg_info(res, db);
   return res;
 }
-INLINE void free_pointer_entities (type *pointer) {
+void free_pointer_entities (type *pointer) {
   assert(pointer && (pointer->type_op == type_pointer));
 }
-INLINE void free_pointer_attrs (type *pointer) {
+void free_pointer_attrs (type *pointer) {
   assert(pointer && (pointer->type_op == type_pointer));
 }
 /* manipulate fields of type_pointer */
@@ -1423,9 +1484,8 @@ type *get_pointer_points_to_type (type *pointer) {
 }
 
 /* typecheck */
-bool  is_pointer_type            (type *pointer) {
-  assert(pointer);
-  if (pointer->type_op == type_pointer) return 1; else return 0;
+int (is_pointer_type)(type *pointer) {
+  return __is_pointer_type(pointer);
 }
 
 /* Returns the first pointer type that has as points_to tp.
@@ -1443,12 +1503,12 @@ type *find_pointer_type_to_type (type *tp) {
 
 
 
-/*******************************************************************/
-/** TYPE_PRIMITIVE                                                **/
-/*******************************************************************/
+/*-----------------------------------------------------------------*/
+/* TYPE_PRIMITIVE                                                  */
+/*-----------------------------------------------------------------*/
 
 /* create a new type primitive */
-INLINE type *new_type_primitive (ident *name, ir_mode *mode) {
+type *new_type_primitive (ident *name, ir_mode *mode) {
   type *res;
   /* @@@ assert( mode_is_data(mode) && (!mode_is_reference(mode))); */
   res = new_type(type_primitive, mode, name);
@@ -1462,28 +1522,25 @@ type *new_d_type_primitive (ident *name, ir_mode *mode, dbg_info* db) {
   set_type_dbg_info(res, db);
   return res;
 }
-INLINE void free_primitive_entities (type *primitive) {
+void free_primitive_entities (type *primitive) {
   assert(primitive && (primitive->type_op == type_primitive));
 }
-INLINE void free_primitive_attrs (type *primitive) {
+void free_primitive_attrs (type *primitive) {
   assert(primitive && (primitive->type_op == type_primitive));
 }
 
 /* typecheck */
-bool  is_primitive_type  (type *primitive) {
-  assert(primitive && primitive->kind == k_type);
-  if (primitive->type_op == type_primitive) return 1; else return 0;
+int (is_primitive_type)(type *primitive) {
+  return __is_primitive_type(primitive);
 }
 
-/*******************************************************************/
-/** common functionality                                          **/
-/*******************************************************************/
+/*-----------------------------------------------------------------*/
+/* common functionality                                            */
+/*-----------------------------------------------------------------*/
 
 
-INLINE int is_atomic_type(type *tp) {
-  assert(tp && tp->kind == k_type);
-  return (is_primitive_type(tp) || is_pointer_type(tp) ||
-         is_enumeration_type(tp));
+int (is_atomic_type)(type *tp) {
+  return __is_atomic_type(tp);
 }
 
 /*
@@ -1528,18 +1585,15 @@ entity *get_compound_member(type *tp, int pos)
 }
 
 
-INLINE int is_compound_type(type *tp) {
+int is_compound_type(type *tp) {
   assert(tp && tp->kind == k_type);
   return (is_class_type(tp) || is_struct_type(tp) ||
          is_array_type(tp) || is_union_type(tp));
 }
 
 
-
-
-
-#if 1 || DEBUG_libfirm
-INLINE int dump_node_opcode(FILE *F, ir_node *n); /* from irdump.c */
+#ifdef DEBUG_libfirm
+int dump_node_opcode(FILE *F, ir_node *n); /* from irdump.c */
 
 void dump_type (type *tp) {
   int i;
@@ -1548,14 +1602,14 @@ void dump_type (type *tp) {
 
   switch (get_type_tpop_code(tp)) {
 
-  case tpo_class: {
+  case tpo_class:
     printf("\n  members: ");
     for (i = 0; i < get_class_n_members(tp); ++i) {
       entity *mem = get_class_member(tp, i);
       printf("\n    (%2d) %s:\t %s",
             get_entity_offset(mem), get_type_name(get_entity_type(mem)), get_entity_name(mem));
     }
-    printf("\n  suptertypes: ");
+    printf("\n  supertypes: ");
     for (i = 0; i < get_class_n_supertypes(tp); ++i) {
       type *stp = get_class_supertype(tp, i);
       printf("\n    %s", get_type_name(stp));
@@ -1567,10 +1621,26 @@ void dump_type (type *tp) {
     }
 
     printf("\n  peculiarity: %s", get_peculiarity_string(get_class_peculiarity(tp)));
+    break;
 
+  case tpo_union:
+  case tpo_struct:
+    printf("\n  members: ");
+    for (i = 0; i < get_compound_n_members(tp); ++i) {
+      entity *mem = get_compound_member(tp, i);
+      printf("\n    (%2d) %s:\t %s",
+            get_entity_offset(mem), get_type_name(get_entity_type(mem)), get_entity_name(mem));
+    }
+    break;
+
+  case tpo_pointer: {
+    type *tt = get_pointer_points_to_type(tp);
+
+    printf("\n  points to %s (%ld)", get_type_name(tt), get_type_nr(tt));
   } break;
+
   default:
-    printf("not implemented\n");
+    printf(": details not implemented\n");
   }
   printf("\n\n");
 }