/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-2011 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
by an entity of this class. */
static void copy_entities_from_superclass(ir_type *clss, void *env)
{
- int i, j, k, l;
+ size_t i;
+ size_t j;
+ size_t k;
+ size_t l;
int overwritten;
ir_type *super, *inhenttype;
ir_entity *inhent, *thisent;
*/
static int tr_inh_trans_cmp(const void *e1, const void *e2, size_t size)
{
- const tr_inh_trans_tp *ef1 = e1;
- const tr_inh_trans_tp *ef2 = e2;
+ const tr_inh_trans_tp *ef1 = (const tr_inh_trans_tp*)e1;
+ const tr_inh_trans_tp *ef2 = (const tr_inh_trans_tp*)e2;
(void) size;
return ef1->kind != ef2->kind;
if (!tr_inh_trans_set) tr_inh_trans_set = new_set(tr_inh_trans_cmp, 128);
- found = set_find(tr_inh_trans_set, &a, sizeof(a), tr_inh_trans_hash(&a));
+ found = (tr_inh_trans_tp*)set_find(tr_inh_trans_set, &a, sizeof(a), tr_inh_trans_hash(&a));
if (!found) {
a.directions[d_up] = pset_new_ptr(16);
a.directions[d_down] = pset_new_ptr(16);
- found = set_insert(tr_inh_trans_set, &a, sizeof(a), tr_inh_trans_hash(&a));
+ found = (tr_inh_trans_tp*)set_insert(tr_inh_trans_set, &a, sizeof(a), tr_inh_trans_hash(&a));
}
return found;
}
static void compute_down_closure(ir_type *tp)
{
pset *myset, *subset;
- int i, n_subtypes, n_members, n_supertypes;
+ size_t i, n_subtypes, n_members, n_supertypes;
ir_visited_t master_visited = get_master_type_visited();
assert(is_Class_type(tp));
n_members = get_class_n_members(tp);
for (i = 0; i < n_members; ++i) {
ir_entity *mem = get_class_member(tp, i);
- int j, n_overwrittenby = get_entity_n_overwrittenby(mem);
+ size_t j, n_overwrittenby = get_entity_n_overwrittenby(mem);
myset = get_entity_map(mem, d_down);
for (j = 0; j < n_overwrittenby; ++j) {
static void compute_up_closure(ir_type *tp)
{
pset *myset, *subset;
- int i, n_subtypes, n_members, n_supertypes;
+ size_t i, n_subtypes, n_members, n_supertypes;
ir_visited_t master_visited = get_master_type_visited();
assert(is_Class_type(tp));
n_members = get_class_n_members(tp);
for (i = 0; i < n_members; ++i) {
ir_entity *mem = get_class_member(tp, i);
- int j, n_overwrites = get_entity_n_overwrites(mem);
+ size_t j, n_overwrites = get_entity_n_overwrites(mem);
myset = get_entity_map(mem, d_up);
for (j = 0; j < n_overwrites; ++j) {
* transitive closure. */
void compute_inh_transitive_closure(void)
{
- int i, n_types = get_irp_n_types();
+ size_t i, n_types = get_irp_n_types();
free_inh_transitive_closure();
/* The 'down' relation */
for (i = 0; i < n_types; ++i) {
ir_type *tp = get_irp_type(i);
if (is_Class_type(tp) && type_not_visited(tp)) { /* For others there is nothing to accumulate. */
- int j, n_subtypes = get_class_n_subtypes(tp);
+ size_t j, n_subtypes = get_class_n_subtypes(tp);
int has_unmarked_subtype = 0;
assert(get_type_visited(tp) < get_master_type_visited()-1);
for (i = 0; i < n_types; ++i) {
ir_type *tp = get_irp_type(i);
if (is_Class_type(tp) && type_not_visited(tp)) { /* For others there is nothing to accumulate. */
- int j, n_supertypes = get_class_n_supertypes(tp);
+ size_t j, n_supertypes = get_class_n_supertypes(tp);
int has_unmarked_supertype = 0;
assert(get_type_visited(tp) < get_master_type_visited()-1);
{
if (tr_inh_trans_set) {
tr_inh_trans_tp *elt;
- for (elt = set_first(tr_inh_trans_set); elt; elt = set_next(tr_inh_trans_set)) {
+ for (elt = (tr_inh_trans_tp*)set_first(tr_inh_trans_set); elt != NULL;
+ elt = (tr_inh_trans_tp*)set_next(tr_inh_trans_set)) {
del_pset(elt->directions[d_up]);
del_pset(elt->directions[d_down]);
}
ir_type *get_class_trans_subtype_first(const ir_type *tp)
{
assert_valid_state();
- return pset_first(get_type_map(tp, d_down));
+ return (ir_type*)pset_first(get_type_map(tp, d_down));
}
ir_type *get_class_trans_subtype_next(const ir_type *tp)
{
assert_valid_state();
- return pset_next(get_type_map(tp, d_down));
+ return (ir_type*)pset_next(get_type_map(tp, d_down));
}
int is_class_trans_subtype(const ir_type *tp, const ir_type *subtp)
ir_type *get_class_trans_supertype_first(const ir_type *tp)
{
assert_valid_state();
- return pset_first(get_type_map(tp, d_up));
+ return (ir_type*)pset_first(get_type_map(tp, d_up));
}
ir_type *get_class_trans_supertype_next(const ir_type *tp)
{
assert_valid_state();
- return pset_next(get_type_map(tp, d_up));
+ return (ir_type*)pset_next(get_type_map(tp, d_up));
}
/* - overwrittenby ------------------------------------------------------- */
ir_entity *get_entity_trans_overwrittenby_first(const ir_entity *ent)
{
assert_valid_state();
- return pset_first(get_entity_map(ent, d_down));
+ return (ir_entity*)pset_first(get_entity_map(ent, d_down));
}
ir_entity *get_entity_trans_overwrittenby_next(const ir_entity *ent)
{
assert_valid_state();
- return pset_next(get_entity_map(ent, d_down));
+ return (ir_entity*)pset_next(get_entity_map(ent, d_down));
}
/* - overwrites ---------------------------------------------------------- */
ir_entity *get_entity_trans_overwrites_first(const ir_entity *ent)
{
assert_valid_state();
- return pset_first(get_entity_map(ent, d_up));
+ return (ir_entity*)pset_first(get_entity_map(ent, d_up));
}
ir_entity *get_entity_trans_overwrites_next(const ir_entity *ent)
{
assert_valid_state();
- return pset_next(get_entity_map(ent, d_up));
+ return (ir_entity*)pset_next(get_entity_map(ent, d_up));
}
/** Returns true if low is subclass of high. */
static int check_is_SubClass_of(ir_type *low, ir_type *high)
{
- int i, n_subtypes;
+ size_t i, n_subtypes;
/* depth first search from high downwards. */
n_subtypes = get_class_n_subtypes(high);
int is_overwritten_by(ir_entity *high, ir_entity *low)
{
- int i, n_overwrittenby;
+ size_t i, n_overwrittenby;
assert(is_entity(low) && is_entity(high));
if (get_irp_inh_transitive_closure_state() == inh_transitive_closure_valid) {
*/
static ir_entity *do_resolve_ent_polymorphy(ir_type *dynamic_class, ir_entity *static_ent)
{
- int i, n_overwrittenby;
+ 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.
void set_irp_class_cast_state(ir_class_cast_state s)
{
#ifndef NDEBUG
- int i;
- for (i = get_irp_n_irgs() - 1; i >= 0; --i)
+ size_t i, n;
+ for (i = 0, n = get_irp_n_irgs(); i < n; ++i)
assert(get_irg_class_cast_state(get_irp_irg(i)) >= s);
#endif
irp->class_cast_state = s;
if (!is_Class_type(totype)) return;
if (is_SubClass_of(totype, fromtype) ||
- is_SubClass_of(fromtype, totype) ) {
+ is_SubClass_of(fromtype, totype)) {
this_state = ir_class_casts_transitive;
- if ((get_class_supertype_index(totype, fromtype) != -1) ||
- (get_class_supertype_index(fromtype, totype) != -1) ||
+ if ((get_class_supertype_index(totype, fromtype) != (size_t)-1) ||
+ (get_class_supertype_index(fromtype, totype) != (size_t)-1) ||
fromtype == totype) {
- /* Das ist doch alt? Aus dem cvs aufgetaucht ...
- if ((get_class_supertype_index(totype, fromtype) == -1) &&
- (get_class_supertype_index(fromtype, totype) == -1) ) { */
this_state = ir_class_casts_normalized;
}
}