Do not resolve the lists of spans for LineInfos and Scopes, but keep them as

ids. This way, we can delay loading spans until we know that we definitely
need an object file. 
Did some restructuring for writing of span lists to the debug info file.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5261 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2011-08-22 17:36:19 +00:00
parent ecfba0c9b0
commit fda7934e68
8 changed files with 67 additions and 56 deletions

View File

@@ -100,19 +100,32 @@ Span* ReadSpan (FILE* F, ObjData* O, unsigned Id)
void ReadSpanList (Collection* Spans, FILE* F, ObjData* O)
/* Read a list of span ids from a file and return the spans for the ids */
unsigned* ReadSpanList (FILE* F)
/* Read a list of span ids from a file. The list is returned as an array of
* unsigneds, the first being the number of spans (never zero) followed by
* the span ids. If the number of spans is zero, NULL is returned.
*/
{
unsigned* Spans;
/* First is number of Spans */
unsigned Count = ReadVar (F);
if (Count == 0) {
return 0;
}
/* Preallocate enough entries in the collection */
CollGrow (Spans, Count);
/* Allocate memory for the list and set the count */
Spans = xmalloc ((Count + 1) * sizeof (*Spans));
*Spans = Count;
/* Read the spans and add them */
while (Count--) {
CollAppend (Spans, CollAt (&O->Spans, ReadVar (F)));
while (Count) {
Spans[Count] = ReadVar (F);
--Count;
}
/* Return the list */
return Spans;
}
@@ -126,14 +139,6 @@ void FreeSpan (Span* S)
unsigned SpanId (const struct ObjData* O, const Span* S)
/* Return the global id of a span */
{
return O->SpanBaseId + S->Id;
}
unsigned SpanCount (void)
/* Return the total number of spans */
{
@@ -154,6 +159,24 @@ unsigned SpanCount (void)
void PrintDbgSpanList (FILE* F, const ObjData* O, const unsigned* List)
/* Output a string ",span=x[+y...]" for the given list. If the list is empty
* or NULL, output nothing. This is a helper function for other modules to
* print a list of spans read by ReadSpanList to the debug info file.
*/
{
if (List && *List) {
unsigned I;
const char* Format = ",span=%u";
for (I = 0; I < *List; ++I) {
fprintf (F, Format, O->SpanBaseId + List[I+1]);
Format = "+%u";
}
}
}
void PrintDbgSpans (FILE* F)
/* Output the spans to a debug info file */
{