Commit 6ba6eadc by Jamie Madill

Rename ConstantUnion to TConstantUnion.

This clarified that we're using the Pool allocator/deallocator for this type. BUG=angleproject:993 Change-Id: If8c95f6054d07291e7014be0d4e35766ba2e943b Reviewed-on: https://chromium-review.googlesource.com/269131Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org>
parent c07c43e4
...@@ -9,16 +9,18 @@ ...@@ -9,16 +9,18 @@
#include <assert.h> #include <assert.h>
class ConstantUnion { #include "compiler/translator/BaseTypes.h"
class TConstantUnion {
public: public:
POOL_ALLOCATOR_NEW_DELETE(); POOL_ALLOCATOR_NEW_DELETE();
ConstantUnion() TConstantUnion()
{ {
iConst = 0; iConst = 0;
type = EbtVoid; type = EbtVoid;
} }
bool cast(TBasicType newType, const ConstantUnion &constant) bool cast(TBasicType newType, const TConstantUnion &constant)
{ {
switch (newType) switch (newType)
{ {
...@@ -109,7 +111,7 @@ public: ...@@ -109,7 +111,7 @@ public:
return b == bConst; return b == bConst;
} }
bool operator==(const ConstantUnion& constant) const bool operator==(const TConstantUnion& constant) const
{ {
if (constant.type != type) if (constant.type != type)
return false; return false;
...@@ -148,12 +150,12 @@ public: ...@@ -148,12 +150,12 @@ public:
return !operator==(b); return !operator==(b);
} }
bool operator!=(const ConstantUnion& constant) const bool operator!=(const TConstantUnion& constant) const
{ {
return !operator==(constant); return !operator==(constant);
} }
bool operator>(const ConstantUnion& constant) const bool operator>(const TConstantUnion& constant) const
{ {
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
...@@ -168,7 +170,7 @@ public: ...@@ -168,7 +170,7 @@ public:
} }
} }
bool operator<(const ConstantUnion& constant) const bool operator<(const TConstantUnion& constant) const
{ {
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
...@@ -183,9 +185,9 @@ public: ...@@ -183,9 +185,9 @@ public:
} }
} }
ConstantUnion operator+(const ConstantUnion& constant) const TConstantUnion operator+(const TConstantUnion& constant) const
{ {
ConstantUnion returnValue; TConstantUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst + constant.iConst); break; case EbtInt: returnValue.setIConst(iConst + constant.iConst); break;
...@@ -197,9 +199,9 @@ public: ...@@ -197,9 +199,9 @@ public:
return returnValue; return returnValue;
} }
ConstantUnion operator-(const ConstantUnion& constant) const TConstantUnion operator-(const TConstantUnion& constant) const
{ {
ConstantUnion returnValue; TConstantUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst - constant.iConst); break; case EbtInt: returnValue.setIConst(iConst - constant.iConst); break;
...@@ -211,9 +213,9 @@ public: ...@@ -211,9 +213,9 @@ public:
return returnValue; return returnValue;
} }
ConstantUnion operator*(const ConstantUnion& constant) const TConstantUnion operator*(const TConstantUnion& constant) const
{ {
ConstantUnion returnValue; TConstantUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst * constant.iConst); break; case EbtInt: returnValue.setIConst(iConst * constant.iConst); break;
...@@ -225,9 +227,9 @@ public: ...@@ -225,9 +227,9 @@ public:
return returnValue; return returnValue;
} }
ConstantUnion operator%(const ConstantUnion& constant) const TConstantUnion operator%(const TConstantUnion& constant) const
{ {
ConstantUnion returnValue; TConstantUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst % constant.iConst); break; case EbtInt: returnValue.setIConst(iConst % constant.iConst); break;
...@@ -238,9 +240,9 @@ public: ...@@ -238,9 +240,9 @@ public:
return returnValue; return returnValue;
} }
ConstantUnion operator>>(const ConstantUnion& constant) const TConstantUnion operator>>(const TConstantUnion& constant) const
{ {
ConstantUnion returnValue; TConstantUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst >> constant.iConst); break; case EbtInt: returnValue.setIConst(iConst >> constant.iConst); break;
...@@ -251,9 +253,9 @@ public: ...@@ -251,9 +253,9 @@ public:
return returnValue; return returnValue;
} }
ConstantUnion operator<<(const ConstantUnion& constant) const TConstantUnion operator<<(const TConstantUnion& constant) const
{ {
ConstantUnion returnValue; TConstantUnion returnValue;
// The signedness of the second parameter might be different, but we // The signedness of the second parameter might be different, but we
// don't care, since the result is undefined if the second parameter is // don't care, since the result is undefined if the second parameter is
// negative, and aliasing should not be a problem with unions. // negative, and aliasing should not be a problem with unions.
...@@ -267,9 +269,9 @@ public: ...@@ -267,9 +269,9 @@ public:
return returnValue; return returnValue;
} }
ConstantUnion operator&(const ConstantUnion& constant) const TConstantUnion operator&(const TConstantUnion& constant) const
{ {
ConstantUnion returnValue; TConstantUnion returnValue;
assert(constant.type == EbtInt || constant.type == EbtUInt); assert(constant.type == EbtInt || constant.type == EbtUInt);
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst & constant.iConst); break; case EbtInt: returnValue.setIConst(iConst & constant.iConst); break;
...@@ -280,9 +282,9 @@ public: ...@@ -280,9 +282,9 @@ public:
return returnValue; return returnValue;
} }
ConstantUnion operator|(const ConstantUnion& constant) const TConstantUnion operator|(const TConstantUnion& constant) const
{ {
ConstantUnion returnValue; TConstantUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst | constant.iConst); break; case EbtInt: returnValue.setIConst(iConst | constant.iConst); break;
...@@ -293,9 +295,9 @@ public: ...@@ -293,9 +295,9 @@ public:
return returnValue; return returnValue;
} }
ConstantUnion operator^(const ConstantUnion& constant) const TConstantUnion operator^(const TConstantUnion& constant) const
{ {
ConstantUnion returnValue; TConstantUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtInt: returnValue.setIConst(iConst ^ constant.iConst); break; case EbtInt: returnValue.setIConst(iConst ^ constant.iConst); break;
...@@ -306,9 +308,9 @@ public: ...@@ -306,9 +308,9 @@ public:
return returnValue; return returnValue;
} }
ConstantUnion operator&&(const ConstantUnion& constant) const TConstantUnion operator&&(const TConstantUnion& constant) const
{ {
ConstantUnion returnValue; TConstantUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtBool: returnValue.setBConst(bConst && constant.bConst); break; case EbtBool: returnValue.setBConst(bConst && constant.bConst); break;
...@@ -318,9 +320,9 @@ public: ...@@ -318,9 +320,9 @@ public:
return returnValue; return returnValue;
} }
ConstantUnion operator||(const ConstantUnion& constant) const TConstantUnion operator||(const TConstantUnion& constant) const
{ {
ConstantUnion returnValue; TConstantUnion returnValue;
assert(type == constant.type); assert(type == constant.type);
switch (type) { switch (type) {
case EbtBool: returnValue.setBConst(bConst || constant.bConst); break; case EbtBool: returnValue.setBConst(bConst || constant.bConst); break;
......
...@@ -17,7 +17,7 @@ TIntermConstantUnion *constructFloatConstUnionNode(const TType &type) ...@@ -17,7 +17,7 @@ TIntermConstantUnion *constructFloatConstUnionNode(const TType &type)
unsigned char size = static_cast<unsigned char>(myType.getNominalSize()); unsigned char size = static_cast<unsigned char>(myType.getNominalSize());
if (myType.isMatrix()) if (myType.isMatrix())
size *= size; size *= size;
ConstantUnion *u = new ConstantUnion[size]; TConstantUnion *u = new TConstantUnion[size];
for (int ii = 0; ii < size; ++ii) for (int ii = 0; ii < size; ++ii)
u[ii].setFConst(0.0f); u[ii].setFConst(0.0f);
...@@ -29,7 +29,7 @@ TIntermConstantUnion *constructFloatConstUnionNode(const TType &type) ...@@ -29,7 +29,7 @@ TIntermConstantUnion *constructFloatConstUnionNode(const TType &type)
TIntermConstantUnion *constructIndexNode(int index) TIntermConstantUnion *constructIndexNode(int index)
{ {
ConstantUnion *u = new ConstantUnion[1]; TConstantUnion *u = new TConstantUnion[1];
u[0].setIConst(index); u[0].setIConst(index);
TType type(EbtInt, EbpUndefined, EvqConst, 1); TType type(EbtInt, EbpUndefined, EvqConst, 1);
......
...@@ -23,9 +23,9 @@ ...@@ -23,9 +23,9 @@
#include "common/angleutils.h" #include "common/angleutils.h"
#include "compiler/translator/Common.h" #include "compiler/translator/Common.h"
#include "compiler/translator/Types.h"
#include "compiler/translator/ConstantUnion.h" #include "compiler/translator/ConstantUnion.h"
#include "compiler/translator/Operator.h" #include "compiler/translator/Operator.h"
#include "compiler/translator/Types.h"
class TIntermTraverser; class TIntermTraverser;
class TIntermAggregate; class TIntermAggregate;
...@@ -264,13 +264,13 @@ class TIntermRaw : public TIntermTyped ...@@ -264,13 +264,13 @@ class TIntermRaw : public TIntermTyped
class TIntermConstantUnion : public TIntermTyped class TIntermConstantUnion : public TIntermTyped
{ {
public: public:
TIntermConstantUnion(ConstantUnion *unionPointer, const TType &type) TIntermConstantUnion(TConstantUnion *unionPointer, const TType &type)
: TIntermTyped(type), : TIntermTyped(type),
mUnionArrayPointer(unionPointer) { } mUnionArrayPointer(unionPointer) { }
virtual bool hasSideEffects() const { return false; } virtual bool hasSideEffects() const { return false; }
ConstantUnion *getUnionArrayPointer() const { return mUnionArrayPointer; } TConstantUnion *getUnionArrayPointer() const { return mUnionArrayPointer; }
int getIConst(size_t index) const int getIConst(size_t index) const
{ {
...@@ -296,11 +296,11 @@ class TIntermConstantUnion : public TIntermTyped ...@@ -296,11 +296,11 @@ class TIntermConstantUnion : public TIntermTyped
TIntermTyped *fold(TOperator op, TIntermConstantUnion *rightNode, TInfoSink &infoSink); TIntermTyped *fold(TOperator op, TIntermConstantUnion *rightNode, TInfoSink &infoSink);
protected: protected:
ConstantUnion *mUnionArrayPointer; TConstantUnion *mUnionArrayPointer;
private: private:
typedef float(*FloatTypeUnaryFunc) (float); typedef float(*FloatTypeUnaryFunc) (float);
bool foldFloatTypeUnary(const ConstantUnion &parameter, FloatTypeUnaryFunc builtinFunc, TInfoSink &infoSink, ConstantUnion *result) const; bool foldFloatTypeUnary(const TConstantUnion &parameter, FloatTypeUnaryFunc builtinFunc, TInfoSink &infoSink, TConstantUnion *result) const;
}; };
// //
......
...@@ -361,7 +361,7 @@ TIntermCase *TIntermediate::addCase( ...@@ -361,7 +361,7 @@ TIntermCase *TIntermediate::addCase(
// //
TIntermConstantUnion *TIntermediate::addConstantUnion( TIntermConstantUnion *TIntermediate::addConstantUnion(
ConstantUnion *unionArrayPointer, const TType &t, const TSourceLoc &line) TConstantUnion *unionArrayPointer, const TType &t, const TSourceLoc &line)
{ {
TIntermConstantUnion *node = new TIntermConstantUnion(unionArrayPointer, t); TIntermConstantUnion *node = new TIntermConstantUnion(unionArrayPointer, t);
node->setLine(line); node->setLine(line);
...@@ -378,11 +378,11 @@ TIntermTyped *TIntermediate::addSwizzle( ...@@ -378,11 +378,11 @@ TIntermTyped *TIntermediate::addSwizzle(
node->setLine(line); node->setLine(line);
TIntermConstantUnion *constIntNode; TIntermConstantUnion *constIntNode;
TIntermSequence *sequenceVector = node->getSequence(); TIntermSequence *sequenceVector = node->getSequence();
ConstantUnion *unionArray; TConstantUnion *unionArray;
for (int i = 0; i < fields.num; i++) for (int i = 0; i < fields.num; i++)
{ {
unionArray = new ConstantUnion[1]; unionArray = new TConstantUnion[1];
unionArray->setIConst(fields.offsets[i]); unionArray->setIConst(fields.offsets[i]);
constIntNode = addConstantUnion( constIntNode = addConstantUnion(
unionArray, TType(EbtInt, EbpUndefined, EvqConst), line); unionArray, TType(EbtInt, EbpUndefined, EvqConst), line);
......
...@@ -49,9 +49,9 @@ class TIntermediate ...@@ -49,9 +49,9 @@ class TIntermediate
TIntermTyped *condition, const TSourceLoc &line); TIntermTyped *condition, const TSourceLoc &line);
TIntermTyped *addComma( TIntermTyped *addComma(
TIntermTyped *left, TIntermTyped *right, const TSourceLoc &); TIntermTyped *left, TIntermTyped *right, const TSourceLoc &);
TIntermConstantUnion *addConstantUnion(ConstantUnion *, const TType &, const TSourceLoc &); TIntermConstantUnion *addConstantUnion(TConstantUnion *, const TType &, const TSourceLoc &);
// TODO(zmo): Get rid of default value. // TODO(zmo): Get rid of default value.
bool parseConstTree(const TSourceLoc &, TIntermNode *, ConstantUnion *, bool parseConstTree(const TSourceLoc &, TIntermNode *, TConstantUnion *,
TOperator, TType, bool singleConstantParam = false); TOperator, TType, bool singleConstantParam = false);
TIntermNode *addLoop(TLoopType, TIntermNode *, TIntermTyped *, TIntermTyped *, TIntermNode *addLoop(TLoopType, TIntermNode *, TIntermTyped *, TIntermTyped *,
TIntermNode *, const TSourceLoc &); TIntermNode *, const TSourceLoc &);
......
...@@ -168,8 +168,8 @@ void TOutputGLSLBase::writeFunctionParameters(const TIntermSequence &args) ...@@ -168,8 +168,8 @@ void TOutputGLSLBase::writeFunctionParameters(const TIntermSequence &args)
} }
} }
const ConstantUnion *TOutputGLSLBase::writeConstantUnion( const TConstantUnion *TOutputGLSLBase::writeConstantUnion(
const TType &type, const ConstantUnion *pConstUnion) const TType &type, const TConstantUnion *pConstUnion)
{ {
TInfoSinkBase &out = objSink(); TInfoSinkBase &out = objSink();
...@@ -386,7 +386,7 @@ bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary *node) ...@@ -386,7 +386,7 @@ bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary *node)
TIntermConstantUnion *element = (*sit)->getAsConstantUnion(); TIntermConstantUnion *element = (*sit)->getAsConstantUnion();
ASSERT(element->getBasicType() == EbtInt); ASSERT(element->getBasicType() == EbtInt);
ASSERT(element->getNominalSize() == 1); ASSERT(element->getNominalSize() == 1);
const ConstantUnion& data = element->getUnionArrayPointer()[0]; const TConstantUnion& data = element->getUnionArrayPointer()[0];
ASSERT(data.getType() == EbtInt); ASSERT(data.getType() == EbtInt);
switch (data.getIConst()) switch (data.getIConst())
{ {
......
...@@ -35,7 +35,7 @@ class TOutputGLSLBase : public TIntermTraverser ...@@ -35,7 +35,7 @@ class TOutputGLSLBase : public TIntermTraverser
void writeVariableType(const TType &type); void writeVariableType(const TType &type);
virtual bool writeVariablePrecision(TPrecision precision) = 0; virtual bool writeVariablePrecision(TPrecision precision) = 0;
void writeFunctionParameters(const TIntermSequence &args); void writeFunctionParameters(const TIntermSequence &args);
const ConstantUnion *writeConstantUnion(const TType &type, const ConstantUnion *pConstUnion); const TConstantUnion *writeConstantUnion(const TType &type, const TConstantUnion *pConstUnion);
void writeConstructorTriplet(Visit visit, const TType &type, const char *constructorBaseType); void writeConstructorTriplet(Visit visit, const TType &type, const char *constructorBaseType);
TString getTypeName(const TType &type); TString getTypeName(const TType &type);
......
...@@ -2895,7 +2895,7 @@ void OutputHLSL::outputConstructor(Visit visit, const TType &type, const char *n ...@@ -2895,7 +2895,7 @@ void OutputHLSL::outputConstructor(Visit visit, const TType &type, const char *n
} }
} }
const ConstantUnion *OutputHLSL::writeConstantUnion(const TType &type, const ConstantUnion *constUnion) const TConstantUnion *OutputHLSL::writeConstantUnion(const TType &type, const TConstantUnion *constUnion)
{ {
TInfoSinkBase &out = getInfoSink(); TInfoSinkBase &out = getInfoSink();
......
...@@ -76,7 +76,7 @@ class OutputHLSL : public TIntermTraverser ...@@ -76,7 +76,7 @@ class OutputHLSL : public TIntermTraverser
// Emit constructor. Called with literal names so using const char* instead of TString. // Emit constructor. Called with literal names so using const char* instead of TString.
void outputConstructor(Visit visit, const TType &type, const char *name, const TIntermSequence *parameters); void outputConstructor(Visit visit, const TType &type, const char *name, const TIntermSequence *parameters);
const ConstantUnion *writeConstantUnion(const TType &type, const ConstantUnion *constUnion); const TConstantUnion *writeConstantUnion(const TType &type, const TConstantUnion *constUnion);
void outputEqual(Visit visit, const TType &type, TOperator op, TInfoSinkBase &out); void outputEqual(Visit visit, const TType &type, TOperator op, TInfoSinkBase &out);
......
...@@ -1133,7 +1133,7 @@ bool TParseContext::executeInitializer(const TSourceLoc &line, const TString &id ...@@ -1133,7 +1133,7 @@ bool TParseContext::executeInitializer(const TSourceLoc &line, const TString &id
const TSymbol* symbol = symbolTable.find(initializer->getAsSymbolNode()->getSymbol(), 0); const TSymbol* symbol = symbolTable.find(initializer->getAsSymbolNode()->getSymbol(), 0);
const TVariable* tVar = static_cast<const TVariable*>(symbol); const TVariable* tVar = static_cast<const TVariable*>(symbol);
ConstantUnion* constArray = tVar->getConstPointer(); TConstantUnion* constArray = tVar->getConstPointer();
variable->shareConstPointer(constArray); variable->shareConstPointer(constArray);
} else { } else {
std::stringstream extraInfoStream; std::stringstream extraInfoStream;
...@@ -1786,7 +1786,7 @@ TIntermTyped* TParseContext::foldConstConstructor(TIntermAggregate* aggrNode, co ...@@ -1786,7 +1786,7 @@ TIntermTyped* TParseContext::foldConstConstructor(TIntermAggregate* aggrNode, co
aggrNode->setType(type); aggrNode->setType(type);
if (canBeFolded) { if (canBeFolded) {
bool returnVal = false; bool returnVal = false;
ConstantUnion* unionArray = new ConstantUnion[type.getObjectSize()]; TConstantUnion* unionArray = new TConstantUnion[type.getObjectSize()];
if (aggrNode->getSequence()->size() == 1) { if (aggrNode->getSequence()->size() == 1) {
returnVal = intermediate.parseConstTree(aggrNode->getLine(), aggrNode, unionArray, aggrNode->getOp(), type, true); returnVal = intermediate.parseConstTree(aggrNode->getLine(), aggrNode, unionArray, aggrNode->getOp(), type, true);
} }
...@@ -1814,7 +1814,7 @@ TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTy ...@@ -1814,7 +1814,7 @@ TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTy
TIntermTyped* typedNode; TIntermTyped* typedNode;
TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion(); TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
ConstantUnion *unionArray; TConstantUnion *unionArray;
if (tempConstantNode) { if (tempConstantNode) {
unionArray = tempConstantNode->getUnionArrayPointer(); unionArray = tempConstantNode->getUnionArrayPointer();
...@@ -1828,7 +1828,7 @@ TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTy ...@@ -1828,7 +1828,7 @@ TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTy
return 0; return 0;
} }
ConstantUnion* constArray = new ConstantUnion[fields.num]; TConstantUnion* constArray = new TConstantUnion[fields.num];
for (int i = 0; i < fields.num; i++) { for (int i = 0; i < fields.num; i++) {
if (fields.offsets[i] >= node->getType().getNominalSize()) { if (fields.offsets[i] >= node->getType().getNominalSize()) {
...@@ -1868,7 +1868,7 @@ TIntermTyped* TParseContext::addConstMatrixNode(int index, TIntermTyped* node, c ...@@ -1868,7 +1868,7 @@ TIntermTyped* TParseContext::addConstMatrixNode(int index, TIntermTyped* node, c
} }
if (tempConstantNode) { if (tempConstantNode) {
ConstantUnion* unionArray = tempConstantNode->getUnionArrayPointer(); TConstantUnion* unionArray = tempConstantNode->getUnionArrayPointer();
int size = tempConstantNode->getType().getCols(); int size = tempConstantNode->getType().getCols();
typedNode = intermediate.addConstantUnion(&unionArray[size*index], tempConstantNode->getType(), line); typedNode = intermediate.addConstantUnion(&unionArray[size*index], tempConstantNode->getType(), line);
} else { } else {
...@@ -1906,7 +1906,7 @@ TIntermTyped* TParseContext::addConstArrayNode(int index, TIntermTyped* node, co ...@@ -1906,7 +1906,7 @@ TIntermTyped* TParseContext::addConstArrayNode(int index, TIntermTyped* node, co
if (tempConstantNode) { if (tempConstantNode) {
size_t arrayElementSize = arrayElementType.getObjectSize(); size_t arrayElementSize = arrayElementType.getObjectSize();
ConstantUnion* unionArray = tempConstantNode->getUnionArrayPointer(); TConstantUnion* unionArray = tempConstantNode->getUnionArrayPointer();
typedNode = intermediate.addConstantUnion(&unionArray[arrayElementSize * index], tempConstantNode->getType(), line); typedNode = intermediate.addConstantUnion(&unionArray[arrayElementSize * index], tempConstantNode->getType(), line);
} else { } else {
error(line, "Cannot offset into the array", "Error"); error(line, "Cannot offset into the array", "Error");
...@@ -1940,7 +1940,7 @@ TIntermTyped* TParseContext::addConstStruct(const TString &identifier, TIntermTy ...@@ -1940,7 +1940,7 @@ TIntermTyped* TParseContext::addConstStruct(const TString &identifier, TIntermTy
TIntermTyped *typedNode; TIntermTyped *typedNode;
TIntermConstantUnion *tempConstantNode = node->getAsConstantUnion(); TIntermConstantUnion *tempConstantNode = node->getAsConstantUnion();
if (tempConstantNode) { if (tempConstantNode) {
ConstantUnion* constArray = tempConstantNode->getUnionArrayPointer(); TConstantUnion* constArray = tempConstantNode->getUnionArrayPointer();
typedNode = intermediate.addConstantUnion(constArray+instanceSize, tempConstantNode->getType(), line); // type will be changed in the calling function typedNode = intermediate.addConstantUnion(constArray+instanceSize, tempConstantNode->getType(), line); // type will be changed in the calling function
} else { } else {
...@@ -2252,7 +2252,7 @@ TIntermTyped* TParseContext::addIndexExpression(TIntermTyped *baseExpression, co ...@@ -2252,7 +2252,7 @@ TIntermTyped* TParseContext::addIndexExpression(TIntermTyped *baseExpression, co
if (indexedExpression == 0) if (indexedExpression == 0)
{ {
ConstantUnion *unionArray = new ConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
unionArray->setFConst(0.0f); unionArray->setFConst(0.0f);
indexedExpression = intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpHigh, EvqConst), location); indexedExpression = intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpHigh, EvqConst), location);
} }
...@@ -2356,7 +2356,7 @@ TIntermTyped* TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpre ...@@ -2356,7 +2356,7 @@ TIntermTyped* TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpre
{ {
error(dotLocation, " non-scalar fields not implemented yet", "."); error(dotLocation, " non-scalar fields not implemented yet", ".");
recover(); recover();
ConstantUnion *unionArray = new ConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
unionArray->setIConst(0); unionArray->setIConst(0);
TIntermTyped* index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), fieldLocation); TIntermTyped* index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), fieldLocation);
indexedExpression = intermediate.addIndex(EOpIndexDirect, baseExpression, index, dotLocation); indexedExpression = intermediate.addIndex(EOpIndexDirect, baseExpression, index, dotLocation);
...@@ -2365,7 +2365,7 @@ TIntermTyped* TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpre ...@@ -2365,7 +2365,7 @@ TIntermTyped* TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpre
} }
else else
{ {
ConstantUnion *unionArray = new ConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
unionArray->setIConst(fields.col * baseExpression->getRows() + fields.row); unionArray->setIConst(fields.col * baseExpression->getRows() + fields.row);
TIntermTyped* index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), fieldLocation); TIntermTyped* index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), fieldLocation);
indexedExpression = intermediate.addIndex(EOpIndexDirect, baseExpression, index, dotLocation); indexedExpression = intermediate.addIndex(EOpIndexDirect, baseExpression, index, dotLocation);
...@@ -2413,7 +2413,7 @@ TIntermTyped* TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpre ...@@ -2413,7 +2413,7 @@ TIntermTyped* TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpre
} }
else else
{ {
ConstantUnion *unionArray = new ConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
unionArray->setIConst(i); unionArray->setIConst(i);
TIntermTyped* index = intermediate.addConstantUnion(unionArray, *fields[i]->type(), fieldLocation); TIntermTyped* index = intermediate.addConstantUnion(unionArray, *fields[i]->type(), fieldLocation);
indexedExpression = intermediate.addIndex(EOpIndexDirectStruct, baseExpression, index, dotLocation); indexedExpression = intermediate.addIndex(EOpIndexDirectStruct, baseExpression, index, dotLocation);
...@@ -2451,7 +2451,7 @@ TIntermTyped* TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpre ...@@ -2451,7 +2451,7 @@ TIntermTyped* TParseContext::addFieldSelectionExpression(TIntermTyped *baseExpre
} }
if (fieldFound) if (fieldFound)
{ {
ConstantUnion *unionArray = new ConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
unionArray->setIConst(i); unionArray->setIConst(i);
TIntermTyped* index = intermediate.addConstantUnion(unionArray, *fields[i]->type(), fieldLocation); TIntermTyped* index = intermediate.addConstantUnion(unionArray, *fields[i]->type(), fieldLocation);
indexedExpression = intermediate.addIndex(EOpIndexDirectInterfaceBlock, baseExpression, index, dotLocation); indexedExpression = intermediate.addIndex(EOpIndexDirectInterfaceBlock, baseExpression, index, dotLocation);
...@@ -3054,7 +3054,7 @@ TIntermTyped *TParseContext::addBinaryMathBooleanResult(TOperator op, TIntermTyp ...@@ -3054,7 +3054,7 @@ TIntermTyped *TParseContext::addBinaryMathBooleanResult(TOperator op, TIntermTyp
{ {
binaryOpError(loc, GetOperatorString(op), left->getCompleteString(), right->getCompleteString()); binaryOpError(loc, GetOperatorString(op), left->getCompleteString(), right->getCompleteString());
recover(); recover();
ConstantUnion *unionArray = new ConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
unionArray->setBConst(false); unionArray->setBConst(false);
return intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), loc); return intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), loc);
} }
...@@ -3142,7 +3142,7 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN ...@@ -3142,7 +3142,7 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN
if (thisNode != nullptr) if (thisNode != nullptr)
{ {
ConstantUnion *unionArray = new ConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
int arraySize = 0; int arraySize = 0;
TIntermTyped *typedThis = thisNode->getAsTyped(); TIntermTyped *typedThis = thisNode->getAsTyped();
if (fnCall->getName() != "length") if (fnCall->getName() != "length")
...@@ -3282,7 +3282,7 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN ...@@ -3282,7 +3282,7 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN
{ {
// error message was put out by findFunction() // error message was put out by findFunction()
// Put on a dummy node for error recovery // Put on a dummy node for error recovery
ConstantUnion *unionArray = new ConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
unionArray->setFConst(0.0f); unionArray->setFConst(0.0f);
callNode = intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), loc); callNode = intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), loc);
recover(); recover();
......
...@@ -39,7 +39,7 @@ bool ContainsVectorNode(const TIntermSequence &sequence) ...@@ -39,7 +39,7 @@ bool ContainsVectorNode(const TIntermSequence &sequence)
TIntermConstantUnion *ConstructIndexNode(int index) TIntermConstantUnion *ConstructIndexNode(int index)
{ {
ConstantUnion *u = new ConstantUnion[1]; TConstantUnion *u = new TConstantUnion[1];
u[0].setIConst(index); u[0].setIConst(index);
TType type(EbtInt, EbpUndefined, EvqConst, 1); TType type(EbtInt, EbpUndefined, EvqConst, 1);
......
...@@ -133,20 +133,20 @@ class TVariable : public TSymbol ...@@ -133,20 +133,20 @@ class TVariable : public TSymbol
type.setQualifier(qualifier); type.setQualifier(qualifier);
} }
ConstantUnion *getConstPointer() TConstantUnion *getConstPointer()
{ {
if (!unionArray) if (!unionArray)
unionArray = new ConstantUnion[type.getObjectSize()]; unionArray = new TConstantUnion[type.getObjectSize()];
return unionArray; return unionArray;
} }
ConstantUnion *getConstPointer() const TConstantUnion *getConstPointer() const
{ {
return unionArray; return unionArray;
} }
void shareConstPointer(ConstantUnion *constArray) void shareConstPointer(TConstantUnion *constArray)
{ {
if (unionArray == constArray) if (unionArray == constArray)
return; return;
...@@ -160,7 +160,7 @@ class TVariable : public TSymbol ...@@ -160,7 +160,7 @@ class TVariable : public TSymbol
bool userType; bool userType;
// we are assuming that Pool Allocator will free the memory // we are assuming that Pool Allocator will free the memory
// allocated to unionArray when this object is destroyed. // allocated to unionArray when this object is destroyed.
ConstantUnion *unionArray; TConstantUnion *unionArray;
}; };
// The function sub-class of symbols and the parser will need to // The function sub-class of symbols and the parser will need to
......
...@@ -13,7 +13,7 @@ namespace ...@@ -13,7 +13,7 @@ namespace
TIntermSelection *UnfoldOR(TIntermTyped *x, TIntermTyped *y) TIntermSelection *UnfoldOR(TIntermTyped *x, TIntermTyped *y)
{ {
const TType boolType(EbtBool, EbpUndefined); const TType boolType(EbtBool, EbpUndefined);
ConstantUnion *u = new ConstantUnion; TConstantUnion *u = new TConstantUnion;
u->setBConst(true); u->setBConst(true);
TIntermConstantUnion *trueNode = new TIntermConstantUnion( TIntermConstantUnion *trueNode = new TIntermConstantUnion(
u, TType(EbtBool, EbpUndefined, EvqConst, 1)); u, TType(EbtBool, EbpUndefined, EvqConst, 1));
...@@ -24,7 +24,7 @@ TIntermSelection *UnfoldOR(TIntermTyped *x, TIntermTyped *y) ...@@ -24,7 +24,7 @@ TIntermSelection *UnfoldOR(TIntermTyped *x, TIntermTyped *y)
TIntermSelection *UnfoldAND(TIntermTyped *x, TIntermTyped *y) TIntermSelection *UnfoldAND(TIntermTyped *x, TIntermTyped *y)
{ {
const TType boolType(EbtBool, EbpUndefined); const TType boolType(EbtBool, EbpUndefined);
ConstantUnion *u = new ConstantUnion; TConstantUnion *u = new TConstantUnion;
u->setBConst(false); u->setBConst(false);
TIntermConstantUnion *falseNode = new TIntermConstantUnion( TIntermConstantUnion *falseNode = new TIntermConstantUnion(
u, TType(EbtBool, EbpUndefined, EvqConst, 1)); u, TType(EbtBool, EbpUndefined, EvqConst, 1));
......
...@@ -218,7 +218,7 @@ variable_identifier ...@@ -218,7 +218,7 @@ variable_identifier
if (variable->getType().getQualifier() == EvqConst) if (variable->getType().getQualifier() == EvqConst)
{ {
ConstantUnion* constArray = variable->getConstPointer(); TConstantUnion* constArray = variable->getConstPointer();
TType t(variable->getType()); TType t(variable->getType());
$$ = context->intermediate.addConstantUnion(constArray, t, @1); $$ = context->intermediate.addConstantUnion(constArray, t, @1);
} }
...@@ -240,22 +240,22 @@ primary_expression ...@@ -240,22 +240,22 @@ primary_expression
$$ = $1; $$ = $1;
} }
| INTCONSTANT { | INTCONSTANT {
ConstantUnion *unionArray = new ConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
unionArray->setIConst($1.i); unionArray->setIConst($1.i);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), @1); $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), @1);
} }
| UINTCONSTANT { | UINTCONSTANT {
ConstantUnion *unionArray = new ConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
unionArray->setUConst($1.u); unionArray->setUConst($1.u);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtUInt, EbpUndefined, EvqConst), @1); $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtUInt, EbpUndefined, EvqConst), @1);
} }
| FLOATCONSTANT { | FLOATCONSTANT {
ConstantUnion *unionArray = new ConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
unionArray->setFConst($1.f); unionArray->setFConst($1.f);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), @1); $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), @1);
} }
| BOOLCONSTANT { | BOOLCONSTANT {
ConstantUnion *unionArray = new ConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
unionArray->setBConst($1.b); unionArray->setBConst($1.b);
$$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), @1); $$ = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), @1);
} }
......
...@@ -2361,7 +2361,7 @@ yyreduce: ...@@ -2361,7 +2361,7 @@ yyreduce:
if (variable->getType().getQualifier() == EvqConst) if (variable->getType().getQualifier() == EvqConst)
{ {
ConstantUnion* constArray = variable->getConstPointer(); TConstantUnion* constArray = variable->getConstPointer();
TType t(variable->getType()); TType t(variable->getType());
(yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(constArray, t, (yylsp[0])); (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(constArray, t, (yylsp[0]));
} }
...@@ -2390,7 +2390,7 @@ yyreduce: ...@@ -2390,7 +2390,7 @@ yyreduce:
case 6: case 6:
{ {
ConstantUnion *unionArray = new ConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
unionArray->setIConst((yyvsp[0].lex).i); unionArray->setIConst((yyvsp[0].lex).i);
(yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), (yylsp[0])); (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtInt, EbpUndefined, EvqConst), (yylsp[0]));
} }
...@@ -2400,7 +2400,7 @@ yyreduce: ...@@ -2400,7 +2400,7 @@ yyreduce:
case 7: case 7:
{ {
ConstantUnion *unionArray = new ConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
unionArray->setUConst((yyvsp[0].lex).u); unionArray->setUConst((yyvsp[0].lex).u);
(yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtUInt, EbpUndefined, EvqConst), (yylsp[0])); (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtUInt, EbpUndefined, EvqConst), (yylsp[0]));
} }
...@@ -2410,7 +2410,7 @@ yyreduce: ...@@ -2410,7 +2410,7 @@ yyreduce:
case 8: case 8:
{ {
ConstantUnion *unionArray = new ConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
unionArray->setFConst((yyvsp[0].lex).f); unionArray->setFConst((yyvsp[0].lex).f);
(yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), (yylsp[0])); (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtFloat, EbpUndefined, EvqConst), (yylsp[0]));
} }
...@@ -2420,7 +2420,7 @@ yyreduce: ...@@ -2420,7 +2420,7 @@ yyreduce:
case 9: case 9:
{ {
ConstantUnion *unionArray = new ConstantUnion[1]; TConstantUnion *unionArray = new TConstantUnion[1];
unionArray->setBConst((yyvsp[0].lex).b); unionArray->setBConst((yyvsp[0].lex).b);
(yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), (yylsp[0])); (yyval.interm.intermTypedNode) = context->intermediate.addConstantUnion(unionArray, TType(EbtBool, EbpUndefined, EvqConst), (yylsp[0]));
} }
......
...@@ -265,7 +265,7 @@ bool TOutputTraverser::visitBinary(Visit visit, TIntermBinary *node) ...@@ -265,7 +265,7 @@ bool TOutputTraverser::visitBinary(Visit visit, TIntermBinary *node)
OutputTreeText(out, intermConstantUnion, mDepth + 1); OutputTreeText(out, intermConstantUnion, mDepth + 1);
// The following code finds the field name from the constant union // The following code finds the field name from the constant union
const ConstantUnion *constantUnion = intermConstantUnion->getUnionArrayPointer(); const TConstantUnion *constantUnion = intermConstantUnion->getUnionArrayPointer();
const TStructure *structure = node->getLeft()->getType().getStruct(); const TStructure *structure = node->getLeft()->getType().getStruct();
const TInterfaceBlock *interfaceBlock = node->getLeft()->getType().getInterfaceBlock(); const TInterfaceBlock *interfaceBlock = node->getLeft()->getType().getInterfaceBlock();
ASSERT(structure || interfaceBlock); ASSERT(structure || interfaceBlock);
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
class TConstTraverser : public TIntermTraverser class TConstTraverser : public TIntermTraverser
{ {
public: public:
TConstTraverser(ConstantUnion *cUnion, bool singleConstParam, TConstTraverser(TConstantUnion *cUnion, bool singleConstParam,
TOperator constructType, TInfoSink &sink, TType &t) TOperator constructType, TInfoSink &sink, TType &t)
: error(false), : error(false),
mIndex(0), mIndex(0),
...@@ -42,7 +42,7 @@ class TConstTraverser : public TIntermTraverser ...@@ -42,7 +42,7 @@ class TConstTraverser : public TIntermTraverser
bool visitBranch(Visit visit, TIntermBranch *); bool visitBranch(Visit visit, TIntermBranch *);
size_t mIndex; size_t mIndex;
ConstantUnion *mUnionArray; TConstantUnion *mUnionArray;
TType mType; TType mType;
TOperator mConstructorType; TOperator mConstructorType;
bool mSingleConstantParam; bool mSingleConstantParam;
...@@ -167,7 +167,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion *node) ...@@ -167,7 +167,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion *node)
return; return;
} }
ConstantUnion *leftUnionArray = mUnionArray; TConstantUnion *leftUnionArray = mUnionArray;
size_t instanceSize = mType.getObjectSize(); size_t instanceSize = mType.getObjectSize();
TBasicType basicType = mType.getBasicType(); TBasicType basicType = mType.getBasicType();
...@@ -177,7 +177,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion *node) ...@@ -177,7 +177,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion *node)
if (!mSingleConstantParam) if (!mSingleConstantParam)
{ {
size_t objectSize = node->getType().getObjectSize(); size_t objectSize = node->getType().getObjectSize();
ConstantUnion *rightUnionArray = node->getUnionArrayPointer(); TConstantUnion *rightUnionArray = node->getUnionArrayPointer();
for (size_t i=0; i < objectSize; i++) for (size_t i=0; i < objectSize; i++)
{ {
if (mIndex >= instanceSize) if (mIndex >= instanceSize)
...@@ -189,7 +189,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion *node) ...@@ -189,7 +189,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion *node)
else else
{ {
size_t totalSize = mIndex + mSize; size_t totalSize = mIndex + mSize;
ConstantUnion *rightUnionArray = node->getUnionArrayPointer(); TConstantUnion *rightUnionArray = node->getUnionArrayPointer();
if (!mIsDiagonalMatrixInit) if (!mIsDiagonalMatrixInit)
{ {
int count = 0; int count = 0;
...@@ -247,7 +247,7 @@ bool TConstTraverser::visitBranch(Visit visit, TIntermBranch *node) ...@@ -247,7 +247,7 @@ bool TConstTraverser::visitBranch(Visit visit, TIntermBranch *node)
// type of node. It's children will still be processed. // type of node. It's children will still be processed.
// //
bool TIntermediate::parseConstTree( bool TIntermediate::parseConstTree(
const TSourceLoc &line, TIntermNode *root, ConstantUnion *unionArray, const TSourceLoc &line, TIntermNode *root, TConstantUnion *unionArray,
TOperator constructorType, TType t, bool singleConstantParam) TOperator constructorType, TType t, bool singleConstantParam)
{ {
if (root == 0) if (root == 0)
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
class ConstantFinder : public TIntermTraverser class ConstantFinder : public TIntermTraverser
{ {
public: public:
ConstantFinder(ConstantUnion constToFind) ConstantFinder(TConstantUnion constToFind)
: mConstToFind(constToFind), : mConstToFind(constToFind),
mFound(false) mFound(false)
{} {}
...@@ -32,7 +32,7 @@ class ConstantFinder : public TIntermTraverser ...@@ -32,7 +32,7 @@ class ConstantFinder : public TIntermTraverser
bool found() const { return mFound; } bool found() const { return mFound; }
private: private:
ConstantUnion mConstToFind; TConstantUnion mConstToFind;
bool mFound; bool mFound;
}; };
...@@ -72,7 +72,7 @@ class ConstantFoldingTest : public testing::Test ...@@ -72,7 +72,7 @@ class ConstantFoldingTest : public testing::Test
} }
} }
bool constantFoundInAST(ConstantUnion c) bool constantFoundInAST(TConstantUnion c)
{ {
ConstantFinder finder(c); ConstantFinder finder(c);
mASTRoot->traverse(&finder); mASTRoot->traverse(&finder);
...@@ -81,7 +81,7 @@ class ConstantFoldingTest : public testing::Test ...@@ -81,7 +81,7 @@ class ConstantFoldingTest : public testing::Test
bool constantFoundInAST(int i) bool constantFoundInAST(int i)
{ {
ConstantUnion c; TConstantUnion c;
c.setIConst(i); c.setIConst(i);
return constantFoundInAST(c); return constantFoundInAST(c);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment