Commit 069370a5 authored by simonmar's avatar simonmar
Browse files

[project @ 2005-03-22 17:13:12 by simonmar]

A start on the GHC API:

Flesh out the GHC module so that it can replace CompManager.  Now, the
clients that used CompManager consume the GHC API instead (namely
Main, DriverMkDepend, and InteractiveUI).  Main is significantly
cleaner as a result.

The interface needs more work: in particular, getInfo returns results
in the form of IfaceDecls but we want to use full HsSyn and
Id/DataCon/Class across the boundary instead.

The interfaces for inspecting loaded modules are not yet implemented.
parent 46a5c73d
......@@ -369,9 +369,6 @@ ALL_SRCS += $(CONFIG_HS)
# HsGeneric.hs is not used just now
EXCLUDED_SRCS += hsSyn/HsGeneric.hs
# main/GHC.hs is not ready yet
EXCLUDED_SRCS += main/GHC.hs
ifeq ($(GhcWithNativeCodeGen),YES)
ALL_DIRS += nativeGen
else
......
This diff is collapsed.
This diff is collapsed.
......@@ -315,7 +315,7 @@ linkExpr hsc_env root_ul_bco
-- Find what packages and linkables are required
; eps <- readIORef (hsc_EPS hsc_env)
; (lnks, pkgs) <- getLinkDeps dflags hpt (eps_PIT eps) needed_mods
; (lnks, pkgs) <- getLinkDeps hsc_env hpt (eps_PIT eps) needed_mods
-- Link the packages and modules required
; linkPackages dflags pkgs
......@@ -350,12 +350,12 @@ linkExpr hsc_env root_ul_bco
dieWith msg = throwDyn (ProgramError (showSDoc msg))
getLinkDeps :: DynFlags -> HomePackageTable -> PackageIfaceTable
getLinkDeps :: HscEnv -> HomePackageTable -> PackageIfaceTable
-> [Module] -- If you need these
-> IO ([Linkable], [PackageId]) -- ... then link these first
-- Fails with an IO exception if it can't find enough files
getLinkDeps dflags hpt pit mods
getLinkDeps hsc_env hpt pit mods
-- Find all the packages and linkables that a set of modules depends on
= do { pls <- readIORef v_PersistentLinkerState ;
let {
......@@ -404,7 +404,7 @@ getLinkDeps dflags hpt pit mods
| otherwise
= -- It's not in the HPT because we are in one shot mode,
-- so use the Finder to get a ModLocation...
do { mb_stuff <- findModule dflags mod_name False ;
do { mb_stuff <- findModule hsc_env mod_name False ;
case mb_stuff of {
Found loc _ -> found loc mod_name ;
_ -> no_obj mod_name
......
......@@ -27,7 +27,7 @@ import IfaceSyn ( IfaceDecl(..), IfaceConDecl(..), IfaceClassOp(..),
import IfaceEnv ( newGlobalBinder, lookupIfaceExt, lookupIfaceTc, lookupAvail )
import HscTypes ( ModIface(..), TyThing, emptyModIface, EpsStats(..),
addEpsInStats, ExternalPackageState(..),
PackageTypeEnv, emptyTypeEnv,
PackageTypeEnv, emptyTypeEnv, HscEnv(..),
lookupIfaceByModule, emptyPackageIfaceTable,
IsBootInterface, mkIfaceFixCache, Gated,
implicitTyThings, addRulesToPool, addInstsToPool
......@@ -576,7 +576,8 @@ findAndReadIface explicit doc_str mod_name hi_boot_file
else do
-- Look for the file
; mb_found <- ioToIOEnv (findHiFile dflags explicit mod_name hi_boot_file)
; hsc_env <- getTopEnv
; mb_found <- ioToIOEnv (findHiFile hsc_env explicit mod_name hi_boot_file)
; case mb_found of {
Failed err -> do
{ traceIf (ptext SLIT("...not found"))
......@@ -598,19 +599,19 @@ findAndReadIface explicit doc_str mod_name hi_boot_file
-- Don't forget to fill in the package name...
}}}
findHiFile :: DynFlags -> Bool -> Module -> IsBootInterface
findHiFile :: HscEnv -> Bool -> Module -> IsBootInterface
-> IO (MaybeErr FindResult (FilePath, PackageIdH))
findHiFile dflags explicit mod_name hi_boot_file
findHiFile hsc_env explicit mod_name hi_boot_file
= do {
-- In interactive or --make mode, we are *not allowed* to demand-load
-- a home package .hi file. So don't even look for them.
-- This helps in the case where you are sitting in eg. ghc/lib/std
-- and start up GHCi - it won't complain that all the modules it tries
-- to load are found in the home location.
let { home_allowed = isOneShot (ghcMode dflags) } ;
let { home_allowed = isOneShot (ghcMode (hsc_dflags hsc_env)) } ;
maybe_found <- if home_allowed
then findModule dflags mod_name explicit
else findPackageModule dflags mod_name explicit;
then findModule hsc_env mod_name explicit
else findPackageModule hsc_env mod_name explicit;
case maybe_found of
Found loc pkg -> return (Succeeded (path, pkg))
......
......@@ -12,11 +12,11 @@ module DriverMkDepend (
#include "HsVersions.h"
import CompManager ( cmDownsweep, cmTopSort, cyclicModuleErr )
import qualified GHC
import GHC ( Session, ModSummary(..) )
import DynFlags ( DynFlags( verbosity, opt_dep ), getOpts )
import Util ( escapeSpaces, splitFilename )
import HscTypes ( IsBootInterface, ModSummary(..), msObjFilePath,
msHsFilePath )
import HscTypes ( HscEnv, IsBootInterface, msObjFilePath, msHsFilePath )
import Packages ( PackageIdH(..) )
import SysTools ( newTempName )
import qualified SysTools
......@@ -47,18 +47,22 @@ import Panic ( catchJust, ioErrors )
--
-----------------------------------------------------------------
doMkDependHS :: DynFlags -> [FilePath] -> IO ()
doMkDependHS dflags srcs
doMkDependHS :: Session -> [FilePath] -> IO ()
doMkDependHS session srcs
= do { -- Initialisation
files <- beginMkDependHS dflags
dflags <- GHC.getSessionDynFlags session
; files <- beginMkDependHS dflags
-- Do the downsweep to find all the modules
; targets <- mapM GHC.guessTarget srcs
; GHC.setTargets session targets
; excl_mods <- readIORef v_Dep_exclude_mods
; mod_summaries <- cmDownsweep dflags srcs [] excl_mods
; GHC.depanal session excl_mods
; mod_summaries <- GHC.getModuleGraph session
-- Sort into dependency order
-- There should be no cycles
; let sorted = cmTopSort False mod_summaries
; let sorted = GHC.topSortModuleGraph False mod_summaries
-- Print out the dependencies if wanted
; if verbosity dflags >= 2 then
......@@ -67,7 +71,7 @@ doMkDependHS dflags srcs
-- Prcess them one by one, dumping results into makefile
-- and complaining about cycles
; mapM (processDeps dflags (mkd_tmp_hdl files)) sorted
; mapM (processDeps session (mkd_tmp_hdl files)) sorted
-- Tidy up
; endMkDependHS dflags files }
......@@ -145,7 +149,7 @@ beginMkDependHS dflags = do
--
-----------------------------------------------------------------
processDeps :: DynFlags
processDeps :: Session
-> Handle -- Write dependencies to here
-> SCC ModSummary
-> IO ()
......@@ -164,19 +168,20 @@ processDeps :: DynFlags
--
-- For {-# SOURCE #-} imports the "hi" will be "hi-boot".
processDeps dflags hdl (CyclicSCC nodes)
processDeps session hdl (CyclicSCC nodes)
= -- There shouldn't be any cycles; report them
throwDyn (ProgramError (showSDoc $ cyclicModuleErr nodes))
throwDyn (ProgramError (showSDoc $ GHC.cyclicModuleErr nodes))
processDeps dflags hdl (AcyclicSCC node)
processDeps session hdl (AcyclicSCC node)
= do { extra_suffixes <- readIORef v_Dep_suffixes
; hsc_env <- GHC.sessionHscEnv session
; include_pkg_deps <- readIORef v_Dep_include_pkg_deps
; let src_file = msHsFilePath node
obj_file = msObjFilePath node
obj_files = insertSuffixes obj_file extra_suffixes
do_imp is_boot imp_mod
= do { mb_hi <- findDependency dflags src_file imp_mod
= do { mb_hi <- findDependency hsc_env src_file imp_mod
is_boot include_pkg_deps
; case mb_hi of {
Nothing -> return () ;
......@@ -200,16 +205,16 @@ processDeps dflags hdl (AcyclicSCC node)
}
findDependency :: DynFlags
findDependency :: HscEnv
-> FilePath -- Importing module: used only for error msg
-> Module -- Imported module
-> IsBootInterface -- Source import
-> Bool -- Record dependency on package modules
-> IO (Maybe FilePath) -- Interface file file
findDependency dflags src imp is_boot include_pkg_deps
findDependency hsc_env src imp is_boot include_pkg_deps
= do { -- Find the module; this will be fast because
-- we've done it once during downsweep
r <- findModule dflags imp True {-explicit-}
r <- findModule hsc_env imp True {-explicit-}
; case r of
Found loc pkg
-- Not in this package: we don't need a dependency
......@@ -220,9 +225,7 @@ findDependency dflags src imp is_boot include_pkg_deps
| otherwise
-> return (Just (addBootSuffix_maybe is_boot (ml_hi_file loc)))
_ -> throwDyn (ProgramError
(src ++ ": " ++ "can't locate import `" ++ (moduleUserString imp) ++ "'"
++ if is_boot then " (SOURCE import)" else ""))
_ -> panic "findDependency"
}
-----------------------------
......
......@@ -2,13 +2,14 @@
--
-- GHC Driver
--
-- (c) The University of Glasgow 2002
-- (c) The University of Glasgow 2005
--
-----------------------------------------------------------------------------
module DriverPipeline (
-- Run a series of compilation steps in a pipeline
runPipeline,
-- Run a series of compilation steps in a pipeline, for a
-- collection of source files.
oneShot,
-- Interfaces for the batch-mode driver
staticLink,
......@@ -70,13 +71,7 @@ import Maybe
preprocess :: DynFlags -> FilePath -> IO (DynFlags, FilePath)
preprocess dflags filename =
ASSERT2(isHaskellSrcFilename filename, text filename)
runPipeline anyHsc dflags
False{-temporary output file-}
Nothing{-no specific output file-}
filename
Nothing{-no ModLocation-}
runPipeline anyHsc dflags filename Temporary Nothing{-no ModLocation-}
-- ---------------------------------------------------------------------------
-- Compile
......@@ -88,12 +83,6 @@ preprocess dflags filename =
-- reading the OPTIONS pragma from the source file, and passing the
-- output of hsc through the C compiler.
-- The driver sits between 'compile' and 'hscMain', translating calls
-- to the former into calls to the latter, and results from the latter
-- into results from the former. It does things like preprocessing
-- the .hs file if necessary, and compiling up the .stub_c files to
-- generate Linkables.
-- NB. No old interface can also mean that the source has changed.
compile :: HscEnv
......@@ -149,9 +138,8 @@ compile hsc_env mod_summary
-- ... and what the next phase should be
let next_phase = hscNextPhase dflags src_flavour hsc_lang
-- ... and what file to generate the output into
let get_output_fn = genOutputFilenameFunc dflags next_phase
False Nothing basename
output_fn <- get_output_fn next_phase (Just location)
output_fn <- getOutputFilename dflags next_phase
Temporary basename next_phase (Just location)
let dflags' = dflags { hscTarget = hsc_lang,
hscOutName = output_fn,
......@@ -209,8 +197,8 @@ compile hsc_env mod_summary
_other -> do
let object_filename = ml_obj_file location
runPipeline StopLn dflags
True Nothing output_fn (Just location)
runPipeline StopLn dflags output_fn Persistent
(Just location)
-- the object filename comes from the ModLocation
o_time <- getModificationTime object_filename
......@@ -230,10 +218,7 @@ compileStub dflags stub_c_exists
-- compile the _stub.c file w/ gcc
let stub_c = hscStubCOutName dflags
(_, stub_o) <- runPipeline StopLn dflags
True{-persistent output-}
Nothing{-no specific output file-}
stub_c
Nothing{-no ModLocation-}
stub_c Persistent Nothing{-no ModLocation-}
return (Just stub_o)
......@@ -304,24 +289,93 @@ link BatchCompile dflags batch_attempt_linking hpt
where
verb = verbosity dflags
-- -----------------------------------------------------------------------------
-- Compile files in one-shot mode.
oneShot :: DynFlags -> Phase -> [String] -> IO ()
oneShot dflags stop_phase srcs = do
o_files <- mapM (compileFile dflags stop_phase) srcs
doLink dflags stop_phase o_files
compileFile :: DynFlags -> Phase -> FilePath -> IO FilePath
compileFile dflags stop_phase src = do
exists <- doesFileExist src
when (not exists) $
throwDyn (CmdLineError ("does not exist: " ++ src))
let
split = dopt Opt_SplitObjs dflags
mb_o_file = outputFile dflags
ghc_link = ghcLink dflags -- Set by -c or -no-link
-- When linking, the -o argument refers to the linker's output.
-- otherwise, we use it as the name for the pipeline's output.
output
| StopLn <- stop_phase, not (isNoLink ghc_link) = Persistent
-- -o foo applies to linker
| Just o_file <- mb_o_file = SpecificFile o_file
-- -o foo applies to the file we are compiling now
| otherwise = Persistent
stop_phase' = case stop_phase of
As | split -> SplitAs
other -> stop_phase
(_, out_file) <- runPipeline stop_phase' dflags
src output Nothing{-no ModLocation-}
return out_file
doLink :: DynFlags -> Phase -> [FilePath] -> IO ()
doLink dflags stop_phase o_files
| not (isStopLn stop_phase)
= return () -- We stopped before the linking phase
| otherwise
= case ghcLink dflags of
NoLink -> return ()
StaticLink -> staticLink dflags o_files link_pkgs
MkDLL -> doMkDLL dflags o_files link_pkgs
where
-- Always link in the haskell98 package for static linking. Other
-- packages have to be specified via the -package flag.
link_pkgs
| ExtPackage h98_id <- haskell98PackageId (pkgState dflags) = [h98_id]
| otherwise = []
-- ---------------------------------------------------------------------------
-- Run a compilation pipeline, consisting of multiple phases.
-- This is the interface to the compilation pipeline, which runs
-- a series of compilation steps on a single source file, specifying
-- at which stage to stop.
-- The DynFlags can be modified by phases in the pipeline (eg. by
-- OPTIONS pragmas), and the changes affect later phases in the
-- pipeline, but we throw away the resulting DynFlags at the end.
-- GHC_OPTIONS pragmas), and the changes affect later phases in the
-- pipeline.
data PipelineOutput
= Temporary
-- output should be to a temporary file: we're going to
-- run more compilation steps on this output later
| Persistent
-- we want a persistent file, i.e. a file in the current directory
-- derived from the input filename, but with the appropriate extension.
-- eg. in "ghc -c Foo.hs" the output goes into ./Foo.o.
| SpecificFile FilePath
-- the output must go into the specified file.
runPipeline
:: Phase -- When to stop
-> DynFlags -- Dynamic flags
-> Bool -- Final output is persistent?
-> Maybe FilePath -- Where to put the output, optionally
-> FilePath -- Input filename
-> Maybe ModLocation -- A ModLocation for this module, if we have one
-> PipelineOutput -- Output filename
-> Maybe ModLocation -- A ModLocation, if this is a Haskell module
-> IO (DynFlags, FilePath) -- (final flags, output filename)
runPipeline stop_phase dflags keep_output
maybe_output_filename input_fn maybe_loc
runPipeline stop_phase dflags input_fn output maybe_loc
= do
let (basename, suffix) = splitFilename input_fn
start_phase = startPhase suffix
......@@ -338,27 +392,29 @@ runPipeline stop_phase dflags keep_output
("cannot compile this file to desired target: "
++ input_fn))
-- generate a function which will be used to calculate output file names
-- as we go along.
let get_output_fn = genOutputFilenameFunc dflags stop_phase keep_output
maybe_output_filename basename
-- this is a function which will be used to calculate output file names
-- as we go along (we partially apply it to some of its inputs here)
let get_output_fn = getOutputFilename dflags stop_phase output basename
-- Execute the pipeline...
(dflags', output_fn, maybe_loc) <- pipeLoop dflags start_phase stop_phase input_fn
basename suffix get_output_fn maybe_loc
(dflags', output_fn, maybe_loc) <-
pipeLoop dflags start_phase stop_phase input_fn
basename suffix get_output_fn maybe_loc
-- Sometimes, a compilation phase doesn't actually generate any output
-- (eg. the CPP phase when -fcpp is not turned on). If we end on this
-- stage, but we wanted to keep the output, then we have to explicitly
-- copy the file.
if keep_output
then do final_fn <- get_output_fn stop_phase maybe_loc
when (final_fn /= output_fn) $
copy dflags ("Copying `" ++ output_fn ++ "' to `" ++ final_fn
case output of
Temporary ->
return (dflags', output_fn)
_other ->
do final_fn <- get_output_fn stop_phase maybe_loc
when (final_fn /= output_fn) $
copy dflags ("Copying `" ++ output_fn ++ "' to `" ++ final_fn
++ "'") output_fn final_fn
return (dflags', final_fn)
else
return (dflags', output_fn)
return (dflags', final_fn)
pipeLoop :: DynFlags -> Phase -> Phase
......@@ -389,10 +445,10 @@ pipeLoop dflags phase stop_phase
; pipeLoop dflags' next_phase stop_phase output_fn
orig_basename orig_suff orig_get_output_fn maybe_loc }
genOutputFilenameFunc :: DynFlags -> Phase -> Bool -> Maybe FilePath -> String
-> (Phase{-next phase-} -> Maybe ModLocation -> IO FilePath)
genOutputFilenameFunc dflags stop_phase keep_final_output
maybe_output_filename basename
getOutputFilename
:: DynFlags -> Phase -> PipelineOutput -> String
-> Phase{-next phase-} -> Maybe ModLocation -> IO FilePath
getOutputFilename dflags stop_phase output basename
= func
where
hcsuf = hcSuf dflags
......@@ -407,11 +463,10 @@ genOutputFilenameFunc dflags stop_phase keep_final_output
myPhaseInputExt other = phaseInputExt other
func next_phase maybe_location
| is_last_phase, Just f <- maybe_output_filename = return f
| is_last_phase && keep_final_output = persistent_fn
| keep_this_output = persistent_fn
| otherwise = newTempName dflags suffix
| is_last_phase, Persistent <- output = persistent_fn
| is_last_phase, SpecificFile f <- output = return f
| keep_this_output = persistent_fn
| otherwise = newTempName dflags suffix
where
is_last_phase = next_phase `eqPhase` stop_phase
......@@ -582,9 +637,6 @@ runPhase (Hsc src_flavour) stop dflags0 basename suff input_fn get_output_fn _ma
= location3 { ml_obj_file = ofile }
| otherwise = location3
-- Tell the finder cache about this module
addHomeModuleToFinder mod_name location4
-- Make the ModSummary to hand to hscMain
src_timestamp <- getModificationTime (basename ++ '.':suff)
let
......@@ -638,6 +690,9 @@ runPhase (Hsc src_flavour) stop dflags0 basename suff input_fn get_output_fn _ma
hsc_env <- newHscEnv dflags'
-- Tell the finder cache about this module
addHomeModuleToFinder hsc_env mod_name location4
-- run the compiler!
result <- hscMain hsc_env printErrorsAndWarnings
mod_summary source_unchanged
......
......@@ -11,7 +11,7 @@ module Finder (
findPackageModule, -- :: ModuleName -> Bool -> IO FindResult
mkHomeModLocation, -- :: ModuleName -> FilePath -> IO ModLocation
mkHomeModLocation2, -- :: ModuleName -> FilePath -> String -> IO ModLocation
addHomeModuleToFinder, -- :: Module -> ModLocation -> IO ()
addHomeModuleToFinder, -- :: HscEnv -> Module -> ModLocation -> IO ()
findLinkable, -- :: ModuleName -> ModLocation -> IO (Maybe Linkable)
......@@ -22,7 +22,7 @@ module Finder (
import Module
import UniqFM ( filterUFM )
import HscTypes ( Linkable(..), Unlinked(..) )
import HscTypes
import Packages
import FastString
import Util
......@@ -55,24 +55,20 @@ type BaseName = String -- Basename of file
-- -----------------------------------------------------------------------------
-- The finder's cache
GLOBAL_VAR(finder_cache, emptyModuleEnv, ModuleEnv FinderCacheEntry)
type FinderCacheEntry = (ModLocation, Maybe (PackageConfig,Bool))
-- remove all the home modules from the cache; package modules are
-- assumed to not move around during a session.
flushFinderCache :: IO ()
flushFinderCache = do
flushFinderCache :: IORef FinderCache -> IO ()
flushFinderCache finder_cache = do
fm <- readIORef finder_cache
writeIORef finder_cache (filterUFM (\(loc,m) -> isNothing m) fm)
writeIORef finder_cache $! filterUFM (\(loc,m) -> isNothing m) fm
addToFinderCache :: Module -> FinderCacheEntry -> IO ()
addToFinderCache mod_name entry = do
addToFinderCache :: IORef FinderCache -> Module -> FinderCacheEntry -> IO ()
addToFinderCache finder_cache mod_name entry = do
fm <- readIORef finder_cache
writeIORef finder_cache (extendModuleEnv fm mod_name entry)
writeIORef finder_cache $! extendModuleEnv fm mod_name entry
lookupFinderCache :: Module -> IO (Maybe FinderCacheEntry)
lookupFinderCache mod_name = do
lookupFinderCache :: IORef FinderCache -> Module -> IO (Maybe FinderCacheEntry)
lookupFinderCache finder_cache mod_name = do
fm <- readIORef finder_cache
return $! lookupModuleEnv fm mod_name
......@@ -108,19 +104,20 @@ type LocalFindResult = MaybeErr [FilePath] FinderCacheEntry
cached :: Bool
-> (DynFlags -> Module -> IO LocalFindResult)
-> DynFlags -> Module -> Bool -> IO FindResult
cached home_allowed wrapped_fn dflags name explicit
-> HscEnv -> Module -> Bool -> IO FindResult
cached home_allowed wrapped_fn hsc_env name explicit
= do { -- First try the cache
mb_entry <- lookupFinderCache name
let cache = hsc_FC hsc_env
; mb_entry <- lookupFinderCache cache name
; case mb_entry of {
Just old_entry -> return (found old_entry) ;
Nothing -> do
{ -- Now try the wrapped function
mb_entry <- wrapped_fn dflags name
mb_entry <- wrapped_fn (hsc_dflags hsc_env) name
; case mb_entry of
Failed paths -> return (NotFound paths)
Succeeded new_entry -> do { addToFinderCache name new_entry
Succeeded new_entry -> do { addToFinderCache cache name new_entry
; return (found new_entry) }
}}}
where
......@@ -137,18 +134,19 @@ cached home_allowed wrapped_fn dflags name explicit
where
pkg_name = packageConfigId pkg
addHomeModuleToFinder :: Module -> ModLocation -> IO ()
addHomeModuleToFinder mod loc = addToFinderCache mod (loc, Nothing)
addHomeModuleToFinder :: HscEnv -> Module -> ModLocation -> IO ()
addHomeModuleToFinder hsc_env mod loc
= addToFinderCache (hsc_FC hsc_env) mod (loc, Nothing)
-- -----------------------------------------------------------------------------
-- The two external entry points
findModule :: DynFlags -> Module -> Bool -> IO FindResult
findModule :: HscEnv -> Module -> Bool -> IO FindResult
findModule = cached True findModule'
findPackageModule :: DynFlags -> Module -> Bool -> IO FindResult
findPackageModule :: HscEnv -> Module -> Bool -> IO FindResult
findPackageModule = cached False findPackageModule'
-- -----------------------------------------------------------------------------
......
This diff is collapsed.
......@@ -42,6 +42,7 @@ import BasicTypes ( Fixity )
import SrcLoc ( SrcLoc, noSrcLoc )
#endif
import Module ( emptyModuleEnv )
import RdrName ( RdrName )
import HsSyn ( HsModule )
import SrcLoc ( Located(..) )
......@@ -104,10 +105,15 @@ newHscEnv dflags
= do { eps_var <- newIORef initExternalPackageState
; us <- mkSplitUniqSupply 'r'
; nc_var <- newIORef (initNameCache us knownKeyNames)
; fc_var <- newIORef emptyModuleEnv
; return (HscEnv { hsc_dflags = dflags,
hsc_targets = [],
hsc_mod_graph = [],
hsc_IC = emptyInteractiveContext,
hsc_HPT = emptyHomePackageTable,
hsc_EPS = eps_var,
hsc_NC = nc_var } ) }
hsc_NC = nc_var,
hsc_FC = fc_var } ) }
knownKeyNames :: [Name] -- Put here to avoid loops involving DsMeta,
......@@ -590,11 +596,10 @@ A naked expression returns a singleton Name [it].
#ifdef GHCI
hscStmt -- Compile a stmt all the way to an HValue, but don't run it
:: HscEnv
-> InteractiveContext -- Context for compiling
-> String -- The statement
-> IO (Maybe (InteractiveContext, [Name], HValue))
-> IO (Maybe (HscEnv, [Name], HValue))
hscStmt hsc_env icontext stmt
hscStmt hsc_env stmt
= do { maybe_stmt <- hscParseStmt (hsc_dflags hsc_env) stmt
; case maybe_stmt of {
Nothing -> return Nothing ; -- Parse error
......@@ -602,8 +607,8 @@ hscStmt hsc_env icontext stmt
Just (Just parsed_stmt) -> do { -- The real stuff
-- Rename and typecheck it
maybe_tc_result
<- tcRnStmt hsc_env icontext parsed_stmt
let icontext = hsc_IC hsc_env
; maybe_tc_result <- tcRnStmt hsc_env icontext parsed_stmt
; case maybe_tc_result of {
Nothing -> return Nothing ;
......@@ -615,17 +620,17 @@ hscStmt hsc_env icontext stmt