From 4dc835c369aa9d79d2012d0903f9628e2721905b Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Tue, 28 Mar 2017 23:43:10 -0600 Subject: [PATCH] Non-functional: Round of adding 'const', related to more efficient getFullNamespaceName(). --- glslang/Include/revision.h | 2 +- .../MachineIndependent/ParseContextBase.cpp | 2 +- glslang/MachineIndependent/ParseHelper.cpp | 4 +-- glslang/MachineIndependent/ParseHelper.h | 6 ++-- hlsl/hlslGrammar.cpp | 5 ++-- hlsl/hlslParseHelper.cpp | 28 +++++++++---------- hlsl/hlslParseHelper.h | 16 +++++------ 7 files changed, 32 insertions(+), 31 deletions(-) diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index aba195a5..6dd31fca 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -2,5 +2,5 @@ // For the version, it uses the latest git tag followed by the number of commits. // For the date, it uses the current date (when then script is run). -#define GLSLANG_REVISION "Overload400-PrecQual.1937" +#define GLSLANG_REVISION "Overload400-PrecQual.1939" #define GLSLANG_DATE "28-Mar-2017" diff --git a/glslang/MachineIndependent/ParseContextBase.cpp b/glslang/MachineIndependent/ParseContextBase.cpp index d2b6b260..44fc0b47 100644 --- a/glslang/MachineIndependent/ParseContextBase.cpp +++ b/glslang/MachineIndependent/ParseContextBase.cpp @@ -531,7 +531,7 @@ void TParseContextBase::parseSwizzleSelector(const TSourceLoc& loc, const TStrin // Make the passed-in variable information become a member of the // global uniform block. If this doesn't exist yet, make it. // -void TParseContextBase::growGlobalUniformBlock(TSourceLoc& loc, TType& memberType, TString& memberName, TTypeList* typeList) +void TParseContextBase::growGlobalUniformBlock(const TSourceLoc& loc, TType& memberType, const TString& memberName, TTypeList* typeList) { // Make the global block, if not yet made. if (globalUniformBlock == nullptr) { diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index a6fe9bdf..ccd5bf7a 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -2990,7 +2990,7 @@ void TParseContext::arrayDimMerge(TType& type, const TArraySizes* sizes) // Do all the semantic checking for declaring or redeclaring an array, with and // without a size, and make the right changes to the symbol table. // -void TParseContext::declareArray(const TSourceLoc& loc, TString& identifier, const TType& type, TSymbol*& symbol) +void TParseContext::declareArray(const TSourceLoc& loc, const TString& identifier, const TType& type, TSymbol*& symbol) { if (symbol == nullptr) { bool currentScope; @@ -5053,7 +5053,7 @@ TVariable* TParseContext::makeInternalVariable(const char* name, const TType& ty // // Return the successfully declared variable. // -TVariable* TParseContext::declareNonArray(const TSourceLoc& loc, TString& identifier, TType& type) +TVariable* TParseContext::declareNonArray(const TSourceLoc& loc, const TString& identifier, const TType& type) { // make a new variable TVariable* variable = new TVariable(&identifier, type); diff --git a/glslang/MachineIndependent/ParseHelper.h b/glslang/MachineIndependent/ParseHelper.h index 6d4fd341..dc9dc6a0 100644 --- a/glslang/MachineIndependent/ParseHelper.h +++ b/glslang/MachineIndependent/ParseHelper.h @@ -136,7 +136,7 @@ public: TSymbolTable& symbolTable; // symbol table that goes with the current language, version, and profile // Manage the global uniform block (default uniforms in GLSL, $Global in HLSL) - virtual void growGlobalUniformBlock(TSourceLoc&, TType&, TString& memberName, TTypeList* typeList = nullptr); + virtual void growGlobalUniformBlock(const TSourceLoc&, TType&, const TString& memberName, TTypeList* typeList = nullptr); virtual bool lValueErrorCheck(const TSourceLoc&, const char* op, TIntermTyped*); virtual void rValueErrorCheck(const TSourceLoc&, const char* op, TIntermTyped*); @@ -371,8 +371,8 @@ protected: void nonInitConstCheck(const TSourceLoc&, TString& identifier, TType& type); void inheritGlobalDefaults(TQualifier& dst) const; TVariable* makeInternalVariable(const char* name, const TType&) const; - TVariable* declareNonArray(const TSourceLoc&, TString& identifier, TType&); - void declareArray(const TSourceLoc&, TString& identifier, const TType&, TSymbol*&); + TVariable* declareNonArray(const TSourceLoc&, const TString& identifier, const TType&); + void declareArray(const TSourceLoc&, const TString& identifier, const TType&, TSymbol*&); TIntermNode* executeInitializer(const TSourceLoc&, TIntermTyped* initializer, TVariable* variable); TIntermTyped* convertInitializerList(const TSourceLoc&, const TType&, TIntermTyped* initializer); void finish() override; diff --git a/hlsl/hlslGrammar.cpp b/hlsl/hlslGrammar.cpp index 3ef3e9d5..155a5b81 100755 --- a/hlsl/hlslGrammar.cpp +++ b/hlsl/hlslGrammar.cpp @@ -344,7 +344,7 @@ bool HlslGrammar::acceptDeclaration(TIntermNode*& nodeList) while (acceptIdentifier(idToken)) { if (peekTokenClass(EHTokLeftParen)) { // looks like function parameters - TString* fnName = idToken.string; + const TString* fnName = idToken.string; // Potentially rename shader entry point function. No-op most of the time. parseContext.renameShaderFunction(fnName); @@ -2090,7 +2090,8 @@ bool HlslGrammar::acceptMemberFunctionDefinition(TIntermNode*& nodeList, const T { bool accepted = false; - TString* functionName = parseContext.getFullNamespaceName(memberName); + const TString* functionName = &memberName; + parseContext.getFullNamespaceName(functionName); declarator.function = new TFunction(functionName, type); if (type.getQualifier().storage == EvqTemporary) declarator.function->setImplicitThis(); diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp index 48b94b62..da2f1ae3 100755 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -162,7 +162,7 @@ bool HlslParseContext::shouldConvertLValue(const TIntermNode* node) const return false; } -void HlslParseContext::growGlobalUniformBlock(TSourceLoc& loc, TType& memberType, TString& memberName, TTypeList* newTypeList) +void HlslParseContext::growGlobalUniformBlock(const TSourceLoc& loc, TType& memberType, const TString& memberName, TTypeList* newTypeList) { newTypeList = nullptr; correctUniform(memberType.getQualifier()); @@ -4759,7 +4759,7 @@ void HlslParseContext::arrayDimMerge(TType& type, const TArraySizes* sizes) // Do all the semantic checking for declaring or redeclaring an array, with and // without a size, and make the right changes to the symbol table. // -void HlslParseContext::declareArray(const TSourceLoc& loc, TString& identifier, const TType& type, TSymbol*& symbol, bool track) +void HlslParseContext::declareArray(const TSourceLoc& loc, const TString& identifier, const TType& type, TSymbol*& symbol, bool track) { if (! symbol) { bool currentScope; @@ -4857,7 +4857,7 @@ void HlslParseContext::updateImplicitArraySize(const TSourceLoc& loc, TIntermNod // // Enforce non-initializer type/qualifier rules. // -void HlslParseContext::fixConstInit(const TSourceLoc& loc, TString& identifier, TType& type, TIntermTyped*& initializer) +void HlslParseContext::fixConstInit(const TSourceLoc& loc, const TString& identifier, TType& type, TIntermTyped*& initializer) { // // Make the qualifier make sense, given that there is an initializer. @@ -5846,7 +5846,7 @@ const TFunction* HlslParseContext::findFunction(const TSourceLoc& loc, TFunction // 'parseType' is the type part of the declaration (to the left) // 'arraySizes' is the arrayness tagged on the identifier (to the right) // -void HlslParseContext::declareTypedef(const TSourceLoc& loc, TString& identifier, const TType& parseType) +void HlslParseContext::declareTypedef(const TSourceLoc& loc, const TString& identifier, const TType& parseType) { TVariable* typeSymbol = new TVariable(&identifier, parseType, true); if (! symbolTable.insert(*typeSymbol)) @@ -5977,7 +5977,7 @@ TSymbol* HlslParseContext::lookupUserType(const TString& typeName, TType& type) // 'parseType' is the type part of the declaration (to the left) // 'arraySizes' is the arrayness tagged on the identifier (to the right) // -TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, TString& identifier, TType& type, TIntermTyped* initializer) +TIntermNode* HlslParseContext::declareVariable(const TSourceLoc& loc, const TString& identifier, TType& type, TIntermTyped* initializer) { if (voidErrorCheck(loc, identifier, type.getBasicType())) return nullptr; @@ -6079,7 +6079,7 @@ TVariable* HlslParseContext::makeInternalVariable(const char* name, const TType& // // Return the successfully declared variable. // -TVariable* HlslParseContext::declareNonArray(const TSourceLoc& loc, TString& identifier, TType& type, bool track) +TVariable* HlslParseContext::declareNonArray(const TSourceLoc& loc, const TString& identifier, const TType& type, bool track) { // make a new variable TVariable* variable = new TVariable(&identifier, type); @@ -7132,15 +7132,15 @@ void HlslParseContext::popNamespace() // Use the class/struct nesting string to create a global name for // a member of a class/struct. -TString* HlslParseContext::getFullNamespaceName(const TString& localName) const +void HlslParseContext::getFullNamespaceName(const TString*& name) const { - TString* name = NewPoolTString(""); - if (currentTypePrefix.size() > 0) - name->append(currentTypePrefix.back()); - name->append(scopeMangler); - name->append(localName); + if (currentTypePrefix.size() == 0) + return; - return name; + TString* fullName = NewPoolTString(currentTypePrefix.back().c_str()); + fullName->append(scopeMangler); + fullName->append(*name); + name = fullName; } // Helper function to add the namespace scope mangling syntax to a string. @@ -7150,7 +7150,7 @@ void HlslParseContext::addScopeMangler(TString& name) } // Potentially rename shader entry point function -void HlslParseContext::renameShaderFunction(TString*& name) const +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. diff --git a/hlsl/hlslParseHelper.h b/hlsl/hlslParseHelper.h index 2d196811..f5f2d07f 100755 --- a/hlsl/hlslParseHelper.h +++ b/hlsl/hlslParseHelper.h @@ -136,10 +136,10 @@ public: void checkNoShaderLayouts(const TSourceLoc&, const TShaderQualifiers&); const TFunction* findFunction(const TSourceLoc& loc, TFunction& call, bool& builtIn, TIntermTyped*& args); - void declareTypedef(const TSourceLoc&, TString& identifier, const TType&); + void declareTypedef(const TSourceLoc&, const TString& identifier, const TType&); void declareStruct(const TSourceLoc&, TString& structName, TType&); TSymbol* lookupUserType(const TString&, TType&); - TIntermNode* declareVariable(const TSourceLoc&, TString& identifier, TType&, TIntermTyped* initializer = 0); + TIntermNode* declareVariable(const TSourceLoc&, const TString& identifier, TType&, TIntermTyped* initializer = 0); void lengthenList(const TSourceLoc&, TIntermSequence& list, int size); TIntermTyped* addConstructor(const TSourceLoc&, TIntermNode*, const TType&); TIntermTyped* constructAggregate(TIntermNode*, const TType&, int, const TSourceLoc&); @@ -173,13 +173,13 @@ public: void pushNamespace(const TString& name); void popNamespace(); - TString* getFullNamespaceName(const TString& localName) const; + void getFullNamespaceName(const TString*&) const; void addScopeMangler(TString&); void pushSwitchSequence(TIntermSequence* sequence) { switchSequenceStack.push_back(sequence); } void popSwitchSequence() { switchSequenceStack.pop_back(); } - virtual void growGlobalUniformBlock(TSourceLoc&, TType&, TString& memberName, TTypeList* typeList = nullptr) override; + virtual void growGlobalUniformBlock(const TSourceLoc&, TType&, const TString& memberName, TTypeList* typeList = nullptr) override; // Apply L-value conversions. E.g, turning a write to a RWTexture into an ImageStore. TIntermTyped* handleLvalue(const TSourceLoc&, const char* op, TIntermTyped* node); @@ -191,7 +191,7 @@ public: bool handleInputGeometry(const TSourceLoc&, const TLayoutGeometry& geometry); // Potentially rename shader entry point function - void renameShaderFunction(TString*& name) const; + void renameShaderFunction(const TString*& name) const; // Reset data for incrementally built referencing of flattened composite structures void initFlattening() { flattenLevel.push_back(0); flattenOffset.push_back(0); } @@ -210,14 +210,14 @@ protected: int nextBinding; // next binding to use. }; - void fixConstInit(const TSourceLoc&, TString& identifier, TType& type, TIntermTyped*& initializer); + void fixConstInit(const TSourceLoc&, const TString& identifier, TType& type, TIntermTyped*& initializer); void inheritGlobalDefaults(TQualifier& dst) const; TVariable* makeInternalVariable(const char* name, const TType&) const; TVariable* makeInternalVariable(const TString& name, const TType& type) const { return makeInternalVariable(name.c_str(), type); } - TVariable* declareNonArray(const TSourceLoc&, TString& identifier, TType&, bool track); - void declareArray(const TSourceLoc&, TString& identifier, const TType&, TSymbol*&, bool track); + TVariable* declareNonArray(const TSourceLoc&, const TString& identifier, const TType&, bool track); + void declareArray(const TSourceLoc&, const TString& identifier, const TType&, TSymbol*&, bool track); TIntermNode* executeInitializer(const TSourceLoc&, TIntermTyped* initializer, TVariable* variable); TIntermTyped* convertInitializerList(const TSourceLoc&, const TType&, TIntermTyped* initializer); bool isZeroConstructor(const TIntermNode*);