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
30 import PprStyle ( PprStyle(..), userStyle )
35 %************************************************************************
37 \subsection[SrcLoc-SrcLocations]{Source-location information}
39 %************************************************************************
41 We keep information about the {\em definition} point for each entity;
42 this is the obvious stuff:
47 | SrcLoc FAST_STRING -- A precise location
50 | UnhelpfulSrcLoc FAST_STRING -- Just a general indication
53 Note that an entity might be imported via more than one route, and
54 there could be more than one ``definition point'' --- in two or more
55 \tr{.hi} files. We deemed it probably-unworthwhile to cater for this
58 %************************************************************************
60 \subsection[SrcLoc-access-fns]{Access functions for names}
62 %************************************************************************
67 mkSrcLoc x IBOX(y) = SrcLoc x y
69 mkIfaceSrcLoc = UnhelpfulSrcLoc SLIT("<an interface file>")
70 mkBuiltinSrcLoc = UnhelpfulSrcLoc SLIT("<built-into-the-compiler>")
71 mkGeneratedSrcLoc = UnhelpfulSrcLoc SLIT("<compiler-generated-code>")
73 isNoSrcLoc NoSrcLoc = True
74 isNoSrcLoc other = False
77 %************************************************************************
79 \subsection[SrcLoc-instances]{Instance declarations for various names}
81 %************************************************************************
84 instance Outputable SrcLoc where
85 ppr sty (SrcLoc src_file src_line)
87 = hcat [ ptext src_file, char ':', text (show IBOX(src_line)) ]
90 = hcat [text "{-# LINE ", text (show IBOX(src_line)), space,
91 char '\"', ptext src_file, text " #-}"]
92 ppr sty (UnhelpfulSrcLoc s) = ptext s
94 ppr sty NoSrcLoc = text "<NoSrcLoc>"
98 = hcat [ptext SLIT("{-# LINE "), text (show IBOX(src_line)), space,
99 char '"', ptext src_file, ptext SLIT(" #-}")]
100 --ptext SLIT("\" #-}")]