1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-28 06:30:16 +00:00

Fixed Issue #1028 by outputing local literals when exiting the function scope.

This commit is contained in:
acqn 2020-06-01 01:28:59 +08:00 committed by Oliver Schmidt
parent 68f53e69f1
commit 07a5324a81
4 changed files with 23 additions and 19 deletions

View File

@ -453,7 +453,7 @@ void FinishCompile (void)
}
/* Output the literal pool */
OutputLiteralPool ();
OutputGlobalLiteralPool ();
/* Emit debug infos if enabled */
EmitDebugInfo ();

View File

@ -582,6 +582,11 @@ void NewFunc (SymEntry* Func)
/* Restore the old literal pool, remembering the one for the function */
Func->V.F.LitPool = PopLiteralPool ();
/* If --local-strings was given, output the literals now */
if (IS_Get (&LocalStrings)) {
OutputLocalLiteralPool (Func->V.F.LitPool);
}
/* Switch back to the old segments */
PopSegments ();

View File

@ -147,18 +147,6 @@ Literal* UseLiteral (Literal* L)
/* Increase the reference count */
++L->RefCount;
/* If --local-strings was given, immediately output the literal */
if (IS_Get (&LocalStrings)) {
/* Switch to the proper data segment */
if (IS_Get (&WritableStrings)) {
g_usedata ();
} else {
g_userodata ();
}
/* Output the literal */
OutputLiteral (L);
}
/* Return the literal */
return L;
}
@ -454,12 +442,20 @@ static void OutputReadOnlyLiterals (Collection* Literals)
void OutputLiteralPool (void)
/* Output the global literal pool */
void OutputLocalLiteralPool (LiteralPool* Pool)
/* Output the local literal pool */
{
/* Output both sorts of literals */
OutputWritableLiterals (&GlobalPool->WritableLiterals);
OutputReadOnlyLiterals (&GlobalPool->ReadOnlyLiterals);
OutputWritableLiterals (&Pool->WritableLiterals);
OutputReadOnlyLiterals (&Pool->ReadOnlyLiterals);
}
void OutputGlobalLiteralPool (void)
/* Output the global literal pool */
{
OutputLocalLiteralPool (GlobalPool);
}

View File

@ -113,8 +113,11 @@ void MoveLiteralPool (LiteralPool* LocalPool);
** function will free LocalPool after moving the used string literals.
*/
void OutputLiteralPool (void);
/* Output the literal pool */
void OutputLocalLiteralPool (LiteralPool* Pool);
/* Output the local literal pool */
void OutputGlobalLiteralPool (void);
/* Output the global literal pool */
Literal* AddLiteral (const char* S);
/* Add a literal string to the literal pool. Return the literal. */