Re: [cc65] Macro label scoping (Was: printf for ca65)

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2005-03-22 20:40:45
On Tue, Mar 22, 2005 at 04:29:54PM +0100, MagerValp wrote:
> In the printf macro, I make the two labels (arglist and string)
> .local, but apparently they still create a new scope (or is it the
> segment changes that cause problems?). @labels can't be made .local,
> so I'm not sure how to handle this. Any suggestions?

Here is the necessary patch:

-------------------------------------------------------------------------------
diff -c -b -r1.18 macro.c
*** macro.c     10 May 2004 21:06:53 -0000      1.18
--- macro.c     22 Mar 2005 19:35:01 -0000
***************
*** 464,470 ****
                        NextTok ();

                /* Need an identifer */
!               if (Tok != TOK_IDENT) {
                    Error ("Identifier expected");
                    SkipUntilSep ();
                    break;
--- 464,470 ----
                        NextTok ();

                /* Need an identifer */
!               if (Tok != TOK_IDENT && Tok != TOK_LOCAL_IDENT) {
                    Error ("Identifier expected");
                    SkipUntilSep ();
                    break;
-------------------------------------------------------------------------------

I broke it when I changed the scanner to return different tokens for normal
and cheap local identifiers.

Since labels declared with .local in macros are replaced when the macro is
expanded, and since the replacement label name cannot be generated by the
user, this should work without the possibility of name collisions.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Mar 22 20:40:49 2005

This archive was generated by hypermail 2.1.8 : 2005-03-22 20:40:55 CET