-
-/* Need two routines because I want to assert the result. */
-static 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;
-}
-
-/** Resolve polymorphy in the inheritance relation.
- *
- * 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;
- assert(static_ent && static_ent->kind == k_entity);
-
- res = resolve_ent_polymorphy2(dynamic_class, static_ent);
-#if DEBUG_libfirm
- if (!res) {
- printf(" Could not find entity "); DDME(static_ent);
- printf(" in "); DDMT(dynamic_class);
- printf("\n");
- dump_entity(static_ent);
- dump_type(get_entity_owner(static_ent));
- dump_type(dynamic_class);
- }
-#endif
- assert(res);
- return res;
-}