X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fghci%2FInteractiveUI.hs;h=c5edfa6c40c97d1049b26d4e5a229717f72b5918;hb=521fcf58f8b10e2bd0299f823ef8919e63d0ed28;hp=2e02c006335782f9ddb581b2bc2e603d29659e61;hpb=2f6a66ee1b53d093c8bbfe6534598719e4d4647f;p=ghc-hetmet.git diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index 2e02c00..c5edfa6 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -15,21 +15,27 @@ module InteractiveUI ( -- The GHC interface import qualified GHC -import GHC ( Session, verbosity, dopt, DynFlag(..), - mkModule, pprModule, Type, Module, SuccessFlag(..), +import GHC ( Session, verbosity, dopt, DynFlag(..), Target(..), + TargetId(..), DynFlags(..), + pprModule, Type, Module, SuccessFlag(..), TyThing(..), Name, LoadHowMuch(..), Phase, GhcException(..), showGhcException, CheckedModule(..), SrcLoc ) +import DynFlags ( allFlags ) +import Packages ( PackageState(..) ) +import PackageConfig ( InstalledPackageInfo(..) ) +import UniqFM ( eltsUFM ) import PprTyThing import Outputable -- for createtags (should these come via GHC?) -import Module( moduleUserString ) -import Name( nameSrcLoc, nameModule, nameOccName ) -import OccName( pprOccName ) -import SrcLoc( isGoodSrcLoc, srcLocFile, srcLocLine, srcLocCol ) +import Module ( moduleString ) +import Name ( nameSrcLoc, nameModule, nameOccName ) +import OccName ( pprOccName ) +import SrcLoc ( isGoodSrcLoc, srcLocFile, srcLocLine, srcLocCol ) -- Other random utilities +import Digraph ( flattenSCCs ) import BasicTypes ( failed, successIf ) import Panic ( panic, installSignalHandlers ) import Config @@ -37,7 +43,6 @@ import StaticFlags ( opt_IgnoreDotGhci ) import Linker ( showLinkerState ) import Util ( removeSpaces, handle, global, toArgs, looksLikeModuleName, prefixMatch, sortLe ) -import ErrUtils ( printErrorsAndWarnings ) #ifndef mingw32_HOST_OS import System.Posix @@ -73,6 +78,7 @@ import System.IO.Error as IO import Data.Char import Control.Monad as Monad import Foreign.StablePtr ( newStablePtr ) +import Text.Printf import GHC.Exts ( unsafeCoerce# ) import GHC.IOBase ( IOErrorType(InvalidArgument) ) @@ -90,30 +96,34 @@ ghciWelcomeMsg = "/ /_\\\\/ __ / /___| | http://www.haskell.org/ghc/\n"++ "\\____/\\/ /_/\\____/|_| Type :? for help.\n" -GLOBAL_VAR(commands, builtin_commands, [(String, String -> GHCi Bool)]) +type Command = (String, String -> GHCi Bool, Bool, String -> IO [String]) +cmdName (n,_,_,_) = n -builtin_commands :: [(String, String -> GHCi Bool)] +GLOBAL_VAR(commands, builtin_commands, [Command]) + +builtin_commands :: [Command] builtin_commands = [ - ("add", keepGoingPaths addModule), - ("browse", keepGoing browseCmd), - ("cd", keepGoing changeDirectory), - ("def", keepGoing defineMacro), - ("help", keepGoing help), - ("?", keepGoing help), - ("info", keepGoing info), - ("load", keepGoingPaths loadModule_), - ("module", keepGoing setContext), - ("reload", keepGoing reloadModule), - ("check", keepGoing checkModule), - ("set", keepGoing setCmd), - ("show", keepGoing showCmd), - ("etags", keepGoing createETagsFileCmd), - ("ctags", keepGoing createCTagsFileCmd), - ("type", keepGoing typeOfExpr), - ("kind", keepGoing kindOfType), - ("unset", keepGoing unsetOptions), - ("undef", keepGoing undefineMacro), - ("quit", quit) + ("add", keepGoingPaths addModule, False, completeFilename), + ("browse", keepGoing browseCmd, False, completeModule), + ("cd", keepGoing changeDirectory, False, completeFilename), + ("def", keepGoing defineMacro, False, completeIdentifier), + ("help", keepGoing help, False, completeNone), + ("?", keepGoing help, False, completeNone), + ("info", keepGoing info, False, completeIdentifier), + ("load", keepGoingPaths loadModule_, False, completeHomeModuleOrFile), + ("module", keepGoing setContext, False, completeModule), + ("main", keepGoing runMain, False, completeIdentifier), + ("reload", keepGoing reloadModule, False, completeNone), + ("check", keepGoing checkModule, False, completeHomeModule), + ("set", keepGoing setCmd, True, completeSetOptions), + ("show", keepGoing showCmd, False, completeNone), + ("etags", keepGoing createETagsFileCmd, False, completeFilename), + ("ctags", keepGoing createCTagsFileCmd, False, completeFilename), + ("type", keepGoing typeOfExpr, False, completeIdentifier), + ("kind", keepGoing kindOfType, False, completeIdentifier), + ("unset", keepGoing unsetOptions, True, completeSetOptions), + ("undef", keepGoing undefineMacro, False, completeMacro), + ("quit", quit, False, completeNone) ] keepGoing :: (String -> GHCi ()) -> (String -> GHCi Bool) @@ -137,6 +147,7 @@ helpText = " :info [ ...] display information about the given names\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" ++ " :reload reload the current module set\n" ++ "\n" ++ " :set