2 % (c) The University of Glasgow, 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, name_of_summary )
23 import FiniteMap ( FiniteMap, emptyFM )
25 import Module ( Module )
26 import RnMonad ( Avails, GlobalRdrEnv, DeclsMap,
27 WhetherHasOrphans, ImportVersion,
28 IfaceInsts, IfaceRules, ExportItem )
29 import TcEnv ( TyThing, InstEnv )
30 import Name ( Name, OccName )
31 import BasicTypes ( Fixity, Version )
33 import CoreSyn ( CoreRule )
34 import RdrHsSyn ( RdrNameDeprecation, RdrNameRuleDecl, RdrNameFixitySig,
35 RdrNameHsDecl, RdrNameInstDecl )
40 cmCompile :: Finder -- to find modules
41 -> ModSummary -- summary, including source
42 -> Maybe ModIFace -- old interface, if available
43 -> HST -- for home module ModDetails
44 -> PCS -- IN: persistent compiler state
47 cmCompile finder summary old_iface hst pcs
48 = do putStrLn ("cmCompile: compiling " ++ name_of_summary summary)
49 return (CompOK (error "cmCompile:modDetails")
50 (Just (error "cmCompile:modIFace",
51 --error "cmCompile:Linkable"
52 --LM (name_of_summary summary) []
53 LM (name_of_summary summary) []
60 = CompOK ModDetails -- new details (HST additions)
61 (Maybe (ModIFace, Linkable))
62 -- summary and code; Nothing => compilation not reqd
63 -- (old summary and code are still valid)
67 | CompErrs PCS -- updated PCS
72 emptyPCS = return (MkPCS emptyPIT emptyPST emptyHoldingPen)
75 -- These two are only here to avoid recursion between CmCompile and
76 -- CompManager. They really ought to be in the latter.
77 type HST = FiniteMap {-really:Module-} String{- == ModName-} ModDetails
78 type HIT = FiniteMap {-really:Module-} String{- == ModName-} ModIFace
81 data PCS = MkPCS PIT -- Package interface table
82 PST -- Package symbol table
83 HoldingPen -- pre slurped interface bits and pieces
85 type PIT = FiniteMap Module ModIFace
86 type PST = FiniteMap Module ModDetails
94 -- ModIFace is nearly the same as RnMonad.ParsedIface.
95 -- Right now it's identical :)
98 mi_mod :: Module, -- Complete with package info
99 mi_vers :: Version, -- Module version number
100 mi_orphan :: WhetherHasOrphans, -- Whether this module has orphans
101 mi_usages :: [ImportVersion OccName], -- Usages
102 mi_exports :: [ExportItem], -- Exports
103 mi_insts :: [RdrNameInstDecl], -- Local instance declarations
104 mi_decls :: [(Version, RdrNameHsDecl)], -- Local definitions
105 mi_fixity :: (Version, [RdrNameFixitySig]), -- Local fixity declarations,
106 -- with their version
107 mi_rules :: (Version, [RdrNameRuleDecl]), -- Rules, with their version
108 mi_deprecs :: [RdrNameDeprecation] -- Deprecations
113 moduleExports :: Avails,
114 moduleEnv :: GlobalRdrEnv, -- == FM RdrName [Name]
115 typeEnv :: FiniteMap Name TyThing, -- TyThing is in TcEnv.lhs
117 fixityEnv :: FiniteMap Name Fixity,
118 ruleEnv :: FiniteMap Id [CoreRule]
121 -- This should eventually replace RnMonad.Ifaces
124 iDecls :: DeclsMap, -- A single, global map of Names to decls
126 iInsts :: IfaceInsts,
127 -- The as-yet un-slurped instance decls; this bag is depleted when we
128 -- slurp an instance decl so that we don't slurp the same one twice.
129 -- Each is 'gated' by the names that must be available before
130 -- this instance decl is needed.
133 -- Similar to instance decls, only for rules
136 emptyHoldingPen :: HoldingPen
137 emptyHoldingPen = error "emptyHoldingPen:unimp"