mirror of
https://github.com/cc65/cc65.git
synced 2024-07-05 21:29:03 +00:00
Use a collection for the modules in a library.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4938 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
9023d0c6f2
commit
a214ccff92
@ -6,7 +6,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2010, Ullrich von Bassewitz */
|
/* (C) 1998-2011, Ullrich von Bassewitz */
|
||||||
/* Roemerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
@ -38,8 +38,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
/* common */
|
/* common */
|
||||||
|
#include "coll.h"
|
||||||
#include "exprdefs.h"
|
#include "exprdefs.h"
|
||||||
#include "filepos.h"
|
|
||||||
#include "libdefs.h"
|
#include "libdefs.h"
|
||||||
#include "objdefs.h"
|
#include "objdefs.h"
|
||||||
#include "symdefs.h"
|
#include "symdefs.h"
|
||||||
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Data */
|
/* Data */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
@ -69,8 +69,7 @@ struct Library {
|
|||||||
unsigned Name; /* String id of the name */
|
unsigned Name; /* String id of the name */
|
||||||
FILE* F; /* Open file stream */
|
FILE* F; /* Open file stream */
|
||||||
LibHeader Header; /* Library header */
|
LibHeader Header; /* Library header */
|
||||||
unsigned ModCount; /* Number of modules in the library */
|
Collection Modules; /* Modules */
|
||||||
ObjData** Modules; /* Modules */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* List of open libraries */
|
/* List of open libraries */
|
||||||
@ -97,8 +96,7 @@ static Library* NewLibrary (FILE* F, const char* Name)
|
|||||||
L->Next = 0;
|
L->Next = 0;
|
||||||
L->Name = GetStringId (Name);
|
L->Name = GetStringId (Name);
|
||||||
L->F = F;
|
L->F = F;
|
||||||
L->ModCount = 0;
|
L->Modules = EmptyCollection;
|
||||||
L->Modules = 0;
|
|
||||||
|
|
||||||
/* Return the new struct */
|
/* Return the new struct */
|
||||||
return L;
|
return L;
|
||||||
@ -115,7 +113,7 @@ static void FreeLibrary (Library* L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Free the module index */
|
/* Free the module index */
|
||||||
xfree (L->Modules);
|
DoneCollection (&L->Modules);
|
||||||
|
|
||||||
/* Free the library structure */
|
/* Free the library structure */
|
||||||
xfree (L);
|
xfree (L);
|
||||||
@ -228,18 +226,18 @@ static ObjData* ReadIndexEntry (Library* L)
|
|||||||
static void LibReadIndex (Library* L)
|
static void LibReadIndex (Library* L)
|
||||||
/* Read the index of a library file */
|
/* Read the index of a library file */
|
||||||
{
|
{
|
||||||
unsigned I;
|
unsigned ModuleCount;
|
||||||
|
|
||||||
/* Seek to the start of the index */
|
/* Seek to the start of the index */
|
||||||
LibSeek (L, L->Header.IndexOffs);
|
LibSeek (L, L->Header.IndexOffs);
|
||||||
|
|
||||||
/* Read the object file count and allocate memory */
|
/* Read the object file count and allocate memory */
|
||||||
L->ModCount = ReadVar (L->F);
|
ModuleCount = ReadVar (L->F);
|
||||||
L->Modules = xmalloc (L->ModCount * sizeof (L->Modules[0]));
|
CollGrow (&L->Modules, ModuleCount);
|
||||||
|
|
||||||
/* Read all entries in the index */
|
/* Read all entries in the index */
|
||||||
for (I = 0; I < L->ModCount; ++I) {
|
while (ModuleCount--) {
|
||||||
L->Modules[I] = ReadIndexEntry (L);
|
CollAppend (&L->Modules, ReadIndexEntry (L));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,10 +311,10 @@ static void LibResolve (void)
|
|||||||
* module if there are unresolved externals in existing modules
|
* module if there are unresolved externals in existing modules
|
||||||
* that may be resolved by adding the module.
|
* that may be resolved by adding the module.
|
||||||
*/
|
*/
|
||||||
for (J = 0; J < L->ModCount; ++J) {
|
for (J = 0; J < CollCount (&L->Modules); ++J) {
|
||||||
|
|
||||||
/* Get the next module */
|
/* Get the next module */
|
||||||
ObjData* O = L->Modules[J];
|
ObjData* O = CollAtUnchecked (&L->Modules, J);
|
||||||
|
|
||||||
/* We only need to check this module if it wasn't added before */
|
/* We only need to check this module if it wasn't added before */
|
||||||
if ((O->Flags & OBJ_REF) == 0) {
|
if ((O->Flags & OBJ_REF) == 0) {
|
||||||
@ -343,10 +341,10 @@ static void LibResolve (void)
|
|||||||
/* Walk over all modules in this library and add the files list and
|
/* Walk over all modules in this library and add the files list and
|
||||||
* sections for all referenced modules.
|
* sections for all referenced modules.
|
||||||
*/
|
*/
|
||||||
for (J = 0; J < L->ModCount; ++J) {
|
for (J = 0; J < CollCount (&L->Modules); ++J) {
|
||||||
|
|
||||||
/* Get the object data */
|
/* Get the object data */
|
||||||
ObjData* O = L->Modules[J];
|
ObjData* O = CollAtUnchecked (&L->Modules, J);
|
||||||
|
|
||||||
/* Is this object file referenced? */
|
/* Is this object file referenced? */
|
||||||
if (O->Flags & OBJ_REF) {
|
if (O->Flags & OBJ_REF) {
|
||||||
|
Loading…
Reference in New Issue
Block a user