* @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++) {
}
}
-/* Resolve implicit inheritance.
- *
- * Resolves the implicit inheritance supplied by firm.
- */
void resolve_inheritance(mangle_inherited_name_func *mfunc)
{
if (!mfunc)
*/
static inline unsigned int tr_inh_trans_hash(const tr_inh_trans_tp *v)
{
- return HASH_PTR(v->kind);
+ return hash_ptr(v->kind);
}
/* This always completes successfully. */
}
}
-/** Compute the transitive closure of the subclass/superclass and
- * overwrites/overwrittenby relation.
- *
- * This function walks over the ir (O(#types+#entities)) to compute the
- * transitive closure. */
void compute_inh_transitive_closure(void)
{
size_t i, n_types = get_irp_n_types();
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. */
void free_inh_transitive_closure(void)
{
if (tr_inh_trans_set) {
/* - overwrites ---------------------------------------------------------- */
-/** Iterate over all transitive overwritten entities. */
ir_entity *get_entity_trans_overwrites_first(const ir_entity *ent)
{
assert_valid_state();
return 0;
}
-/* Returns true if low is subclass of high. */
int is_SubClass_of(ir_type *low, ir_type *high)
{
assert(is_Class_type(low) && is_Class_type(high));
return check_is_SubClass_of(low, 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(ir_type *low, ir_type *high)
{
while (is_Pointer_type(low) && is_Pointer_type(high)) {
return static_ent;
}
-/* Resolve polymorphy in the inheritance relation.
- *
- * Returns the dynamically referenced entity if the static entity and the
- * dynamic type are given.
- * Search downwards in overwritten tree.
- */
ir_entity *resolve_ent_polymorphy(ir_type *dynamic_class, ir_entity *static_ent)
{
ir_entity *res;
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;
ccs->worst_situation = this_state;
}
-/** Verify that the graph meets requirements of state set. */
void verify_irg_class_cast_state(ir_graph *irg)
{
ccs_env env;