Promote and fold indexing nodes similarly to other binary ops

Indexing nodes now get their type set in TIntermBinary::promote, same
as math and logic ops. They are also constant folded through
TIntermBinary::fold() instead of having special functions for constant
folding them in ParseContext.

Index nodes for struct and interface block member access now always
have integer type, instead of sometimes having the type of the field
they were used to access.

Usage of TIntermBinary constructor is cleaned up so only the
constructor that takes in left and right operands is used. The type
of TIntermBinary nodes is always determined automatically.

Together these changes make the code considerably cleaner.

Note that the code for constant folding for array indexing is actually
never hit because constant folding array constructors is still
intentionally disabled in the code.

BUG=angleproject:1490
TEST=angle_unittests

Change-Id: Ifcec45257476cdb0d495c7d72e3cf2f83388e8c5
Reviewed-on: https://chromium-review.googlesource.com/377961
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/InitializeVariables.cpp b/src/compiler/translator/InitializeVariables.cpp
index 6b01d62..8332385 100644
--- a/src/compiler/translator/InitializeVariables.cpp
+++ b/src/compiler/translator/InitializeVariables.cpp
@@ -99,10 +99,9 @@
 
             for (unsigned int i = 0; i < var.arraySize; ++i)
             {
-                TIntermBinary *element = new TIntermBinary(EOpIndexDirect);
-                element->setLeft(new TIntermSymbol(0, name, type));
-                element->setRight(TIntermTyped::CreateIndexNode(i));
-                element->setType(elementType);
+                TIntermSymbol *arraySymbol = new TIntermSymbol(0, name, type);
+                TIntermBinary *element     = new TIntermBinary(EOpIndexDirect, arraySymbol,
+                                                           TIntermTyped::CreateIndexNode(i));
 
                 TIntermTyped *zero        = TIntermTyped::CreateZero(elementType);
                 TIntermBinary *assignment = new TIntermBinary(EOpAssign, element, zero);