X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Ftr%2Fentity.c;h=8bc79552d07b2343165132830be1e34980001582;hb=7a68aade04d8cac3d294dd8c4448e7b71f53b9b3;hp=7c57f22b7d07d412552854383f2c9cb8ce71a12d;hpb=1fb376a0abbaa02759baf1df5374a30a14c0dcb3;p=libfirm diff --git a/ir/tr/entity.c b/ir/tr/entity.c index 7c57f22b7..8bc79552d 100644 --- a/ir/tr/entity.c +++ b/ir/tr/entity.c @@ -22,6 +22,7 @@ /* All this is needed to build the constant node for methods: */ # include "irprog_t.h" # include "ircons.h" +# include "tv_t.h" /*******************************************************************/ /** general **/ @@ -36,7 +37,10 @@ init_entity (void) /** ENTITY **/ /*******************************************************************/ -INLINE type *get_entity_owner (entity *ent); +/* redeclared to declare INLINE. */ +INLINE entity *get_entity_overwrites (entity *ent, int pos); +INLINE entity *get_entity_overwrittenby (entity *ent, int pos); +INLINE type *get_entity_owner (entity *ent); INLINE void insert_entity_in_owner (entity *ent) { type *owner = ent->owner; @@ -81,10 +85,12 @@ new_entity (type *owner, ident *name, type *type) res->variability = constant; rem = current_ir_graph; current_ir_graph = get_const_code_irg(); - res->value = new_Const(mode_P, tarval_P_from_entity(res)); + res->value = new_Const(mode_P, new_tarval_from_entity(res, mode_P)); current_ir_graph = rem; } else { res->variability = uninitialized; + res->value = NULL; + res->values = NULL; } res->peculiarity = existent; res->volatility = non_volatile; @@ -142,6 +148,9 @@ copy_entity_own (entity *old, type *new_owner) { new->overwrites = NEW_ARR_F(entity *, 1); new->overwrittenby = NEW_ARR_F(entity *, 1); } +#ifdef DEBUG_libfirm + new->nr = get_irp_new_node_nr(); +#endif insert_entity_in_owner (new); @@ -157,16 +166,23 @@ copy_entity_name (entity *old, ident *new_name) { memcpy (new, old, sizeof (entity)); new->name = new_name; new->ld_name = NULL; - new->overwrites = DUP_ARR_F(entity *, old->overwrites); - new->overwrittenby = DUP_ARR_F(entity *, old->overwrittenby); + if (is_class_type(new->owner)) { + new->overwrites = DUP_ARR_F(entity *, old->overwrites); + new->overwrittenby = DUP_ARR_F(entity *, old->overwrittenby); + } +#ifdef DEBUG_libfirm + new->nr = get_irp_new_node_nr(); +#endif insert_entity_in_owner (new); return new; } + void free_entity (entity *ent) { + free_tarval_entity(ent); free_entity_attrs(ent); free(ent); } @@ -274,8 +290,8 @@ set_entity_visibility (entity *ent, ent_visibility vis) { if (vis != local) assert((ent->allocation == static_allocated) || (ent->allocation == automatic_allocated)); - // @@@ Test that the owner type is not local, but how?? - // && get_class_visibility(get_entity_owner(ent)) != local)); + /* @@@ Test that the owner type is not local, but how?? + && get_class_visibility(get_entity_owner(ent)) != local));*/ ent->visibility = vis; } @@ -303,6 +319,19 @@ set_entity_variability (entity *ent, ent_variability var){ ent->variability = var; } +/* return the name of the variablity */ +const char *get_variability_name(ent_variability var) +{ +#define X(a) case a: return #a + switch (var) { + X(uninitialized); + X(initialized); + X(part_constant); + X(constant); + default: return "BAD VALUE"; + } +#undef X +} INLINE ent_volatility get_entity_volatility (entity *ent) { @@ -316,6 +345,18 @@ set_entity_volatility (entity *ent, ent_volatility vol) { ent->volatility = vol; } +/* return the name of the volatility */ +const char *get_volatility_name(ent_volatility var) +{ +#define X(a) case a: return #a + switch (var) { + X(non_volatile); + X(is_volatile); + default: return "BAD VALUE"; + } +#undef X +} + INLINE peculiarity get_entity_peculiarity (entity *ent) { assert (ent); @@ -330,6 +371,19 @@ set_entity_peculiarity (entity *ent, peculiarity pec) { ent->peculiarity = pec; } +/* return the name of the peculiarity */ +const char *get_peculiarity_name(peculiarity var) +{ +#define X(a) case a: return #a + switch (var) { + X(description); + X(inherited); + X(existent); + default: return "BAD VALUE"; + } +#undef X +} + /* Set has no effect for entities of type method. */ INLINE ir_node * get_atomic_ent_value(entity *ent) { @@ -359,7 +413,9 @@ ir_node *copy_const_value(ir_node *n) { case iro_Add: nn = new_Add(copy_const_value(get_Add_left(n)), copy_const_value(get_Add_right(n)), m); break; default: - assert(0 && "opdope invalid or not implemented"); break; + assert(0 && "opdope invalid or not implemented"); + nn=NULL; + break; } return nn; } @@ -453,7 +509,7 @@ set_array_entity_values(entity *ent, tarval **values, int num_vals) { current_ir_graph = get_const_code_irg(); for (i = 0; i < num_vals; i++) { - val = new_Const(get_tv_mode (values[i]), values[i]); + val = new_Const(get_tarval_mode (values[i]), values[i]); add_compound_ent_value(ent, val, get_array_element_entity(arrtp)); } current_ir_graph = rem;