From: simonpj@microsoft.com Date: Wed, 13 Oct 2010 09:11:07 +0000 (+0000) Subject: Remove GHC.extendGlobalRdrScope, GHC.extendGlobalTypeScope X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=762c24327f4a2f874fb8a4b2d6717d36aa6c5e02 Remove GHC.extendGlobalRdrScope, GHC.extendGlobalTypeScope These functions were added by Tue Apr 18 03:36:06 BST 2006 Lemmih * Make the initial rdr and type scope available in the ghc-api The are extremely dubious, because they extend the Rdr and Type env for every compilation. The right thing to do is to use the InteractiveContext for temporary extensions. So far as we know, no one uses them. And if they are being used it's probably a mistake. So we're backing them out. --- diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs index 82a5adc..638e1db 100644 --- a/compiler/main/GHC.hs +++ b/compiler/main/GHC.hs @@ -36,12 +36,6 @@ module GHC ( removeTarget, guessTarget, - -- * Extending the program scope - extendGlobalRdrScope, - setGlobalRdrScope, - extendGlobalTypeScope, - setGlobalTypeScope, - -- * Loading\/compiling the program depanal, load, loadWithLogger, LoadHowMuch(..), @@ -596,31 +590,6 @@ guessTarget str Nothing target tid = Target tid obj_allowed Nothing -- ----------------------------------------------------------------------------- --- Extending the program scope - -extendGlobalRdrScope :: GhcMonad m => [GlobalRdrElt] -> m () -extendGlobalRdrScope rdrElts - = modifySession $ \hscEnv -> - let global_rdr = hsc_global_rdr_env hscEnv - in hscEnv{ hsc_global_rdr_env = foldl extendGlobalRdrEnv global_rdr rdrElts } - -setGlobalRdrScope :: GhcMonad m => [GlobalRdrElt] -> m () -setGlobalRdrScope rdrElts - = modifySession $ \hscEnv -> - hscEnv{ hsc_global_rdr_env = foldl extendGlobalRdrEnv emptyGlobalRdrEnv rdrElts } - -extendGlobalTypeScope :: GhcMonad m => [Id] -> m () -extendGlobalTypeScope ids - = modifySession $ \hscEnv -> - let global_type = hsc_global_type_env hscEnv - in hscEnv{ hsc_global_type_env = extendTypeEnvWithIds global_type ids } - -setGlobalTypeScope :: GhcMonad m => [Id] -> m () -setGlobalTypeScope ids - = modifySession $ \hscEnv -> - hscEnv{ hsc_global_type_env = extendTypeEnvWithIds emptyTypeEnv ids } - --- ----------------------------------------------------------------------------- -- Loading the program -- | Perform a dependency analysis starting from the current targets diff --git a/compiler/main/HscMain.lhs b/compiler/main/HscMain.lhs index 93ad614..0daab4a 100644 --- a/compiler/main/HscMain.lhs +++ b/compiler/main/HscMain.lhs @@ -149,9 +149,7 @@ newHscEnv callbacks dflags hsc_FC = fc_var, hsc_MLC = mlc_var, hsc_OptFuel = optFuel, - hsc_type_env_var = Nothing, - hsc_global_rdr_env = emptyGlobalRdrEnv, - hsc_global_type_env = emptyNameEnv } ) } + hsc_type_env_var = Nothing } ) } knownKeyNames :: [Name] -- Put here to avoid loops involving DsMeta, diff --git a/compiler/main/HscTypes.lhs b/compiler/main/HscTypes.lhs index bc9c9ee..f88ef35 100644 --- a/compiler/main/HscTypes.lhs +++ b/compiler/main/HscTypes.lhs @@ -567,21 +567,10 @@ data HscEnv -- by limiting the number of transformations, -- we can use binary search to help find compiler bugs. - hsc_type_env_var :: Maybe (Module, IORef TypeEnv), + hsc_type_env_var :: Maybe (Module, IORef TypeEnv) -- ^ Used for one-shot compilation only, to initialise -- the 'IfGblEnv'. See 'TcRnTypes.tcg_type_env_var' for -- 'TcRunTypes.TcGblEnv' - - hsc_global_rdr_env :: GlobalRdrEnv, - -- ^ A mapping from 'RdrName's that are in global scope during - -- the compilation of the current file to more detailed - -- information about those names. Not necessarily just the - -- names directly imported by the module being compiled! - - hsc_global_type_env :: TypeEnv - -- ^ Typing information about all those things in global scope. - -- Not necessarily just the things directly imported by the module - -- being compiled! } hscEPS :: HscEnv -> IO ExternalPackageState diff --git a/compiler/typecheck/TcRnMonad.lhs b/compiler/typecheck/TcRnMonad.lhs index ba694b6..3333bb7 100644 --- a/compiler/typecheck/TcRnMonad.lhs +++ b/compiler/typecheck/TcRnMonad.lhs @@ -89,11 +89,11 @@ initTc hsc_env hsc_src keep_rn_syntax mod do_this gbl_env = TcGblEnv { tcg_mod = mod, tcg_src = hsc_src, - tcg_rdr_env = hsc_global_rdr_env hsc_env, + tcg_rdr_env = emptyGlobalRdrEnv, tcg_fix_env = emptyNameEnv, tcg_field_env = RecFields emptyNameEnv emptyNameSet, tcg_default = Nothing, - tcg_type_env = hsc_global_type_env hsc_env, + tcg_type_env = emptyNameEnv, tcg_type_env_var = type_env_var, tcg_inst_env = emptyInstEnv, tcg_fam_inst_env = emptyFamInstEnv,