• Home
  • Raw
  • Download

Lines Matching full:macro

77     for (const std::shared_ptr<Macro> &macro : mExpander->mMacrosToReenable)  in ~ScopedMacroReenabler()  local
81 ASSERT(macro->name.substr() != ""); in ~ScopedMacroReenabler()
82 macro->disabled = false; in ~ScopedMacroReenabler()
119 // Defined operator is parsed here since it may be generated by macro expansion. in lex()
120 // Defined operator produced by macro expansion has undefined behavior according to C++ in lex()
126 // Defined inside a macro is forbidden in WebGL. in lex()
171 std::shared_ptr<Macro> macro = iter->second; in lex() local
172 if (macro->disabled) in lex()
180 // otherwise there could be a #undef of the macro before the next token. in lex()
181 macro->expansionCount++; in lex()
182 if ((macro->type == Macro::kTypeFunc) && !isNextTokenLeftParen()) in lex()
184 // If the token immediately after the macro name is not a '(', in lex()
185 // this macro should not be expanded. in lex()
186 macro->expansionCount--; in lex()
190 pushMacro(macro, *token); in lex()
203 // First pop all empty macro contexts. in getToken()
246 bool MacroExpander::pushMacro(std::shared_ptr<Macro> macro, const Token &identifier) in pushMacro() argument
248 ASSERT(!macro->disabled); in pushMacro()
251 ASSERT(identifier.text == macro->name); in pushMacro()
254 if (!expandMacro(*macro, identifier, &replacements)) in pushMacro()
257 // Macro is disabled for expansion until it is popped off the stack. in pushMacro()
258 macro->disabled = true; in pushMacro()
261 context->macro = macro; in pushMacro()
276 ASSERT(context->macro->disabled); in popMacro()
277 ASSERT(context->macro->expansionCount > 0); in popMacro()
280 mMacrosToReenable.push_back(context->macro); in popMacro()
284 context->macro->disabled = false; in popMacro()
286 context->macro->expansionCount--; in popMacro()
291 bool MacroExpander::expandMacro(const Macro &macro, in expandMacro() argument
297 // In the case of an object-like macro, the replacement list gets its location in expandMacro()
298 // from the identifier, but in the case of a function-like macro, the replacement in expandMacro()
299 // list gets its location from the closing parenthesis of the macro invocation. in expandMacro()
302 if (macro.type == Macro::kTypeObj) in expandMacro()
304 replacements->assign(macro.replacements.begin(), macro.replacements.end()); in expandMacro()
306 if (macro.predefined) in expandMacro()
313 if (macro.name == kLine) in expandMacro()
317 else if (macro.name == kFile) in expandMacro()
325 ASSERT(macro.type == Macro::kTypeFunc); in expandMacro()
327 args.reserve(macro.parameters.size()); in expandMacro()
328 if (!collectMacroArgs(macro, identifier, &args, &replacementLocation)) in expandMacro()
331 replaceMacroParams(macro, args, replacements); in expandMacro()
349 bool MacroExpander::collectMacroArgs(const Macro &macro, in collectMacroArgs() argument
413 const Macro::Parameters &params = macro.parameters; in collectMacroArgs()
422 Diagnostics::ID id = args->size() < macro.parameters.size() in collectMacroArgs()
431 // inserted into the macro body. in collectMacroArgs()
463 void MacroExpander::replaceMacroParams(const Macro &macro, in replaceMacroParams() argument
467 for (std::size_t i = 0; i < macro.replacements.size(); ++i) in replaceMacroParams()
477 const Token &repl = macro.replacements[i]; in replaceMacroParams()
485 // There is no need to search for macro params every time. in replaceMacroParams()
487 Macro::Parameters::const_iterator iter = in replaceMacroParams()
488 std::find(macro.parameters.begin(), macro.parameters.end(), repl.text); in replaceMacroParams()
489 if (iter == macro.parameters.end()) in replaceMacroParams()
495 std::size_t iArg = std::distance(macro.parameters.begin(), iter); in replaceMacroParams()
504 // macro replacement token. in replaceMacroParams()
509 MacroExpander::MacroContext::MacroContext() : macro(0), index(0) {} in MacroContext()