1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-09 01:28:58 +00:00

Convert imports, exports and debug symbols to use and write line infos instead

of embedded file positions.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4918 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2011-01-25 16:27:17 +00:00
parent f3487b7c0f
commit 5b79d7e685
3 changed files with 47 additions and 38 deletions

View File

@ -86,7 +86,8 @@ SymEntry* NewSymEntry (const StrBuf* Name, unsigned Flags)
S->Right = 0; S->Right = 0;
S->Locals = 0; S->Locals = 0;
S->Sym.Tab = 0; S->Sym.Tab = 0;
S->Pos = CurTok.Pos; S->LineInfos = EmptyCollection;
GetFullLineInfo (&S->LineInfos);
for (I = 0; I < sizeof (S->GuessedUse) / sizeof (S->GuessedUse[0]); ++I) { for (I = 0; I < sizeof (S->GuessedUse) / sizeof (S->GuessedUse[0]); ++I) {
S->GuessedUse[I] = 0; S->GuessedUse[I] = 0;
} }
@ -693,3 +694,12 @@ unsigned GetSymInfoFlags (const SymEntry* S, long* ConstVal)
const FilePos* GetSymPos (const SymEntry* S)
/* Return the position of first occurence in the source for the given symbol */
{
/* The actual source entry is in slot zero */
return &((const LineInfo*) CollConstAt (&S->LineInfos, 0))->Pos;
}

View File

@ -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 */
@ -86,7 +86,7 @@ struct SymEntry {
struct SymTable* Tab; /* Table this symbol is in */ struct SymTable* Tab; /* Table this symbol is in */
struct SymEntry* Entry; struct SymEntry* Entry;
} Sym; } Sym;
FilePos Pos; /* File position for this symbol */ Collection LineInfos; /* Line infos for this symbol */
FilePos* GuessedUse[1]; /* File position where symbol FilePos* GuessedUse[1]; /* File position where symbol
* address size was guessed, and the * address size was guessed, and the
* smallest possible addressing was NOT * smallest possible addressing was NOT
@ -345,15 +345,8 @@ unsigned GetSymInfoFlags (const SymEntry* Sym, long* ConstVal);
* See common/symdefs.h for more information. * See common/symdefs.h for more information.
*/ */
#if defined(HAVE_INLINE) const FilePos* GetSymPos (const SymEntry* S);
INLINE const FilePos* GetSymPos (const SymEntry* S)
/* Return the position of first occurence in the source for the given symbol */ /* Return the position of first occurence in the source for the given symbol */
{
return &S->Pos;
}
#else
# define GetSymPos(S) (&(S)->Pos)
#endif

View File

