From a40cbc91feed7f5b17a28664e7fce4fd5d012351 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Tue, 26 Jul 2005 15:14:06 +0000 Subject: [PATCH] fixed some typos added more doxygen comments make *_visited functions inline replaced bool type [r6304] --- ir/tr/entity.c | 52 ++++++++++++++++++++++++------------------------ ir/tr/entity.h | 14 ++++++------- ir/tr/entity_t.h | 47 ++++++++++++++++++++++++++++++++++++------- 3 files changed, 73 insertions(+), 40 deletions(-) diff --git a/ir/tr/entity.c b/ir/tr/entity.c index c791c24cd..5923eec92 100644 --- a/ir/tr/entity.c +++ b/ir/tr/entity.c @@ -577,6 +577,7 @@ ir_node *copy_const_value(ir_node *n) { return nn; } +/* Creates a new compound graph path. */ compound_graph_path * new_compound_graph_path(type *tp, int length) { compound_graph_path *res; @@ -594,40 +595,43 @@ new_compound_graph_path(type *tp, int length) { return res; } -void -free_compound_graph_path (compound_graph_path *gr) { +/* Frees an graph path object */ +void free_compound_graph_path (compound_graph_path *gr) { assert(gr && is_compound_graph_path(gr)); gr->kind = k_BAD; free(gr ->arr_indicees); free(gr); } -int -is_compound_graph_path(void *thing) { +/* Returns non-zero if an object is a compound graph path */ +int is_compound_graph_path(void *thing) { return (get_kind(thing) == k_ir_compound_graph_path); } -/* checks whether nodes 0..pos are correct (all lie on a path.) */ -/* @@@ not implemented */ +/* Checks whether the path up to pos is correct. If the path contains a NULL, + * assumes the path is not complete and returns 'true'. */ int is_proper_compound_graph_path(compound_graph_path *gr, int pos) { int i; entity *node; type *owner = gr->tp; + for (i = 0; i <= pos; i++) { node = get_compound_graph_path_node(gr, i); if (node == NULL) /* Path not yet complete. */ return true; - if (get_entity_owner(node) != owner) return false; + if (get_entity_owner(node) != owner) + return false; owner = get_entity_type(node); } if (pos == get_compound_graph_path_length(gr)) - if (!is_atomic_type(owner)) return false; + if (!is_atomic_type(owner)) + return false; return true; } -int -get_compound_graph_path_length(compound_graph_path *gr) { +/* Returns the length of a graph path */ +int get_compound_graph_path_length(compound_graph_path *gr) { assert(gr && is_compound_graph_path(gr)); return gr->len; } @@ -1277,27 +1281,23 @@ bool equal_entity(entity *ent1, entity *ent2) { } -unsigned long get_entity_visited(entity *ent) { - assert(ent && ent->kind == k_entity); - return ent->visit; +unsigned long (get_entity_visited)(entity *ent) { + return _get_entity_visited(ent->visit); } -void set_entity_visited(entity *ent, unsigned long num) { - assert(ent && ent->kind == k_entity); - ent->visit = num; + +void (set_entity_visited)(entity *ent, unsigned long num) { + _set_entity_visited(ent, num); } + /* Sets visited field in entity to entity_visited. */ -void mark_entity_visited(entity *ent) { - assert(ent && ent->kind == k_entity); - ent->visit = type_visited; +void (mark_entity_visited)(entity *ent) { + _mark_entity_visited(ent); } - -bool entity_visited(entity *ent) { - assert(ent && ent->kind == k_entity); - return get_entity_visited(ent) >= type_visited; +int (entity_visited)(entity *ent) { + return _entity_visited(ent); } -bool entity_not_visited(entity *ent) { - assert(ent && ent->kind == k_entity); - return get_entity_visited(ent) < type_visited; +int (entity_not_visited)(entity *ent) { + return _entity_not_visited(ent); } diff --git a/ir/tr/entity.h b/ir/tr/entity.h index 870a2dbca..819ec8de2 100644 --- a/ir/tr/entity.h +++ b/ir/tr/entity.h @@ -130,7 +130,7 @@ typedef struct entity entity; * Creates a new entity. * * Automatically inserts the entity as a member of owner. - * Entity is automatic_allocated and uninitialize except if the type + * Entity is automatic_allocated and uninitialized except if the type * is type_method, then it is static_allocated and constant. The constant * value is a pointer to the method. * Visibility is local, offset -1, and it is not volatile. @@ -421,7 +421,7 @@ entity *get_compound_ent_value_member(entity *ent, int pos); /** Sets the path at pos 0 */ void set_compound_ent_value(entity *ent, ir_node *val, entity *member, int pos); -/** Inits the entity ent witch must be of a one dimensional +/** Initializes the entity ent which must be of a one dimensional array type with the values given in the values array. The array must have a lower and an upper bound. Keeps the order of values. Does not test whether the number of values @@ -474,7 +474,7 @@ void sort_compound_ent_values(entity *ent); /* --- Fields of entities with a class type as owner --- */ /* Overwrites is a field that specifies that an access to the overwritten entity in the supertype must use this entity. It's a list as with - multiple inheritance several enitites can be overwritten. This field + multiple inheritance several entities can be overwritten. This field is mostly useful for method entities. If a Sel node selects an entity that is overwritten by other entities it must return a pointer to the entity of the dynamic type of the pointer @@ -523,20 +523,20 @@ bool equal_entity(entity *ent1, entity *ent2); debugging, (configure with --enable-debug) else returns 0. */ long get_entity_nr(entity *ent); -/** Returns the entitys visited count. */ +/** Returns the entities visited count. */ unsigned long get_entity_visited(entity *ent); -/** Sets the entitys visited count. */ +/** Sets the entities visited count. */ void set_entity_visited(entity *ent, unsigned long num); /** Sets visited field in entity to entity_visited. */ void mark_entity_visited(entity *ent); /** Returns true if this entity was visited. */ -bool entity_visited(entity *ent); +int entity_visited(entity *ent); /** Returns true if this entity was not visited. */ -bool entity_not_visited(entity *ent); +int entity_not_visited(entity *ent); /** * @page unknown_entity diff --git a/ir/tr/entity_t.h b/ir/tr/entity_t.h index 181950be0..cf29e38d0 100644 --- a/ir/tr/entity_t.h +++ b/ir/tr/entity_t.h @@ -41,11 +41,11 @@ #include "firm_common_t.h" #include "firm_config.h" -# include "entity.h" -# include "typegmod.h" -# include "mangle.h" -# include "pseudo_irg.h" - +#include "type_t.h" +#include "entity.h" +#include "typegmod.h" +#include "mangle.h" +#include "pseudo_irg.h" /** A path in a compund graph. */ struct compound_graph_path { @@ -92,10 +92,10 @@ struct entity { /* ------------- fields for compound entities ---------------*/ ir_node **values; /**< constant values of compound entities. Only available if - variablility not uninitialized. Must be set for variability constant + variability not uninitialized. Must be set for variability constant */ compound_graph_path **val_paths; /**< paths corresponding to constant values. Only available if - variablility not uninitialized. Must be set for variability constant */ + variability not uninitialized. Must be set for variability constant */ /* ------------- fields for entities owned by a class type ---------------*/ @@ -294,6 +294,34 @@ _get_entity_irg(const entity *ent) { return ent->irg; } +static INLINE unsigned long +_get_entity_visited(entity *ent) { + assert(ent && ent->kind == k_entity); + return ent->visit; +} + +static INLINE void +_set_entity_visited(entity *ent, unsigned long num) { + assert(ent && ent->kind == k_entity); + ent->visit = num; +} + +static INLINE void +_mark_entity_visited(entity *ent) { + assert(ent && ent->kind == k_entity); + ent->visit = type_visited; +} + +static INLINE int +_entity_visited(entity *ent) { + return _get_entity_visited(ent) >= type_visited; +} + +static INLINE int +_entity_not_visited(entity *ent) { + return _get_entity_visited(ent) < type_visited; +} + #define is_entity(thing) _is_entity(thing) #define get_entity_name(ent) _get_entity_name(ent) #define get_entity_ident(ent) _get_entity_ident(ent) @@ -320,5 +348,10 @@ _get_entity_irg(const entity *ent) { #define get_entity_link(ent) _get_entity_link(ent) #define set_entity_link(ent, l) _set_entity_link(ent, l) #define get_entity_irg(ent) _get_entity_irg(ent) +#define get_entity_visited(ent) _get_entity_visited(ent) +#define set_entity_visited(ent, num) _set_entity_visited(ent, num) +#define mark_entity_visited(ent) _mark_entity_visited(ent) +#define entity_visited(ent) _entity_visited(ent) +#define entity_not_visited(ent) _entity_not_visited(ent) # endif /* _ENTITY_T_H_ */ -- 2.20.1