Commit d3d9b9c6 by Nicolas Capens

Fix unary operator return type.

Change-Id: I68322e6626953023c3af97325f085bc33ff1b7c6 Reviewed-on: https://swiftshader-review.googlesource.com/5080Tested-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 f13a0393
......@@ -332,11 +332,8 @@ TIntermTyped* TIntermediate::addIndex(TOperator op, TIntermTyped* base, TIntermT
//
// Returns the added node.
//
TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode, const TSourceLoc &line)
TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child, const TSourceLoc &line, const TType *funcReturnType)
{
TIntermUnary* node;
TIntermTyped* child = childNode->getAsTyped();
if (child == 0) {
infoSink.info.message(EPrefixInternalError, "Bad type in AddUnaryMath", line);
return 0;
......@@ -372,11 +369,11 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode,
//
// Make a new node for the operator.
//
node = new TIntermUnary(op);
TIntermUnary *node = new TIntermUnary(op);
node->setLine(line);
node->setOperand(child);
if (! node->promote(infoSink))
if (! node->promote(infoSink, funcReturnType))
return 0;
if (childTempConstant) {
......@@ -728,8 +725,16 @@ bool TIntermOperator::isConstructor() const
//
// Returns false in nothing makes sense.
//
bool TIntermUnary::promote(TInfoSink&)
bool TIntermUnary::promote(TInfoSink&, const TType *funcReturnType)
{
setType(funcReturnType ? *funcReturnType : operand->getType());
// Unary operations result in temporary variables unless const.
if(type.getQualifier() != EvqConstExpr)
{
type.setQualifier(EvqTemporary);
}
switch (op) {
case EOpLogicalNot:
if (operand->getBasicType() != EbtBool)
......@@ -773,13 +778,6 @@ bool TIntermUnary::promote(TInfoSink&)
return false;
}
setType(operand->getType());
// Unary operations results in temporary variables unless const.
if (operand->getQualifier() != EvqConstExpr) {
getTypePointer()->setQualifier(EvqTemporary);
}
return true;
}
......
......@@ -3086,7 +3086,7 @@ TIntermTyped *TParseContext::createUnaryMath(TOperator op, TIntermTyped *child,
break;
}
return intermediate.addUnaryMath(op, child, loc); // FIXME , funcReturnType);
return intermediate.addUnaryMath(op, child, loc, funcReturnType);
}
TIntermTyped *TParseContext::addUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc)
......
......@@ -513,7 +513,7 @@ public:
void setOperand(TIntermTyped* o) { operand = o; }
TIntermTyped* getOperand() { return operand; }
bool promote(TInfoSink&);
bool promote(TInfoSink&, const TType *funcReturnType);
protected:
TIntermTyped* operand;
......
......@@ -27,7 +27,7 @@ public:
TIntermTyped* addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, const TSourceLoc&);
TIntermTyped* addUnaryMath(TOperator op, TIntermNode* child, const TSourceLoc&);
TIntermTyped* addUnaryMath(TOperator op, TIntermTyped* child, const TSourceLoc&, const TType*);
TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right, const TSourceLoc&);
TIntermAggregate* makeAggregate(TIntermNode* node, const TSourceLoc&);
TIntermAggregate* setAggregateOperator(TIntermNode*, TOperator, const TSourceLoc&);
......@@ -45,7 +45,7 @@ public:
TIntermTyped* addSwizzle(TVectorFields&, const TSourceLoc&);
bool postProcess(TIntermNode*);
void outputTree(TIntermNode*);
protected:
TInfoSink& infoSink;
......
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