2 % (c) The University of Glasgow, 2000
4 \section[CmTypes]{Types for the compilation manager}
8 Unlinked(..), isObject, nameOfObject, isInterpretable,
9 Linkable(..), isObjectLinkable, partitionLinkable,
10 ModSummary(..), ms_allimps, pprSummaryTime, modSummaryName,
18 import Time ( ClockTime )
25 | BCOs [UnlinkedBCO] ItblEnv -- bunch of interpretable bindings, +
26 -- a mapping from DataCons to their itbls
28 instance Outputable Unlinked where
29 ppr (DotO path) = text "DotO" <+> text path
30 ppr (DotA path) = text "DotA" <+> text path
31 ppr (DotDLL path) = text "DotDLL" <+> text path
32 ppr (BCOs bcos _) = text "BCOs" <+> ppr bcos
34 isObject (DotO _) = True
35 isObject (DotA _) = True
36 isObject (DotDLL _) = True
39 nameOfObject (DotO fn) = fn
40 nameOfObject (DotA fn) = fn
41 nameOfObject (DotDLL fn) = fn
43 isInterpretable = not . isObject
46 linkableTime :: ClockTime,
47 linkableModName :: ModuleName, -- should be Module, but see below
48 linkableUnlinked :: [Unlinked]
51 isObjectLinkable :: Linkable -> Bool
52 isObjectLinkable l = all isObject (linkableUnlinked l)
54 -- HACK to support f-x-dynamic in the interpreter; no other purpose
55 partitionLinkable :: Linkable -> [Linkable]
57 = let li_uls = linkableUnlinked li
58 li_uls_obj = filter isObject li_uls
59 li_uls_bco = filter isInterpretable li_uls
61 case (li_uls_obj, li_uls_bco) of
62 (objs@(_:_), bcos@(_:_))
63 -> [li{linkableUnlinked=li_uls_obj}, li{linkableUnlinked=li_uls_bco}]
67 instance Outputable Linkable where
68 ppr (LM when_made mod unlinkeds)
69 = (text "LinkableM" <+> parens (text (show when_made)) <+> ppr mod)
70 $$ nest 3 (ppr unlinkeds)
72 -- The ModuleLocation contains both the original source filename and the
73 -- filename of the cleaned-up source file after all preprocessing has been
74 -- done. The point is that the summariser will have to cpp/unlit/whatever
75 -- all files anyway, and there's no point in doing this twice -- just
76 -- park the result in a temp file, put the name of it in the location,
77 -- and let @compile@ read from that file on the way back up.
80 ms_mod :: Module, -- name, package
81 ms_location :: ModuleLocation, -- location
82 ms_srcimps :: [ModuleName], -- source imports
83 ms_imps :: [ModuleName], -- non-source imports
84 ms_hs_date :: ClockTime -- timestamp of summarised file
87 instance Outputable ModSummary where
89 = sep [text "ModSummary {",
90 nest 3 (sep [text "ms_hs_date = " <> text (show (ms_hs_date ms)),
91 text "ms_mod =" <+> ppr (ms_mod ms) <> comma,
92 text "ms_imps =" <+> ppr (ms_imps ms),
93 text "ms_srcimps =" <+> ppr (ms_srcimps ms)]),
98 = text "ms_hs_date = " <> parens (text (show (ms_hs_date ms)))
101 = ms_srcimps ms ++ ms_imps ms
103 modSummaryName :: ModSummary -> ModuleName
104 modSummaryName = moduleName . ms_mod