diff options
author | andy@galois.com <unknown> | 2007-07-12 19:42:00 +0000 |
---|---|---|
committer | andy@galois.com <unknown> | 2007-07-12 19:42:00 +0000 |
commit | a966047ca5c407f336a633d716d3d7b5ed29d231 (patch) | |
tree | 2022e1d3b41e70d664efc1fd93b7f39590502464 /utils/hpc/HpcUtils.hs | |
parent | 41ac7eb30ff99535c24c39efd33e2b65ea458707 (diff) | |
download | haskell-a966047ca5c407f336a633d716d3d7b5ed29d231.tar.gz |
Adding draft and show to hpc
we now have
hpc draft <TIX_FILE>
This drafts up a candidate overlay for 100% coverage.
and
hpc show <TIX_FILE>
This show verbose details about a tix file; mainly for debugging.
Diffstat (limited to 'utils/hpc/HpcUtils.hs')
-rw-r--r-- | utils/hpc/HpcUtils.hs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/utils/hpc/HpcUtils.hs b/utils/hpc/HpcUtils.hs new file mode 100644 index 0000000000..b679a37741 --- /dev/null +++ b/utils/hpc/HpcUtils.hs @@ -0,0 +1,20 @@ +module HpcUtils where + +import Trace.Hpc.Util +import qualified HpcMap as Map + +-- turns \n into ' ' +-- | grab's the text behind a HpcPos; +grabHpcPos :: Map.Map Int String -> HpcPos -> String +grabHpcPos hsMap span = + case lns of + [ln] -> (take ((c2 - c1) + 1) $ drop (c1 - 1) ln) + _ -> let lns1 = drop (c1 -1) (head lns) : tail lns + lns2 = init lns1 ++ [take (c2 + 1) (last lns1) ] + in foldl1 (\ xs ys -> xs ++ "\n" ++ ys) lns2 + where (l1,c1,l2,c2) = fromHpcPos span + lns = map (\ n -> case Map.lookup n hsMap of + Just ln -> ln + Nothing -> error $ "bad line number : " ++ show n + ) [l1..l2] + |