[project @ 2003-10-16 10:19:27 by simonpj]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcRnDriver.lhs
index 20d0d21..b1dd133 100644 (file)
@@ -10,7 +10,7 @@ module TcRnDriver (
 #endif
        tcRnModule, 
        tcTopSrcDecls,
-       tcRnIface, tcRnExtCore
+       tcRnExtCore
     ) where
 
 #include "HsVersions.h"
@@ -42,7 +42,7 @@ import TcEnv          ( tcExtendGlobalValEnv, tcLookupGlobal )
 import TcRules         ( tcRules )
 import TcForeign       ( tcForeignImports, tcForeignExports )
 import TcInstDcls      ( tcInstDecls1, tcInstDecls2 )
-import TcIface         ( typecheckIface, tcExtCoreBindings )
+import TcIface         ( tcExtCoreBindings )
 import TcSimplify      ( tcSimplifyTop )
 import TcTyClsDecls    ( tcTyAndClassDecls )
 import LoadIface       ( loadOrphanModules )
@@ -91,7 +91,7 @@ import TyCon          ( DataConDetails(..) )
 import Inst            ( tcStdSyntaxName )
 import RnExpr          ( rnStmts, rnExpr )
 import RnNames         ( exportsToAvails )
-import LoadIface       ( loadSysInterface )
+import LoadIface       ( loadSrcInterface )
 import IfaceSyn                ( IfaceDecl(..), IfaceClassOp(..), IfaceConDecl(..), IfaceExtName(..),
                          tyThingToIfaceDecl )
 import IfaceEnv                ( tcIfaceGlobal )
@@ -199,24 +199,6 @@ tcRnModule hsc_env
 \end{code}
 
 
-%*********************************************************
-%*                                                      *
-\subsection{Closing up the interface decls}
-%*                                                      *
-%*********************************************************
-
-Suppose we discover we don't need to recompile.   Then we start from the
-IfaceDecls in the ModIface, and fluff them up by sucking in all the decls they need.
-
-\begin{code}
-tcRnIface :: HscEnv
-         -> ModIface   -- Get the decls from here
-         -> IO ModDetails
-tcRnIface hsc_env iface
-  = initIfaceIO hsc_env (typecheckIface iface)
-\end{code}
-
-
 %************************************************************************
 %*                                                                     *
                The interactive interface 
@@ -517,9 +499,7 @@ tcRnExtCore hsc_env (HsExtCore this_mod decls src_binds)
 
        -- Deal with the type declarations; first bring their stuff
        -- into scope, then rname them, then type check them
-   (rdr_env, imports) <- importsFromLocalDecls $
-       HsGroup { hs_tyclds = decls, hs_valds = EmptyBinds, hs_fords = [] } ;
-               -- Rather clumsy; lots of unused fields
+   (rdr_env, imports) <- importsFromLocalDecls (mkFakeGroup decls) ;
 
    updGblEnv (\gbl -> gbl { tcg_rdr_env = rdr_env `plusGlobalRdrEnv` tcg_rdr_env gbl,
                            tcg_imports = imports `plusImportAvails` tcg_imports gbl }) 
@@ -570,6 +550,12 @@ tcRnExtCore hsc_env (HsExtCore this_mod decls src_binds)
 
    return mod_guts
    }}}}
+
+mkFakeGroup decls -- Rather clumsy; lots of unused fields
+  = HsGroup {  hs_tyclds = decls,      -- This is the one we want
+               hs_valds = EmptyBinds, hs_fords = [],
+               hs_instds = [], hs_fixds = [], hs_depds = [],
+               hs_ruleds = [], hs_defds = [] }
 \end{code}
 
 
@@ -800,15 +786,15 @@ tcTopSrcDecls
 \begin{code}
 #ifdef GHCI
 mkExportEnv :: HscEnv -> [ModuleName]  -- Expose these modules' exports only
-           -> IO GlobalRdrEnv
+           -> IO (Maybe GlobalRdrEnv)
 
 mkExportEnv hsc_env exports
-  = initIfaceIO hsc_env $ do {
+  = initTc hsc_env iNTERACTIVE $ do {
     export_envs <- mappM getModuleExports exports ;
     returnM (foldr plusGlobalRdrEnv emptyGlobalRdrEnv export_envs)
     }
 
-getModuleExports :: ModuleName -> IfG GlobalRdrEnv
+getModuleExports :: ModuleName -> TcM GlobalRdrEnv
 getModuleExports mod 
   = do { iface <- load_iface mod
        ; avails <- exportsToAvails (mi_exports iface)
@@ -829,10 +815,10 @@ getModuleContents
   -> InteractiveContext
   -> ModuleName                        -- Module to inspect
   -> Bool                      -- Grab just the exports, or the whole toplev
-  -> IO [IfaceDecl]
+  -> IO (Maybe [IfaceDecl])
 
 getModuleContents hsc_env ictxt mod exports_only
- = initIfaceIO hsc_env (get_mod_contents exports_only)
+ = initTc hsc_env iNTERACTIVE (get_mod_contents exports_only)
  where
    get_mod_contents exports_only
       | not exports_only       -- We want the whole top-level type env
@@ -854,7 +840,7 @@ getModuleContents hsc_env ictxt mod exports_only
        }
 
    get_decl avail 
-       = do { thing <- tcIfaceGlobal (availName avail)
+       = do { thing <- tcLookupGlobal (availName avail)
             ; return (filter_decl (availOccs avail) (toIfaceDecl ictxt thing)) }
 
 ---------------------
@@ -875,7 +861,9 @@ wantToSee (ADataCon _) = False      -- They'll come via their TyCon
 wantToSee _           = True
 
 ---------------------
-load_iface mod = loadSysInterface (text "context for compiling statements") mod
+load_iface mod = loadSrcInterface doc mod False {- Not boot iface -}
+              where
+                doc = ptext SLIT("context for compiling statements")
 
 ---------------------
 noRdrEnvErr mod = ptext SLIT("No top-level environment available for module")