some fixes for xml dumper / still buggy.
[libfirm] / ir / tr / type.c
index a6f906e..967397c 100644 (file)
@@ -236,6 +236,8 @@ set_type_state(type *tp, type_state state) {
        assert(get_type_size(tp) > -1);
        if (tp != get_glob_type())
          for (i = 0; i < get_class_n_members(tp); i++) {
+           if (get_entity_offset(get_class_member(tp, i)) <= -1)
+             { DDMT(tp); DDME(get_class_member(tp, i)); }
            assert(get_entity_offset(get_class_member(tp, i)) > -1);
            assert(is_method_type(get_entity_type(get_class_member(tp, i))) ||
                   (get_entity_allocation(get_class_member(tp, i)) == automatic_allocated));
@@ -835,10 +837,10 @@ build_value_type(ident *name, int len, type **tps) {
    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 *res;
-  res = new_type(type_method, mode_P, name);
+  res = new_type(type_method, mode_P_mach, name);
   res->state = layout_fixed;
-  assert((get_mode_size_bytes(mode_P) != -1) && "unorthodox modes not implemented");
-  res->size = get_mode_size_bytes(mode_P);
+  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;
@@ -849,16 +851,19 @@ INLINE type *new_type_method (ident *name, int n_param, int n_res) {
 
   return res;
 }
+
 type *new_d_type_method (ident *name, int n_param, int n_res, dbg_info* db) {
   type *res = new_type_method (name, n_param, n_res);
   set_type_dbg_info(res, db);
   return res;
 }
+
 INLINE 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);
 }
+
 /* manipulate private fields of method. */
 int   get_method_n_params  (type *method) {
   assert(method && (method->type_op == type_method));
@@ -1239,17 +1244,18 @@ bool    is_enumeration_type     (type *enumeration) {
 /*******************************************************************/
 
 /* Create a new type pointer */
-INLINE type *new_type_pointer           (ident *name, type *points_to) {
+INLINE type *new_type_pointer_mode (ident *name, type *points_to, ir_mode *ptr_mode) {
   type *res;
-  res = new_type(type_pointer, mode_P, name);
+  assert(mode_is_reference(ptr_mode));
+  res = new_type(type_pointer, ptr_mode, name);
   res->attr.pa.points_to = points_to;
   assert((get_mode_size_bytes(res->mode) != -1) && "unorthodox modes not implemented");
   res->size = get_mode_size_bytes(res->mode);
   res->state = layout_fixed;
   return res;
 }
-type *new_d_type_pointer           (ident *name, type *points_to, dbg_info* db) {
-  type *res = new_type_pointer (name, points_to);
+type *new_d_type_pointer (ident *name, type *points_to, ir_mode *ptr_mode, dbg_info* db) {
+  type *res = new_type_pointer_mode (name, points_to, ptr_mode);
   set_type_dbg_info(res, db);
   return res;
 }
@@ -1280,7 +1286,7 @@ bool  is_pointer_type            (type *pointer) {
 /* create a new type primitive */
 INLINE type *new_type_primitive (ident *name, ir_mode *mode) {
   type *res;
-  /* @@@ assert( mode_is_data(mode) && (!mode == mode_P)); */
+  /* @@@ assert( mode_is_data(mode) && (!mode_is_reference(mode))); */
   res = new_type(type_primitive, mode, name);
   assert((get_mode_size_bytes(mode) != -1) && "unorthodox modes not implemented");
   res->size = get_mode_size_bytes(mode);
@@ -1346,7 +1352,10 @@ entity *get_compound_member(type *tp, int pos)
   else if (is_union_type(tp))
     res = get_union_member(tp, pos);
   else
+  {
     assert(0 && "need struct, union or class to get a member");
+    res=NULL;
+  }
 
   return res;
 }