X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fghci%2FInteractiveUI.hs;h=c4b5f973072b3fcb22572dba1e603f7be9b0447f;hb=315a1f6c671b9800909752c702bda347198dd60a;hp=7cd720cd39540aef4fff84552d36f88240b6a902;hpb=b4ab2c414dcc719a2dc0c38b29c65624165ad1c7;p=ghc-hetmet.git diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index 7cd720c..c4b5f97 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -15,21 +15,26 @@ 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 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 +42,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 +77,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 +95,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, 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, completeFilename), + ("browse", keepGoing browseCmd, completeModule), + ("cd", keepGoing changeDirectory, completeFilename), + ("def", keepGoing defineMacro, completeIdentifier), + ("help", keepGoing help, completeNone), + ("?", keepGoing help, completeNone), + ("info", keepGoing info, completeIdentifier), + ("load", keepGoingPaths loadModule_, completeHomeModuleOrFile), + ("module", keepGoing setContext, completeModule), + ("main", keepGoing runMain, completeIdentifier), + ("reload", keepGoing reloadModule, completeNone), + ("check", keepGoing checkModule, completeHomeModule), + ("set", keepGoing setCmd, completeNone), -- ToDo + ("show", keepGoing showCmd, completeNone), + ("etags", keepGoing createETagsFileCmd, completeFilename), + ("ctags", keepGoing createCTagsFileCmd, completeFilename), + ("type", keepGoing typeOfExpr, completeIdentifier), + ("kind", keepGoing kindOfType, completeIdentifier), + ("unset", keepGoing unsetOptions, completeNone), -- ToDo + ("undef", keepGoing undefineMacro, completeNone), -- ToDo + ("quit", quit, completeNone) ] keepGoing :: (String -> GHCi ()) -> (String -> GHCi Bool) @@ -137,6 +146,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