X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Ftr%2Fentity.c;h=28b00b29426c49f7b9f4bb5c378c5848fd8483f2;hb=58278afc9917d9fc28ae5a4def6e1d9e53d7179f;hp=c4bbdf10c679af78fa2ad0dbd797ace4e0a67053;hpb=5c27107154d63252e27639ebb34e98022f9b3358;p=libfirm diff --git a/ir/tr/entity.c b/ir/tr/entity.c index c4bbdf10c..28b00b294 100644 --- a/ir/tr/entity.c +++ b/ir/tr/entity.c @@ -36,6 +36,8 @@ init_entity (void) /** ENTITY **/ /*******************************************************************/ +INLINE type *get_entity_owner (entity *ent); + INLINE void insert_entity_in_owner (entity *ent) { type *owner = ent->owner; switch (get_type_tpop_code(owner)) { @@ -96,10 +98,18 @@ new_entity (type *owner, ident *name, type *type) insert_entity_in_owner (res); return res; } +entity * +new_d_entity (type *owner, ident *name, type *type, dbg_info *db) { + entity *res = new_entity(owner, name, type); + set_entity_dbg_info(res, db); + return res; +} INLINE void free_entity_attrs(entity *ent) { assert(ent); - DEL_ARR_F(ent->overwrites); - DEL_ARR_F(ent->overwrittenby); + if (get_type_tpop(get_entity_owner(ent)) == type_class) { + DEL_ARR_F(ent->overwrites); + DEL_ARR_F(ent->overwrittenby); + } } entity * @@ -111,8 +121,15 @@ copy_entity_own (entity *old, type *new_owner) { new = (entity *) malloc (sizeof (entity)); memcpy (new, old, sizeof (entity)); new->owner = new_owner; - new->overwrites = DUP_ARR_F(entity *, old->overwrites); - new->overwrittenby = DUP_ARR_F(entity *, old->overwrittenby); + if ((get_type_tpop(get_entity_owner(old)) == type_class) && + (get_type_tpop(new_owner) == type_class)) { + new->overwrites = DUP_ARR_F(entity *, old->overwrites); + new->overwrittenby = DUP_ARR_F(entity *, old->overwrittenby); + } else if ((get_type_tpop(get_entity_owner(old)) != type_class) && + (get_type_tpop(new_owner) == type_class)) { + new->overwrites = NEW_ARR_F(entity *, 1); + new->overwrittenby = NEW_ARR_F(entity *, 1); + } insert_entity_in_owner (new); @@ -136,6 +153,12 @@ copy_entity_name (entity *old, ident *new_name) { return new; } +void +free_entity (entity *ent) { + free_entity_attrs(ent); + free(ent); +} + INLINE const char * get_entity_name (entity *ent) { assert (ent); @@ -256,11 +279,13 @@ set_entity_variability (entity *ent, ent_variability var){ INLINE ent_volatility get_entity_volatility (entity *ent) { + assert (ent); return ent->volatility; } INLINE void set_entity_volatility (entity *ent, ent_volatility vol) { + assert (ent); ent->volatility = vol; } @@ -273,6 +298,7 @@ get_entity_peculiarity (entity *ent) { INLINE void set_entity_peculiarity (entity *ent, peculiarity pec) { assert (ent); + /* @@@ why peculiarity only for methods? */ assert (is_method_type(ent->type)); ent->peculiarity = pec; } @@ -311,13 +337,6 @@ ir_node *copy_const_value(ir_node *n) { return nn; } -/* Copies the value represented by the entity to current_block - in current_ir_graph. */ -ir_node *copy_atomic_ent_value(entity *ent) { - assert(ent && is_atomic_entity(ent) && (ent->variability != uninitialized)); - return copy_const_value(ent->value); -} - /* A value of a compound entity is a pair of value and the corresponding member of the compound. */ INLINE void @@ -329,7 +348,7 @@ add_compound_ent_value(entity *ent, ir_node *val, entity *member) { /* Copies the firm subgraph referenced by val to const_code_irg and adds the node as constant initialization to ent. - The subgraph may not contain control flow operations. */ + The subgraph may not contain control flow operations. INLINE void copy_and_add_compound_ent_value(entity *ent, ir_node *val, entity *member) { ir_graph *rem = current_ir_graph; @@ -340,7 +359,7 @@ copy_and_add_compound_ent_value(entity *ent, ir_node *val, entity *member) { val = copy_const_value(val); add_compound_ent_value(ent, val, member); current_ir_graph = rem; -} + }*/ INLINE int get_compound_ent_n_values(entity *ent) { @@ -354,12 +373,12 @@ get_compound_ent_value(entity *ent, int pos) { return ent->values[pos+1]; } -/* Copies the value i of the entity to current_block in current_ir_graph. */ +/* Copies the value i of the entity to current_block in current_ir_graph. ir_node * copy_compound_ent_value(entity *ent, int pos) { assert(ent && is_compound_entity(ent) && (ent->variability != uninitialized)); return copy_const_value(ent->values[pos+1]); -} + }*/ INLINE entity * get_compound_ent_value_member(entity *ent, int pos) { @@ -374,6 +393,23 @@ set_compound_ent_value(entity *ent, ir_node *val, entity *member, int pos) { ent->val_ents[pos+1] = member; } +void +remove_compound_ent_value(entity *ent, entity *value_ent) { + int i; + assert(ent && is_compound_entity(ent) && (ent->variability != uninitialized)); + for (i = 1; i < (ARR_LEN (ent->val_ents)); i++) { + if (ent->val_ents[i] == value_ent) { + for(; i < (ARR_LEN (ent->val_ents))-1; i++) { + ent->val_ents[i] = ent->val_ents[i+1]; + ent->values[i] = ent->values[i+1]; + } + ARR_SETLEN(entity*, ent->val_ents, ARR_LEN(ent->val_ents) - 1); + ARR_SETLEN(ir_node*, ent->values, ARR_LEN(ent->values) - 1); + break; + } + } +} + void set_array_entity_values(entity *ent, tarval **values, int num_vals) { int i; @@ -510,3 +546,22 @@ int is_compound_entity(entity *ent) { return (is_class_type(t) || is_struct_type(t) || is_array_type(t) || is_union_type(t)); } + +bool equal_entity(entity *ent1, entity *ent2) { + return true; +} + + +unsigned long get_entity_visited(entity *entity) { + assert (entity); + return entity->visit; +} +void set_entity_visited(entity *entity, unsigned long num) { + assert (entity); + entity->visit = num; +} +/* Sets visited field in entity to entity_visited. */ +void mark_entity_visited(entity *entity) { + assert (entity); + entity->visit = type_visited; +}