X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fghci%2FInteractiveUI.hs;h=f8ee7bf1b8d5a4ec7fb65566e983fc37fd4ab2a1;hb=e68a5b608d7ac55f133481d9e428119850668e7a;hp=0bf37dc4005e408893fc4663c9dc5d34b22a9528;hpb=8d180b0dd5b3796c96b162464b93ab1cacc3b789;p=ghc-hetmet.git diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index 0bf37dc..f8ee7bf 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -16,19 +16,23 @@ module InteractiveUI ( -- The GHC interface import qualified GHC import GHC ( Session, verbosity, dopt, DynFlag(..), Target(..), - TargetId(..), - mkModule, pprModule, Type, Module, SuccessFlag(..), + 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 ) @@ -74,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) ) @@ -91,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) @@ -138,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