02f33cadac4f748043af3864e570119f394086d3
[ghc-hetmet.git] / ghc / compiler / ghci / CompManager.lhs
1 %
2 % (c) The AQUA Project, Glasgow University, 1993-2000
3 %
4 \section[CompManager]{The Compilation Manager}
5
6 \begin{code}
7 module CompManager ( cmInit, cmLoadModule, 
8                      cmGetExpr, cmRunExpr,
9                      CmState  -- abstract
10                    )
11 where
12
13 #include "HsVersions.h"
14
15 import Outputable       ( SDoc )
16 import FiniteMap        ( emptyFM )
17
18 import CmStaticInfo     ( FLAGS, PCI, SI, mkSI )
19 import CmFind           ( Finder, newFinder, ModName )
20 import CmSummarise      ( )
21 import CmCompile        ( PCS, emptyPCS, HST, HIT )
22 import CmLink           ( PLS, emptyPLS, HValue, Linkable )
23
24
25
26 cmInit :: FLAGS 
27        -> PCI
28        -> IO CmState
29 cmInit flags pkginfo
30    = emptyCmState flags pkginfo
31
32 cmLoadModule :: CmState 
33              -> ModName
34              -> IO (CmState, Either [SDoc] ModHandle)
35 cmLoadModule cmstate modname
36    = return (error "cmLoadModule:unimp")
37
38 cmGetExpr :: CmState
39           -> ModHandle
40           -> String
41           -> IO (CmState, Either [SDoc] HValue)
42 cmGetExpr cmstate modhdl expr
43    = return (error "cmGetExpr:unimp")
44
45 cmRunExpr :: HValue -> IO ()
46 cmRunExpr hval
47    = return (error "cmRunExpr:unimp")
48
49 type ModHandle = String   -- ToDo: do better?
50
51
52 -- Persistent state just for CM, excluding link & compile subsystems
53 data PCMS
54    = PCMS HST   -- home symbol table
55           HIT   -- home interface table
56           UI    -- the unlinked images
57           MG    -- the module graph
58
59 emptyPCMS :: PCMS
60 emptyPCMS = PCMS emptyHST emptyHIT emptyUI emptyMG
61
62 emptyHIT :: HIT
63 emptyHIT = emptyFM
64
65 emptyHST :: HST
66 emptyHST = emptyFM
67
68
69
70 -- Persistent state for the entire system
71 data CmState
72    = CmState PCMS      -- CM's persistent state
73              PCS       -- compile's persistent state
74              PLS       -- link's persistent state
75              SI        -- static info, never changes
76              Finder    -- the module finder
77
78 emptyCmState :: FLAGS -> PCI -> IO CmState
79 emptyCmState flags pci
80     = do let pcms = emptyPCMS
81          pcs     <- emptyPCS
82          pls     <- emptyPLS
83          let si   = mkSI flags pci
84          finder  <- newFinder pci
85          return (CmState pcms pcs pls si finder)
86
87 -- CM internal types
88 type UI = [Linkable]    -- the unlinked images (should be a set, really)
89 emptyUI :: UI
90 emptyUI = []
91
92
93 data MG = MG            -- the module graph
94 emptyMG :: MG
95 emptyMG = MG
96
97
98
99
100 \end{code}