Allow length() on arbitrary array expressions

This is required to pass some dEQP GLES 3.1 tests for arrays of
arrays, and WebGL conformance tests were also recently fixed to
require this behavior. The intent of the GLSL ES spec was not to
restrict usage of length().

In practice GL drivers don't implement array length() on expressions
with side effects correctly in all cases. HLSL doesn't have an array
length operator either. Because of this we always remove array length
ops from the AST before output.

BUG=angleproject:2142
TEST=angle_unittests, angle_end2end_tests, WebGL conformance tests

Change-Id: I863a92e83ac5315b013af9a5626348482bad72b3
Reviewed-on: https://chromium-review.googlesource.com/643190
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/IntermNodePatternMatcher.cpp b/src/compiler/translator/IntermNodePatternMatcher.cpp
index ed2b9f7..567e8f7 100644
--- a/src/compiler/translator/IntermNodePatternMatcher.cpp
+++ b/src/compiler/translator/IntermNodePatternMatcher.cpp
@@ -48,6 +48,18 @@
     return false;
 }
 
+bool IntermNodePatternMatcher::match(TIntermUnary *node)
+{
+    if ((mMask & kArrayLengthMethod) != 0)
+    {
+        if (node->getOp() == EOpArrayLength)
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
 bool IntermNodePatternMatcher::match(TIntermBinary *node, TIntermNode *parentNode)
 {
     // L-value tracking information is needed to check for dynamic indexing in L-value.