#include "objfile.h"
#include "segment.h"
#include "span.h"
+#include "spool.h"
S->Seg = Seg;
S->Start = Start;
S->End = End;
- S->Type = 0;
+ S->Type = EMPTY_STRING_ID;
/* Return the new struct */
return S;
Span* E = HT_Find (&SpanTab, S);
if (E) {
/* If S has a type and E not, move the type */
- CHECK (E->Type == 0);
- E->Type = S->Type;
- S->Type = 0;
+ if (S->Type != EMPTY_STRING_ID) {
+ CHECK (E->Type == EMPTY_STRING_ID);
+ E->Type = S->Type;
+ }
+
/* Free S and return E */
FreeSpan (S);
return E;
+void SetSpanType (Span* S, const StrBuf* Type)
+/* Set the generic type of the span to Type */
+{
+ S->Type = GetStrBufId (Type);
+}
+
+
+
Span* OpenSpan (void)
/* Open a span for the active segment and return it. */
{
ObjWriteVar (S->Seg->Num);
ObjWriteVar (S->Start);
ObjWriteVar (S->End - S->Start);
+ ObjWriteVar (S->Type);
}
/* Free the collection with the spans */
#include "gentype.h"
#include "hashtab.h"
#include "inline.h"
+#include "strbuf.h"
# define GetSpanSize(R) ((R)->End - (R)->Start)
#endif
+void SetSpanType (Span* S, const StrBuf* Type);
+/* Set the generic type of the span to Type */
+
Span* OpenSpan (void);
/* Open a span for the active segment and return it. */
#include "objdata.h"
#include "segments.h"
#include "span.h"
+#include "spool.h"
unsigned Sec; /* Section id of this span */
unsigned long Offs; /* Offset of span within segment */
unsigned long Size; /* Size of span */
+ unsigned Type; /* Generic type of the data */
};
-static Span* NewSpan (unsigned Id, unsigned Sec, unsigned long Offs, unsigned long Size)
+static Span* NewSpan (unsigned Id)
/* Create and return a new span */
{
/* Allocate memory */
- Span* S = xmalloc (sizeof (*S));
+ Span* S = xmalloc (sizeof (Span));
- /* Initialize the fields */
+ /* Initialize the fields as necessary */
S->Id = Id;
- S->Sec = Sec;
- S->Offs = Offs;
- S->Size = Size;
/* Return the result */
return S;
-Span* ReadSpan (FILE* F, ObjData* O attribute ((unused)), unsigned Id)
+Span* ReadSpan (FILE* F, ObjData* O, unsigned Id)
/* Read a Span from a file and return it */
{
- /* Create a new Span and return it */
- unsigned SecId = ReadVar (F);
- unsigned long Offs = ReadVar (F);
- unsigned Size = ReadVar (F);
- return NewSpan (Id, SecId, Offs, Size);
+ /* Create a new Span and initialize it */
+ Span* S = NewSpan (Id);
+ S->Sec = ReadVar (F);
+ S->Offs = ReadVar (F);
+ S->Size = ReadVar (F);
+ S->Type = MakeGlobalStringId (O, ReadVar (F));
+
+ /* Return the new span */
+ return S;
}