-set_entity_link(entity *ent, void *l) {
- assert(ent);
- ent->link = l;
-}
-
-INLINE ir_graph *
-get_entity_irg(entity *ent) {
- assert (ent);
- assert (is_method_type(ent->type));
- return ent->irg;
-}
-
-INLINE void
-set_entity_irg(entity *ent, ir_graph *irg) {
- assert (ent && ent->type);
- /* Wie kann man die Referenz auf einen IRG löschen, z.B. wenn die
- * Methode selbst nicht mehr aufgerufen werden kann, die Entität
- * aber erhalten bleiben soll. */
- /* assert (irg); */
- assert (is_method_type(ent->type));
- assert (ent->peculiarity == peculiarity_existent);
- ent->irg = irg;
-}
-
-int is_entity (void *thing) {
- assert(thing);
- if (get_kind(thing) == k_entity)
- return 1;
- else
- return 0;
-}
-
-int is_atomic_entity(entity *ent) {
- type* t = get_entity_type(ent);
- return (is_primitive_type(t) || is_pointer_type(t) ||
- is_enumeration_type(t) || is_method_type(t));
-}
-
-int is_compound_entity(entity *ent) {
- type* t = get_entity_type(ent);
- return (is_class_type(t) || is_struct_type(t) ||
- is_array_type(t) || is_union_type(t));
-}
-
-/* @@@ not implemnted!!! */
-bool equal_entity(entity *ent1, entity *ent2) {
- printf(" calling unimplemented equal entity!!! \n");
- return true;
-}
-
-
-unsigned long get_entity_visited(entity *ent) {
- assert (ent);
- return ent->visit;
-}
-void set_entity_visited(entity *ent, unsigned long num) {
- assert (ent);
- ent->visit = num;
-}
-/* Sets visited field in entity to entity_visited. */
-void mark_entity_visited(entity *ent) {
- assert (ent);
- ent->visit = type_visited;
-}
-
-
-INLINE bool entity_visited(entity *ent) {
- return get_entity_visited(ent) >= type_visited;
-}
-
-INLINE bool entity_not_visited(entity *ent) {
- return get_entity_visited(ent) < type_visited;
-}
-
-/* Need two routines because I want to assert the result. */
-static INLINE entity *resolve_ent_polymorphy2 (type *dynamic_class, entity* static_ent) {
- int i, n_overwrittenby;
- entity *res = NULL;
-
- if (get_entity_owner(static_ent) == dynamic_class) return static_ent;
-
- n_overwrittenby = get_entity_n_overwrittenby(static_ent);
- for (i = 0; i < n_overwrittenby; ++i) {
- res = resolve_ent_polymorphy2(dynamic_class, get_entity_overwrittenby(static_ent, i));
- if (res) break;
- }
-
- return res;
-}
-
-/* Returns the dynamically referenced entity if the static entity and the
- * dynamic type are given.
- * Search downwards in overwritten tree. */
-entity *resolve_ent_polymorphy(type *dynamic_class, entity* static_ent) {
- entity *res = resolve_ent_polymorphy2(dynamic_class, static_ent);
- assert(res);
- return res;
-}
+(set_entity_link)(ir_entity *ent, void *l) {
+ _set_entity_link(ent, l);
+} /* set_entity_link */
+
+ir_graph *
+(get_entity_irg)(const ir_entity *ent) {
+ return _get_entity_irg(ent);
+} /* get_entity_irg */
+
+void
+set_entity_irg(ir_entity *ent, ir_graph *irg) {
+ assert(is_method_entity(ent));
+ /* Wie kann man die Referenz auf einen IRG löschen, z.B. wenn die
+ * Methode selbst nicht mehr aufgerufen werden kann, die Entität
+ * aber erhalten bleiben soll? Wandle die Entitaet in description oder
+ * inherited um! */
+ /* assert(irg); */
+ assert((irg && ent->peculiarity == peculiarity_existent) ||
+ (!irg && (ent->peculiarity == peculiarity_existent)
+ && (ent -> visibility == visibility_external_allocated)) ||
+ (!irg && ent->peculiarity == peculiarity_description) ||
+ (!irg && ent->peculiarity == peculiarity_inherited));
+ ent->attr.mtd_attr.irg = irg;
+} /* set_entity_irg */
+
+unsigned get_entity_vtable_number(const ir_entity *ent) {
+ assert(is_method_entity((ir_entity *)ent));
+ return ent->attr.mtd_attr.vtable_number;
+} /* get_entity_vtable_number */
+
+void set_entity_vtable_number(ir_entity *ent, unsigned vtable_number) {
+ assert(is_method_entity(ent));
+ ent->attr.mtd_attr.vtable_number = vtable_number;
+} /* set_entity_vtable_number */
+
+/* Returns the section of a method. */
+ir_img_section get_method_img_section(const ir_entity *ent) {
+ assert(is_method_entity((ir_entity *)ent));
+ return ent->attr.mtd_attr.section;
+} /* get_method_img_section */
+
+/* Sets the section of a method. */
+void set_method_img_section(ir_entity *ent, ir_img_section section) {
+ assert(is_method_entity(ent));
+ ent->attr.mtd_attr.section = section;
+} /* set_method_img_section */
+
+int
+(is_entity)(const void *thing) {
+ return _is_entity(thing);
+} /* is_entity */
+
+int is_atomic_entity(ir_entity *ent) {
+ ir_type *t = get_entity_type(ent);
+ const tp_op *op = get_type_tpop(t);
+ return (op == type_primitive || op == type_pointer ||
+ op == type_enumeration || op == type_method);
+} /* is_atomic_entity */
+
+int is_compound_entity(ir_entity *ent) {
+ ir_type *t = get_entity_type(ent);
+ const tp_op *op = get_type_tpop(t);
+ return (op == type_class || op == type_struct ||
+ op == type_array || op == type_union);
+} /* is_compound_entity */
+
+int is_method_entity(ir_entity *ent) {
+ ir_type *t = get_entity_type(ent);
+ return is_Method_type(t);
+} /* is_method_entity */
+
+/**
+ * @todo not implemented!!! */
+int equal_entity(ir_entity *ent1, ir_entity *ent2) {
+ fprintf(stderr, " calling unimplemented equal entity!!! \n");
+ return 1;
+} /* equal_entity */
+
+
+unsigned long (get_entity_visited)(ir_entity *ent) {
+ return _get_entity_visited(ent);
+} /* get_entity_visited */
+
+void (set_entity_visited)(ir_entity *ent, unsigned long num) {
+ _set_entity_visited(ent, num);
+} /* set_entity_visited */
+
+/* Sets visited field in ir_entity to entity_visited. */
+void (mark_entity_visited)(ir_entity *ent) {
+ _mark_entity_visited(ent);
+} /* mark_entity_visited */
+
+int (entity_visited)(ir_entity *ent) {
+ return _entity_visited(ent);
+} /* entity_visited */
+
+int (entity_not_visited)(ir_entity *ent) {
+ return _entity_not_visited(ent);
+} /* entity_not_visited */
+
+/* Returns the mask of the additional entity properties. */
+unsigned get_entity_additional_properties(ir_entity *ent) {
+ ir_graph *irg;
+
+ assert(is_method_entity(ent));
+
+ /* first check, if the graph has additional properties */
+ irg = get_entity_irg(ent);
+
+ if (irg)
+ return get_irg_additional_properties(irg);
+
+ if (ent->attr.mtd_attr.irg_add_properties & mtp_property_inherited)
+ return get_method_additional_properties(get_entity_type(ent));
+
+ return ent->attr.mtd_attr.irg_add_properties;
+} /* get_entity_additional_properties */
+
+/* Sets the mask of the additional graph properties. */
+void set_entity_additional_properties(ir_entity *ent, unsigned property_mask)
+{
+ ir_graph *irg;
+
+ assert(is_method_entity(ent));
+
+ /* first check, if the graph exists */
+ irg = get_entity_irg(ent);
+ if (irg)
+ set_irg_additional_properties(irg, property_mask);
+ else {
+ /* do not allow to set the mtp_property_inherited flag or
+ * the automatic inheritance of flags will not work */
+ ent->attr.mtd_attr.irg_add_properties = property_mask & ~mtp_property_inherited;
+ }
+} /* set_entity_additional_properties */
+
+/* Sets one additional graph property. */
+void set_entity_additional_property(ir_entity *ent, mtp_additional_property flag)
+{
+ ir_graph *irg;
+
+ assert(is_method_entity(ent));
+
+ /* first check, if the graph exists */
+ irg = get_entity_irg(ent);
+ if (irg)
+ set_irg_additional_property(irg, flag);
+ else {
+ unsigned mask = ent->attr.mtd_attr.irg_add_properties;
+
+ if (mask & mtp_property_inherited)
+ mask = get_method_additional_properties(get_entity_type(ent));
+
+ /* do not allow to set the mtp_property_inherited flag or
+ * the automatic inheritance of flags will not work */
+ ent->attr.mtd_attr.irg_add_properties = mask | (flag & ~mtp_property_inherited);
+ }
+} /* set_entity_additional_property */
+
+/* Returns the class type that this type info entity represents or NULL
+ if ent is no type info entity. */
+ir_type *(get_entity_repr_class)(const ir_entity *ent) {
+ return _get_entity_repr_class(ent);
+} /* get_entity_repr_class */
+
+/* Initialize entity module. */
+void firm_init_entity(void)
+{
+ symconst_symbol sym;
+
+ assert(firm_unknown_type && "Call init_type() before firm_init_entity()!");
+ assert(!unknown_entity && "Call firm_init_entity() only once!");
+
+ unknown_entity = new_rd_entity(NULL, firm_unknown_type, new_id_from_str(UNKNOWN_ENTITY_NAME), firm_unknown_type);
+ set_entity_visibility(unknown_entity, visibility_external_allocated);
+ set_entity_ld_ident(unknown_entity, get_entity_ident(unknown_entity));
+
+ current_ir_graph = get_const_code_irg();
+ sym.entity_p = unknown_entity;
+ unknown_entity->value = new_SymConst(sym, symconst_addr_ent);
+} /* firm_init_entity */