compiler: Write .o files atomically. See #14533
[ghc.git] / compiler / main / InteractiveEvalTypes.hs
1 -- -----------------------------------------------------------------------------
2 --
3 -- (c) The University of Glasgow, 2005-2007
4 --
5 -- Running statements interactively
6 --
7 -- -----------------------------------------------------------------------------
8
9 module InteractiveEvalTypes (
10 Resume(..), History(..), ExecResult(..),
11 SingleStep(..), isStep, ExecOptions(..),
12 BreakInfo(..)
13 ) where
14
15 import GhcPrelude
16
17 import GHCi.RemoteTypes
18 import GHCi.Message (EvalExpr, ResumeContext)
19 import Id
20 import Name
21 import Module
22 import RdrName
23 import Type
24 import SrcLoc
25 import Exception
26
27 import Data.Word
28 import GHC.Stack.CCS
29
30 data ExecOptions
31 = ExecOptions
32 { execSingleStep :: SingleStep -- ^ stepping mode
33 , execSourceFile :: String -- ^ filename (for errors)
34 , execLineNumber :: Int -- ^ line number (for errors)
35 , execWrap :: ForeignHValue -> EvalExpr ForeignHValue
36 }
37
38 data SingleStep
39 = RunToCompletion
40 | SingleStep
41 | RunAndLogSteps
42
43 isStep :: SingleStep -> Bool
44 isStep RunToCompletion = False
45 isStep _ = True
46
47 data ExecResult
48 = ExecComplete
49 { execResult :: Either SomeException [Name]
50 , execAllocation :: Word64
51 }
52 | ExecBreak
53 { breakNames :: [Name]
54 , breakInfo :: Maybe BreakInfo
55 }
56
57 data BreakInfo = BreakInfo
58 { breakInfo_module :: Module
59 , breakInfo_number :: Int
60 }
61
62 data Resume = Resume
63 { resumeStmt :: String -- the original statement
64 , resumeContext :: ForeignRef (ResumeContext [HValueRef])
65 , resumeBindings :: ([TyThing], GlobalRdrEnv)
66 , resumeFinalIds :: [Id] -- [Id] to bind on completion
67 , resumeApStack :: ForeignHValue -- The object from which we can get
68 -- value of the free variables.
69 , resumeBreakInfo :: Maybe BreakInfo
70 -- the breakpoint we stopped at
71 -- (module, index)
72 -- (Nothing <=> exception)
73 , resumeSpan :: SrcSpan -- just a copy of the SrcSpan
74 -- from the ModBreaks,
75 -- otherwise it's a pain to
76 -- fetch the ModDetails &
77 -- ModBreaks to get this.
78 , resumeDecl :: String -- ditto
79 , resumeCCS :: RemotePtr CostCentreStack
80 , resumeHistory :: [History]
81 , resumeHistoryIx :: Int -- 0 <==> at the top of the history
82 }
83
84 data History
85 = History {
86 historyApStack :: ForeignHValue,
87 historyBreakInfo :: BreakInfo,
88 historyEnclosingDecls :: [String] -- declarations enclosing the breakpoint
89 }