Split TIntermBlock from TIntermAggregate
The new TIntermBlock node class replaces TIntermAggregate nodes with
the EOpSequence op. It represents the root node of the tree which is
a list of declarations and function definitions, and any code blocks
that can be denoted by curly braces. These include function and loop
bodies, and if-else branches.
This change enables a bunch of more compile-time type checking, and
makes the AST code easier to understand and less error-prone.
The PostProcess step that used to be done to ensure that the root node
is TIntermAggregate is removed in favor of making sure that the root
node is a TIntermBlock in the glslang.y parsing code.
Intermediate output formatting is improved to print the EOpNull error
in a clearer way.
After this patch, TIntermAggregate is still used for function
definitions, 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: I04044affff979a11577bc1fe75d747e538b799c8
Reviewed-on: https://chromium-review.googlesource.com/393726
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/compiler/translator/intermOut.cpp b/src/compiler/translator/intermOut.cpp
index aed53d4..e3f9a55 100644
--- a/src/compiler/translator/intermOut.cpp
+++ b/src/compiler/translator/intermOut.cpp
@@ -48,6 +48,7 @@
bool visitTernary(Visit visit, TIntermTernary *node) override;
bool visitIfElse(Visit visit, TIntermIfElse *node) override;
bool visitAggregate(Visit visit, TIntermAggregate *) override;
+ bool visitBlock(Visit visit, TIntermBlock *) override;
bool visitLoop(Visit visit, TIntermLoop *) override;
bool visitBranch(Visit visit, TIntermBranch *) override;
// TODO: Add missing visit functions
@@ -374,18 +375,18 @@
{
TInfoSinkBase &out = sink;
+ OutputTreeText(out, node, mDepth);
+
if (node->getOp() == EOpNull)
{
out.prefix(EPrefixError);
- out << "node is still EOpNull!";
+ out << "node is still EOpNull!\n";
return true;
}
- OutputTreeText(out, node, mDepth);
switch (node->getOp())
{
- case EOpSequence: out << "Sequence\n"; return true;
case EOpComma: out << "Comma\n"; return true;
case EOpFunction: OutputFunction(out, "Function Definition", node); break;
case EOpFunctionCall: OutputFunction(out, "Function Call", node); break;
@@ -457,7 +458,7 @@
out << "Bad aggregation op";
}
- if (node->getOp() != EOpSequence && node->getOp() != EOpParameters)
+ if (node->getOp() != EOpParameters)
out << " (" << node->getCompleteString() << ")";
out << "\n";
@@ -465,6 +466,16 @@
return true;
}
+bool TOutputTraverser::visitBlock(Visit visit, TIntermBlock *node)
+{
+ TInfoSinkBase &out = sink;
+
+ OutputTreeText(out, node, mDepth);
+ out << "Code block\n";
+
+ return true;
+}
+
bool TOutputTraverser::visitTernary(Visit visit, TIntermTernary *node)
{
TInfoSinkBase &out = sink;