1 /*****************************************************************************/
5 /* Source file line info management */
9 /* (C) 2001-2011, Ullrich von Bassewitz */
10 /* Roemerstrasse 52 */
11 /* 70794 Filderstadt */
12 /* EMail: uz@cc65.org */
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. */
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: */
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 */
32 /*****************************************************************************/
47 /*****************************************************************************/
49 /*****************************************************************************/
53 /* Predefined line info slots. These are allocated when initializing the
54 * module. Beware: Some code relies on the fact that slot zero is the basic
55 * standard line info. It is assumed to be always there.
58 LI_SLOT_ASM = 0, /* Normal assembler source */
59 LI_SLOT_EXT = 1, /* Externally supplied line info */
62 /* Types of line infos. The low byte may be used for some sort of depth
66 LI_MASK_COUNT = 0x00FF, /* Mask to extract the count */
68 LI_TYPE_EXT = 0x0100, /* Externally supplied line info */
69 LI_TYPE_ASM = 0x0200, /* Normal assembler source */
70 LI_TYPE_MACRO = 0x0300, /* Macro expansion */
71 LI_MASK_TYPE = 0x7F00, /* Mask to extract the type */
74 /* The LineInfo structure is shared between several fragments, so we need a
77 typedef struct LineInfo LineInfo;
79 unsigned Usage; /* Usage counter */
80 unsigned Type; /* Type of line info */
81 unsigned Index; /* Index */
82 FilePos Pos; /* File position */
87 /*****************************************************************************/
89 /*****************************************************************************/
93 void InitLineInfo (void);
94 /* Initialize the line infos */
96 unsigned AllocLineInfoSlot (unsigned Type);
97 /* Allocate a line info slot of the given type and return the slot index */
99 void FreeLineInfoSlot (unsigned Slot);
100 /* Free the line info in the given slot. Note: Alloc/Free must be used in
104 void GenLineInfo (unsigned Slot, const FilePos* Pos);
105 /* Generate a new line info in the given slot */
107 void ClearLineInfo (unsigned Slot);
108 /* Clear the line info in the given slot */
110 LineInfo* GetLineInfo (unsigned Slot);
111 /* Get the line info from the given slot */
113 void GetFullLineInfo (Collection* LineInfos);
114 /* Return full line infos, that is line infos for all slots in LineInfos. The
115 * function does also increase the usage counter for all line infos returned.
118 LineInfo* UseLineInfo (LineInfo* LI);
119 /* Increase the reference count of the given line info and return it. The
120 * function will gracefully accept NULL pointers and do nothing in this case.
123 LineInfo* ReleaseLineInfo (LineInfo* LI);
124 /* Decrease the reference count of the given line info and return it. The
125 * function will gracefully accept NULL pointers and do nothing in this case.
128 void WriteLineInfo (const Collection* LineInfos);
129 /* Write a list of line infos to the object file. MakeLineInfoIndex has to
133 void MakeLineInfoIndex (void);
134 /* Index the line infos */
136 void WriteLineInfos (void);
137 /* Write a list of all line infos to the object file. */
141 /* End of lineinfo.h */