, hscSimplify
, hscNormalIface, hscWriteIface, hscGenHardCode
#ifdef GHCI
- , hscStmt, hscTcExpr, hscKcType
+ , hscStmt, hscTcExpr, hscImport, hscKcType
, compileExpr
#endif
, HsCompiler(..)
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 )
#endif
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)
, 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
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
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 =>
let loc = mkSrcLoc (fsLit "<interactive>") 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