import Outputable
import Finder ( Finder )
import PrelNames ( mkUnboundName )
-import HscTypes ( GlobalSymbolTable, OrigNameEnv, AvailEnv,
+import HscTypes ( GlobalSymbolTable, AvailEnv,
+ OrigNameEnv(..), OrigNameNameEnv, OrigNameIParamEnv,
WhetherHasOrphans, ImportVersion, ExportItem,
PersistentRenamerState(..), IsBootInterface, Avails,
DeclsMap, IfaceInsts, IfaceRules, DeprecationEnv,
HomeSymbolTable, PackageSymbolTable,
- PersistentCompilerState(..), GlobalRdrEnv )
+ PersistentCompilerState(..), GlobalRdrEnv,
+ HomeIfaceTable, PackageIfaceTable )
infixr 9 `thenRn`, `thenRn_`
\end{code}
rn_finder :: Finder,
rn_dflags :: DynFlags,
- rn_hst :: HomeSymbolTable,
+ rn_hit :: HomeIfaceTable,
+ rn_done :: Name -> Bool, -- available before compiling this module?
rn_errs :: IORef (Bag WarnMsg, Bag ErrMsg),
- rn_ns :: IORef (UniqSupply, OrigNameEnv),
+
+ -- The second and third components are a flattened-out OrigNameEnv
+ rn_ns :: IORef (UniqSupply, OrigNameNameEnv, OrigNameIParamEnv),
rn_ifaces :: IORef Ifaces
}
pi_exports :: [ExportItem], -- Exports
pi_insts :: [RdrNameInstDecl], -- Local instance declarations
pi_decls :: [(Version, RdrNameHsDecl)], -- Local definitions
- pi_fixity :: (Version, [RdrNameFixitySig]), -- Local fixity declarations, with their version
+ pi_fixity :: (Version, [RdrNameFixitySig]), -- Local fixity declarations,
+ -- with their version
pi_rules :: (Version, [RdrNameRuleDecl]), -- Rules, with their version
pi_deprecs :: [RdrNameDeprecation] -- Deprecations
}
\begin{code}
data Ifaces = Ifaces {
-- PERSISTENT FIELDS
- iPST :: PackageSymbolTable,
- -- The ModuleDetails for modules in other packages
+ iPIT :: PackageIfaceTable,
+ -- The ModuleIFaces for modules in other packages
-- whose interfaces we have opened
- -- The contents of those interface files may be mostly
- -- in the iDecls, iInsts, iRules (below), but what *will*
- -- be in the PackageSymbolTable is:
+ -- The declarations in these interface files are held in
+ -- iDecls, iInsts, iRules (below), not in the mi_decls fields
+ -- of the iPIT. What _is_ in the iPIT is:
-- * The Module
-- * Version info
-- * Its exports
-- * Fixities
-- * Deprecations
- -- This field is initialised from the compiler's persistent
+ -- The iPIT field is initialised from the compiler's persistent
-- package symbol table, and the renamer incrementally adds
-- to it.
%************************************************************************
\begin{code}
-initRn :: DynFlags -> Finder -> HomeSymbolTable
+initRn :: DynFlags
+ -> Finder
+ -> HomeIfaceTable
-> PersistentCompilerState
- -> Module -> SrcLoc
+ -> Module
+ -> SrcLoc
-> RnMG t
-> IO (t, PersistentCompilerState, (Bag WarnMsg, Bag ErrMsg))
-initRn dflags finder hst pcs mod loc do_rn
+initRn dflags finder hit pcs mod loc do_rn
= do
let prs = pcs_PRS pcs
uniqs <- mkSplitUniqSupply 'r'
- names_var <- newIORef (uniqs, prsOrig prs)
+ names_var <- newIORef (uniqs, origNames (prsOrig prs),
+ origIParam (prsOrig prs))
errs_var <- newIORef (emptyBag,emptyBag)
iface_var <- newIORef (initIfaces pcs)
let rn_down = RnDown { rn_mod = mod,
rn_finder = finder,
rn_dflags = dflags,
- rn_hst = hst,
+ rn_hit = hit,
rn_ns = names_var,
rn_errs = errs_var,
res <- do_rn rn_down ()
-- Grab state and record it
- (warns, errs) <- readIORef errs_var
- new_ifaces <- readIORef iface_var
- (_, new_orig) <- readIORef names_var
-
- let new_prs = prs { prsOrig = new_orig,
+ (warns, errs) <- readIORef errs_var
+ new_ifaces <- readIORef iface_var
+ (_, new_origN, new_origIP) <- readIORef names_var
+ let new_orig = Orig { origNames = new_origN, origIParam = new_origIP }
+ let new_prs = prs { prsOrig = new_orig,
prsDecls = iDecls new_ifaces,
prsInsts = iInsts new_ifaces,
prsRules = iRules new_ifaces }
-- only do any I/O if we need to read in a fixity declaration;
-- and that doesn't happen in pragmas etc
- mkSplitUniqSupply 'r' >>= \ new_us ->
- newIORef (new_us, prsOrig prs) >>= \ names_var ->
- newIORef (emptyBag,emptyBag) >>= \ errs_var ->
+ mkSplitUniqSupply 'r' >>= \ new_us ->
+ newIORef (new_us, origNames (prsOrig prs),
+ origIParam (prsOrig prs)) >>= \ names_var ->
+ newIORef (emptyBag,emptyBag) >>= \ errs_var ->
let
rn_down = RnDown { rn_dflags = dflags,
rn_loc = generatedSrcLoc, rn_ns = names_var,
doptRn :: DynFlag -> RnM d Bool
doptRn dflag (RnDown { rn_dflags = dflags}) l_down
= return (dopt dflag dflags)
+
+getDOptsRn :: RnM d DynFlags
+getDOptsRn (RnDown { rn_dflags = dflags}) l_down
+ = return dflags
\end{code}
%================
-\subsubsection{ Source location}
+\subsubsection{Source location}
%=====================
\begin{code}
getFinderRn :: RnM d Finder
getFinderRn down l_down = return (rn_finder down)
-getHomeSymbolTableRn :: RnM d HomeSymbolTable
-getHomeSymbolTableRn down l_down = return (rn_hst down)
+getHomeIfaceTableRn :: RnM d HomeIfaceTable
+getHomeIfaceTableRn down l_down = return (rn_hit down)
\end{code}
%================
%=====================
\begin{code}
-getNameSupplyRn :: RnM d (UniqSupply, OrigNameEnv)
+getNameSupplyRn :: RnM d (UniqSupply, OrigNameNameEnv, OrigNameIParamEnv)
getNameSupplyRn rn_down l_down
= readIORef (rn_ns rn_down)
-setNameSupplyRn :: (UniqSupply, OrigNameEnv) -> RnM d ()
+setNameSupplyRn :: (UniqSupply, OrigNameNameEnv, OrigNameIParamEnv) -> RnM d ()
setNameSupplyRn names' (RnDown {rn_ns = names_var}) l_down
= writeIORef names_var names'
getUniqRn :: RnM d Unique
getUniqRn (RnDown {rn_ns = names_var}) l_down
- = readIORef names_var >>= \ (us, {-cache,-} ipcache) ->
+ = readIORef names_var >>= \ (us, cache, ipcache) ->
let
(us1,us') = splitUniqSupply us
in
- writeIORef names_var (us', {-cache,-} ipcache) >>
+ writeIORef names_var (us', cache, ipcache) >>
return (uniqFromSupply us1)
\end{code}