%
-% (c) The GRASP/AQUA Project, Glasgow University, 1992-1995
+% (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
%
-\section[RenameMonad3]{The monad used by the third renamer pass}
+\section[RnMonad3]{The monad used by the third renamer pass}
\begin{code}
#include "HsVersions.h"
-module RenameMonad3 (
+module RnMonad3 (
Rn3M(..),
initRn3, thenRn3, andRn3, returnRn3, mapRn3, fixRn3,
putInfoDownM3,
- newFullNameM3, newInvisibleNameM3,
+ newFullNameM3, newInvisibleNameM3
-- for completeness
- IE, FullName, ExportFlag, ProtoName, Unique,
- SplitUniqSupply
- IF_ATTACK_PRAGMAS(COMMA splitUniqSupply)
) where
-import AbsSyn -- including, IE, getIEStrings, ...
-import FiniteMap
-import Maybes ( Maybe(..), assocMaybe )
-import NameTypes
-import Outputable
-import ProtoName
-import RenameMonad4 ( GlobalNameFun(..) )
-import SplitUniq
-import Unique
-import Util
+import Ubiq{-uitous-}
+
+import FiniteMap ( emptyFM, isEmptyFM, lookupFM,
+ emptySet, isEmptySet, elementOf
+ )
+import HsSyn ( IE )
+import NameTypes -- lots of stuff
+import Outputable ( ExportFlag(..) )
+import ProtoName ( ProtoName(..) )
+import RdrHsSyn ( getExportees, ExportListInfo(..), ProtoNameIE(..) )
+import UniqSupply ( getUnique, splitUniqSupply )
+import Util ( panic )
infixr 9 `thenRn3`
\end{code}
%************************************************************************
%* *
-\subsection{Plain @Rename3@ monadery}
+\subsection{Plain @RnPass3@ monadery}
%* *
%************************************************************************
\begin{code}
type Rn3M result
- = ImExportListInfo -> FAST_STRING{-ModuleName-} -> SplitUniqSupply
+ = ExportListInfo -> FAST_STRING{-ModuleName-} -> UniqSupply
-> result
-#ifdef __GLASGOW_HASKELL__
{-# INLINE andRn3 #-}
{-# INLINE thenRn3 #-}
{-# INLINE returnRn3 #-}
-#endif
-initRn3 :: Rn3M a -> SplitUniqSupply -> a
+initRn3 :: Rn3M a -> UniqSupply -> a
-initRn3 m us = m (emptyFM,emptySet) (panic "initRn3: uninitialised module name") us
+initRn3 m us = m Nothing{-no export list-} (panic "initRn3: uninitialised module name") us
thenRn3 :: Rn3M a -> (a -> Rn3M b) -> Rn3M b
andRn3 :: (a -> a -> a) -> Rn3M a -> Rn3M a -> Rn3M a
where
result = m result exps mod_name us
-putInfoDownM3 :: FAST_STRING{-ModuleName-} -> [IE] -> Rn3M a -> Rn3M a
+putInfoDownM3 :: FAST_STRING{-ModuleName-} -> Maybe [ProtoNameIE] -> Rn3M a -> Rn3M a
putInfoDownM3 mod_name exports cont _ _ uniqs
- = cont (getIEStrings exports) mod_name uniqs
+ = cont (getExportees exports) mod_name uniqs
\end{code}
%************************************************************************
%* *
-\subsection[RenameMonad3-new-names]{Making new names}
+\subsection[RnMonad3-new-names]{Making new names}
%* *
%************************************************************************
new_name pn src_loc is_tycon_ish frcd_export_flag want_invisible exps mod_name uniqs
= (uniq, name)
where
- uniq = getSUnique uniqs
+ uniq = getUnique uniqs
mk_name = if want_invisible then mkPrivateFullName else mkFullName
name = case pn of
- Unk s -> mk_name mod_name s
- (if fromPrelude mod_name
- && is_tycon_ish then -- & tycon/clas/datacon => Core
- HereInPreludeCore
- else
- ThisModule
- )
- (case frcd_export_flag of
- Just fl -> fl
- Nothing -> mk_export_flag True [mod_name] s exps)
- src_loc
+ Unk s -> mk_name mod_name s
+ (if fromPrelude mod_name
+ && is_tycon_ish then -- & tycon/clas/datacon => Core
+ HereInPreludeCore
+ else
+ ThisModule
+ )
+ (case frcd_export_flag of
+ Just fl -> fl
+ Nothing -> mk_export_flag True [mod_name] s exps)
+ src_loc
+
+ Qunk m s -> mk_name mod_name s
+ (if fromPrelude mod_name
+ && is_tycon_ish then -- & tycon/clas/datacon => Core
+ HereInPreludeCore
+ else
+ ThisModule
+ )
+ (case frcd_export_flag of
+ Just fl -> fl
+ Nothing -> mk_export_flag (_trace "mk_export_flag?" True) [m] s exps)
+ src_loc
-- note: the assigning of prelude-ness is most dubious (ToDo)
OtherModule l informant_mods -- for Other*, we save its occurrence name
)
(case frcd_export_flag of
- Just fl -> fl
+ Just fl -> fl
Nothing -> mk_export_flag (m==mod_name) informant_mods l exps)
src_loc
- Prel n -> panic "RenameMonad3.new_name: prelude name"
+ Prel n -> panic "RnMonad3.new_name: prelude name"
\end{code}
In deciding the ``exportness'' of something, there are these cases to
\begin{code}
mk_export_flag :: Bool -- True <=> originally from the module we're compiling
- -> [FAST_STRING] -- modules that told us about this thing
+ -> [FAST_STRING]-- modules that told us about this thing
-> FAST_STRING -- name of the thing we're looking at
- -> ImExportListInfo
+ -> ExportListInfo
-> ExportFlag -- result
-mk_export_flag this_module informant_mods thing (exports_alist, dotdot_modules)
- | isEmptyFM exports_alist && isEmptySet dotdot_modules
+mk_export_flag this_module informant_mods thing Nothing{-no export list-}
= if this_module then ExportAll else NotExported
+mk_export_flag this_module informant_mods thing (Just (exports_alist, dotdot_modules))
| otherwise
= case (lookupFM exports_alist thing) of
Just how_to_export -> how_to_export