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
29 import PprStyle ( PprStyle(..) )
33 %************************************************************************
35 \subsection[SrcLoc-SrcLocations]{Source-location information}
37 %************************************************************************
39 We keep information about the {\em definition} point for each entity;
40 this is the obvious stuff:
45 | SrcLoc FAST_STRING -- A precise location
48 | UnhelpfulSrcLoc FAST_STRING -- Just a general indication
51 Note that an entity might be imported via more than one route, and
52 there could be more than one ``definition point'' --- in two or more
53 \tr{.hi} files. We deemed it probably-unworthwhile to cater for this
56 %************************************************************************
58 \subsection[SrcLoc-access-fns]{Access functions for names}
60 %************************************************************************
65 mkSrcLoc x IBOX(y) = SrcLoc x y
67 mkIfaceSrcLoc = UnhelpfulSrcLoc SLIT("<an interface file>")
68 mkBuiltinSrcLoc = UnhelpfulSrcLoc SLIT("<built-into-the-compiler>")
69 mkGeneratedSrcLoc = UnhelpfulSrcLoc SLIT("<compiler-generated-code>")
71 isNoSrcLoc NoSrcLoc = True
72 isNoSrcLoc other = False
75 %************************************************************************
77 \subsection[SrcLoc-instances]{Instance declarations for various names}
79 %************************************************************************
82 instance Outputable SrcLoc where
83 ppr PprForUser (SrcLoc src_file src_line)
84 = ppBesides [ ppPStr src_file, ppStr ": ", ppStr (show IBOX(src_line)) ]
86 ppr sty (SrcLoc src_file src_line)
87 = ppBesides [ppPStr SLIT("{-# LINE "), ppStr (show IBOX(src_line)), ppSP,
88 ppChar '"', ppPStr src_file, ppPStr SLIT("\" #-}")]
90 ppr sty (UnhelpfulSrcLoc s) = ppPStr s
92 ppr sty NoSrcLoc = ppStr "<NoSrcLoc>"