X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcRnMonad.lhs;h=64b40f60b2592e4f21a02c5de8b7c102167bcce6;hp=e6d75e3a6509740f84e327d0e4926cbaac9a4818;hb=940524aec90652b5ef81789c9a453c57c0e42cc9;hpb=49c98d143c382a1341e1046f5ca00819a25691ba diff --git a/compiler/typecheck/TcRnMonad.lhs b/compiler/typecheck/TcRnMonad.lhs index e6d75e3..64b40f6 100644 --- a/compiler/typecheck/TcRnMonad.lhs +++ b/compiler/typecheck/TcRnMonad.lhs @@ -14,18 +14,6 @@ module TcRnMonad( import TcRnTypes -- Re-export all import IOEnv -- Re-export all -#if defined(GHCI) && defined(BREAKPOINT) -import TypeRep -import Var -import IdInfo -import OccName -import SrcLoc -import TysWiredIn -import PrelNames -import NameEnv -import TcEnv -#endif - import HsSyn hiding (LIE) import HscTypes import Module @@ -47,7 +35,6 @@ import OccName import Bag import Outputable import UniqSupply -import UniqFM import Unique import DynFlags import StaticFlags @@ -73,15 +60,17 @@ ioToTcRn = ioToIOEnv \end{code} \begin{code} + initTc :: HscEnv -> HscSource + -> Bool -- True <=> retain renamed syntax trees -> Module -> TcM r -> IO (Messages, Maybe r) -- Nothing => error thrown by the thing inside -- (error messages should have been printed already) -initTc hsc_env hsc_src mod do_this +initTc hsc_env hsc_src keep_rn_syntax mod do_this = do { errs_var <- newIORef (emptyBag, emptyBag) ; tvs_var <- newIORef emptyVarSet ; type_env_var <- newIORef emptyNameEnv ; @@ -90,6 +79,10 @@ initTc hsc_env hsc_src mod do_this th_var <- newIORef False ; dfun_n_var <- newIORef 1 ; let { + maybe_rn_syntax empty_val + | keep_rn_syntax = Just empty_val + | otherwise = Nothing ; + gbl_env = TcGblEnv { tcg_mod = mod, tcg_src = hsc_src, @@ -103,11 +96,13 @@ initTc hsc_env hsc_src mod do_this tcg_inst_uses = dfuns_var, tcg_th_used = th_var, tcg_exports = [], - tcg_imports = init_imports, + tcg_imports = emptyImportAvails, tcg_dus = emptyDUs, - tcg_rn_imports = Nothing, - tcg_rn_exports = Nothing, - tcg_rn_decls = Nothing, + + tcg_rn_imports = maybe_rn_syntax [], + tcg_rn_exports = maybe_rn_syntax [], + tcg_rn_decls = maybe_rn_syntax emptyRnGroup, + tcg_binds = emptyLHsBinds, tcg_deprecs = NoDeprecs, tcg_insts = [], @@ -149,12 +144,6 @@ initTc hsc_env hsc_src mod do_this return (msgs, final_res) } - where - init_imports = emptyImportAvails {imp_env = unitUFM (moduleName mod) []} - -- Initialise tcg_imports with an empty set of bindings for - -- this module, so that if we see 'module M' in the export - -- list, and there are no bindings in M, we don't bleat - -- "unknown module M". initTcPrintErrors -- Used from the interactive loop only :: HscEnv @@ -162,7 +151,7 @@ initTcPrintErrors -- Used from the interactive loop only -> TcM r -> IO (Maybe r) initTcPrintErrors env mod todo = do - (msgs, res) <- initTc env HsSrcFile mod todo + (msgs, res) <- initTc env HsSrcFile False mod todo printErrorsAndWarnings (hsc_dflags env) msgs return res \end{code} @@ -170,28 +159,7 @@ initTcPrintErrors env mod todo = do \begin{code} addBreakpointBindings :: TcM a -> TcM a addBreakpointBindings thing_inside -#if defined(GHCI) && defined(BREAKPOINT) - = do { unique <- newUnique - ; let { var = mkInternalName unique (mkOccName tvName "a") noSrcLoc; - tyvar = mkTyVar var liftedTypeKind; - basicType extra = (FunTy intTy - (FunTy (mkListTy unitTy) - (FunTy stringTy - (ForAllTy tyvar - (extra - (FunTy (TyVarTy tyvar) - (TyVarTy tyvar))))))); - breakpointJumpId - = mkGlobalId VanillaGlobal breakpointJumpName - (basicType id) vanillaIdInfo; - breakpointCondJumpId - = mkGlobalId VanillaGlobal breakpointCondJumpName - (basicType (FunTy boolTy)) vanillaIdInfo - } - ; tcExtendIdEnv [breakpointJumpId, breakpointCondJumpId] thing_inside} -#else = thing_inside -#endif \end{code} %************************************************************************ @@ -356,7 +324,7 @@ newUniqueSupply newLocalName :: Name -> TcRnIf gbl lcl Name newLocalName name -- Make a clone = do { uniq <- newUnique - ; return (mkInternalName uniq (nameOccName name) (getSrcLoc name)) } + ; return (mkInternalName uniq (nameOccName name) (getSrcSpan name)) } newSysLocalIds :: FastString -> [TcType] -> TcRnIf gbl lcl [TcId] newSysLocalIds fs tys @@ -435,8 +403,8 @@ extendFixityEnv new_bit = updGblEnv (\env@(TcGblEnv { tcg_fix_env = old_fix_env }) -> env {tcg_fix_env = extendNameEnvList old_fix_env new_bit}) -getDefaultTys :: TcRn (Maybe [Type]) -getDefaultTys = do { env <- getGblEnv; return (tcg_default env) } +getDeclaredDefaultTys :: TcRn (Maybe [Type]) +getDeclaredDefaultTys = do { env <- getGblEnv; return (tcg_default env) } \end{code} %************************************************************************ @@ -757,11 +725,14 @@ checkTc False err = failWithTc err \begin{code} addWarnTc :: Message -> TcM () -addWarnTc msg +addWarnTc msg = do { env0 <- tcInitTidyEnv + ; addWarnTcM (env0, msg) } + +addWarnTcM :: (TidyEnv, Message) -> TcM () +addWarnTcM (env0, msg) = do { ctxt <- getErrCtxt ; - env0 <- tcInitTidyEnv ; ctxt_msgs <- do_ctxt env0 ctxt ; - addWarn (vcat (msg : ctxt_to_use ctxt_msgs)) } + addReport (vcat (ptext SLIT("Warning:") <+> msg : ctxt_to_use ctxt_msgs)) } warnTc :: Bool -> Message -> TcM () warnTc warn_if_true warn_msg