]> git.sur5r.net Git - cc65/commitdiff
Change the .LOCAL command so that the cheap local symbol prefix is kept.
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 25 Sep 2002 21:35:00 +0000 (21:35 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 25 Sep 2002 21:35:00 +0000 (21:35 +0000)
This allows to create macros with local labels that expand to cheap local
symbols when the macro is expanded.
Tip from Dagan Galarneau <dagan@msd.com>

git-svn-id: svn://svn.cc65.org/cc65/trunk@1405 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/ca65/macro.c

index 0e6bca3a1426b049f6261147af50d2ba4fa655f2..976e19306d54b2b96c47a5723238baa42845c6a6 100644 (file)
@@ -44,6 +44,7 @@
 /* ca65 */
 #include "condasm.h"
 #include "error.h"
+#include "global.h"
 #include "istack.h"
 #include "nexttok.h"
 #include "pseudo.h"
@@ -541,8 +542,14 @@ static int MacExpand (void* Data)
                    IdDesc* I = Mac->M->Locals;
                    while (I) {
                        if (strcmp (SVal, I->Id) == 0) {
-                           /* This is in fact a local symbol, change the name */
-                           sprintf (SVal, "___%04X__", Mac->LocalStart + Index);
+                           /* This is in fact a local symbol, change the name. Be sure
+                     * to generate a local label name if the original name was
+                     * a local label, and also generate a name that cannot be
+                     * generated by a user.
+                     */
+                    unsigned PrefixLen = (I->Id[0] == LocalStart);
+                           sprintf (SVal, "%.*sLOCAL-MACRO-SYMBOL-%04X", PrefixLen, 
+                             I->Id, Mac->LocalStart + Index);
                            break;
                        }
                        /* Next symbol */