Commit 8a17626d by Olli Etuaho Committed by Commit Bot

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/371238Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 583c4d2a
......@@ -130,6 +130,8 @@ class TParseContext : angle::NonCopyable
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 @@ class TParseContext : angle::NonCopyable
// 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 @@ class TParseContext : angle::NonCopyable
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 @@ class TParseContext : angle::NonCopyable
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(
......
......@@ -1022,7 +1022,7 @@ type_specifier_no_prec
| type_specifier_nonarray LEFT_BRACKET constant_expression RIGHT_BRACKET {
$$ = $1;
if (!context->checkIsValidTypeForArray(@2, $1))
if (context->checkIsValidTypeForArray(@2, $1))
{
unsigned int size = context->checkIsValidArraySize(@2, $3);
$$.setArraySize(size);
......
......@@ -3768,7 +3768,7 @@ yyreduce:
{
(yyval.interm.type) = (yyvsp[-3].interm.type);
if (!context->checkIsValidTypeForArray((yylsp[-2]), (yyvsp[-3].interm.type)))
if (context->checkIsValidTypeForArray((yylsp[-2]), (yyvsp[-3].interm.type)))
{
unsigned int size = context->checkIsValidArraySize((yylsp[-2]), (yyvsp[-1].interm.intermTypedNode));
(yyval.interm.type).setArraySize(size);
......
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