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