{- **********************************************************************
%*                                                                      *
                Initialisation
%*                                                                      *
%********************************************************************* -}

newHscEnv :: DynFlags -> IO HscEnv
newHscEnv dflags = do
    eps_var <- newIORef initExternalPackageState
    us      <- mkSplitUniqSupply 'r'
    nc_var  <- newIORef (initNameCache us knownKeyNames)
    fc_var  <- newIORef emptyInstalledModuleEnv
    iserv_mvar <- newMVar Nothing
    mlc_var <- newIORef emptyModuleEnv
    ic      <- newInteractiveContext dflags
    idx_var <- newMVar emptyClassIndex
    return HscEnv {  hsc_dflags       = dflags,
                     hsc_targets      = [],
                     hsc_mod_graph    = emptyMG,
                     hsc_IC           = ic,
                     hsc_HPT          = emptyHomePackageTable,
                     hsc_EPS          = eps_var,
                     hsc_NC           = nc_var,
                     hsc_FC           = fc_var,
                     hsc_iserv        = iserv_mvar,
                     hsc_MLC          = mlc_var,
                     hsc_type_env_var = Nothing,
                     hsc_classIndex   = idx_var }

-- -----------------------------------------------------------------------------
newHscEnv :: DynFlags -> IO HscEnv
newHscEnv dflags = do
    eps_var <- newIORef initExternalPackageState
    us      <- mkSplitUniqSupply 'r'
    nc_var  <- newIORef (initNameCache us knownKeyNames)
    fc_var  <- newIORef emptyInstalledModuleEnv
    iserv_mvar <- newMVar Nothing
    mlc_var <- newIORef emptyModuleEnv
    ic      <- newInteractiveContext dflags
    idx_var <- newMVar emptyClassIndex
    return HscEnv {  hsc_dflags       = dflags,
                     hsc_targets      = [],
                     hsc_mod_graph    = emptyMG,
                     hsc_IC           = ic,
                     hsc_HPT          = emptyHomePackageTable,
                     hsc_EPS          = eps_var,
                     hsc_NC           = nc_var,
                     hsc_FC           = fc_var,
                     hsc_iserv        = iserv_mvar,
                     hsc_MLC          = mlc_var,
                     hsc_type_env_var = Nothing,
                     hsc_classIndex   = idx_var }

-- -----------------------------------------------------------------------------
newHscEnv dflags = do
    eps_var <- newIORef initExternalPackageState
    us      <- mkSplitUniqSupply 'r'
    nc_var  <- newIORef (initNameCache us knownKeyNames)
    fc_var  <- newIORef emptyInstalledModuleEnv
    iserv_mvar <- newMVar Nothing
    mlc_var <- newIORef emptyModuleEnv
    ic      <- newInteractiveContext dflags
    idx_var <- newMVar emptyClassIndex
    return HscEnv {  hsc_dflags       = dflags,
                     hsc_targets      = [],
                     hsc_mod_graph    = emptyMG,
                     hsc_IC           = ic,
                     hsc_HPT          = emptyHomePackageTable,
                     hsc_EPS          = eps_var,
                     hsc_NC           = nc_var,
                     hsc_FC           = fc_var,
                     hsc_iserv        = iserv_mvar,
                     hsc_MLC          = mlc_var,
                     hsc_type_env_var = Nothing,
                     hsc_classIndex   = idx_var }

-- -----------------------------------------------------------------------------