Refactor: Return true when checks succeed in ParseContext
Instead of returning false when a check succeeds in ParseContext,
return true. This is more intuitive and in line with conventions used
elsewhere inside ANGLE.
Also includes some minor other cleanup in ParseContext, like improved
variable names and code structure especially when checking array
element properties. This will make introducing arrays of arrays easier
in the future.
BUG=angleproject:911
TEST=angle_unittests
Change-Id: I68233c01ccfbfef9529341af588f615efc2b503a
Reviewed-on: https://chromium-review.googlesource.com/371238
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/ParseContext.h b/src/compiler/translator/ParseContext.h
index 2ffd7de..ccc7e21 100644
--- a/src/compiler/translator/ParseContext.h
+++ b/src/compiler/translator/ParseContext.h
@@ -130,6 +130,8 @@
void unaryOpError(const TSourceLoc &line, const char *op, TString operand);
void binaryOpError(const TSourceLoc &line, const char *op, TString left, TString right);
+ // Check functions - the ones that return bool return false if an error was generated.
+
bool checkIsNotReserved(const TSourceLoc &line, const TString &identifier);
void checkPrecisionSpecified(const TSourceLoc &line, TPrecision precision, TBasicType type);
bool checkCanBeLValue(const TSourceLoc &line, const char *op, TIntermTyped *node);
@@ -144,8 +146,8 @@
// Returns a sanitized array size to use (the size is at least 1).
unsigned int checkIsValidArraySize(const TSourceLoc &line, TIntermTyped *expr);
- bool checkIsValidQualifierForArray(const TSourceLoc &line, const TPublicType &type);
- bool checkIsValidTypeForArray(const TSourceLoc &line, const TPublicType &type);
+ bool checkIsValidQualifierForArray(const TSourceLoc &line, const TPublicType &elementQualifier);
+ bool checkIsValidTypeForArray(const TSourceLoc &line, const TPublicType &elementType);
bool checkIsNonVoid(const TSourceLoc &line, const TString &identifier, const TBasicType &type);
void checkIsScalarBool(const TSourceLoc &line, const TIntermTyped *type);
void checkIsScalarBool(const TSourceLoc &line, const TPublicType &pType);
@@ -322,7 +324,7 @@
void enterStructDeclaration(const TSourceLoc &line, const TString &identifier);
void exitStructDeclaration();
- bool structNestingErrorCheck(const TSourceLoc &line, const TField &field);
+ void checkIsBelowStructNestingLimit(const TSourceLoc &line, const TField &field);
TIntermSwitch *addSwitch(TIntermTyped *init, TIntermAggregate *statementList, const TSourceLoc &loc);
TIntermCase *addCase(TIntermTyped *condition, const TSourceLoc &loc);
@@ -383,6 +385,9 @@
const TString &identifier,
TPublicType *type);
+ bool checkIsValidTypeAndQualifierForArray(const TSourceLoc &indexLocation,
+ const TPublicType &elementType);
+
TIntermTyped *addBinaryMathInternal(
TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc);
TIntermTyped *createAssign(