import qualified Id ( setIdType )
import IdInfo ( GlobalIdDetails(..) )
import Linker ( HValue, extendLinkEnv, withExtendedLinkEnv,initDynLinker )
-import PrelNames ( breakpointJumpName )
+import PrelNames ( breakpointJumpName, breakpointCondJumpName )
#endif
-- The GHC interface
nest 2 (pprWithCommas showId ids)
where showId id = ppr (idName id) <+> dcolon <+> ppr (idType id)
+jumpCondFunction :: Session -> Int -> [HValue] -> String -> Bool -> b -> b
+jumpCondFunction session ptr hValues location True b = b
+jumpCondFunction session ptr hValues location False b
+ = jumpFunction session ptr hValues location b
+
jumpFunction :: Session -> Int -> [HValue] -> String -> b -> b
jumpFunction session@(Session ref) (I# idsPtr) hValues location b
= unsafePerformIO $
new_ic = ictxt { ic_rn_local_env = new_rn_env,
ic_type_env = new_type_env }
writeIORef ref (hsc_env { hsc_IC = new_ic })
+ is_tty <- hIsTerminalDevice stdin
withExtendedLinkEnv (zip names hValues) $
- startGHCi (runGHCi [] Nothing)
+ startGHCi (interactiveLoop is_tty True)
GHCiState{ progname = "<interactive>",
args = [],
prompt = location++"> ",
interactiveUI session srcs maybe_expr = do
#if defined(GHCI) && defined(BREAKPOINT)
initDynLinker =<< GHC.getSessionDynFlags session
- extendLinkEnv [(breakpointJumpName,unsafeCoerce# (jumpFunction session))]
+ extendLinkEnv [(breakpointJumpName,unsafeCoerce# (jumpFunction session))
+ ,(breakpointCondJumpName,unsafeCoerce# (jumpCondFunction session))]
#endif
-- HACK! If we happen to get into an infinite loop (eg the user
-- types 'let x=x in x' at the prompt), then the thread will block
l -> do quit <- runCommand l
if quit then return () else fileLoop hdl show_prompt
-stringLoop :: [String] -> GHCi ()
-stringLoop [] = return ()
+stringLoop :: [String] -> GHCi Bool{-True: we quit-}
+stringLoop [] = return False
stringLoop (s:ss) = do
case removeSpaces s of
"" -> stringLoop ss
l -> do quit <- runCommand l
- if quit then return () else stringLoop ss
+ if quit then return True else stringLoop ss
mkPrompt toplevs exports prompt
= showSDoc $ f prompt
case maybe_hv of
Nothing -> return ()
Just hv -> io (writeIORef commands --
- (cmds ++ [(macro_name, keepGoing (runMacro hv), False, completeNone)]))
+ (cmds ++ [(macro_name, runMacro hv, False, completeNone)]))
-runMacro :: GHC.HValue{-String -> IO String-} -> String -> GHCi ()
+runMacro :: GHC.HValue{-String -> IO String-} -> String -> GHCi Bool
runMacro fun s = do
str <- io ((unsafeCoerce# fun :: String -> IO String) s)
stringLoop (lines str)
setContextAfterLoad session graph'
modulesLoadedMsg ok (map GHC.ms_mod graph')
#if defined(GHCI) && defined(BREAKPOINT)
- io (extendLinkEnv [(breakpointJumpName,unsafeCoerce# (jumpFunction session))])
+ io (extendLinkEnv [(breakpointJumpName,unsafeCoerce# (jumpFunction session))
+ ,(breakpointCondJumpName,unsafeCoerce# (jumpCondFunction session))])
#endif
setContextAfterLoad session [] = do