Added implementatio of overwrites stuff.
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Thu, 12 Jul 2001 10:08:17 +0000 (10:08 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Thu, 12 Jul 2001 10:08:17 +0000 (10:08 +0000)
[r228]

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

diff --git a/Changes b/Changes
index b0e03ed..d71073e 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+  12.1.2001 Goetz
+  Added implementation of overwrites stuff.
+
   11.7.2001 Goetz
   Implemented stuff to change the type graph.  See
   typegmod.h and tpop.h for basic documentation of the change.
index b9b50f1..32dfbfd 100644 (file)
@@ -14,6 +14,7 @@
 # include "entity_t.h"
 # include "mangle.h"
 # include "typegmod_t.h"
+# include "array.h"
 
 /*******************************************************************/
 /** general                                                       **/
@@ -61,6 +62,7 @@ new_entity (type *owner, ident *name, type *type)
   res->allocation = dynamic_allocated;
   res->visibility = local;
   res->ld_name = NULL;
+  res->overwrites = NEW_ARR_F(entity *, 1);
 
   res->visit = 0;
 
@@ -68,6 +70,10 @@ new_entity (type *owner, ident *name, type *type)
   insert_entity_in_owner (res);
   return res;
 }
+inline void free_entity_attrs(entity *ent) {
+  assert(ent);
+  DEL_ARR_F(ent->overwrites);
+}
 
 entity *
 copy_entity_own (entity *old, type *new_owner) {
@@ -78,6 +84,7 @@ 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);
 
   insert_entity_in_owner (new);
 
@@ -93,6 +100,7 @@ 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);
 
   insert_entity_in_owner (new);
 
@@ -197,6 +205,30 @@ set_entity_offset (entity *ent, int offset) {
   ent->offset = offset;
 }
 
+inline void
+add_entity_overwrites   (entity *ent, entity *overwritten) {
+  assert(ent);
+  ARR_APP1 (entity *, ent->overwrites, overwritten);
+}
+
+inline int
+get_entity_n_overwrites (entity *ent){
+  assert(ent);
+  return (ARR_LEN (ent->overwrites))-1;
+}
+
+inline entity *
+get_entity_overwrites   (entity *ent, int pos){
+  assert(ent);
+  return ent->overwrites[pos+1];
+}
+
+inline void
+set_entity_overwrites   (entity *ent, int pos, entity *overwritten) {
+  assert(ent);
+  ent->overwrites[pos+1] = overwritten;
+}
+
 inline ir_graph *
 get_entity_irg(entity *ent) {
   assert (ent);
index 45176fb..48e9114 100644 (file)
@@ -157,7 +157,10 @@ void      set_entity_offset (entity *ent, int offset);
 /* 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
-   is mostly useful for method entities. */
+   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. */
 void    add_entity_overwrites   (entity *ent, entity *overwritten);
 int     get_entity_n_overwrites (entity *ent);
 entity *get_entity_overwrites   (entity *ent, int pos);
index a605f6d..0c7988c 100644 (file)
@@ -47,6 +47,7 @@ struct entity {
                            basic type of the language or a class itself */
   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.  */
   ent_allocation allocation;  /* Distinguishes static and dynamically allocated
                                 entities. */
   ent_visibility visibility;  /* Specifies visibility to external program