-typedef struct entity {
- firm_kind kind;
- ident *name; /* name of this entity */
- ident *ld_name; /* Unique name of this entity, i.e., the mangled
- name. E.g., for a class `A' with field `a' this
- is the ident for `A_a'. */
- type *type; /* The type of this entity, e.g., a method type, a
- basic type of the language or a class itself */
- type *owner; /* The class this entity belongs to */
- /* for methods *
- ir_graph *irg; * If (type == method_type) this is the corresponding irg.
- The ir_graph constructor automatically sets this field.
- @@@ Does this go here, or should it be in type_mehtod,
- or should Call have an attribute ent?? */
- /* Do we need to remember the initializer of fields? */
- unsigned long visit; /* visited counter for walks of the type information */
-} entity;
-
-/* create a new entity */
-entity *new_entity (type *owner, ident *name, type *type);
-
-/* manipulate fields of entity */
-char *get_entity_name (entity *);
-ident *get_entity_ident (entity *);
+#ifndef _IR_GRAPH_TYPEDEF_
+#define _IR_GRAPH_TYPEDEF_
+/* to resolve recursion between entity.h and irgraph.h */
+typedef struct ir_graph ir_graph;
+#endif
+
+/****s* entity/entity
+ *
+ * NAME
+ * entity - An abstract data type to represent program entites.
+ * NOTE
+ *
+ * ATTRIBUTES
+ * owner A compound type this entity is a part of.
+ * type The type of this entity.
+ * name The string that represents this entity in the source program.
+ * allocation A flag saying whether the entity is dynamically or statically
+ * allocated (values: dynamic_allocated, static_allocated).
+ * @@@ Does this make sense???
+ * visibility A flag indicating the visibility of this entity (values: local,
+ * external_visible, external_allocated)
+ * offset The offset of the entity within the compound object. Only set
+ * if IR in the state "@@@" Wie nennen wir den??
+ * 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.
+ * irg If the entity is a method this is the ir graph that represents the
+ * code of the method.
+ *
+ *
+ * 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 */
+typedef struct entity entity;
+#endif
+
+/* Creates a new entity.
+ Automatically inserts the entity as a member of owner. */
+entity *new_entity (type *owner, ident *name, type *type);
+/* Copies the entity if the new_owner is different from the
+ owner of the old entity. Else returns the old entity.
+ Automatically inserts the new entity as a member of owner. */
+entity *copy_entity_own (entity *old, type *new_owner);
+/* Copies the entity if the new_name is different from the
+ name of the old entity. Else returns the old entity.
+ 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 **/
+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
+ set it returns the existing name. Else it generates a name
+ with mangle_entity() and remembers this new name internally. */
+ident *get_entity_ld_ident (entity *ent);
+void set_entity_ld_ident (entity *ent, ident *ld_ident);