Fix accepting arrays as array indices

Previously, arrays were being incorrectly accepted as array indices.
This was because the isScalar() check only checked that the type was
not a vector or matrix, but still returned true for scalar arrays.

This patch changes the isScalar() check so that it returns false for
arrays. This makes usage of the term "scalar" more consistent in the
shader translator. Most of the code using isScalar() was compatible
with this change. Code in util.cpp that used to assume that isScalar()
doesn't care about arrayness is refactored to work with the new
behavior.

BUG=angleproject:2102
TEST=angle_unittests

Change-Id: I2a7f4c30fca7917d1099d0400efe3de859338b2a
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index 7c7e360..0d5559a 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -765,7 +765,7 @@
 // or not.
 bool TParseContext::checkIsScalarBool(const TSourceLoc &line, const TIntermTyped *type)
 {
-    if (type->getBasicType() != EbtBool || type->isArray() || type->isMatrix() || type->isVector())
+    if (type->getBasicType() != EbtBool || !type->isScalar())
     {
         error(line, "boolean expression expected", "");
         return false;
diff --git a/src/compiler/translator/Types.h b/src/compiler/translator/Types.h
index 12da0ca..f861366 100644
--- a/src/compiler/translator/Types.h
+++ b/src/compiler/translator/Types.h
@@ -378,7 +378,7 @@
     bool isInterfaceBlock() const { return type == EbtInterfaceBlock; }
 
     bool isVector() const { return primarySize > 1 && secondarySize == 1; }
-    bool isScalar() const { return primarySize == 1 && secondarySize == 1 && !structure; }
+    bool isScalar() const { return primarySize == 1 && secondarySize == 1 && !structure && !array; }
     bool isScalarFloat() const { return isScalar() && type == EbtFloat; }
     bool isScalarInt() const { return isScalar() && (type == EbtInt || type == EbtUInt); }
 
diff --git a/src/compiler/translator/util.cpp b/src/compiler/translator/util.cpp
index e55216c..32ed128 100644
--- a/src/compiler/translator/util.cpp
+++ b/src/compiler/translator/util.cpp
@@ -186,11 +186,7 @@
 {
     if (type.getBasicType() == EbtFloat)
     {
-        if (type.isScalar())
-        {
-            return GL_FLOAT;
-        }
-        else if (type.isVector())
+        if (type.isVector())
         {
             switch (type.getNominalSize())
             {
@@ -252,15 +248,13 @@
             }
         }
         else
-            UNREACHABLE();
+        {
+            return GL_FLOAT;
+        }
     }
     else if (type.getBasicType() == EbtInt)
     {
-        if (type.isScalar())
-        {
-            return GL_INT;
-        }
-        else if (type.isVector())
+        if (type.isVector())
         {
             switch (type.getNominalSize())
             {
@@ -275,15 +269,14 @@
             }
         }
         else
-            UNREACHABLE();
+        {
+            ASSERT(!type.isMatrix());
+            return GL_INT;
+        }
     }
     else if (type.getBasicType() == EbtUInt)
     {
-        if (type.isScalar())
-        {
-            return GL_UNSIGNED_INT;
-        }
-        else if (type.isVector())
+        if (type.isVector())
         {
             switch (type.getNominalSize())
             {
@@ -298,15 +291,14 @@
             }
         }
         else
-            UNREACHABLE();
+        {
+            ASSERT(!type.isMatrix());
+            return GL_UNSIGNED_INT;
+        }
     }
     else if (type.getBasicType() == EbtBool)
     {
-        if (type.isScalar())
-        {
-            return GL_BOOL;
-        }
-        else if (type.isVector())
+        if (type.isVector())
         {
             switch (type.getNominalSize())
             {
@@ -321,7 +313,10 @@
             }
         }
         else
-            UNREACHABLE();
+        {
+            ASSERT(!type.isMatrix());
+            return GL_BOOL;
+        }
     }
 
     switch (type.getBasicType())