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/OutputGLSLBase.cpp b/src/compiler/translator/OutputGLSLBase.cpp
index 2be8e7e..8abafb8 100644
--- a/src/compiler/translator/OutputGLSLBase.cpp
+++ b/src/compiler/translator/OutputGLSLBase.cpp
@@ -916,27 +916,6 @@
         out << ")";
         visitChildren = false;
         break;
-      case EOpDeclaration:
-        // Variable declaration.
-        if (visit == PreVisit)
-        {
-            const TIntermSequence &sequence = *(node->getSequence());
-            const TIntermTyped *variable = sequence.front()->getAsTyped();
-            writeLayoutQualifier(variable->getType());
-            writeVariableType(variable->getType());
-            out << " ";
-            mDeclaringVariables = true;
-        }
-        else if (visit == InVisit)
-        {
-            out << ", ";
-            mDeclaringVariables = true;
-        }
-        else
-        {
-            mDeclaringVariables = false;
-        }
-        break;
       case EOpInvariantDeclaration:
         // Invariant declaration.
         ASSERT(visit == PreVisit);
@@ -1059,6 +1038,32 @@
     return visitChildren;
 }
 
+bool TOutputGLSLBase::visitDeclaration(Visit visit, TIntermDeclaration *node)
+{
+    TInfoSinkBase &out = objSink();
+
+    // Variable declaration.
+    if (visit == PreVisit)
+    {
+        const TIntermSequence &sequence = *(node->getSequence());
+        const TIntermTyped *variable    = sequence.front()->getAsTyped();
+        writeLayoutQualifier(variable->getType());
+        writeVariableType(variable->getType());
+        out << " ";
+        mDeclaringVariables = true;
+    }
+    else if (visit == InVisit)
+    {
+        out << ", ";
+        mDeclaringVariables = true;
+    }
+    else
+    {
+        mDeclaringVariables = false;
+    }
+    return true;
+}
+
 bool TOutputGLSLBase::visitLoop(Visit visit, TIntermLoop *node)
 {
     TInfoSinkBase &out = objSink();
@@ -1092,8 +1097,7 @@
         else
         {
             // Need to put a one-iteration loop here to handle break.
-            TIntermSequence *declSeq =
-                node->getInit()->getAsAggregate()->getSequence();
+            TIntermSequence *declSeq = node->getInit()->getAsDeclarationNode()->getSequence();
             TIntermSymbol *indexSymbol =
                 (*declSeq)[0]->getAsBinaryNode()->getLeft()->getAsSymbolNode();
             TString name = hashVariableName(indexSymbol->getSymbol());