From 5f96bbf9fd9922b7dfc623463391e029f00be022 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Wed, 19 Dec 2012 00:50:42 +0000 Subject: [PATCH] Bug fix: Make the type of the result of a structure assignment be the type of the structure assigned. That is, the type of the result of the "=" itself, if used in a broader expression. This probably fixes some other subtle problems as well. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@20001 e7fa87d3-cd2b-0410-9028-fcbf551c1848 --- glslang/Include/intermediate.h | 2 +- glslang/MachineIndependent/Intermediate.cpp | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/glslang/Include/intermediate.h b/glslang/Include/intermediate.h index f9571c98..0def51d0 100644 --- a/glslang/Include/intermediate.h +++ b/glslang/Include/intermediate.h @@ -281,7 +281,7 @@ public: TIntermTyped(const TType& t) : type(t) { } virtual TIntermTyped* getAsTyped() { return this; } virtual void setType(const TType& t) { type = t; } - virtual TType getType() const { return type; } + virtual const TType& getType() const { return type; } virtual TType* getTypePointer() { return &type; } virtual TBasicType getBasicType() const { return type.getBasicType(); } diff --git a/glslang/MachineIndependent/Intermediate.cpp b/glslang/MachineIndependent/Intermediate.cpp index 03871eda..1ccbd839 100644 --- a/glslang/MachineIndependent/Intermediate.cpp +++ b/glslang/MachineIndependent/Intermediate.cpp @@ -815,7 +815,7 @@ bool TIntermBinary::promote(TInfoSink& infoSink) if (right->getNominalSize() > size) size = right->getNominalSize(); - TBasicType type = left->getBasicType(); + TBasicType basicType = left->getBasicType(); // // Arrays have to be exact matches. @@ -827,7 +827,8 @@ bool TIntermBinary::promote(TInfoSink& infoSink) // Base assumption: just make the type the same as the left // operand. Then only deviations from this need be coded. // - setType(TType(type, EvqTemporary, left->getNominalSize(), left->isMatrix())); + setType(left->getType()); + type.changeQualifier(EvqTemporary); // // Array operations. @@ -844,12 +845,8 @@ bool TIntermBinary::promote(TInfoSink& infoSink) setType(TType(EbtBool)); break; - // - // Set array information. - // case EOpAssign: - getType().setArraySize(left->getType().getArraySize()); - getType().setArrayInformationType(left->getType().getArrayInformationType()); + // array information was correctly set above break; default: @@ -939,12 +936,12 @@ bool TIntermBinary::promote(TInfoSink& infoSink) op = EOpVectorTimesMatrix; else { op = EOpMatrixTimesScalar; - setType(TType(type, EvqTemporary, size, true)); + setType(TType(basicType, EvqTemporary, size, true)); } } else if (left->isMatrix() && !right->isMatrix()) { if (right->isVector()) { op = EOpMatrixTimesVector; - setType(TType(type, EvqTemporary, size, false)); + setType(TType(basicType, EvqTemporary, size, false)); } else { op = EOpMatrixTimesScalar; } @@ -955,7 +952,7 @@ bool TIntermBinary::promote(TInfoSink& infoSink) // leave as component product } else if (left->isVector() || right->isVector()) { op = EOpVectorTimesScalar; - setType(TType(type, EvqTemporary, size, false)); + setType(TType(basicType, EvqTemporary, size, false)); } } else { infoSink.info.message(EPrefixInternalError, "Missing elses", getLine()); @@ -984,7 +981,7 @@ bool TIntermBinary::promote(TInfoSink& infoSink) if (! left->isVector()) return false; op = EOpVectorTimesScalarAssign; - setType(TType(type, EvqTemporary, size, false)); + setType(TType(basicType, EvqTemporary, size, false)); } } else { infoSink.info.message(EPrefixInternalError, "Missing elses", getLine()); @@ -1007,7 +1004,7 @@ bool TIntermBinary::promote(TInfoSink& infoSink) left->isVector() && right->isMatrix() || left->getBasicType() != right->getBasicType()) return false; - setType(TType(type, EvqTemporary, size, left->isMatrix() || right->isMatrix())); + setType(TType(basicType, EvqTemporary, size, left->isMatrix() || right->isMatrix())); break; case EOpEqual: