Non-functional: Fix HLSL error message, and code formatting.

This commit is contained in:
John Kessenich 2018-01-08 11:41:59 -07:00
parent 99892d5a9a
commit adc33b23cc
3 changed files with 26 additions and 16 deletions

View File

@ -841,7 +841,8 @@ int TScanContext::tokenizeIdentifier()
case VOLATILE: case VOLATILE:
if (parseContext.profile == EEsProfile && parseContext.version >= 310) if (parseContext.profile == EEsProfile && parseContext.version >= 310)
return keyword; return keyword;
if (! parseContext.symbolTable.atBuiltInLevel() && (parseContext.profile == EEsProfile || (parseContext.version < 420 && ! parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store)))) if (! parseContext.symbolTable.atBuiltInLevel() && (parseContext.profile == EEsProfile ||
(parseContext.version < 420 && ! parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))))
reservedWord(); reservedWord();
return keyword; return keyword;
@ -985,8 +986,8 @@ int TScanContext::tokenizeIdentifier()
case U64VEC4: case U64VEC4:
afterType = true; afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() || if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64) && (parseContext.profile != EEsProfile && parseContext.version >= 450 &&
parseContext.profile != EEsProfile && parseContext.version >= 450)) parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_int64)))
return keyword; return keyword;
return identifierOrType(); return identifierOrType();
@ -1001,8 +1002,8 @@ int TScanContext::tokenizeIdentifier()
case U16VEC4: case U16VEC4:
afterType = true; afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() || if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_int16) && (parseContext.profile != EEsProfile && parseContext.version >= 450 &&
parseContext.profile != EEsProfile && parseContext.version >= 450)) parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_int16)))
return keyword; return keyword;
return identifierOrType(); return identifierOrType();
@ -1024,8 +1025,8 @@ int TScanContext::tokenizeIdentifier()
case F16MAT4X4: case F16MAT4X4:
afterType = true; afterType = true;
if (parseContext.symbolTable.atBuiltInLevel() || if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float) && (parseContext.profile != EEsProfile && parseContext.version >= 450 &&
parseContext.profile != EEsProfile && parseContext.version >= 450)) parseContext.extensionTurnedOn(E_GL_AMD_gpu_shader_half_float)))
return keyword; return keyword;
return identifierOrType(); return identifierOrType();
#endif #endif
@ -1115,7 +1116,7 @@ int TScanContext::tokenizeIdentifier()
case SAMPLER3D: case SAMPLER3D:
afterType = true; afterType = true;
if (parseContext.profile == EEsProfile && parseContext.version < 300) { if (parseContext.profile == EEsProfile && parseContext.version < 300) {
if (! parseContext.extensionTurnedOn(E_GL_OES_texture_3D)) if (!parseContext.extensionTurnedOn(E_GL_OES_texture_3D))
reservedWord(); reservedWord();
} }
return keyword; return keyword;
@ -1403,7 +1404,8 @@ int TScanContext::dMat()
int TScanContext::firstGenerationImage(bool inEs310) int TScanContext::firstGenerationImage(bool inEs310)
{ {
if (parseContext.symbolTable.atBuiltInLevel() || if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.profile != EEsProfile && (parseContext.version >= 420 || parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))) || (parseContext.profile != EEsProfile && (parseContext.version >= 420 ||
parseContext.extensionTurnedOn(E_GL_ARB_shader_image_load_store))) ||
(inEs310 && parseContext.profile == EEsProfile && parseContext.version >= 310)) (inEs310 && parseContext.profile == EEsProfile && parseContext.version >= 310))
return keyword; return keyword;

View File

@ -570,7 +570,8 @@ bool TParseVersions::checkExtensionsRequested(const TSourceLoc& loc, int numExte
// //
void TParseVersions::requireExtensions(const TSourceLoc& loc, int numExtensions, const char* const extensions[], const char* featureDesc) void TParseVersions::requireExtensions(const TSourceLoc& loc, int numExtensions, const char* const extensions[], const char* featureDesc)
{ {
if (checkExtensionsRequested(loc, numExtensions, extensions, featureDesc)) return; if (checkExtensionsRequested(loc, numExtensions, extensions, featureDesc))
return;
// If we get this far, give errors explaining what extensions are needed // If we get this far, give errors explaining what extensions are needed
if (numExtensions == 1) if (numExtensions == 1)
@ -588,7 +589,8 @@ void TParseVersions::requireExtensions(const TSourceLoc& loc, int numExtensions,
// //
void TParseVersions::ppRequireExtensions(const TSourceLoc& loc, int numExtensions, const char* const extensions[], const char* featureDesc) void TParseVersions::ppRequireExtensions(const TSourceLoc& loc, int numExtensions, const char* const extensions[], const char* featureDesc)
{ {
if (checkExtensionsRequested(loc, numExtensions, extensions, featureDesc)) return; if (checkExtensionsRequested(loc, numExtensions, extensions, featureDesc))
return;
// If we get this far, give errors explaining what extensions are needed // If we get this far, give errors explaining what extensions are needed
if (numExtensions == 1) if (numExtensions == 1)
@ -626,7 +628,8 @@ bool TParseVersions::extensionTurnedOn(const char* const extension)
bool TParseVersions::extensionsTurnedOn(int numExtensions, const char* const extensions[]) bool TParseVersions::extensionsTurnedOn(int numExtensions, const char* const extensions[])
{ {
for (int i = 0; i < numExtensions; ++i) { for (int i = 0; i < numExtensions; ++i) {
if (extensionTurnedOn(extensions[i])) return true; if (extensionTurnedOn(extensions[i]))
return true;
} }
return false; return false;
} }

View File

@ -565,10 +565,15 @@ EHlslTokenClass HlslScanContext::tokenizeClass(HlslToken& token)
case EndOfInput: return EHTokNone; case EndOfInput: return EHTokNone;
default: default:
char buf[2]; if (token < PpAtomMaxSingle) {
buf[0] = (char)token; char buf[2];
buf[1] = 0; buf[0] = (char)token;
parseContext.error(loc, "unexpected token", buf, ""); buf[1] = 0;
parseContext.error(loc, "unexpected token", buf, "");
} else if (tokenText[0] != 0)
parseContext.error(loc, "unexpected token", tokenText, "");
else
parseContext.error(loc, "unexpected token", "", "");
break; break;
} }
} while (true); } while (true);