Array of Array prep: Turn a batch of 0's into nullptr or UnsizedArraySize.
Added some const as well. This will remove camouflage of the next commit, which will add the bulk of Array of Array semantics and functionality. (Note the basic grammar and data structure is already in place.)
This commit is contained in:
parent
6726cccc91
commit
b35483587f
7 changed files with 139 additions and 138 deletions
|
|
@ -804,8 +804,8 @@ public:
|
|||
vectorSize = 1;
|
||||
matrixRows = 0;
|
||||
matrixCols = 0;
|
||||
arraySizes = 0;
|
||||
userDef = 0;
|
||||
arraySizes = nullptr;
|
||||
userDef = nullptr;
|
||||
loc = l;
|
||||
}
|
||||
|
||||
|
|
@ -840,7 +840,7 @@ public:
|
|||
|
||||
bool isScalar() const
|
||||
{
|
||||
return matrixCols == 0 && vectorSize == 1 && arraySizes == 0 && userDef == 0;
|
||||
return matrixCols == 0 && vectorSize == 1 && arraySizes == nullptr && userDef == nullptr;
|
||||
}
|
||||
|
||||
bool isImage() const
|
||||
|
|
@ -858,8 +858,8 @@ public:
|
|||
|
||||
// for "empty" type (no args) or simple scalar/vector/matrix
|
||||
explicit TType(TBasicType t = EbtVoid, TStorageQualifier q = EvqTemporary, int vs = 1, int mc = 0, int mr = 0) :
|
||||
basicType(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), arraySizes(0),
|
||||
structure(0), fieldName(0), typeName(0)
|
||||
basicType(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), arraySizes(nullptr),
|
||||
structure(nullptr), fieldName(nullptr), typeName(nullptr)
|
||||
{
|
||||
sampler.clear();
|
||||
qualifier.clear();
|
||||
|
|
@ -867,8 +867,8 @@ public:
|
|||
}
|
||||
// for explicit precision qualifier
|
||||
TType(TBasicType t, TStorageQualifier q, TPrecisionQualifier p, int vs = 1, int mc = 0, int mr = 0) :
|
||||
basicType(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), arraySizes(0),
|
||||
structure(0), fieldName(0), typeName(0)
|
||||
basicType(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), arraySizes(nullptr),
|
||||
structure(nullptr), fieldName(nullptr), typeName(nullptr)
|
||||
{
|
||||
sampler.clear();
|
||||
qualifier.clear();
|
||||
|
|
@ -879,7 +879,7 @@ public:
|
|||
// for turning a TPublicType into a TType
|
||||
explicit TType(const TPublicType& p) :
|
||||
basicType(p.basicType), vectorSize(p.vectorSize), matrixCols(p.matrixCols), matrixRows(p.matrixRows), arraySizes(p.arraySizes),
|
||||
structure(0), fieldName(0), typeName(0)
|
||||
structure(nullptr), fieldName(nullptr), typeName(nullptr)
|
||||
{
|
||||
if (basicType == EbtSampler)
|
||||
sampler = p.sampler;
|
||||
|
|
@ -910,7 +910,7 @@ public:
|
|||
// for making structures, ...
|
||||
TType(TTypeList* userDef, const TString& n) :
|
||||
basicType(EbtStruct), vectorSize(1), matrixCols(0), matrixRows(0),
|
||||
arraySizes(0), structure(userDef), fieldName(0)
|
||||
arraySizes(nullptr), structure(userDef), fieldName(nullptr)
|
||||
{
|
||||
sampler.clear();
|
||||
qualifier.clear();
|
||||
|
|
@ -919,7 +919,7 @@ public:
|
|||
// For interface blocks
|
||||
TType(TTypeList* userDef, const TString& n, const TQualifier& q) :
|
||||
basicType(EbtBlock), vectorSize(1), matrixCols(0), matrixRows(0),
|
||||
qualifier(q), arraySizes(0), structure(userDef), fieldName(0)
|
||||
qualifier(q), arraySizes(nullptr), structure(userDef), fieldName(nullptr)
|
||||
{
|
||||
sampler.clear();
|
||||
typeName = NewPoolTString(n.c_str());
|
||||
|
|
@ -1000,7 +1000,7 @@ public:
|
|||
virtual void dereference(bool rowMajor = false)
|
||||
{
|
||||
if (arraySizes)
|
||||
arraySizes = 0;
|
||||
arraySizes = nullptr;
|
||||
else if (matrixCols > 0) {
|
||||
if (rowMajor)
|
||||
vectorSize = matrixCols;
|
||||
|
|
@ -1039,17 +1039,17 @@ public:
|
|||
virtual int getMatrixCols() const { return matrixCols; }
|
||||
virtual int getMatrixRows() const { return matrixRows; }
|
||||
virtual int getArraySize() const { return arraySizes->getOuterSize(); }
|
||||
virtual bool isArrayOfArrays() const { return arraySizes && arraySizes->getNumDims() > 1; }
|
||||
virtual bool isArrayOfArrays() const { return arraySizes != nullptr && arraySizes->getNumDims() > 1; }
|
||||
virtual int getImplicitArraySize() const { return arraySizes->getImplicitSize(); }
|
||||
|
||||
virtual bool isScalar() const { return vectorSize == 1 && ! isStruct() && ! isArray(); }
|
||||
virtual bool isVector() const { return vectorSize > 1; }
|
||||
virtual bool isMatrix() const { return matrixCols ? true : false; }
|
||||
virtual bool isArray() const { return arraySizes != 0; }
|
||||
virtual bool isImplicitlySizedArray() const { return isArray() && ! getArraySize() && qualifier.storage != EvqBuffer; }
|
||||
virtual bool isExplicitlySizedArray() const { return isArray() && getArraySize(); }
|
||||
virtual bool isRuntimeSizedArray() const { return isArray() && ! getArraySize() && qualifier.storage == EvqBuffer; }
|
||||
virtual bool isStruct() const { return structure != 0; }
|
||||
virtual bool isArray() const { return arraySizes != nullptr; }
|
||||
virtual bool isExplicitlySizedArray() const { return isArray() && getArraySize() != UnsizedArraySize; }
|
||||
virtual bool isImplicitlySizedArray() const { return isArray() && getArraySize() == UnsizedArraySize && qualifier.storage != EvqBuffer; }
|
||||
virtual bool isRuntimeSizedArray() const { return isArray() && getArraySize() == UnsizedArraySize && qualifier.storage == EvqBuffer; }
|
||||
virtual bool isStruct() const { return structure != nullptr; }
|
||||
virtual bool isImage() const { return basicType == EbtSampler && getSampler().image; }
|
||||
|
||||
// Recursively checks if the type contains the given basic type
|
||||
|
|
@ -1071,7 +1071,7 @@ public:
|
|||
{
|
||||
if (isArray())
|
||||
return true;
|
||||
if (! structure)
|
||||
if (structure == nullptr)
|
||||
return false;
|
||||
for (unsigned int i = 0; i < structure->size(); ++i) {
|
||||
if ((*structure)[i].type->containsArray())
|
||||
|
|
@ -1083,7 +1083,7 @@ public:
|
|||
// Check the structure for any structures, needed for some error checks
|
||||
virtual bool containsStructure() const
|
||||
{
|
||||
if (! structure)
|
||||
if (structure == nullptr)
|
||||
return false;
|
||||
for (unsigned int i = 0; i < structure->size(); ++i) {
|
||||
if ((*structure)[i].type->structure)
|
||||
|
|
@ -1097,7 +1097,7 @@ public:
|
|||
{
|
||||
if (isImplicitlySizedArray())
|
||||
return true;
|
||||
if (! structure)
|
||||
if (structure == nullptr)
|
||||
return false;
|
||||
for (unsigned int i = 0; i < structure->size(); ++i) {
|
||||
if ((*structure)[i].type->containsImplicitlySizedArray())
|
||||
|
|
@ -1242,11 +1242,10 @@ public:
|
|||
p += snprintf(p, end - p, "writeonly ");
|
||||
p += snprintf(p, end - p, "%s ", getStorageQualifierString());
|
||||
if (arraySizes) {
|
||||
if (arraySizes->getOuterSize() == 0) {
|
||||
if (arraySizes->getOuterSize() == UnsizedArraySize) {
|
||||
p += snprintf(p, end - p, "implicitly-sized array of ");
|
||||
} else {
|
||||
for(int i = 0; i < (int)arraySizes->getNumDims() ; ++i) {
|
||||
// p += snprintf(p, end - p, "%s%d", (i == 0 ? "" : "x"), arraySizes->sizes[numDimensions-1-i]);
|
||||
p += snprintf(p, end - p, "%d-element array of ", (*arraySizes)[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1337,12 +1336,12 @@ public:
|
|||
//
|
||||
bool sameStructType(const TType& right) const
|
||||
{
|
||||
// Most commonly, they are both 0, or the same pointer to the same actual structure
|
||||
// Most commonly, they are both nullptr, or the same pointer to the same actual structure
|
||||
if (structure == right.structure)
|
||||
return true;
|
||||
|
||||
// Both being 0 was caught above, now they both have to be structures of the same number of elements
|
||||
if (structure == 0 || right.structure == 0 ||
|
||||
// Both being nullptr was caught above, now they both have to be structures of the same number of elements
|
||||
if (structure == nullptr || right.structure == nullptr ||
|
||||
structure->size() != right.structure->size())
|
||||
return false;
|
||||
|
||||
|
|
@ -1371,7 +1370,7 @@ public:
|
|||
// See if two type's arrayness match
|
||||
bool sameArrayness(const TType& right) const
|
||||
{
|
||||
return ((arraySizes == 0 && right.arraySizes == 0) ||
|
||||
return ((arraySizes == nullptr && right.arraySizes == nullptr) ||
|
||||
(arraySizes && right.arraySizes && *arraySizes == *right.arraySizes));
|
||||
}
|
||||
|
||||
|
|
@ -1410,8 +1409,8 @@ protected:
|
|||
TSampler sampler;
|
||||
TQualifier qualifier;
|
||||
|
||||
TArraySizes* arraySizes; // 0 unless an array; can be shared across types
|
||||
TTypeList* structure; // 0 unless this is a struct; can be shared across types
|
||||
TArraySizes* arraySizes; // nullptr unless an array; can be shared across types
|
||||
TTypeList* structure; // nullptr unless this is a struct; can be shared across types
|
||||
TString *fieldName; // for structure field names
|
||||
TString *typeName; // for structure type name
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue