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/RewriteTexelFetchOffset.cpp b/src/compiler/translator/RewriteTexelFetchOffset.cpp
index bcd0bb5..bf89dda 100644
--- a/src/compiler/translator/RewriteTexelFetchOffset.cpp
+++ b/src/compiler/translator/RewriteTexelFetchOffset.cpp
@@ -96,21 +96,20 @@
int uniqueId = texelFetchSymbol->getUniqueId();
// Create new node that represents the call of function texelFetch.
+ // Its argument list will be: texelFetch(sampler, Position+offset, lod).
TIntermAggregate *texelFetchNode = new TIntermAggregate(EOpFunctionCall);
texelFetchNode->setName(newName);
texelFetchNode->setFunctionId(uniqueId);
texelFetchNode->setType(node->getType());
texelFetchNode->setLine(node->getLine());
- // Create argument List of texelFetch(sampler, Position+offset, lod).
- TIntermSequence newsequence;
-
// sampler
- newsequence.push_back(sequence->at(0));
+ texelFetchNode->getSequence()->push_back(sequence->at(0));
// Position
TIntermTyped *texCoordNode = sequence->at(1)->getAsTyped();
ASSERT(texCoordNode);
+
// offset
TIntermTyped *offsetNode = nullptr;
ASSERT(sequence->at(3)->getAsTyped());
@@ -122,16 +121,14 @@
constructIVec3Node->setLine(texCoordNode->getLine());
constructIVec3Node->setType(texCoordNode->getType());
- TIntermSequence ivec3Sequence;
- ivec3Sequence.push_back(sequence->at(3)->getAsTyped());
+ constructIVec3Node->getSequence()->push_back(sequence->at(3)->getAsTyped());
TConstantUnion *zero = new TConstantUnion();
zero->setIConst(0);
TType *intType = new TType(EbtInt);
TIntermConstantUnion *zeroNode = new TIntermConstantUnion(zero, *intType);
- ivec3Sequence.push_back(zeroNode);
- constructIVec3Node->insertChildNodes(0, ivec3Sequence);
+ constructIVec3Node->getSequence()->push_back(zeroNode);
offsetNode = constructIVec3Node;
}
@@ -143,11 +140,12 @@
// Position+offset
TIntermBinary *add = new TIntermBinary(EOpAdd, texCoordNode, offsetNode);
add->setLine(texCoordNode->getLine());
- newsequence.push_back(add);
+ texelFetchNode->getSequence()->push_back(add);
// lod
- newsequence.push_back(sequence->at(2));
- texelFetchNode->insertChildNodes(0, newsequence);
+ texelFetchNode->getSequence()->push_back(sequence->at(2));
+
+ ASSERT(texelFetchNode->getSequence()->size() == 3u);
// Replace the old node by this new node.
queueReplacement(node, texelFetchNode, OriginalNode::IS_DROPPED);