Merge branch 'TiemoJung-semantic_handling'

This commit is contained in:
John Kessenich
2017-03-14 21:50:06 -06:00
11 changed files with 187 additions and 49 deletions

View File

@@ -3528,7 +3528,9 @@ bool HlslGrammar::acceptPostDecls(TQualifier& qualifier)
parseContext.handleRegister(registerDesc.loc, qualifier, profile.string, *registerDesc.string, subComponent, spaceDesc.string);
} else {
// semantic, in idToken.string
parseContext.handleSemantic(idToken.loc, qualifier, mapSemantic(*idToken.string));
TString semanticUpperCase = *idToken.string;
std::transform(semanticUpperCase.begin(), semanticUpperCase.end(), semanticUpperCase.begin(), ::toupper);
parseContext.handleSemantic(idToken.loc, qualifier, mapSemantic(semanticUpperCase.c_str()), semanticUpperCase);
}
} else if (peekTokenClass(EHTokLeftAngle)) {
found = true;

View File

@@ -4144,7 +4144,7 @@ TFunction* HlslParseContext::handleConstructorCall(const TSourceLoc& loc, const
// Handle seeing a "COLON semantic" at the end of a type declaration,
// by updating the type according to the semantic.
//
void HlslParseContext::handleSemantic(TSourceLoc loc, TQualifier& qualifier, TBuiltInVariable builtIn)
void HlslParseContext::handleSemantic(TSourceLoc loc, TQualifier& qualifier, TBuiltInVariable builtIn, const TString& upperCase)
{
// adjust for stage in/out
@@ -4161,6 +4161,7 @@ void HlslParseContext::handleSemantic(TSourceLoc loc, TQualifier& qualifier, TBu
}
qualifier.builtIn = builtIn;
qualifier.semanticName = intermediate.addSemanticName(upperCase);
}
//

View File

@@ -91,7 +91,7 @@ public:
TIntermTyped* addOutputArgumentConversions(const TFunction&, TIntermOperator&);
void builtInOpCheck(const TSourceLoc&, const TFunction&, TIntermOperator&);
TFunction* handleConstructorCall(const TSourceLoc&, const TType&);
void handleSemantic(TSourceLoc, TQualifier&, TBuiltInVariable);
void handleSemantic(TSourceLoc, TQualifier&, TBuiltInVariable, const TString& upperCase);
void handlePackOffset(const TSourceLoc&, TQualifier&, const glslang::TString& location,
const glslang::TString* component);
void handleRegister(const TSourceLoc&, TQualifier&, const glslang::TString* profile, const glslang::TString& desc,

View File

@@ -467,12 +467,9 @@ void HlslScanContext::tokenize(HlslToken& token)
token.tokenClass = tokenClass;
}
glslang::TBuiltInVariable HlslScanContext::mapSemantic(const TString& semantic)
glslang::TBuiltInVariable HlslScanContext::mapSemantic(const char* upperCase)
{
TString semanticUpperCase = semantic;
std::transform(semanticUpperCase.begin(), semanticUpperCase.end(), semanticUpperCase.begin(), ::toupper);
auto it = SemanticMap->find(semanticUpperCase.c_str());
auto it = SemanticMap->find(upperCase);
if (it != SemanticMap->end())
return it->second;
else

View File

@@ -82,7 +82,7 @@ public:
static void deleteKeywordMap();
void tokenize(HlslToken&);
glslang::TBuiltInVariable mapSemantic(const TString& semantic);
glslang::TBuiltInVariable mapSemantic(const char*);
protected:
HlslScanContext(HlslScanContext&);

View File

@@ -52,7 +52,7 @@ namespace glslang {
bool acceptTokenClass(EHlslTokenClass);
EHlslTokenClass peek() const;
bool peekTokenClass(EHlslTokenClass) const;
glslang::TBuiltInVariable mapSemantic(const TString& semantic) { return scanner.mapSemantic(semantic); }
glslang::TBuiltInVariable mapSemantic(const char* upperCase) { return scanner.mapSemantic(upperCase); }
void pushTokenStream(const TVector<HlslToken>* tokens);
void popTokenStream();