/*****************************************************************************/
/* */
-/* symentry.c */
+/* symentry.c */
/* */
/* Symbol table entry for the ca65 macroassembler */
/* */
/*****************************************************************************/
-/* Data */
+/* Data */
/*****************************************************************************/
/*****************************************************************************/
-/* Code */
+/* Code */
/*****************************************************************************/
SymEntry* S = xmalloc (sizeof (SymEntry));
/* Initialize the entry */
- S->Left = 0;
- S->Right = 0;
- S->Locals = 0;
+ S->Left = 0;
+ S->Right = 0;
+ S->Locals = 0;
S->Sym.Tab = 0;
S->DefLines = EmptyCollection;
S->RefLines = EmptyCollection;
for (I = 0; I < sizeof (S->GuessedUse) / sizeof (S->GuessedUse[0]); ++I) {
S->GuessedUse[I] = 0;
}
- S->Flags = Flags;
+ S->HLLSym = 0;
+ S->Flags = Flags;
S->DebugSymId = ~0U;
S->ImportId = ~0U;
S->ExportId = ~0U;
{
/* Is there a tree? */
if (T == 0) {
- *E = 0;
- return 1;
+ *E = 0;
+ return 1;
}
/* We have a table, search it */
/* Get the symbol name */
const StrBuf* SymName = GetStrBuf (T->Name);
- /* Choose next entry */
+ /* Choose next entry */
int Cmp = SB_Compare (Name, SymName);
- if (Cmp < 0 && T->Left) {
- T = T->Left;
- } else if (Cmp > 0&& T->Right) {
- T = T->Right;
- } else {
- /* Found or end of search, return the result */
+ if (Cmp < 0 && T->Left) {
+ T = T->Left;
+ } else if (Cmp > 0 && T->Right) {
+ T = T->Right;
+ } else {
+ /* Found or end of search, return the result */
*E = T;
return Cmp;
- }
+ }
}
}
/* Define a new symbol */
{
if (S->Flags & SF_IMPORT) {
- /* Defined symbol is marked as imported external symbol */
- Error ("Symbol `%m%p' is already an import", GetSymName (S));
- return;
+ /* Defined symbol is marked as imported external symbol */
+ Error ("Symbol `%m%p' is already an import", GetSymName (S));
+ return;
}
if ((Flags & SF_VAR) != 0 && (S->Flags & (SF_EXPORT | SF_GLOBAL))) {
/* Variable symbols cannot be exports or globals */
return;
}
if (S->Flags & SF_DEFINED) {
- /* Multiple definition. In case of a variable, this is legal. */
+ /* Multiple definition. In case of a variable, this is legal. */
if ((S->Flags & SF_VAR) == 0) {
Error ("Symbol `%m%p' is already defined", GetSymName (S));
S->Flags |= SF_MULTDEF;
/* If this is not a local symbol, remember it as the last global one */
if ((S->Flags & SF_LOCAL) == 0) {
- SymLast = S;
+ SymLast = S;
}
}
/* Mark the given symbol as an imported symbol */
{
if (S->Flags & SF_DEFINED) {
- Error ("Symbol `%m%p' is already defined", GetSymName (S));
- S->Flags |= SF_MULTDEF;
- return;
+ Error ("Symbol `%m%p' is already defined", GetSymName (S));
+ S->Flags |= SF_MULTDEF;
+ return;
}
if (S->Flags & SF_EXPORT) {
- /* The symbol is already marked as exported symbol */
- Error ("Cannot import exported symbol `%m%p'", GetSymName (S));
- return;
+ /* The symbol is already marked as exported symbol */
+ Error ("Cannot import exported symbol `%m%p'", GetSymName (S));
+ return;
}
/* If no address size is given, use the address size of the enclosing
* then do silently remove the global flag.
*/
if (S->Flags & SF_IMPORT) {
- if ((Flags & SF_FORCED) != (S->Flags & SF_FORCED)) {
- Error ("Redeclaration mismatch for symbol `%m%p'", GetSymName (S));
- }
+ if ((Flags & SF_FORCED) != (S->Flags & SF_FORCED)) {
+ Error ("Redeclaration mismatch for symbol `%m%p'", GetSymName (S));
+ }
if (AddrSize != S->AddrSize) {
Error ("Address size mismatch for symbol `%m%p'", GetSymName (S));
}
S->Flags &= ~SF_GLOBAL;
if (AddrSize != S->AddrSize) {
Error ("Address size mismatch for symbol `%m%p'", GetSymName (S));
- }
+ }
}
/* Set the symbol data */
{
/* Check if it's ok to export the symbol */
if (S->Flags & SF_IMPORT) {
- /* The symbol is already marked as imported external symbol */
- Error ("Symbol `%m%p' is already an import", GetSymName (S));
- return;
+ /* The symbol is already marked as imported external symbol */
+ Error ("Symbol `%m%p' is already an import", GetSymName (S));
+ return;
}
if (S->Flags & SF_VAR) {
/* Variable symbols cannot be exported */
/* Set the symbol data */
S->Flags |= (SF_EXPORT | SF_REFERENCED | Flags);
+
+ /* Remember line info for this reference */
+ CollAppend (&S->RefLines, GetAsmLineInfo ());
}
/* Check for errors */
if (S->Flags & SF_IMPORT) {
- /* The symbol is already marked as imported external symbol */
- Error ("Symbol `%m%p' is already an import", GetSymName (S));
- return;
+ /* The symbol is already marked as imported external symbol */
+ Error ("Symbol `%m%p' is already an import", GetSymName (S));
+ return;
}
if (S->Flags & SF_VAR) {
/* Variable symbols cannot be exported or imported */
* priority value is the same as the old one.
*/
if (S->ConDesPrio[Type] != CD_PRIO_NONE) {
- if (S->ConDesPrio[Type] != Prio) {
- Error ("Redeclaration mismatch for symbol `%m%p'", GetSymName (S));
- }
+ if (S->ConDesPrio[Type] != Prio) {
+ Error ("Redeclaration mismatch for symbol `%m%p'", GetSymName (S));
+ }
}
S->ConDesPrio[Type] = Prio;