#include "HsVersions.h"
module SrcLoc (
- SrcLoc, -- abstract
+ SrcLoc, -- Abstract
- mkSrcLoc, mkSrcLoc2, -- the usual
- mkUnknownSrcLoc, -- "I'm sorry, I haven't a clue"
- mkBuiltinSrcLoc, -- something wired into the compiler
- mkGeneratedSrcLoc, -- code generated within the compiler
- unpackSrcLoc
+ mkSrcLoc,
+ noSrcLoc, isNoSrcLoc, -- "I'm sorry, I haven't a clue"
+
+ mkIfaceSrcLoc, -- Unknown place in an interface
+ -- (this one can die eventually ToDo)
+
+ mkBuiltinSrcLoc, -- Something wired into the compiler
+
+ mkGeneratedSrcLoc -- Code generated within the compiler
) where
-import Ubiq
+IMP_Ubiq()
import PprStyle ( PprStyle(..) )
import Pretty
this is the obvious stuff:
\begin{code}
data SrcLoc
- = SrcLoc FAST_STRING -- source file name
- FAST_STRING -- line number in source file
- | SrcLoc2 FAST_STRING -- same, but w/ an Int line#
+ = NoSrcLoc
+
+ | SrcLoc FAST_STRING -- A precise location
FAST_INT
+
+ | UnhelpfulSrcLoc FAST_STRING -- Just a general indication
\end{code}
Note that an entity might be imported via more than one route, and
Things to make 'em:
\begin{code}
-mkSrcLoc = SrcLoc
-mkSrcLoc2 x IBOX(y) = SrcLoc2 x y
-mkUnknownSrcLoc = SrcLoc SLIT("<unknown>") SLIT("<unknown>")
-mkBuiltinSrcLoc = SrcLoc SLIT("<built-into-the-compiler>") SLIT("<none>")
-mkGeneratedSrcLoc = SrcLoc SLIT("<compiler-generated-code>") SLIT("<none>")
-
-unpackSrcLoc (SrcLoc src_file src_line) = (src_file, src_line)
-unpackSrcLoc (SrcLoc2 src_file src_line) = (src_file, _PK_ (show IBOX(src_line)))
+noSrcLoc = NoSrcLoc
+mkSrcLoc x IBOX(y) = SrcLoc x y
+
+mkIfaceSrcLoc = UnhelpfulSrcLoc SLIT("<an interface file>")
+mkBuiltinSrcLoc = UnhelpfulSrcLoc SLIT("<built-into-the-compiler>")
+mkGeneratedSrcLoc = UnhelpfulSrcLoc SLIT("<compiler-generated-code>")
+
+isNoSrcLoc NoSrcLoc = True
+isNoSrcLoc other = False
\end{code}
%************************************************************************
\begin{code}
instance Outputable SrcLoc where
ppr PprForUser (SrcLoc src_file src_line)
- = ppBesides [ ppChar '"', ppPStr src_file, ppPStr SLIT("\", line "), ppPStr src_line ]
+ = ppBesides [ ppPStr src_file, ppChar ':', ppStr (show IBOX(src_line)) ]
ppr sty (SrcLoc src_file src_line)
- = ppBesides [ppPStr SLIT("{-# LINE "), ppPStr src_line, ppSP,
- ppChar '"', ppPStr src_file, ppPStr SLIT("\" #-}")]
+ = ppBesides [ppStr "{-# LINE ", ppStr (show IBOX(src_line)), ppSP,
+ ppChar '\"', ppPStr src_file, ppStr " #-}"]
+ ppr sty (UnhelpfulSrcLoc s) = ppPStr s
- ppr sty (SrcLoc2 src_file src_line)
- = ppr sty (SrcLoc src_file (_PK_ (show IBOX(src_line))))
+ ppr sty NoSrcLoc = ppStr "<NoSrcLoc>"
\end{code}
+
+{-
+ = ppBesides [ppPStr SLIT("{-# LINE "), ppStr (show IBOX(src_line)), ppSP,
+ ppChar '"', ppPStr src_file, ppPStr SLIT(" #-}")]
+ --ppPStr SLIT("\" #-}")]
+-}