/* */
/* */
/* */
-/* (C) 2001-2008 Ullrich von Bassewitz */
-/* Roemerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 2001-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
unsigned I, J;
/* Output the files section */
- for (I = 0; I < O->FileCount; ++I) {
- const FileInfo* FI = O->Files[I];
+ for (I = 0; I < CollCount (&O->Files); ++I) {
+ const FileInfo* FI = CollConstAt (&O->Files, I);
fprintf (F, "file\t\"%s\",size=%lu,mtime=0x%08lX\n",
GetString (FI->Name), FI->Size, FI->MTime);
}
/* Output the line infos */
- for (I = 0; I < O->LineInfoCount; ++I) {
+ for (I = 0; I < CollCount (&O->LineInfos); ++I) {
/* Get this line info */
- const LineInfo* LI = O->LineInfos[I];
+ const LineInfo* LI = CollConstAt (&O->LineInfos, I);
/* Get a pointer to the code ranges */
const Collection* CodeRanges = &LI->CodeRanges;
/* */
/* */
/* */
-/* (C) 1998-2008 Ullrich von Bassewitz */
-/* Roemerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
D->Flags = 0;
D->Obj = O;
D->Expr = 0;
- D->Name = 0;
+ D->Name = 0;
D->Type = Type;
D->AddrSize = AddrSize;
{
/* Create the hash. We hash over the symbol value */
unsigned Hash = ((Val >> 24) & 0xFF) ^
- ((Val >> 16) & 0xFF) ^
- ((Val >> 8) & 0xFF) ^
- ((Val >> 0) & 0xFF);
+ ((Val >> 16) & 0xFF) ^
+ ((Val >> 8) & 0xFF) ^
+ ((Val >> 0) & 0xFF);
/* Check for this symbol */
DbgSym* Sym = DbgSymPool[Hash];
-long GetDbgSymVal (DbgSym* D)
+long GetDbgSymVal (const DbgSym* D)
/* Get the value of this symbol */
{
CHECK (D->Expr != 0);
unsigned I;
/* Walk through all debug symbols in this module */
- for (I = 0; I < O->DbgSymCount; ++I) {
+ for (I = 0; I < CollCount (&O->DbgSyms); ++I) {
long Val;
/* Get the next debug symbol */
- DbgSym* D = O->DbgSyms [I];
+ DbgSym* D = CollAt (&O->DbgSyms, I);
/* Get the symbol value */
Val = GetDbgSymVal (D);
unsigned I;
/* Walk through all debug symbols in this module */
- for (I = 0; I < O->DbgSymCount; ++I) {
+ for (I = 0; I < CollCount (&O->DbgSyms); ++I) {
long Val;
/* Get the next debug symbol */
- DbgSym* D = O->DbgSyms [I];
+ DbgSym* D = CollAt (&O->DbgSyms, I);
/* Emit this symbol only if it is a label (ignore equates) */
if (IS_EXP_EQUATE (D->Type)) {
DbgSym* ReadDbgSym (FILE* F, ObjData* Obj);
/* Read a debug symbol from a file, insert and return it */
-long GetDbgSymVal (DbgSym* D);
+long GetDbgSymVal (const DbgSym* D);
/* Get the value of this symbol */
void ClearDbgSymTable (void);
/* */
/* */
/* */
-/* (C) 1998-2007 Ullrich von Bassewitz */
-/* Roemerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
PRECONDITION (Expr->Op == EXPR_SYMBOL);
/* Return the import */
- return Expr->Obj->Imports [Expr->V.ImpNum];
+ return CollAt (&Expr->Obj->Imports, Expr->V.ImpNum);
}
/* Check that this is really a symbol */
PRECONDITION (Expr->Op == EXPR_SYMBOL);
- /* Return the export */
- return Expr->Obj->Imports [Expr->V.ImpNum]->Exp;
+ /* Return the export for an import*/
+ return GetExprImport (Expr)->Exp;
}
*/
if (Expr->Obj) {
/* Return the export */
- return Expr->Obj->Sections[Expr->V.SegNum];
+ return CollAt (&Expr->Obj->Sections, Expr->V.SegNum);
} else {
return Expr->V.Sec;
}
case EXPR_BOOLXOR:
return (GetExprVal (Expr->Left) != 0) ^ (GetExprVal (Expr->Right) != 0);
-
+
case EXPR_MAX:
Left = GetExprVal (Expr->Left);
Right = GetExprVal (Expr->Right);
/* */
/* */
/* */
-/* (C) 1998-2005 Ullrich von Bassewitz */
-/* Römerstraße 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
unsigned I;
/* Check all exports */
- for (I = 0; I < O->ExportCount; ++I) {
- if (IsUnresolved (O->Exports[I]->Name)) {
- /* We need this module */
- O->Flags |= OBJ_REF; break;
+ for (I = 0; I < CollCount (&O->Exports); ++I) {
+ const Export* E = CollConstAt (&O->Exports, I);
+ if (IsUnresolved (E->Name)) {
+ /* We need this module, insert the imports and exports */
+ O->Flags |= OBJ_REF;
+ InsertObjGlobals (O);
+ break;
}
}
-
- /* If we need this module, insert the imports and exports */
- if (O->Flags & OBJ_REF) {
- InsertObjGlobals (O);
- }
}
/* */
/* */
/* */
-/* (C) 2001 Ullrich von Bassewitz */
-/* Römerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 2001-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
ReadFilePos (F, &LI->Pos);
/* Resolve the file index to a pointer to FileInfo struct */
- CHECK (LI->Pos.Name < O->FileCount);
- LI->File = O->Files[LI->Pos.Name];
+ CHECK (LI->Pos.Name < CollCount (&O->Files));
+ LI->File = CollAt (&O->Files, LI->Pos.Name);
/* Return the new LineInfo */
return LI;
+
/* */
/* */
/* */
-/* (C) 1998-2005 Ullrich von Bassewitz */
-/* Römerstraße 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
} else {
fprintf (F, "%s:\n", GetObjFileName (O));
}
- for (J = 0; J < O->SectionCount; ++J) {
- const Section* S = O->Sections [J];
+ for (J = 0; J < CollCount (&O->Sections); ++J) {
+ const Section* S = CollConstAt (&O->Sections, J);
/* Don't include zero sized sections if not explicitly
* requested
*/
/* */
/* */
/* */
-/* (C) 1998-2003 Ullrich von Bassewitz */
-/* Römerstraße 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/*****************************************************************************/
-/* Data */
+/* Data */
/*****************************************************************************/
/*****************************************************************************/
-/* Code */
+/* Code */
/*****************************************************************************/
O->Flags = 0;
O->Start = 0;
O->ExportCount = 0;
- O->Exports = 0;
+ O->Exports = EmptyCollection;
O->ImportCount = 0;
- O->Imports = 0;
+ O->Imports = EmptyCollection;
O->DbgSymCount = 0;
- O->DbgSyms = 0;
+ O->DbgSyms = EmptyCollection;
O->LineInfoCount = 0;
- O->LineInfos = 0;
+ O->LineInfos = EmptyCollection;
O->StringCount = 0;
O->Strings = 0;
O->AssertionCount = 0;
- O->Assertions = 0;
+ O->Assertions = EmptyCollection;
O->ScopeCount = 0;
- O->Scopes = 0;
+ O->Scopes = EmptyCollection;
/* Return the new entry */
return O;
* referenced.
*/
{
+ unsigned I;
+
/* Unused ObjData do only have the string pool, Exports and Imports. */
- while (O->ExportCount) {
- FreeExport (O->Exports[--O->ExportCount]);
+ for (I = 0; I < CollCount (&O->Exports); ++I) {
+ FreeExport (CollAt (&O->Exports, I));
}
- xfree (O->Exports);
- while (O->ImportCount) {
- FreeImport (O->Imports[--O->ImportCount]);
+ DoneCollection (&O->Exports);
+ for (I = 0; I < CollCount (&O->Imports); ++I) {
+ FreeImport (CollAt (&O->Imports, I));
}
- xfree (O->Imports);
+ DoneCollection (&O->Imports);
+ DoneCollection (&O->DbgSyms);
+ DoneCollection (&O->LineInfos);
xfree (O->Strings);
+ DoneCollection (&O->Assertions);
+ DoneCollection (&O->Scopes);
xfree (O);
}
unsigned I;
/* Insert exports and imports */
- for (I = 0; I < O->ExportCount; ++I) {
- InsertExport (O->Exports[I]);
+ for (I = 0; I < CollCount (&O->Exports); ++I) {
+ InsertExport (CollAt (&O->Exports, I));
}
- for (I = 0; I < O->ImportCount; ++I) {
- InsertImport (O->Imports[I]);
+ for (I = 0; I < CollCount (&O->Imports); ++I) {
+ InsertImport (CollAt (&O->Imports, I));
}
}
} else {
/* Check the parameter */
- if (Index >= O->FileCount) {
+ if (Index >= CollCount (&O->Files)) {
/* Error() will terminate the program */
Warning ("Invalid file index (%u) in module `%s' (input file corrupt?)",
Index, GetObjFileName (O));
return "[invalid]"; /* ### */
- }
- /* Return the name */
- return GetString (O->Files[Index]->Name);
+ } else {
+ /* Get a pointer to the file info struct */
+ const FileInfo* FI = CollAt (&O->Files, Index);
+
+ /* Return the name */
+ return GetString (FI->Name);
+
+ }
}
}
/* */
/* */
/* */
-/* (C) 1998-2003 Ullrich von Bassewitz */
-/* Römerstraße 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
unsigned long Start; /* Start offset of data in library */
unsigned Flags;
unsigned FileCount; /* Input file count */
- struct FileInfo** Files; /* List of input files */
+ Collection Files; /* List of input files */
unsigned SectionCount; /* Count of sections in this object */
- struct Section** Sections; /* List of all sections */
+ Collection Sections; /* List of all sections */
unsigned ExportCount; /* Count of exports */
- struct Export** Exports; /* List of all exports */
+ Collection Exports; /* List of all exports */
unsigned ImportCount; /* Count of imports */
- struct Import** Imports; /* List of all imports */
+ Collection Imports; /* List of all imports */
unsigned DbgSymCount; /* Count of debug symbols */
- struct DbgSym** DbgSyms; /* List of debug symbols */
+ Collection DbgSyms; /* List of debug symbols */
unsigned LineInfoCount; /* Count of additional line infos */
- struct LineInfo** LineInfos; /* List of additional line infos */
+ Collection LineInfos; /* List of additional line infos */
unsigned StringCount; /* Count of strings */
unsigned* Strings; /* List of global string indices */
unsigned AssertionCount; /* Count of module assertions */
- struct Assertion** Assertions; /* List of module assertions */
+ Collection Assertions; /* List of module assertions */
unsigned ScopeCount; /* Count of scopes */
- struct Scope** Scopes; /* List of scopes */
+ Collection Scopes; /* List of scopes */
};
INLINE int ObjHasFiles (const ObjData* O)
/* Return true if the files list does exist */
{
- return (O != 0 && O->Files != 0);
+ return (O != 0 && CollCount (&O->Files) != 0);
}
#else
-# define ObjHasFiles(O) ((O) != 0 && (O)->Files != 0)
+# define ObjHasFiles(O) ((O) != 0 && CollCount ((O)->Files) != 0)
#endif
const char* GetSourceFileName (const ObjData* O, unsigned Index);
/* */
/* */
/* */
-/* (C) 1998-2003 Ullrich von Bassewitz */
-/* Römerstraße 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* Read the data */
O->FileCount = ReadVar (F);
- O->Files = xmalloc (O->FileCount * sizeof (O->Files[0]));
+ CollGrow (&O->Files, O->FileCount);
for (I = 0; I < O->FileCount; ++I) {
- O->Files[I] = ReadFileInfo (F, O);
+ CollAppend (&O->Files, ReadFileInfo (F, O));
}
}
/* Read the data */
O->SectionCount = ReadVar (F);
- O->Sections = xmalloc (O->SectionCount * sizeof (O->Sections[0]));
+ CollGrow (&O->Sections, O->SectionCount);
for (I = 0; I < O->SectionCount; ++I) {
- O->Sections [I] = ReadSection (F, O);
+ CollAppend (&O->Sections, ReadSection (F, O));
}
}
/* Read the data */
O->ImportCount = ReadVar (F);
- O->Imports = xmalloc (O->ImportCount * sizeof (O->Imports[0]));
+ CollGrow (&O->Imports, O->ImportCount);
for (I = 0; I < O->ImportCount; ++I) {
- O->Imports [I] = ReadImport (F, O);
+ CollAppend (&O->Imports, ReadImport (F, O));
}
}
/* Read the data */
O->ExportCount = ReadVar (F);
- O->Exports = xmalloc (O->ExportCount * sizeof (O->Exports[0]));
+ CollGrow (&O->Exports, O->ExportCount);
for (I = 0; I < O->ExportCount; ++I) {
- O->Exports [I] = ReadExport (F, O);
+ CollAppend (&O->Exports, ReadExport (F, O));
}
}
/* Read the data */
O->DbgSymCount = ReadVar (F);
- O->DbgSyms = xmalloc (O->DbgSymCount * sizeof (O->DbgSyms[0]));
+ CollGrow (&O->DbgSyms, O->DbgSymCount);
for (I = 0; I < O->DbgSymCount; ++I) {
- O->DbgSyms [I] = ReadDbgSym (F, O);
+ CollAppend (&O->DbgSyms, ReadDbgSym (F, O));
}
}
/* Read the data */
O->LineInfoCount = ReadVar (F);
- O->LineInfos = xmalloc (O->LineInfoCount * sizeof (O->LineInfos[0]));
+ CollGrow (&O->LineInfos, O->LineInfoCount);
for (I = 0; I < O->LineInfoCount; ++I) {
- O->LineInfos[I] = ReadLineInfo (F, O);
+ CollAppend (&O->LineInfos, ReadLineInfo (F, O));
}
}
/* Read the data */
O->AssertionCount = ReadVar (F);
- O->Assertions = xmalloc (O->AssertionCount * sizeof (O->Assertions[0]));
+ CollGrow (&O->Assertions, O->AssertionCount);
for (I = 0; I < O->AssertionCount; ++I) {
- O->Assertions[I] = ReadAssertion (F, O);
+ CollAppend (&O->Assertions, ReadAssertion (F, O));
}
}
/* Read the data */
O->ScopeCount = ReadVar (F);
- O->Scopes = xmalloc (O->ScopeCount * sizeof (O->Scopes[0]));
+ CollGrow (&O->Scopes, O->ScopeCount);
for (I = 0; I < O->ScopeCount; ++I) {
- O->Scopes[I] = 0; /* ReadScope (F, O); ### not implemented */
+ CollAppend (&O->Scopes, 0); /* ReadScope (F, O); ### not implemented */
}
}
/* */
/* */
/* */
-/* (C) 1998-2003 Ullrich von Bassewitz */
-/* Römerstraße 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
LineInfoIndex = ReadVar (F);
if (LineInfoIndex) {
--LineInfoIndex;
- if (LineInfoIndex >= O->LineInfoCount) {
+ if (LineInfoIndex >= CollCount (&O->LineInfos)) {
Internal ("In module `%s', file `%s', line %lu: Invalid line "
"info with index %u (max count %u)",
GetObjFileName (O),
GetSourceFileName (O, Frag->Pos.Name),
- Frag->Pos.Line, LineInfoIndex, O->LineInfoCount);
+ Frag->Pos.Line, LineInfoIndex,
+ CollCount (&O->LineInfos));
}
/* Point from the fragment to the line info... */
- Frag->LI = O->LineInfos[LineInfoIndex];
+ Frag->LI = CollAt (&O->LineInfos, LineInfoIndex);
/* ...and back from the line info to the fragment */
CollAppend (&Frag->LI->Fragments, Frag);
}