diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-07-21 16:51:51 -0700 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-07-22 13:04:04 -0700 |
commit | 0b12aca09efd4c151a8c2682b7534bda9bdc99ad (patch) | |
tree | f8620d05c2285898ff35b03e218caf6e27fc36cc | |
parent | cf57f8f9e9a649d7ffdfe0be09e503f6ed468a5d (diff) | |
download | haskell-0b12aca09efd4c151a8c2682b7534bda9bdc99ad.tar.gz |
Switch from recording IsBootInterface to recording full HscSource.
Note: ModIface format change is BC, no need to recompile.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
-rw-r--r-- | compiler/deSugar/Desugar.hs | 2 | ||||
-rw-r--r-- | compiler/ghci/Linker.hs | 2 | ||||
-rw-r--r-- | compiler/iface/LoadIface.hs | 7 | ||||
-rw-r--r-- | compiler/iface/MkIface.hs | 12 | ||||
-rw-r--r-- | compiler/main/DriverPhases.hs | 12 | ||||
-rw-r--r-- | compiler/main/HscMain.hs | 2 | ||||
-rw-r--r-- | compiler/main/HscTypes.hs | 21 |
7 files changed, 38 insertions, 20 deletions
diff --git a/compiler/deSugar/Desugar.hs b/compiler/deSugar/Desugar.hs index e3a31b9caa..9d751fcd0a 100644 --- a/compiler/deSugar/Desugar.hs +++ b/compiler/deSugar/Desugar.hs @@ -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, diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs index 3e8423c432..c5fe7139fc 100644 --- a/compiler/ghci/Linker.hs +++ b/compiler/ghci/Linker.hs @@ -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) diff --git a/compiler/iface/LoadIface.hs b/compiler/iface/LoadIface.hs index 5250c4f0fa..ad813578c4 100644 --- a/compiler/iface/LoadIface.hs +++ b/compiler/iface/LoadIface.hs @@ -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: diff --git a/compiler/iface/MkIface.hs b/compiler/iface/MkIface.hs index a493da988d..753c81a8a0 100644 --- a/compiler/iface/MkIface.hs +++ b/compiler/iface/MkIface.hs @@ -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, diff --git a/compiler/main/DriverPhases.hs b/compiler/main/DriverPhases.hs index 9d1199339a..ff6f8b8ab1 100644 --- a/compiler/main/DriverPhases.hs +++ b/compiler/main/DriverPhases.hs @@ -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]" diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs index 94896b0e86..13717b6b4b 100644 --- a/compiler/main/HscMain.hs +++ b/compiler/main/HscMain.hs @@ -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, diff --git a/compiler/main/HscTypes.hs b/compiler/main/HscTypes.hs index cf2c64b6f5..9be51753c7 100644 --- a/compiler/main/HscTypes.hs +++ b/compiler/main/HscTypes.hs @@ -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 |