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 ...@@ -482,7 +482,6 @@ bool TParseContext::constructorErrorCheck(const TSourceLoc &line, TIntermNode* n
// //
int size = 0; int size = 0;
bool constType = true;
bool full = false; bool full = false;
bool overFull = false; bool overFull = false;
bool matrixInMatrix = false; bool matrixInMatrix = false;
...@@ -497,15 +496,10 @@ bool TParseContext::constructorErrorCheck(const TSourceLoc &line, TIntermNode* n ...@@ -497,15 +496,10 @@ bool TParseContext::constructorErrorCheck(const TSourceLoc &line, TIntermNode* n
overFull = true; overFull = true;
if (op != EOpConstructStruct && !type->isArray() && size >= type->getObjectSize()) if (op != EOpConstructStruct && !type->isArray() && size >= type->getObjectSize())
full = true; full = true;
if (param.type->getQualifier() != EvqConstExpr)
constType = false;
if (param.type->isArray()) if (param.type->isArray())
arrayArg = true; arrayArg = true;
} }
if (constType)
type->setQualifier(EvqConstExpr);
if(type->isArray()) { if(type->isArray()) {
if(type->getArraySize() == 0) { if(type->getArraySize() == 0) {
type->setArraySize(function.getParamCount()); type->setArraySize(function.getParamCount());
...@@ -3536,7 +3530,6 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN ...@@ -3536,7 +3530,6 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN
recover(); recover();
callNode = intermediate.setAggregateOperator(nullptr, op, loc); callNode = intermediate.setAggregateOperator(nullptr, op, loc);
} }
callNode->setType(type);
} }
else else
{ {
...@@ -3608,7 +3601,6 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN ...@@ -3608,7 +3601,6 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN
functionCallLValueErrorCheck(fnCandidate, aggregate); functionCallLValueErrorCheck(fnCandidate, aggregate);
} }
callNode->setType(fnCandidate->getReturnType());
} }
else else
{ {
......
...@@ -297,7 +297,7 @@ public: ...@@ -297,7 +297,7 @@ public:
TIntermTyped(const TType& t) : type(t) { } TIntermTyped(const TType& t) : type(t) { }
virtual TIntermTyped* getAsTyped() { return this; } 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; } const TType& getType() const { return type; }
TType* getTypePointer() { return &type; } TType* getTypePointer() { return &type; }
...@@ -469,6 +469,16 @@ public: ...@@ -469,6 +469,16 @@ public:
virtual TIntermBinary* getAsBinaryNode() { return this; } virtual TIntermBinary* getAsBinaryNode() { return this; }
virtual void traverse(TIntermTraverser*); 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 setLeft(TIntermTyped* n) { left = n; }
void setRight(TIntermTyped* n) { right = n; } void setRight(TIntermTyped* n) { right = n; }
TIntermTyped* getLeft() const { return left; } TIntermTyped* getLeft() const { return left; }
...@@ -488,6 +498,16 @@ public: ...@@ -488,6 +498,16 @@ public:
TIntermUnary(TOperator o, TType& t) : TIntermOperator(o, t), operand(0) {} TIntermUnary(TOperator o, TType& t) : TIntermOperator(o, t), operand(0) {}
TIntermUnary(TOperator o) : TIntermOperator(o), 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 void traverse(TIntermTraverser*);
virtual TIntermUnary* getAsUnaryNode() { return this; } virtual TIntermUnary* getAsUnaryNode() { return this; }
...@@ -516,6 +536,24 @@ public: ...@@ -516,6 +536,24 @@ public:
TIntermSequence& getSequence() { return sequence; } 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; } void setName(const TString& n) { name = n; }
const TString& getName() const { return name; } 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