Split TIntermDeclaration from TIntermAggregate

The new class TIntermDeclaration is now used for struct, interface
block and variable declarations. TIntermDeclaration nodes do not have
a type - rather the type is stored in each child node. The types may
differ in case the declaration is a series of array declarators with
mismatching sizes.

TIntermAggregate is still used for function calls, function
prototypes, function parameter lists and invariant declarations.

BUG=angleproject:1490
TEST=angle_unittests

Change-Id: I0457188f354481470855f61ac1c878fc2579b1d1
Reviewed-on: https://chromium-review.googlesource.com/400023
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/compiler/translator/SeparateDeclarations.cpp b/src/compiler/translator/SeparateDeclarations.cpp
index cc339ea..a6aab22 100644
--- a/src/compiler/translator/SeparateDeclarations.cpp
+++ b/src/compiler/translator/SeparateDeclarations.cpp
@@ -26,7 +26,7 @@
     static void apply(TIntermNode *root);
   private:
     SeparateDeclarationsTraverser();
-    bool visitAggregate(Visit, TIntermAggregate *node) override;
+    bool visitDeclaration(Visit, TIntermDeclaration *node) override;
 };
 
 void SeparateDeclarationsTraverser::apply(TIntermNode *root)
@@ -41,33 +41,28 @@
 {
 }
 
-bool SeparateDeclarationsTraverser::visitAggregate(Visit, TIntermAggregate *node)
+bool SeparateDeclarationsTraverser::visitDeclaration(Visit, TIntermDeclaration *node)
 {
-    if (node->getOp() == EOpDeclaration)
+    TIntermSequence *sequence = node->getSequence();
+    if (sequence->size() > 1)
     {
-        TIntermSequence *sequence = node->getSequence();
-        if (sequence->size() > 1)
+        TIntermBlock *parentBlock = getParentNode()->getAsBlock();
+        ASSERT(parentBlock != nullptr);
+
+        TIntermSequence replacementDeclarations;
+        for (size_t ii = 0; ii < sequence->size(); ++ii)
         {
-            TIntermBlock *parentBlock = getParentNode()->getAsBlock();
-            ASSERT(parentBlock != nullptr);
+            TIntermDeclaration *replacementDeclaration = new TIntermDeclaration();
 
-            TIntermSequence replacementDeclarations;
-            for (size_t ii = 0; ii < sequence->size(); ++ii)
-            {
-                TIntermAggregate *replacementDeclaration = new TIntermAggregate;
-
-                replacementDeclaration->setOp(EOpDeclaration);
-                replacementDeclaration->getSequence()->push_back(sequence->at(ii));
-                replacementDeclaration->setLine(sequence->at(ii)->getLine());
-                replacementDeclarations.push_back(replacementDeclaration);
-            }
-
-            mMultiReplacements.push_back(
-                NodeReplaceWithMultipleEntry(parentBlock, node, replacementDeclarations));
+            replacementDeclaration->appendDeclarator(sequence->at(ii)->getAsTyped());
+            replacementDeclaration->setLine(sequence->at(ii)->getLine());
+            replacementDeclarations.push_back(replacementDeclaration);
         }
-        return false;
+
+        mMultiReplacements.push_back(
+            NodeReplaceWithMultipleEntry(parentBlock, node, replacementDeclarations));
     }
-    return true;
+    return false;
 }
 
 } // namespace