2 % (c) The University of Glasgow, 2000
4 \section[HscTypes]{Types for the per-module compiler}
10 #include "HsVersions.h"
14 %************************************************************************
16 \subsection{Module details}
18 %************************************************************************
20 A @ModDetails@ summarises everything we know about a compiled module
25 moduleExports :: Avails, -- What it exports
26 moduleEnv :: GlobalRdrEnv, -- Its top level environment
28 fixityEnv :: NameEnv Fixity,
29 deprecEnv :: NameEnv DeprecTxt,
30 typeEnv :: NameEnv TyThing, -- TyThing is in TcEnv.lhs
33 ruleEnv :: IdEnv [CoreRule] -- Domain includes Ids from other modules
40 type DeprecationEnv = NameEnv DeprecTxt -- Give reason for deprecation
42 type GlobalRdrEnv = RdrNameEnv [Name] -- The list is because there may be name clashes
43 -- These only get reported on lookup,
44 -- not on construction
46 data GenAvailInfo name = Avail name -- An ordinary identifier
47 | AvailTC name -- The name of the type or class
48 [name] -- The available pieces of type/class.
49 -- NB: If the type or class is itself
50 -- to be in scope, it must be in this list.
51 -- Thus, typically: AvailTC Eq [Eq, ==, /=]
53 -- Equality used when deciding if the interface has changed
55 type AvailEnv = NameEnv AvailInfo -- Maps a Name to the AvailInfo that contains it
56 type AvailInfo = GenAvailInfo Name
57 type RdrAvailInfo = GenAvailInfo OccName
58 type Avails = [AvailInfo]
62 %************************************************************************
66 %************************************************************************
69 -- ModIFace is nearly the same as RnMonad.ParsedIface.
70 -- Right now it's identical :)
73 mi_mod :: Module, -- Complete with package info
74 mi_vers :: Version, -- Module version number
75 mi_orphan :: WhetherHasOrphans, -- Whether this module has orphans
76 mi_usages :: [ImportVersion OccName], -- Usages
77 mi_exports :: [ExportItem], -- Exports
78 mi_insts :: [RdrNameInstDecl], -- Local instance declarations
79 mi_decls :: [(Version, RdrNameHsDecl)], -- Local definitions
80 mi_fixity :: (Version, [RdrNameFixitySig]), -- Local fixity declarations,
82 mi_rules :: (Version, [RdrNameRuleDecl]), -- Rules, with their version
83 mi_deprecs :: [RdrNameDeprecation] -- Deprecations
87 %************************************************************************
89 \subsection{The persistent compiler state}
91 %************************************************************************
94 data PersistentCompilerState
96 pcsPST :: PackageSymbolTable, -- Domain = non-home-package modules
97 pcsHP :: HoldingPen, -- Pre-slurped interface bits and pieces
98 pcsNS :: NameSupply -- Allocate uniques for names
101 type PackageSymbolTable = ModuleEnv ModDetails
104 = NS { nsUniqs :: UniqSupply,
105 nsNames :: FiniteMap (Module,OccName) Name -- Ensures that one original name gets one unique
106 nsIParam :: FiniteMap OccName Name -- Ensures that one implicit parameter name gets one unique
110 %************************************************************************
112 \subsection{The result of compiling one module}
114 %************************************************************************
118 = CompOK ModDetails -- new details (HST additions)
119 (Maybe (ModIFace, Linkable))
120 -- summary and code; Nothing => compilation not reqd
121 -- (old summary and code are still valid)
122 PersistentCompilerState -- updated PCS
125 | CompErrs PersistentCompilerState -- updated PCS
130 -- The driver sits between 'compile' and 'hscMain', translating calls
131 -- to the former into calls to the latter, and results from the latter
132 -- into results from the former. It does things like preprocessing
133 -- the .hs file if necessary, and compiling up the .stub_c files to
134 -- generate Linkables.
137 = HscOK ModDetails -- new details (HomeSymbolTable additions)
138 Maybe ModIFace -- new iface (if any compilation was done)
139 Maybe String -- generated stub_h
140 Maybe String -- generated stub_c
141 PersistentCompilerState -- updated PCS
144 | HscErrs PersistentCompilerState -- updated PCS
150 -- These two are only here to avoid recursion between CmCompile and
151 -- CompManager. They really ought to be in the latter.
152 type ModuleEnv a = UniqFM a -- Domain is Module
154 type HomeModMap = FiniteMap ModuleName Module -- domain: home mods only
155 type HomeSymbolTable = ModuleEnv ModDetails -- ditto
156 type HomeInterfaceTable = ModuleEnv ModIFace