2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1994
4 %************************************************************************
6 \section[SrcLoc]{The @SrcLoc@ type}
8 %************************************************************************
11 #include "HsVersions.h"
17 noSrcLoc, isNoSrcLoc, -- "I'm sorry, I haven't a clue"
19 mkIfaceSrcLoc, -- Unknown place in an interface
20 -- (this one can die eventually ToDo)
22 mkBuiltinSrcLoc, -- Something wired into the compiler
24 mkGeneratedSrcLoc -- Code generated within the compiler
34 %************************************************************************
36 \subsection[SrcLoc-SrcLocations]{Source-location information}
38 %************************************************************************
40 We keep information about the {\em definition} point for each entity;
41 this is the obvious stuff:
46 | SrcLoc FAST_STRING -- A precise location
49 | UnhelpfulSrcLoc FAST_STRING -- Just a general indication
52 Note that an entity might be imported via more than one route, and
53 there could be more than one ``definition point'' --- in two or more
54 \tr{.hi} files. We deemed it probably-unworthwhile to cater for this
57 %************************************************************************
59 \subsection[SrcLoc-access-fns]{Access functions for names}
61 %************************************************************************
66 mkSrcLoc x IBOX(y) = SrcLoc x y
68 mkIfaceSrcLoc = UnhelpfulSrcLoc SLIT("<an interface file>")
69 mkBuiltinSrcLoc = UnhelpfulSrcLoc SLIT("<built-into-the-compiler>")
70 mkGeneratedSrcLoc = UnhelpfulSrcLoc SLIT("<compiler-generated-code>")
72 isNoSrcLoc NoSrcLoc = True
73 isNoSrcLoc other = False
76 %************************************************************************
78 \subsection[SrcLoc-instances]{Instance declarations for various names}
80 %************************************************************************
83 instance Outputable SrcLoc where
84 ppr sty (SrcLoc src_file src_line)
86 = hcat [ ptext src_file, char ':', text (show IBOX(src_line)) ]
89 = hcat [text "{-# LINE ", text (show IBOX(src_line)), space,
90 char '\"', ptext src_file, text " #-}"]
91 ppr sty (UnhelpfulSrcLoc s) = ptext s
93 ppr sty NoSrcLoc = text "<NoSrcLoc>"
97 = hcat [ptext SLIT("{-# LINE "), text (show IBOX(src_line)), space,
98 char '"', ptext src_file, ptext SLIT(" #-}")]
99 --ptext SLIT("\" #-}")]