2 % (c) The AQUA Project, Glasgow University, 1993-2000
4 \section[CmCompile]{Compiler for GHCI}
7 module CmCompile ( cmCompile,
8 ModDetails, -- abstract
10 PCS, emptyPCS, -- abstract
11 HST, -- not abstract (CM needs to see it)
17 #include "HsVersions.h"
19 import CmLink ( Linkable )
20 import Outputable ( SDoc )
21 import CmFind ( Finder )
22 import CmSummarise ( ModSummary )
23 import CmStaticInfo ( SI )
24 import FiniteMap ( FiniteMap, emptyFM )
26 import Module ( Module )
27 import RnMonad ( Avails, GlobalRdrEnv, DeclsMap,
28 WhetherHasOrphans, ImportVersion,
29 IfaceInsts, IfaceRules, ExportItem )
30 import TcEnv ( TyThing, InstEnv )
31 import Name ( Name, OccName )
32 import BasicTypes ( Fixity, Version )
34 import CoreSyn ( CoreRule )
35 import RdrHsSyn ( RdrNameDeprecation, RdrNameRuleDecl, RdrNameFixitySig,
36 RdrNameHsDecl, RdrNameInstDecl )
41 cmCompile :: SI -- obvious
42 -> Finder -- to find modules
43 -> ModSummary -- summary, including source
44 -> Maybe ModIFace -- old interface, if available
45 -> HST -- for home module ModDetails
46 -> PCS -- IN: persistent compiler state
49 cmCompile flags finder summary old_iface hst pcs
50 = return (error "cmCompile:unimp")
54 = CompOK ModDetails -- new details (HST additions)
55 (Maybe (ModIFace, Linkable))
56 -- summary and code; Nothing => compilation not reqd
57 -- (old summary and code are still valid)
61 | CompErrs PCS -- updated PCS
62 [SDoc] -- warnings and errors
65 emptyPCS = return (MkPCS emptyPIT emptyPST emptyHoldingPen)
68 -- These two are only here to avoid recursion between CmCompile and
69 -- CompManager. They really ought to be in the latter.
70 type HST = FiniteMap {-really:Module-} String{- == ModName-} ModDetails
71 type HIT = FiniteMap {-really:Module-} String{- == ModName-} ModIFace
74 data PCS = MkPCS PIT -- Package interface table
75 PST -- Package symbol table
76 HoldingPen -- pre slurped interface bits and pieces
78 type PIT = FiniteMap Module ModIFace
79 type PST = FiniteMap Module ModDetails
87 -- ModIFace is nearly the same as RnMonad.ParsedIface.
88 -- Right now it's identical :)
91 mi_mod :: Module, -- Complete with package info
92 mi_vers :: Version, -- Module version number
93 mi_orphan :: WhetherHasOrphans, -- Whether this module has orphans
94 mi_usages :: [ImportVersion OccName], -- Usages
95 mi_exports :: [ExportItem], -- Exports
96 mi_insts :: [RdrNameInstDecl], -- Local instance declarations
97 mi_decls :: [(Version, RdrNameHsDecl)], -- Local definitions
98 mi_fixity :: (Version, [RdrNameFixitySig]), -- Local fixity declarations,
100 mi_rules :: (Version, [RdrNameRuleDecl]), -- Rules, with their version
101 mi_deprecs :: [RdrNameDeprecation] -- Deprecations
106 moduleExports :: Avails,
107 moduleEnv :: GlobalRdrEnv, -- == FM RdrName [Name]
108 typeEnv :: FiniteMap Name TyThing, -- TyThing is in TcEnv.lhs
110 fixityEnv :: FiniteMap Name Fixity,
111 ruleEnv :: FiniteMap Id [CoreRule]
114 -- This should eventually replace RnMonad.Ifaces
117 iDecls :: DeclsMap, -- A single, global map of Names to decls
119 iInsts :: IfaceInsts,
120 -- The as-yet un-slurped instance decls; this bag is depleted when we
121 -- slurp an instance decl so that we don't slurp the same one twice.
122 -- Each is 'gated' by the names that must be available before
123 -- this instance decl is needed.
126 -- Similar to instance decls, only for rules
129 emptyHoldingPen :: HoldingPen
130 emptyHoldingPen = error "emptyHoldingPen:unimp"