diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-12-01 05:19:55 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-12-01 05:19:55 -0800 |
commit | 121a9209a20d5789f693c77e4fbe74522506f74d (patch) | |
tree | 9123f95ea1ed8fa9c237f6c551b9aaaef5cea856 /struct.c | |
parent | 61f01a3021229b3674f0dafcab74282a9945f45e (diff) | |
download | txr-121a9209a20d5789f693c77e4fbe74522506f74d.tar.gz txr-121a9209a20d5789f693c77e4fbe74522506f74d.tar.bz2 txr-121a9209a20d5789f693c77e4fbe74522506f74d.zip |
Resolve method name to supertype.
* struct.c (method_name): Don't return first match. Resolve to
most ancestral superclass which has that function in the
same slot.
Diffstat (limited to 'struct.c')
-rw-r--r-- | struct.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -1060,8 +1060,24 @@ val method_name(val fun) val slot = car(sl_iter); loc ptr = lookup_static_slot(stype, st, slot); - if (!nullocp(ptr) && deref(ptr) == fun) + if (!nullocp(ptr) && deref(ptr) == fun) { + val sstype; + + while ((sstype = super(stype)) != nil) { + struct struct_type *sst = coerce(struct struct_type *, + sstype->co.handle); + loc sptr = lookup_static_slot(sstype, sst, slot); + if (!nullocp(sptr) && deref(sptr) == fun) { + stype = sstype; + sym = sst->name; + continue; + } + + break; + } + return list(meth_s, sym, slot, nao); + } } } |