Expose the sampler type from a TType, and add a way to rebuild just the sampler type name for messages/annotation.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@20672 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2013-02-21 17:22:17 +00:00
parent e141d5c99c
commit 6f045f3e72
5 changed files with 42 additions and 32 deletions

View File

@ -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;

View File

@ -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();
}

View File

@ -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

View File

@ -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();
}
}

View File

@ -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.
//