From 73aba04481fc9b5982b5f61c44994ebd9b1d73cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Thu, 12 Jul 2001 10:08:17 +0000 Subject: [PATCH] Added implementatio of overwrites stuff. [r228] --- Changes | 3 +++ ir/tr/entity.c | 32 ++++++++++++++++++++++++++++++++ ir/tr/entity.h | 5 ++++- ir/tr/entity_t.h | 1 + 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index b0e03ed43..d71073e23 100644 --- 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. diff --git a/ir/tr/entity.c b/ir/tr/entity.c index b9b50f18c..32dfbfdfb 100644 --- a/ir/tr/entity.c +++ b/ir/tr/entity.c @@ -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); diff --git a/ir/tr/entity.h b/ir/tr/entity.h index 45176fb16..48e911443 100644 --- a/ir/tr/entity.h +++ b/ir/tr/entity.h @@ -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); diff --git a/ir/tr/entity_t.h b/ir/tr/entity_t.h index a605f6da6..0c7988c84 100644 --- a/ir/tr/entity_t.h +++ b/ir/tr/entity_t.h @@ -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 -- 2.20.1