Lines Matching full:macro
77 for (const std::shared_ptr<Macro> ¯o : mExpander->mMacrosToReenable) in ~ScopedMacroReenabler() local
81 ASSERT(macro->name.substr() != ""); in ~ScopedMacroReenabler()
82 macro->disabled = false; in ~ScopedMacroReenabler()
106 context.macro->expansionCount--; in ~MacroExpander()
107 context.macro->disabled = false; in ~MacroExpander()
120 // Defined operator is parsed here since it may be generated by macro expansion. in lex()
121 // Defined operator produced by macro expansion has undefined behavior according to C++ in lex()
127 // Defined inside a macro is forbidden in WebGL. in lex()
172 std::shared_ptr<Macro> macro = iter->second; in lex() local
173 if (macro->disabled) in lex()
181 // otherwise there could be a #undef of the macro before the next token. in lex()
182 macro->expansionCount++; in lex()
183 if ((macro->type == Macro::kTypeFunc) && !isNextTokenLeftParen()) in lex()
185 // If the token immediately after the macro name is not a '(', in lex()
186 // this macro should not be expanded. in lex()
187 macro->expansionCount--; in lex()
191 pushMacro(macro, *token); in lex()
204 // First pop all empty macro contexts. in getToken()
247 bool MacroExpander::pushMacro(std::shared_ptr<Macro> macro, const Token &identifier) in pushMacro() argument
249 ASSERT(!macro->disabled); in pushMacro()
252 ASSERT(identifier.text == macro->name); in pushMacro()
255 if (!expandMacro(*macro, identifier, &replacements)) in pushMacro()
258 // Macro is disabled for expansion until it is popped off the stack. in pushMacro()
259 macro->disabled = true; in pushMacro()
262 mContextStack.emplace_back(std::move(macro), std::move(replacements)); in pushMacro()
274 ASSERT(context.macro->disabled); in popMacro()
275 ASSERT(context.macro->expansionCount > 0); in popMacro()
278 mMacrosToReenable.push_back(context.macro); in popMacro()
282 context.macro->disabled = false; in popMacro()
284 context.macro->expansionCount--; in popMacro()
288 bool MacroExpander::expandMacro(const Macro ¯o, in expandMacro() argument
294 // In the case of an object-like macro, the replacement list gets its location in expandMacro()
295 // from the identifier, but in the case of a function-like macro, the replacement in expandMacro()
296 // list gets its location from the closing parenthesis of the macro invocation. in expandMacro()
299 if (macro.type == Macro::kTypeObj) in expandMacro()
301 replacements->assign(macro.replacements.begin(), macro.replacements.end()); in expandMacro()
303 if (macro.predefined) in expandMacro()
310 if (macro.name == kLine) in expandMacro()
314 else if (macro.name == kFile) in expandMacro()
322 ASSERT(macro.type == Macro::kTypeFunc); in expandMacro()
324 args.reserve(macro.parameters.size()); in expandMacro()
325 if (!collectMacroArgs(macro, identifier, &args, &replacementLocation)) in expandMacro()
328 replaceMacroParams(macro, args, replacements); in expandMacro()
346 bool MacroExpander::collectMacroArgs(const Macro ¯o, in collectMacroArgs() argument
410 const Macro::Parameters ¶ms = macro.parameters; in collectMacroArgs()
419 Diagnostics::ID id = args->size() < macro.parameters.size() in collectMacroArgs()
428 // inserted into the macro body. in collectMacroArgs()
460 void MacroExpander::replaceMacroParams(const Macro ¯o, in replaceMacroParams() argument
464 for (std::size_t i = 0; i < macro.replacements.size(); ++i) in replaceMacroParams()
474 const Token &repl = macro.replacements[i]; in replaceMacroParams()
482 // There is no need to search for macro params every time. in replaceMacroParams()
484 Macro::Parameters::const_iterator iter = in replaceMacroParams()
485 std::find(macro.parameters.begin(), macro.parameters.end(), repl.text); in replaceMacroParams()
486 if (iter == macro.parameters.end()) in replaceMacroParams()
492 std::size_t iArg = std::distance(macro.parameters.begin(), iter); in replaceMacroParams()
501 // macro replacement token. in replaceMacroParams()