X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Flitpool.h;h=7a771d5eb252caa34c155a9aa8dd2d84f7285911;hb=1bcd4b44f84d322871ac774dff831d6524733f21;hp=f168d89cf01bf86d95a6ac71794facdfd0ec3edf;hpb=53dd513176425872128ef26031d00952ef7a0628;p=cc65 diff --git a/src/cc65/litpool.h b/src/cc65/litpool.h index f168d89cf..7a771d5eb 100644 --- a/src/cc65/litpool.h +++ b/src/cc65/litpool.h @@ -1,15 +1,15 @@ /*****************************************************************************/ /* */ -/* litpool.h */ +/* litpool.h */ /* */ -/* Literal string handling for the cc65 C compiler */ +/* Literal string handling for the cc65 C compiler */ /* */ /* */ /* */ -/* (C) 1998 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ +/* (C) 1998-2009, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -38,51 +38,94 @@ +#include + +/* common */ +#include "strbuf.h" + + + /*****************************************************************************/ -/* Data */ +/* Data */ /*****************************************************************************/ -extern unsigned LiteralLabel; /* Pool asm label */ +/* Forward for struct SymEntry */ +struct SymEntry; + +/* Forward for a literal */ +typedef struct Literal Literal; + +/* Forward for a literal pool */ +typedef struct LiteralPool LiteralPool; /*****************************************************************************/ -/* Code */ +/* struct Literal */ /*****************************************************************************/ -void TranslateLiteralPool (unsigned Offs); -/* Translate the literals starting from the given offset into the target - * charset. - */ +Literal* UseLiteral (Literal* L); +/* Increase the reference counter for the literal and return it */ -void DumpLiteralPool (void); -/* Dump the literal pool */ +void ReleaseLiteral (Literal* L); +/* Decrement the reference counter for the literal */ -unsigned GetLiteralOffs (void); -/* Return the current offset into the literal pool */ +void TranslateLiteral (Literal* L); +/* Translate a literal into the target charset. */ -void ResetLiteralOffs (unsigned Offs); -/* Reset the offset into the literal pool to some earlier value, effectively - * removing values from the pool. - */ +unsigned GetLiteralLabel (const Literal* L); +/* Return the asm label for a literal */ + +const char* GetLiteralStr (const Literal* L); +/* Return the data for a literal as pointer to char */ + +const StrBuf* GetLiteralStrBuf (const Literal* L); +/* Return the data for a literal as pointer to the string buffer */ -void AddLiteralChar (char C); -/* Add one character to the literal pool */ +unsigned GetLiteralSize (const Literal* L); +/* Get the size of a literal string */ -unsigned AddLiteral (const char* S); -/* Add a literal string to the literal pool. Return the starting offset into - * the pool for this string. + + +/*****************************************************************************/ +/* Code */ +/*****************************************************************************/ + + + +void InitLiteralPool (void); +/* Initialize the literal pool */ + +void PushLiteralPool (struct SymEntry* Func); +/* Push the current literal pool onto the stack and create a new one */ + +LiteralPool* PopLiteralPool (void); +/* Pop the last literal pool from TOS and activate it. Return the old + * literal pool. */ -const char* GetLiteral (unsigned Offs); -/* Get a pointer to the literal with the given offset in the pool */ +void MoveLiteralPool (LiteralPool* LocalPool); +/* Move all referenced literals in LocalPool to the global literal pool. This + * function will free LocalPool after moving the used string literals. + */ + +void OutputLiteralPool (void); +/* Output the literal pool */ + +Literal* AddLiteral (const char* S); +/* Add a literal string to the literal pool. Return the literal. */ -void PrintLiteralStats (FILE* F); -/* Print statistics about the literal space used */ +Literal* AddLiteralBuf (const void* Buf, unsigned Len); +/* Add a buffer containing a literal string to the literal pool. Return the + * literal. + */ + +Literal* AddLiteralStr (const StrBuf* S); +/* Add a literal string to the literal pool. Return the literal. */ @@ -91,3 +134,4 @@ void PrintLiteralStats (FILE* F); +