Added overwrittenby relation: inverse of overwrites. will be automatically
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Thu, 11 Apr 2002 14:03:51 +0000 (14:03 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Thu, 11 Apr 2002 14:03:51 +0000 (14:03 +0000)
built by frontend

[r347]

ir/tr/entity.c
ir/tr/entity.h
ir/tr/entity_t.h

index e49f6d8..8eba693 100644 (file)
@@ -84,6 +84,7 @@ new_entity (type *owner, ident *name, type *type)
   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;
 
@@ -96,6 +97,7 @@ new_entity (type *owner, ident *name, type *type)
 inline void free_entity_attrs(entity *ent) {
   assert(ent);
   DEL_ARR_F(ent->overwrites);
+  DEL_ARR_F(ent->overwrittenby);
 }
 
 entity *
@@ -108,6 +110,7 @@ copy_entity_own (entity *old, type *new_owner) {
   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);
 
@@ -124,6 +127,7 @@ copy_entity_name (entity *old, ident *new_name) {
   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);
 
@@ -364,27 +368,64 @@ set_entity_offset (entity *ent, int offset) {
 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) {
index 8e424e1..464d7a5 100644 (file)
@@ -90,6 +90,9 @@ typedef struct ir_graph ir_graph;
  *   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.
@@ -234,12 +237,17 @@ void      set_entity_offset (entity *ent, int offset);
    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);
index 5ffe3b5..a5d5780 100644 (file)
@@ -50,6 +50,7 @@ struct entity {
   type *owner;          /* The class this entity belongs to.  In case of local
                           variables the method they are defined in. */
   entity **overwrites;  /* A list of entities this entity overwrites.  */
+  entity **overwrittenby;  /* A list of entities that overwrite this entity.  */
   ent_allocation allocation;  /* Distinguishes static and dynamically allocated
                                 entities. */
   ent_visibility visibility;  /* Specifies visibility to external program