]> git.sur5r.net Git - cc65/blob - src/ca65/lineinfo.h
New version by Greg King.
[cc65] / src / ca65 / lineinfo.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                lineinfo.h                                 */
4 /*                                                                           */
5 /*                      Source file line info structure                      */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2001      Ullrich von Bassewitz                                       */
10 /*               Wacholderweg 14                                             */
11 /*               D-70597 Stuttgart                                           */
12 /* EMail:        uz@cc65.org                                                 */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 /* Note: The line infos kept here are additional line infos supplied by the
37  * ".dbg line" command. The native line infos are always kept in the fragments
38  * itself (because one fragment always originates from one line). The
39  * additional line infos (which may not exist if none are supplied in the
40  * source) may have several fragments attached (as is the case with sources
41  * generated by the C compiler).
42  */
43
44
45
46 #ifndef LINEINFO_H
47 #define LINEINFO_H
48
49
50
51 /* common */
52 #include "coll.h"
53 #include "filepos.h"
54
55 /* ca65 */
56 #include "global.h"
57
58
59
60 /*****************************************************************************/
61 /*                                   Data                                    */
62 /*****************************************************************************/
63
64
65
66 /* The LineInfo structure is shared between several fragments, so we need a
67  * reference counter.
68  */
69 typedef struct LineInfo LineInfo;
70 struct LineInfo {
71     unsigned        Usage;                /* Usage counter */
72     unsigned        Index;                /* Index */
73     FilePos         Pos;                  /* File position */
74 };
75
76 /* Collection containing all line infos */
77 extern Collection LineInfoColl;
78 extern unsigned  LineInfoValid;           /* Valid, that is, used entries */
79
80 /* Global pointer to last line info or NULL if not active */
81 extern LineInfo* CurLineInfo;
82
83
84
85 /*****************************************************************************/
86 /*                                   Code                                    */
87 /*****************************************************************************/
88
89
90
91 LineInfo* UseLineInfo (LineInfo* LI);
92 /* Increase the reference count of the given line info and return it. The
93  * function will gracefully accept NULL pointers and do nothing in this case.
94  */
95
96 void GenLineInfo (unsigned FileIndex, unsigned long LineNum);
97 /* Generate a new line info */
98
99 void ClearLineInfo (void);
100 /* Clear the current line info */
101
102 void MakeLineInfoIndex (void);
103 /* Walk over the line info list and make an index of all entries ignoring
104  * those with a usage count of zero.
105  */
106
107 void WriteLineInfo (void);
108 /* Write a list of all line infos to the object file. */
109
110
111
112 /* End of lineinfo.h */
113 #endif
114
115
116