X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fghci%2FInteractiveUI.hs;h=1ab604c6cdf76d3e7c39b322032ba7a9a6b60f94;hb=ed1f16f4bde6ffcbb953ebeea0db1bc3802d3af3;hp=b794436b952d1a96464d6cb1424e4c1e419218da;hpb=cdce647711c0f46f5799b24de087622cb77e647f;p=ghc-hetmet.git diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs index b794436..1ab604c 100644 --- a/compiler/ghci/InteractiveUI.hs +++ b/compiler/ghci/InteractiveUI.hs @@ -18,13 +18,16 @@ import GhciMonad -- The GHC interface import qualified GHC import GHC ( Session, LoadHowMuch(..), Target(..), TargetId(..), - Type, Module, ModuleName, TyThing(..), Phase ) + Type, Module, ModuleName, TyThing(..), Phase, + BreakIndex ) +import Debugger import DynFlags import Packages import PackageConfig import UniqFM import PprTyThing -import Outputable +import Outputable hiding (printForUser) +import Module -- for ModuleEnv -- for createtags import Name @@ -35,23 +38,12 @@ import SrcLoc import Digraph import BasicTypes hiding (isTopLevel) import Panic hiding (showException) +import FastString ( unpackFS ) import Config import StaticFlags import Linker import Util --- The debugger -import Debugger -import HscTypes -import Id -import Var ( globaliseId ) -import IdInfo -import NameEnv -import RdrName -import Module -import Type -import TcType - #ifndef mingw32_HOST_OS import System.Posix #if __GLASGOW_HASKELL__ > 504 @@ -73,8 +65,9 @@ import System.Console.Readline as Readline import Control.Exception as Exception -- import Control.Concurrent +import qualified Data.ByteString.Char8 as BS import Data.List -import Data.Maybe ( isJust, isNothing, fromMaybe, catMaybes ) +import Data.Maybe import System.Cmd import System.Environment import System.Exit ( exitWith, ExitCode(..) ) @@ -85,21 +78,15 @@ import Data.Char import Data.Dynamic import Data.Array import Control.Monad as Monad -import Foreign.StablePtr ( StablePtr, newStablePtr, deRefStablePtr, freeStablePtr ) +import Foreign.StablePtr ( newStablePtr ) import GHC.Exts ( unsafeCoerce# ) -import GHC.IOBase ( IOErrorType(InvalidArgument), IO(IO) ) +import GHC.IOBase ( IOErrorType(InvalidArgument) ) import Data.IORef ( IORef, readIORef, writeIORef ) import System.Posix.Internals ( setNonBlockingFD ) --- these are needed by the new ghci debugger -import ByteCodeLink (HValue) -import ByteCodeInstr (BreakInfo (..)) -import BreakArray -import TickTree - ----------------------------------------------------------------------------- ghciWelcomeMsg = @@ -118,15 +105,15 @@ builtin_commands :: [Command] builtin_commands = [ -- Hugs users are accustomed to :e, so make sure it doesn't overlap ("?", keepGoing help, False, completeNone), - ("add", tlC$ keepGoingPaths addModule, False, completeFilename), - ("break", breakCmd, False, completeNone), + ("add", keepGoingPaths addModule, False, completeFilename), + ("break", keepGoing breakCmd, False, completeIdentifier), ("browse", keepGoing browseCmd, False, completeModule), - ("cd", tlC$ keepGoing changeDirectory, False, completeFilename), + ("cd", keepGoing changeDirectory, False, completeFilename), ("check", keepGoing checkModule, False, completeHomeModule), - ("continue", continueCmd, False, completeNone), + ("continue", continueCmd, False, completeNone), ("ctags", keepGoing createCTagsFileCmd, False, completeFilename), ("def", keepGoing defineMacro, False, completeIdentifier), - ("delete", deleteCmd, False, completeNone), + ("delete", keepGoing deleteCmd, False, completeNone), ("e", keepGoing editFile, False, completeFilename), ("edit", keepGoing editFile, False, completeFilename), ("etags", keepGoing createETagsFileCmd, False, completeFilename), @@ -134,16 +121,17 @@ builtin_commands = [ ("help", keepGoing help, False, completeNone), ("info", keepGoing info, False, completeIdentifier), ("kind", keepGoing kindOfType, False, completeIdentifier), - ("load", tlC$ keepGoingPaths loadModule_,False, completeHomeModuleOrFile), + ("load", keepGoingPaths loadModule_, False, completeHomeModuleOrFile), + ("list", keepGoing listCmd, False, completeNone), ("module", keepGoing setContext, False, completeModule), - ("main", tlC$ keepGoing runMain, False, completeIdentifier), + ("main", keepGoing runMain, False, completeIdentifier), ("print", keepGoing (pprintClosureCommand True False), False, completeIdentifier), ("quit", quit, False, completeNone), - ("reload", tlC$ keepGoing reloadModule, False, completeNone), + ("reload", keepGoing reloadModule, False, completeNone), ("set", keepGoing setCmd, True, completeSetOptions), ("show", keepGoing showCmd, False, completeNone), ("sprint", keepGoing (pprintClosureCommand False False),False, completeIdentifier), - ("step", stepCmd, False, completeNone), + ("step", stepCmd, False, completeIdentifier), ("type", keepGoing typeOfExpr, False, completeIdentifier), ("undef", keepGoing undefineMacro, False, completeMacro), ("unset", keepGoing unsetOptions, True, completeSetOptions) @@ -152,37 +140,37 @@ builtin_commands = [ keepGoing :: (String -> GHCi ()) -> (String -> GHCi Bool) keepGoing a str = a str >> return False --- tlC: Top Level Command, not allowed in inferior sessions -tlC :: (String -> GHCi Bool) -> (String -> GHCi Bool) -tlC a str = do - top_level <- isTopLevel - if not top_level - then throwDyn (CmdLineError "Command only allowed at Top Level") - else a str - keepGoingPaths :: ([FilePath] -> GHCi ()) -> (String -> GHCi Bool) keepGoingPaths a str = a (toArgs str) >> return False shortHelpText = "use :? for help.\n" --- NOTE: spaces at the end of each line to workaround CPP/string gap bug. helpText = " Commands available from the prompt:\n" ++ "\n" ++ " evaluate/run \n" ++ " :add ... add module(s) to the current target set\n" ++ + " :break [] [] set a breakpoint at the specified location\n" ++ + " :break set a breakpoint on the specified function\n" ++ " :browse [*] display the names defined by \n" ++ " :cd change directory to \n" ++ + " :continue resume after a breakpoint\n" ++ + " :ctags [] create tags file for Vi (default: \"tags\")\n" ++ " :def define a command :\n" ++ + " :delete delete the specified breakpoint\n" ++ + " :delete * delete all breakpoints\n" ++ " :edit edit file\n" ++ " :edit edit last module\n" ++ + " :etags [] create tags file for Emacs (default: \"TAGS\")\n" ++ +-- " :force print , forcing unevaluated parts\n" ++ " :help, :? display this list of commands\n" ++ " :info [ ...] display information about the given names\n" ++ - " :print [ ...] prints a value without forcing its computation\n" ++ - " :sprint [ ...] simplified version of :print\n" ++ + " :kind show the kind of \n" ++ " :load ... load module(s) and their dependents\n" ++ " :module [+/-] [*] ... set the context for expression evaluation\n" ++ " :main [ ...] run the main function with the given arguments\n" ++ + " :print [ ...] prints a value without forcing its computation\n" ++ + " :quit exit GHCi\n" ++ " :reload reload the current module set\n" ++ "\n" ++ " :set