1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-26 20:29:34 +00:00

Second part of the experimental fix for #796.

This commit is contained in:
laubzega 2020-07-04 00:02:00 -07:00
parent 633e0a2d64
commit 779461f407
3 changed files with 27 additions and 1 deletions

View File

@ -178,6 +178,9 @@ SymEntry* ParseScopedSymName (SymFindAction Action)
*/
if (NoScope && (Action & SYM_ALLOC_NEW) == 0) {
Sym = SymFindAny (Scope, &Ident);
if (!Sym) {
Sym = SymFindInChildren(Scope, &Ident);
}
} else {
/* If we are processing a symbol within an expression, which the
** parser expects to be constant, that symbol had to be defined
@ -193,10 +196,11 @@ SymEntry* ParseScopedSymName (SymFindAction Action)
Sym = SymFindAny (Scope, &Ident);
}
}
/* If still not found, or if in non-const expression, it will just
** get added to the current scope.
*/
if (!Sym ) {
if (!Sym) {
Sym = SymFind (Scope, &Ident, Action);
}
}

View File

@ -424,6 +424,22 @@ SymEntry* SymFind (SymTable* Scope, const StrBuf* Name, SymFindAction Action)
}
SymEntry* SymFindInChildren (SymTable* Parent, const StrBuf* Name)
{
SymTable* Scope = Parent->Childs;
SymEntry* Sym = 0;
if (Scope) {
do {
Sym = SymFind(Scope, Name, SYM_CHECK_ONLY);
Scope = Scope->Next;
} while (Scope && !Sym);
}
return Sym;
}
SymEntry* SymFindAny (SymTable* Scope, const StrBuf* Name)
/* Find a symbol in the given or any of its parent scopes. The function will

View File

@ -122,6 +122,12 @@ SymEntry* SymFindLocal (SymEntry* Parent, const StrBuf* Name, SymFindAction Acti
** created, or - in case Action is SYM_FIND_EXISTING - return 0.
*/
SymEntry* SymFindInChildren (SymTable* Scope, const StrBuf* Name);
/* Find a symbol in children scopes of given scope (if they exist). The
** function will never create a new symbol, since this can only be done in one
** specific scope.
*/
SymEntry* SymFind (SymTable* Scope, const StrBuf* Name, SymFindAction Action);
/* Find a new symbol table entry in the given table. If Action contains
** SYM_ALLOC_NEW and the entry is not found, create a new one. Return the