void MakeLineInfoIndex (void)
/* Sort the line infos and drop all unreferenced ones */
{
+ unsigned I;
+
/* Sort the collection */
CollSort (&LineInfoColl, CmpLineInfo, 0);
+
+ /* Walk over the list and index the line infos. */
+ for (I = 0; I < LineInfoValid; ++I) {
+ /* Get a pointer to this line info */
+ LineInfo* LI = CollAtUnchecked (&LineInfoColl, I);
+ LI->Index = I;
+ }
}
ObjWriteVar (0);
}
+
+ /* End of line infos */
+ ObjEndLineInfos ();
}
/* Write one segment to the object file */
{
Fragment* Frag;
- Fragment* F;
- unsigned long Size;
unsigned LineInfoIndex;
/* Write the segment name followed by the byte count in this segment */
switch (Frag->Type) {
case FRAG_LITERAL:
- /* To make the object file somewhat smaller, write all literal
- * data of this and the following fragments preceeded by the
- * length.
- */
- F = Frag;
- Size = 0;
- while (F && F->Type == FRAG_LITERAL) {
- Size += F->Len;
- F = F->Next;
- }
ObjWrite8 (FRAG_LITERAL);
- ObjWriteVar (Size);
-
- /* Now write the literal data */
- F = Frag;
- while (F && F->Type == FRAG_LITERAL) {
- ObjWriteData (F->V.Data, F->Len);
- Frag = F;
- F = F->Next;
- }
+ ObjWriteVar (Frag->Len);
+ ObjWriteData (Frag->V.Data, Frag->Len);
break;
case FRAG_EXPR:
/* Write extra line info for this fragment. Zero is considered
* "no line info", so add one to the value.
- */
+ */
LineInfoIndex = Frag->LI? Frag->LI->Index + 1 : 0;
ObjWriteVar (LineInfoIndex);