Add interface and abstract flags to class types.
[libfirm] / ir / tr / type.c
index 9a933dc..d0820ac 100644 (file)
@@ -361,7 +361,7 @@ int get_type_alignment_bits(ir_type *tp) {
 void
 set_type_alignment_bits(ir_type *tp, int align) {
   assert(tp && tp->kind == k_type);
-  assert((align & (align - 1)) == 0 && "type alignment not power of two");
+  assert((align == -1 || (align & (align - 1)) == 0) && "type alignment not power of two");
   /* Methods don't have an alignment. */
   if (tp->type_op != type_method) {
     tp->align = align;
@@ -370,7 +370,11 @@ set_type_alignment_bits(ir_type *tp, int align) {
 
 void
 set_type_alignment_bytes(ir_type *tp, int align) {
-  set_type_alignment_bits(tp, 8*align);
+       if (align == -1) {
+               set_type_alignment_bits(tp, -1);
+       } else {
+               set_type_alignment_bits(tp, 8*align);
+       }
 }
 
 /* Returns a human readable string for the enum entry. */
@@ -766,7 +770,8 @@ ir_type *new_d_type_class (ident *name, dbg_info *db) {
   res->attr.ca.supertypes  = NEW_ARR_F (ir_type *, 0);
   res->attr.ca.peculiarity = peculiarity_existent;
   res->attr.ca.type_info   = NULL;
-  res->attr.ca.final       = 0;
+  res->attr.ca.vtable_size = 0;
+  res->attr.ca.clss_flags  = cf_none;
   res->attr.ca.dfn         = 0;
   hook_new_type(res);
   return res;
@@ -972,12 +977,44 @@ void        set_class_peculiarity (ir_type *clss, peculiarity pec) {
   clss->attr.ca.peculiarity = pec;
 }
 
+/* Returns the size of the virtual function table. */
+unsigned (get_class_vtable_size)(const ir_type *clss) {
+  return _get_class_vtable_size(clss);
+}
+
+/* Sets a new size of the virtual function table. */
+void (set_class_vtable_size)(ir_type *clss, unsigned size) {
+  _set_class_vtable_size(clss, size);
+}
+
+/* Returns non-zero if a class is final. */
 int (is_class_final)(const ir_type *clss) {
   return _is_class_final(clss);
 }
 
-void (set_class_final)(ir_type *clss, int final) {
-  _set_class_final(clss, final);
+/* Sets if a class is final. */
+void (set_class_final)(ir_type *clss, int flag) {
+  _set_class_final(clss, flag);
+}
+
+/* Returns non-zero if a class is an interface. */
+int (is_class_interface)(const ir_type *clss) {
+  return _is_class_interface(clss);
+}
+
+/* Sets the class interface flag. */
+void (set_class_interface)(ir_type *clss, int flag) {
+  _set_class_interface(clss, flag);
+}
+
+/* Returns non-zero if a class is abstract. */
+int (is_class_abstract)(const ir_type *clss) {
+  return _is_class_abstract(clss);
+}
+
+/* Sets the class abstract flag. */
+void (set_class_abstract)(ir_type *clss, int final) {
+  _set_class_abstract(clss, final);
 }
 
 void set_class_dfn (ir_type *clss, int dfn) {
@@ -1515,6 +1552,7 @@ void free_array_attrs (ir_type *array) {
   assert(array && (array->type_op == type_array));
   free(array->attr.aa.lower_bound);
   free(array->attr.aa.upper_bound);
+  free(array->attr.aa.order);
 }
 
 /* manipulate private fields of array ir_type */