Started to generalize line info handling. Remove separate FilePos fields and

try to manage all and everything with LineInfos.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4914 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2011-01-24 22:38:22 +00:00
parent 0f9ced267e
commit 06e3152035
11 changed files with 446 additions and 141 deletions

View File

@@ -52,34 +52,46 @@
#include "coll.h"
#include "filepos.h"
/* ca65 */
#include "global.h"
/*****************************************************************************/
/* Data */
/* Data */
/*****************************************************************************/
/* 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 {
LI_SLOT_ASM = 0, /* Normal assembler source */
LI_SLOT_EXT = 1, /* Externally supplied line info */
};
/* Types of line infos. The low byte may be used for some sort of depth
* counter.
*/
enum {
LI_MASK_COUNT = 0x00FF, /* Mask to extract the count */
LI_TYPE_EXT = 0x0100, /* Externally supplied line info */
LI_TYPE_ASM = 0x0200, /* Normal assembler source */
LI_TYPE_MACRO = 0x0300, /* Macro expansion */
LI_MASK_TYPE = 0x7F00, /* Mask to extract the type */
};
/* The LineInfo structure is shared between several fragments, so we need a
* reference counter.
*/
typedef struct LineInfo LineInfo;
struct LineInfo {
unsigned Usage; /* Usage counter */
unsigned Index; /* Index */
FilePos Pos; /* File position */
unsigned Usage; /* Usage counter */
unsigned Type; /* Type of line info */
unsigned Index; /* Index */
FilePos Pos; /* File position */
};
/* Collection containing all line infos */
extern Collection LineInfoColl;
extern unsigned LineInfoValid; /* Valid, that is, used entries */
/* Global pointer to last line info or NULL if not active */
extern LineInfo* CurLineInfo;
/*****************************************************************************/
@@ -88,23 +100,50 @@ extern LineInfo* CurLineInfo;
void InitLineInfo (void);
/* Initialize the line infos */
unsigned AllocLineInfoSlot (unsigned Type);
/* Allocate a line info slot of the given type and return the slot index */
void FreeLineInfoSlot (unsigned Slot);
/* Free the line info in the given slot. Note: Alloc/Free must be used in
* FIFO order.
*/
void GenLineInfo (unsigned Slot, unsigned File, unsigned long Line, unsigned Col);
/* Generate a new line info in the given slot */
void ClearLineInfo (unsigned Slot);
/* Clear the line info in the given slot */
LineInfo* GetLineInfo (unsigned Slot);
/* Get the line info from the given slot */
void GetFullLineInfo (Collection* LineInfos);
/* Return full line infos, that is line infos for all slots in LineInfos. The
* function does also increase the usage counter for all line infos returned.
*/
LineInfo* UseLineInfo (LineInfo* LI);
/* Increase the reference count of the given line info and return it. The
* function will gracefully accept NULL pointers and do nothing in this case.
*/
void GenLineInfo (unsigned FileIndex, unsigned long LineNum, unsigned ColNum);
/* Generate a new line info */
void ClearLineInfo (void);
/* Clear the current line info */
void MakeLineInfoIndex (void);
/* Walk over the line info list and make an index of all entries ignoring
* those with a usage count of zero.
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.
*/
void WriteLineInfo (void);
void WriteLineInfo (const Collection* LineInfos);
/* Write a list of line infos to the object file. MakeLineInfoIndex has to
* be called before!
*/
void MakeLineInfoIndex (void);
/* Index the line infos */
void WriteLineInfos (void);
/* Write a list of all line infos to the object file. */