X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fiface%2FIfaceEnv.lhs;h=20d7327cfeb515a43d6b8436486860b6419e7e05;hp=8074fe0d1810d8db620d792cb618eebe782a39d8;hb=66579ff945831c5fc9a17c58c722ff01f2268d76;hpb=7fcfb091b89d24e32faf95487208caca47fd0ab8 diff --git a/compiler/iface/IfaceEnv.lhs b/compiler/iface/IfaceEnv.lhs index 8074fe0..20d7327 100644 --- a/compiler/iface/IfaceEnv.lhs +++ b/compiler/iface/IfaceEnv.lhs @@ -8,6 +8,7 @@ module IfaceEnv ( newIfaceName, newIfaceNames, extendIfaceIdEnv, extendIfaceTyVarEnv, tcIfaceLclId, tcIfaceTyVar, + tcIfaceTick, ifaceExportNames, @@ -28,12 +29,13 @@ import Name import OccName import PrelNames import Module -import UniqFM +import LazyUniqFM import FastString import UniqSupply import FiniteMap import BasicTypes import SrcLoc +import MkId import Outputable \end{code} @@ -46,7 +48,7 @@ import Outputable %********************************************************* \begin{code} -newGlobalBinder :: Module -> OccName -> SrcLoc -> TcRnIf a b Name +newGlobalBinder :: Module -> OccName -> SrcSpan -> TcRnIf a b Name -- Used for source code and interface files, to make the -- Name for a thing, given its Module and OccName -- @@ -66,7 +68,7 @@ newGlobalBinder mod occ loc allocateGlobalBinder :: NameCache - -> Module -> OccName -> SrcLoc + -> Module -> OccName -> SrcSpan -> (NameCache, Name) allocateGlobalBinder name_supply mod occ loc = case lookupOrigNameCache (nsNames name_supply) mod occ of @@ -114,7 +116,7 @@ newImplicitBinder :: Name -- Base name newImplicitBinder base_name mk_sys_occ = newGlobalBinder (nameModule base_name) (mk_sys_occ (nameOccName base_name)) - (nameSrcLoc base_name) + (nameSrcSpan base_name) ifaceExportNames :: [IfaceExport] -> TcRnIf gbl lcl [AvailInfo] ifaceExportNames exports = do @@ -130,7 +132,7 @@ lookupAvail mod (AvailTC p_occ occs) = do p_name <- lookupOrig mod p_occ let lookup_sub occ | occ == p_occ = return p_name | otherwise = lookupOrig mod occ - subs <- mappM lookup_sub occs + subs <- mapM lookup_sub occs return (AvailTC p_name subs) -- Remember that 'occs' is all the exported things, including -- the parent. It's possible to export just class ops without @@ -150,12 +152,12 @@ lookupOrig mod occ ; name_cache <- getNameCache ; case lookupOrigNameCache (nsNames name_cache) mod occ of { - Just name -> returnM name; + Just name -> return name; Nothing -> let us = nsUniqs name_cache uniq = uniqFromSupply us - name = mkExternalName uniq mod occ noSrcLoc + name = mkExternalName uniq mod occ noSrcSpan new_cache = extendNameCache (nsNames name_cache) mod occ name in case splitUniqSupply us of { (us',_) -> do @@ -164,15 +166,14 @@ lookupOrig mod occ }}} newIPName :: IPName OccName -> TcRnIf m n (IPName Name) -newIPName occ_name_ip - = getNameCache `thenM` \ name_supply -> +newIPName occ_name_ip = do + name_supply <- getNameCache let ipcache = nsIPs name_supply - in case lookupFM ipcache key of - Just name_ip -> returnM name_ip - Nothing -> setNameCache new_ns `thenM_` - returnM name_ip + Just name_ip -> return name_ip + Nothing -> do setNameCache new_ns + return name_ip where (us', us1) = splitUniqSupply (nsUniqs name_supply) uniq = uniqFromSupply us1 @@ -183,12 +184,17 @@ newIPName occ_name_ip key = occ_name_ip -- Ensures that ?x and %x get distinct Names \end{code} - Local helper functions (not exported) +%************************************************************************ +%* * + Name cache access +%* * +%************************************************************************ \begin{code} lookupOrigNameCache :: OrigNameCache -> Module -> OccName -> Maybe Name -lookupOrigNameCache nc mod occ - | mod == dATA_TUP || mod == gHC_PRIM, -- Boxed tuples from one, +lookupOrigNameCache _ mod occ + -- XXX Why is gHC_UNIT not mentioned here? + | mod == gHC_TUPLE || mod == gHC_PRIM, -- Boxed tuples from one, Just tup_info <- isTupleOcc_maybe occ -- unboxed from the other = -- Special case for tuples; there are too many -- of them to pre-populate the original-name cache @@ -206,7 +212,8 @@ lookupOrigNameCache nc mod occ -- The normal case extendOrigNameCache :: OrigNameCache -> Name -> OrigNameCache extendOrigNameCache nc name - = extendNameCache nc (nameModule name) (nameOccName name) name + = ASSERT2( isExternalName name, ppr name ) + extendNameCache nc (nameModule name) (nameOccName name) name extendNameCache :: OrigNameCache -> Module -> OccName -> Name -> OrigNameCache extendNameCache nc mod occ name @@ -292,11 +299,27 @@ lookupIfaceTop occ newIfaceName :: OccName -> IfL Name newIfaceName occ = do { uniq <- newUnique - ; return $! mkInternalName uniq occ noSrcLoc } + ; return $! mkInternalName uniq occ noSrcSpan } newIfaceNames :: [OccName] -> IfL [Name] newIfaceNames occs = do { uniqs <- newUniqueSupply - ; return [ mkInternalName uniq occ noSrcLoc + ; return [ mkInternalName uniq occ noSrcSpan | (occ,uniq) <- occs `zip` uniqsFromSupply uniqs] } \end{code} + +%************************************************************************ +%* * + (Re)creating tick boxes +%* * +%************************************************************************ + +\begin{code} +tcIfaceTick :: Module -> Int -> IfL Id +tcIfaceTick modName tickNo + = do { uniq <- newUnique + ; return $ mkTickBoxOpId uniq modName tickNo + } +\end{code} + +