From e4c7fc35015d5a0c5bceb993ecdb9d5da5ddbb61 Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis Date: Mon, 8 Feb 2016 00:25:37 -0800 Subject: Tidy gerCapsuleDirectoryEntry Factor out candidatesForSlot. --- src/interp/c-util.boot | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/interp/c-util.boot b/src/interp/c-util.boot index cc77d040..70675bf0 100644 --- a/src/interp/c-util.boot +++ b/src/interp/c-util.boot @@ -1478,13 +1478,20 @@ makeCapsuleFunctionContext(db,fun) == | symbolEq?(fun,rest impl)] or systemError ['"cannot find context for",:bright fun] +++ Return the list of implementations candidate for a given domain slot. +candidatesForSlot(db,slot) == + [x for x in dbCapsuleDefinitions db | x is [.,=slot,:.]] + ++ Return the linkage name of the exported operation associated with ++ slot number `slot'. A nil result means that either the operation ++ is not defined, or the scope predicates don't match. getCapsuleDirectoryEntry(fc,slot) == pred' := fcPredicate fc - or/[rest impl for [[.,:pred],:impl] in dbCapsuleDefinitions fcDatabase fc - | first impl = slot and (pred is true or pred = pred')] + candidates := candidatesForSlot(fcDatabase fc ,slot) => + -- FIXME: consider subsumption? How often does this occur? + or/[func for [[.,:pred],.,:func] in candidates + | pred = pred' or pred is true] + nil ++ `defs' is a list of function definitions from the current domain. ++ Walk that list and replace references to unconditional operations -- cgit v1.2.3