Clarify error checking function names in the GLSL parser
Most error checking functions in ParseContext used to follow a format
like <property>ErrorCheck. Sometimes this function would check that
the node/value would have <property>, sometimes it would check that
the node/value would not have it, which was confusing. Change most of
these functions to use a lot more descriptive names, which clearly
communicate what they are checking for.
Also includes a bit of refactoring in constructorErrorCheck(), so that
the function only checks for errors rather than also setting the type
of the constructor node.
Also make TType::arraySize unsigned, and return a sanitized size from
checkIsValidArraySize() instead of using an output parameter.
BUG=angleproject:911
TEST=angle_unittests
Change-Id: Id9767b8c79594ad3f782f801ea68eb96df721a31
Reviewed-on: https://chromium-review.googlesource.com/367070
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index ff1c1a3..0051d2d 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -224,7 +224,7 @@
int OutputHLSL::vectorSize(const TType &type) const
{
int elementSize = type.isMatrix() ? type.getCols() : 1;
- int arraySize = type.isArray() ? type.getArraySize() : 1;
+ unsigned int arraySize = type.isArray() ? type.getArraySize() : 1u;
return elementSize * arraySize;
}
@@ -1711,7 +1711,7 @@
TVector<TIntermSymbol *> samplerSymbols;
TString structName = samplerNamePrefixFromStruct(typedArg);
argType.createSamplerSymbols("angle_" + structName, "",
- argType.isArray() ? argType.getArraySize() : 0,
+ argType.isArray() ? argType.getArraySize() : 0u,
&samplerSymbols, nullptr);
for (const TIntermSymbol *sampler : samplerSymbols)
{
@@ -2502,7 +2502,7 @@
{
ASSERT(qualifier != EvqOut && qualifier != EvqInOut);
TVector<TIntermSymbol *> samplerSymbols;
- type.createSamplerSymbols("angle" + nameStr, "", 0, &samplerSymbols, nullptr);
+ type.createSamplerSymbols("angle" + nameStr, "", 0u, &samplerSymbols, nullptr);
for (const TIntermSymbol *sampler : samplerSymbols)
{
if (mOutputType == SH_HLSL_4_1_OUTPUT)
@@ -2870,14 +2870,14 @@
fnOut << "void " << function.functionName << "(out "
<< typeName << " a[" << type.getArraySize() << "]";
- for (int i = 0; i < type.getArraySize(); ++i)
+ for (unsigned int i = 0u; i < type.getArraySize(); ++i)
{
fnOut << ", " << typeName << " b" << i;
}
fnOut << ")\n"
"{\n";
- for (int i = 0; i < type.getArraySize(); ++i)
+ for (unsigned int i = 0u; i < type.getArraySize(); ++i)
{
fnOut << " a[" << i << "] = b" << i << ";\n";
}