added new check routines
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Fri, 1 Jul 2005 14:17:39 +0000 (14:17 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Fri, 1 Jul 2005 14:17:39 +0000 (14:17 +0000)
bugfix after michael added a useful assertion in get_Cast_op

[r6170]

ir/tr/tr_inheritance.c
ir/tr/tr_inheritance.h

index ea2c044..926bd2f 100644 (file)
@@ -488,10 +488,32 @@ int is_subclass_of(type *low, type *high) {
   return 0;
 }
 
+
+/* Subclass check for pointers to classes.
+ *
+ *  Dereferences at both types the same amount of pointer types (as
+ *  many as possible).  If the remaining types are both class types
+ *  and subclasses, returns true, else false.  Can also be called with
+ *  two class types.  */
+int is_subclass_ptr_of(type *low, type *high) {
+  while (is_Pointer_type(low) && is_Pointer_type(high)) {
+    low  = get_pointer_points_to_type(low);
+    high = get_pointer_points_to_type(high);
+  }
+
+  if (is_Class_type(low) && is_Class_type(high))
+    return is_subclass_of(low, high);
+  return 0;
+}
+
 int is_superclass_of(type *high, type *low) {
   return is_subclass_of(low, high);
 }
 
+int is_superclass_ptr_of(type *high, type *low) {
+  return is_subclass_ptr_of(low, high);
+}
+
 int is_overwritten_by(entity *high, entity *low) {
   int i, n_overwrittenby;
   assert(is_entity(low) && is_entity(high));
@@ -596,6 +618,8 @@ void verify_irn_class_cast_state(ir_node *n, void *env) {
   ccs_env *ccs = (ccs_env *)env;
   ir_class_cast_state this_state = ir_class_casts_any;
 
+  if (get_irn_op(n) != op_Cast) return;
+
   type *fromtype = get_irn_typeinfo_type(get_Cast_op(n));
   type *totype   = get_Cast_type(n);
   int ref_depth = 0;
index b521051..0bbcc56 100644 (file)
@@ -52,6 +52,14 @@ typedef struct ir_graph ir_graph;
  *  subclasses of high.  */
 int is_subclass_of(type *low, type *high);
 
+/** Subclass check for pointers to classes.
+ *
+ *  Dereferences at both types the same amount of pointer types (as
+ *  many as possible).  If the remaining types are both class types
+ *  and subclasses, returns true, else false.  Can also be called with
+ *  two class types.  */
+int is_subclass_ptr_of(type *low, type *high);
+
 /** Returns true if high is superclass of low.
  *
  *  Low is a subclass of high if low == high or if low is a subclass of
@@ -60,6 +68,14 @@ int is_subclass_of(type *low, type *high);
  *  subclasses of high.  */
 int is_superclass_of(type *high, type *low);
 
+/** Superclass check for pointers to classes.
+ *
+ *  Dereferences at both types the same amount of pointer types (as
+ *  many as possible).  If the remaining types are both class types
+ *  and superclasses, returns true, else false.  Can also be called with
+ *  two class types.  */
+int is_subclass_ptr_of(type *low, type *high);
+
 /** Returns true if high is (transitive) overwritten by low.
  *
  *  Returns false if high == low. */
@@ -121,6 +137,8 @@ void resolve_inheritance(mangle_inherited_name_func *mfunc);
 /*                                                                         */
 /* The transitive edges are held in a set, not in an array as the          */
 /* underlying relation.                                                    */
+/*                                                                         */
+/* Do the sets contain the node itself?  I assume NOT!                     */
 /* ----------------------------------------------------------------------- */
 
 /** The state of the transitive closure.