X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fghci%2FInteractiveUI.hs;h=4494f229e22661d45a5ba619d3b9c03077cb6906;hp=ddd6a139e37f5749f8a0a171a3eb83f63c3f542b;hb=6a13ee14f604f5ab0178b326c24590402ee66615;hpb=0855975c5e81b1ef9a7871a436af3f34c55dfd87 diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs index ddd6a13..4494f22 100644 --- a/compiler/ghci/InteractiveUI.hs +++ b/compiler/ghci/InteractiveUI.hs @@ -6,21 +6,19 @@ -- (c) The GHC Team 2005-2006 -- ----------------------------------------------------------------------------- -module InteractiveUI ( - interactiveUI, - ghciWelcomeMsg - ) where +module InteractiveUI ( interactiveUI ) where #include "HsVersions.h" import GhciMonad +import GhciTags +import Debugger -- The GHC interface import qualified GHC import GHC ( Session, LoadHowMuch(..), Target(..), TargetId(..), Type, Module, ModuleName, TyThing(..), Phase, - BreakIndex ) -import Debugger + BreakIndex, SrcSpan, Resume, SingleStep ) import DynFlags import Packages import PackageConfig @@ -28,11 +26,7 @@ import UniqFM import PprTyThing import Outputable hiding (printForUser) import Module -- for ModuleEnv - --- for createtags import Name -import OccName -import SrcLoc -- Other random utilities import Digraph @@ -42,12 +36,10 @@ import Config import StaticFlags import Linker import Util +import FastString #ifndef mingw32_HOST_OS -import System.Posix -#if __GLASGOW_HASKELL__ > 504 - hiding (getEnv) -#endif +import System.Posix hiding (getEnv) #else import GHC.ConsoleHandler ( flushConsole ) import System.Win32 ( setConsoleCP, setConsoleOutputCP ) @@ -64,6 +56,7 @@ 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 import System.Cmd @@ -76,28 +69,28 @@ import Data.Char import Data.Dynamic import Data.Array import Control.Monad as Monad +import Text.Printf 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 - ----------------------------------------------------------------------------- ghciWelcomeMsg = " ___ ___ _\n"++ " / _ \\ /\\ /\\/ __(_)\n"++ - " / /_\\// /_/ / / | | GHC Interactive, version " ++ cProjectVersion ++ ", for Haskell 98.\n"++ - "/ /_\\\\/ __ / /___| | http://www.haskell.org/ghc/\n"++ - "\\____/\\/ /_/\\____/|_| Type :? for help.\n" + " / /_\\// /_/ / / | | GHC Interactive, version " ++ cProjectVersion ++ ", for Haskell 98.\n"++ + "/ /_\\\\/ __ / /___| | http://www.haskell.org/ghc/\n"++ + "\\____/\\/ /_/\\____/|_| Type :? for help.\n" + +ghciShortWelcomeMsg = + "GHCi, version " ++ cProjectVersion ++ + ": http://www.haskell.org/ghc/ :? for help" type Command = (String, String -> GHCi Bool, Bool, String -> IO [String]) cmdName (n,_,_,_) = n @@ -109,32 +102,39 @@ builtin_commands = [ -- Hugs users are accustomed to :e, so make sure it doesn't overlap ("?", keepGoing help, False, completeNone), ("add", keepGoingPaths addModule, False, completeFilename), - ("break", breakCmd, False, completeNone), + ("abandon", keepGoing abandonCmd, False, completeNone), + ("break", keepGoing breakCmd, False, completeIdentifier), + ("back", keepGoing backCmd, False, completeNone), ("browse", keepGoing browseCmd, False, completeModule), ("cd", keepGoing changeDirectory, False, completeFilename), ("check", keepGoing checkModule, False, completeHomeModule), - ("continue", continueCmd, False, completeNone), + ("continue", keepGoing continueCmd, False, completeNone), + ("cmd", keepGoing cmdCmd, False, completeIdentifier), ("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), - ("force", keepGoing (pprintClosureCommand False True), False, completeIdentifier), + ("force", keepGoing forceCmd, False, completeIdentifier), + ("forward", keepGoing forwardCmd, False, completeNone), ("help", keepGoing help, False, completeNone), + ("history", keepGoing historyCmd, False, completeNone), ("info", keepGoing info, False, completeIdentifier), ("kind", keepGoing kindOfType, False, completeIdentifier), - ("load", keepGoingPaths loadModule_,False, completeHomeModuleOrFile), + ("load", keepGoingPaths loadModule_, False, completeHomeModuleOrFile), + ("list", keepGoing listCmd, False, completeNone), ("module", keepGoing setContext, False, completeModule), ("main", keepGoing runMain, False, completeIdentifier), - ("print", keepGoing (pprintClosureCommand True False), False, completeIdentifier), + ("print", keepGoing printCmd, False, completeIdentifier), ("quit", quit, 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), + ("sprint", keepGoing sprintCmd, False, completeIdentifier), + ("step", keepGoing stepCmd, False, completeIdentifier), ("type", keepGoing typeOfExpr, False, completeIdentifier), + ("trace", keepGoing traceCmd, False, completeIdentifier), ("undef", keepGoing undefineMacro, False, completeMacro), ("unset", keepGoing unsetOptions, True, completeSetOptions) ] @@ -147,53 +147,77 @@ 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" ++ + " evaluate/run \n" ++ " :add ... add module(s) to the current target set\n" ++ " :browse [*] display the names defined by \n" ++ " :cd change directory to \n" ++ + " :cmd run the commands returned by ::IO String\n" ++ + " :ctags [] create tags file for Vi (default: \"tags\")\n" ++ " :def define a command :\n" ++ " :edit edit file\n" ++ " :edit edit last module\n" ++ + " :etags [] create tags file for Emacs (default: \"TAGS\")\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" ++ + " :quit exit GHCi\n" ++ " :reload reload the current module set\n" ++ + " :type show the type of \n" ++ + " :undef undefine user-defined command :\n" ++ + " :! run the shell command \n" ++ + "\n" ++ + " -- Commands for debugging:\n" ++ + "\n" ++ + " :abandon at a breakpoint, abandon current computation\n" ++ + " :back go back in the history (after :trace)\n" ++ + " :break [] [] set a breakpoint at the specified location\n" ++ + " :break set a breakpoint on the specified function\n" ++ + " :continue resume after a breakpoint\n" ++ + " :delete delete the specified breakpoint\n" ++ + " :delete * delete all breakpoints\n" ++ + " :force print , forcing unevaluated parts\n" ++ + " :forward go forward in the history (after :back)\n" ++ + " :history [] show the last items in the history (after :trace)\n" ++ + " :print [ ...] prints a value without forcing its computation\n" ++ + " :sprint [ ...] simplifed version of :print\n" ++ + " :step single-step after stopping at a breakpoint\n"++ + " :step single-step into \n"++ + " :trace trace after stopping at a breakpoint\n"++ + " :trace trace into (remembers breakpoints for :history)\n"++ + + "\n" ++ + " -- Commands for changing settings:\n" ++ "\n" ++ " :set