1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-25 17:29:50 +00:00

Make .DEF, .REF and friends also work with cheap local symbols.

git-svn-id: svn://svn.cc65.org/cc65/trunk@4767 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2010-07-26 17:28:34 +00:00
parent 38d50cce0b
commit 7d506c84c9
5 changed files with 48 additions and 31 deletions

View File

@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 2000-2004 Ullrich von Bassewitz */
/* Römerstraße 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* (C) 2000-2010, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@ -310,7 +310,7 @@ void DoConditionals (void)
D = AllocIf (".IFDEF", 1);
NextTok ();
if (IfCond) {
SymEntry* Sym = ParseScopedSymName (SYM_FIND_EXISTING);
SymEntry* Sym = ParseAnySymName (SYM_FIND_EXISTING);
SetIfCond (D, Sym != 0 && SymIsDef (Sym));
}
IfCond = GetCurrentIfCond ();
@ -346,7 +346,7 @@ void DoConditionals (void)
D = AllocIf (".IFNDEF", 1);
NextTok ();
if (IfCond) {
SymEntry* Sym = ParseScopedSymName (SYM_FIND_EXISTING);
SymEntry* Sym = ParseAnySymName (SYM_FIND_EXISTING);
SetIfCond (D, Sym == 0 || !SymIsDef (Sym));
ExpectSep ();
}
@ -357,7 +357,7 @@ void DoConditionals (void)
D = AllocIf (".IFNREF", 1);
NextTok ();
if (IfCond) {
SymEntry* Sym = ParseScopedSymName (SYM_FIND_EXISTING);
SymEntry* Sym = ParseAnySymName (SYM_FIND_EXISTING);
SetIfCond (D, Sym == 0 || !SymIsRef (Sym));
ExpectSep ();
}
@ -408,7 +408,7 @@ void DoConditionals (void)
D = AllocIf (".IFREF", 1);
NextTok ();
if (IfCond) {
SymEntry* Sym = ParseScopedSymName (SYM_FIND_EXISTING);
SymEntry* Sym = ParseAnySymName (SYM_FIND_EXISTING);
SetIfCond (D, Sym != 0 && SymIsRef (Sym));
ExpectSep ();
}

View File

@ -385,7 +385,7 @@ static ExprNode* FuncDefined (void)
/* Handle the .DEFINED builtin function */
{
/* Parse the symbol name and search for the symbol */
SymEntry* Sym = ParseScopedSymName (SYM_FIND_EXISTING);
SymEntry* Sym = ParseAnySymName (SYM_FIND_EXISTING);
/* Check if the symbol is defined */
return GenLiteralExpr (Sym != 0 && SymIsDef (Sym));
@ -597,7 +597,7 @@ static ExprNode* FuncReferenced (void)
/* Handle the .REFERENCED builtin function */
{
/* Parse the symbol name and search for the symbol */
SymEntry* Sym = ParseScopedSymName (SYM_FIND_EXISTING);
SymEntry* Sym = ParseAnySymName (SYM_FIND_EXISTING);
/* Check if the symbol is referenced */
return GenLiteralExpr (Sym != 0 && SymIsRef (Sym));
@ -867,13 +867,9 @@ static ExprNode* Factor (void)
case TOK_NAMESPACE:
case TOK_IDENT:
N = Symbol (ParseScopedSymName (SYM_ALLOC_NEW));
break;
case TOK_LOCAL_IDENT:
N = Symbol (SymFindLocal (SymLast, &SVal, SYM_ALLOC_NEW));
NextTok ();
break;
N = Symbol (ParseAnySymName (SYM_ALLOC_NEW));
break;
case TOK_ULABEL:
N = ULabRef (IVal);

View File

@ -360,7 +360,7 @@ static void OptAutoImport (const char* Opt attribute ((unused)),
static void OptBinIncludeDir (const char* Opt attribute ((unused)), const char* Arg)
/* Add an include search path for binaries */
{
{
AddSearchPath (BinSearchPath, Arg);
}
@ -632,12 +632,7 @@ static void OneLine (void)
int HadWS = WS;
/* Generate the symbol table entry, then skip the name */
if (Tok == TOK_LOCAL_IDENT) {
Sym = SymFindLocal (SymLast, &SVal, SYM_ALLOC_NEW);
NextTok ();
} else {
Sym = ParseScopedSymName (SYM_ALLOC_NEW);
}
Sym = ParseAnySymName (SYM_ALLOC_NEW);
/* If a colon follows, this is a label definition. If there
* is no colon, it's an assignment.

View File

@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (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 */
@ -245,3 +245,24 @@ SymTable* ParseScopedSymTable (void)
SymEntry* ParseAnySymName (int AllocNew)
/* Parse a cheap local symbol or a a (possibly scoped) symbol name, search
* for it in the symbol table and return the symbol table entry.
*/
{
SymEntry* Sym;
/* Distinguish cheap locals and other symbols */
if (Tok == TOK_LOCAL_IDENT) {
Sym = SymFindLocal (SymLast, &SVal, AllocNew);
NextTok ();
} else {
Sym = ParseScopedSymName (AllocNew);
}
/* Return the symbol found */
return Sym;
}

View File

@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (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 */
@ -74,6 +74,11 @@ struct SymTable* ParseScopedSymTable (void);
* symbol space and return the symbol table struct.
*/
struct SymEntry* ParseAnySymName (int AllocNew);
/* Parse a cheap local symbol or a a (possibly scoped) symbol name, search
* for it in the symbol table and return the symbol table entry.
*/
/* End of symbol.h */