#include "HsVersions.h"
-import GhciMonad
+import qualified GhciMonad
+import GhciMonad hiding (runStmt)
import GhciTags
import Debugger
-- The GHC interface
-import qualified GHC
+import qualified GHC hiding (resume, runStmt)
import GHC ( Session, LoadHowMuch(..), Target(..), TargetId(..),
Module, ModuleName, TyThing(..), Phase,
BreakIndex, SrcSpan, Resume, SingleStep )
cmdName :: Command -> String
cmdName (n,_,_,_) = n
-macros_ref :: IORef [Command]
GLOBAL_VAR(macros_ref, [], [Command])
builtin_commands :: [Command]
when is_tty $ do
Readline.initialize
- -- XXX Should we be catching exceptions thrown by readHistory?
withGhcAppData
(\dir -> Readline.readHistory (dir </> "ghci_history"))
- (return ())
+ (return True)
Readline.setAttemptedCompletionFunction (Just completeWord)
--Readline.parseAndBind "set show-all-if-ambiguous 1"
default_editor <- findEditor
+ cwd <- getCurrentDirectory
+
startGHCi (runGHCi srcs maybe_exprs)
GHCiState{ progname = "<interactive>",
args = [],
tickarrays = emptyModuleEnv,
last_command = Nothing,
cmdqueue = [],
- remembered_ctx = []
+ remembered_ctx = [],
+ virtual_path = cwd
}
#ifdef USE_EDITLINE
Readline.stifleHistory 100
- -- XXX Should we be catching exceptions thrown by readHistory?
withGhcAppData (\dir -> Readline.writeHistory (dir </> "ghci_history"))
- (return ())
+ (return True)
Readline.resetTerminal Nothing
#endif
| null (filter (not.isSpace) stmt) = return False
| ["import", mod] <- words stmt = keepGoing setContext ('+':mod)
| otherwise
- = do st <- getGHCiState
- session <- getSession
- result <- io $ withProgName (progname st) $ withArgs (args st) $
- GHC.runStmt session stmt step
+ = do result <- GhciMonad.runStmt stmt step
afterRunStmt (const True) result
-
--afterRunStmt :: GHC.RunResult -> GHCi Bool
-- False <=> the statement failed to compile
afterRunStmt :: (SrcSpan -> Bool) -> GHC.RunResult -> GHCi Bool
st <- getGHCiState
enqueueCommands [stop st]
return ()
- | otherwise -> io(GHC.resume session GHC.SingleStep) >>=
+ | otherwise -> resume GHC.SingleStep >>=
afterRunStmt step_here >> return ()
_ -> return ()
-- doContinue :: SingleStep -> GHCi ()
doContinue :: (SrcSpan -> Bool) -> SingleStep -> GHCi ()
doContinue pred step = do
- session <- getSession
- runResult <- io $ GHC.resume session step
+ runResult <- resume step
afterRunStmt pred runResult
return ()