* @file tr_inheritance.c
* @brief Utility routines for inheritance representation
* @author Goetz Lindenmaier
- * @version $Id$
*/
#include "config.h"
#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. */
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;
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++) {
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) {
}
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. */
{
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) {
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.
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;
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;