[project @ 2000-11-16 15:57:05 by simonmar]
[ghc-hetmet.git] / ghc / compiler / compMan / CmTypes.lhs
1 %
2 % (c) The University of Glasgow, 2000
3 %
4 \section[CmTypes]{Types for the compilation manager}
5
6 \begin{code}
7 module CmTypes ( 
8    Unlinked(..),  isObject, nameOfObject, isInterpretable,
9    Linkable(..),
10    ModSummary(..), name_of_summary
11   ) where
12
13 import Interpreter
14 import HscTypes
15 import Module
16 import CmStaticInfo
17 import Outputable
18
19 data Unlinked
20    = DotO FilePath
21    | DotA FilePath
22    | DotDLL FilePath
23    | Trees [UnlinkedIBind] ItblEnv  -- bunch of interpretable bindings, +
24                                     -- a mapping from DataCons to their itbls
25
26 instance Outputable Unlinked where
27    ppr (DotO path)   = text "DotO" <+> text path
28    ppr (DotA path)   = text "DotA" <+> text path
29    ppr (DotDLL path) = text "DotDLL" <+> text path
30    ppr (Trees binds _) = text "Trees" <+> ppr binds
31
32 isObject (DotO _) = True
33 isObject (DotA _) = True
34 isObject (DotDLL _) = True
35 isObject _ = False
36
37 nameOfObject (DotO fn)   = fn
38 nameOfObject (DotA fn)   = fn
39 nameOfObject (DotDLL fn) = fn
40
41 isInterpretable (Trees _ _) = True
42 isInterpretable _ = False
43
44 data Linkable
45    = LM ModuleName [Unlinked]
46    | LP PackageName
47
48 instance Outputable Linkable where
49    ppr (LM mod_nm unlinkeds) = text "LinkableM" <+> ppr mod_nm <+> ppr unlinkeds
50    ppr (LP package_nm)       = text "LinkableP" <+> ptext package_nm
51
52 -- The ModuleLocation contains both the original source filename and the
53 -- filename of the cleaned-up source file after all preprocessing has been
54 -- done.  The point is that the summariser will have to cpp/unlit/whatever
55 -- all files anyway, and there's no point in doing this twice -- just 
56 -- park the result in a temp file, put the name of it in the location,
57 -- and let @compile@ read from that file on the way back up.
58 data ModSummary
59    = ModSummary {
60         ms_mod      :: Module,               -- name, package
61         ms_location :: ModuleLocation,       -- location
62         ms_srcimps  :: [ModuleName],         -- source imports
63         ms_imps     :: [ModuleName]          -- non-source imports
64         --ms_date     :: Maybe ClockTime       -- timestamp of summarised
65                                              -- file, if home && source
66      }
67
68 instance Outputable ModSummary where
69    ppr ms
70       = sep [--text "ModSummary { ms_date = " <> text (show ms_date),
71              text "ModSummary {",
72              nest 3 (sep [text "ms_mod =" <+> ppr (ms_mod ms) <> comma,
73                           text "ms_imps =" <+> ppr (ms_imps ms),
74                           text "ms_srcimps =" <+> ppr (ms_srcimps ms)]),
75              char '}'
76             ]
77
78 name_of_summary :: ModSummary -> ModuleName
79 name_of_summary = moduleName . ms_mod
80 \end{code}