Commit 0b12aca0 authored by Edward Z. Yang's avatar Edward Z. Yang

Switch from recording IsBootInterface to recording full HscSource.

Note: ModIface format change is BC, no need to recompile.
Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent cf57f8f9
......@@ -168,7 +168,7 @@ deSugar hsc_env
; let mod_guts = ModGuts {
mg_module = mod,
mg_boot = hsc_src == HsBootFile,
mg_hsc_src = hsc_src,
mg_exports = exports,
mg_deps = deps,
mg_used_names = used_names,
......
......@@ -662,7 +662,7 @@ getLinkDeps hsc_env hpt pls replace_osuf span mods
adjust_linkable iface lnk
-- Signatures have no linkables! Don't return one.
| Just _ <- mi_sig_of iface = return Nothing
| mi_hsc_src iface == HsigFile = return Nothing
| Just new_osuf <- replace_osuf = do
new_uls <- mapM (adjust_ul new_osuf)
(linkableUnlinked lnk)
......
......@@ -911,7 +911,7 @@ pprModIface :: ModIface -> SDoc
-- Show a ModIface
pprModIface iface
= vcat [ ptext (sLit "interface")
<+> ppr (mi_module iface) <+> pp_boot
<+> ppr (mi_module iface) <+> pp_hsc_src (mi_hsc_src iface)
<+> (if mi_orphan iface then ptext (sLit "[orphan module]") else Outputable.empty)
<+> (if mi_finsts iface then ptext (sLit "[family instance module]") else Outputable.empty)
<+> (if mi_hpc iface then ptext (sLit "[hpc]") else Outputable.empty)
......@@ -940,8 +940,9 @@ pprModIface iface
, pprTrustPkg (mi_trust_pkg iface)
]
where
pp_boot | mi_boot iface = ptext (sLit "[boot]")
| otherwise = Outputable.empty
pp_hsc_src HsBootFile = ptext (sLit "[boot]")
pp_hsc_src HsigFile = ptext (sLit "[hsig]")
pp_hsc_src HsSrcFile = Outputable.empty
{-
When printing export lists, we print like this:
......
......@@ -142,7 +142,7 @@ mkIface :: HscEnv
mkIface hsc_env maybe_old_fingerprint mod_details
ModGuts{ mg_module = this_mod,
mg_boot = is_boot,
mg_hsc_src = hsc_src,
mg_used_names = used_names,
mg_used_th = used_th,
mg_deps = deps,
......@@ -156,7 +156,7 @@ mkIface hsc_env maybe_old_fingerprint mod_details
mg_dependent_files = dependent_files
}
= mkIface_ hsc_env maybe_old_fingerprint
this_mod is_boot used_names used_th deps rdr_env fix_env
this_mod hsc_src used_names used_th deps rdr_env fix_env
warns hpc_info dir_imp_mods self_trust dependent_files
safe_mode mod_details
......@@ -187,7 +187,7 @@ mkIfaceTc hsc_env maybe_old_fingerprint safe_mode mod_details
used_th <- readIORef tc_splice_used
dep_files <- (readIORef dependent_files)
mkIface_ hsc_env maybe_old_fingerprint
this_mod (hsc_src == HsBootFile) used_names
this_mod hsc_src used_names
used_th deps rdr_env
fix_env warns hpc_info (imp_mods imports)
(imp_trust_own_pkg imports) dep_files safe_mode mod_details
......@@ -231,7 +231,7 @@ mkDependencies
-- sort to get into canonical order
-- NB. remember to use lexicographic ordering
mkIface_ :: HscEnv -> Maybe Fingerprint -> Module -> IsBootInterface
mkIface_ :: HscEnv -> Maybe Fingerprint -> Module -> HscSource
-> NameSet -> Bool -> Dependencies -> GlobalRdrEnv
-> NameEnv FixItem -> Warnings -> HpcInfo
-> ImportedMods -> Bool
......@@ -240,7 +240,7 @@ mkIface_ :: HscEnv -> Maybe Fingerprint -> Module -> IsBootInterface
-> ModDetails
-> IO (Messages, Maybe (ModIface, Bool))
mkIface_ hsc_env maybe_old_fingerprint
this_mod is_boot used_names used_th deps rdr_env fix_env src_warns
this_mod hsc_src used_names used_th deps rdr_env fix_env src_warns
hpc_info dir_imp_mods pkg_trust_req dependent_files safe_mode
ModDetails{ md_insts = insts,
md_fam_insts = fam_insts,
......@@ -281,7 +281,7 @@ mkIface_ hsc_env maybe_old_fingerprint
intermediate_iface = ModIface {
mi_module = this_mod,
mi_sig_of = sig_of,
mi_boot = is_boot,
mi_hsc_src = hsc_src,
mi_deps = deps,
mi_usages = usages,
mi_exports = mkIfaceExports exports,
......
......@@ -41,6 +41,7 @@ import {-# SOURCE #-} DynFlags
import Outputable
import Platform
import System.FilePath
import Binary
-----------------------------------------------------------------------------
-- Phases
......@@ -95,6 +96,17 @@ data HscSource
deriving( Eq, Ord, Show )
-- Ord needed for the finite maps we build in CompManager
instance Binary HscSource where
put_ bh HsSrcFile = putByte bh 0
put_ bh HsBootFile = putByte bh 1
put_ bh HsigFile = putByte bh 2
get bh = do
h <- getByte bh
case h of
0 -> return HsSrcFile
1 -> return HsBootFile
_ -> return HsigFile
hscSourceString :: HscSource -> String
hscSourceString HsSrcFile = ""
hscSourceString HsBootFile = "[boot]"
......
......@@ -1622,7 +1622,7 @@ mkModGuts :: Module -> SafeHaskellMode -> CoreProgram -> ModGuts
mkModGuts mod safe binds =
ModGuts {
mg_module = mod,
mg_boot = False,
mg_hsc_src = HsSrcFile,
mg_exports = [],
mg_deps = noDependencies,
mg_dir_imps = emptyModuleEnv,
......
......@@ -67,7 +67,7 @@ module HscTypes (
-- * Interfaces
ModIface(..), mkIfaceWarnCache, mkIfaceHashCache, mkIfaceFixCache,
emptyIfaceWarnCache,
emptyIfaceWarnCache, mi_boot,
-- * Fixity
FixityEnv, FixItem(..), lookupFixity, emptyFixityEnv,
......@@ -748,7 +748,7 @@ data ModIface
mi_orphan :: !WhetherHasOrphans, -- ^ Whether this module has orphans
mi_finsts :: !WhetherHasFamInst, -- ^ Whether this module has family instances
mi_boot :: !IsBootInterface, -- ^ Read from an hi-boot file?
mi_hsc_src :: !HscSource, -- ^ Boot? Signature?
mi_deps :: Dependencies,
-- ^ The dependencies of the module. This is
......@@ -846,11 +846,16 @@ data ModIface
-- See Note [RnNames . Trust Own Package]
}
-- | Old-style accessor for whether or not the ModIface came from an hs-boot
-- file.
mi_boot :: ModIface -> Bool
mi_boot iface = mi_hsc_src iface == HsBootFile
instance Binary ModIface where
put_ bh (ModIface {
mi_module = mod,
mi_sig_of = sig_of,
mi_boot = is_boot,
mi_hsc_src = hsc_src,
mi_iface_hash= iface_hash,
mi_mod_hash = mod_hash,
mi_flag_hash = flag_hash,
......@@ -874,7 +879,7 @@ instance Binary ModIface where
mi_trust = trust,
mi_trust_pkg = trust_pkg }) = do
put_ bh mod
put_ bh is_boot
put_ bh hsc_src
put_ bh iface_hash
put_ bh mod_hash
put_ bh flag_hash
......@@ -901,7 +906,7 @@ instance Binary ModIface where
get bh = do
mod_name <- get bh
is_boot <- get bh
hsc_src <- get bh
iface_hash <- get bh
mod_hash <- get bh
flag_hash <- get bh
......@@ -928,7 +933,7 @@ instance Binary ModIface where
return (ModIface {
mi_module = mod_name,
mi_sig_of = sig_of,
mi_boot = is_boot,
mi_hsc_src = hsc_src,
mi_iface_hash = iface_hash,
mi_mod_hash = mod_hash,
mi_flag_hash = flag_hash,
......@@ -970,7 +975,7 @@ emptyModIface mod
mi_flag_hash = fingerprint0,
mi_orphan = False,
mi_finsts = False,
mi_boot = False,
mi_hsc_src = HsSrcFile,
mi_deps = noDependencies,
mi_usages = [],
mi_exports = [],
......@@ -1048,7 +1053,7 @@ type ImportedModsVal = (ModuleName, Bool, SrcSpan, IsSafeImport)
data ModGuts
= ModGuts {
mg_module :: !Module, -- ^ Module being compiled
mg_boot :: IsBootInterface, -- ^ Whether it's an hs-boot module
mg_hsc_src :: HscSource, -- ^ Whether it's an hs-boot module
mg_exports :: ![AvailInfo], -- ^ What it exports
mg_deps :: !Dependencies, -- ^ What it depends on, directly or
-- otherwise
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment