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/Compiler.cpp b/src/compiler/translator/Compiler.cpp
index 7ef30ee..25395b1 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -763,22 +763,31 @@
bool operator ()(TIntermNode *node)
{
const TIntermAggregate *asAggregate = node->getAsAggregate();
+ const TIntermFunctionDefinition *asFunction = node->getAsFunctionDefinition();
- if (asAggregate == nullptr)
+ const TFunctionSymbolInfo *functionInfo = nullptr;
+
+ if (asFunction)
+ {
+ functionInfo = asFunction->getFunctionSymbolInfo();
+ }
+ else if (asAggregate)
+ {
+ if (asAggregate->getOp() == EOpPrototype)
+ {
+ functionInfo = asAggregate->getFunctionSymbolInfo();
+ }
+ }
+ if (functionInfo == nullptr)
{
return false;
}
- if (!(asAggregate->getOp() == EOpFunction || asAggregate->getOp() == EOpPrototype))
- {
- return false;
- }
-
- size_t callDagIndex = mCallDag->findIndex(asAggregate->getFunctionSymbolInfo());
+ size_t callDagIndex = mCallDag->findIndex(functionInfo);
if (callDagIndex == CallDAG::InvalidIndex)
{
// This happens only for unimplemented prototypes which are thus unused
- ASSERT(asAggregate->getOp() == EOpPrototype);
+ ASSERT(asAggregate && asAggregate->getOp() == EOpPrototype);
return true;
}