summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/compiler/translator/Types.h
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/angle/src/compiler/translator/Types.h')
-rwxr-xr-xgfx/angle/src/compiler/translator/Types.h232
1 files changed, 89 insertions, 143 deletions
diff --git a/gfx/angle/src/compiler/translator/Types.h b/gfx/angle/src/compiler/translator/Types.h
index fc26d5f59..2a85e010c 100755
--- a/gfx/angle/src/compiler/translator/Types.h
+++ b/gfx/angle/src/compiler/translator/Types.h
@@ -13,9 +13,6 @@
#include "compiler/translator/BaseTypes.h"
#include "compiler/translator/Common.h"
-namespace sh
-{
-
struct TPublicType;
class TType;
class TSymbol;
@@ -106,7 +103,13 @@ class TStructure : public TFieldListCollection
{
public:
POOL_ALLOCATOR_NEW_DELETE();
- TStructure(const TString *name, TFieldList *fields);
+ TStructure(const TString *name, TFieldList *fields)
+ : TFieldListCollection(name, fields),
+ mDeepestNesting(0),
+ mUniqueId(0),
+ mAtGlobalScope(false)
+ {
+ }
int deepestNesting() const
{
@@ -117,7 +120,6 @@ class TStructure : public TFieldListCollection
bool containsArrays() const;
bool containsType(TBasicType t) const;
bool containsSamplers() const;
- bool containsImages() const;
void createSamplerSymbols(const TString &structName,
const TString &structAPIName,
@@ -233,18 +235,10 @@ class TType
public:
POOL_ALLOCATOR_NEW_DELETE();
TType()
- : type(EbtVoid),
- precision(EbpUndefined),
- qualifier(EvqGlobal),
- invariant(false),
- memoryQualifier(TMemoryQualifier::create()),
+ : type(EbtVoid), precision(EbpUndefined), qualifier(EvqGlobal), invariant(false),
layoutQualifier(TLayoutQualifier::create()),
- primarySize(0),
- secondarySize(0),
- array(false),
- arraySize(0),
- interfaceBlock(nullptr),
- structure(nullptr)
+ primarySize(0), secondarySize(0), array(false), arraySize(0),
+ interfaceBlock(nullptr), structure(nullptr)
{
}
explicit TType(TBasicType t, unsigned char ps = 1, unsigned char ss = 1)
@@ -252,7 +246,6 @@ class TType
precision(EbpUndefined),
qualifier(EvqGlobal),
invariant(false),
- memoryQualifier(TMemoryQualifier::create()),
layoutQualifier(TLayoutQualifier::create()),
primarySize(ps),
secondarySize(ss),
@@ -262,24 +255,12 @@ class TType
structure(0)
{
}
- TType(TBasicType t,
- TPrecision p,
- TQualifier q = EvqTemporary,
- unsigned char ps = 1,
- unsigned char ss = 1,
- bool a = false)
- : type(t),
- precision(p),
- qualifier(q),
- invariant(false),
- memoryQualifier(TMemoryQualifier::create()),
+ TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary,
+ unsigned char ps = 1, unsigned char ss = 1, bool a = false)
+ : type(t), precision(p), qualifier(q), invariant(false),
layoutQualifier(TLayoutQualifier::create()),
- primarySize(ps),
- secondarySize(ss),
- array(a),
- arraySize(0),
- interfaceBlock(0),
- structure(0)
+ primarySize(ps), secondarySize(ss), array(a), arraySize(0),
+ interfaceBlock(0), structure(0)
{
}
explicit TType(const TPublicType &p);
@@ -288,7 +269,6 @@ class TType
precision(p),
qualifier(EvqTemporary),
invariant(false),
- memoryQualifier(TMemoryQualifier::create()),
layoutQualifier(TLayoutQualifier::create()),
primarySize(1),
secondarySize(1),
@@ -298,22 +278,12 @@ class TType
structure(userDef)
{
}
- TType(TInterfaceBlock *interfaceBlockIn,
- TQualifier qualifierIn,
- TLayoutQualifier layoutQualifierIn,
- int arraySizeIn)
- : type(EbtInterfaceBlock),
- precision(EbpUndefined),
- qualifier(qualifierIn),
- invariant(false),
- memoryQualifier(TMemoryQualifier::create()),
- layoutQualifier(layoutQualifierIn),
- primarySize(1),
- secondarySize(1),
- array(arraySizeIn > 0),
- arraySize(arraySizeIn),
- interfaceBlock(interfaceBlockIn),
- structure(0)
+ TType(TInterfaceBlock *interfaceBlockIn, TQualifier qualifierIn,
+ TLayoutQualifier layoutQualifierIn, int arraySizeIn)
+ : type(EbtInterfaceBlock), precision(EbpUndefined), qualifier(qualifierIn),
+ invariant(false), layoutQualifier(layoutQualifierIn),
+ primarySize(1), secondarySize(1), array(arraySizeIn > 0), arraySize(arraySizeIn),
+ interfaceBlock(interfaceBlockIn), structure(0)
{
}
@@ -358,9 +328,6 @@ class TType
void setInvariant(bool i) { invariant = i; }
- TMemoryQualifier getMemoryQualifier() const { return memoryQualifier; }
- void setMemoryQualifier(const TMemoryQualifier &mq) { memoryQualifier = mq; }
-
TLayoutQualifier getLayoutQualifier() const
{
return layoutQualifier;
@@ -538,16 +505,16 @@ class TType
const char *getBasicString() const
{
- return sh::getBasicString(type);
+ return ::getBasicString(type);
}
const char *getPrecisionString() const
{
- return sh::getPrecisionString(precision);
+ return ::getPrecisionString(precision);
}
const char *getQualifierString() const
{
- return sh::getQualifierString(qualifier);
+ return ::getQualifierString(qualifier);
}
const char *getBuiltInTypeNameString() const;
@@ -586,11 +553,6 @@ class TType
return structure ? structure->containsSamplers() : false;
}
- bool isStructureContainingImages() const
- {
- return structure ? structure->containsImages() : false;
- }
-
void createSamplerSymbols(const TString &structName,
const TString &structAPIName,
const unsigned int arrayOfStructsSize,
@@ -617,7 +579,6 @@ class TType
TPrecision precision;
TQualifier qualifier;
bool invariant;
- TMemoryQualifier memoryQualifier;
TLayoutQualifier layoutQualifier;
unsigned char primarySize; // size of vector or cols matrix
unsigned char secondarySize; // rows of a matrix
@@ -633,25 +594,44 @@ class TType
mutable TString mangled;
};
-// TTypeSpecifierNonArray stores all of the necessary fields for type_specifier_nonarray from the
-// grammar
-struct TTypeSpecifierNonArray
+//
+// This is a workaround for a problem with the yacc stack, It can't have
+// types that it thinks have non-trivial constructors. It should
+// just be used while recognizing the grammar, not anything else. Pointers
+// could be used, but also trying to avoid lots of memory management overhead.
+//
+// Not as bad as it looks, there is no actual assumption that the fields
+// match up or are name the same or anything like that.
+//
+struct TPublicType
{
TBasicType type;
+ TLayoutQualifier layoutQualifier;
+ TQualifier qualifier;
+ bool invariant;
+ TPrecision precision;
unsigned char primarySize; // size of vector or cols of matrix
unsigned char secondarySize; // rows of matrix
+ bool array;
+ int arraySize;
TType *userDef;
TSourceLoc line;
// true if the type was defined by a struct specifier rather than a reference to a type name.
bool isStructSpecifier;
- void initialize(TBasicType bt, const TSourceLoc &ln)
+ void setBasic(TBasicType bt, TQualifier q, const TSourceLoc &ln)
{
type = bt;
+ layoutQualifier = TLayoutQualifier::create();
+ qualifier = q;
+ invariant = false;
+ precision = EbpUndefined;
primarySize = 1;
secondarySize = 1;
- userDef = nullptr;
+ array = false;
+ arraySize = 0;
+ userDef = 0;
line = ln;
isStructSpecifier = false;
}
@@ -661,113 +641,79 @@ struct TTypeSpecifierNonArray
primarySize = size;
}
- void setMatrix(unsigned char columns, unsigned char rows)
+ void setMatrix(unsigned char c, unsigned char r)
{
- ASSERT(columns > 1 && rows > 1 && columns <= 4 && rows <= 4);
- primarySize = columns;
- secondarySize = rows;
+ ASSERT(c > 1 && r > 1 && c <= 4 && r <= 4);
+ primarySize = c;
+ secondarySize = r;
}
- bool isMatrix() const { return primarySize > 1 && secondarySize > 1; }
-
- bool isVector() const { return primarySize > 1 && secondarySize == 1; }
-};
-
-//
-// This is a workaround for a problem with the yacc stack, It can't have
-// types that it thinks have non-trivial constructors. It should
-// just be used while recognizing the grammar, not anything else. Pointers
-// could be used, but also trying to avoid lots of memory management overhead.
-//
-// Not as bad as it looks, there is no actual assumption that the fields
-// match up or are name the same or anything like that.
-//
-struct TPublicType
-{
- TTypeSpecifierNonArray typeSpecifierNonArray;
- TLayoutQualifier layoutQualifier;
- TMemoryQualifier memoryQualifier;
- TQualifier qualifier;
- bool invariant;
- TPrecision precision;
- bool array;
- int arraySize;
-
- void initialize(const TTypeSpecifierNonArray &typeSpecifier, TQualifier q)
+ bool isUnsizedArray() const
{
- typeSpecifierNonArray = typeSpecifier;
- layoutQualifier = TLayoutQualifier::create();
- memoryQualifier = TMemoryQualifier::create();
- qualifier = q;
- invariant = false;
- precision = EbpUndefined;
- array = false;
- arraySize = 0;
+ return array && arraySize == 0;
}
-
- void initializeBasicType(TBasicType basicType)
+ void setArraySize(int s)
{
- typeSpecifierNonArray.type = basicType;
- typeSpecifierNonArray.primarySize = 1;
- typeSpecifierNonArray.secondarySize = 1;
- layoutQualifier = TLayoutQualifier::create();
- memoryQualifier = TMemoryQualifier::create();
- qualifier = EvqTemporary;
- invariant = false;
- precision = EbpUndefined;
- array = false;
- arraySize = 0;
+ array = true;
+ arraySize = s;
+ }
+ void clearArrayness()
+ {
+ array = false;
+ arraySize = 0;
}
-
- TBasicType getBasicType() const { return typeSpecifierNonArray.type; }
- void setBasicType(TBasicType basicType) { typeSpecifierNonArray.type = basicType; }
-
- unsigned char getPrimarySize() const { return typeSpecifierNonArray.primarySize; }
- unsigned char getSecondarySize() const { return typeSpecifierNonArray.secondarySize; }
-
- const TType *getUserDef() const { return typeSpecifierNonArray.userDef; }
- const TSourceLoc &getLine() const { return typeSpecifierNonArray.line; }
-
- bool isStructSpecifier() const { return typeSpecifierNonArray.isStructSpecifier; }
bool isStructureContainingArrays() const
{
- if (!typeSpecifierNonArray.userDef)
+ if (!userDef)
{
return false;
}
- return typeSpecifierNonArray.userDef->isStructureContainingArrays();
+ return userDef->isStructureContainingArrays();
}
bool isStructureContainingType(TBasicType t) const
{
- if (!typeSpecifierNonArray.userDef)
+ if (!userDef)
{
return false;
}
- return typeSpecifierNonArray.userDef->isStructureContainingType(t);
+ return userDef->isStructureContainingType(t);
}
- bool isUnsizedArray() const { return array && arraySize == 0; }
- void setArraySize(int s)
+ bool isMatrix() const
{
- array = true;
- arraySize = s;
+ return primarySize > 1 && secondarySize > 1;
}
- void clearArrayness()
+
+ bool isVector() const
{
- array = false;
- arraySize = 0;
+ return primarySize > 1 && secondarySize == 1;
+ }
+
+ int getCols() const
+ {
+ ASSERT(isMatrix());
+ return primarySize;
+ }
+
+ int getRows() const
+ {
+ ASSERT(isMatrix());
+ return secondarySize;
+ }
+
+ int getNominalSize() const
+ {
+ return primarySize;
}
bool isAggregate() const
{
- return array || typeSpecifierNonArray.isMatrix() || typeSpecifierNonArray.isVector();
+ return array || isMatrix() || isVector();
}
};
-} // namespace sh
-
#endif // COMPILER_TRANSLATOR_TYPES_H_