Clean up parseMatrixFields

Applying field selection directly on matrices is not mentioned in ESSL
1.00 or 3.00 specs. Remove erroneous code that generated odd error
messages when a shader tried to apply certain kinds of field selection
on a matrix.

BUG=angleproject:1118
TEST=angle_unittests, dEQP-GLES3.functional.shaders.swizzles.*

Change-Id: I7bbf5d0cbaee3f21d20b830d904c0feef445dd78
Reviewed-on: https://chromium-review.googlesource.com/293190
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index dd77b63..8eaa111 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -126,68 +126,6 @@
     return true;
 }
 
-//
-// Look at a '.' field selector string and change it into offsets
-// for a matrix.
-//
-bool TParseContext::parseMatrixFields(const TString &compString,
-                                      int matCols,
-                                      int matRows,
-                                      TMatrixFields &fields,
-                                      const TSourceLoc &line)
-{
-    fields.wholeRow = false;
-    fields.wholeCol = false;
-    fields.row      = -1;
-    fields.col      = -1;
-
-    if (compString.size() != 2)
-    {
-        error(line, "illegal length of matrix field selection", compString.c_str());
-        return false;
-    }
-
-    if (compString[0] == '_')
-    {
-        if (compString[1] < '0' || compString[1] > '3')
-        {
-            error(line, "illegal matrix field selection", compString.c_str());
-            return false;
-        }
-        fields.wholeCol = true;
-        fields.col      = compString[1] - '0';
-    }
-    else if (compString[1] == '_')
-    {
-        if (compString[0] < '0' || compString[0] > '3')
-        {
-            error(line, "illegal matrix field selection", compString.c_str());
-            return false;
-        }
-        fields.wholeRow = true;
-        fields.row      = compString[0] - '0';
-    }
-    else
-    {
-        if (compString[0] < '0' || compString[0] > '3' || compString[1] < '0' ||
-            compString[1] > '3')
-        {
-            error(line, "illegal matrix field selection", compString.c_str());
-            return false;
-        }
-        fields.row = compString[0] - '0';
-        fields.col = compString[1] - '0';
-    }
-
-    if (fields.row >= matRows || fields.col >= matCols)
-    {
-        error(line, "matrix field selection out of range", compString.c_str());
-        return false;
-    }
-
-    return true;
-}
-
 ///////////////////////////////////////////////////////////////////////
 //
 // Errors
@@ -3033,46 +2971,6 @@
                                              (unsigned char)vectorString.size()));
         }
     }
-    else if (baseExpression->isMatrix())
-    {
-        TMatrixFields fields;
-        if (!parseMatrixFields(fieldString, baseExpression->getCols(), baseExpression->getRows(),
-                               fields, fieldLocation))
-        {
-            fields.wholeRow = false;
-            fields.wholeCol = false;
-            fields.row      = 0;
-            fields.col = 0;
-            recover();
-        }
-
-        if (fields.wholeRow || fields.wholeCol)
-        {
-            error(dotLocation, " non-scalar fields not implemented yet", ".");
-            recover();
-            TConstantUnion *unionArray = new TConstantUnion[1];
-            unionArray->setIConst(0);
-            TIntermTyped *index = intermediate.addConstantUnion(
-                unionArray, TType(EbtInt, EbpUndefined, EvqConst), fieldLocation);
-            indexedExpression =
-                intermediate.addIndex(EOpIndexDirect, baseExpression, index, dotLocation);
-            indexedExpression->setType(
-                TType(baseExpression->getBasicType(), baseExpression->getPrecision(), EvqTemporary,
-                      static_cast<unsigned char>(baseExpression->getCols()),
-                      static_cast<unsigned char>(baseExpression->getRows())));
-        }
-        else
-        {
-            TConstantUnion *unionArray = new TConstantUnion[1];
-            unionArray->setIConst(fields.col * baseExpression->getRows() + fields.row);
-            TIntermTyped *index = intermediate.addConstantUnion(
-                unionArray, TType(EbtInt, EbpUndefined, EvqConst), fieldLocation);
-            indexedExpression =
-                intermediate.addIndex(EOpIndexDirect, baseExpression, index, dotLocation);
-            indexedExpression->setType(
-                TType(baseExpression->getBasicType(), baseExpression->getPrecision()));
-        }
-    }
     else if (baseExpression->getBasicType() == EbtStruct)
     {
         bool fieldFound          = false;
@@ -3174,15 +3072,14 @@
     {
         if (mShaderVersion < 300)
         {
-            error(dotLocation,
-                  " field selection requires structure, vector, or matrix on left hand side",
+            error(dotLocation, " field selection requires structure or vector on left hand side",
                   fieldString.c_str());
         }
         else
         {
             error(dotLocation,
-                  " field selection requires structure, vector, matrix, or interface block on left "
-                  "hand side",
+                  " field selection requires structure, vector, or interface block on left hand "
+                  "side",
                   fieldString.c_str());
         }
         recover();