Commit f13a0393 by Nicolas Capens

Propagate constness.

Change-Id: I38ccac08347592356e0225b6eb90517e20394909 Reviewed-on: https://swiftshader-review.googlesource.com/5079Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 5e0c3546
......@@ -482,7 +482,6 @@ bool TParseContext::constructorErrorCheck(const TSourceLoc &line, TIntermNode* n
//
int size = 0;
bool constType = true;
bool full = false;
bool overFull = false;
bool matrixInMatrix = false;
......@@ -497,15 +496,10 @@ bool TParseContext::constructorErrorCheck(const TSourceLoc &line, TIntermNode* n
overFull = true;
if (op != EOpConstructStruct && !type->isArray() && size >= type->getObjectSize())
full = true;
if (param.type->getQualifier() != EvqConstExpr)
constType = false;
if (param.type->isArray())
arrayArg = true;
}
if (constType)
type->setQualifier(EvqConstExpr);
if(type->isArray()) {
if(type->getArraySize() == 0) {
type->setArraySize(function.getParamCount());
......@@ -3536,7 +3530,6 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN
recover();
callNode = intermediate.setAggregateOperator(nullptr, op, loc);
}
callNode->setType(type);
}
else
{
......@@ -3608,7 +3601,6 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN
functionCallLValueErrorCheck(fnCandidate, aggregate);
}
callNode->setType(fnCandidate->getReturnType());
}
else
{
......
......@@ -297,7 +297,7 @@ public:
TIntermTyped(const TType& t) : type(t) { }
virtual TIntermTyped* getAsTyped() { return this; }
void setType(const TType& t) { type = t; }
virtual void setType(const TType& t) { type = t; }
const TType& getType() const { return type; }
TType* getTypePointer() { return &type; }
......@@ -469,6 +469,16 @@ public:
virtual TIntermBinary* getAsBinaryNode() { return this; }
virtual void traverse(TIntermTraverser*);
void setType(const TType &t) override
{
type = t;
if(left->getQualifier() == EvqConstExpr && right->getQualifier() == EvqConstExpr)
{
type.setQualifier(EvqConstExpr);
}
}
void setLeft(TIntermTyped* n) { left = n; }
void setRight(TIntermTyped* n) { right = n; }
TIntermTyped* getLeft() const { return left; }
......@@ -488,6 +498,16 @@ public:
TIntermUnary(TOperator o, TType& t) : TIntermOperator(o, t), operand(0) {}
TIntermUnary(TOperator o) : TIntermOperator(o), operand(0) {}
void setType(const TType &t) override
{
type = t;
if(operand->getQualifier() == EvqConstExpr)
{
type.setQualifier(EvqConstExpr);
}
}
virtual void traverse(TIntermTraverser*);
virtual TIntermUnary* getAsUnaryNode() { return this; }
......@@ -516,6 +536,24 @@ public:
TIntermSequence& getSequence() { return sequence; }
void setType(const TType &t) override
{
type = t;
if(op != EOpFunctionCall)
{
for(TIntermNode *node : sequence)
{
if(!node->getAsTyped() || node->getAsTyped()->getQualifier() != EvqConstExpr)
{
return;
}
}
type.setQualifier(EvqConstExpr);
}
}
void setName(const TString& n) { name = n; }
const TString& getName() const { return name; }
......
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