GLSL: Promote HLSL entry-point renaming code to be used by GLSL as well.
Fixes #1045.
diff --git a/hlsl/hlslGrammar.cpp b/hlsl/hlslGrammar.cpp
index 2f687c5..fcdeff4 100755
--- a/hlsl/hlslGrammar.cpp
+++ b/hlsl/hlslGrammar.cpp
@@ -387,7 +387,7 @@
HlslToken idToken;
TIntermAggregate* initializers = nullptr;
while (acceptIdentifier(idToken)) {
- const TString *fullName = idToken.string;
+ TString *fullName = idToken.string;
if (parseContext.symbolTable.atGlobalLevel())
parseContext.getFullNamespaceName(fullName);
if (peekTokenClass(EHTokLeftParen)) {
@@ -2263,12 +2263,12 @@
//
// Expects type to have EvqGlobal for a static member and
// EvqTemporary for non-static member.
-bool HlslGrammar::acceptMemberFunctionDefinition(TIntermNode*& nodeList, const TType& type, const TString& memberName,
+bool HlslGrammar::acceptMemberFunctionDefinition(TIntermNode*& nodeList, const TType& type, TString& memberName,
TFunctionDeclarator& declarator)
{
bool accepted = false;
- const TString* functionName = &memberName;
+ TString* functionName = &memberName;
parseContext.getFullNamespaceName(functionName);
declarator.function = new TFunction(functionName, type);
if (type.getQualifier().storage == EvqTemporary)
diff --git a/hlsl/hlslGrammar.h b/hlsl/hlslGrammar.h
index ded8e96..2db0754 100755
--- a/hlsl/hlslGrammar.h
+++ b/hlsl/hlslGrammar.h
@@ -91,7 +91,7 @@
bool acceptConstantBufferType(TType&);
bool acceptStruct(TType&, TIntermNode*& nodeList);
bool acceptStructDeclarationList(TTypeList*&, TIntermNode*& nodeList, TVector<TFunctionDeclarator>&);
- bool acceptMemberFunctionDefinition(TIntermNode*& nodeList, const TType&, const TString& memberName,
+ bool acceptMemberFunctionDefinition(TIntermNode*& nodeList, const TType&, TString& memberName,
TFunctionDeclarator&);
bool acceptFunctionParameters(TFunction&);
bool acceptParameterDeclaration(TFunction&);
diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp
index 66cd040..2ed252c 100755
--- a/hlsl/hlslParseHelper.cpp
+++ b/hlsl/hlslParseHelper.cpp
@@ -58,11 +58,10 @@
const TString sourceEntryPointName,
bool forwardCompatible, EShMessages messages) :
TParseContextBase(symbolTable, interm, parsingBuiltins, version, profile, spvVersion, language, infoSink,
- forwardCompatible, messages),
+ forwardCompatible, messages, &sourceEntryPointName),
annotationNestingLevel(0),
inputPatch(nullptr),
nextInLocation(0), nextOutLocation(0),
- sourceEntryPointName(sourceEntryPointName),
entryPointFunction(nullptr),
entryPointFunctionBody(nullptr),
gsStreamOutput(nullptr),
@@ -8710,7 +8709,7 @@
// Use the class/struct nesting string to create a global name for
// a member of a class/struct.
-void HlslParseContext::getFullNamespaceName(const TString*& name) const
+void HlslParseContext::getFullNamespaceName(TString*& name) const
{
if (currentTypePrefix.size() == 0)
return;
@@ -8726,15 +8725,6 @@
name.append(scopeMangler);
}
-// Potentially rename shader entry point function
-void HlslParseContext::renameShaderFunction(const TString*& name) const
-{
- // Replace the entry point name given in the shader with the real entry point name,
- // if there is a substitution.
- if (name != nullptr && *name == sourceEntryPointName)
- name = NewPoolTString(intermediate.getEntryPointName().c_str());
-}
-
// Return true if this has uniform-interface like decorations.
bool HlslParseContext::hasUniform(const TQualifier& qualifier) const
{
diff --git a/hlsl/hlslParseHelper.h b/hlsl/hlslParseHelper.h
index a276d6e..3f654e0 100755
--- a/hlsl/hlslParseHelper.h
+++ b/hlsl/hlslParseHelper.h
@@ -182,7 +182,7 @@
void pushNamespace(const TString& name);
void popNamespace();
- void getFullNamespaceName(const TString*&) const;
+ void getFullNamespaceName(TString*&) const;
void addScopeMangler(TString&);
void pushSwitchSequence(TIntermSequence* sequence) { switchSequenceStack.push_back(sequence); }
@@ -207,9 +207,6 @@
// Determine loop control from attributes
TLoopControl handleLoopControl(const TAttributeMap& attributes) const;
- // Potentially rename shader entry point function
- void renameShaderFunction(const TString*& name) const;
-
// Share struct buffer deep types
void shareStructBufferType(TType&);
@@ -423,7 +420,6 @@
unsigned int nextInLocation;
unsigned int nextOutLocation;
- TString sourceEntryPointName;
TFunction* entryPointFunction;
TIntermNode* entryPointFunctionBody;