X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fmain%2FHscMain.lhs;h=933503e4915742d14184463212503051a61a4b62;hp=b1832504f9342201146ec3bc86a44a62497d8a3f;hb=b017f34bebf1588e5e579d7c653413e2a4c2d170;hpb=7828bf3ea2ea34e7a3a8662f5f621ef706ffee5c diff --git a/compiler/main/HscMain.lhs b/compiler/main/HscMain.lhs index b183250..933503e 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,7 +51,7 @@ 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 ) #endif @@ -186,7 +186,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) @@ -931,6 +931,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 => @@ -990,7 +996,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