1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-09 06:29:38 +00:00

Fix/workaround for a problem with nested macros.

git-svn-id: svn://svn.cc65.org/cc65/trunk@5053 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2011-06-13 10:03:26 +00:00
parent 4709e8251e
commit 00f57bbc87

View File

@ -654,17 +654,17 @@ static int MacExpand (void* Data)
/* We're expanding a macro. Check if we are expanding one of the
* macro parameters.
*/
ExpandParam:
if (Mac->ParamExp) {
/* Ok, use token from parameter list, but don't use its line info */
TokSet (Mac->ParamExp, LI_SLOT_INV);
/* Set pointer to next token */
Mac->ParamExp = Mac->ParamExp->Next;
/* Done */
return 1;
}
/* We're not expanding macro parameters. Check if we have tokens left from
@ -689,10 +689,10 @@ static int MacExpand (void* Data)
if (CurTok.Tok == TOK_MACPARAM) {
/* Start to expand the parameter token list */
Mac->ParamExp = Mac->Params [CurTok.IVal];
Mac->ParamExp = Mac->Params[CurTok.IVal];
/* Recursive call to expand the parameter */
return MacExpand (Mac);
/* Go back and expand the parameter */
goto ExpandParam;
}
/* If it's an identifier, it may in fact be a local symbol */
@ -730,7 +730,6 @@ static int MacExpand (void* Data)
/* The token was successfully set */
return 1;
}
/* No more macro tokens. Do we have a final token? */
@ -741,9 +740,21 @@ static int MacExpand (void* Data)
FreeTokNode (Mac->Final);
Mac->Final = 0;
/* Problem: When a .define style macro is expanded within the call
* of a classic one, the latter may be terminated and removed while
* the expansion of the .define style macro is still active. Because
* line info slots are "stacked", this runs into a CHECK FAILED. For
* now, we will fix that by removing the .define style macro expansion
* immediately, once the final token is placed. The better solution
* would probably be to not require AllocLineInfoSlot/FreeLineInfoSlot
* to be called in FIFO order, but this is a bigger change.
*/
/* End of macro expansion and pop the input function */
FreeMacExp (Mac);
PopInput ();
/* The token was successfully set */
return 1;
}
MacEnd: