Adding a {-# GENERATED "SourceFile" SourceSpan #-} <expr> pragma.
This will be used to generate coverage for tool generated (or quoted) code.
The pragma states the the expression was generated/quoted from the stated
source file and source span.
import PrimOp
import BasicTypes ( RecFlag(..), Activation(NeverActive), Boxity(..) )
import Data.List ( isSuffixOf )
+import FastString ( unpackFS )
import System.Time (ClockTime(..))
import System.Directory (getModificationTime)
liftM2 ArithSeq
(return ty)
(addTickArithSeqInfo arith_seq)
+addTickHsExpr (HsTickPragma (file,(l1,c1),(l2,c2)) (L pos e0)) = do
+ e1 <- addTickHsExpr e0
+ fn <- allocTickBox (ExternalBox (unpackFS file) (P l1 c1 l2 c2)) pos
+ let (L _ e2) = fn $ L pos e1
+ return $ e2
addTickHsExpr (PArrSeq {}) = error "addTickHsExpr: PArrSeq "
addTickHsExpr (HsSCC {}) = error "addTickHsExpr: HsSCC "
addTickHsExpr (HsCoreAnn {}) = error "addTickHsExpr: HsCoreAnn "
| AltBox
| TopLevelBox [String]
| LocalBox [String]
- -- | UserBox (Maybe String)
| GuardBinBox Bool
| CondBinBox Bool
| QualBinBox Bool
- -- | PreludeBinBox String Bool
- -- | UserBinBox (Maybe String) Bool
+ | ExternalBox String HpcPos
+ -- ^The position was generated from the named file/module,
+ -- with the stated position (inside the named file/module).
+ -- The HpcPos inside this MixEntry refers to the generated Haskell location.
deriving (Read, Show)
mixCreate :: String -> String -> Mix -> IO ()
repE e@(PArrSeq {}) = notHandled "Parallel arrays" (ppr e)
repE e@(HsCoreAnn {}) = notHandled "Core annotations" (ppr e)
repE e@(HsSCC {}) = notHandled "Cost centres" (ppr e)
+repE e@(HsTickPragma {}) = notHandled "Tick Pragma" (ppr e)
repE e@(HsBracketOut {}) = notHandled "TH brackets" (ppr e)
repE e = notHandled "Expression form" (ppr e)
Int -- module-local tick number for False
(LHsExpr id) -- sub-expression
+ | HsTickPragma -- A pragma introduced tick
+ (FastString,(Int,Int),(Int,Int)) -- external span for this tick
+ (LHsExpr id)
+
---------------------------------------
-- The following are commands, not expressions proper
ppr tickIdFalse,
ptext SLIT(">("),
ppr exp,ptext SLIT(")")]
+ppr_expr (HsTickPragma externalSrcLoc exp)
+ = hcat [ptext SLIT("tickpragma<"), ppr externalSrcLoc,ptext SLIT(">("), ppr exp,ptext SLIT(")")]
ppr_expr (HsArrApp arrow arg _ HsFirstOrderApp True)
= hsep [ppr_lexpr arrow, ptext SLIT("-<"), ppr_lexpr arg]
"{-#" $whitechar* (DEPRECATED|deprecated)
{ token ITdeprecated_prag }
"{-#" $whitechar* (SCC|scc) { token ITscc_prag }
+ "{-#" $whitechar* (GENERATED|generated)
+ { token ITgenerated_prag }
"{-#" $whitechar* (CORE|core) { token ITcore_prag }
"{-#" $whitechar* (UNPACK|unpack) { token ITunpack_prag }
| ITdeprecated_prag
| ITline_prag
| ITscc_prag
+ | ITgenerated_prag
| ITcore_prag -- hdaume: core annotations
| ITunpack_prag
| ITclose_prag
SrcSpan, combineLocs, srcLocFile,
mkSrcLoc, mkSrcSpan )
import Module
-import StaticFlags ( opt_SccProfilingOn )
+import StaticFlags ( opt_SccProfilingOn, opt_Hpc )
import Type ( Kind, mkArrowKind, liftedTypeKind, unliftedTypeKind )
import BasicTypes ( Boxity(..), Fixity(..), FixityDirection(..), IPName(..),
Activation(..), defaultInlineSpec )
'{-# RULES' { L _ ITrules_prag }
'{-# CORE' { L _ ITcore_prag } -- hdaume: annotated core
'{-# SCC' { L _ ITscc_prag }
+ '{-# GENERATED' { L _ ITgenerated_prag }
'{-# DEPRECATED' { L _ ITdeprecated_prag }
'{-# UNPACK' { L _ ITunpack_prag }
'#-}' { L _ ITclose_prag }
| scc_annot exp { LL $ if opt_SccProfilingOn
then HsSCC (unLoc $1) $2
else HsPar $2 }
+ | hpc_annot exp { LL $ if opt_Hpc
+ then HsTickPragma (unLoc $1) $2
+ else HsPar $2 }
| 'proc' aexp '->' exp
{% checkPattern $2 >>= \ p ->
: '_scc_' STRING { LL $ getSTRING $2 }
| '{-# SCC' STRING '#-}' { LL $ getSTRING $2 }
+hpc_annot :: { Located (FastString,(Int,Int),(Int,Int)) }
+ : '{-# GENERATED' STRING INTEGER ':' INTEGER '-' INTEGER ':' INTEGER '#-}'
+ { LL $ (getSTRING $2
+ ,( fromInteger $ getINTEGER $3
+ , fromInteger $ getINTEGER $5
+ )
+ ,( fromInteger $ getINTEGER $7
+ , fromInteger $ getINTEGER $9
+ )
+ )
+ }
+
fexp :: { LHsExpr RdrName }
: fexp aexp { LL $ HsApp $1 $2 }
| aexp { $1 }
rnExpr (HsSCC lbl expr)
= rnLExpr expr `thenM` \ (expr', fvs_expr) ->
returnM (HsSCC lbl expr', fvs_expr)
+rnExpr (HsTickPragma info expr)
+ = rnLExpr expr `thenM` \ (expr', fvs_expr) ->
+ returnM (HsTickPragma info expr', fvs_expr)
rnExpr (HsLam matches)
= rnMatchGroup LambdaExpr matches `thenM` \ (matches', fvMatch) ->
tcExpr (HsSCC lbl expr) res_ty = do { expr' <- tcMonoExpr expr res_ty
; returnM (HsSCC lbl expr') }
+tcExpr (HsTickPragma info expr) res_ty
+ = do { expr' <- tcMonoExpr expr res_ty
+ ; returnM (HsTickPragma info expr') }
tcExpr (HsCoreAnn lbl expr) res_ty -- hdaume: core annotation
= do { expr' <- tcMonoExpr expr res_ty
= zonkLExpr env expr `thenM` \ new_expr ->
returnM (HsSCC lbl new_expr)
+zonkExpr env (HsTickPragma info expr)
+ = zonkLExpr env expr `thenM` \ new_expr ->
+ returnM (HsTickPragma info new_expr)
+
-- hdaume: core annotations
zonkExpr env (HsCoreAnn lbl expr)
= zonkLExpr env expr `thenM` \ new_expr ->