\begin{code}
module HscTypes (
- ModDetails(..), GlobalSymbolTable,
+ ModDetails(..), ModIface(..), GlobalSymbolTable,
HomeSymbolTable, PackageSymbolTable,
+ HomeIfaceTable, PackageIfaceTable,
TyThing(..), groupTyThings,
unitNameEnv, extendNameEnv, plusNameEnv,
lookupNameEnv, emptyNameEnv, getName, nameModule,
nameSrcLoc )
-import Module ( Module, ModuleName,
+import Module ( Module, ModuleName, ModuleEnv,
extendModuleEnv, lookupModuleEnv )
import Class ( Class )
import OccName ( OccName )
import CoreSyn ( CoreRule )
import NameSet ( NameSet )
import Type ( Type )
+import Name ( emptyNameEnv )
import VarSet ( TyVarSet )
import Panic ( panic )
import Outputable
import SrcLoc ( SrcLoc, isGoodSrcLoc )
import Util ( thenCmp )
+import RnHsSyn ( RenamedHsDecl )
\end{code}
%************************************************************************
linking; it is the "linked" form of the mi_decls field.
\begin{code}
-data ModDetails
- = ModDetails {
- md_module :: Module, -- Complete with package info
- md_version :: VersionInfo, -- Module version number
- md_orphan :: WhetherHasOrphans, -- Whether this module has orphans
- md_usages :: [ImportVersion Name], -- Usages
+data ModIface
+ = ModIface {
+ mi_module :: Module, -- Complete with package info
+ mi_version :: VersionInfo, -- Module version number
+ mi_orphan :: WhetherHasOrphans, -- Whether this module has orphans
+ mi_usages :: [ImportVersion Name], -- Usages
- md_exports :: Avails, -- What it exports
- md_globals :: GlobalRdrEnv, -- Its top level environment
+ mi_exports :: Avails, -- What it exports
+ mi_globals :: GlobalRdrEnv, -- Its top level environment
- md_fixities :: NameEnv Fixity, -- Fixities
- md_deprecs :: NameEnv DeprecTxt, -- Deprecations
+ mi_fixities :: NameEnv Fixity, -- Fixities
+ mi_deprecs :: NameEnv DeprecTxt, -- Deprecations
+
+ mi_decls :: [RenamedHsDecl] -- types, classes
+ -- inst decls, rules, iface sigs
+ }
+-- typechecker should only look at this, not ModIface
+-- Should be able to construct ModDetails from mi_decls in ModIface
+data ModDetails
+ = ModDetails {
-- The next three fields are created by the typechecker
md_types :: TypeEnv,
md_insts :: [DFunId], -- Dfun-ids for the instances in this module
md_rules :: RuleEnv -- Domain may include Ids from other modules
}
-
--- ModIFace is nearly the same as RnMonad.ParsedIface.
--- Right now it's identical :)
-data ModIFace
- = ModIFace {
- mi_mod :: Module, -- Complete with package info
- mi_vers :: Version, -- Module version number
- mi_orphan :: WhetherHasOrphans, -- Whether this module has orphans
- mi_usages :: [ImportVersion OccName], -- Usages
- mi_exports :: [ExportItem], -- Exports
- mi_insts :: [RdrNameInstDecl], -- Local instance declarations
- mi_decls :: [(Version, RdrNameHsDecl)], -- Local definitions
- mi_fixity :: (Version, [RdrNameFixitySig]), -- Local fixity declarations,
- -- with their version
- mi_rules :: (Version, [RdrNameRuleDecl]), -- Rules, with their version
- mi_deprecs :: [RdrNameDeprecation] -- Deprecations
- }
-
\end{code}
\begin{code}
-emptyModDetails :: Module -> ModDetails
-emptyModDetails mod
- = ModDetails { md_module = mod,
- md_exports = [],
- md_globals = emptyRdrEnv,
- md_fixities = emptyNameEnv,
- md_deprecs = emptyNameEnv,
- md_types = emptyNameEnv,
- md_insts = [],
- md_rules = emptyRuleEnv
+emptyModDetails :: ModDetails
+emptyModDetails
+ = ModDetails { md_types = emptyTypeEnv,
+ md_insts = [],
+ md_rules = emptyRuleEnv
+ }
+
+emptyModIface :: Module -> ModIface
+emptyModIface mod
+ = ModIface { mi_module = mod,
+ mi_exports = [],
+ mi_globals = emptyRdrEnv,
+ mi_deprecs = emptyNameEnv,
}
\end{code}
\begin{code}
type SymbolTable = ModuleEnv ModDetails
+type IfaceTable = ModuleEnv ModIface
+
+type HomeIfaceTable = IfaceTable
+type PackageIfaceTable = IfaceTable
+
type HomeSymbolTable = SymbolTable -- Domain = modules in the home package
type PackageSymbolTable = SymbolTable -- Domain = modules in the some other package
type GlobalSymbolTable = SymbolTable -- Domain = all modules
Simple lookups in the symbol table.
\begin{code}
-lookupFixityEnv :: SymbolTable -> Name -> Maybe Fixity
+lookupFixityEnv :: IfaceTable -> Name -> Maybe Fixity
-- Returns defaultFixity if there isn't an explicit fixity
lookupFixityEnv tbl name
= case lookupModuleEnv tbl (nameModule name) of
Nothing -> Nothing
- Just details -> lookupNameEnv (md_fixities details) name
+ Just details -> lookupNameEnv (mi_fixities details) name
\end{code}
\begin{code}
type TypeEnv = NameEnv TyThing
+emptyTypeEnv = emptyNameEnv
data TyThing = AnId Id
| ATyCon TyCon
where
new_details
= case lookupModuleEnv tbl mod of
- Nothing -> (emptyModDetails mod) {md_types = type_env}
+ Nothing -> emptyModDetails {md_types = type_env}
Just details -> details {md_types = md_types details
`plusNameEnv` type_env}
\end{code}
\begin{code}
data CompResult
= CompOK ModDetails -- new details (HST additions)
- (Maybe (ModIFace, Linkable))
+ (Maybe (ModIface, Linkable))
-- summary and code; Nothing => compilation not reqd
-- (old summary and code are still valid)
PersistentCompilerState -- updated PCS
data HscResult
= HscOK ModDetails -- new details (HomeSymbolTable additions)
- (Maybe ModIFace) -- new iface (if any compilation was done)
+ (Maybe ModIface) -- new iface (if any compilation was done)
(Maybe String) -- generated stub_h filename (in /tmp)
(Maybe String) -- generated stub_c filename (in /tmp)
(Maybe [UnlinkedIBind]) -- interpreted code, if any
| HscErrs PersistentCompilerState -- updated PCS
(Bag ErrMsg) -- errors
(Bag WarnMsg) -- warnings
-
--- These two are only here to avoid recursion between CmCompile and
--- CompManager. They really ought to be in the latter.
-type ModuleEnv a = UniqFM a -- Domain is Module
-
-type HomeModMap = FiniteMap ModuleName Module -- domain: home mods only
-type HomeInterfaceTable = ModuleEnv ModIFace
\end{code}
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),
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'
rn_finder = finder,
rn_dflags = dflags,
- rn_hst = hst,
+ rn_hit = hit,
rn_ns = names_var,
rn_errs = errs_var,
%================
-\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}
%================