res->volatility = non_volatile;
res->ld_name = NULL;
res->overwrites = NEW_ARR_F(entity *, 1);
+ res->overwrittenby = NEW_ARR_F(entity *, 1);
res->irg = NULL;
inline void free_entity_attrs(entity *ent) {
assert(ent);
DEL_ARR_F(ent->overwrites);
+ DEL_ARR_F(ent->overwrittenby);
}
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->overwrites);
insert_entity_in_owner (new);
new->name = new_name;
new->ld_name = NULL;
new->overwrites = DUP_ARR_F(entity *, old->overwrites);
+ new->overwrittenby = DUP_ARR_F(entity *, old->overwrites);
insert_entity_in_owner (new);
inline void
add_entity_overwrites (entity *ent, entity *overwritten) {
assert(ent);
+ assert(is_class_type(get_entity_owner(ent)));
ARR_APP1 (entity *, ent->overwrites, overwritten);
+ ARR_APP1 (entity *, overwritten->overwrittenby, ent);
}
inline int
-get_entity_n_overwrites (entity *ent){
+get_entity_n_overwrites (entity *ent) {
assert(ent);
+ assert(is_class_type(get_entity_owner(ent)));
return (ARR_LEN (ent->overwrites))-1;
}
inline entity *
-get_entity_overwrites (entity *ent, int pos){
+get_entity_overwrites (entity *ent, int pos) {
assert(ent);
+ assert(is_class_type(get_entity_owner(ent)));
+ assert(pos < get_entity_n_overwrites(ent));
return ent->overwrites[pos+1];
}
inline void
set_entity_overwrites (entity *ent, int pos, entity *overwritten) {
assert(ent);
+ assert(is_class_type(get_entity_owner(ent)));
+ assert(pos < get_entity_n_overwrites(ent));
ent->overwrites[pos+1] = overwritten;
}
+inline void
+add_entity_overwrittenby (entity *ent, entity *overwrites) {
+ assert(ent);
+ assert(is_class_type(get_entity_owner(ent)));
+ add_entity_overwrites(overwrites, ent);
+}
+
+inline int
+get_entity_n_overwrittenby (entity *ent) {
+ assert(ent);
+ assert(is_class_type(get_entity_owner(ent)));
+ return (ARR_LEN (ent->overwrittenby))-1;
+}
+
+inline entity *
+get_entity_overwrittenby (entity *ent, int pos) {
+ assert(ent);
+ assert(is_class_type(get_entity_owner(ent)));
+ assert(pos < get_entity_n_overwrittenby(ent));
+ return ent->overwrittenby[pos+1];
+}
+
+inline void
+set_entity_overwrittenby (entity *ent, int pos, entity *overwrites) {
+ assert(ent);
+ assert(is_class_type(get_entity_owner(ent)));
+ assert(pos < get_entity_n_overwrittenby(ent));
+ ent->overwrittenby[pos+1] = overwrites;
+}
+
/* A link to store intermediate information */
void *
get_entity_link(entity *ent) {
* overwrites A list of entities overwritten by this entity. This list is only
* existent if the owner of this entity is a class. The members in
* this list must be entities of super classes.
+ * overwrittenby A list of entities that overwrite this entity. This list is only
+ * existent if the owner of this entity is a class. The members in
+ * this list must be entities of sub classes.
* link A void* to associate some additional information with the entity.
* irg If the entity is a method this is the ir graph that represents the
* code of the method.
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
- that is passed to it. Lowering of the Sel node must assure this. */
+ that is passed to it. Lowering of the Sel node must assure this.
+ Overwrittenby is the inverse of overwrites. Both add routines add
+ both relations, they only differ in the order of arguments. */
void add_entity_overwrites (entity *ent, entity *overwritten);
int get_entity_n_overwrites (entity *ent);
entity *get_entity_overwrites (entity *ent, int pos);
void set_entity_overwrites (entity *ent, int pos, entity *overwritten);
-/* Do we need a second relation "overwritten"? */
+void add_entity_overwrittenby (entity *ent, entity *overwrites);
+int get_entity_n_overwrittenby (entity *ent);
+entity *get_entity_overwrittenby (entity *ent, int pos);
+void set_entity_overwrittenby (entity *ent, int pos, entity *overwrites);
/* A link to store intermediate information */
void* get_entity_link(entity *ent);