Remove .*_ptr variants of firm-types
[libfirm] / ir / tr / tr_inheritance.c
index 03bc472..639b4fc 100644 (file)
@@ -21,7 +21,6 @@
  * @file    tr_inheritance.c
  * @brief   Utility routines for inheritance representation
  * @author  Goetz Lindenmaier
- * @version $Id$
  */
 #include "config.h"
 
@@ -35,7 +34,7 @@
 #include "irgwalk.h"
 #include "irflag.h"
 
-DEBUG_ONLY(static firm_dbg_module_t *dbg);
+DEBUG_ONLY(static firm_dbg_module_t *dbg;)
 
 /* ----------------------------------------------------------------------- */
 /* Resolve implicit inheritance.                                           */
@@ -55,7 +54,7 @@ static void copy_entities_from_superclass(ir_type *clss, void *env)
        size_t k;
        size_t l;
        int overwritten;
-       ir_type *super, *inhenttype;
+       ir_type *super;
        ir_entity *inhent, *thisent;
        mangle_inherited_name_func *mfunc = *(mangle_inherited_name_func **)env;
 
@@ -64,7 +63,6 @@ static void copy_entities_from_superclass(ir_type *clss, void *env)
                assert(is_Class_type(super) && "not a class");
                for (j = 0; j < get_class_n_members(super); j++) {
                        inhent = get_class_member(super, j);
-                       inhenttype = get_entity_type(inhent);
                        /* check whether inhent is already overwritten */
                        overwritten = 0;
                        for (k = 0; (k < get_class_n_members(clss)) && (overwritten == 0); k++) {
@@ -354,7 +352,7 @@ void compute_inh_transitive_closure(void)
        free_inh_transitive_closure();
 
        /* The 'down' relation */
-       irp_reserve_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_reserve_resources(irp, IRP_RESOURCE_TYPE_VISITED);
        inc_master_type_visited();  /* Inc twice: one if on stack, second if values computed. */
        inc_master_type_visited();
        for (i = 0; i < n_types; ++i) {
@@ -403,7 +401,7 @@ void compute_inh_transitive_closure(void)
        }
 
        irp->inh_trans_closure_state = inh_transitive_closure_valid;
-       irp_free_resources(irp, IR_RESOURCE_TYPE_VISITED);
+       irp_free_resources(irp, IRP_RESOURCE_TYPE_VISITED);
 }
 
 /** Free memory occupied by the transitive closure information. */
@@ -573,7 +571,12 @@ static ir_entity *do_resolve_ent_polymorphy(ir_type *dynamic_class, ir_entity *s
 {
        size_t i, n_overwrittenby;
 
-       if (get_entity_owner(static_ent) == dynamic_class) return static_ent;
+       ir_type *owner = get_entity_owner(static_ent);
+       if (owner == dynamic_class) return static_ent;
+
+       // if the owner of the static_ent already is more special than the dynamic
+       // type to check against - stop here.
+       if (! is_SubClass_of(dynamic_class, owner)) return NULL;
 
        n_overwrittenby = get_entity_n_overwrittenby(static_ent);
        for (i = 0; i < n_overwrittenby; ++i) {
@@ -581,7 +584,9 @@ static ir_entity *do_resolve_ent_polymorphy(ir_type *dynamic_class, ir_entity *s
                ent = do_resolve_ent_polymorphy(dynamic_class, ent);
                if (ent) return ent;
        }
-       return NULL;
+
+       // No further specialization of static_ent has been found
+       return static_ent;
 }
 
 /* Resolve polymorphy in the inheritance relation.
@@ -664,7 +669,6 @@ static 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;
        ir_type             *fromtype, *totype;
-       int                 ref_depth = 0;
 
        if (!is_Cast(n)) return;
 
@@ -674,7 +678,6 @@ static void verify_irn_class_cast_state(ir_node *n, void *env)
        while (is_Pointer_type(totype) && is_Pointer_type(fromtype)) {
                totype   = get_pointer_points_to_type(totype);
                fromtype = get_pointer_points_to_type(fromtype);
-               ref_depth++;
        }
 
        if (!is_Class_type(totype)) return;