X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fprelude%2FPrelInfo.lhs;h=e97d2882b6767fadc9de76311c759bb9bcb40ad3;hb=d0bf18ef6ff50e8764231537f1052a81ac65b229;hp=9bbfc6761be0e0e546411c84a02fd2b77348a664;hpb=9bedea20f62a1da832c69833c39dd1d15e6ee9a3;p=ghc-hetmet.git diff --git a/ghc/compiler/prelude/PrelInfo.lhs b/ghc/compiler/prelude/PrelInfo.lhs index 9bbfc67..e97d288 100644 --- a/ghc/compiler/prelude/PrelInfo.lhs +++ b/ghc/compiler/prelude/PrelInfo.lhs @@ -8,10 +8,10 @@ module PrelInfo ( module PrelNames, module MkId, - wiredInNames, -- Names of wired in things - wiredInThings, - maybeWiredInTyConName, - maybeWiredInIdName, + wiredInThings, -- Names of wired in things + wiredInThingEnv, + ghcPrimExports, + cCallableClassDecl, cReturnableClassDecl, assertDecl, -- Primop RdrNames eqH_Char_RDR, ltH_Char_RDR, eqH_Word_RDR, ltH_Word_RDR, @@ -30,28 +30,27 @@ module PrelInfo ( #include "HsVersions.h" --- friends: import PrelNames -- Prelude module names -import PrimOp ( PrimOp(..), allThePrimOps, primOpRdrName ) -import DataCon ( DataCon, dataConId, dataConWrapId ) +import PrimOp ( PrimOp(..), allThePrimOps, primOpRdrName, primOpOcc ) +import DataCon ( DataCon ) +import Id ( idName ) import MkId ( mkPrimOpId, wiredInIds ) import MkId -- All of it, for re-export +import Name ( nameOccName, nameRdrName ) +import RdrName ( mkRdrUnqual ) +import HsSyn ( HsTyVarBndr(..), TyClDecl(..), HsType(..) ) +import OccName ( mkVarOcc ) import TysPrim ( primTyCons ) import TysWiredIn ( wiredInTyCons ) -import HscTypes ( TyThing(..) ) -import Id ( Id, idName ) - --- others: -import RdrName ( RdrName ) -import Name ( Name, getName ) -import TyCon ( tyConDataConsIfAvailable, TyCon, tyConName ) +import RdrHsSyn ( mkClassDecl ) +import HscTypes ( TyThing(..), implicitTyThingIds, TypeEnv, mkTypeEnv, + GenAvailInfo(..), RdrAvailInfo ) import Class ( Class, classKey ) -import Type ( funTyCon ) -import Bag -import BasicTypes ( Boxity(..) ) +import Type ( funTyCon, openTypeKind, liftedTypeKind ) +import TyCon ( tyConName ) +import SrcLoc ( noSrcLoc ) import Util ( isIn ) -import Outputable ( ppr, pprPanic ) \end{code} %************************************************************************ @@ -67,8 +66,9 @@ We have two ``builtin name funs,'' one to look up @TyCons@ and wiredInThings :: [TyThing] wiredInThings = concat - [ -- Wired in TyCons - map ATyCon ([funTyCon] ++ primTyCons ++ wiredInTyCons) + [ -- Wired in TyCons and their implicit Ids + tycon_things + , map AnId (implicitTyThingIds tycon_things) -- Wired in Ids , map AnId wiredInIds @@ -76,35 +76,68 @@ wiredInThings -- PrimOps , map (AnId . mkPrimOpId) allThePrimOps ] + where + tycon_things = map ATyCon ([funTyCon] ++ primTyCons ++ wiredInTyCons) -wiredInNames :: [Name] -wiredInNames = [n | thing <- wiredInThings, n <- tyThingNames thing] - -tyThingNames :: TyThing -> [Name] -tyThingNames (AClass cl) = pprPanic "tyThingNames" (ppr cl) -- Not used -tyThingNames (AnId id) = [getName id] -tyThingNames (ATyCon tc) - = getName tc : [ getName n | dc <- tyConDataConsIfAvailable tc, - n <- [dataConId dc, dataConWrapId dc] ] - -- Synonyms return empty list of constructors - -maybeWiredInIdName :: Name -> Maybe Id -maybeWiredInIdName nm - = case filter ((== nm).idName) wiredInIds of - [] -> Nothing - (i:is) -> Just i - -maybeWiredInTyConName :: Name -> Maybe TyCon -maybeWiredInTyConName nm - = case filter ((== nm).tyConName) wiredInTyCons of - [] -> Nothing - (tc:tcs) -> Just tc +wiredInThingEnv :: TypeEnv +wiredInThingEnv = mkTypeEnv wiredInThings \end{code} We let a lot of "non-standard" values be visible, so that we can make sense of them in interface pragmas. It's cool, though they all have "non-standard" names, so they won't get past the parser in user code. +%************************************************************************ +%* * +\subsection{Export lists for pseudo-modules (GHC.Prim)} +%* * +%************************************************************************ + +GHC.Prim "exports" all the primops and primitive types, some +wired-in Ids, and the CCallable & CReturnable classes. + +\begin{code} +ghcPrimExports :: [RdrAvailInfo] + = AvailTC cCallableOcc [ cCallableOcc ] : + AvailTC cReturnableOcc [ cReturnableOcc ] : + Avail (nameOccName assertName) : -- doesn't have an Id + map (Avail . nameOccName . idName) ghcPrimIds ++ + map (Avail . primOpOcc) allThePrimOps ++ + [ AvailTC occ [occ] | + n <- funTyCon : primTyCons, let occ = nameOccName (tyConName n) + ] + where + cCallableOcc = nameOccName cCallableClassName + cReturnableOcc = nameOccName cReturnableClassName + +assertDecl + = IfaceSig { + tcdName = nameRdrName assertName, + tcdType = HsForAllTy (Just [liftedAlpha]) [] (HsTyVar alpha), + tcdIdInfo = [], + tcdLoc = noSrcLoc + } + +cCallableClassDecl + = mkClassDecl + ([], nameRdrName cCallableClassName, [openAlpha]) + [] -- no fds + [] -- no sigs + Nothing -- no mbinds + noSrcLoc + +cReturnableClassDecl + = mkClassDecl + ([], nameRdrName cReturnableClassName, [openAlpha]) + [] -- no fds + [] -- no sigs + Nothing -- no mbinds + noSrcLoc + +alpha = mkRdrUnqual (mkVarOcc FSLIT("a")) +openAlpha = IfaceTyVar alpha openTypeKind +liftedAlpha = IfaceTyVar alpha liftedTypeKind +\end{code} %************************************************************************ %* *