diff options
Diffstat (limited to 'src/interp')
-rw-r--r-- | src/interp/c-util.boot | 26 | ||||
-rw-r--r-- | src/interp/define.boot | 2 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/interp/c-util.boot b/src/interp/c-util.boot index 88565415..c45159a7 100644 --- a/src/interp/c-util.boot +++ b/src/interp/c-util.boot @@ -355,7 +355,33 @@ TrimCF() == new:= [[first u,:NREVERSE unew],:new] $CategoryFrame:= [[NREVERSE new]] nil + +--% + +++ Returns non-nil if `t' is a known type in the environement `e'. +isKnownType: (%Mode,%Env) -> %Form +isKnownType(t,e) == + atom t => + t in '($ constant) => t + t' := assoc(t,getDomainsInScope e) => t' + get(first getmode(t,e),"isCategory",$CategoryFrame) => t + STRINGP t => t + t is ["Mapping",:sig] => + and/[isKnownType(t',e) for t' in sig] => t + nil + ctor := first t + ctor in $BuiltinConstructorNames => t -- ??? check Record and Union fields + -- ??? Ideally `e' should be a local extension of $CategoryFrame + -- ??? so that we don't have to access it here as a global state. + get(ctor,"isFunctor",$CategoryFrame) + or get(ctor,"isCategory",$CategoryFrame) => t + nil +diagnoseUknownType: (%Mode,%Env) -> %Thing +diagnoseUknownType(t,e) == + if not isKnownType(t,e) then + stackWarning('"%1pb is unknown. Try importing it.",[t]) + --% PREDICATES diff --git a/src/interp/define.boot b/src/interp/define.boot index 14ff75a1..5b017517 100644 --- a/src/interp/define.boot +++ b/src/interp/define.boot @@ -1602,4 +1602,6 @@ compCategoryItem(x,predl) == nil --4. branch on a single type or a signature %with source and target + for t in first sig repeat + diagnoseUknownType(t,e) PUSH(MKQ [rest x,pred],$sigList) |