+/* Returns the entity that contains the implementation of the inherited
+ entity if available, else returns the entity passed. */
+entity *get_inherited_methods_implementation(entity *inh_meth) {
+ entity *impl_meth = NULL;
+ ir_node *addr = get_atomic_ent_value(inh_meth);
+ assert(addr && "constant entity without value");
+
+ if (get_irn_op(addr) == op_Const) {
+ impl_meth = get_tv_entity(get_Const_tarval(addr));
+ }
+
+ assert(!impl_meth || get_entity_peculiarity(impl_meth) == existent);
+ return impl_meth? impl_meth : inh_meth;
+}
+
+/* A recursive descend in the overwritten relation.
+ Cycle-free, therefore must terminate. */
+void collect_impls(entity *method, eset *set, int *size, bool *open) {
+ int i;
+ if (get_entity_peculiarity(method) == existent) {
+ if (get_entity_visibility(method) == external_allocated) {
+ assert(get_entity_irg(method) == NULL);
+ *open = true;
+ } else {
+ assert(get_entity_irg(method) != NULL);
+ eset_insert(set, method);
+ ++(*size);
+ }
+ }
+ if (get_entity_peculiarity(method) == inherited) {
+ entity *impl_ent = get_inherited_methods_implementation(method);
+ assert(impl_ent && "no implementation for inherited entity");
+ if (get_entity_visibility(impl_ent) == external_allocated) {
+ assert(get_entity_irg(impl_ent) == NULL);
+ *open = true;
+ } else {
+ assert(get_entity_irg(impl_ent) != NULL);
+ if (!eset_contains(set, impl_ent)) {
+ eset_insert(set, impl_ent);
+ ++(*size);
+ }
+ }
+ }
+ /** recursive descend **/
+ for (i = get_entity_n_overwrittenby(method) - 1; i >= 0; --i)
+ collect_impls(get_entity_overwrittenby(method, i) ,set, size, open);
+}
+