X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=ghc%2Fcompiler%2Ftypecheck%2FTcRnDriver.lhs;h=7fbbc32cb3891a7438a69d2d1a4eb15f7a2f8b65;hb=1f5e55804b97d2b9a77207d568d602ba88d8855d;hp=480b28f9322724117813aa8a5e7e655db0bd4764;hpb=0dfa678a3be85a7b8353b510a026ae684b1ee7cc;p=ghc-hetmet.git diff --git a/ghc/compiler/typecheck/TcRnDriver.lhs b/ghc/compiler/typecheck/TcRnDriver.lhs index 480b28f..7fbbc32 100644 --- a/ghc/compiler/typecheck/TcRnDriver.lhs +++ b/ghc/compiler/typecheck/TcRnDriver.lhs @@ -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 @@ -573,7 +555,7 @@ 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_ruleds = [], hs_defds = [] } \end{code} @@ -655,6 +637,8 @@ tc_rn_src_decls ds -- Rename the splice expression, and get its supporting decls (rn_splice_expr, splice_fvs) <- addSrcLoc splice_loc $ rnExpr splice_expr ; + failIfErrsM ; -- Don't typecheck if renaming failed + -- Execute the splice spliced_decls <- tcSpliceDecls rn_splice_expr ; @@ -704,6 +688,7 @@ rnTopSrcDecls group tcg_imports = imports `plusImportAvails` tcg_imports gbl }) $ do { + traceRn (ptext SLIT("rnTopSrcDecls") <+> ppr rdr_env) ; failIfErrsM ; -- No point in continuing if (say) we have duplicate declarations -- Rename the source decls @@ -807,12 +792,15 @@ mkExportEnv :: HscEnv -> [ModuleName] -- Expose these modules' exports only -> IO GlobalRdrEnv mkExportEnv hsc_env exports - = initIfaceIO hsc_env $ do { - export_envs <- mappM getModuleExports exports ; - returnM (foldr plusGlobalRdrEnv emptyGlobalRdrEnv export_envs) + = do { mb_envs <- initTc hsc_env iNTERACTIVE $ + mappM getModuleExports exports + ; case mb_envs of + Just envs -> return (foldr plusGlobalRdrEnv emptyGlobalRdrEnv envs) + Nothing -> return emptyGlobalRdrEnv + -- Some error; initTc will have printed it } -getModuleExports :: ModuleName -> IfG GlobalRdrEnv +getModuleExports :: ModuleName -> TcM GlobalRdrEnv getModuleExports mod = do { iface <- load_iface mod ; avails <- exportsToAvails (mi_exports iface) @@ -833,10 +821,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 @@ -858,7 +846,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)) } --------------------- @@ -879,7 +867,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") @@ -903,7 +893,7 @@ checkMain let { main_mod = case mb_main_mod of { Just mod -> mkModuleName mod ; Nothing -> mAIN_Name } ; - main_fn = case mb_main_fn of { + main_fn = case mb_main_fn of { Just fn -> mkRdrUnqual (mkVarOcc (mkFastString fn)) ; Nothing -> main_RDR_Unqual } } ;