some new fields.
[r219]
typedef struct ir_graph ir_graph;
#endif
+/****s* entity/entity
+ *
+ * NAME
+ * entity - An abstract data type to represent program entites.
+ * NOTE
+ *
+ * ... not documented ...
+ *
+ * ATTRIBUTES
+ *
+ *
+ * These fields can only be accessed via access functions.
+ *
+ * SEE ALSO
+ * type
+ * SOURCE
+ */
+
#ifndef _ENTITY_TYPEDEF_
#define _ENTITY_TYPEDEF_
/* to resolve recursion between entity.h and type.h */
Automatically inserts the new entity as a member of owner.
The mangled name ld_name is set to NULL. */
entity *copy_entity_name (entity *old, ident *new_name);
-/* manipulate fields of entity */
+
+/** manipulate fields of entity **/
const char *get_entity_name (entity *ent);
ident *get_entity_ident (entity *ent);
/* returns the mangled name of the entity. If the mangled name is
int get_entity_offset (entity *ent);
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. */
+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"? */
+
/* The entity knows the corresponding irg if the entity is a method.
This allows to get from a Call to the called irg. */
ir_graph *get_entity_irg(entity *ent);
void set_entity_irg(entity *ent, ir_graph *irg);
+
+/*****/
+
# endif /* _ENTITY_H_ */
assert(clss && (clss->type_op == type_class));
clss->attr.ca.members[pos+1] = member;
}
+void remove_class_member(type *clss, entity *member) {
+ int i;
+ assert(clss && (clss->type_op == type_class));
+ for (i = 1; i < (ARR_LEN (clss->attr.ca.members))-1; i++)
+ if (clss->attr.ca.members[i+1] == member) {
+ clss->attr.ca.members[i+1] = NULL;
+ break;
+ }
+}
void add_class_subtype (type *clss, type *subtype) {
assert(clss && (clss->type_op == type_class));
ARR_APP1 (type *, clss->attr.ca.subtypes, subtype);
+ ARR_APP1 (type *, subtype->attr.ca.supertypes, clss);
}
int get_class_n_subtype (type *clss) {
assert(clss && (clss->type_op == type_class));
assert(clss && (clss->type_op == type_class));
clss->attr.ca.subtypes[pos+1] = subtype;
}
+void remove_class_subtype(type *clss, type *subtype) {
+ int i;
+ assert(clss && (clss->type_op == type_class));
+ for (i = 1; i < (ARR_LEN (clss->attr.ca.subtypes))-1; i++)
+ if (clss->attr.ca.subtypes[i+1] == subtype) {
+ clss->attr.ca.subtypes[i+1] = NULL;
+ break;
+ }
+}
void add_class_supertype (type *clss, type *supertype) {
assert(clss && (clss->type_op == type_class));
ARR_APP1 (type *, clss->attr.ca.supertypes, supertype);
+ ARR_APP1 (type *, supertype->attr.ca.subtypes, clss);
}
int get_class_n_supertype (type *clss) {
assert(clss && (clss->type_op == type_class));
assert(clss && (clss->type_op == type_class));
clss->attr.ca.supertypes[pos+1] = supertype;
}
+void remove_class_supertype(type *clss, type *supertype) {
+ int i;
+ assert(clss && (clss->type_op == type_class));
+ for (i = 1; i < (ARR_LEN (clss->attr.ca.supertypes))-1; i++)
+ if (clss->attr.ca.supertypes[i+1] == supertype) {
+ clss->attr.ca.supertypes[i+1] = NULL;
+ break;
+ }
+}
/* typecheck */
bool is_class_type(type *clss) {
assert(clss);
assert(strct && (strct->type_op == type_struct));
strct->attr.sa.members[pos+1] = member;
}
+void remove_struct_member(type *strct, entity *member) {
+ int i;
+ assert(strct && (strct->type_op == type_struct));
+ for (i = 1; i < (ARR_LEN (strct->attr.ca.members))-1; i++)
+ if (strct->attr.ca.members[i+1] == member) {
+ strct->attr.ca.members[i+1] = NULL;
+ break;
+ }
+}
/* typecheck */
bool is_struct_type(type *strct) {
assert(strct);
assert(uni && (uni->type_op == type_union));
uni->attr.ua.members[pos+1] = member;
}
+void remove_union_member(type *uni, entity *member) {
+ int i;
+ assert(uni && (uni->type_op == type_union));
+ for (i = 1; i < (ARR_LEN (uni->attr.ca.members))-1; i++)
+ if (uni->attr.ca.members[i+1] == member) {
+ uni->attr.ca.members[i+1] = NULL;
+ break;
+ }
+}
/* typecheck */
bool is_union_type (type *uni) {
/* create a new class type */
type *new_type_class (ident *name);
-/* manipulate private fields of class type */
+/** manipulate private fields of class type **/
+/* Adds the entity as member of the class. */
void add_class_member (type *clss, entity *member);
+/* Returns the number of members of this class. */
int get_class_n_member (type *clss);
+/* Returns the member at position pos, 0 <= pos < n_member */
entity *get_class_member (type *clss, int pos);
+/* Overwrites the member at position pos, 0 <= pos < n_member with
+ the passed entity. */
void set_class_member (type *clss, entity *member, int pos);
+/* Finds member in the list of members and overwrites it with NULL */
+void remove_class_member(type *clss, entity *member);
+
+/* Adds subtype as subtype to clss and also
+ clss as supertype to subtype */
void add_class_subtype (type *clss, type *subtype);
+/* Returns the number of subtypes */
int get_class_n_subtype (type *clss);
+/* Gets the subtype at position pos, 0 <= pos < n_subtype. */
type *get_class_subtype (type *clss, int pos);
+/* Sets the subtype at positioin pos, 0 <= pos < n_subtype. Does not
+ set the corresponding supertype relation for subtype: this might
+ be a different position! */
void set_class_subtype (type *clss, type *subtype, int pos);
+/* Finds subtype in the list of subtypes and overwrites it with NULL */
+void remove_class_subtype(type *clss, type *subtype);
+
+/* Adds supertype as supertype to class and also
+ class as subtype to supertype. */
void add_class_supertype (type *clss, type *supertype);
+/* Returns the number of supertypes */
int get_class_n_supertype (type *clss);
+/* Gets the supertype at position pos, 0 <= pos < n_supertype. */
type *get_class_supertype (type *clss, int pos);
+/* Sets the supertype at postition pos, 0 <= pos < n_subtype. Does not
+ set the corresponding subtype relation for supertype: this might
+ be a different position! */
void set_class_supertype (type *clss, type *supertype, int pos);
+/* Finds supertype in the list of supertypes and overwrites it with NULL */
+void remove_class_supertype(type *clss, type *supertype);
/* typecheck */
bool is_class_type(type *clss);
int get_struct_n_member (type *strct);
entity *get_struct_member (type *strct, int pos);
void set_struct_member (type *strct, int pos, entity *member);
+/* Finds member in the list of memberss and overwrites it with NULL */
+void remove_struct_member (type *strct, entity *member);
/* typecheck */
bool is_struct_type(type *strct);
void add_union_member (type *uni, entity *member);
entity *get_union_member (type *uni, int pos);
void set_union_member (type *uni, int pos, entity *member);
+void remove_union_member (type *uni, entity *member);
/* typecheck */
bool is_union_type (type *uni);
# include "type_or_entity.h"
-/** dumps all type information reachable from global roots **/
+/** Walks over all type information reachable from global roots.
+ Touches every type and entity in unspecified order. If new
+ types/entities are created during the traversal these will
+ be visited, too. **/
void type_walk(void (pre)(type_or_ent*, void*),
void (post)(type_or_ent*, void*),
void *env);
-/** dumps all type information reachable from irg **/
+/** walks over all type information reachable from irg **/
void type_walk_irg(ir_graph *irg,
void (pre)(type_or_ent*, void*),
void (post)(type_or_ent*, void*),