]> git.sur5r.net Git - cc65/commitdiff
Make .DEF, .REF and friends also work with cheap local symbols.
authoruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 26 Jul 2010 17:28:34 +0000 (17:28 +0000)
committeruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 26 Jul 2010 17:28:34 +0000 (17:28 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@4767 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/ca65/condasm.c
src/ca65/expr.c
src/ca65/main.c
src/ca65/symbol.c
src/ca65/symbol.h

index b92db812d783387bddfbbbc2eab932549ae96d26..e89bcf62b52f708129d75637d62db0d0eacde71e 100644 (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 ();
                }
index 4d41c06f6bb0c94746a2e166462d0a56181523a3..56d728e9cb31e5c14c6339c25861101727d220af 100644 (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);
index b552e8363fc5c5cb86a2f3a52b19a08db3998432..eae7c384f1278601cc3cb42d09c1d7661928c7b0 100644 (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.
index 444decfc5c3e95694ebc296b169c5361430323cf..3be3b9b5cc7fafe4495cfe4826a35edb279894a0 100644 (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;
+}
+
+
+
index 4d0bcbf7d05d4e984f413e81249379d6ec9ace93..b790fcacb32ef96de13409177e231c74c6c9d876 100644 (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 */