From: Ian Lynagh Date: Mon, 17 Mar 2008 18:01:50 +0000 (+0000) Subject: Eliminate a global variable X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=f09fe9cd924df3ca73baf124e66f05794e066780 Eliminate a global variable Very little parameter passing is needed without it, so there was no real benefit to it. --- diff --git a/compiler/iface/BinIface.hs b/compiler/iface/BinIface.hs index 12bde11..5b94dd6 100644 --- a/compiler/iface/BinIface.hs +++ b/compiler/iface/BinIface.hs @@ -10,7 +10,7 @@ -- -- Binary interface file support. -module BinIface ( writeBinIface, readBinIface, v_IgnoreHiWay ) where +module BinIface ( writeBinIface, readBinIface, CheckHiWay(..) ) where #include "HsVersions.h" @@ -48,18 +48,22 @@ import Data.IORef import Control.Exception import Control.Monad +data CheckHiWay = CheckHiWay | IgnoreHiWay + deriving Eq + -- --------------------------------------------------------------------------- -- Reading and writing binary interface files -readBinIface :: FilePath -> TcRnIf a b ModIface -readBinIface hi_path = do +readBinIface :: CheckHiWay -> FilePath -> TcRnIf a b ModIface +readBinIface checkHiWay hi_path = do nc <- getNameCache - (new_nc, iface) <- liftIO $ readBinIface_ hi_path nc + (new_nc, iface) <- liftIO $ readBinIface_ checkHiWay hi_path nc setNameCache new_nc return iface -readBinIface_ :: FilePath -> NameCache -> IO (NameCache, ModIface) -readBinIface_ hi_path nc = do +readBinIface_ :: CheckHiWay -> FilePath -> NameCache + -> IO (NameCache, ModIface) +readBinIface_ checkHiWay hi_path nc = do bh <- Binary.readBinMem hi_path -- Read the magic number to check that this really is a GHC .hi file @@ -88,9 +92,8 @@ readBinIface_ hi_path nc = do ++ our_ver ++ ", found " ++ check_ver)) check_way <- get bh - ignore_way <- readIORef v_IgnoreHiWay way_descr <- getWayDescr - when (not ignore_way && check_way /= way_descr) $ + when (checkHiWay == CheckHiWay && check_way /= way_descr) $ -- This will be caught by readIface -- which will emit an error msg containing the iface module name. throwDyn (ProgramError ( @@ -367,8 +370,6 @@ instance Binary ModIface where mi_fix_fn = mkIfaceFixCache fixities, mi_ver_fn = mkIfaceVerCache decls }) -GLOBAL_VAR(v_IgnoreHiWay, False, Bool) - getWayDescr :: IO String getWayDescr = do tag <- readIORef v_Build_tag diff --git a/compiler/iface/LoadIface.lhs b/compiler/iface/LoadIface.lhs index 5df77fc..f41f5da 100644 --- a/compiler/iface/LoadIface.lhs +++ b/compiler/iface/LoadIface.lhs @@ -515,7 +515,7 @@ readIface :: Module -> FilePath -> IsBootInterface readIface wanted_mod file_path is_hi_boot_file = do { dflags <- getDOpts - ; res <- tryMostM $ readBinIface file_path + ; res <- tryMostM $ readBinIface CheckHiWay file_path ; case res of Right iface | wanted_mod == actual_mod -> return (Succeeded iface) @@ -610,10 +610,9 @@ ifaceStats eps -- | Read binary interface, and print it out showIface :: HscEnv -> FilePath -> IO () showIface hsc_env filename = do - -- skip the version check; we don't want to worry about profiled vs. + -- skip the hi way check; we don't want to worry about profiled vs. -- non-profiled interfaces, for example. - writeIORef v_IgnoreHiWay True - iface <- initTcRnIf 's' hsc_env () () $ readBinIface filename + iface <- initTcRnIf 's' hsc_env () () $ readBinIface IgnoreHiWay filename printDump (pprModIface iface) \end{code} @@ -624,6 +623,7 @@ pprModIface iface = vcat [ ptext SLIT("interface") <+> ppr (mi_module iface) <+> pp_boot <+> ppr (mi_mod_vers iface) <+> pp_sub_vers + <+> ppr (mi_mod_vers iface) <+> (if mi_orphan iface then ptext SLIT("[orphan module]") else empty) <+> (if mi_finsts iface then ptext SLIT("[family instance module]") else empty) <+> (if mi_hpc iface then ptext SLIT("[hpc]") else empty)