diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index c1710914..8d6c1350 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -350,6 +350,7 @@ public: } virtual TBasicType getBasicType() const { return type; } + virtual const TSampler& getSampler() const { return sampler; } virtual TQualifier& getQualifier() { return qualifier; } virtual const TQualifier& getQualifier() const { return qualifier; } @@ -384,6 +385,9 @@ public: default: return "unknown type"; } } + TString getCompleteString() const; + TString getCompleteTypeString() const; + const char* getBasicString() const { return TType::getBasicString(type); } const char* getStorageQualifierString() const { return ::getStorageQualifierString(qualifier.storage); } const char* getPrecisionQualifierString() const { return ::getPrecisionQualifierString(qualifier.precision); } @@ -441,8 +445,6 @@ public: return !operator==(right); } - TString getCompleteString() const; - protected: void buildMangledName(TString&); int getStructSize() const; diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 497a9b7c..8dd4cfe5 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -612,7 +612,7 @@ bool TParseContext::samplerErrorCheck(int line, const TPublicType& pType, const { if (pType.type == EbtStruct) { if (containsSampler(*pType.userDef)) { - error(line, reason, TType::getBasicString(pType.type), "(structure contains a sampler)"); + error(line, reason, TType::getBasicString(pType.type), "(structure contains a sampler/image)"); return true; } @@ -683,7 +683,7 @@ bool TParseContext::parameterSamplerErrorCheck(int line, TStorageQualifier quali { if ((qualifier == EvqOut || qualifier == EvqInOut) && type.getBasicType() != EbtStruct && type.getBasicType() == EbtSampler) { - error(line, "samplers cannot be output parameters", type.getBasicString(), ""); + error(line, "samplers cannot be output parameters", type.getCompleteTypeString().c_str(), ""); return true; } @@ -1334,7 +1334,7 @@ TIntermTyped* TParseContext::constructStruct(TIntermNode* node, TType* type, int return intermediate.setAggregateOperator(node->getAsTyped(), EOpConstructStruct, line); } else { error(line, "", "constructor", "cannot convert parameter %d from '%s' to '%s'", paramCount, - node->getAsTyped()->getType().getBasicString(), type->getBasicString()); + node->getAsTyped()->getType().getCompleteTypeString().c_str(), type->getCompleteTypeString().c_str()); recover(); } diff --git a/glslang/MachineIndependent/SymbolTable.cpp b/glslang/MachineIndependent/SymbolTable.cpp index 038c55da..9fe5dc18 100644 --- a/glslang/MachineIndependent/SymbolTable.cpp +++ b/glslang/MachineIndependent/SymbolTable.cpp @@ -131,7 +131,7 @@ int TType::getStructSize() const void TVariable::dump(TInfoSink& infoSink) const { - infoSink.debug << getName().c_str() << ": " << type.getStorageQualifierString() << " " << type.getBasicString(); + infoSink.debug << getName().c_str() << ": " << type.getStorageQualifierString() << " " << type.getCompleteTypeString(); if (type.isArray()) { infoSink.debug << "[0]"; } @@ -140,7 +140,7 @@ void TVariable::dump(TInfoSink& infoSink) const void TFunction::dump(TInfoSink &infoSink) const { - infoSink.debug << getName().c_str() << ": " << returnType.getBasicString() << " " << getMangledName().c_str() << "\n"; + infoSink.debug << getName().c_str() << ": " << returnType.getCompleteTypeString() << " " << getMangledName().c_str() << "\n"; } void TSymbolTableLevel::dump(TInfoSink &infoSink) const diff --git a/glslang/MachineIndependent/glslang.y b/glslang/MachineIndependent/glslang.y index 2ba802d3..81ceb480 100644 --- a/glslang/MachineIndependent/glslang.y +++ b/glslang/MachineIndependent/glslang.y @@ -1203,7 +1203,7 @@ function_prototype TFunction* prevDec = symbol ? symbol->getAsFunction() : 0; if (prevDec) { if (prevDec->getReturnType() != $1->getReturnType()) { - parseContext.error($2.line, "overloaded functions must have the same return type", $1->getReturnType().getBasicString(), ""); + parseContext.error($2.line, "overloaded functions must have the same return type", $1->getReturnType().getCompleteTypeString().c_str(), ""); parseContext.recover(); } for (int i = 0; i < prevDec->getParamCount(); ++i) { @@ -2950,7 +2950,7 @@ function_definition parseContext.recover(); } if (function.getReturnType().getBasicType() != EbtVoid) { - parseContext.error($1.line, "", function.getReturnType().getBasicString(), "main function cannot return a value"); + parseContext.error($1.line, "", function.getReturnType().getCompleteTypeString().c_str(), "main function cannot return a value"); parseContext.recover(); } } diff --git a/glslang/MachineIndependent/intermOut.cpp b/glslang/MachineIndependent/intermOut.cpp index e9e6e62a..e004b80e 100644 --- a/glslang/MachineIndependent/intermOut.cpp +++ b/glslang/MachineIndependent/intermOut.cpp @@ -55,30 +55,9 @@ public: TInfoSink& infoSink; }; -TString TType::getCompleteString() const +TString TType::getCompleteTypeString() const { - const int maxSize = 100; - char buf[maxSize]; - char *p = &buf[0]; - char *end = &buf[maxSize]; - - if (qualifier.storage != EvqTemporary && qualifier.storage != EvqGlobal) - p += snprintf(p, end - p, "%s ", getStorageQualifierString()); - if (arraySizes) { - if (arraySizes->front() == 0) - p += snprintf(p, end - p, "unsized array of "); - else - p += snprintf(p, end - p, "%d-element array of ", arraySizes->front()); - } - if (qualifier.precision != EpqNone) - p += snprintf(p, end - p, "%s ", getPrecisionQualifierString()); - if (matrixCols > 0) - p += snprintf(p, end - p, "%dX%d matrix of ", matrixCols, matrixRows); - else if (vectorSize > 1) - p += snprintf(p, end - p, "%d-component vector of ", vectorSize); - - *p = 0; - TString s(buf); + TString s; if (type == EbtSampler) { switch (sampler.type) { @@ -110,6 +89,35 @@ TString TType::getCompleteString() const return s; } +TString TType::getCompleteString() const +{ + const int maxSize = 100; + char buf[maxSize]; + char *p = &buf[0]; + char *end = &buf[maxSize]; + + if (qualifier.storage != EvqTemporary && qualifier.storage != EvqGlobal) + p += snprintf(p, end - p, "%s ", getStorageQualifierString()); + if (arraySizes) { + if (arraySizes->front() == 0) + p += snprintf(p, end - p, "unsized array of "); + else + p += snprintf(p, end - p, "%d-element array of ", arraySizes->front()); + } + if (qualifier.precision != EpqNone) + p += snprintf(p, end - p, "%s ", getPrecisionQualifierString()); + if (matrixCols > 0) + p += snprintf(p, end - p, "%dX%d matrix of ", matrixCols, matrixRows); + else if (vectorSize > 1) + p += snprintf(p, end - p, "%d-component vector of ", vectorSize); + + *p = 0; + TString s(buf); + s.append(getCompleteTypeString()); + + return s; +} + // // Helper functions for printing, not part of traversing. //