Commit 18464b51 by Jamie Madill Committed by Shannon Woods

Removed checks for zero-length arrays because you can never define such arrays.

Also removed support for max-array-size. You can only define a fixed-size array. TEST=WebGL conformance tests Review URL: https://codereview.appspot.com/9697044 git-svn-id: https://angleproject.googlecode.com/svn/trunk@2247 736b8ea6-26fd-11df-bfd4-992fa37f6226 TRAC #23333 Authored-by: alokp@chromium.org Signed-off-by: Shannon Woods Signed-off-by Nicolas Capens Merged-by: Jamie Madill
parent 28b97423
...@@ -811,16 +811,6 @@ bool TParseContext::arrayErrorCheck(const TSourceLoc& line, const TString& ident ...@@ -811,16 +811,6 @@ bool TParseContext::arrayErrorCheck(const TSourceLoc& line, const TString& ident
return true; return true;
} }
TType* t = variable->getArrayInformationType();
while (t != 0) {
if (t->getMaxArraySize() > type.arraySize) {
error(line, "higher index value already used for the array", identifier.c_str());
return true;
}
t->setArraySize(type.arraySize);
t = t->getArrayInformationType();
}
if (type.arraySize) if (type.arraySize)
variable->getType().setArraySize(type.arraySize); variable->getType().setArraySize(type.arraySize);
} }
...@@ -831,50 +821,6 @@ bool TParseContext::arrayErrorCheck(const TSourceLoc& line, const TString& ident ...@@ -831,50 +821,6 @@ bool TParseContext::arrayErrorCheck(const TSourceLoc& line, const TString& ident
return false; return false;
} }
bool TParseContext::arraySetMaxSize(TIntermSymbol *node, TType* type, int size, bool updateFlag, const TSourceLoc& line)
{
bool builtIn = false;
TSymbol* symbol = symbolTable.find(node->getSymbol(), 0, &builtIn);
if (symbol == 0) {
error(line, " undeclared identifier", node->getSymbol().c_str());
return true;
}
TVariable* variable = static_cast<TVariable*>(symbol);
type->setArrayInformationType(variable->getArrayInformationType());
variable->updateArrayInformationType(type);
// special casing to test index value of gl_FragData. If the accessed index is >= gl_MaxDrawBuffers
// its an error
if (node->getSymbol() == "gl_FragData") {
TSymbol* fragData = symbolTable.find("gl_MaxDrawBuffers", 0, &builtIn);
ASSERT(fragData);
int fragDataValue = static_cast<TVariable*>(fragData)->getConstPointer()[0].getIConst();
if (fragDataValue <= size) {
error(line, "", "[", "gl_FragData can only have a max array size of up to gl_MaxDrawBuffers");
return true;
}
}
// we dont want to update the maxArraySize when this flag is not set, we just want to include this
// node type in the chain of node types so that its updated when a higher maxArraySize comes in.
if (!updateFlag)
return false;
size++;
variable->getType().setMaxArraySize(size);
type->setMaxArraySize(size);
TType* tt = type;
while(tt->getArrayInformationType() != 0) {
tt = tt->getArrayInformationType();
tt->setMaxArraySize(size);
}
return false;
}
// //
// Enforce non-initializer type/qualifier rules. // Enforce non-initializer type/qualifier rules.
// //
...@@ -2127,20 +2073,7 @@ TIntermTyped* TParseContext::addIndexExpression(TIntermTyped *baseExpression, co ...@@ -2127,20 +2073,7 @@ TIntermTyped* TParseContext::addIndexExpression(TIntermTyped *baseExpression, co
{ {
if (baseExpression->isArray()) if (baseExpression->isArray())
{ {
if (baseExpression->getType().getArraySize() == 0) if (index >= baseExpression->getType().getArraySize())
{
if (baseExpression->getType().getMaxArraySize() <= index)
{
if (arraySetMaxSize(baseExpression->getAsSymbolNode(), baseExpression->getTypePointer(), index, true, location))
recover();
}
else
{
if (arraySetMaxSize(baseExpression->getAsSymbolNode(), baseExpression->getTypePointer(), 0, false, location))
recover();
}
}
else if (index >= baseExpression->getType().getArraySize())
{ {
std::stringstream extraInfoStream; std::stringstream extraInfoStream;
extraInfoStream << "array index out of range '" << index << "'"; extraInfoStream << "array index out of range '" << index << "'";
...@@ -2166,12 +2099,7 @@ TIntermTyped* TParseContext::addIndexExpression(TIntermTyped *baseExpression, co ...@@ -2166,12 +2099,7 @@ TIntermTyped* TParseContext::addIndexExpression(TIntermTyped *baseExpression, co
} }
else else
{ {
if (baseExpression->isArray() && baseExpression->getType().getArraySize() == 0) if (baseExpression->getBasicType() == EbtInterfaceBlock)
{
error(location, "", "[", "array must be redeclared with a size before being indexed with a variable");
recover();
}
else if (baseExpression->getBasicType() == EbtInterfaceBlock)
{ {
error(location, "", "[", "array indexes for interface blocks arrays must be constant integeral expressions"); error(location, "", "[", "array indexes for interface blocks arrays must be constant integeral expressions");
recover(); recover();
......
...@@ -119,7 +119,6 @@ struct TParseContext { ...@@ -119,7 +119,6 @@ struct TParseContext {
const TFunction* findFunction(const TSourceLoc& line, TFunction* pfnCall, int shaderVersion, bool *builtIn = 0); const TFunction* findFunction(const TSourceLoc& line, TFunction* pfnCall, int shaderVersion, bool *builtIn = 0);
bool executeInitializer(const TSourceLoc& line, const TString& identifier, TPublicType& pType, bool executeInitializer(const TSourceLoc& line, const TString& identifier, TPublicType& pType,
TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0); TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0);
bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, const TSourceLoc&);
TPublicType addFullySpecifiedType(TQualifier qualifier, const TPublicType& typeSpecifier); TPublicType addFullySpecifiedType(TQualifier qualifier, const TPublicType& typeSpecifier);
TPublicType addFullySpecifiedType(TQualifier qualifier, TLayoutQualifier layoutQualifier, const TPublicType& typeSpecifier); TPublicType addFullySpecifiedType(TQualifier qualifier, TLayoutQualifier layoutQualifier, const TPublicType& typeSpecifier);
......
...@@ -23,7 +23,7 @@ int TSymbolTableLevel::uniqueId = 0; ...@@ -23,7 +23,7 @@ int TSymbolTableLevel::uniqueId = 0;
TType::TType(const TPublicType &p) : TType::TType(const TPublicType &p) :
type(p.type), precision(p.precision), qualifier(p.qualifier), primarySize(p.primarySize), secondarySize(p.secondarySize), array(p.array), layoutQualifier(p.layoutQualifier), arraySize(p.arraySize), type(p.type), precision(p.precision), qualifier(p.qualifier), primarySize(p.primarySize), secondarySize(p.secondarySize), array(p.array), layoutQualifier(p.layoutQualifier), arraySize(p.arraySize),
maxArraySize(0), arrayInformationType(0), interfaceBlockType(0), structure(0), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), typeName(0) interfaceBlockType(0), structure(0), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), typeName(0)
{ {
if (p.userDef) { if (p.userDef) {
structure = p.userDef->getStruct(); structure = p.userDef->getStruct();
...@@ -117,7 +117,7 @@ size_t TType::getObjectSize() const ...@@ -117,7 +117,7 @@ size_t TType::getObjectSize() const
totalSize = primarySize * secondarySize; totalSize = primarySize * secondarySize;
if (isArray()) { if (isArray()) {
size_t arraySize = std::max(getArraySize(), getMaxArraySize()); size_t arraySize = getArraySize();
if (arraySize > INT_MAX / totalSize) if (arraySize > INT_MAX / totalSize)
totalSize = INT_MAX; totalSize = INT_MAX;
else else
......
...@@ -70,15 +70,13 @@ private: ...@@ -70,15 +70,13 @@ private:
// //
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), type(t), userType(uT), unionArray(0) { }
virtual ~TVariable() { } virtual ~TVariable() { }
virtual bool isVariable() const { return true; } virtual bool isVariable() const { return true; }
TType& getType() { return type; } TType& getType() { 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 setQualifier(TQualifier qualifier) { type.setQualifier(qualifier); } void setQualifier(TQualifier qualifier) { type.setQualifier(qualifier); }
void updateArrayInformationType(TType *t) { arrayInformationType = t; }
TType* getArrayInformationType() { return arrayInformationType; }
ConstantUnion* getConstPointer() ConstantUnion* getConstPointer()
{ {
...@@ -107,7 +105,6 @@ private: ...@@ -107,7 +105,6 @@ private:
// 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
ConstantUnion *unionArray; ConstantUnion *unionArray;
TType *arrayInformationType; // this is used for updating maxArraySize in all the references to a given symbol
}; };
// //
......
...@@ -39,13 +39,13 @@ public: ...@@ -39,13 +39,13 @@ public:
TType() {} TType() {}
TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, int ps = 1, int ss = 1, bool a = false) : TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, int ps = 1, int ss = 1, bool a = false) :
type(t), precision(p), qualifier(q), primarySize(ps), secondarySize(ss), array(a), layoutQualifier(TLayoutQualifier::create()), arraySize(0), type(t), precision(p), qualifier(q), primarySize(ps), secondarySize(ss), array(a), layoutQualifier(TLayoutQualifier::create()), arraySize(0),
maxArraySize(0), arrayInformationType(0), interfaceBlockType(0), structure(0), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), typeName(0), instanceName(0) interfaceBlockType(0), structure(0), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), typeName(0), instanceName(0)
{ {
} }
explicit TType(const TPublicType &p); explicit TType(const TPublicType &p);
TType(TTypeList* userDef, const TString& n, TPrecision p = EbpUndefined) : TType(TTypeList* userDef, const TString& n, TPrecision p = EbpUndefined) :
type(EbtStruct), precision(p), qualifier(EvqTemporary), primarySize(1), secondarySize(1), array(false), layoutQualifier(TLayoutQualifier::create()), arraySize(0), type(EbtStruct), precision(p), qualifier(EvqTemporary), primarySize(1), secondarySize(1), array(false), layoutQualifier(TLayoutQualifier::create()), arraySize(0),
maxArraySize(0), arrayInformationType(0), interfaceBlockType(0), structure(userDef), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), instanceName(0) interfaceBlockType(0), structure(userDef), structureSize(0), deepestStructNesting(0), fieldName(0), mangled(0), instanceName(0)
{ {
typeName = NewPoolTString(n.c_str()); typeName = NewPoolTString(n.c_str());
} }
...@@ -113,11 +113,7 @@ public: ...@@ -113,11 +113,7 @@ public:
bool isArray() const { return array ? true : false; } bool isArray() const { return array ? true : false; }
int getArraySize() const { return arraySize; } int getArraySize() const { return arraySize; }
void setArraySize(int s) { array = true; arraySize = s; } void setArraySize(int s) { array = true; arraySize = s; }
int getMaxArraySize () const { return maxArraySize; } void clearArrayness() { array = false; arraySize = 0; }
void setMaxArraySize (int s) { maxArraySize = s; }
void clearArrayness() { array = false; arraySize = 0; maxArraySize = 0; }
void setArrayInformationType(TType* t) { arrayInformationType = t; }
TType* getArrayInformationType() const { return arrayInformationType; }
void setInterfaceBlockType(TType* t) { interfaceBlockType = t; } void setInterfaceBlockType(TType* t) { interfaceBlockType = t; }
TType* getInterfaceBlockType() const { return interfaceBlockType; } TType* getInterfaceBlockType() const { return interfaceBlockType; }
bool isInterfaceBlockMember() const { return interfaceBlockType != NULL; } bool isInterfaceBlockMember() const { return interfaceBlockType != NULL; }
...@@ -241,8 +237,6 @@ private: ...@@ -241,8 +237,6 @@ private:
int primarySize; // size of vector or cols matrix int primarySize; // size of vector or cols matrix
int secondarySize; // rows of a matrix int secondarySize; // rows of a matrix
int arraySize; int arraySize;
int maxArraySize;
TType* arrayInformationType;
TType* interfaceBlockType; TType* interfaceBlockType;
TTypeList* structure; // 0 unless this is a struct TTypeList* structure; // 0 unless this is a struct
......
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