Commit 5f753e02 by John Kessenich

Full thread safety working:

- don't use [] for map lookups, it can modify the map - copy up built-in symbols out of shared symbol table levels before modifying them - enforce shallow vs. deep TType copies - combine maxArraySize with the array dimensions vector, encapsulate - remove chaining of array types git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22953 e7fa87d3-cd2b-0410-9028-fcbf551c1848
parent 38f3b890
...@@ -114,3 +114,12 @@ void v2() ...@@ -114,3 +114,12 @@ void v2()
{ {
return v1(); // ERROR, no expression allowed, even though void return v1(); // ERROR, no expression allowed, even though void
} }
void atest()
{
vec4 v = gl_TexCoord[1];
v += gl_TexCoord[3];
}
varying vec4 gl_TexCoord[6]; // okay, assigning a size
varying vec4 gl_TexCoord[5]; // ERROR, changing size
...@@ -27,7 +27,8 @@ ERROR: 0:94: 'a' : variables with qualifier 'const' must be initialized ...@@ -27,7 +27,8 @@ ERROR: 0:94: 'a' : variables with qualifier 'const' must be initialized
ERROR: 0:97: 'out' : overloaded functions must have the same parameter qualifiers ERROR: 0:97: 'out' : overloaded functions must have the same parameter qualifiers
ERROR: 0:99: 'return' : function return is not matching type: ERROR: 0:99: 'return' : function return is not matching type:
ERROR: 0:115: 'return' : void function cannot return a value ERROR: 0:115: 'return' : void function cannot return a value
ERROR: 29 compilation errors. No code generated. ERROR: 0:125: 'gl_TexCoord' : redeclaration of array with size
ERROR: 30 compilation errors. No code generated.
ERROR: node is still EOpNull! ERROR: node is still EOpNull!
0:21 Function Definition: main( (void) 0:21 Function Definition: main( (void)
...@@ -265,6 +266,20 @@ ERROR: node is still EOpNull! ...@@ -265,6 +266,20 @@ ERROR: node is still EOpNull!
0:115 Sequence 0:115 Sequence
0:115 Branch: Return with expression 0:115 Branch: Return with expression
0:115 Function Call: v1( (void) 0:115 Function Call: v1( (void)
0:118 Function Definition: atest( (void)
0:118 Function Parameters:
0:120 Sequence
0:120 Sequence
0:120 move second child to first child (4-component vector of float)
0:120 'v' (4-component vector of float)
0:120 direct index (smooth in 4-component vector of float)
0:120 'gl_TexCoord' (smooth in unsized array of 4-component vector of float)
0:120 1 (const int)
0:121 add second child into first child (4-component vector of float)
0:121 'v' (4-component vector of float)
0:121 direct index (smooth in 4-component vector of float)
0:121 'gl_TexCoord' (smooth in unsized array of 4-component vector of float)
0:121 3 (const int)
0:? Linker Objects 0:? Linker Objects
0:? 'i' (smooth in 4-component vector of float) 0:? 'i' (smooth in 4-component vector of float)
0:? 'o' (out 4-component vector of float) 0:? 'o' (out 4-component vector of float)
......
...@@ -134,7 +134,7 @@ ERROR: node is still EOpNull! ...@@ -134,7 +134,7 @@ ERROR: node is still EOpNull!
0:? 'rep2' (centroid smooth sample out highp 4-component vector of float) 0:? 'rep2' (centroid smooth sample out highp 4-component vector of float)
0:? 'rep3' (in highp 4-component vector of float) 0:? 'rep3' (in highp 4-component vector of float)
0:? 's' (smooth out structure) 0:? 's' (smooth out structure)
0:? 'ubInst' (layout(shared ) uniform 1-element array of block) 0:? 'ubInst' (layout(shared ) uniform unsized array of block)
0:? 'gl_VertexID' (gl_VertexId highp int) 0:? 'gl_VertexID' (gl_VertexId highp int)
0:? 'gl_InstanceID' (gl_InstanceId highp int) 0:? 'gl_InstanceID' (gl_InstanceId highp int)
...@@ -5,7 +5,7 @@ ERROR: 0:9: 'arrayed type' : not supported for this version or the enabled exten ...@@ -5,7 +5,7 @@ ERROR: 0:9: 'arrayed type' : not supported for this version or the enabled exten
ERROR: 0:11: 'arrayed constructor' : not supported for this version or the enabled extensions ERROR: 0:11: 'arrayed constructor' : not supported for this version or the enabled extensions
ERROR: 0:21: '[' : array index out of range '2' ERROR: 0:21: '[' : array index out of range '2'
ERROR: 0:25: 'assign' : cannot convert from '4-element array of mediump float' to '5-element array of mediump float' ERROR: 0:25: 'assign' : cannot convert from '4-element array of mediump float' to '5-element array of mediump float'
ERROR: 0:26: 'assign' : cannot convert from '4-element array of mediump float' to '1-element array of mediump float' ERROR: 0:26: 'assign' : cannot convert from '4-element array of mediump float' to 'unsized array of mediump float'
ERROR: 0:28: 'foo' : no matching overloaded function found ERROR: 0:28: 'foo' : no matching overloaded function found
ERROR: 0:31: 'arrayed constructor' : not supported for this version or the enabled extensions ERROR: 0:31: 'arrayed constructor' : not supported for this version or the enabled extensions
ERROR: 0:35: '[' : array index out of range '5' ERROR: 0:35: '[' : array index out of range '5'
...@@ -49,7 +49,7 @@ ERROR: node is still EOpNull! ...@@ -49,7 +49,7 @@ ERROR: node is still EOpNull!
0:24 Function Call: foo(f1[5]; (4-element array of mediump float) 0:24 Function Call: foo(f1[5]; (4-element array of mediump float)
0:24 'g5' (5-element array of mediump float) 0:24 'g5' (5-element array of mediump float)
0:25 'g5' (5-element array of mediump float) 0:25 'g5' (5-element array of mediump float)
0:26 'gu' (1-element array of mediump float) 0:26 'gu' (unsized array of mediump float)
0:28 0.000000 0:28 0.000000
0:29 Function Call: bar(f1[5]; (void) 0:29 Function Call: bar(f1[5]; (void)
0:29 'g5' (5-element array of mediump float) 0:29 'g5' (5-element array of mediump float)
...@@ -64,7 +64,7 @@ ERROR: node is still EOpNull! ...@@ -64,7 +64,7 @@ ERROR: node is still EOpNull!
0:31 true case 0:31 true case
0:32 move second child to first child (mediump float) 0:32 move second child to first child (mediump float)
0:32 direct index (mediump float) 0:32 direct index (mediump float)
0:32 'gu' (1-element array of mediump float) 0:32 'gu' (unsized array of mediump float)
0:32 0 (const int) 0:32 0 (const int)
0:32 2.000000 0:32 2.000000
0:35 move second child to first child (mediump float) 0:35 move second child to first child (mediump float)
......
...@@ -372,11 +372,11 @@ struct TIntermNodePair { ...@@ -372,11 +372,11 @@ struct TIntermNodePair {
// //
class TIntermTyped : public TIntermNode { class TIntermTyped : public TIntermNode {
public: public:
TIntermTyped(const TType& t) : type(t) { } TIntermTyped(const TType& t) { type.shallowCopy(t); }
virtual TIntermTyped* getAsTyped() { return this; } virtual TIntermTyped* getAsTyped() { return this; }
virtual void setType(const TType& t) { type = t; } virtual void setType(const TType& t) { type.shallowCopy(t); }
virtual const TType& getType() const { return type; } virtual const TType& getType() const { return type; }
virtual TType* getTypePointer() { return &type; } virtual TType& getWritableType() { return type; }
virtual TBasicType getBasicType() const { return type.getBasicType(); } virtual TBasicType getBasicType() const { return type.getBasicType(); }
virtual TQualifier& getQualifier() { return type.getQualifier(); } virtual TQualifier& getQualifier() { return type.getQualifier(); }
......
...@@ -71,7 +71,8 @@ bool CompareStruct(const TType& leftNodeType, TConstUnion* rightUnionArray, TCon ...@@ -71,7 +71,8 @@ bool CompareStruct(const TType& leftNodeType, TConstUnion* rightUnionArray, TCon
bool CompareStructure(const TType& leftNodeType, TConstUnion* rightUnionArray, TConstUnion* leftUnionArray) bool CompareStructure(const TType& leftNodeType, TConstUnion* rightUnionArray, TConstUnion* leftUnionArray)
{ {
if (leftNodeType.isArray()) { if (leftNodeType.isArray()) {
TType typeWithoutArrayness(leftNodeType); TType typeWithoutArrayness;
typeWithoutArrayness.shallowCopy(leftNodeType); // TODO: arrays of arrays: the shallow copy won't work if arrays are shared and dereferenced
typeWithoutArrayness.dereference(); typeWithoutArrayness.dereference();
int arraySize = leftNodeType.getArraySize(); int arraySize = leftNodeType.getArraySize();
...@@ -137,7 +138,8 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod ...@@ -137,7 +138,8 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
// For most cases, the return type matches the argument type, so set that // For most cases, the return type matches the argument type, so set that
// up and just code to exceptions below. // up and just code to exceptions below.
TType returnType(getType()); TType returnType;
returnType.shallowCopy(getType());
// //
// A pair of nodes is to be folded together // A pair of nodes is to be folded together
...@@ -157,7 +159,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod ...@@ -157,7 +159,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
unionArray = new TConstUnion[constantNode->getType().getObjectSize()]; unionArray = new TConstUnion[constantNode->getType().getObjectSize()];
for (int i = 0; i < constantNode->getType().getObjectSize(); ++i) for (int i = 0; i < constantNode->getType().getObjectSize(); ++i)
unionArray[i] = *getUnionArrayPointer(); unionArray[i] = *getUnionArrayPointer();
returnType = node->getType(); returnType.shallowCopy(node->getType());
objectSize = constantNode->getType().getObjectSize(); objectSize = constantNode->getType().getObjectSize();
} }
...@@ -192,7 +194,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod ...@@ -192,7 +194,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
newConstArray[column * getMatrixRows() + row].setDConst(sum); newConstArray[column * getMatrixRows() + row].setDConst(sum);
} }
} }
returnType = TType(getType().getBasicType(), EvqConst, 0, getMatrixRows(), node->getMatrixCols()); returnType.shallowCopy(TType(getType().getBasicType(), EvqConst, 0, getMatrixRows(), node->getMatrixCols()));
break; break;
case EOpDiv: case EOpDiv:
newConstArray = new TConstUnion[objectSize]; newConstArray = new TConstUnion[objectSize];
...@@ -232,7 +234,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod ...@@ -232,7 +234,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
newConstArray[i].setDConst(sum); newConstArray[i].setDConst(sum);
} }
returnType = TType(getBasicType(), EvqConst, getMatrixRows()); returnType.shallowCopy(TType(getBasicType(), EvqConst, getMatrixRows()));
break; break;
case EOpVectorTimesMatrix: case EOpVectorTimesMatrix:
...@@ -244,7 +246,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod ...@@ -244,7 +246,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
newConstArray[i].setDConst(sum); newConstArray[i].setDConst(sum);
} }
returnType = TType(getBasicType(), EvqConst, node->getMatrixCols()); returnType.shallowCopy(TType(getBasicType(), EvqConst, node->getMatrixCols()));
break; break;
case EOpMod: case EOpMod:
...@@ -307,13 +309,13 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod ...@@ -307,13 +309,13 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
assert(objectSize == 1); assert(objectSize == 1);
newConstArray = new TConstUnion[1]; newConstArray = new TConstUnion[1];
newConstArray->setBConst(*unionArray < *rightUnionArray); newConstArray->setBConst(*unionArray < *rightUnionArray);
returnType = TType(EbtBool, EvqConst); returnType.shallowCopy(TType(EbtBool, EvqConst));
break; break;
case EOpGreaterThan: case EOpGreaterThan:
assert(objectSize == 1); assert(objectSize == 1);
newConstArray = new TConstUnion[1]; newConstArray = new TConstUnion[1];
newConstArray->setBConst(*unionArray > *rightUnionArray); newConstArray->setBConst(*unionArray > *rightUnionArray);
returnType = TType(EbtBool, EvqConst); returnType.shallowCopy(TType(EbtBool, EvqConst));
break; break;
case EOpLessThanEqual: case EOpLessThanEqual:
{ {
...@@ -322,7 +324,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod ...@@ -322,7 +324,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
constant.setBConst(*unionArray > *rightUnionArray); constant.setBConst(*unionArray > *rightUnionArray);
newConstArray = new TConstUnion[1]; newConstArray = new TConstUnion[1];
newConstArray->setBConst(!constant.getBConst()); newConstArray->setBConst(!constant.getBConst());
returnType = TType(EbtBool, EvqConst); returnType.shallowCopy(TType(EbtBool, EvqConst));
break; break;
} }
case EOpGreaterThanEqual: case EOpGreaterThanEqual:
...@@ -332,7 +334,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod ...@@ -332,7 +334,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
constant.setBConst(*unionArray < *rightUnionArray); constant.setBConst(*unionArray < *rightUnionArray);
newConstArray = new TConstUnion[1]; newConstArray = new TConstUnion[1];
newConstArray->setBConst(!constant.getBConst()); newConstArray->setBConst(!constant.getBConst());
returnType = TType(EbtBool, EvqConst); returnType.shallowCopy(TType(EbtBool, EvqConst));
break; break;
} }
...@@ -351,7 +353,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod ...@@ -351,7 +353,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
newConstArray = new TConstUnion[1]; newConstArray = new TConstUnion[1];
newConstArray->setBConst(! boolNodeFlag); newConstArray->setBConst(! boolNodeFlag);
returnType = TType(EbtBool, EvqConst); returnType.shallowCopy(TType(EbtBool, EvqConst));
break; break;
case EOpNotEqual: case EOpNotEqual:
...@@ -369,7 +371,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod ...@@ -369,7 +371,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
newConstArray = new TConstUnion[1]; newConstArray = new TConstUnion[1];
newConstArray->setBConst(! boolNodeFlag); newConstArray->setBConst(! boolNodeFlag);
returnType = TType(EbtBool, EvqConst); returnType.shallowCopy(TType(EbtBool, EvqConst));
break; break;
default: default:
...@@ -607,7 +609,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType) ...@@ -607,7 +609,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
} }
TIntermConstantUnion *newNode = new TIntermConstantUnion(newConstArray, returnType); TIntermConstantUnion *newNode = new TIntermConstantUnion(newConstArray, returnType);
newNode->getTypePointer()->getQualifier().storage = EvqConst; newNode->getWritableType().getQualifier().storage = EvqConst;
newNode->setLoc(getLoc()); newNode->setLoc(getLoc());
return newNode; return newNode;
...@@ -775,7 +777,7 @@ TIntermTyped* TIntermediate::fold(TIntermAggregate* aggrNode) ...@@ -775,7 +777,7 @@ TIntermTyped* TIntermediate::fold(TIntermAggregate* aggrNode)
} }
TIntermConstantUnion *newNode = new TIntermConstantUnion(newConstArray, aggrNode->getType()); TIntermConstantUnion *newNode = new TIntermConstantUnion(newConstArray, aggrNode->getType());
newNode->getTypePointer()->getQualifier().storage = EvqConst; newNode->getWritableType().getQualifier().storage = EvqConst;
newNode->setLoc(aggrNode->getLoc()); newNode->setLoc(aggrNode->getLoc());
return newNode; return newNode;
......
...@@ -1654,8 +1654,8 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb ...@@ -1654,8 +1654,8 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
if (version < FirstProfileVersion || profile == ECompatibilityProfile || (! ForwardCompatibility && profile != EEsProfile && version < 420)) { if (version < FirstProfileVersion || profile == ECompatibilityProfile || (! ForwardCompatibility && profile != EEsProfile && version < 420)) {
TPrecisionQualifier pq = profile == EEsProfile ? EpqMedium : EpqNone; TPrecisionQualifier pq = profile == EEsProfile ? EpqMedium : EpqNone;
TType fragData(EbtFloat, EvqFragColor, 4); TType fragData(EbtFloat, EvqFragColor, 4);
TArraySizes arraySizes = NewPoolTArraySizes(); TArraySizes* arraySizes = NewPoolTArraySizes();
arraySizes->push_back(resources.maxDrawBuffers); arraySizes->setSize(resources.maxDrawBuffers);
fragData.setArraySizes(arraySizes); fragData.setArraySizes(arraySizes);
symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData)); symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
} }
......
...@@ -716,8 +716,8 @@ TIntermTyped* TIntermediate::addComma(TIntermTyped* left, TIntermTyped* right, T ...@@ -716,8 +716,8 @@ TIntermTyped* TIntermediate::addComma(TIntermTyped* left, TIntermTyped* right, T
TIntermTyped *commaAggregate = growAggregate(left, right, loc); TIntermTyped *commaAggregate = growAggregate(left, right, loc);
commaAggregate->getAsAggregate()->setOperator(EOpComma); commaAggregate->getAsAggregate()->setOperator(EOpComma);
commaAggregate->setType(right->getType()); commaAggregate->setType(right->getType());
commaAggregate->getTypePointer()->getQualifier().storage = EvqTemporary; commaAggregate->getWritableType().getQualifier().storage = EvqTemporary;
commaAggregate->getTypePointer()->getQualifier().precision = right->getTypePointer()->getQualifier().precision; commaAggregate->getWritableType().getQualifier().precision = right->getType().getQualifier().precision;
return commaAggregate; return commaAggregate;
} }
...@@ -1028,7 +1028,7 @@ bool TIntermUnary::promote() ...@@ -1028,7 +1028,7 @@ bool TIntermUnary::promote()
} }
setType(operand->getType()); setType(operand->getType());
getTypePointer()->getQualifier().storage = EvqTemporary; getWritableType().getQualifier().storage = EvqTemporary;
return true; return true;
} }
......
...@@ -101,12 +101,11 @@ public: ...@@ -101,12 +101,11 @@ public:
bool constructorError(TSourceLoc, TIntermNode*, TFunction&, TOperator, TType&); bool constructorError(TSourceLoc, TIntermNode*, TFunction&, TOperator, TType&);
void arraySizeCheck(TSourceLoc, TIntermTyped* expr, int& size); void arraySizeCheck(TSourceLoc, TIntermTyped* expr, int& size);
bool arrayQualifierError(TSourceLoc, const TPublicType&); bool arrayQualifierError(TSourceLoc, const TPublicType&);
void arraySizeRequiredCheck(TSourceLoc, int& size); void arraySizeRequiredCheck(TSourceLoc, int size);
void arrayDimError(TSourceLoc); void arrayDimError(TSourceLoc);
void arrayDimCheck(TSourceLoc, TArraySizes sizes1, TArraySizes sizes2); void arrayDimCheck(TSourceLoc, TArraySizes* sizes1, TArraySizes* sizes2);
void arrayDimCheck(TSourceLoc, const TType*, TArraySizes); void arrayDimCheck(TSourceLoc, const TType*, TArraySizes*);
void arrayCheck(TSourceLoc, TString& identifier, const TPublicType&, TVariable*& variable); void arrayCheck(TSourceLoc, TString& identifier, const TPublicType&, TVariable*& variable);
bool insertBuiltInArrayAtGlobalLevel();
bool voidErrorCheck(TSourceLoc, const TString&, const TPublicType&); bool voidErrorCheck(TSourceLoc, const TString&, const TPublicType&);
void boolCheck(TSourceLoc, const TIntermTyped*); void boolCheck(TSourceLoc, const TIntermTyped*);
void boolCheck(TSourceLoc, const TPublicType&); void boolCheck(TSourceLoc, const TPublicType&);
...@@ -136,7 +135,7 @@ public: ...@@ -136,7 +135,7 @@ public:
TIntermTyped* addConstructor(TIntermNode*, const TType&, TOperator, TFunction*, TSourceLoc); TIntermTyped* addConstructor(TIntermNode*, const TType&, TOperator, TFunction*, TSourceLoc);
TIntermTyped* constructStruct(TIntermNode*, const TType&, int, TSourceLoc); TIntermTyped* constructStruct(TIntermNode*, const TType&, int, TSourceLoc);
TIntermTyped* constructBuiltIn(const TType&, TOperator, TIntermNode*, TSourceLoc, bool subset); TIntermTyped* constructBuiltIn(const TType&, TOperator, TIntermNode*, TSourceLoc, bool subset);
void addBlock(TSourceLoc, TTypeList& typeList, const TString* instanceName = 0, TArraySizes arraySizes = 0); void addBlock(TSourceLoc, TTypeList& typeList, const TString* instanceName = 0, TArraySizes* arraySizes = 0);
void addQualifierToExisting(TSourceLoc, TQualifier, const TString& identifier); void addQualifierToExisting(TSourceLoc, TQualifier, const TString& identifier);
void addQualifierToExisting(TSourceLoc, TQualifier, TIdentifierList&); void addQualifierToExisting(TSourceLoc, TQualifier, TIdentifierList&);
void updateQualifierDefaults(TQualifier); void updateQualifierDefaults(TQualifier);
...@@ -149,7 +148,7 @@ public: ...@@ -149,7 +148,7 @@ public:
TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc); TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc);
TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc); TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc);
bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc); bool arraySetMaxSize(TSourceLoc, TIntermSymbol*, int);
void requireProfile(TSourceLoc, EProfileMask profileMask, const char *featureDesc); void requireProfile(TSourceLoc, EProfileMask profileMask, const char *featureDesc);
void requireStage(TSourceLoc, EShLanguageMask languageMask, const char *featureDesc); void requireStage(TSourceLoc, EShLanguageMask languageMask, const char *featureDesc);
......
...@@ -550,11 +550,12 @@ int TScanContext::tokenizeIdentifier() ...@@ -550,11 +550,12 @@ int TScanContext::tokenizeIdentifier()
if (ReservedSet->find(tokenText) != ReservedSet->end()) if (ReservedSet->find(tokenText) != ReservedSet->end())
return reservedWord(); return reservedWord();
keyword = (*KeywordMap)[tokenText]; std::map<std::string, int>::const_iterator it = KeywordMap->find(tokenText);
if (keyword == 0) { if (it == KeywordMap->end()) {
// Should have an identifier of some sort // Should have an identifier of some sort
return identifierOrType(); return identifierOrType();
} }
keyword = it->second;
field = false; field = false;
switch (keyword) { switch (keyword) {
......
...@@ -449,9 +449,6 @@ bool CompileDeferred( ...@@ -449,9 +449,6 @@ bool CompileDeferred(
if (! symbolTable.atGlobalLevel()) if (! symbolTable.atGlobalLevel())
parseContext.infoSink.info.message(EPrefixInternalError, "Wrong symbol table level"); parseContext.infoSink.info.message(EPrefixInternalError, "Wrong symbol table level");
if (parseContext.insertBuiltInArrayAtGlobalLevel())
success = false;
bool ret = parseContext.parseShaderStrings(ppContext, const_cast<char**>(shaderStrings), lengths, numStrings); bool ret = parseContext.parseShaderStrings(ppContext, const_cast<char**>(shaderStrings), lengths, numStrings);
if (! ret) if (! ret)
success = false; success = false;
......
...@@ -90,7 +90,7 @@ void TType::buildMangledName(TString& mangledName) ...@@ -90,7 +90,7 @@ void TType::buildMangledName(TString& mangledName)
case EbtStruct: case EbtStruct:
mangledName += "struct-"; mangledName += "struct-";
if (typeName) if (typeName)
mangledName += *typeName; mangledName += *typeName;
for (unsigned int i = 0; i < structure->size(); ++i) { for (unsigned int i = 0; i < structure->size(); ++i) {
mangledName += '-'; mangledName += '-';
(*structure)[i].type->buildMangledName(mangledName); (*structure)[i].type->buildMangledName(mangledName);
...@@ -107,9 +107,9 @@ void TType::buildMangledName(TString& mangledName) ...@@ -107,9 +107,9 @@ void TType::buildMangledName(TString& mangledName)
} }
if (arraySizes) { if (arraySizes) {
const int maxSize = 11; const int maxSize = 11;
char buf[maxSize]; char buf[maxSize];
snprintf(buf, maxSize, "%d", arraySizes->front()); snprintf(buf, maxSize, "%d", arraySizes->sizes.front());
mangledName += '['; mangledName += '[';
mangledName += buf; mangledName += buf;
mangledName += ']'; mangledName += ']';
...@@ -173,8 +173,8 @@ void TSymbolTable::dump(TInfoSink &infoSink) const ...@@ -173,8 +173,8 @@ void TSymbolTable::dump(TInfoSink &infoSink) const
// //
TFunction::~TFunction() TFunction::~TFunction()
{ {
for (TParamList::iterator i = parameters.begin(); i != parameters.end(); ++i) for (TParamList::iterator i = parameters.begin(); i != parameters.end(); ++i)
delete (*i).type; delete (*i).type;
} }
// //
...@@ -182,8 +182,8 @@ TFunction::~TFunction() ...@@ -182,8 +182,8 @@ TFunction::~TFunction()
// //
TSymbolTableLevel::~TSymbolTableLevel() TSymbolTableLevel::~TSymbolTableLevel()
{ {
for (tLevel::iterator it = level.begin(); it != level.end(); ++it) for (tLevel::iterator it = level.begin(); it != level.end(); ++it)
delete (*it).second; delete (*it).second;
delete [] defaultPrecision; delete [] defaultPrecision;
} }
...@@ -213,58 +213,59 @@ void TSymbolTableLevel::relateToOperator(const char* name, TOperator op) ...@@ -213,58 +213,59 @@ void TSymbolTableLevel::relateToOperator(const char* name, TOperator op)
void TSymbolTableLevel::readOnly() void TSymbolTableLevel::readOnly()
{ {
for (tLevel::iterator it = level.begin(); it != level.end(); ++it) for (tLevel::iterator it = level.begin(); it != level.end(); ++it)
(*it).second->readOnly(); (*it).second->makeReadOnly();
} }
//
// Copy a symbol, but the copy is writable; call readOnly() afterward if that's not desired.
//
TSymbol::TSymbol(const TSymbol& copyOf) TSymbol::TSymbol(const TSymbol& copyOf)
{ {
name = NewPoolTString(copyOf.name->c_str()); name = NewPoolTString(copyOf.name->c_str());
uniqueId = copyOf.uniqueId; uniqueId = copyOf.uniqueId;
writable = true;
} }
TVariable::TVariable(const TVariable& copyOf, TStructureMap& remapper) : TSymbol(copyOf) TVariable::TVariable(const TVariable& copyOf, TStructureMap& remapper) : TSymbol(copyOf)
{ {
type.copyType(copyOf.type, remapper); type.deepCopy(copyOf.type, remapper);
userType = copyOf.userType; userType = copyOf.userType;
// for builtIn symbol table level, unionArray and arrayInformation pointers should be NULL
assert(copyOf.arrayInformationType == 0); if (copyOf.unionArray) {
arrayInformationType = 0; assert(!copyOf.type.getStruct());
assert(copyOf.type.getObjectSize() == 1);
if (copyOf.unionArray) { unionArray = new TConstUnion[1];
assert(!copyOf.type.getStruct());
assert(copyOf.type.getObjectSize() == 1);
unionArray = new TConstUnion[1];
unionArray[0] = copyOf.unionArray[0]; unionArray[0] = copyOf.unionArray[0];
} else } else
unionArray = 0; unionArray = 0;
} }
TVariable* TVariable::clone(TStructureMap& remapper) TVariable* TVariable::clone(TStructureMap& remapper)
{ {
TVariable *variable = new TVariable(*this, remapper); TVariable *variable = new TVariable(*this, remapper);
return variable; return variable;
} }
TFunction::TFunction(const TFunction& copyOf, const TStructureMap& remapper) : TSymbol(copyOf) TFunction::TFunction(const TFunction& copyOf, const TStructureMap& remapper) : TSymbol(copyOf)
{ {
for (unsigned int i = 0; i < copyOf.parameters.size(); ++i) { for (unsigned int i = 0; i < copyOf.parameters.size(); ++i) {
TParameter param; TParameter param;
parameters.push_back(param); parameters.push_back(param);
parameters.back().copyParam(copyOf.parameters[i], remapper); parameters.back().copyParam(copyOf.parameters[i], remapper);
} }
returnType.copyType(copyOf.returnType, remapper); returnType.deepCopy(copyOf.returnType, remapper);
mangledName = copyOf.mangledName; mangledName = copyOf.mangledName;
op = copyOf.op; op = copyOf.op;
defined = copyOf.defined; defined = copyOf.defined;
} }
TFunction* TFunction::clone(TStructureMap& remapper) TFunction* TFunction::clone(TStructureMap& remapper)
{ {
TFunction *function = new TFunction(*this, remapper); TFunction *function = new TFunction(*this, remapper);
return function; return function;
} }
TAnonMember* TAnonMember::clone(TStructureMap& remapper) TAnonMember* TAnonMember::clone(TStructureMap& remapper)
...@@ -277,24 +278,24 @@ TAnonMember* TAnonMember::clone(TStructureMap& remapper) ...@@ -277,24 +278,24 @@ TAnonMember* TAnonMember::clone(TStructureMap& remapper)
TSymbolTableLevel* TSymbolTableLevel::clone(TStructureMap& remapper) TSymbolTableLevel* TSymbolTableLevel::clone(TStructureMap& remapper)
{ {
TSymbolTableLevel *symTableLevel = new TSymbolTableLevel(); TSymbolTableLevel *symTableLevel = new TSymbolTableLevel();
symTableLevel->anonId = anonId; symTableLevel->anonId = anonId;
tLevel::iterator iter; tLevel::iterator iter;
for (iter = level.begin(); iter != level.end(); ++iter) for (iter = level.begin(); iter != level.end(); ++iter)
symTableLevel->insert(*iter->second->clone(remapper)); symTableLevel->insert(*iter->second->clone(remapper));
return symTableLevel; return symTableLevel;
} }
void TSymbolTable::copyTable(const TSymbolTable& copyOf) void TSymbolTable::copyTable(const TSymbolTable& copyOf)
{ {
assert(adoptedLevels == copyOf.adoptedLevels); assert(adoptedLevels == copyOf.adoptedLevels);
TStructureMap remapper; TStructureMap remapper;
uniqueId = copyOf.uniqueId; uniqueId = copyOf.uniqueId;
noBuiltInRedeclarations = copyOf.noBuiltInRedeclarations; noBuiltInRedeclarations = copyOf.noBuiltInRedeclarations;
for (unsigned int i = copyOf.adoptedLevels; i < copyOf.table.size(); ++i) for (unsigned int i = copyOf.adoptedLevels; i < copyOf.table.size(); ++i)
table.push_back(copyOf.table[i]->clone(remapper)); table.push_back(copyOf.table[i]->clone(remapper));
} }
} // end namespace glslang } // end namespace glslang
...@@ -96,7 +96,8 @@ public: ...@@ -96,7 +96,8 @@ public:
int getUniqueId() const { return uniqueId; } int getUniqueId() const { return uniqueId; }
virtual void dump(TInfoSink &infoSink) const = 0; virtual void dump(TInfoSink &infoSink) const = 0;
void readOnly() { writable = false; } bool isReadOnly() { return ! writable; }
void makeReadOnly() { writable = false; }
protected: protected:
explicit TSymbol(const TSymbol&); explicit TSymbol(const TSymbol&);
...@@ -124,7 +125,7 @@ protected: ...@@ -124,7 +125,7 @@ protected:
// //
class TVariable : public TSymbol { class TVariable : public TSymbol {
public: public:
TVariable(const TString *name, const TType& t, bool uT = false ) : TSymbol(name), type(t), userType(uT), unionArray(0), arrayInformationType(0) { } TVariable(const TString *name, const TType& t, bool uT = false ) : TSymbol(name), userType(uT), unionArray(0) { type.shallowCopy(t); }
virtual TVariable* clone(TStructureMap& remapper); virtual TVariable* clone(TStructureMap& remapper);
virtual ~TVariable() { } virtual ~TVariable() { }
...@@ -133,12 +134,11 @@ public: ...@@ -133,12 +134,11 @@ public:
TType& getWritableType() { assert(writable); return type; } TType& getWritableType() { assert(writable); return type; }
const TType& getType() const { return type; } const TType& getType() const { return type; }
bool isUserType() const { return userType; } bool isUserType() const { return userType; }
void updateArrayInformationType(TType *t) { assert(writable); arrayInformationType = t; }
TType* getArrayInformationType() { assert(writable); return arrayInformationType; }
virtual void dump(TInfoSink &infoSink) const; virtual void dump(TInfoSink &infoSink) const;
TConstUnion* getConstUnionPointer() { TConstUnion* getConstUnionPointer()
{
if (!unionArray) if (!unionArray)
unionArray = new TConstUnion[type.getObjectSize()]; unionArray = new TConstUnion[type.getObjectSize()];
...@@ -154,16 +154,15 @@ public: ...@@ -154,16 +154,15 @@ public:
} }
protected: protected:
explicit TVariable(TVariable&); explicit TVariable(const TVariable&);
TVariable(const TVariable&, TStructureMap& remapper); TVariable(const TVariable&, TStructureMap& remapper);
TVariable& operator=(TVariable&); TVariable& operator=(const TVariable&);
TType type; TType type;
bool userType; bool userType;
// we are assuming that Pool Allocator will free the memory allocated to unionArray // we are assuming that Pool Allocator will free the memory allocated to unionArray
// when this object is destroyed // when this object is destroyed
TConstUnion *unionArray; TConstUnion *unionArray;
TType *arrayInformationType; // this is used for updating maxArraySize in all the references to a given symbol
}; };
// //
...@@ -190,15 +189,13 @@ class TFunction : public TSymbol { ...@@ -190,15 +189,13 @@ class TFunction : public TSymbol {
public: public:
explicit TFunction(TOperator o) : explicit TFunction(TOperator o) :
TSymbol(0), TSymbol(0),
returnType(TType(EbtVoid)),
op(o), op(o),
defined(false) { } defined(false) { }
TFunction(const TString *name, const TType& retType, TOperator tOp = EOpNull) : TFunction(const TString *name, const TType& retType, TOperator tOp = EOpNull) :
TSymbol(name), TSymbol(name),
returnType(retType),
mangledName(*name + '('), mangledName(*name + '('),
op(tOp), op(tOp),
defined(false) { } defined(false) { returnType.shallowCopy(retType); }
virtual TFunction* clone(TStructureMap& remapper); virtual TFunction* clone(TStructureMap& remapper);
virtual ~TFunction(); virtual ~TFunction();
...@@ -455,7 +452,20 @@ public: ...@@ -455,7 +452,20 @@ public:
return table[currentLevel()]->insert(symbol); return table[currentLevel()]->insert(symbol);
} }
TSymbol* find(const TString& name, bool* builtIn = 0, bool *currentScope = 0, bool *sharedLevel = 0) //
// To copy a variable from a shared level up to the current level, so it can be
// modified without impacting other users of the shared table.
//
TVariable* copyUp(TVariable* shared)
{
TVariable* variable = shared->clone(remapper);
variable->setUniqueId(shared->getUniqueId());
table[currentLevel()]->insert(*variable);
return variable;
}
TSymbol* find(const TString& name, bool* builtIn = 0, bool *currentScope = 0)
{ {
int level = currentLevel(); int level = currentLevel();
TSymbol* symbol; TSymbol* symbol;
...@@ -467,9 +477,7 @@ public: ...@@ -467,9 +477,7 @@ public:
if (builtIn) if (builtIn)
*builtIn = isBuiltInLevel(level); *builtIn = isBuiltInLevel(level);
if (currentScope) if (currentScope)
*currentScope = level == currentLevel(); *currentScope = isGlobalLevel(currentLevel()) || level == currentLevel(); // consider shared levels as "current scope" WRT user globals
if (sharedLevel)
*sharedLevel = isSharedLevel(level);
return symbol; return symbol;
} }
...@@ -502,6 +510,7 @@ protected: ...@@ -502,6 +510,7 @@ protected:
int uniqueId; // for unique identification in code generation int uniqueId; // for unique identification in code generation
bool noBuiltInRedeclarations; bool noBuiltInRedeclarations;
unsigned int adoptedLevels; unsigned int adoptedLevels;
TStructureMap remapper; // for now, dummy for copyUp(), which is not yet used for structures
}; };
} // end namespace glslang } // end namespace glslang
......
...@@ -90,7 +90,7 @@ using namespace glslang; ...@@ -90,7 +90,7 @@ using namespace glslang;
glslang::TParameter param; glslang::TParameter param;
glslang::TTypeLoc typeLine; glslang::TTypeLoc typeLine;
glslang::TTypeList* typeList; glslang::TTypeList* typeList;
glslang::TArraySizes arraySizes; glslang::TArraySizes* arraySizes;
glslang::TIdentifierList* identifierList; glslang::TIdentifierList* identifierList;
}; };
} interm; } interm;
...@@ -334,13 +334,15 @@ function_call_header_no_parameters ...@@ -334,13 +334,15 @@ function_call_header_no_parameters
function_call_header_with_parameters function_call_header_with_parameters
: function_call_header assignment_expression { : function_call_header assignment_expression {
TParameter param = { 0, new TType($2->getType()) }; TParameter param = { 0, new TType };
param.type->shallowCopy($2->getType());
$1.function->addParameter(param); $1.function->addParameter(param);
$$.function = $1.function; $$.function = $1.function;
$$.intermNode = $2; $$.intermNode = $2;
} }
| function_call_header_with_parameters COMMA assignment_expression { | function_call_header_with_parameters COMMA assignment_expression {
TParameter param = { 0, new TType($3->getType()) }; TParameter param = { 0, new TType };
param.type->shallowCopy($3->getType());
$1.function->addParameter(param); $1.function->addParameter(param);
$$.function = $1.function; $$.function = $1.function;
$$.intermNode = parseContext.intermediate.growAggregate($1.intermNode, $3, $2.loc); $$.intermNode = parseContext.intermediate.growAggregate($1.intermNode, $3, $2.loc);
...@@ -890,7 +892,7 @@ parameter_declarator ...@@ -890,7 +892,7 @@ parameter_declarator
if ($1.arraySizes) { if ($1.arraySizes) {
parseContext.profileRequires($1.loc, ENoProfile, 120, "GL_3DL_array_objects", "arrayed type"); parseContext.profileRequires($1.loc, ENoProfile, 120, "GL_3DL_array_objects", "arrayed type");
parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type"); parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->front()); parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->getSize());
} }
if ($1.basicType == EbtVoid) { if ($1.basicType == EbtVoid) {
parseContext.error($2.loc, "illegal use of type 'void'", $2.string->c_str(), ""); parseContext.error($2.loc, "illegal use of type 'void'", $2.string->c_str(), "");
...@@ -905,11 +907,11 @@ parameter_declarator ...@@ -905,11 +907,11 @@ parameter_declarator
if ($1.arraySizes) { if ($1.arraySizes) {
parseContext.profileRequires($1.loc, ENoProfile, 120, "GL_3DL_array_objects", "arrayed type"); parseContext.profileRequires($1.loc, ENoProfile, 120, "GL_3DL_array_objects", "arrayed type");
parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type"); parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->front()); parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->getSize());
} }
parseContext.arrayDimCheck($2.loc, $1.arraySizes, $3.arraySizes); parseContext.arrayDimCheck($2.loc, $1.arraySizes, $3.arraySizes);
parseContext.arraySizeRequiredCheck($3.loc, $3.arraySizes->front()); parseContext.arraySizeRequiredCheck($3.loc, $3.arraySizes->getSize());
parseContext.reservedErrorCheck($2.loc, *$2.string); parseContext.reservedErrorCheck($2.loc, *$2.string);
$1.arraySizes = $3.arraySizes; $1.arraySizes = $3.arraySizes;
...@@ -976,7 +978,7 @@ init_declarator_list ...@@ -976,7 +978,7 @@ init_declarator_list
| init_declarator_list COMMA IDENTIFIER array_specifier { | init_declarator_list COMMA IDENTIFIER array_specifier {
parseContext.nonInitConstCheck($3.loc, *$3.string, $1.type); parseContext.nonInitConstCheck($3.loc, *$3.string, $1.type);
if (parseContext.profile == EEsProfile) if (parseContext.profile == EEsProfile)
parseContext.arraySizeRequiredCheck($4.loc, $4.arraySizes->front()); parseContext.arraySizeRequiredCheck($4.loc, $4.arraySizes->getSize());
parseContext.arrayDimCheck($3.loc, $1.type.arraySizes, $4.arraySizes); parseContext.arrayDimCheck($3.loc, $1.type.arraySizes, $4.arraySizes);
$$ = $1; $$ = $1;
...@@ -1047,7 +1049,7 @@ single_declaration ...@@ -1047,7 +1049,7 @@ single_declaration
$$.intermAggregate = 0; $$.intermAggregate = 0;
parseContext.nonInitConstCheck($2.loc, *$2.string, $1); parseContext.nonInitConstCheck($2.loc, *$2.string, $1);
if (parseContext.profile == EEsProfile) if (parseContext.profile == EEsProfile)
parseContext.arraySizeRequiredCheck($3.loc, $3.arraySizes->front()); parseContext.arraySizeRequiredCheck($3.loc, $3.arraySizes->getSize());
parseContext.arrayDimCheck($2.loc, $1.arraySizes, $3.arraySizes); parseContext.arrayDimCheck($2.loc, $1.arraySizes, $3.arraySizes);
$$.type = $1; $$.type = $1;
...@@ -1111,7 +1113,7 @@ fully_specified_type ...@@ -1111,7 +1113,7 @@ fully_specified_type
parseContext.profileRequires($1.loc, ENoProfile, 120, "GL_3DL_array_objects", "arrayed type"); parseContext.profileRequires($1.loc, ENoProfile, 120, "GL_3DL_array_objects", "arrayed type");
parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type"); parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
if (parseContext.profile == EEsProfile) if (parseContext.profile == EEsProfile)
parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->front()); parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->getSize());
} }
parseContext.precisionQualifierCheck($$.loc, $$); parseContext.precisionQualifierCheck($$.loc, $$);
...@@ -1123,7 +1125,7 @@ fully_specified_type ...@@ -1123,7 +1125,7 @@ fully_specified_type
parseContext.profileRequires($2.loc, ENoProfile, 120, "GL_3DL_array_objects", "arrayed type"); parseContext.profileRequires($2.loc, ENoProfile, 120, "GL_3DL_array_objects", "arrayed type");
parseContext.profileRequires($2.loc, EEsProfile, 300, 0, "arrayed type"); parseContext.profileRequires($2.loc, EEsProfile, 300, 0, "arrayed type");
if (parseContext.profile == EEsProfile) if (parseContext.profile == EEsProfile)
parseContext.arraySizeRequiredCheck($2.loc, $2.arraySizes->front()); parseContext.arraySizeRequiredCheck($2.loc, $2.arraySizes->getSize());
} }
if ($2.arraySizes && parseContext.arrayQualifierError($2.loc, $1)) if ($2.arraySizes && parseContext.arrayQualifierError($2.loc, $1))
...@@ -1391,7 +1393,7 @@ array_specifier ...@@ -1391,7 +1393,7 @@ array_specifier
: LEFT_BRACKET RIGHT_BRACKET { : LEFT_BRACKET RIGHT_BRACKET {
$$.loc = $1.loc; $$.loc = $1.loc;
$$.arraySizes = NewPoolTArraySizes(); $$.arraySizes = NewPoolTArraySizes();
$$.arraySizes->push_back(0); $$.arraySizes->setSize(0);
} }
| LEFT_BRACKET constant_expression RIGHT_BRACKET { | LEFT_BRACKET constant_expression RIGHT_BRACKET {
$$.loc = $1.loc; $$.loc = $1.loc;
...@@ -1399,18 +1401,18 @@ array_specifier ...@@ -1399,18 +1401,18 @@ array_specifier
int size; int size;
parseContext.arraySizeCheck($2->getLoc(), $2, size); parseContext.arraySizeCheck($2->getLoc(), $2, size);
$$.arraySizes->push_back(size); $$.arraySizes->setSize(size);
} }
| array_specifier LEFT_BRACKET RIGHT_BRACKET { | array_specifier LEFT_BRACKET RIGHT_BRACKET {
$$ = $1; $$ = $1;
$$.arraySizes->push_back(0); $$.arraySizes->setSize(0);
} }
| array_specifier LEFT_BRACKET constant_expression RIGHT_BRACKET { | array_specifier LEFT_BRACKET constant_expression RIGHT_BRACKET {
$$ = $1; $$ = $1;
int size; int size;
parseContext.arraySizeCheck($3->getLoc(), $3, size); parseContext.arraySizeCheck($3->getLoc(), $3, size);
$$.arraySizes->push_back(size); $$.arraySizes->setSize(size);
} }
; ;
...@@ -2114,7 +2116,7 @@ struct_declaration ...@@ -2114,7 +2116,7 @@ struct_declaration
parseContext.profileRequires($1.loc, ENoProfile, 120, "GL_3DL_array_objects", "arrayed type"); parseContext.profileRequires($1.loc, ENoProfile, 120, "GL_3DL_array_objects", "arrayed type");
parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type"); parseContext.profileRequires($1.loc, EEsProfile, 300, 0, "arrayed type");
if (parseContext.profile == EEsProfile) if (parseContext.profile == EEsProfile)
parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->front()); parseContext.arraySizeRequiredCheck($1.loc, $1.arraySizes->getSize());
} }
$$ = $2; $$ = $2;
...@@ -2132,7 +2134,7 @@ struct_declaration ...@@ -2132,7 +2134,7 @@ struct_declaration
parseContext.profileRequires($2.loc, ENoProfile, 120, "GL_3DL_array_objects", "arrayed type"); parseContext.profileRequires($2.loc, ENoProfile, 120, "GL_3DL_array_objects", "arrayed type");
parseContext.profileRequires($2.loc, EEsProfile, 300, 0, "arrayed type"); parseContext.profileRequires($2.loc, EEsProfile, 300, 0, "arrayed type");
if (parseContext.profile == EEsProfile) if (parseContext.profile == EEsProfile)
parseContext.arraySizeRequiredCheck($2.loc, $2.arraySizes->front()); parseContext.arraySizeRequiredCheck($2.loc, $2.arraySizes->getSize());
} }
$$ = $3; $$ = $3;
...@@ -2166,7 +2168,7 @@ struct_declarator ...@@ -2166,7 +2168,7 @@ struct_declarator
} }
| IDENTIFIER array_specifier { | IDENTIFIER array_specifier {
if (parseContext.profile == EEsProfile) if (parseContext.profile == EEsProfile)
parseContext.arraySizeRequiredCheck($2.loc, $2.arraySizes->front()); parseContext.arraySizeRequiredCheck($2.loc, $2.arraySizes->getSize());
parseContext.arrayDimCheck($1.loc, $2.arraySizes, 0); parseContext.arrayDimCheck($1.loc, $2.arraySizes, 0);
$$.type = new TType(EbtVoid); $$.type = new TType(EbtVoid);
......
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