Commit 6ff56fd4 by alokp@chromium.org

Renamed constUnion class to ConstantUnion.

Review URL: http://codereview.appspot.com/1106042 git-svn-id: https://angleproject.googlecode.com/svn/trunk@227 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 428d1587
......@@ -8,7 +8,7 @@
#define _CONSTANT_UNION_INCLUDED_
class constUnion {
class ConstantUnion {
public:
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
......@@ -47,7 +47,7 @@ public:
return false;
}
bool operator==(const constUnion& constant) const
bool operator==(const ConstantUnion& constant) const
{
if (constant.type != type)
return false;
......@@ -88,12 +88,12 @@ public:
return !operator==(b);
}
bool operator!=(const constUnion& constant) const
bool operator!=(const ConstantUnion& constant) const
{
return !operator==(constant);
}
bool operator>(const constUnion& constant) const
bool operator>(const ConstantUnion& constant) const
{
assert(type == constant.type);
switch (type) {
......@@ -115,7 +115,7 @@ public:
return false;
}
bool operator<(const constUnion& constant) const
bool operator<(const ConstantUnion& constant) const
{
assert(type == constant.type);
switch (type) {
......@@ -137,9 +137,9 @@ public:
return false;
}
constUnion operator+(const constUnion& constant) const
ConstantUnion operator+(const ConstantUnion& constant) const
{
constUnion returnValue;
ConstantUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst + constant.iConst); break;
......@@ -150,9 +150,9 @@ public:
return returnValue;
}
constUnion operator-(const constUnion& constant) const
ConstantUnion operator-(const ConstantUnion& constant) const
{
constUnion returnValue;
ConstantUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst - constant.iConst); break;
......@@ -163,9 +163,9 @@ public:
return returnValue;
}
constUnion operator*(const constUnion& constant) const
ConstantUnion operator*(const ConstantUnion& constant) const
{
constUnion returnValue;
ConstantUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst * constant.iConst); break;
......@@ -176,9 +176,9 @@ public:
return returnValue;
}
constUnion operator%(const constUnion& constant) const
ConstantUnion operator%(const ConstantUnion& constant) const
{
constUnion returnValue;
ConstantUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst % constant.iConst); break;
......@@ -188,9 +188,9 @@ public:
return returnValue;
}
constUnion operator>>(const constUnion& constant) const
ConstantUnion operator>>(const ConstantUnion& constant) const
{
constUnion returnValue;
ConstantUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst >> constant.iConst); break;
......@@ -200,9 +200,9 @@ public:
return returnValue;
}
constUnion operator<<(const constUnion& constant) const
ConstantUnion operator<<(const ConstantUnion& constant) const
{
constUnion returnValue;
ConstantUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst << constant.iConst); break;
......@@ -212,9 +212,9 @@ public:
return returnValue;
}
constUnion operator&(const constUnion& constant) const
ConstantUnion operator&(const ConstantUnion& constant) const
{
constUnion returnValue;
ConstantUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst & constant.iConst); break;
......@@ -224,9 +224,9 @@ public:
return returnValue;
}
constUnion operator|(const constUnion& constant) const
ConstantUnion operator|(const ConstantUnion& constant) const
{
constUnion returnValue;
ConstantUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst | constant.iConst); break;
......@@ -236,9 +236,9 @@ public:
return returnValue;
}
constUnion operator^(const constUnion& constant) const
ConstantUnion operator^(const ConstantUnion& constant) const
{
constUnion returnValue;
ConstantUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtInt: returnValue.setIConst(iConst ^ constant.iConst); break;
......@@ -248,9 +248,9 @@ public:
return returnValue;
}
constUnion operator&&(const constUnion& constant) const
ConstantUnion operator&&(const ConstantUnion& constant) const
{
constUnion returnValue;
ConstantUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtBool: returnValue.setBConst(bConst && constant.bConst); break;
......@@ -260,9 +260,9 @@ public:
return returnValue;
}
constUnion operator||(const constUnion& constant) const
ConstantUnion operator||(const ConstantUnion& constant) const
{
constUnion returnValue;
ConstantUnion returnValue;
assert(type == constant.type);
switch (type) {
case EbtBool: returnValue.setBConst(bConst || constant.bConst); break;
......
......@@ -115,7 +115,7 @@ void TOutputGLSL::visitConstantUnion(TIntermConstantUnion* node)
out << getTypeName(type) << "(";
for (int i = 0; i < size; ++i)
{
const constUnion& data = node->getUnionArrayPointer()[i];
const ConstantUnion& data = node->getUnionArrayPointer()[i];
switch (data.getType())
{
case EbtFloat: out << data.getFConst(); break;
......@@ -178,7 +178,7 @@ bool TOutputGLSL::visitBinary(Visit visit, TIntermBinary* node)
TIntermConstantUnion* element = (*sit)->getAsConstantUnion();
ASSERT(element->getBasicType() == EbtInt);
ASSERT(element->getNominalSize() == 1);
const constUnion& data = element->getUnionArrayPointer()[0];
const ConstantUnion& data = element->getUnionArrayPointer()[0];
ASSERT(data.getType() == EbtInt);
switch (data.getIConst())
{
......
......@@ -951,7 +951,7 @@ bool TParseContext::executeInitializer(TSourceLoc line, TString& identifier, TPu
return true;
}
if (initializer->getAsConstantUnion()) {
constUnion* unionArray = variable->getConstPointer();
ConstantUnion* unionArray = variable->getConstPointer();
if (type.getObjectSize() == 1 && type.getBasicType() != EbtStruct) {
*unionArray = (initializer->getAsConstantUnion()->getUnionArrayPointer())[0];
......@@ -962,7 +962,7 @@ bool TParseContext::executeInitializer(TSourceLoc line, TString& identifier, TPu
const TSymbol* symbol = symbolTable.find(initializer->getAsSymbolNode()->getSymbol());
const TVariable* tVar = static_cast<const TVariable*>(symbol);
constUnion* constArray = tVar->getConstPointer();
ConstantUnion* constArray = tVar->getConstPointer();
variable->shareConstPointer(constArray);
} else {
error(line, " cannot assign to", "=", "'%s'", variable->getType().getCompleteString().c_str());
......@@ -1095,7 +1095,7 @@ TIntermTyped* TParseContext::foldConstConstructor(TIntermAggregate* aggrNode, co
aggrNode->setType(type);
if (canBeFolded) {
bool returnVal = false;
constUnion* unionArray = new constUnion[type.getObjectSize()];
ConstantUnion* unionArray = new ConstantUnion[type.getObjectSize()];
if (aggrNode->getSequence().size() == 1) {
returnVal = intermediate.parseConstTree(aggrNode->getLine(), aggrNode, unionArray, aggrNode->getOp(), symbolTable, type, true);
}
......@@ -1208,12 +1208,12 @@ TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTy
TIntermTyped* typedNode;
TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
constUnion *unionArray;
ConstantUnion *unionArray;
if (tempConstantNode) {
unionArray = tempConstantNode->getUnionArrayPointer();
if (!unionArray) { // this error message should never be raised
infoSink.info.message(EPrefixInternalError, "constUnion not initialized in addConstVectorNode function", line);
infoSink.info.message(EPrefixInternalError, "ConstantUnion not initialized in addConstVectorNode function", line);
recover();
return node;
......@@ -1225,7 +1225,7 @@ TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTy
return 0;
}
constUnion* constArray = new constUnion[fields.num];
ConstantUnion* constArray = new ConstantUnion[fields.num];
for (int i = 0; i < fields.num; i++) {
if (fields.offsets[i] >= node->getType().getObjectSize()) {
......@@ -1259,7 +1259,7 @@ TIntermTyped* TParseContext::addConstMatrixNode(int index, TIntermTyped* node, T
}
if (tempConstantNode) {
constUnion* unionArray = tempConstantNode->getUnionArrayPointer();
ConstantUnion* unionArray = tempConstantNode->getUnionArrayPointer();
int size = tempConstantNode->getType().getNominalSize();
typedNode = intermediate.addConstantUnion(&unionArray[size*index], tempConstantNode->getType(), line);
} else {
......@@ -1295,7 +1295,7 @@ TIntermTyped* TParseContext::addConstArrayNode(int index, TIntermTyped* node, TS
int arrayElementSize = arrayElementType.getObjectSize();
if (tempConstantNode) {
constUnion* unionArray = tempConstantNode->getUnionArrayPointer();
ConstantUnion* unionArray = tempConstantNode->getUnionArrayPointer();
typedNode = intermediate.addConstantUnion(&unionArray[arrayElementSize * index], tempConstantNode->getType(), line);
} else {
error(line, "Cannot offset into the array", "Error", "");
......@@ -1330,7 +1330,7 @@ TIntermTyped* TParseContext::addConstStruct(TString& identifier, TIntermTyped* n
}
if (tempConstantNode) {
constUnion* constArray = tempConstantNode->getUnionArrayPointer();
ConstantUnion* constArray = tempConstantNode->getUnionArrayPointer();
typedNode = intermediate.addConstantUnion(constArray+instanceSize, tempConstantNode->getType(), line); // type will be changed in the calling function
} else {
......
......@@ -156,7 +156,7 @@ TVariable::TVariable(const TVariable& copyOf, TStructureMap& remapper) : TSymbol
if (copyOf.unionArray) {
assert(!copyOf.type.getStruct());
assert(copyOf.type.getObjectSize() == 1);
unionArray = new constUnion[1];
unionArray = new ConstantUnion[1];
unionArray[0] = copyOf.unionArray[0];
} else
unionArray = 0;
......
......@@ -81,17 +81,17 @@ public:
virtual void dump(TInfoSink &infoSink) const;
constUnion* getConstPointer()
ConstantUnion* getConstPointer()
{
if (!unionArray)
unionArray = new constUnion[type.getObjectSize()];
unionArray = new ConstantUnion[type.getObjectSize()];
return unionArray;
}
constUnion* getConstPointer() const { return unionArray; }
ConstantUnion* getConstPointer() const { return unionArray; }
void shareConstPointer( constUnion *constArray)
void shareConstPointer( ConstantUnion *constArray)
{
delete unionArray;
unionArray = constArray;
......@@ -104,7 +104,7 @@ protected:
bool userType;
// we are assuming that Pool Allocator will free the memory allocated to unionArray
// when this object is destroyed
constUnion *unionArray;
ConstantUnion *unionArray;
TType *arrayInformationType; // this is used for updating maxArraySize in all the references to a given symbol
};
......
......@@ -314,14 +314,14 @@ protected:
class TIntermConstantUnion : public TIntermTyped {
public:
TIntermConstantUnion(constUnion *unionPointer, const TType& t) : TIntermTyped(t), unionArrayPointer(unionPointer) { }
constUnion* getUnionArrayPointer() const { return unionArrayPointer; }
void setUnionArrayPointer(constUnion *c) { unionArrayPointer = c; }
TIntermConstantUnion(ConstantUnion *unionPointer, const TType& t) : TIntermTyped(t), unionArrayPointer(unionPointer) { }
ConstantUnion* getUnionArrayPointer() const { return unionArrayPointer; }
void setUnionArrayPointer(ConstantUnion *c) { unionArrayPointer = c; }
virtual TIntermConstantUnion* getAsConstantUnion() { return this; }
virtual void traverse(TIntermTraverser* );
virtual TIntermTyped* fold(TOperator, TIntermTyped*, TInfoSink&);
protected:
constUnion *unionArrayPointer;
ConstantUnion *unionArrayPointer;
};
//
......
......@@ -37,9 +37,9 @@ public:
TIntermNode* addSelection(TIntermTyped* cond, TIntermNodePair code, TSourceLoc);
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
TIntermConstantUnion* addConstantUnion(constUnion*, const TType&, TSourceLoc);
TIntermConstantUnion* addConstantUnion(ConstantUnion*, const TType&, TSourceLoc);
TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
bool parseConstTree(TSourceLoc, TIntermNode*, constUnion*, TOperator, TSymbolTable&, TType, bool singleConstantParam = false);
bool parseConstTree(TSourceLoc, TIntermNode*, ConstantUnion*, TOperator, TSymbolTable&, TType, bool singleConstantParam = false);
TIntermNode* addLoop(TIntermNode*, TIntermNode*, TIntermTyped*, TIntermTyped*, bool testFirst, TSourceLoc);
TIntermBranch* addBranch(TOperator, TSourceLoc);
TIntermBranch* addBranch(TOperator, TIntermTyped*, TSourceLoc);
......
......@@ -12,7 +12,7 @@
//
class TConstTraverser : public TIntermTraverser {
public:
TConstTraverser(constUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, TSymbolTable& symTable, TType& t) : unionArray(cUnion), type(t),
TConstTraverser(ConstantUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, TSymbolTable& symTable, TType& t) : unionArray(cUnion), type(t),
constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), symbolTable(symTable), error(false), isMatrix(false), matrixSize(0)
{
index = 0;
......@@ -31,7 +31,7 @@ protected:
bool visitBranch(Visit visit, TIntermBranch*);
int index;
constUnion *unionArray;
ConstantUnion *unionArray;
TType type;
TOperator constructorType;
bool singleConstantParam;
......@@ -140,7 +140,7 @@ bool TConstTraverser::visitSelection(Visit visit, TIntermSelection* node)
void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
{
constUnion* leftUnionArray = unionArray;
ConstantUnion* leftUnionArray = unionArray;
int instanceSize = type.getObjectSize();
if (index >= instanceSize)
......@@ -149,7 +149,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
if (!singleConstantParam) {
int size = node->getType().getObjectSize();
constUnion *rightUnionArray = node->getUnionArrayPointer();
ConstantUnion *rightUnionArray = node->getUnionArrayPointer();
for (int i=0; i < size; i++) {
if (index >= instanceSize)
return;
......@@ -159,7 +159,7 @@ void TConstTraverser::visitConstantUnion(TIntermConstantUnion* node)
}
} else {
int totalSize = index + size;
constUnion *rightUnionArray = node->getUnionArrayPointer();
ConstantUnion *rightUnionArray = node->getUnionArrayPointer();
if (!isMatrix) {
int count = 0;
for (int i = index; i < totalSize; i++) {
......@@ -212,7 +212,7 @@ bool TConstTraverser::visitBranch(Visit visit, TIntermBranch* node)
// Individual functions can be initialized to 0 to skip processing of that
// type of node. It's children will still be processed.
//
bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, constUnion* unionArray, TOperator constructorType, TSymbolTable& symbolTable, TType t, bool singleConstantParam)
bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, ConstantUnion* unionArray, TOperator constructorType, TSymbolTable& symbolTable, TType t, bool singleConstantParam)
{
if (root == 0)
return false;
......
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