X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcRnMonad.lhs;h=12f0cf6d320b495efdc809cd4fdcf34c69592d8e;hb=a92a7502797818f8d0823b3e3b37147c14bd9cb9;hp=0b5e4fc72a1a1f0c443d0ad6f1cf07c3cb74aae4;hpb=afef39736dcde6f4947a6f362f9e6b3586933db4;p=ghc-hetmet.git diff --git a/compiler/typecheck/TcRnMonad.lhs b/compiler/typecheck/TcRnMonad.lhs index 0b5e4fc..12f0cf6 100644 --- a/compiler/typecheck/TcRnMonad.lhs +++ b/compiler/typecheck/TcRnMonad.lhs @@ -19,9 +19,10 @@ import SrcLoc ( noSrcLoc ) import TysWiredIn ( intTy, stringTy, mkListTy, unitTy, boolTy ) import PrelNames ( breakpointJumpName, breakpointCondJumpName ) import NameEnv ( mkNameEnv ) +import TcEnv ( tcExtendIdEnv ) #endif -import HsSyn ( emptyLHsBinds ) +import HsSyn ( emptyLHsBinds, HaddockModInfo(..) ) import HscTypes ( HscEnv(..), ModGuts(..), ModIface(..), TypeEnv, emptyTypeEnv, HscSource(..), isHsBoot, ExternalPackageState(..), HomePackageTable, @@ -31,11 +32,13 @@ import Module ( Module, moduleName ) import RdrName ( GlobalRdrEnv, LocalRdrEnv, emptyLocalRdrEnv ) import Name ( Name, mkInternalName, tidyNameOcc, nameOccName, getSrcLoc ) import Type ( Type ) -import TcType ( tcIsTyVarTy, tcGetTyVar ) +import TcType ( TcType, tcIsTyVarTy, tcGetTyVar ) import NameEnv ( extendNameEnvList, nameEnvElts ) import InstEnv ( emptyInstEnv ) +import FamInstEnv ( emptyFamInstEnv ) import Var ( setTyVarName ) +import Id ( mkSysLocal ) import VarSet ( emptyVarSet ) import VarEnv ( TidyEnv, emptyTidyEnv, extendVarEnv ) import ErrUtils ( Message, Messages, emptyMessages, errorsFound, @@ -47,12 +50,13 @@ import NameSet ( NameSet, emptyDUs, emptyNameSet, unionNameSets, addOneToNameSe import OccName ( emptyOccEnv, tidyOccName ) import Bag ( emptyBag ) import Outputable -import UniqSupply ( UniqSupply, mkSplitUniqSupply, uniqFromSupply, splitUniqSupply ) +import UniqSupply ( UniqSupply, mkSplitUniqSupply, uniqFromSupply, uniqsFromSupply, splitUniqSupply ) import UniqFM ( unitUFM ) import Unique ( Unique ) import DynFlags ( DynFlags(..), DynFlag(..), dopt, dopt_set, dopt_unset, GhcMode ) import StaticFlags ( opt_PprStyle_Debug ) +import FastString ( FastString ) import Bag ( snocBag, unionBags ) import Panic ( showException ) @@ -101,6 +105,7 @@ initTc hsc_env hsc_src mod do_this tcg_type_env = hsc_global_type_env hsc_env, tcg_type_env_var = type_env_var, tcg_inst_env = emptyInstEnv, + tcg_fam_inst_env = emptyFamInstEnv, tcg_inst_uses = dfuns_var, tcg_th_used = th_var, tcg_exports = emptyNameSet, @@ -112,10 +117,13 @@ initTc hsc_env hsc_src mod do_this tcg_binds = emptyLHsBinds, tcg_deprecs = NoDeprecs, tcg_insts = [], + tcg_fam_insts= [], tcg_rules = [], tcg_fords = [], tcg_dfun_n = dfun_n_var, - tcg_keep = keep_var + tcg_keep = keep_var, + tcg_doc = Nothing, + tcg_hmi = HaddockModInfo Nothing Nothing Nothing Nothing } ; lcl_env = TcLclEnv { tcl_errs = errs_var, @@ -132,33 +140,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 } ; @@ -191,6 +174,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} %************************************************************************ %* * @@ -353,8 +362,13 @@ newUniqueSupply newLocalName :: Name -> TcRnIf gbl lcl Name newLocalName name -- Make a clone - = newUnique `thenM` \ uniq -> - returnM (mkInternalName uniq (nameOccName name) (getSrcLoc name)) + = do { uniq <- newUnique + ; return (mkInternalName uniq (nameOccName name) (getSrcLoc name)) } + +newSysLocalIds :: FastString -> [TcType] -> TcRnIf gbl lcl [TcId] +newSysLocalIds fs tys + = do { us <- newUniqueSupply + ; return (zipWith (mkSysLocal fs) (uniqsFromSupply us) tys) } \end{code}