#include "HsVersions.h"
import Module ( ModuleName, mkPrelModule, mkModuleName )
-import OccName ( NameSpace, varName, dataName, tcName, clsName )
-import RdrName ( RdrName, mkPreludeQual )
+import OccName ( NameSpace, UserFS, varName, dataName, tcName, clsName, mkKindOccFS )
+import RdrName ( RdrName, mkOrig, mkUnqual )
import UniqFM
import Unique ( Unique, Uniquable(..), hasKey,
mkPreludeMiscIdUnique, mkPreludeDataConUnique,
import UniqFM ( UniqFM, listToUFM )
import Name ( Name, mkLocalName, mkKnownKeyGlobal, nameRdrName )
import RdrName ( rdrNameOcc )
-import SrcLoc ( noSrcLoc )
+import SrcLoc ( builtinSrcLoc )
import Util ( nOfThem )
import Panic ( panic )
\end{code}
fromRationalName,
deRefStablePtrName,
- makeStablePtrName,
+ newStablePtrName,
bindIOName,
returnIOName,
%************************************************************************
\begin{code}
-mkTupNameStr :: Boxity -> Int -> (ModuleName, FAST_STRING)
+mkTupNameStr :: Boxity -> Int -> (ModuleName, UserFS)
mkTupNameStr Boxed 0 = (pREL_BASE_Name, SLIT("()"))
mkTupNameStr Boxed 1 = panic "Name.mkTupNameStr: 1 ???"
mkTupConRdrName :: NameSpace -> Boxity -> Arity -> RdrName
mkTupConRdrName space boxity arity = case mkTupNameStr boxity arity of
- (mod, occ) -> mkPreludeQual space mod occ
+ (mod, occ) -> mkOrig space mod occ
+\end{code}
+
+
+%************************************************************************
+%* *
+\subsection{Unqualified RdrNames}
+%* *
+%************************************************************************
+
+\begin{code}
+main_RDR_Unqual :: RdrName
+main_RDR_Unqual = mkUnqual varName SLIT("main")
+-- Don't get a RdrName from PrelNames.mainName, because nameRdrName
+-- gets an Orig RdrName, and we want a Qual or Unqual one. An Unqual
+-- one will do fine.
\end{code}
%* *
%************************************************************************
-These RdrNames are not really "built in", but some parts of the
+Many of these Names are not really "built in", but some parts of the
compiler (notably the deriving mechanism) need to mention their names,
and it's convenient to write them all down in one place.
mainName = varQual mAIN_Name SLIT("main") mainKey
-- Stuff from PrelGHC
-funTyConName = tcQual pREL_GHC_Name SLIT("(->)") funTyConKey
-cCallableClassName = clsQual pREL_GHC_Name SLIT("CCallable") cCallableClassKey
-cReturnableClassName = clsQual pREL_GHC_Name SLIT("CReturnable") cReturnableClassKey
+usOnceTyConName = kindQual SLIT(".") usOnceTyConKey
+usManyTyConName = kindQual SLIT("!") usManyTyConKey
+superKindName = kindQual SLIT("KX") kindConKey
+superBoxityName = kindQual SLIT("BX") boxityConKey
+boxedConName = kindQual SLIT("*") boxedConKey
+unboxedConName = kindQual SLIT("#") unboxedConKey
+openKindConName = kindQual SLIT("?") anyBoxConKey
+usageKindConName = kindQual SLIT("$") usageConKey
+typeConName = kindQual SLIT("Type") typeConKey
+
+funTyConName = tcQual pREL_GHC_Name SLIT("(->)") funTyConKey
+charPrimTyConName = tcQual pREL_GHC_Name SLIT("Char#") charPrimTyConKey
+intPrimTyConName = tcQual pREL_GHC_Name SLIT("Int#") intPrimTyConKey
+int64PrimTyConName = tcQual pREL_GHC_Name SLIT("Int64#") int64PrimTyConKey
+wordPrimTyConName = tcQual pREL_GHC_Name SLIT("Word#") wordPrimTyConKey
+word64PrimTyConName = tcQual pREL_GHC_Name SLIT("Word64#") word64PrimTyConKey
+addrPrimTyConName = tcQual pREL_GHC_Name SLIT("Addr#") addrPrimTyConKey
+floatPrimTyConName = tcQual pREL_GHC_Name SLIT("Float#") floatPrimTyConKey
+doublePrimTyConName = tcQual pREL_GHC_Name SLIT("Double#") doublePrimTyConKey
+statePrimTyConName = tcQual pREL_GHC_Name SLIT("State#") statePrimTyConKey
+realWorldTyConName = tcQual pREL_GHC_Name SLIT("RealWorld") realWorldTyConKey
+arrayPrimTyConName = tcQual pREL_GHC_Name SLIT("Array#") arrayPrimTyConKey
+byteArrayPrimTyConName = tcQual pREL_GHC_Name SLIT("ByteArray#") byteArrayPrimTyConKey
+mutableArrayPrimTyConName = tcQual pREL_GHC_Name SLIT("MutableArray#") mutableArrayPrimTyConKey
+mutableByteArrayPrimTyConName = tcQual pREL_GHC_Name SLIT("MutableByteArray#") mutableByteArrayPrimTyConKey
+mutVarPrimTyConName = tcQual pREL_GHC_Name SLIT("MutVar#") mutVarPrimTyConKey
+mVarPrimTyConName = tcQual pREL_GHC_Name SLIT("MVar#") mVarPrimTyConKey
+stablePtrPrimTyConName = tcQual pREL_GHC_Name SLIT("StablePtr#") stablePtrPrimTyConKey
+stableNamePrimTyConName = tcQual pREL_GHC_Name SLIT("StableName#") stableNamePrimTyConKey
+foreignObjPrimTyConName = tcQual pREL_GHC_Name SLIT("ForeignObj#") foreignObjPrimTyConKey
+bcoPrimTyConName = tcQual pREL_GHC_Name SLIT("BCO#") bcoPrimTyConKey
+weakPrimTyConName = tcQual pREL_GHC_Name SLIT("Weak#") weakPrimTyConKey
+threadIdPrimTyConName = tcQual pREL_GHC_Name SLIT("ThreadId#") threadIdPrimTyConKey
+cCallableClassName = clsQual pREL_GHC_Name SLIT("CCallable") cCallableClassKey
+cReturnableClassName = clsQual pREL_GHC_Name SLIT("CReturnable") cReturnableClassKey
-- PrelBase data types and constructors
charTyConName = tcQual pREL_BASE_Name SLIT("Char") charTyConKey
-- Forign objects and weak pointers
foreignObjTyConName = tcQual pREL_IO_BASE_Name SLIT("ForeignObj") foreignObjTyConKey
foreignObjDataConName = dataQual pREL_IO_BASE_Name SLIT("ForeignObj") foreignObjDataConKey
-bcoPrimTyConName = tcQual pREL_BASE_Name SLIT("BCO#") bcoPrimTyConKey
stablePtrTyConName = tcQual pREL_STABLE_Name SLIT("StablePtr") stablePtrTyConKey
stablePtrDataConName = dataQual pREL_STABLE_Name SLIT("StablePtr") stablePtrDataConKey
deRefStablePtrName = varQual pREL_STABLE_Name SLIT("deRefStablePtr") deRefStablePtrIdKey
-makeStablePtrName = varQual pREL_STABLE_Name SLIT("makeStablePtr") makeStablePtrIdKey
+newStablePtrName = varQual pREL_STABLE_Name SLIT("newStablePtr") newStablePtrIdKey
errorName = varQual pREL_ERR_Name SLIT("error") errorIdKey
assertName = varQual pREL_GHC_Name SLIT("assert") assertIdKey
pre-assigned keys. Mostly these names are used in generating deriving
code, which is passed through the renamer anyway.
+ THEY ARE ALL ORIGINAL NAMES, HOWEVER
+
\begin{code}
-unpackCString_RDR = varQual_RDR pREL_BASE_Name SLIT("unpackCString#")
-unpackCStringFoldr_RDR = varQual_RDR pREL_BASE_Name SLIT("unpackFoldrCString#")
-unpackCStringUtf8_RDR = varQual_RDR pREL_BASE_Name SLIT("unpackCStringUtf8#")
-deRefStablePtr_RDR = varQual_RDR pREL_STABLE_Name SLIT("deRefStablePtr")
-makeStablePtr_RDR = varQual_RDR pREL_STABLE_Name SLIT("makeStablePtr")
-bindIO_RDR = varQual_RDR pREL_IO_BASE_Name SLIT("bindIO")
-returnIO_RDR = varQual_RDR pREL_IO_BASE_Name SLIT("returnIO")
-
-main_RDR = varQual_RDR mAIN_Name SLIT("main")
+-- Lists and tuples
+tupleCon_RDR, tupleTyCon_RDR :: Int -> RdrName
+ubxTupleCon_RDR, ubxTupleTyCon_RDR :: Int -> RdrName
+
+tupleCon_RDR = mkTupConRdrName dataName Boxed
+tupleTyCon_RDR = mkTupConRdrName tcName Boxed
+ubxTupleCon_RDR = mkTupConRdrName dataName Unboxed
+ubxTupleTyCon_RDR = mkTupConRdrName tcName Unboxed
+
+unitCon_RDR = dataQual_RDR pREL_BASE_Name SLIT("()")
+unitTyCon_RDR = tcQual_RDR pREL_BASE_Name SLIT("()")
+
and_RDR = varQual_RDR pREL_BASE_Name SLIT("&&")
not_RDR = varQual_RDR pREL_BASE_Name SLIT("not")
compose_RDR = varQual_RDR pREL_BASE_Name SLIT(".")
assertErr_RDR = varQual_RDR pREL_ERR_Name SLIT("assertError")
\end{code}
+These RDR names also have known keys, so we need to get back the RDR names to
+populate the occurrence list above.
+
+\begin{code}
+funTyCon_RDR = nameRdrName funTyConName
+nilCon_RDR = nameRdrName nilDataConName
+listTyCon_RDR = nameRdrName listTyConName
+ioTyCon_RDR = nameRdrName ioTyConName
+intTyCon_RDR = nameRdrName intTyConName
+eq_RDR = nameRdrName eqName
+ge_RDR = nameRdrName geName
+numClass_RDR = nameRdrName numClassName
+ordClass_RDR = nameRdrName ordClassName
+map_RDR = nameRdrName mapName
+append_RDR = nameRdrName appendName
+foldr_RDR = nameRdrName foldrName
+build_RDR = nameRdrName buildName
+enumFromTo_RDR = nameRdrName enumFromToName
+returnM_RDR = nameRdrName returnMName
+thenM_RDR = nameRdrName thenMName
+failM_RDR = nameRdrName failMName
+false_RDR = nameRdrName falseDataConName
+true_RDR = nameRdrName trueDataConName
+error_RDR = nameRdrName errorName
+getTag_RDR = nameRdrName getTagName
+fromEnum_RDR = nameRdrName fromEnumName
+toEnum_RDR = nameRdrName toEnumName
+enumFrom_RDR = nameRdrName enumFromName
+mkInt_RDR = nameRdrName intDataConName
+enumFromThen_RDR = nameRdrName enumFromThenName
+enumFromThenTo_RDR = nameRdrName enumFromThenToName
+ratioDataCon_RDR = nameRdrName ratioDataConName
+plusInteger_RDR = nameRdrName plusIntegerName
+timesInteger_RDR = nameRdrName timesIntegerName
+enumClass_RDR = nameRdrName enumClassName
+monadClass_RDR = nameRdrName monadClassName
+ioDataCon_RDR = nameRdrName ioDataConName
+cCallableClass_RDR = nameRdrName cCallableClassName
+cReturnableClass_RDR = nameRdrName cReturnableClassName
+eqClass_RDR = nameRdrName eqClassName
+eqString_RDR = nameRdrName eqStringName
+unpackCString_RDR = nameRdrName unpackCStringName
+unpackCStringFoldr_RDR = nameRdrName unpackCStringFoldrName
+unpackCStringUtf8_RDR = nameRdrName unpackCStringUtf8Name
+deRefStablePtr_RDR = nameRdrName deRefStablePtrName
+newStablePtr_RDR = nameRdrName newStablePtrName
+bindIO_RDR = nameRdrName bindIOName
+returnIO_RDR = nameRdrName returnIOName
+fromInteger_RDR = nameRdrName fromIntegerName
+fromRational_RDR = nameRdrName fromRationalName
+minus_RDR = nameRdrName minusName
+\end{code}
+
%************************************************************************
%* *
\subsection{Local helpers}
%* *
%************************************************************************
-\begin{code}
-varQual mod str uq = mkKnownKeyGlobal (mkPreludeQual varName mod str) uq
-dataQual mod str uq = mkKnownKeyGlobal (mkPreludeQual dataName mod str) uq
-tcQual mod str uq = mkKnownKeyGlobal (mkPreludeQual tcName mod str) uq
-clsQual mod str uq = mkKnownKeyGlobal (mkPreludeQual clsName mod str) uq
+All these are original names; hence mkOrig
-varQual_RDR mod str = mkPreludeQual varName mod str
-dataQual_RDR mod str = mkPreludeQual dataName mod str
+\begin{code}
+varQual mod str uq = mkKnownKeyGlobal (varQual_RDR mod str) uq
+dataQual mod str uq = mkKnownKeyGlobal (dataQual_RDR mod str) uq
+tcQual mod str uq = mkKnownKeyGlobal (tcQual_RDR mod str) uq
+clsQual mod str uq = mkKnownKeyGlobal (clsQual_RDR mod str) uq
+
+kindQual str uq = mkLocalName uq (mkKindOccFS tcName str) builtinSrcLoc
+ -- Kinds are not z-encoded in interface file, hence mkKindOccFS
+ -- And they don't come from any particular module; indeed we always
+ -- want to print them unqualified. Hence the LocalName
+
+varQual_RDR mod str = mkOrig varName mod str
+tcQual_RDR mod str = mkOrig tcName mod str
+clsQual_RDR mod str = mkOrig clsName mod str
+dataQual_RDR mod str = mkOrig dataName mod str
\end{code}
%************************************************************************
threadIdPrimTyConKey = mkPreludeTyConUnique 70
bcoPrimTyConKey = mkPreludeTyConUnique 71
+-- Usage type constructors
+usageConKey = mkPreludeTyConUnique 72
+usOnceTyConKey = mkPreludeTyConUnique 73
+usManyTyConKey = mkPreludeTyConUnique 74
+
-- Generic Type Constructors
-crossTyConKey = mkPreludeTyConUnique 72
-plusTyConKey = mkPreludeTyConUnique 73
-genUnitTyConKey = mkPreludeTyConUnique 74
+crossTyConKey = mkPreludeTyConUnique 75
+plusTyConKey = mkPreludeTyConUnique 76
+genUnitTyConKey = mkPreludeTyConUnique 77
\end{code}
%************************************************************************
bindIOIdKey = mkPreludeMiscIdUnique 36
returnIOIdKey = mkPreludeMiscIdUnique 37
deRefStablePtrIdKey = mkPreludeMiscIdUnique 38
-makeStablePtrIdKey = mkPreludeMiscIdUnique 39
+newStablePtrIdKey = mkPreludeMiscIdUnique 39
getTagIdKey = mkPreludeMiscIdUnique 40
plusIntegerIdKey = mkPreludeMiscIdUnique 41
timesIntegerIdKey = mkPreludeMiscIdUnique 42
-- or for taggery.
-- ordClass: really it's the methods that are actually used.
-- numClass: for Int literals
-
--- these RDR names also have known keys, so we need to get back the RDR names to
--- populate the occurrence list above.
-ioTyCon_RDR = nameRdrName ioTyConName
-intTyCon_RDR = nameRdrName intTyConName
-eq_RDR = nameRdrName eqName
-ge_RDR = nameRdrName geName
-numClass_RDR = nameRdrName numClassName
-ordClass_RDR = nameRdrName ordClassName
-map_RDR = nameRdrName mapName
-append_RDR = nameRdrName appendName
-foldr_RDR = nameRdrName foldrName
-build_RDR = nameRdrName buildName
-enumFromTo_RDR = nameRdrName enumFromToName
-returnM_RDR = nameRdrName returnMName
-thenM_RDR = nameRdrName thenMName
-failM_RDR = nameRdrName failMName
-false_RDR = nameRdrName falseDataConName
-true_RDR = nameRdrName trueDataConName
-error_RDR = nameRdrName errorName
-getTag_RDR = nameRdrName getTagName
-fromEnum_RDR = nameRdrName fromEnumName
-toEnum_RDR = nameRdrName toEnumName
-enumFrom_RDR = nameRdrName enumFromName
-mkInt_RDR = nameRdrName intDataConName
-enumFromThen_RDR = nameRdrName enumFromThenName
-enumFromThenTo_RDR = nameRdrName enumFromThenToName
-ratioDataCon_RDR = nameRdrName ratioDataConName
-plusInteger_RDR = nameRdrName plusIntegerName
-timesInteger_RDR = nameRdrName timesIntegerName
-enumClass_RDR = nameRdrName enumClassName
-monadClass_RDR = nameRdrName monadClassName
-ioDataCon_RDR = nameRdrName ioDataConName
-cCallableClass_RDR = nameRdrName cCallableClassName
-cReturnableClass_RDR = nameRdrName cReturnableClassName
-eqClass_RDR = nameRdrName eqClassName
-eqString_RDR = nameRdrName eqStringName
\end{code}
-- mkUnboundName makes a place-holder Name; it shouldn't be looked at except possibly
-- during compiler debugging.
mkUnboundName :: RdrName -> Name
-mkUnboundName rdr_name = mkLocalName unboundKey (rdrNameOcc rdr_name) noSrcLoc
+mkUnboundName rdr_name = mkLocalName unboundKey (rdrNameOcc rdr_name) builtinSrcLoc
isUnboundName :: Name -> Bool
isUnboundName name = name `hasKey` unboundKey