X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fmain%2FHscMain.lhs;h=93ad614a58a53f009f607068996c0f4a100506e7;hb=781fd68db0abe2ebca2481a149442ee3ff8d99b7;hp=d5ad093bc9d3ef10f5cfa92ebd48e166e65a68d0;hpb=ce426964baf58f76ad4681d8a26f671c10ad4f7e;p=ghc-hetmet.git diff --git a/compiler/main/HscMain.lhs b/compiler/main/HscMain.lhs index d5ad093..93ad614 100644 --- a/compiler/main/HscMain.lhs +++ b/compiler/main/HscMain.lhs @@ -14,7 +14,7 @@ module HscMain , hscSimplify , hscNormalIface, hscWriteIface, hscGenHardCode #ifdef GHCI - , hscStmt, hscTcExpr, hscKcType + , hscStmt, hscTcExpr, hscImport, hscKcType , compileExpr #endif , HsCompiler(..) @@ -51,9 +51,10 @@ import PrelNames ( iNTERACTIVE ) import {- Kind parts of -} Type ( Kind ) import CoreLint ( lintUnfolding ) import DsMeta ( templateHaskellNames ) -import SrcLoc ( SrcSpan, noSrcLoc, interactiveSrcLoc, srcLocSpan, noSrcSpan ) +import SrcLoc ( SrcSpan, noSrcLoc, interactiveSrcLoc, srcLocSpan, noSrcSpan, unLoc ) import VarSet import VarEnv ( emptyTidyEnv ) +import Panic #endif import Id ( Id ) @@ -109,7 +110,7 @@ import HscStats ( ppSourceStats ) import HscTypes import MkExternalCore ( emitExternalCore ) import FastString -import LazyUniqFM ( emptyUFM ) +import UniqFM ( emptyUFM ) import UniqSupply ( initUs_ ) import Bag ( unitBag ) import Exception @@ -186,7 +187,7 @@ hscParse mod_summary = do let loc = mkSrcLoc (mkFastString src_filename) 1 1 - case unP parseModule (mkPState buf loc dflags) of + case unP parseModule (mkPState dflags buf loc) of PFailed span err -> throwOneError (mkPlainErrMsg span err) @@ -435,7 +436,12 @@ hscOneShotCompiler = , hscRecompile = genericHscRecompile hscOneShotCompiler - , hscBackend = genericHscBackend hscOneShotCompiler + , hscBackend = \ tc_result mod_summary mb_old_hash -> do + hsc_env <- getSession + case hscTarget (hsc_dflags hsc_env) of + HscNothing -> return (HscRecomp False ()) + _otherw -> genericHscBackend hscOneShotCompiler + tc_result mod_summary mb_old_hash , hscGenBootOutput = \tc_result mod_summary mb_old_iface -> do (iface, changed, _) <- hscSimpleIface tc_result mb_old_iface @@ -536,13 +542,7 @@ hscNothingCompiler = details <- genModDetails iface return (HscNoRecomp, iface, details) - , hscRecompile = \mod_summary mb_old_hash -> - case ms_hsc_src mod_summary of - ExtCoreFile -> - panic "hscCompileNothing: cannot do external core" - _otherwise -> do - tc_result <- hscFileFrontEnd mod_summary - hscBackend hscNothingCompiler tc_result mod_summary mb_old_hash + , hscRecompile = genericHscRecompile hscNothingCompiler , hscBackend = \tc_result _mod_summary mb_old_iface -> do (iface, _changed, details) <- hscSimpleIface tc_result mb_old_iface @@ -932,6 +932,12 @@ hscStmt hsc_env stmt = do return $ Just (ids, hval) +hscImport :: GhcMonad m => HscEnv -> String -> m (ImportDecl RdrName) +hscImport hsc_env str = do + (L _ (HsModule{hsmodImports=is})) <- hscParseThing parseModule (hsc_dflags hsc_env) str + case is of + [i] -> return (unLoc i) + _ -> throwOneError (mkPlainErrMsg noSrcSpan (ptext (sLit "parse error in import declaration"))) hscTcExpr -- Typecheck an expression (but don't run it) :: GhcMonad m => @@ -991,7 +997,7 @@ hscParseThing parser dflags str let loc = mkSrcLoc (fsLit "") 1 1 - case unP parser (mkPState buf loc dflags) of + case unP parser (mkPState dflags buf loc) of PFailed span err -> do let msg = mkPlainErrMsg span err @@ -1021,6 +1027,11 @@ hscParseThing parser dflags str compileExpr :: HscEnv -> SrcSpan -> CoreExpr -> IO HValue compileExpr hsc_env srcspan ds_expr + | rtsIsProfiled + = throwIO (InstallationError "You can't call compileExpr in a profiled compiler") + -- Otherwise you get a seg-fault when you run it + + | otherwise = do { let { dflags = hsc_dflags hsc_env ; lint_on = dopt Opt_DoCoreLinting dflags }