@ -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 */
@ -458,14 +458,16 @@ static void SymCheckUndefined (SymEntry* S)
if (S->Flags & SF_EXPORT) { if (S->Flags & SF_EXPORT) {
if (Sym->Flags & SF_IMPORT) { if (Sym->Flags & SF_IMPORT) {
/* The symbol is already marked as import */ /* The symbol is already marked as import */
PError (&S->Pos, "Symbol `%s' is already an import", LIError (&S->LineInfos,
GetString (Sym->Name)); "Symbol `%s' is already an import",
GetString (Sym->Name));
} }
if (Sym->Flags & SF_EXPORT) { if (Sym->Flags & SF_EXPORT) {
/* The symbol is already marked as an export. */ /* The symbol is already marked as an export. */
if (Sym->AddrSize > S->ExportSize) { if (Sym->AddrSize > S->ExportSize) {
/* We're exporting a symbol smaller than it actually is */ /* We're exporting a symbol smaller than it actually is */
PWarning (&S->Pos, 1, "Symbol `%m%p' is %s but exported %s", LIWarning (&S->LineInfos, 1,
"Symbol `%m%p' is %s but exported %s",
GetSymName (Sym), GetSymName (Sym),
AddrSizeToStr (Sym->AddrSize), AddrSizeToStr (Sym->AddrSize),
AddrSizeToStr (S->ExportSize)); AddrSizeToStr (S->ExportSize));
@ -480,10 +482,11 @@ static void SymCheckUndefined (SymEntry* S)
} }
if (Sym->AddrSize > Sym->ExportSize) { if (Sym->AddrSize > Sym->ExportSize) {
/* We're exporting a symbol smaller than it actually is */ /* We're exporting a symbol smaller than it actually is */
PWarning (&S->Pos, 1, "Symbol `%m%p' is %s but exported %s", LIWarning (&S->LineInfos, 1,
GetSymName (Sym), "Symbol `%m%p' is %s but exported %s",
AddrSizeToStr (Sym->AddrSize), GetSymName (Sym),
AddrSizeToStr (Sym->ExportSize)); AddrSizeToStr (Sym->AddrSize),
AddrSizeToStr (Sym->ExportSize));
} }
} }
} }
@ -499,8 +502,9 @@ static void SymCheckUndefined (SymEntry* S)
/* The symbol is definitely undefined */ /* The symbol is definitely undefined */
if (S->Flags & SF_EXPORT) { if (S->Flags & SF_EXPORT) {
/* We will not auto-import an export */ /* We will not auto-import an export */
PError (&S->Pos, "Exported symbol `%m%p' was never defined", LIError (&S->LineInfos,
GetSymName (S)); "Exported symbol `%m%p' was never defined",
GetSymName (S));
} else { } else {
if (AutoImport) { if (AutoImport) {
/* Mark as import, will be indexed later */ /* Mark as import, will be indexed later */
@ -509,7 +513,9 @@ static void SymCheckUndefined (SymEntry* S)
S->AddrSize = CodeAddrSize; S->AddrSize = CodeAddrSize;
} else { } else {
/* Error */ /* Error */
PError (&S->Pos, "Symbol `%m%p' is undefined", GetSymName (S)); LIError (&S->LineInfos,
"Symbol `%m%p' is undefined",
GetSymName (S));
} }
} }
} }
@ -567,9 +573,9 @@ void SymCheck (void)
if ((S->Flags & SF_DEFINED) != 0 && (S->Flags & SF_REFERENCED) == 0) { if ((S->Flags & SF_DEFINED) != 0 && (S->Flags & SF_REFERENCED) == 0) {
const StrBuf* Name = GetStrBuf (S->Name); const StrBuf* Name = GetStrBuf (S->Name);
if (SB_At (Name, 0) != '.') { /* Ignore internals */ if (SB_At (Name, 0) != '.') { /* Ignore internals */
PWarning (&S->Pos, 2, LIWarning (&S->LineInfos, 2,
"Symbol `%m%p' is defined but never used", "Symbol `%m%p' is defined but never used",
GetSymName (S)); GetSymName (S));
} }
} }
@ -577,9 +583,9 @@ void SymCheck (void)
if (S->Flags & SF_IMPORT) { if (S->Flags & SF_IMPORT) {
if ((S->Flags & (SF_REFERENCED | SF_FORCED)) == SF_NONE) { if ((S->Flags & (SF_REFERENCED | SF_FORCED)) == SF_NONE) {
/* Imported symbol is not referenced */ /* Imported symbol is not referenced */
PWarning (&S->Pos, 2, LIWarning (&S->LineInfos, 2,
"Symbol `%m%p' is imported but never used", "Symbol `%m%p' is imported but never used",
GetSymName (S)); GetSymName (S));
} else { } else {
/* Give the import an id, count imports */ /* Give the import an id, count imports */
S->ImportId = ImportCount++; S->ImportId = ImportCount++;
@ -605,11 +611,11 @@ void SymCheck (void)
S->ExportSize = S->AddrSize; S->ExportSize = S->AddrSize;
} else if (S->AddrSize > S->ExportSize) { } else if (S->AddrSize > S->ExportSize) {
/* We're exporting a symbol smaller than it actually is */ /* We're exporting a symbol smaller than it actually is */
PWarning (&S->Pos, 1, LIWarning (&S->LineInfos, 1,
"Symbol `%m%p' is %s but exported %s", "Symbol `%m%p' is %s but exported %s",
GetSymName (S), GetSymName (S),
AddrSizeToStr (S->AddrSize), AddrSizeToStr (S->AddrSize),
AddrSizeToStr (S->ExportSize)); AddrSizeToStr (S->ExportSize));
} }
} }
ED_Done (&ED); ED_Done (&ED);
@ -689,7 +695,7 @@ void WriteImports (void)
ObjWrite8 (S->AddrSize); ObjWrite8 (S->AddrSize);
ObjWriteVar (S->Name); ObjWriteVar (S->Name);
ObjWritePos (&S->Pos); WriteLineInfo (&S->LineInfos);
} }
S = S->List; S = S->List;
} }
@ -754,8 +760,8 @@ void WriteExports (void)
WriteExpr (S->Expr); WriteExpr (S->Expr);
} }
/* Write the source file position */ /* Write the line infos */
ObjWritePos (&S->Pos); WriteLineInfo (&S->LineInfos);
} }
S = S->List; S = S->List;
} }
@ -818,8 +824,8 @@ void WriteDbgSyms (void)
WriteExpr (S->Expr); WriteExpr (S->Expr);
} }
/* Write the source file position */ /* Write the line infos */
ObjWritePos (&S->Pos); WriteLineInfo (&S->LineInfos);
} }
S = S->List; S = S->List;
} }