module GHC.Types.Target
( Target(..)
, TargetId(..)
, InputFileBuffer
, pprTarget
, pprTargetId
)
where
import GHC.Prelude
import GHC.Driver.Phases ( Phase )
import GHC.Unit
import GHC.Data.StringBuffer ( StringBuffer )
import GHC.Utils.Outputable
import Data.Time
data Target
= Target {
Target -> TargetId
targetId :: !TargetId,
Target -> Bool
targetAllowObjCode :: !Bool,
Target -> UnitId
targetUnitId :: !UnitId,
Target -> Maybe (InputFileBuffer, UTCTime)
targetContents :: !(Maybe (InputFileBuffer, UTCTime))
}
data TargetId
= TargetModule !ModuleName
| TargetFile !FilePath !(Maybe Phase)
deriving TargetId -> TargetId -> Bool
(TargetId -> TargetId -> Bool)
-> (TargetId -> TargetId -> Bool) -> Eq TargetId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TargetId -> TargetId -> Bool
== :: TargetId -> TargetId -> Bool
$c/= :: TargetId -> TargetId -> Bool
/= :: TargetId -> TargetId -> Bool
Eq
type InputFileBuffer = StringBuffer
pprTarget :: Target -> SDoc
pprTarget :: Target -> SDoc
pprTarget Target { targetUnitId :: Target -> UnitId
targetUnitId = UnitId
uid, targetId :: Target -> TargetId
targetId = TargetId
id, targetAllowObjCode :: Target -> Bool
targetAllowObjCode = Bool
obj } =
(if Bool
obj then SDoc
forall doc. IsOutput doc => doc
empty else Char -> SDoc
forall doc. IsLine doc => Char -> doc
char Char
'*') SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> UnitId -> SDoc
forall a. Outputable a => a -> SDoc
ppr UnitId
uid SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
forall doc. IsLine doc => doc
colon SDoc -> SDoc -> SDoc
forall doc. IsLine doc => doc -> doc -> doc
<> TargetId -> SDoc
pprTargetId TargetId
id
instance Outputable Target where
ppr :: Target -> SDoc
ppr = Target -> SDoc
pprTarget
pprTargetId :: TargetId -> SDoc
pprTargetId :: TargetId -> SDoc
pprTargetId (TargetModule ModuleName
m) = ModuleName -> SDoc
forall a. Outputable a => a -> SDoc
ppr ModuleName
m
pprTargetId (TargetFile FilePath
f Maybe Phase
_) = FilePath -> SDoc
forall doc. IsLine doc => FilePath -> doc
text FilePath
f
instance Outputable TargetId where
ppr :: TargetId -> SDoc
ppr = TargetId -> SDoc
pprTargetId