/*****************************************************************************/
/* */
-/* 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 */
+#include <stdio.h>
+
+/* 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. */
+