summaryrefslogtreecommitdiff
path: root/compiler/deSugar/Coverage.lhs
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2011-06-02 00:23:27 +0100
committerIan Lynagh <igloo@earth.li>2011-06-09 13:01:09 +0100
commit5f8f1f244f49543cda309303f065c5bdcf961ea4 (patch)
treeb6640c1a7838a53904077e6448ddb0fcb6476242 /compiler/deSugar/Coverage.lhs
parent1d746841aafe38044dd9f0de1a8d686ea554a3c7 (diff)
downloadhaskell-srcloc.tar.gz
Refactor SrcLoc and SrcSpansrcloc
The "Unhelpful" cases are now in a separate type. This allows us to improve various things, e.g.: * Most of the panic's in SrcLoc are now gone * The Lexer now works with RealSrcSpans rather than SrcSpans, i.e. it knows that it has real locations and thus can assume that the line number etc really exists * Some of the more suspicious cases are no longer necessary, e.g. we no longer need this case in advanceSrcLoc: advanceSrcLoc loc _ = loc -- Better than nothing More improvements can probably be made, e.g. tick locations can probably use RealSrcSpans too.
Diffstat (limited to 'compiler/deSugar/Coverage.lhs')
-rw-r--r--compiler/deSugar/Coverage.lhs26
1 files changed, 8 insertions, 18 deletions
diff --git a/compiler/deSugar/Coverage.lhs b/compiler/deSugar/Coverage.lhs
index 37cbc2d5c5..fbe1ab9a45 100644
--- a/compiler/deSugar/Coverage.lhs
+++ b/compiler/deSugar/Coverage.lhs
@@ -846,26 +846,16 @@ allocBinTickBox boxLabel pos m
allocBinTickBox _boxLabel pos m = do e <- m; return (L pos e)
isGoodSrcSpan' :: SrcSpan -> Bool
-isGoodSrcSpan' pos
- | not (isGoodSrcSpan pos) = False
- | start == end = False
- | otherwise = True
- where
- start = srcSpanStart pos
- end = srcSpanEnd pos
+isGoodSrcSpan' pos@(RealSrcSpan _) = srcSpanStart pos /= srcSpanEnd pos
+isGoodSrcSpan' (UnhelpfulSpan _) = False
mkHpcPos :: SrcSpan -> HpcPos
-mkHpcPos pos
- | not (isGoodSrcSpan' pos) = panic "bad source span; expected such spans to be filtered out"
- | otherwise = hpcPos
- where
- start = srcSpanStart pos
- end = srcSpanEnd pos
- hpcPos = toHpcPos ( srcLocLine start
- , srcLocCol start
- , srcLocLine end
- , srcLocCol end - 1
- )
+mkHpcPos pos@(RealSrcSpan s)
+ | isGoodSrcSpan' pos = toHpcPos (srcSpanStartLine s,
+ srcSpanStartCol s,
+ srcSpanEndLine s,
+ srcSpanEndCol s)
+mkHpcPos _ = panic "bad source span; expected such spans to be filtered out"
hpcSrcSpan :: SrcSpan
hpcSrcSpan = mkGeneralSrcSpan (fsLit "Haskell Program Coverage internals")