Unify aggregate operator folding with other constant folding

Setting the type for folded aggregate nodes should work in a similar way
as other constant folding. Common functionality between the different
folding functions is refactored into a single function.

TEST=dEQP-GLES3.functional.shaders.constant_expressions.*
BUG=angleproject:817

Change-Id: Ie0be561f4a30e52e52d570ff0b2bdb426f6e4f7a
Reviewed-on: https://chromium-review.googlesource.com/275186
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/Intermediate.cpp b/src/compiler/translator/Intermediate.cpp
index 915002c..cf0717f 100644
--- a/src/compiler/translator/Intermediate.cpp
+++ b/src/compiler/translator/Intermediate.cpp
@@ -441,9 +441,9 @@
     return true;
 }
 
-TIntermTyped *TIntermediate::foldAggregateBuiltIn(TOperator op, TIntermAggregate *aggregate)
+TIntermTyped *TIntermediate::foldAggregateBuiltIn(TIntermAggregate *aggregate)
 {
-    switch (op)
+    switch (aggregate->getOp())
     {
       case EOpAtan:
       case EOpPow:
@@ -466,7 +466,7 @@
       case EOpFaceForward:
       case EOpReflect:
       case EOpRefract:
-        return TIntermConstantUnion::FoldAggregateBuiltIn(op, aggregate, mInfoSink);
+        return aggregate->fold(mInfoSink);
       default:
         // Constant folding not supported for the built-in.
         return nullptr;