resolve_ent_polymorphy() now can handle non-flat inheritance again ...
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Thu, 12 Oct 2006 09:24:47 +0000 (09:24 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Thu, 12 Oct 2006 09:24:47 +0000 (09:24 +0000)
[r8340]

ir/tr/tr_inheritance.c

index 75fb442..e569a56 100644 (file)
@@ -528,9 +528,15 @@ int is_overwritten_by(entity *high, entity *low) {
   return 0;
 }
 
-
-/** Need two routines because I want to assert the result. */
-static entity *resolve_ent_polymorphy2 (ir_type *dynamic_class, entity *static_ent) {
+/** 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.
+ *
+ * Need two routines because I want to assert the result.
+ */
+static entity *do_resolve_ent_polymorphy(ir_type *dynamic_class, entity *static_ent) {
   int i, n_overwrittenby;
 
   if (get_entity_owner(static_ent) == dynamic_class) return static_ent;
@@ -538,7 +544,8 @@ static entity *resolve_ent_polymorphy2 (ir_type *dynamic_class, entity *static_e
   n_overwrittenby = get_entity_n_overwrittenby(static_ent);
   for (i = 0; i < n_overwrittenby; ++i) {
     entity *ent = get_entity_overwrittenby(static_ent, i);
-    if (get_entity_owner(ent) == dynamic_class) return ent;
+    ent = do_resolve_ent_polymorphy(dynamic_class, ent);
+    if (ent) return ent;
   }
   return NULL;
 }
@@ -552,7 +559,7 @@ entity *resolve_ent_polymorphy(ir_type *dynamic_class, entity *static_ent) {
   entity *res;
   assert(static_ent && is_entity(static_ent));
 
-  res = resolve_ent_polymorphy2(dynamic_class, static_ent);
+  res = do_resolve_ent_polymorphy(dynamic_class, static_ent);
   assert(res);
 
   return res;