HLSL: Implement 'this' keyword.

This commit is contained in:
John Kessenich
2017-03-22 11:38:22 -06:00
parent 3778979cd4
commit 7a41f96d10
8 changed files with 435 additions and 9 deletions

View File

@@ -75,16 +75,33 @@ void HlslGrammar::unimplemented(const char* error)
parseContext.error(token.loc, "Unimplemented", error, "");
}
// IDENTIFIER
// THIS
// type that can be used as IDENTIFIER
//
// Only process the next token if it is an identifier.
// Return true if it was an identifier.
bool HlslGrammar::acceptIdentifier(HlslToken& idToken)
{
// IDENTIFIER
if (peekTokenClass(EHTokIdentifier)) {
idToken = token;
advanceToken();
return true;
}
// THIS
// -> maps to the IDENTIFIER spelled with the internal special name for 'this'
if (peekTokenClass(EHTokThis)) {
idToken = token;
advanceToken();
idToken.tokenClass = EHTokIdentifier;
idToken.string = NewPoolTString(intermediate.implicitThisName);
return true;
}
// type that can be used as IDENTIFIER
// Even though "sample", "bool", "float", etc keywords (for types, interpolation modifiers),
// they ARE still accepted as identifiers. This is not a dense space: e.g, "void" is not a
// valid identifier, nor is "linear". This code special cases the known instances of this, so