2001-05-23 07:04:09 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* lineinfo.h */
|
|
|
|
/* */
|
2011-01-27 16:39:30 +00:00
|
|
|
/* Source file line info management */
|
2001-05-23 07:04:09 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* */
|
2011-01-20 20:54:30 +00:00
|
|
|
/* (C) 2001-2011, Ullrich von Bassewitz */
|
|
|
|
/* Roemerstrasse 52 */
|
|
|
|
/* 70794 Filderstadt */
|
|
|
|
/* EMail: uz@cc65.org */
|
2001-05-23 07:04:09 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* This software is provided 'as-is', without any expressed or implied */
|
|
|
|
/* warranty. In no event will the authors be held liable for any damages */
|
|
|
|
/* arising from the use of this software. */
|
|
|
|
/* */
|
|
|
|
/* Permission is granted to anyone to use this software for any purpose, */
|
|
|
|
/* including commercial applications, and to alter it and redistribute it */
|
|
|
|
/* freely, subject to the following restrictions: */
|
|
|
|
/* */
|
|
|
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
|
|
/* claim that you wrote the original software. If you use this software */
|
|
|
|
/* in a product, an acknowledgment in the product documentation would be */
|
|
|
|
/* appreciated but is not required. */
|
|
|
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
|
|
/* be misrepresented as being the original software. */
|
|
|
|
/* 3. This notice may not be removed or altered from any source */
|
|
|
|
/* distribution. */
|
|
|
|
/* */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef LINEINFO_H
|
|
|
|
#define LINEINFO_H
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-05-23 08:51:48 +00:00
|
|
|
/* common */
|
2001-05-23 22:02:19 +00:00
|
|
|
#include "coll.h"
|
2001-05-23 08:51:48 +00:00
|
|
|
#include "filepos.h"
|
2011-01-29 22:16:03 +00:00
|
|
|
#include "lidefs.h"
|
2001-05-23 08:51:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-05-23 07:04:09 +00:00
|
|
|
/*****************************************************************************/
|
2011-01-24 22:38:22 +00:00
|
|
|
/* Data */
|
2001-05-23 07:04:09 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-24 22:38:22 +00:00
|
|
|
/* Predefined line info slots. These are allocated when initializing the
|
|
|
|
* module. Beware: Some code relies on the fact that slot zero is the basic
|
|
|
|
* standard line info. It is assumed to be always there.
|
|
|
|
*/
|
|
|
|
enum {
|
2011-06-13 08:53:41 +00:00
|
|
|
LI_SLOT_INV = -1, /* Use to mark invalid slots */
|
2011-01-24 22:38:22 +00:00
|
|
|
LI_SLOT_ASM = 0, /* Normal assembler source */
|
|
|
|
LI_SLOT_EXT = 1, /* Externally supplied line info */
|
|
|
|
};
|
|
|
|
|
2001-05-23 07:04:09 +00:00
|
|
|
/* The LineInfo structure is shared between several fragments, so we need a
|
|
|
|
* reference counter.
|
|
|
|
*/
|
|
|
|
typedef struct LineInfo LineInfo;
|
|
|
|
struct LineInfo {
|
2011-01-24 22:38:22 +00:00
|
|
|
unsigned Usage; /* Usage counter */
|
|
|
|
unsigned Type; /* Type of line info */
|
|
|
|
unsigned Index; /* Index */
|
|
|
|
FilePos Pos; /* File position */
|
2001-05-23 07:04:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* Code */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-24 22:38:22 +00:00
|
|
|
void InitLineInfo (void);
|
|
|
|
/* Initialize the line infos */
|
|
|
|
|
2011-06-13 08:53:41 +00:00
|
|
|
int AllocLineInfoSlot (unsigned Type, unsigned Count);
|
2011-01-24 22:38:22 +00:00
|
|
|
/* Allocate a line info slot of the given type and return the slot index */
|
|
|
|
|
2011-06-13 08:53:41 +00:00
|
|
|
void FreeLineInfoSlot (int Slot);
|
2011-01-24 22:38:22 +00:00
|
|
|
/* Free the line info in the given slot. Note: Alloc/Free must be used in
|
|
|
|
* FIFO order.
|
|
|
|
*/
|
|
|
|
|
2011-06-13 08:53:41 +00:00
|
|
|
void GenLineInfo (int Slot, const FilePos* Pos);
|
2011-01-24 22:38:22 +00:00
|
|
|
/* Generate a new line info in the given slot */
|
|
|
|
|
2011-06-13 08:53:41 +00:00
|
|
|
void ClearLineInfo (int Slot);
|
2011-01-24 22:38:22 +00:00
|
|
|
/* Clear the line info in the given slot */
|
|
|
|
|
2011-01-29 18:43:36 +00:00
|
|
|
void GetFullLineInfo (Collection* LineInfos, unsigned IncUsage);
|
2011-01-24 22:38:22 +00:00
|
|
|
/* Return full line infos, that is line infos for all slots in LineInfos. The
|
2011-01-29 18:43:36 +00:00
|
|
|
* function will clear LineInfos before usage and will increment the usage
|
|
|
|
* counter by IncUsage for all line infos returned.
|
2011-01-24 22:38:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
LineInfo* ReleaseLineInfo (LineInfo* LI);
|
|
|
|
/* Decrease the reference count of the given line info and return it. The
|
|
|
|
* function will gracefully accept NULL pointers and do nothing in this case.
|
|
|
|
*/
|
2001-05-23 07:04:09 +00:00
|
|
|
|
2011-01-27 22:25:32 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE const FilePos* GetSourcePos (const LineInfo* LI)
|
|
|
|
/* Return the source file position from the given line info */
|
|
|
|
{
|
|
|
|
return &LI->Pos;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define GetSourcePos(LI) (&(LI)->Pos)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE unsigned GetLineInfoType (const LineInfo* LI)
|
|
|
|
/* Return the type of a line info */
|
|
|
|
{
|
2011-01-29 22:16:03 +00:00
|
|
|
return LI_GET_TYPE (LI->Type);
|
2011-01-27 22:25:32 +00:00
|
|
|
}
|
|
|
|
#else
|
2011-01-29 22:16:03 +00:00
|
|
|
# define GetLineInfoType(LI) LI_GET_TYPE ((LI)->Type)
|
2011-01-27 22:25:32 +00:00
|
|
|
#endif
|
|
|
|
|
2011-01-24 22:38:22 +00:00
|
|
|
void WriteLineInfo (const Collection* LineInfos);
|
|
|
|
/* Write a list of line infos to the object file. MakeLineInfoIndex has to
|
|
|
|
* be called before!
|
|
|
|
*/
|
2001-05-23 19:03:40 +00:00
|
|
|
|
|
|
|
void MakeLineInfoIndex (void);
|
2011-01-24 22:38:22 +00:00
|
|
|
/* Index the line infos */
|
2001-05-23 19:03:40 +00:00
|
|
|
|
2011-01-24 22:38:22 +00:00
|
|
|
void WriteLineInfos (void);
|
2001-05-23 19:03:40 +00:00
|
|
|
/* Write a list of all line infos to the object file. */
|
|
|
|
|
2001-05-23 07:04:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* End of lineinfo.h */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-08-11 21:23:37 +00:00
|
|
|
|