diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-preprocessor.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/source/slang/slang-preprocessor.cpp b/source/slang/slang-preprocessor.cpp index 60af58df0..1c7f338fb 100644 --- a/source/slang/slang-preprocessor.cpp +++ b/source/slang/slang-preprocessor.cpp @@ -586,7 +586,7 @@ static bool _isMacroBusy(PreprocessorMacro* macro, PreprocessorEnvironment* env) // Reading Tokens With Expansion // -static void InitializeMacroExpansion( +static void initializeMacroExpansion( Preprocessor* preprocessor, MacroExpansion* expansion, PreprocessorMacro* macro) @@ -627,6 +627,16 @@ static void InitializeMacroExpansion( // macro, that environment will be the environment where // the function-like macro was *invoked*, which might be // in the context of another macro expansion. +} + +static void pushMacroExpansion( + Preprocessor* preprocessor, + MacroExpansion* expansion) +{ + // Before pushing a macro as an input stream, + // we need to set the appropraite "busy" state + // that will be used during expansions of that + // macro's definition. // A macro is always busy in its own expansion environment, // to prevent recursive expansion. Here we construct a @@ -639,6 +649,7 @@ static void InitializeMacroExpansion( // expansion. We could try to avoid the extra step at // the cost of a bit more code complexity here. // + auto macro = expansion->macro; expansion->busy.macro = macro; expansion->expansionEnvironment.busyMacros = &expansion->busy; @@ -653,23 +664,19 @@ static void InitializeMacroExpansion( // This happens to be what is stored in the parent // environment. // + auto parentEnvironment = expansion->expansionEnvironment.parent; expansion->busy.next = parentEnvironment->busyMacros; } else { - // For the other cases (function-like and objet-like + // For the other cases (function-like and object-like // macros), the busy list should include anything // that was already busy in the environment that // is beginning to expand a macro. // expansion->busy.next = preprocessor->inputStream->environment->busyMacros; } -} -static void PushMacroExpansion( - Preprocessor* preprocessor, - MacroExpansion* expansion) -{ PushInputStream(preprocessor, expansion); } @@ -930,7 +937,7 @@ static void MaybeBeginMacroExpansion( } MacroExpansion* expansion = new MacroExpansion(); - InitializeMacroExpansion(preprocessor, expansion, macro); + initializeMacroExpansion(preprocessor, expansion, macro); // Consume the opening `(` Token leftParen = AdvanceRawToken(preprocessor); @@ -963,7 +970,7 @@ static void MaybeBeginMacroExpansion( // Now that the arguments have been parsed and validated, // we are ready to proceed with expansion of the macro body. // - PushMacroExpansion(preprocessor, expansion); + pushMacroExpansion(preprocessor, expansion); } else { @@ -972,8 +979,8 @@ static void MaybeBeginMacroExpansion( // Object-like macros are the easy case. MacroExpansion* expansion = new MacroExpansion(); - InitializeMacroExpansion(preprocessor, expansion, macro); - PushMacroExpansion(preprocessor, expansion); + initializeMacroExpansion(preprocessor, expansion, macro); + pushMacroExpansion(preprocessor, expansion); } } } |
