X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Fghci%2FInteractiveUI.hs;h=980dcd92df8cb7e618da1cb57d4ccb58a32b0017;hp=0685168e3dfa11eb3674ca41eda4fa4bfeeef798;hb=121da25a0d638bbe6c7f90525ff50b3a20949bbc;hpb=5527bc59052caeb5d03cc24a972edacb32ccd9c8 diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs index 0685168..980dcd9 100644 --- a/compiler/ghci/InteractiveUI.hs +++ b/compiler/ghci/InteractiveUI.hs @@ -3,7 +3,7 @@ -- -- GHC Interactive User Interface -- --- (c) The GHC Team 2005 +-- (c) The GHC Team 2005-2006 -- ----------------------------------------------------------------------------- module InteractiveUI ( @@ -13,53 +13,45 @@ module InteractiveUI ( #include "HsVersions.h" -#if defined(GHCI) && defined(BREAKPOINT) -import GHC.Exts ( Int(..), Ptr(..), int2Addr# ) -import Foreign.StablePtr ( deRefStablePtr, castPtrToStablePtr ) -import System.IO.Unsafe ( unsafePerformIO ) -import Var ( Id, globaliseId, idName, idType ) -import HscTypes ( Session(..), InteractiveContext(..), HscEnv(..) - , extendTypeEnvWithIds ) -import RdrName ( extendLocalRdrEnv, mkRdrUnqual, lookupLocalRdrEnv ) -import NameEnv ( delListFromNameEnv ) -import TcType ( tidyTopType ) -import qualified Id ( setIdType ) -import IdInfo ( GlobalIdDetails(..) ) -import Linker ( HValue, extendLinkEnv, withExtendedLinkEnv, - initDynLinker ) -import PrelNames ( breakpointJumpName, breakpointCondJumpName ) -#endif +import GhciMonad -- The GHC interface import qualified GHC -import GHC ( Session, dopt, DynFlag(..), Target(..), - TargetId(..), DynFlags(..), - pprModule, Type, Module, ModuleName, SuccessFlag(..), - TyThing(..), Name, LoadHowMuch(..), Phase, - GhcException(..), showGhcException, - CheckedModule(..), SrcLoc ) -import DynFlags ( allFlags ) -import Packages ( PackageState(..) ) -import PackageConfig ( InstalledPackageInfo(..) ) -import UniqFM ( eltsUFM ) +import GHC ( Session, LoadHowMuch(..), Target(..), TargetId(..), + Type, Module, ModuleName, TyThing(..), Phase ) +import DynFlags +import Packages +import PackageConfig +import UniqFM import PprTyThing import Outputable --- for createtags (should these come via GHC?) -import Name ( nameSrcLoc, nameModule, nameOccName ) -import OccName ( pprOccName ) -import SrcLoc ( isGoodSrcLoc, srcLocFile, srcLocLine, srcLocCol ) +-- for createtags +import Name +import OccName +import SrcLoc -- Other random utilities -import Digraph ( flattenSCCs ) -import BasicTypes ( failed, successIf ) -import Panic ( panic, installSignalHandlers ) +import Digraph +import BasicTypes hiding (isTopLevel) +import Panic hiding (showException) import Config -import StaticFlags ( opt_IgnoreDotGhci ) -import Linker ( showLinkerState, linkPackages ) -import Util ( removeSpaces, handle, global, toArgs, - looksLikeModuleName, prefixMatch, sortLe, - joinFileName ) +import StaticFlags +import Linker +import Util + +-- The debugger +import Breakpoints +import Debugger hiding ( addModule ) +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 @@ -80,7 +72,6 @@ import System.Console.Readline as Readline --import SystemExts import Control.Exception as Exception -import Data.Dynamic -- import Control.Concurrent import Numeric @@ -88,7 +79,6 @@ import Data.List import Data.Int ( Int64 ) import Data.Maybe ( isJust, isNothing, fromMaybe, catMaybes ) import System.Cmd -import System.CPUTime import System.Environment import System.Exit ( exitWith, ExitCode(..) ) import System.Directory @@ -121,9 +111,9 @@ GLOBAL_VAR(commands, builtin_commands, [Command]) builtin_commands :: [Command] builtin_commands = [ - ("add", keepGoingPaths addModule, False, completeFilename), + ("add", tlC$ keepGoingPaths addModule, False, completeFilename), ("browse", keepGoing browseCmd, False, completeModule), - ("cd", keepGoing changeDirectory, False, completeFilename), + ("cd", keepGoing changeDirectory, False, completeFilename), ("def", keepGoing defineMacro, False, completeIdentifier), ("e", keepGoing editFile, False, completeFilename), -- Hugs users are accustomed to :e, so make sure it doesn't overlap @@ -131,16 +121,22 @@ builtin_commands = [ ("help", keepGoing help, False, completeNone), ("?", keepGoing help, False, completeNone), ("info", keepGoing info, False, completeIdentifier), - ("load", keepGoingPaths loadModule_, False, completeHomeModuleOrFile), + ("load", tlC$ keepGoingPaths loadModule_,False, completeHomeModuleOrFile), ("module", keepGoing setContext, False, completeModule), - ("main", keepGoing runMain, False, completeIdentifier), - ("reload", keepGoing reloadModule, False, completeNone), + ("main", tlC$ keepGoing runMain, False, completeIdentifier), + ("reload", tlC$ 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), +#if defined(GHCI) + ("print", keepGoing (pprintClosureCommand True False), False, completeIdentifier), + ("sprint", keepGoing (pprintClosureCommand False False),False, completeIdentifier), + ("force", keepGoing (pprintClosureCommand False True), False, completeIdentifier), + ("breakpoint",keepGoing bkptOptions, False, completeBkpt), +#endif ("kind", keepGoing kindOfType, False, completeIdentifier), ("unset", keepGoing unsetOptions, True, completeSetOptions), ("undef", keepGoing undefineMacro, False, completeMacro), @@ -150,6 +146,14 @@ builtin_commands = [ keepGoing :: (String -> GHCi ()) -> (String -> GHCi Bool) keepGoing a str = a str >> return False +-- tlC: Top Level Command +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 @@ -161,6 +165,7 @@ helpText = "\n" ++ " evaluate/run \n" ++ " :add ... add module(s) to the current target set\n" ++ + " :breakpoint