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/intermOut.cpp b/src/compiler/translator/intermOut.cpp
index dff6008..42e29c8 100644
--- a/src/compiler/translator/intermOut.cpp
+++ b/src/compiler/translator/intermOut.cpp
@@ -10,11 +10,11 @@
namespace
{
-void OutputFunction(TInfoSinkBase &out, const char *str, TIntermAggregate *node)
+void OutputFunction(TInfoSinkBase &out, const char *str, TFunctionSymbolInfo *info)
{
- const char *internal =
- node->getFunctionSymbolInfo()->getNameObj().isInternal() ? " (internal function)" : "";
- out << str << internal << ": " << node->getFunctionSymbolInfo()->getNameObj().getString();
+ const char *internal = info->getNameObj().isInternal() ? " (internal function)" : "";
+ out << str << internal << ": " << info->getNameObj().getString() << " (symbol id "
+ << info->getId() << ")";
}
//
@@ -48,6 +48,7 @@
bool visitUnary(Visit visit, TIntermUnary *) override;
bool visitTernary(Visit visit, TIntermTernary *node) override;
bool visitIfElse(Visit visit, TIntermIfElse *node) override;
+ bool visitFunctionDefinition(Visit visit, TIntermFunctionDefinition *node) override;
bool visitAggregate(Visit visit, TIntermAggregate *) override;
bool visitBlock(Visit visit, TIntermBlock *) override;
bool visitLoop(Visit visit, TIntermLoop *) override;
@@ -372,6 +373,15 @@
return true;
}
+bool TOutputTraverser::visitFunctionDefinition(Visit visit, TIntermFunctionDefinition *node)
+{
+ TInfoSinkBase &out = sink;
+ OutputTreeText(out, node, mDepth);
+ OutputFunction(out, "Function Definition", node->getFunctionSymbolInfo());
+ out << "\n";
+ return true;
+}
+
bool TOutputTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
{
TInfoSinkBase &out = sink;
@@ -389,10 +399,13 @@
switch (node->getOp())
{
case EOpComma: out << "Comma\n"; return true;
- case EOpFunction: OutputFunction(out, "Function Definition", node); break;
- case EOpFunctionCall: OutputFunction(out, "Function Call", node); break;
+ case EOpFunctionCall:
+ OutputFunction(out, "Function Call", node->getFunctionSymbolInfo());
+ break;
case EOpParameters: out << "Function Parameters: "; break;
- case EOpPrototype: OutputFunction(out, "Function Prototype", node); break;
+ case EOpPrototype:
+ OutputFunction(out, "Function Prototype", node->getFunctionSymbolInfo());
+ break;
case EOpConstructFloat: out << "Construct float"; break;
case EOpConstructVec2: out << "Construct vec2"; break;