mirror of
https://github.com/cc65/cc65.git
synced 2025-01-13 09:31:53 +00:00
Check for macros within .STRUCT/.ENUM.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5076 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
241afdc738
commit
bf6b0b9eb7
@ -41,6 +41,7 @@
|
||||
#include "enum.h"
|
||||
#include "error.h"
|
||||
#include "expr.h"
|
||||
#include "macro.h"
|
||||
#include "nexttok.h"
|
||||
#include "scanner.h"
|
||||
#include "symbol.h"
|
||||
@ -75,6 +76,7 @@ void DoEnum (void)
|
||||
/* Read until end of struct */
|
||||
while (CurTok.Tok != TOK_ENDENUM && CurTok.Tok != TOK_EOF) {
|
||||
|
||||
Macro* M;
|
||||
SymEntry* Sym;
|
||||
ExprNode* EnumExpr;
|
||||
|
||||
@ -93,6 +95,12 @@ void DoEnum (void)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* We have an identifier. Is it a macro? */
|
||||
if ((M = FindMacro (&CurTok.SVal)) != 0) {
|
||||
MacExpandStart (M);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* We have an identifier, generate a symbol */
|
||||
Sym = SymFind (CurrentScope, &CurTok.SVal, SYM_ALLOC_NEW);
|
||||
|
||||
|
@ -62,7 +62,7 @@ struct StrBuf;
|
||||
struct Macro;
|
||||
typedef struct Macro Macro;
|
||||
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
@ -73,7 +73,7 @@ typedef struct Macro Macro;
|
||||
void MacDef (unsigned Style);
|
||||
/* Parse a macro definition */
|
||||
|
||||
void MacUndef (const StrBuf* Name, unsigned char Style);
|
||||
void MacUndef (const struct StrBuf* Name, unsigned char Style);
|
||||
/* Undefine the macro with the given name and style. A style mismatch is
|
||||
* treated as if the macro didn't exist.
|
||||
*/
|
||||
@ -84,12 +84,12 @@ void MacExpandStart (Macro* M);
|
||||
void MacAbort (void);
|
||||
/* Abort the current macro expansion */
|
||||
|
||||
Macro* FindMacro (const StrBuf* Name);
|
||||
Macro* FindMacro (const struct StrBuf* Name);
|
||||
/* Try to find the macro with the given name and return it. If no macro with
|
||||
* this name was found, return NULL.
|
||||
*/
|
||||
|
||||
Macro* FindDefine (const StrBuf* Name);
|
||||
Macro* FindDefine (const struct StrBuf* Name);
|
||||
/* Try to find the define style macro with the given name and return it. If no
|
||||
* such macro was found, return NULL.
|
||||
*/
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "condasm.h"
|
||||
#include "error.h"
|
||||
#include "expr.h"
|
||||
#include "macro.h"
|
||||
#include "nexttok.h"
|
||||
#include "scanner.h"
|
||||
#include "sizeof.h"
|
||||
@ -133,6 +134,16 @@ static long DoStructInternal (long Offs, unsigned Type)
|
||||
/* The format is "[identifier] storage-allocator [, multiplicator]" */
|
||||
Sym = 0;
|
||||
if (CurTok.Tok == TOK_IDENT) {
|
||||
|
||||
/* Beware: An identifier may also be a macro, in which case we have
|
||||
* to start over.
|
||||
*/
|
||||
Macro* M = FindMacro (&CurTok.SVal);
|
||||
if (M) {
|
||||
MacExpandStart (M);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* We have an identifier, generate a symbol */
|
||||
Sym = SymFind (CurrentScope, &CurTok.SVal, SYM_ALLOC_NEW);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user