1 /*****************************************************************************/
5 /* Literal string handling for the cc65 C compiler */
9 /* (C) 1998-2009, Ullrich von Bassewitz */
10 /* Roemerstrasse 52 */
11 /* D-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 /*****************************************************************************/
48 /*****************************************************************************/
50 /*****************************************************************************/
54 /* Forward for struct SymEntry */
57 /* Forward for a literal */
58 typedef struct Literal Literal;
60 /* Forward for a literal pool */
61 typedef struct LiteralPool LiteralPool;
65 /*****************************************************************************/
67 /*****************************************************************************/
71 Literal* UseLiteral (Literal* L);
72 /* Increase the reference counter for the literal and return it */
74 void ReleaseLiteral (Literal* L);
75 /* Decrement the reference counter for the literal */
77 void TranslateLiteral (Literal* L);
78 /* Translate a literal into the target charset. */
80 unsigned GetLiteralLabel (const Literal* L);
81 /* Return the asm label for a literal */
83 const char* GetLiteralStr (const Literal* L);
84 /* Return the data for a literal as pointer to char */
86 const StrBuf* GetLiteralStrBuf (const Literal* L);
87 /* Return the data for a literal as pointer to the string buffer */
89 unsigned GetLiteralSize (const Literal* L);
90 /* Get the size of a literal string */
94 /*****************************************************************************/
96 /*****************************************************************************/
100 void InitLiteralPool (void);
101 /* Initialize the literal pool */
103 void PushLiteralPool (struct SymEntry* Func);
104 /* Push the current literal pool onto the stack and create a new one */
106 LiteralPool* PopLiteralPool (void);
107 /* Pop the last literal pool from TOS and activate it. Return the old
111 void MoveLiteralPool (LiteralPool* LocalPool);
112 /* Move all referenced literals in LocalPool to the global literal pool. This
113 * function will free LocalPool after moving the used string literals.
116 void OutputLiteralPool (void);
117 /* Output the literal pool */
119 Literal* AddLiteral (const char* S);
120 /* Add a literal string to the literal pool. Return the literal. */
122 Literal* AddLiteralBuf (const void* Buf, unsigned Len);
123 /* Add a buffer containing a literal string to the literal pool. Return the
127 Literal* AddLiteralStr (const StrBuf* S);
128 /* Add a literal string to the literal pool. Return the literal. */
132 /* End of litpool.h */