X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcRnMonad.lhs;h=abe87451049cbdfef34932679b8ac1460faaa82d;hb=67ee8a93fc96a38c3f73468cb86d8421a11d2911;hp=1fa44ca308ec26c2aa184d8bebdad2486c5b3a3c;hpb=bb3dcf3988d766149f7793b93210db5f64e91542;p=ghc-hetmet.git diff --git a/compiler/typecheck/TcRnMonad.lhs b/compiler/typecheck/TcRnMonad.lhs index 1fa44ca..abe8745 100644 --- a/compiler/typecheck/TcRnMonad.lhs +++ b/compiler/typecheck/TcRnMonad.lhs @@ -19,6 +19,7 @@ import SrcLoc ( noSrcLoc ) import TysWiredIn ( intTy, stringTy, mkListTy, unitTy, boolTy ) import PrelNames ( breakpointJumpName, breakpointCondJumpName ) import NameEnv ( mkNameEnv ) +import TcEnv ( tcExtendIdEnv ) #endif import HsSyn ( emptyLHsBinds ) @@ -50,7 +51,8 @@ import Outputable import UniqSupply ( UniqSupply, mkSplitUniqSupply, uniqFromSupply, splitUniqSupply ) import UniqFM ( unitUFM ) import Unique ( Unique ) -import DynFlags ( DynFlags(..), DynFlag(..), dopt, dopt_set, GhcMode ) +import DynFlags ( DynFlags(..), DynFlag(..), dopt, dopt_set, + dopt_unset, GhcMode ) import StaticFlags ( opt_PprStyle_Debug ) import Bag ( snocBag, unionBags ) import Panic ( showException ) @@ -131,33 +133,8 @@ initTc hsc_env hsc_src mod do_this -- OK, here's the business end! maybe_res <- initTcRnIf 'a' hsc_env gbl_env lcl_env $ - do { -#if defined(GHCI) && defined(BREAKPOINT) - 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))))))); - breakpointJumpType - = mkGlobalId VanillaGlobal breakpointJumpName - (basicType id) vanillaIdInfo; - breakpointCondJumpType - = mkGlobalId VanillaGlobal breakpointCondJumpName - (basicType (FunTy boolTy)) vanillaIdInfo; - new_env = mkNameEnv [(breakpointJumpName - , ATcId breakpointJumpType topLevel False) - ,(breakpointCondJumpName - , ATcId breakpointCondJumpType topLevel False)]; - }; - r <- tryM (updLclEnv (\gbl -> gbl{tcl_env=new_env}) do_this) -#else - r <- tryM do_this -#endif + addBreakpointBindings $ + do { r <- tryM do_this ; case r of Right res -> return (Just res) Left _ -> return Nothing } ; @@ -190,6 +167,32 @@ initTcPrintErrors env mod todo = do return res \end{code} +\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} %************************************************************************ %* * @@ -268,6 +271,10 @@ setOptM :: DynFlag -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a setOptM flag = updEnv (\ env@(Env { env_top = top }) -> env { env_top = top { hsc_dflags = dopt_set (hsc_dflags top) flag}} ) +unsetOptM :: DynFlag -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a +unsetOptM flag = updEnv (\ env@(Env { env_top = top }) -> + env { env_top = top { hsc_dflags = dopt_unset (hsc_dflags top) flag}} ) + ifOptM :: DynFlag -> TcRnIf gbl lcl () -> TcRnIf gbl lcl () -- Do it flag is true ifOptM flag thing_inside = do { b <- doptM flag; if b then thing_inside else return () }