Non functional: Simplify accesses to the parseContext in the flex file.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@20315 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2013-01-24 22:33:43 +00:00
parent 6dc6df377d
commit 62b51a2b7e

View File

@ -489,7 +489,9 @@ int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext& parseCon
void yyerror(char *s)
{
if (((TParseContext *)cpp->pC)->AfterEOF) {
TParseContext& parseContext = *((TParseContext *)cpp->pC);
if (parseContext.AfterEOF) {
if (cpp->tokensBeforeEOF == 1) {
GlobalParseContext->error(yylineno, "syntax error", "pre-mature EOF", s, "");
GlobalParseContext->recover();
@ -554,23 +556,31 @@ extern "C" {
void CPPDebugLogMsg(const char *msg)
{
((TParseContext *)cpp->pC)->infoSink.debug.message(EPrefixNone, msg);
TParseContext& parseContext = *((TParseContext *)cpp->pC);
parseContext.infoSink.debug.message(EPrefixNone, msg);
}
void CPPWarningToInfoLog(const char *msg)
{
((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg, yylineno);
TParseContext& parseContext = *((TParseContext *)cpp->pC);
parseContext.infoSink.info.message(EPrefixWarning, msg, yylineno);
}
void CPPShInfoLogMsg(const char *msg)
{
((TParseContext *)cpp->pC)->error(yylineno,"", "",msg,"");
TParseContext& parseContext = *((TParseContext *)cpp->pC);
parseContext.error(yylineno,"", "",msg,"");
GlobalParseContext->recover();
}
void CPPErrorToInfoLog(char *msg)
{
((TParseContext *)cpp->pC)->error(yylineno, "CPP error:", "",msg,"");
TParseContext& parseContext = *((TParseContext *)cpp->pC);
parseContext.error(yylineno, "CPP error:", "",msg,"");
GlobalParseContext->recover();
}
@ -609,6 +619,8 @@ void DecLineNumber(void)
void HandlePragma(const char **tokens, int numTokens)
{
TParseContext& parseContext = *((TParseContext *)cpp->pC);
if (!strcmp(tokens[0], "optimize")) {
if (numTokens != 4) {
CPPShInfoLogMsg("optimize pragma syntax is incorrect");
@ -621,9 +633,9 @@ void HandlePragma(const char **tokens, int numTokens)
}
if (!strcmp(tokens[2], "on"))
((TParseContext *)cpp->pC)->contextPragma.optimize = true;
parseContext.contextPragma.optimize = true;
else if (!strcmp(tokens[2], "off"))
((TParseContext *)cpp->pC)->contextPragma.optimize = false;
parseContext.contextPragma.optimize = false;
else {
CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma");
return;
@ -645,9 +657,9 @@ void HandlePragma(const char **tokens, int numTokens)
}
if (!strcmp(tokens[2], "on"))
((TParseContext *)cpp->pC)->contextPragma.debug = true;
parseContext.contextPragma.debug = true;
else if (!strcmp(tokens[2], "off"))
((TParseContext *)cpp->pC)->contextPragma.debug = false;
parseContext.contextPragma.debug = false;
else {
CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma");
return;
@ -662,14 +674,14 @@ void HandlePragma(const char **tokens, int numTokens)
#ifdef PRAGMA_TABLE
//
// implementation specific pragma
// use ((TParseContext *)cpp->pC)->contextPragma.pragmaTable to store the information about pragma
// use parseContext.contextPragma.pragmaTable to store the information about pragma
// For now, just ignore the pragma that the implementation cannot recognize
// An Example of one such implementation for a pragma that has a syntax like
// #pragma pragmaname(pragmavalue)
// This implementation stores the current pragmavalue against the pragma name in pragmaTable.
//
if (numTokens == 4 && !strcmp(tokens[1], "(") && !strcmp(tokens[3], ")")) {
TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable;
TPragmaTable& pragmaTable = parseContext.contextPragma.pragmaTable;
TPragmaTable::iterator iter;
iter = pragmaTable.find(TString(tokens[0]));
if (iter != pragmaTable.end()) {
@ -678,7 +690,7 @@ void HandlePragma(const char **tokens, int numTokens)
pragmaTable[tokens[0]] = tokens[2];
}
} else if (numTokens >= 2) {
TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable;
TPragmaTable& pragmaTable = parseContext.contextPragma.pragmaTable;
TPragmaTable::iterator iter;
iter = pragmaTable.find(TString(tokens[0]));
if (iter != pragmaTable.end()) {
@ -693,26 +705,33 @@ void HandlePragma(const char **tokens, int numTokens)
void StoreStr(char *string)
{
TParseContext& parseContext = *((TParseContext *)cpp->pC);
TString strSrc;
strSrc = TString(string);
((TParseContext *)cpp->pC)->HashErrMsg = ((TParseContext *)cpp->pC)->HashErrMsg + " " + strSrc;
parseContext.HashErrMsg = parseContext.HashErrMsg + " " + strSrc;
}
const char* GetStrfromTStr(void)
{
cpp->ErrMsg = (((TParseContext *)cpp->pC)->HashErrMsg).c_str();
TParseContext& parseContext = *((TParseContext *)cpp->pC);
cpp->ErrMsg = parseContext.HashErrMsg.c_str();
return cpp->ErrMsg;
}
void ResetTString(void)
{
((TParseContext *)cpp->pC)->HashErrMsg = "";
TParseContext& parseContext = *((TParseContext *)cpp->pC);
parseContext.HashErrMsg = "";
}
void SetVersion(int version)
{
((TParseContext *)cpp->pC)->version = version;
TParseContext& parseContext = *((TParseContext *)cpp->pC);
parseContext.version = version;
}
const int FirstProfileVersion = 150;
@ -721,32 +740,32 @@ const int FirstProfileVersion = 150;
// if there is a version, sending in a ENoProfile if there is no profile given.
void SetProfile(EProfile profile)
{
int version = ((TParseContext *)cpp->pC)->version;
TParseContext& parseContext = *((TParseContext *)cpp->pC);
if (profile == ENoProfile) {
if (version == 100 || version == 300) {
if (parseContext.version == 100 || parseContext.version == 300) {
CPPErrorToInfoLog("versions 100 and 300 require specifying the es profile");
((TParseContext *)cpp->pC)->profile = ENoProfile;
} else if (version >= FirstProfileVersion)
((TParseContext *)cpp->pC)->profile = ECoreProfile;
parseContext.profile = ENoProfile;
} else if (parseContext.version >= FirstProfileVersion)
parseContext.profile = ECoreProfile;
else
((TParseContext *)cpp->pC)->profile = ENoProfile;
parseContext.profile = ENoProfile;
} else {
// a profile was provided...
if (version == 100 || version == 300) {
if (parseContext.version == 100 || parseContext.version == 300) {
if (profile != EEsProfile)
CPPErrorToInfoLog("versions 100 and 300 only support the es profile");
((TParseContext *)cpp->pC)->profile = EEsProfile;
parseContext.profile = EEsProfile;
} else {
if (profile == EEsProfile) {
CPPErrorToInfoLog("only versions 100 and 300 support the es profile");
if (version >= FirstProfileVersion)
((TParseContext *)cpp->pC)->profile = ECoreProfile;
if (parseContext.version >= FirstProfileVersion)
parseContext.profile = ECoreProfile;
else
((TParseContext *)cpp->pC)->profile = ENoProfile;
parseContext.profile = ENoProfile;
} else {
// typical desktop case... e.g., "#version 410 core"
((TParseContext *)cpp->pC)->profile = profile;
parseContext.profile = profile;
}
}
}
@ -770,6 +789,7 @@ TBehavior GetBehavior(const char* behavior)
void updateExtensionBehavior(const char* extName, const char* behavior)
{
TParseContext& parseContext = *((TParseContext *)cpp->pC);
TBehavior behaviorVal = GetBehavior(behavior);
TMap<TString, TBehavior>:: iterator iter;
TString msg;
@ -780,12 +800,12 @@ void updateExtensionBehavior(const char* extName, const char* behavior)
CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior");
return;
} else {
for (iter = ((TParseContext *)cpp->pC)->extensionBehavior.begin(); iter != ((TParseContext *)cpp->pC)->extensionBehavior.end(); ++iter)
for (iter = parseContext.extensionBehavior.begin(); iter != parseContext.extensionBehavior.end(); ++iter)
iter->second = behaviorVal;
}
} else {
iter = ((TParseContext *)cpp->pC)->extensionBehavior.find(TString(extName));
if (iter == ((TParseContext *)cpp->pC)->extensionBehavior.end()) {
iter = parseContext.extensionBehavior.find(TString(extName));
if (iter == parseContext.extensionBehavior.end()) {
switch (behaviorVal) {
case EBhRequire:
CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str());
@ -794,7 +814,7 @@ void updateExtensionBehavior(const char* extName, const char* behavior)
case EBhWarn:
case EBhDisable:
msg = TString("extension '") + extName + "' is not supported";
((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno);
parseContext.infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno);
break;
}
return;