X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Ftr%2Ftr_inheritance.h;h=5395966b3f49e890b00de00e4eabb640ff90f1ea;hb=d0d85962ef52c14950db90e5981a7bea36023ab3;hp=5585c257c8bd1b7816304aaf86606081b77109b4;hpb=7012801102da788b13623eb0768e1acf7bf5578c;p=libfirm diff --git a/ir/tr/tr_inheritance.h b/ir/tr/tr_inheritance.h index 5585c257c..5395966b3 100644 --- a/ir/tr/tr_inheritance.h +++ b/ir/tr/tr_inheritance.h @@ -1,6 +1,5 @@ /** - * - * @file tp_inheritance.h + * @file tr_inheritance.h * * Project: libFIRM
* File name: ir/tr/tp_inheritance.h
@@ -25,21 +24,13 @@ * * @see type.h entity.h */ +#ifndef _FIRM_TR_INHERITANCE_H_ +#define _FIRM_TR_INHERITANCE_H_ -#ifndef _TR_INHERITANCE_H_ -#define _TR_INHERITANCE_H_ - +#include "firm_types.h" #include "type.h" -/*#include "entity.h"*/ #include "ident.h" - -/* to resolve recursion between entity.h and irgraph.h */ -#ifndef _IR_GRAPH_TYPEDEF_ -#define _IR_GRAPH_TYPEDEF_ -typedef struct ir_graph ir_graph; -#endif - /* ----------------------------------------------------------------------- */ /* Classify pairs of types/entities in the inheritance relations. */ /* ----------------------------------------------------------------------- */ @@ -50,7 +41,15 @@ typedef struct ir_graph ir_graph; * a subclass of high. I.e, we search in all subtypes of high for low. * @@@ this can be implemented more efficient if we know the set of all * subclasses of high. */ -int is_subclass_of(type *low, type *high); +int is_SubClass_of(ir_type *low, ir_type *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); /** Returns true if high is superclass of low. * @@ -58,19 +57,27 @@ int is_subclass_of(type *low, type *high); * a subclass of high. I.e, we search in all subtypes of high for low. * @@@ this can be implemented more efficient if we know the set of all * subclasses of high. */ -int is_superclass_of(type *high, type *low); +#define is_SuperClass_of(high, low) is_SubClass_of(low, high) + +/** Superclass 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 superclasses, returns true, else false. Can also be called with + * two class types. */ +#define is_SuperClass_ptr_of(low, high) is_SubClass_ptr_of(high, low) /** Returns true if high is (transitive) overwritten by low. * * Returns false if high == low. */ int is_overwritten_by(entity *high, entity *low); -/** Resolve polymorphy in the inheritance relation. +/** Resolve polymorphism in the inheritance relation. * * Returns the dynamically referenced entity if the static entity and the * dynamic type are given. * Searches downwards in overwritten tree. */ -entity *resolve_ent_polymorphy(type *dynamic_class, entity* static_ent); +entity *resolve_ent_polymorphy(ir_type *dynamic_class, entity* static_ent); /* ----------------------------------------------------------------------- */ /* Resolve implicit inheritance. */ @@ -80,16 +87,16 @@ entity *resolve_ent_polymorphy(type *dynamic_class, entity* static_ent); * * Returns an ident that consists of the name of type followed by an * underscore and the name (not ld_name) of the entity. */ -ident *default_mangle_inherited_name(entity *super, type *clss); +ident *default_mangle_inherited_name(entity *ent, ir_type *clss); /** Type of argument functions for inheritance resolver. * - * @param super The entity in the super type that will be overwritten + * @param ent The entity in the super type that will be overwritten * by the newly generated entity, for which this name is * used. * @param clss The class type in which the new entity will be placed. */ -typedef ident *mangle_inherited_name_func(entity *super, type *clss); +typedef ident *mangle_inherited_name_func(entity *ent, ir_type *clss); /** Resolve implicit inheritance. * @@ -121,11 +128,13 @@ void resolve_inheritance(mangle_inherited_name_func *mfunc); /* */ /* The transitive edges are held in a set, not in an array as the */ /* underlying relation. */ +/* */ +/* Do the sets contain the node itself? I assume NOT! */ /* ----------------------------------------------------------------------- */ /** The state of the transitive closure. * - * @TODO: we could manage the state for each relation separately. Invalidating + * @todo: we could manage the state for each relation separately. Invalidating * the entity relations does not mean invalidating the class relation. */ typedef enum { inh_transitive_closure_none, /**< Closure is not computed, can not be accessed. */ @@ -153,15 +162,15 @@ void free_inh_transitive_closure(void); /* - subtype ------------------------------------------------------------- */ /** Iterate over all transitive subtypes. */ -type *get_class_trans_subtype_first(type *tp); -type *get_class_trans_subtype_next (type *tp); -int is_class_trans_subtype (type *tp, type *subtp); +ir_type *get_class_trans_subtype_first(ir_type *tp); +ir_type *get_class_trans_subtype_next (ir_type *tp); +int is_class_trans_subtype (ir_type *tp, ir_type *subtp); /* - supertype ----------------------------------------------------------- */ /** Iterate over all transitive supertypes. */ -type *get_class_trans_supertype_first(type *tp); -type *get_class_trans_supertype_next (type *tp); +ir_type *get_class_trans_supertype_first(ir_type *tp); +ir_type *get_class_trans_supertype_next (ir_type *tp); /* - overwrittenby ------------------------------------------------------- */ @@ -201,7 +210,7 @@ entity *get_entity_trans_overwrites_next (entity *ent); /** Flags for class cast state. * - * The state in irp is allways smaller or equal to the state of any + * The state in irp is always smaller or equal to the state of any * irg. * * We rely on the ordering of the enum. */ @@ -210,7 +219,7 @@ typedef enum { the class hierarchy. @@@ So far this does not happen in Firm. */ ir_class_casts_transitive = 1, /**< Class casts conform to transitive inheritance edges. Default. */ ir_class_casts_normalized = 2, /**< Class casts conform to inheritance edges. */ - ir_class_casts_state_max, + ir_class_casts_state_max } ir_class_cast_state; char *get_class_cast_state_string(ir_class_cast_state s); @@ -225,4 +234,4 @@ ir_class_cast_state get_irp_class_cast_state(void); * and firm verbosity is set. */ void verify_irg_class_cast_state(ir_graph *irg); -#endif /* _TR_INHERITANCE_H_ */ +#endif /* _FIRM_TR_INHERITANCE_H_ */