TyThing, TypeEnv, emptyTypeEnv, HscSource(..), isHsBoot,
ExternalPackageState(..), HomePackageTable,
Deprecs(..), FixityEnv, FixItem,
- GhciMode, lookupType, unQualInScope )
+ lookupType, unQualInScope )
import Module ( Module, unitModuleEnv )
import RdrName ( GlobalRdrEnv, emptyGlobalRdrEnv,
LocalRdrEnv, emptyLocalRdrEnv )
import Outputable
import UniqSupply ( UniqSupply, mkSplitUniqSupply, uniqFromSupply, splitUniqSupply )
import Unique ( Unique )
-import CmdLineOpts ( DynFlags, DynFlag(..), dopt, opt_PprStyle_Debug, dopt_set )
+import DynFlags ( DynFlags(..), DynFlag(..), dopt, dopt_set, GhcMode )
+import StaticFlags ( opt_PprStyle_Debug )
import Bag ( snocBag, unionBags )
import Panic ( showException )
dfuns_var <- newIORef emptyNameSet ;
keep_var <- newIORef emptyNameSet ;
th_var <- newIORef False ;
+ dfun_n_var <- newIORef 1 ;
let {
gbl_env = TcGblEnv {
tcg_exports = emptyNameSet,
tcg_imports = init_imports,
tcg_dus = emptyDUs,
+ tcg_rn_decls = Nothing,
tcg_binds = emptyLHsBinds,
tcg_deprecs = NoDeprecs,
tcg_insts = [],
tcg_rules = [],
tcg_fords = [],
+ tcg_dfun_n = dfun_n_var,
tcg_keep = keep_var
} ;
lcl_env = TcLclEnv {
tcl_ctxt = [],
tcl_rdr = emptyLocalRdrEnv,
tcl_th_ctxt = topStage,
- tcl_arrow_ctxt = topArrowCtxt,
+ tcl_arrow_ctxt = NoArrowCtxt,
tcl_env = emptyNameEnv,
tcl_tyvars = tvs_var,
tcl_lie = panic "initTc:LIE", -- LIE only valid inside a getLIE
ifOptM flag thing_inside = do { b <- doptM flag;
if b then thing_inside else return () }
-getGhciMode :: TcRnIf gbl lcl GhciMode
-getGhciMode = do { env <- getTopEnv; return (hsc_mode env) }
+getGhciMode :: TcRnIf gbl lcl GhcMode
+getGhciMode = do { env <- getTopEnv; return (ghcMode (hsc_dflags env)) }
\end{code}
\begin{code}
%************************************************************************
\begin{code}
+nextDFunIndex :: TcM Int -- Get the next dfun index
+nextDFunIndex = do { env <- getGblEnv
+ ; let dfun_n_var = tcg_dfun_n env
+ ; n <- readMutVar dfun_n_var
+ ; writeMutVar dfun_n_var (n+1)
+ ; return n }
+
getLIEVar :: TcM (TcRef LIE)
getLIEVar = do { env <- getLclEnv; return (tcl_lie env) }
%************************************************************************
%* *
- Arrow context
-%* *
-%************************************************************************
-
-\begin{code}
-popArrowBinders :: TcM a -> TcM a -- Move to the left of a (-<); see comments in TcRnTypes
-popArrowBinders
- = updLclEnv (\ env -> env { tcl_arrow_ctxt = pop (tcl_arrow_ctxt env) })
- where
- pop (ArrCtxt {proc_level = curr_lvl, proc_banned = banned})
- = ASSERT( not (curr_lvl `elem` banned) )
- ArrCtxt {proc_level = curr_lvl, proc_banned = curr_lvl : banned}
-
-getBannedProcLevels :: TcM [ProcLevel]
- = do { env <- getLclEnv; return (proc_banned (tcl_arrow_ctxt env)) }
-
-incProcLevel :: TcM a -> TcM a
-incProcLevel
- = updLclEnv (\ env -> env { tcl_arrow_ctxt = inc (tcl_arrow_ctxt env) })
- where
- inc ctxt = ctxt { proc_level = proc_level ctxt + 1 }
-\end{code}
-
-
-%************************************************************************
-%* *
Stuff for the renamer's local env
%* *
%************************************************************************
; initTcRnIf 'i' hsc_env gbl_env () do_this
}
-initIfaceTc :: HscEnv -> ModIface
- -> (TcRef TypeEnv -> IfL a) -> IO a
+initIfaceTc :: ModIface
+ -> (TcRef TypeEnv -> IfL a) -> TcRnIf gbl lcl a
-- Used when type-checking checking an up-to-date interface file
-- No type envt from the current module, but we do know the module dependencies
-initIfaceTc hsc_env iface do_this
- = do { tc_env_var <- newIORef emptyTypeEnv
+initIfaceTc iface do_this
+ = do { tc_env_var <- newMutVar emptyTypeEnv
; let { gbl_env = IfGblEnv { if_rec_types = Just (mod, readMutVar tc_env_var) } ;
; if_lenv = mkIfLclEnv mod doc
}
- ; initTcRnIf 'i' hsc_env gbl_env if_lenv (do_this tc_env_var)
+ ; setEnvs (gbl_env, if_lenv) (do_this tc_env_var)
}
where
mod = mi_module iface