MCPcopy Create free account
hub / github.com/KhronosGroup/glslang / evalToToken

Method evalToToken

glslang/MachineIndependent/preprocessor/Pp.cpp:582–610  ·  view source on GitHub ↗

Expand macros, skipping empty expansions, to get to the first real token in those expansions.

Source from the content-addressed store, hash-verified

580
581// Expand macros, skipping empty expansions, to get to the first real token in those expansions.
582int TPpContext::evalToToken(int token, bool shortCircuit, int& res, bool& err, TPpToken* ppToken)
583{
584 while (token == PpAtomIdentifier && strcmp("defined", ppToken->name) != 0) {
585 switch (MacroExpand(ppToken, true, false)) {
586 case MacroExpandNotStarted:
587 case MacroExpandError:
588 parseContext.ppError(ppToken->loc, "can't evaluate expression", "preprocessor evaluation", "");
589 err = true;
590 res = 0;
591 break;
592 case MacroExpandStarted:
593 break;
594 case MacroExpandUndef:
595 if (! shortCircuit && parseContext.isEsProfile()) {
596 const char* message = "undefined macro in expression not allowed in es profile";
597 if (parseContext.relaxedErrors())
598 parseContext.ppWarn(ppToken->loc, message, "preprocessor evaluation", ppToken->name);
599 else
600 parseContext.ppError(ppToken->loc, message, "preprocessor evaluation", ppToken->name);
601 }
602 break;
603 }
604 token = scanToken(ppToken);
605 if (err)
606 break;
607 }
608
609 return token;
610}
611
612// Handle #if
613int TPpContext::CPPif(TPpToken* ppToken)

Callers

nothing calls this directly

Calls 4

ppErrorMethod · 0.80
relaxedErrorsMethod · 0.80
ppWarnMethod · 0.80
isEsProfileMethod · 0.45

Tested by

no test coverage detected