projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Stoping constant folding of calls to chr# that are invalid
[ghc-hetmet.git]
/
compiler
/
basicTypes
/
SrcLoc.lhs
diff --git
a/compiler/basicTypes/SrcLoc.lhs
b/compiler/basicTypes/SrcLoc.lhs
index
99ce717
..
c1b49e9
100644
(file)
--- a/
compiler/basicTypes/SrcLoc.lhs
+++ b/
compiler/basicTypes/SrcLoc.lhs
@@
-11,7
+11,6
@@
module SrcLoc (
advanceSrcLoc,
importedSrcLoc, -- Unknown place in an interface
advanceSrcLoc,
importedSrcLoc, -- Unknown place in an interface
- wiredInSrcLoc, -- Something wired into the compiler
generatedSrcLoc, -- Code generated within the compiler
interactiveSrcLoc, -- Code from an interactive session
generatedSrcLoc, -- Code generated within the compiler
interactiveSrcLoc, -- Code from an interactive session
@@
-22,6
+21,8
@@
module SrcLoc (
SrcSpan, -- Abstract
noSrcSpan,
SrcSpan, -- Abstract
noSrcSpan,
+ wiredInSrcSpan, -- Something wired into the compiler
+ importedSrcSpan, -- Unknown place in an interface
mkGeneralSrcSpan,
isGoodSrcSpan, isOneLineSpan,
mkSrcSpan, srcLocSpan,
mkGeneralSrcSpan,
isGoodSrcSpan, isOneLineSpan,
mkSrcSpan, srcLocSpan,
@@
-30,7
+31,9
@@
module SrcLoc (
-- These are dubious exports, because they crash on some inputs,
-- used only in Lexer.x where we are sure what the Span looks like
-- These are dubious exports, because they crash on some inputs,
-- used only in Lexer.x where we are sure what the Span looks like
- srcSpanFile, srcSpanEndLine, srcSpanEndCol,
+ srcSpanFile,
+ srcSpanStartLine, srcSpanEndLine,
+ srcSpanStartCol, srcSpanEndCol,
Located(..), getLoc, unLoc, noLoc, eqLocated, cmpLocated, combineLocs, addCLoc
) where
Located(..), getLoc, unLoc, noLoc, eqLocated, cmpLocated, combineLocs, addCLoc
) where
@@
-58,7
+61,7
@@
data SrcLoc
-- Don't ask me why lines start at 1 and columns start at
-- zero. That's just the way it is, so there. --SDM
-- Don't ask me why lines start at 1 and columns start at
-- zero. That's just the way it is, so there. --SDM
- | ImportedLoc String -- Module name
+ | ImportedLoc FastString -- Module name
| UnhelpfulLoc FastString -- Just a general indication
\end{code}
| UnhelpfulLoc FastString -- Just a general indication
\end{code}
@@
-79,13
+82,12
@@
Things to make 'em:
mkSrcLoc x line col = SrcLoc x line col
noSrcLoc = UnhelpfulLoc FSLIT("<no location info>")
generatedSrcLoc = UnhelpfulLoc FSLIT("<compiler-generated code>")
mkSrcLoc x line col = SrcLoc x line col
noSrcLoc = UnhelpfulLoc FSLIT("<no location info>")
generatedSrcLoc = UnhelpfulLoc FSLIT("<compiler-generated code>")
-wiredInSrcLoc = UnhelpfulLoc FSLIT("<wired into compiler>")
interactiveSrcLoc = UnhelpfulLoc FSLIT("<interactive session>")
mkGeneralSrcLoc :: FastString -> SrcLoc
mkGeneralSrcLoc = UnhelpfulLoc
interactiveSrcLoc = UnhelpfulLoc FSLIT("<interactive session>")
mkGeneralSrcLoc :: FastString -> SrcLoc
mkGeneralSrcLoc = UnhelpfulLoc
-importedSrcLoc :: String -> SrcLoc
+importedSrcLoc :: FastString -> SrcLoc
importedSrcLoc mod_name = ImportedLoc mod_name
isGoodSrcLoc (SrcLoc _ _ _) = True
importedSrcLoc mod_name = ImportedLoc mod_name
isGoodSrcLoc (SrcLoc _ _ _) = True
@@
-148,7
+150,7
@@
instance Outputable SrcLoc where
hcat [text "{-# LINE ", int src_line, space,
char '\"', ftext src_path, text " #-}"]
hcat [text "{-# LINE ", int src_line, space,
char '\"', ftext src_path, text " #-}"]
- ppr (ImportedLoc mod) = ptext SLIT("Defined in") <+> text mod
+ ppr (ImportedLoc mod) = ptext SLIT("Defined in") <+> ftext mod
ppr (UnhelpfulLoc s) = ftext s
\end{code}
ppr (UnhelpfulLoc s) = ftext s
\end{code}
@@
-191,7
+193,7
@@
data SrcSpan
srcSpanCol :: !Int
}
srcSpanCol :: !Int
}
- | ImportedSpan String -- Module name
+ | ImportedSpan FastString -- Module name
| UnhelpfulSpan FastString -- Just a general indication
-- also used to indicate an empty span
| UnhelpfulSpan FastString -- Just a general indication
-- also used to indicate an empty span
@@
-204,7
+206,9
@@
instance Ord SrcSpan where
(srcSpanStart a `compare` srcSpanStart b) `thenCmp`
(srcSpanEnd a `compare` srcSpanEnd b)
(srcSpanStart a `compare` srcSpanStart b) `thenCmp`
(srcSpanEnd a `compare` srcSpanEnd b)
-noSrcSpan = UnhelpfulSpan FSLIT("<no location info>")
+noSrcSpan = UnhelpfulSpan FSLIT("<no location info>")
+wiredInSrcSpan = UnhelpfulSpan FSLIT("<wired into compiler>")
+importedSrcSpan = ImportedSpan
mkGeneralSrcSpan :: FastString -> SrcSpan
mkGeneralSrcSpan = UnhelpfulSpan
mkGeneralSrcSpan :: FastString -> SrcSpan
mkGeneralSrcSpan = UnhelpfulSpan
@@
-304,11
+308,11
@@
combineSrcSpans start end
col2 = srcSpanEndCol end
file = srcSpanFile start
col2 = srcSpanEndCol end
file = srcSpanFile start
-pprDefnLoc :: SrcLoc -> SDoc
+pprDefnLoc :: SrcSpan -> SDoc
-- "defined at ..." or "imported from ..."
pprDefnLoc loc
-- "defined at ..." or "imported from ..."
pprDefnLoc loc
- | isGoodSrcLoc loc = ptext SLIT("Defined at") <+> ppr loc
- | otherwise = ppr loc
+ | isGoodSrcSpan loc = ptext SLIT("Defined at") <+> ppr loc
+ | otherwise = ppr loc
instance Outputable SrcSpan where
ppr span
instance Outputable SrcSpan where
ppr span
@@
-345,7
+349,7
@@
pprUserSpan (SrcSpanPoint src_path line col)
char ':', int col
]
char ':', int col
]
-pprUserSpan (ImportedSpan mod) = ptext SLIT("Defined in") <+> text mod
+pprUserSpan (ImportedSpan mod) = ptext SLIT("Defined in") <+> ftext mod
pprUserSpan (UnhelpfulSpan s) = ftext s
\end{code}
pprUserSpan (UnhelpfulSpan s) = ftext s
\end{code}