mirror of
https://github.com/cc65/cc65.git
synced 2024-12-27 00:29:31 +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:
parent
38d50cce0b
commit
7d506c84c9
@ -6,8 +6,8 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 2000-2004 Ullrich von Bassewitz */
|
/* (C) 2000-2010, Ullrich von Bassewitz */
|
||||||
/* Römerstraße 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
@ -310,7 +310,7 @@ void DoConditionals (void)
|
|||||||
D = AllocIf (".IFDEF", 1);
|
D = AllocIf (".IFDEF", 1);
|
||||||
NextTok ();
|
NextTok ();
|
||||||
if (IfCond) {
|
if (IfCond) {
|
||||||
SymEntry* Sym = ParseScopedSymName (SYM_FIND_EXISTING);
|
SymEntry* Sym = ParseAnySymName (SYM_FIND_EXISTING);
|
||||||
SetIfCond (D, Sym != 0 && SymIsDef (Sym));
|
SetIfCond (D, Sym != 0 && SymIsDef (Sym));
|
||||||
}
|
}
|
||||||
IfCond = GetCurrentIfCond ();
|
IfCond = GetCurrentIfCond ();
|
||||||
@ -346,7 +346,7 @@ void DoConditionals (void)
|
|||||||
D = AllocIf (".IFNDEF", 1);
|
D = AllocIf (".IFNDEF", 1);
|
||||||
NextTok ();
|
NextTok ();
|
||||||
if (IfCond) {
|
if (IfCond) {
|
||||||
SymEntry* Sym = ParseScopedSymName (SYM_FIND_EXISTING);
|
SymEntry* Sym = ParseAnySymName (SYM_FIND_EXISTING);
|
||||||
SetIfCond (D, Sym == 0 || !SymIsDef (Sym));
|
SetIfCond (D, Sym == 0 || !SymIsDef (Sym));
|
||||||
ExpectSep ();
|
ExpectSep ();
|
||||||
}
|
}
|
||||||
@ -357,7 +357,7 @@ void DoConditionals (void)
|
|||||||
D = AllocIf (".IFNREF", 1);
|
D = AllocIf (".IFNREF", 1);
|
||||||
NextTok ();
|
NextTok ();
|
||||||
if (IfCond) {
|
if (IfCond) {
|
||||||
SymEntry* Sym = ParseScopedSymName (SYM_FIND_EXISTING);
|
SymEntry* Sym = ParseAnySymName (SYM_FIND_EXISTING);
|
||||||
SetIfCond (D, Sym == 0 || !SymIsRef (Sym));
|
SetIfCond (D, Sym == 0 || !SymIsRef (Sym));
|
||||||
ExpectSep ();
|
ExpectSep ();
|
||||||
}
|
}
|
||||||
@ -408,7 +408,7 @@ void DoConditionals (void)
|
|||||||
D = AllocIf (".IFREF", 1);
|
D = AllocIf (".IFREF", 1);
|
||||||
NextTok ();
|
NextTok ();
|
||||||
if (IfCond) {
|
if (IfCond) {
|
||||||
SymEntry* Sym = ParseScopedSymName (SYM_FIND_EXISTING);
|
SymEntry* Sym = ParseAnySymName (SYM_FIND_EXISTING);
|
||||||
SetIfCond (D, Sym != 0 && SymIsRef (Sym));
|
SetIfCond (D, Sym != 0 && SymIsRef (Sym));
|
||||||
ExpectSep ();
|
ExpectSep ();
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,7 @@ static ExprNode* FuncDefined (void)
|
|||||||
/* Handle the .DEFINED builtin function */
|
/* Handle the .DEFINED builtin function */
|
||||||
{
|
{
|
||||||
/* Parse the symbol name and search for the symbol */
|
/* 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 */
|
/* Check if the symbol is defined */
|
||||||
return GenLiteralExpr (Sym != 0 && SymIsDef (Sym));
|
return GenLiteralExpr (Sym != 0 && SymIsDef (Sym));
|
||||||
@ -597,7 +597,7 @@ static ExprNode* FuncReferenced (void)
|
|||||||
/* Handle the .REFERENCED builtin function */
|
/* Handle the .REFERENCED builtin function */
|
||||||
{
|
{
|
||||||
/* Parse the symbol name and search for the symbol */
|
/* 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 */
|
/* Check if the symbol is referenced */
|
||||||
return GenLiteralExpr (Sym != 0 && SymIsRef (Sym));
|
return GenLiteralExpr (Sym != 0 && SymIsRef (Sym));
|
||||||
@ -867,12 +867,8 @@ static ExprNode* Factor (void)
|
|||||||
|
|
||||||
case TOK_NAMESPACE:
|
case TOK_NAMESPACE:
|
||||||
case TOK_IDENT:
|
case TOK_IDENT:
|
||||||
N = Symbol (ParseScopedSymName (SYM_ALLOC_NEW));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TOK_LOCAL_IDENT:
|
case TOK_LOCAL_IDENT:
|
||||||
N = Symbol (SymFindLocal (SymLast, &SVal, SYM_ALLOC_NEW));
|
N = Symbol (ParseAnySymName (SYM_ALLOC_NEW));
|
||||||
NextTok ();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOK_ULABEL:
|
case TOK_ULABEL:
|
||||||
|
@ -632,12 +632,7 @@ static void OneLine (void)
|
|||||||
int HadWS = WS;
|
int HadWS = WS;
|
||||||
|
|
||||||
/* Generate the symbol table entry, then skip the name */
|
/* Generate the symbol table entry, then skip the name */
|
||||||
if (Tok == TOK_LOCAL_IDENT) {
|
Sym = ParseAnySymName (SYM_ALLOC_NEW);
|
||||||
Sym = SymFindLocal (SymLast, &SVal, SYM_ALLOC_NEW);
|
|
||||||
NextTok ();
|
|
||||||
} else {
|
|
||||||
Sym = ParseScopedSymName (SYM_ALLOC_NEW);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If a colon follows, this is a label definition. If there
|
/* If a colon follows, this is a label definition. If there
|
||||||
* is no colon, it's an assignment.
|
* is no colon, it's an assignment.
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2008 Ullrich von Bassewitz */
|
/* (C) 1998-2010, Ullrich von Bassewitz */
|
||||||
/* Roemerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2008 Ullrich von Bassewitz */
|
/* (C) 1998-2010, Ullrich von Bassewitz */
|
||||||
/* Roemerstrasse 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
@ -74,6 +74,11 @@ struct SymTable* ParseScopedSymTable (void);
|
|||||||
* symbol space and return the symbol table struct.
|
* 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 */
|
/* End of symbol.h */
|
||||||
|
Loading…
Reference in New Issue
Block a user