BugFix: fixed list_for_each_safe() instance.
[libfirm] / ir / tr / tr_inheritance.c
index bceae17..33d77a2 100644 (file)
@@ -23,9 +23,7 @@
  * @author  Goetz Lindenmaier
  * @version $Id$
  */
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
 
 #include "debug.h"
 #include "typerep.h"
@@ -43,8 +41,8 @@ DEBUG_ONLY(static firm_dbg_module_t *dbg);
 /* Resolve implicit inheritance.                                           */
 /* ----------------------------------------------------------------------- */
 
-ident *default_mangle_inherited_name(ir_entity *super, ir_type *clss) {
-       return mangle_u(new_id_from_str("inh"), mangle_u(get_type_ident(clss), get_entity_ident(super)));
+ident *default_mangle_inherited_name(const ir_entity *super, const ir_type *clss) {
+       return id_mangle_u(new_id_from_str("inh"), id_mangle_u(get_class_ident(clss), get_entity_ident(super)));
 }
 
 /** Replicates all entities in all super classes that are not overwritten
@@ -82,10 +80,10 @@ static void copy_entities_from_superclass(ir_type *clss, void *env)
                                if (get_entity_peculiarity(inhent) == peculiarity_existent)
                                        set_entity_peculiarity(thisent, peculiarity_inherited);
                                set_entity_ld_ident(thisent, mfunc(inhent, clss));
-                               if (get_entity_variability(inhent) == variability_constant) {
+                               if (get_entity_linkage(inhent) & IR_LINKAGE_CONSTANT) {
                                        assert(is_atomic_entity(inhent) &&  /* @@@ */
                                                "Inheritance of constant, compound entities not implemented");
-                                       set_entity_variability(thisent, variability_constant);
+                                       add_entity_linkage(thisent, IR_LINKAGE_CONSTANT);
                                        set_atomic_ent_value(thisent, get_atomic_ent_value(inhent));
                                }
                        }
@@ -168,7 +166,7 @@ static int tr_inh_trans_cmp(const void *e1, const void *e2, size_t size) {
 /**
  * calculate the hash value of an tr_inh_trans_tp
  */
-static INLINE unsigned int tr_inh_trans_hash(const tr_inh_trans_tp *v) {
+static inline unsigned int tr_inh_trans_hash(const tr_inh_trans_tp *v) {
        return HASH_PTR(v->kind);
 }
 
@@ -224,7 +222,7 @@ static pset *get_type_map(const ir_type *tp, dir d) {
 static void compute_down_closure(ir_type *tp) {
        pset *myset, *subset;
        int i, n_subtypes, n_members, n_supertypes;
-       unsigned long master_visited = get_master_type_visited();
+       ir_visited_t master_visited = get_master_type_visited();
 
        assert(is_Class_type(tp));
 
@@ -278,7 +276,7 @@ static void compute_down_closure(ir_type *tp) {
 static void compute_up_closure(ir_type *tp) {
        pset *myset, *subset;
        int i, n_subtypes, n_members, n_supertypes;
-       unsigned long master_visited = get_master_type_visited();
+       ir_visited_t master_visited = get_master_type_visited();
 
        assert(is_Class_type(tp));
 
@@ -339,6 +337,7 @@ void compute_inh_transitive_closure(void) {
        free_inh_transitive_closure();
 
        /* The 'down' relation */
+       irp_reserve_resources(irp, IR_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) {
@@ -387,6 +386,7 @@ void compute_inh_transitive_closure(void) {
        }
 
        irp->inh_trans_closure_state = inh_transitive_closure_valid;
+       irp_free_resources(irp, IR_RESOURCE_TYPE_VISITED);
 }
 
 /** Free memory occupied by the transitive closure information. */
@@ -555,7 +555,8 @@ static ir_entity *do_resolve_ent_polymorphy(ir_type *dynamic_class, ir_entity *s
  *
  * Returns the dynamically referenced entity if the static entity and the
  * dynamic type are given.
- * Search downwards in overwritten tree. */
+ * Search downwards in overwritten tree.
+ */
 ir_entity *resolve_ent_polymorphy(ir_type *dynamic_class, ir_entity *static_ent) {
        ir_entity *res;
        assert(static_ent && is_entity(static_ent));
@@ -575,11 +576,12 @@ ir_entity *resolve_ent_polymorphy(ir_type *dynamic_class, ir_entity *static_ent)
 /* - State handling. ----------------------------------------- */
 
 void set_irg_class_cast_state(ir_graph *irg, ir_class_cast_state s) {
-       if (get_irp_class_cast_state() > s) set_irp_class_cast_state(s);
+       if (get_irp_class_cast_state() > s)
+               set_irp_class_cast_state(s);
        irg->class_cast_state = s;
 }
 
-ir_class_cast_state get_irg_class_cast_state(ir_graph *irg) {
+ir_class_cast_state get_irg_class_cast_state(const ir_graph *irg) {
        return irg->class_cast_state;
 }
 
@@ -596,7 +598,7 @@ ir_class_cast_state get_irp_class_cast_state(void) {
        return irp->class_cast_state;
 }
 
-char *get_class_cast_state_string(ir_class_cast_state s) {
+const char *get_class_cast_state_string(ir_class_cast_state s) {
 #define X(a)    case a: return #a
        switch(s) {
        X(ir_class_casts_any);
@@ -615,7 +617,10 @@ typedef struct ccs_env {
        ir_class_cast_state worst_situation;
 } ccs_env;
 
-void verify_irn_class_cast_state(ir_node *n, void *env) {
+/**
+ * Walker: check Casts.
+ */
+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;