X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FdeSugar%2FCoverage.lhs;h=af9f002723f6c1427de0b03a3fe65a9f400c77d2;hb=2423c249f5ca7785d0ec89eb33e72662da7561c1;hp=9a53b2bdfcc2480d0d7132fc39a2ff71d74d719b;hpb=d5934bbb856aa0aa620c9b2e0fa51c90a1a5a048;p=ghc-hetmet.git diff --git a/compiler/deSugar/Coverage.lhs b/compiler/deSugar/Coverage.lhs index 9a53b2b..af9f002 100644 --- a/compiler/deSugar/Coverage.lhs +++ b/compiler/deSugar/Coverage.lhs @@ -58,11 +58,23 @@ import System.Directory ( createDirectoryIfMissing ) \begin{code} addCoverageTicksToBinds dflags mod mod_loc binds = do + { let orig_file = + case ml_hs_file mod_loc of + Just file -> file + Nothing -> error "can not find the original file during hpc trans" + + ; if "boot" `isSuffixOf` orig_file then return (binds, 0) + else addCoverageTicksToBinds2 dflags mod orig_file binds + } + +addCoverageTicksToBinds2 dflags mod orig_file binds = do let main_mod = mainModIs dflags main_is = case mainFunIs dflags of Nothing -> "main" Just main -> main + modTime <- getModificationTime' orig_file + let mod_name = moduleNameString (moduleName mod) let (binds1,st) @@ -78,12 +90,6 @@ addCoverageTicksToBinds dflags mod mod_loc binds = do -- write the mix entries for this module let tabStop = 1 -- counts as a normal char in GHC's location ranges. - let orig_file = case ml_hs_file mod_loc of - Just file -> file - Nothing -> error "can not find the original file during hpc trans" - - modTime <- getModificationTime' orig_file - createDirectoryIfMissing True hpc_dir mixCreate hpc_dir mod_name (Mix orig_file modTime tabStop $ reverse $ mixEntries st) @@ -122,7 +128,7 @@ addTickLHsBind (L pos (funBind@(FunBind { fun_id = (L _ id) }))) = do let arg_count = matchGroupArity mg let (tys,res_ty) = splitFunTysN arg_count ty - return $ L pos $ funBind { fun_matches = MatchGroup ({-L pos fn_entry:-}matches') ty + return $ L pos $ funBind { fun_matches = MatchGroup matches' ty , fun_tick = tick_no } @@ -266,22 +272,30 @@ addTickHsExpr (HsWrap w e) = liftM2 HsWrap (return w) (addTickHsExpr e) -- explicitly no tick on inside -addTickHsExpr (HsArrApp {}) = error "addTickHsExpr: HsArrApp " -addTickHsExpr (HsArrForm {}) = error "addTickHsExpr: HsArrForm" +addTickHsExpr (HsArrApp e1 e2 ty1 arr_ty lr) = + liftM5 HsArrApp + (addTickLHsExpr e1) + (addTickLHsExpr e2) + (return ty1) + (return arr_ty) + (return lr) +addTickHsExpr (HsArrForm e fix cmdtop) = + liftM3 HsArrForm + (addTickLHsExpr e) + (return fix) + (mapM (liftL addTickHsCmdTop) cmdtop) + +addTickHsExpr e@(HsType ty) = return e + +-- Should never happen in expression content. addTickHsExpr (EAsPat _ _) = error "addTickHsExpr: EAsPat _ _" addTickHsExpr (ELazyPat _) = error "addTickHsExpr: ELazyPat _" addTickHsExpr (EWildPat) = error "addTickHsExpr: EWildPat" addTickHsExpr (HsBinTick _ _ _) = error "addTickhsExpr: HsBinTick _ _ _" addTickHsExpr (HsTick _ _) = error "addTickhsExpr: HsTick _ _" -addTickHsExpr e@(HsType ty) = return e - --- catch all, and give an error message. ---addTickHsExpr e = error ("addTickLhsExpr: " ++ showSDoc (ppr e)) - - addTickMatchGroup (MatchGroup matches ty) = do - let isOneOfMany = True -- AJG: for now + let isOneOfMany = matchesOneOfMany matches matches' <- mapM (liftL (addTickMatch isOneOfMany)) matches return $ MatchGroup matches' ty @@ -506,6 +520,14 @@ hpcLoc = L hpcSrcSpan \begin{code} +matchesOneOfMany :: [LMatch Id] -> Bool +matchesOneOfMany lmatches = sum (map matchCount lmatches) > 1 + where + matchCount (L _ (Match _pats _ty (GRHSs grhss _binds))) = length grhss +\end{code} + + +\begin{code} --------------------------------------------------------------- -- Datatypes and file-access routines for the per-module (.mix) -- indexes used by Hpc.