added several missing #include config.h
[libfirm] / ir / tr / tr_inheritance.c
index 7e086e4..161f7d3 100644 (file)
  *  @see  type.h entity.h
  */
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include "type.h"
 #include "entity.h"
 #include "typewalk.h"
@@ -528,22 +532,26 @@ 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;
-  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;
+    entity *ent = get_entity_overwrittenby(static_ent, i);
+    ent = do_resolve_ent_polymorphy(dynamic_class, ent);
+    if (ent) return ent;
   }
-
-  return res;
+  return NULL;
 }
 
 /* Resolve polymorphy in the inheritance relation.
@@ -555,7 +563,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;