X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fcodelab.c;h=9e3b93765f64ebf69b57dd13a45433e4d7b1ec6d;hb=8dd3cc35dcbd7155812e6a7c01039573aff640cb;hp=89b45b0e6d4d9a0fb45699aad9460ea584fa11db;hpb=989aacec2c0a5aa83b7c719d1f5292c8cd0183df;p=cc65 diff --git a/src/cc65/codelab.c b/src/cc65/codelab.c index 89b45b0e6..9e3b93765 100644 --- a/src/cc65/codelab.c +++ b/src/cc65/codelab.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2001 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ +/* (C) 2001-2009, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -40,6 +40,7 @@ /* cc65 */ #include "codeent.h" #include "codelab.h" +#include "output.h" @@ -59,7 +60,6 @@ CodeLabel* NewCodeLabel (const char* Name, unsigned Hash) L->Next = 0; L->Name = xstrdup (Name); L->Hash = Hash; - L->Flags = 0; L->Owner = 0; InitCollection (&L->JumpFrom); @@ -84,33 +84,36 @@ void FreeCodeLabel (CodeLabel* L) -void AddLabelRef (CodeLabel* L, struct CodeEntry* E) +void CL_AddRef (CodeLabel* L, struct CodeEntry* E) /* Let the CodeEntry E reference the label L */ { /* The insn at E jumps to this label */ E->JumpTo = L; + /* Replace the code entry argument with the name of the new label */ + CE_SetArg (E, L->Name); + /* Remember that in the label */ CollAppend (&L->JumpFrom, E); } -void MoveLabelRefs (CodeLabel* OldLabel, CodeLabel* NewLabel) +void CL_MoveRefs (CodeLabel* OldLabel, CodeLabel* NewLabel) /* Move all references to OldLabel to point to NewLabel. OldLabel will have no * more references on return. */ { /* Walk through all instructions referencing the old label */ - unsigned Count = CollCount (&OldLabel->JumpFrom); + unsigned Count = CL_GetRefCount (OldLabel); while (Count--) { /* Get the instruction that references the old label */ - CodeEntry* E = CollAt (&OldLabel->JumpFrom, Count); + CodeEntry* E = CL_GetRef (OldLabel, Count); /* Change the reference to the new label */ CHECK (E->JumpTo == OldLabel); - AddLabelRef (NewLabel, E); + CL_AddRef (NewLabel, E); } @@ -120,11 +123,16 @@ void MoveLabelRefs (CodeLabel* OldLabel, CodeLabel* NewLabel) -void OutputCodeLabel (const CodeLabel* L, FILE* F) -/* Output the code label to a file */ +void CL_Output (const CodeLabel* L) +/* Output the code label to the output file */ { - fprintf (F, "%s:", L->Name); + WriteOutput ("%s:", L->Name); + if (strlen (L->Name) > 6) { + /* Label is too long, add a linefeed */ + WriteOutput ("\n"); + } } +