Split vector swizzle AST nodes into a different node class

This avoids creating a weird aggregate node with a sequence of
constant union nodes to store the offsets. They're stored neatly
inside a vector instead. This makes code that needs to iterate
over the swizzle offsets much simpler.

BUG=angleproject:1490
TEST=angle_unittests

Change-Id: I156b95723529ee05a94d30295ffb6d0952a98564
Reviewed-on: https://chromium-review.googlesource.com/390832
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/Intermediate.cpp b/src/compiler/translator/Intermediate.cpp
index d018260..cd9712e 100644
--- a/src/compiler/translator/Intermediate.cpp
+++ b/src/compiler/translator/Intermediate.cpp
@@ -304,25 +304,22 @@
     return node;
 }
 
-TIntermTyped *TIntermediate::addSwizzle(
-    TVectorFields &fields, const TSourceLoc &line)
+TIntermTyped *TIntermediate::AddSwizzle(TIntermTyped *baseExpression,
+                                        const TVectorFields &fields,
+                                        const TSourceLoc &dotLocation)
 {
-
-    TIntermAggregate *node = new TIntermAggregate(EOpSequence);
-    node->getTypePointer()->setQualifier(EvqConst);
-
-    node->setLine(line);
-    TIntermConstantUnion *constIntNode;
-    TIntermSequence *sequenceVector = node->getSequence();
-    TConstantUnion *unionArray;
-
-    for (int i = 0; i < fields.num; i++)
+    TVector<int> fieldsVector;
+    for (int i = 0; i < fields.num; ++i)
     {
-        unionArray = new TConstantUnion[1];
-        unionArray->setIConst(fields.offsets[i]);
-        constIntNode = addConstantUnion(
-            unionArray, TType(EbtInt, EbpUndefined, EvqConst), line);
-        sequenceVector->push_back(constIntNode);
+        fieldsVector.push_back(fields.offsets[i]);
+    }
+    TIntermSwizzle *node = new TIntermSwizzle(baseExpression, fieldsVector);
+    node->setLine(dotLocation);
+
+    TIntermTyped *folded = node->fold();
+    if (folded)
+    {
+        return folded;
     }
 
     return node;