1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
-- -----------------------------------------------------------------------------
--
-- (c) The University of Glasgow, 2005-2007
--
-- Running statements interactively
--
-- -----------------------------------------------------------------------------
module GHC.Runtime.Eval.Types (
Resume(..), ResumeBindings, IcGlobalRdrEnv(..),
History(..), ExecResult(..),
SingleStep(..), isStep, ExecOptions(..)
) where
import GHC.Prelude
import GHCi.RemoteTypes
import GHCi.Message (EvalExpr, ResumeContext)
import GHC.Types.Id
import GHC.Types.Name
import GHC.Types.TyThing
import GHC.Types.BreakInfo
import GHC.Types.Name.Reader
import GHC.Types.SrcLoc
import GHC.Utils.Exception
import Data.Word
import GHC.Stack.CCS
data ExecOptions
= ExecOptions
{ execSingleStep :: SingleStep -- ^ stepping mode
, execSourceFile :: String -- ^ filename (for errors)
, execLineNumber :: Int -- ^ line number (for errors)
, execWrap :: ForeignHValue -> EvalExpr ForeignHValue
}
data SingleStep
= RunToCompletion
| SingleStep
| RunAndLogSteps
isStep :: SingleStep -> Bool
isStep RunToCompletion = False
isStep _ = True
data ExecResult
= ExecComplete
{ execResult :: Either SomeException [Name]
, execAllocation :: Word64
}
| ExecBreak
{ breakNames :: [Name]
, breakInfo :: Maybe BreakInfo
}
-- | Essentially a GlobalRdrEnv, but with additional cached values to allow
-- efficient re-calculation when the imports change.
-- Fields are strict to avoid space leaks (see T4029)
-- All operations are in GHC.Runtime.Context.
-- See Note [icReaderEnv recalculation]
data IcGlobalRdrEnv = IcGlobalRdrEnv
{ igre_env :: !GlobalRdrEnv
-- ^ The final environment
, igre_prompt_env :: !GlobalRdrEnv
-- ^ Just the things defined at the prompt (excluding imports!)
}
data Resume = Resume
{ resumeStmt :: String -- the original statement
, resumeContext :: ForeignRef (ResumeContext [HValueRef])
, resumeBindings :: ResumeBindings
, resumeFinalIds :: [Id] -- [Id] to bind on completion
, resumeApStack :: ForeignHValue -- The object from which we can get
-- value of the free variables.
, resumeBreakInfo :: Maybe BreakInfo
-- the breakpoint we stopped at
-- (module, index)
-- (Nothing <=> exception)
, resumeSpan :: SrcSpan -- just a copy of the SrcSpan
-- from the ModBreaks,
-- otherwise it's a pain to
-- fetch the ModDetails &
-- ModBreaks to get this.
, resumeDecl :: String -- ditto
, resumeCCS :: RemotePtr CostCentreStack
, resumeHistory :: [History]
, resumeHistoryIx :: Int -- 0 <==> at the top of the history
}
type ResumeBindings = ([TyThing], IcGlobalRdrEnv)
data History
= History {
historyApStack :: ForeignHValue,
historyBreakInfo :: BreakInfo,
historyEnclosingDecls :: [String] -- declarations enclosing the breakpoint
}
|