{-# LANGUAGE CPP, RankNTypes, TypeFamilies #-}
module GHC.Driver.Hooks
( Hooks
, HasHooks (..)
, ContainsHooks (..)
, emptyHooks
, DsForeignsHook
, dsForeignsHook
, tcForeignImportsHook
, tcForeignExportsHook
, hscFrontendHook
, hscCompileCoreExprHook
, ghcPrimIfaceHook
, runPhaseHook
, runMetaHook
, linkHook
, runRnSpliceHook
, getValueSafelyHook
, createIservProcessHook
, stgToCmmHook
, cmmToRawCmmHook
)
where
import GHC.Prelude
import GHC.Driver.Env
import GHC.Driver.Session
import GHC.Driver.Pipeline.Monad
import GHC.Hs.Decls
import GHC.Hs.Binds
import GHC.Hs.Expr
import GHC.Hs.Extension
import GHC.Types.Name.Reader
import GHC.Types.Name
import GHC.Types.Id
import GHC.Types.SrcLoc
import GHC.Types.Basic
import GHC.Types.CostCentre
import GHC.Types.IPE
import GHC.Types.Meta
import GHC.Types.HpcInfo
import GHC.Types.ForeignStubs
import GHC.Unit.Module
import GHC.Unit.Module.ModSummary
import GHC.Unit.Module.ModIface
import GHC.Unit.Home.ModInfo
import GHC.Core
import GHC.Core.TyCon
import GHC.Core.Type
import GHC.Tc.Types
import GHC.Stg.Syntax
import GHC.StgToCmm.Types (ModuleLFInfos)
import GHC.Cmm
import GHCi.RemoteTypes
import GHC.Data.Stream
import GHC.Data.Bag
import qualified Data.Kind
import System.Process
emptyHooks :: Hooks
emptyHooks :: Hooks
emptyHooks = Hooks :: Maybe DsForeignsHook
-> Maybe
([LForeignDecl GhcRn]
-> TcM ([Id], [LForeignDecl GhcTc], Bag GlobalRdrElt))
-> Maybe
([LForeignDecl GhcRn]
-> TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt))
-> Maybe (ModSummary -> Hsc FrontendResult)
-> Maybe (HscEnv -> SrcSpan -> CoreExpr -> IO ForeignHValue)
-> Maybe ModIface
-> Maybe
(PhasePlus -> FilePath -> CompPipeline (PhasePlus, FilePath))
-> Maybe (MetaHook TcM)
-> Maybe
(GhcLink -> DynFlags -> Bool -> HomePackageTable -> IO SuccessFlag)
-> Maybe (HsSplice GhcRn -> RnM (HsSplice GhcRn))
-> Maybe (HscEnv -> Name -> Type -> IO (Maybe HValue))
-> Maybe (CreateProcess -> IO ProcessHandle)
-> Maybe
(DynFlags
-> Module
-> InfoTableProvMap
-> [TyCon]
-> CollectedCCs
-> [CgStgTopBinding]
-> HpcInfo
-> Stream IO CmmGroup (CStub, ModuleLFInfos))
-> (forall a.
Maybe
(DynFlags
-> Maybe Module
-> Stream IO CmmGroupSRTs a
-> IO (Stream IO RawCmmGroup a)))
-> Hooks
Hooks
{ dsForeignsHook :: Maybe DsForeignsHook
dsForeignsHook = Maybe DsForeignsHook
forall a. Maybe a
Nothing
, tcForeignImportsHook :: Maybe
([LForeignDecl GhcRn]
-> TcM ([Id], [LForeignDecl GhcTc], Bag GlobalRdrElt))
tcForeignImportsHook = Maybe
([LForeignDecl GhcRn]
-> TcM ([Id], [LForeignDecl GhcTc], Bag GlobalRdrElt))
forall a. Maybe a
Nothing
, tcForeignExportsHook :: Maybe
([LForeignDecl GhcRn]
-> TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt))
tcForeignExportsHook = Maybe
([LForeignDecl GhcRn]
-> TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt))
forall a. Maybe a
Nothing
, hscFrontendHook :: Maybe (ModSummary -> Hsc FrontendResult)
hscFrontendHook = Maybe (ModSummary -> Hsc FrontendResult)
forall a. Maybe a
Nothing
, hscCompileCoreExprHook :: Maybe (HscEnv -> SrcSpan -> CoreExpr -> IO ForeignHValue)
hscCompileCoreExprHook = Maybe (HscEnv -> SrcSpan -> CoreExpr -> IO ForeignHValue)
forall a. Maybe a
Nothing
, ghcPrimIfaceHook :: Maybe ModIface
ghcPrimIfaceHook = Maybe ModIface
forall a. Maybe a
Nothing
, runPhaseHook :: Maybe (PhasePlus -> FilePath -> CompPipeline (PhasePlus, FilePath))
runPhaseHook = Maybe (PhasePlus -> FilePath -> CompPipeline (PhasePlus, FilePath))
forall a. Maybe a
Nothing
, runMetaHook :: Maybe (MetaHook TcM)
runMetaHook = Maybe (MetaHook TcM)
forall a. Maybe a
Nothing
, linkHook :: Maybe
(GhcLink -> DynFlags -> Bool -> HomePackageTable -> IO SuccessFlag)
linkHook = Maybe
(GhcLink -> DynFlags -> Bool -> HomePackageTable -> IO SuccessFlag)
forall a. Maybe a
Nothing
, runRnSpliceHook :: Maybe (HsSplice GhcRn -> RnM (HsSplice GhcRn))
runRnSpliceHook = Maybe (HsSplice GhcRn -> RnM (HsSplice GhcRn))
forall a. Maybe a
Nothing
, getValueSafelyHook :: Maybe (HscEnv -> Name -> Type -> IO (Maybe HValue))
getValueSafelyHook = Maybe (HscEnv -> Name -> Type -> IO (Maybe HValue))
forall a. Maybe a
Nothing
, createIservProcessHook :: Maybe (CreateProcess -> IO ProcessHandle)
createIservProcessHook = Maybe (CreateProcess -> IO ProcessHandle)
forall a. Maybe a
Nothing
, stgToCmmHook :: Maybe
(DynFlags
-> Module
-> InfoTableProvMap
-> [TyCon]
-> CollectedCCs
-> [CgStgTopBinding]
-> HpcInfo
-> Stream IO CmmGroup (CStub, ModuleLFInfos))
stgToCmmHook = Maybe
(DynFlags
-> Module
-> InfoTableProvMap
-> [TyCon]
-> CollectedCCs
-> [CgStgTopBinding]
-> HpcInfo
-> Stream IO CmmGroup (CStub, ModuleLFInfos))
forall a. Maybe a
Nothing
, cmmToRawCmmHook :: forall a.
Maybe
(DynFlags
-> Maybe Module
-> Stream IO CmmGroupSRTs a
-> IO (Stream IO RawCmmGroup a))
cmmToRawCmmHook = forall a. Maybe a
forall a.
Maybe
(DynFlags
-> Maybe Module
-> Stream IO CmmGroupSRTs a
-> IO (Stream IO RawCmmGroup a))
Nothing
}
type family DsForeignsHook :: Data.Kind.Type
data Hooks = Hooks
{ Hooks -> Maybe DsForeignsHook
dsForeignsHook :: !(Maybe DsForeignsHook)
, Hooks
-> Maybe
([LForeignDecl GhcRn]
-> TcM ([Id], [LForeignDecl GhcTc], Bag GlobalRdrElt))
tcForeignImportsHook :: !(Maybe ([LForeignDecl GhcRn]
-> TcM ([Id], [LForeignDecl GhcTc], Bag GlobalRdrElt)))
, Hooks
-> Maybe
([LForeignDecl GhcRn]
-> TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt))
tcForeignExportsHook :: !(Maybe ([LForeignDecl GhcRn]
-> TcM (LHsBinds GhcTc, [LForeignDecl GhcTc], Bag GlobalRdrElt)))
, Hooks -> Maybe (ModSummary -> Hsc FrontendResult)
hscFrontendHook :: !(Maybe (ModSummary -> Hsc FrontendResult))
, Hooks -> Maybe (HscEnv -> SrcSpan -> CoreExpr -> IO ForeignHValue)
hscCompileCoreExprHook ::
!(Maybe (HscEnv -> SrcSpan -> CoreExpr -> IO ForeignHValue))
, Hooks -> Maybe ModIface
ghcPrimIfaceHook :: !(Maybe ModIface)
, Hooks
-> Maybe
(PhasePlus -> FilePath -> CompPipeline (PhasePlus, FilePath))
runPhaseHook :: !(Maybe (PhasePlus -> FilePath -> CompPipeline (PhasePlus, FilePath)))
, Hooks -> Maybe (MetaHook TcM)
runMetaHook :: !(Maybe (MetaHook TcM))
, Hooks
-> Maybe
(GhcLink -> DynFlags -> Bool -> HomePackageTable -> IO SuccessFlag)
linkHook :: !(Maybe (GhcLink -> DynFlags -> Bool
-> HomePackageTable -> IO SuccessFlag))
, Hooks -> Maybe (HsSplice GhcRn -> RnM (HsSplice GhcRn))
runRnSpliceHook :: !(Maybe (HsSplice GhcRn -> RnM (HsSplice GhcRn)))
, Hooks -> Maybe (HscEnv -> Name -> Type -> IO (Maybe HValue))
getValueSafelyHook :: !(Maybe (HscEnv -> Name -> Type
-> IO (Maybe HValue)))
, Hooks -> Maybe (CreateProcess -> IO ProcessHandle)
createIservProcessHook :: !(Maybe (CreateProcess -> IO ProcessHandle))
, Hooks
-> Maybe
(DynFlags
-> Module
-> InfoTableProvMap
-> [TyCon]
-> CollectedCCs
-> [CgStgTopBinding]
-> HpcInfo
-> Stream IO CmmGroup (CStub, ModuleLFInfos))
stgToCmmHook :: !(Maybe (DynFlags -> Module -> InfoTableProvMap -> [TyCon] -> CollectedCCs
-> [CgStgTopBinding] -> HpcInfo -> Stream IO CmmGroup (CStub, ModuleLFInfos)))
, Hooks
-> forall a.
Maybe
(DynFlags
-> Maybe Module
-> Stream IO CmmGroupSRTs a
-> IO (Stream IO RawCmmGroup a))
cmmToRawCmmHook :: !(forall a . Maybe (DynFlags -> Maybe Module -> Stream IO CmmGroupSRTs a
-> IO (Stream IO RawCmmGroup a)))
}
class HasHooks m where
getHooks :: m Hooks
class ContainsHooks a where
:: a -> Hooks