From 78344000bd296ef582677dbcbc53954ea317dcda Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Thu, 12 Oct 2006 09:24:47 +0000 Subject: [PATCH] resolve_ent_polymorphy() now can handle non-flat inheritance again ... [r8340] --- ir/tr/tr_inheritance.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ir/tr/tr_inheritance.c b/ir/tr/tr_inheritance.c index 75fb44268..e569a56f3 100644 --- a/ir/tr/tr_inheritance.c +++ b/ir/tr/tr_inheritance.c @@ -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; -- 2.20.1