Split TIntermFunctionDefinition from TIntermAggregate

This makes the code easier to understand. Function definition nodes
always have just two children, the parameters node and the function
body node, so there was no proper reason why they should be aggregate
nodes.

As a part of this change, intermediate output is modified to print
symbol table ids of functions so that debugging function id related
functionality will be easier in the future.

After this patch, TIntermAggregate is still used for function
prototypes, function parameter lists, function calls, variable and
invariant declarations and the comma (sequence) operator.

BUG=angleproject:1490
TEST=angle_unittests, angle_end2end_tests

Change-Id: Ib88b4ca5d21abd5f126836ca5900d0baecabd19e
Reviewed-on: https://chromium-review.googlesource.com/394707
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/compiler/translator/RemoveDynamicIndexing.cpp b/src/compiler/translator/RemoveDynamicIndexing.cpp
index 5555868..994ae31 100644
--- a/src/compiler/translator/RemoveDynamicIndexing.cpp
+++ b/src/compiler/translator/RemoveDynamicIndexing.cpp
@@ -172,7 +172,7 @@
 //    base[1] = value;
 // }
 // Note that else is not used in above functions to avoid the RewriteElseBlocks transformation.
-TIntermAggregate *GetIndexFunctionDefinition(TType type, bool write)
+TIntermFunctionDefinition *GetIndexFunctionDefinition(TType type, bool write)
 {
     ASSERT(!type.isArray());
     // Conservatively use highp here, even if the indexed type is not highp. That way the code can't
@@ -180,8 +180,6 @@
     // highp values are being indexed in the shader. For HLSL precision doesn't matter, but in
     // principle this code could be used with multiple backends.
     type.setPrecision(EbpHigh);
-    TIntermAggregate *indexingFunction = new TIntermAggregate(EOpFunction);
-    indexingFunction->getFunctionSymbolInfo()->setNameObj(GetIndexFunctionName(type, write));
 
     TType fieldType = GetFieldType(type);
     int numCases = 0;
@@ -193,14 +191,6 @@
     {
         numCases = type.getNominalSize();
     }
-    if (write)
-    {
-        indexingFunction->setType(TType(EbtVoid));
-    }
-    else
-    {
-        indexingFunction->setType(fieldType);
-    }
 
     TIntermAggregate *paramsNode = new TIntermAggregate(EOpParameters);
     TQualifier baseQualifier = EvqInOut;
@@ -215,7 +205,6 @@
         TIntermSymbol *valueParam = CreateValueSymbol(fieldType);
         paramsNode->getSequence()->push_back(valueParam);
     }
-    indexingFunction->getSequence()->push_back(paramsNode);
 
     TIntermBlock *statementList = new TIntermBlock();
     for (int i = 0; i < numCases; ++i)
@@ -284,8 +273,16 @@
     bodyNode->getSequence()->push_back(ifNode);
     bodyNode->getSequence()->push_back(useLastBlock);
 
-    indexingFunction->getSequence()->push_back(bodyNode);
-
+    TIntermFunctionDefinition *indexingFunction = nullptr;
+    if (write)
+    {
+        indexingFunction = new TIntermFunctionDefinition(TType(EbtVoid), paramsNode, bodyNode);
+    }
+    else
+    {
+        indexingFunction = new TIntermFunctionDefinition(fieldType, paramsNode, bodyNode);
+    }
+    indexingFunction->getFunctionSymbolInfo()->setNameObj(GetIndexFunctionName(type, write));
     return indexingFunction;
 }