X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FbasicTypes%2FSrcLoc.lhs;h=51d4318b0be60e8c785d8a28b959b04e4c7a62f3;hb=28a464a75e14cece5db40f2765a29348273ff2d2;hp=95b7172c1b9494f01d7a09b4331a9493e7ff6a6c;hpb=864388a3bddc77623b438b83070722da1629bf16;p=ghc-hetmet.git diff --git a/ghc/compiler/basicTypes/SrcLoc.lhs b/ghc/compiler/basicTypes/SrcLoc.lhs index 95b7172..51d4318 100644 --- a/ghc/compiler/basicTypes/SrcLoc.lhs +++ b/ghc/compiler/basicTypes/SrcLoc.lhs @@ -23,7 +23,7 @@ module SrcLoc ( srcLocFile, -- return the file name part srcLocLine, -- return the line part srcLocCol, -- return the column part - + pprDefnLoc, SrcSpan, -- Abstract noSrcSpan, @@ -108,14 +108,9 @@ srcLocCol (SrcLoc _ l c) = c srcLocCol other = panic "srcLocCol: unknown col" advanceSrcLoc :: SrcLoc -> Char -> SrcLoc -advanceSrcLoc (SrcLoc f l c) '\t' = SrcLoc f l (tab c) advanceSrcLoc (SrcLoc f l c) '\n' = SrcLoc f (l + 1) 0 advanceSrcLoc (SrcLoc f l c) _ = SrcLoc f l (c + 1) advanceSrcLoc loc _ = loc -- Better than nothing - --- Advance to the next tab stop. Tabs are at column positions 0, 8, 16, etc. -tab :: Int -> Int -tab c = (c `quot` 8 + 1) * 8 \end{code} %************************************************************************ @@ -161,7 +156,7 @@ instance Outputable SrcLoc where hcat [text "{-# LINE ", int src_line, space, char '\"', ftext src_path, text " #-}"] - ppr (ImportedLoc mod) = ptext SLIT("Imported from") <+> quotes (text mod) + ppr (ImportedLoc mod) = ptext SLIT("Imported from") <+> text mod ppr (UnhelpfulLoc s) = ftext s \end{code} @@ -304,6 +299,12 @@ combineSrcSpans start end col2 = srcSpanEndCol end file = srcSpanFile start +pprDefnLoc :: SrcLoc -> SDoc +-- "defined at ..." or "imported from ..." +pprDefnLoc loc + | isGoodSrcLoc loc = ptext SLIT("Defined at") <+> ppr loc + | otherwise = ppr loc + instance Outputable SrcSpan where ppr span = getPprStyle $ \ sty -> @@ -380,6 +381,6 @@ instance Functor Located where fmap f (L l e) = L l (f e) instance Outputable e => Outputable (Located e) where - ppr (L span e) = ppr e + ppr (L span e) = ppr e -- do we want to dump the span in debugSty mode? \end{code}