import CoreSyn ( CoreRule )
import Maybes ( orElse, fromJust, expectJust )
import Outputable
-import SrcLoc ( SrcSpan )
+import SrcLoc ( SrcSpan, Located )
import UniqSupply ( UniqSupply )
import FastString ( FastString )
-- the old linkable because it was out of date.
-- after a complete compilation (GHC.load), all hm_linkable
-- fields in the HPT will be Just.
+ --
+ -- When re-linking a module (hscNoRecomp), we construct
+ -- the HomModInfo by building a new ModDetails from the
+ -- old ModIface (only).
\end{code}
Simple lookups in the symbol table.
mi_decls :: [(Version,IfaceDecl)], -- Sorted
mi_globals :: !(Maybe GlobalRdrEnv),
- -- Its top level environment or Nothing if we read this
- -- interface from an interface file. (We need the source
- -- file to figure out the top-level environment.)
+ -- Binds all the things defined at the top level in
+ -- the *original source* code for this module. which
+ -- is NOT the same as mi_exports, nor mi_decls (which
+ -- may contains declarations for things not actually
+ -- defined by the user). Used for GHCi and for inspecting
+ -- the contents of modules via the GHC API only.
+ --
+ -- (We need the source file to figure out the
+ -- top-level environment, if we didn't compile this module
+ -- from source then this field contains Nothing).
+ --
+ -- Strictly speaking this field should live in the
+ -- HomeModInfo, but that leads to more plumbing.
-- Instance declarations and rules
mi_insts :: [IfaceInst], -- Sorted
ms_location :: ModLocation, -- Location
ms_hs_date :: ClockTime, -- Timestamp of source file
ms_obj_date :: Maybe ClockTime, -- Timestamp of object, maybe
- ms_srcimps :: [Module], -- Source imports
- ms_imps :: [Module], -- Non-source imports
+ ms_srcimps :: [Located Module], -- Source imports
+ ms_imps :: [Located Module], -- Non-source imports
ms_hspp_file :: Maybe FilePath, -- Filename of preprocessed source,
-- once we have preprocessed it.
ms_hspp_buf :: Maybe StringBuffer -- The actual preprocessed source, maybe.
}
isObjectLinkable :: Linkable -> Bool
-isObjectLinkable l = all isObject (linkableUnlinked l)
+isObjectLinkable l = not (null unlinked) && all isObject unlinked
+ where unlinked = linkableUnlinked l
+ -- A linkable with no Unlinked's is treated as a BCO. We can
+ -- generate a linkable with no Unlinked's as a result of
+ -- compiling a module in HscNothing mode, and this choice
+ -- happens to work well with checkStability in module GHC.
instance Outputable Linkable where
ppr (LM when_made mod unlinkeds)