# include "entity_t.h"
# include "mangle.h"
# include "typegmod_t.h"
+# include "array.h"
/*******************************************************************/
/** general **/
res->allocation = dynamic_allocated;
res->visibility = local;
res->ld_name = NULL;
+ res->overwrites = NEW_ARR_F(entity *, 1);
res->visit = 0;
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) {
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);
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);
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);
/* 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);
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