daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 7 | #include "compiler/translator/IntermNode.h" |
Olli Etuaho | d4f303e | 2015-05-20 17:09:06 +0300 | [diff] [blame] | 8 | #include "compiler/translator/InfoSink.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 9 | |
Olli Etuaho | 56eea88 | 2015-05-18 12:41:03 +0300 | [diff] [blame] | 10 | void TIntermTraverser::pushParentBlock(TIntermAggregate *node) |
| 11 | { |
Olli Etuaho | 64f0be9 | 2015-06-03 17:38:34 +0300 | [diff] [blame] | 12 | mParentBlockStack.push_back(ParentBlock(node, 0)); |
Olli Etuaho | 56eea88 | 2015-05-18 12:41:03 +0300 | [diff] [blame] | 13 | } |
| 14 | |
| 15 | void TIntermTraverser::incrementParentBlockPos() |
| 16 | { |
Olli Etuaho | 64f0be9 | 2015-06-03 17:38:34 +0300 | [diff] [blame] | 17 | ++mParentBlockStack.back().pos; |
Olli Etuaho | 56eea88 | 2015-05-18 12:41:03 +0300 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | void TIntermTraverser::popParentBlock() |
| 21 | { |
| 22 | ASSERT(!mParentBlockStack.empty()); |
| 23 | mParentBlockStack.pop_back(); |
| 24 | } |
| 25 | |
| 26 | void TIntermTraverser::insertStatementsInParentBlock(const TIntermSequence &insertions) |
| 27 | { |
| 28 | ASSERT(!mParentBlockStack.empty()); |
| 29 | NodeInsertMultipleEntry insert(mParentBlockStack.back().node, mParentBlockStack.back().pos, insertions); |
| 30 | mInsertions.push_back(insert); |
| 31 | } |
| 32 | |
Olli Etuaho | a4aa4e3 | 2015-06-04 15:54:30 +0300 | [diff] [blame^] | 33 | TIntermSymbol *TIntermTraverser::createTempSymbol(const TType &type, TQualifier qualifier) |
Olli Etuaho | d4f303e | 2015-05-20 17:09:06 +0300 | [diff] [blame] | 34 | { |
| 35 | // Each traversal uses at most one temporary variable, so the index stays the same within a single traversal. |
| 36 | TInfoSinkBase symbolNameOut; |
| 37 | ASSERT(mTemporaryIndex != nullptr); |
| 38 | symbolNameOut << "s" << (*mTemporaryIndex); |
| 39 | TString symbolName = symbolNameOut.c_str(); |
| 40 | |
| 41 | TIntermSymbol *node = new TIntermSymbol(0, symbolName, type); |
| 42 | node->setInternal(true); |
Olli Etuaho | a4aa4e3 | 2015-06-04 15:54:30 +0300 | [diff] [blame^] | 43 | node->getTypePointer()->setQualifier(qualifier); |
Olli Etuaho | d4f303e | 2015-05-20 17:09:06 +0300 | [diff] [blame] | 44 | return node; |
| 45 | } |
| 46 | |
Olli Etuaho | a4aa4e3 | 2015-06-04 15:54:30 +0300 | [diff] [blame^] | 47 | TIntermSymbol *TIntermTraverser::createTempSymbol(const TType &type) |
| 48 | { |
| 49 | return createTempSymbol(type, EvqTemporary); |
| 50 | } |
| 51 | |
Olli Etuaho | 4f1af78 | 2015-05-25 11:55:07 +0300 | [diff] [blame] | 52 | TIntermAggregate *TIntermTraverser::createTempDeclaration(const TType &type) |
| 53 | { |
| 54 | TIntermAggregate *tempDeclaration = new TIntermAggregate(EOpDeclaration); |
| 55 | tempDeclaration->getSequence()->push_back(createTempSymbol(type)); |
| 56 | return tempDeclaration; |
| 57 | } |
Olli Etuaho | d4f303e | 2015-05-20 17:09:06 +0300 | [diff] [blame] | 58 | |
Olli Etuaho | a4aa4e3 | 2015-06-04 15:54:30 +0300 | [diff] [blame^] | 59 | TIntermAggregate *TIntermTraverser::createTempInitDeclaration(TIntermTyped *initializer, TQualifier qualifier) |
Olli Etuaho | d4f303e | 2015-05-20 17:09:06 +0300 | [diff] [blame] | 60 | { |
| 61 | ASSERT(initializer != nullptr); |
Olli Etuaho | a4aa4e3 | 2015-06-04 15:54:30 +0300 | [diff] [blame^] | 62 | TIntermSymbol *tempSymbol = createTempSymbol(initializer->getType(), qualifier); |
Olli Etuaho | d4f303e | 2015-05-20 17:09:06 +0300 | [diff] [blame] | 63 | TIntermAggregate *tempDeclaration = new TIntermAggregate(EOpDeclaration); |
| 64 | TIntermBinary *tempInit = new TIntermBinary(EOpInitialize); |
| 65 | tempInit->setLeft(tempSymbol); |
| 66 | tempInit->setRight(initializer); |
| 67 | tempInit->setType(tempSymbol->getType()); |
| 68 | tempDeclaration->getSequence()->push_back(tempInit); |
| 69 | return tempDeclaration; |
| 70 | } |
| 71 | |
Olli Etuaho | a4aa4e3 | 2015-06-04 15:54:30 +0300 | [diff] [blame^] | 72 | TIntermAggregate *TIntermTraverser::createTempInitDeclaration(TIntermTyped *initializer) |
| 73 | { |
| 74 | return createTempInitDeclaration(initializer, EvqTemporary); |
| 75 | } |
| 76 | |
Olli Etuaho | d4f303e | 2015-05-20 17:09:06 +0300 | [diff] [blame] | 77 | TIntermBinary *TIntermTraverser::createTempAssignment(TIntermTyped *rightNode) |
| 78 | { |
| 79 | ASSERT(rightNode != nullptr); |
| 80 | TIntermSymbol *tempSymbol = createTempSymbol(rightNode->getType()); |
| 81 | TIntermBinary *assignment = new TIntermBinary(EOpAssign); |
| 82 | assignment->setLeft(tempSymbol); |
| 83 | assignment->setRight(rightNode); |
| 84 | assignment->setType(tempSymbol->getType()); |
| 85 | return assignment; |
| 86 | } |
| 87 | |
| 88 | void TIntermTraverser::useTemporaryIndex(unsigned int *temporaryIndex) |
| 89 | { |
| 90 | mTemporaryIndex = temporaryIndex; |
| 91 | } |
| 92 | |
| 93 | void TIntermTraverser::nextTemporaryIndex() |
| 94 | { |
| 95 | ASSERT(mTemporaryIndex != nullptr); |
| 96 | ++(*mTemporaryIndex); |
| 97 | } |
| 98 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 99 | // |
| 100 | // Traverse the intermediate representation tree, and |
| 101 | // call a node type specific function for each node. |
| 102 | // Done recursively through the member function Traverse(). |
| 103 | // Node types can be skipped if their function to call is 0, |
| 104 | // but their subtree will still be traversed. |
| 105 | // Nodes with children can have their whole subtree skipped |
| 106 | // if preVisit is turned on and the type specific function |
| 107 | // returns false. |
| 108 | // |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 109 | |
| 110 | // |
| 111 | // Traversal functions for terminals are straighforward.... |
| 112 | // |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 113 | void TIntermSymbol::traverse(TIntermTraverser *it) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 114 | { |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 115 | it->visitSymbol(this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 116 | } |
| 117 | |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 118 | void TIntermConstantUnion::traverse(TIntermTraverser *it) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 119 | { |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 120 | it->visitConstantUnion(this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | // |
| 124 | // Traverse a binary node. |
| 125 | // |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 126 | void TIntermBinary::traverse(TIntermTraverser *it) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 127 | { |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 128 | bool visit = true; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 129 | |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 130 | // |
| 131 | // visit the node before children if pre-visiting. |
| 132 | // |
| 133 | if (it->preVisit) |
| 134 | visit = it->visitBinary(PreVisit, this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 135 | |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 136 | // |
| 137 | // Visit the children, in the right order. |
| 138 | // |
| 139 | if (visit) |
| 140 | { |
Zhenyao Mo | 7cab38b | 2013-10-15 12:59:30 -0700 | [diff] [blame] | 141 | it->incrementDepth(this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 142 | |
Olli Etuaho | 64f0be9 | 2015-06-03 17:38:34 +0300 | [diff] [blame] | 143 | if (mLeft) |
| 144 | mLeft->traverse(it); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 145 | |
Olli Etuaho | 64f0be9 | 2015-06-03 17:38:34 +0300 | [diff] [blame] | 146 | if (it->inVisit) |
| 147 | visit = it->visitBinary(InVisit, this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 148 | |
Olli Etuaho | 64f0be9 | 2015-06-03 17:38:34 +0300 | [diff] [blame] | 149 | if (visit && mRight) |
| 150 | mRight->traverse(it); |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 151 | |
| 152 | it->decrementDepth(); |
| 153 | } |
| 154 | |
| 155 | // |
| 156 | // Visit the node after the children, if requested and the traversal |
| 157 | // hasn't been cancelled yet. |
| 158 | // |
| 159 | if (visit && it->postVisit) |
| 160 | it->visitBinary(PostVisit, this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | // |
| 164 | // Traverse a unary node. Same comments in binary node apply here. |
| 165 | // |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 166 | void TIntermUnary::traverse(TIntermTraverser *it) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 167 | { |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 168 | bool visit = true; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 169 | |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 170 | if (it->preVisit) |
| 171 | visit = it->visitUnary(PreVisit, this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 172 | |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 173 | if (visit) { |
Zhenyao Mo | 7cab38b | 2013-10-15 12:59:30 -0700 | [diff] [blame] | 174 | it->incrementDepth(this); |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 175 | mOperand->traverse(it); |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 176 | it->decrementDepth(); |
| 177 | } |
| 178 | |
| 179 | if (visit && it->postVisit) |
| 180 | it->visitUnary(PostVisit, this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | // |
| 184 | // Traverse an aggregate node. Same comments in binary node apply here. |
| 185 | // |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 186 | void TIntermAggregate::traverse(TIntermTraverser *it) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 187 | { |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 188 | bool visit = true; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 189 | |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 190 | if (it->preVisit) |
| 191 | visit = it->visitAggregate(PreVisit, this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 192 | |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 193 | if (visit) |
| 194 | { |
Olli Etuaho | 56eea88 | 2015-05-18 12:41:03 +0300 | [diff] [blame] | 195 | if (mOp == EOpSequence) |
| 196 | it->pushParentBlock(this); |
| 197 | |
Zhenyao Mo | 7cab38b | 2013-10-15 12:59:30 -0700 | [diff] [blame] | 198 | it->incrementDepth(this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 199 | |
Olli Etuaho | 64f0be9 | 2015-06-03 17:38:34 +0300 | [diff] [blame] | 200 | for (TIntermSequence::iterator sit = mSequence.begin(); |
| 201 | sit != mSequence.end(); sit++) |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 202 | { |
Olli Etuaho | 64f0be9 | 2015-06-03 17:38:34 +0300 | [diff] [blame] | 203 | (*sit)->traverse(it); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 204 | |
Olli Etuaho | 64f0be9 | 2015-06-03 17:38:34 +0300 | [diff] [blame] | 205 | if (visit && it->inVisit) |
| 206 | { |
| 207 | if (*sit != mSequence.back()) |
| 208 | visit = it->visitAggregate(InVisit, this); |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 209 | } |
Olli Etuaho | 64f0be9 | 2015-06-03 17:38:34 +0300 | [diff] [blame] | 210 | if (mOp == EOpSequence) |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 211 | { |
Olli Etuaho | 64f0be9 | 2015-06-03 17:38:34 +0300 | [diff] [blame] | 212 | it->incrementParentBlockPos(); |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 213 | } |
| 214 | } |
| 215 | |
| 216 | it->decrementDepth(); |
Olli Etuaho | 56eea88 | 2015-05-18 12:41:03 +0300 | [diff] [blame] | 217 | |
| 218 | if (mOp == EOpSequence) |
| 219 | it->popParentBlock(); |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | if (visit && it->postVisit) |
| 223 | it->visitAggregate(PostVisit, this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | // |
| 227 | // Traverse a selection node. Same comments in binary node apply here. |
| 228 | // |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 229 | void TIntermSelection::traverse(TIntermTraverser *it) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 230 | { |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 231 | bool visit = true; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 232 | |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 233 | if (it->preVisit) |
| 234 | visit = it->visitSelection(PreVisit, this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 235 | |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 236 | if (visit) |
| 237 | { |
Zhenyao Mo | 7cab38b | 2013-10-15 12:59:30 -0700 | [diff] [blame] | 238 | it->incrementDepth(this); |
Olli Etuaho | 64f0be9 | 2015-06-03 17:38:34 +0300 | [diff] [blame] | 239 | mCondition->traverse(it); |
| 240 | if (mTrueBlock) |
| 241 | mTrueBlock->traverse(it); |
| 242 | if (mFalseBlock) |
| 243 | mFalseBlock->traverse(it); |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 244 | it->decrementDepth(); |
| 245 | } |
| 246 | |
| 247 | if (visit && it->postVisit) |
| 248 | it->visitSelection(PostVisit, this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | // |
Olli Etuaho | a3a3666 | 2015-02-17 13:46:51 +0200 | [diff] [blame] | 252 | // Traverse a switch node. Same comments in binary node apply here. |
| 253 | // |
| 254 | void TIntermSwitch::traverse(TIntermTraverser *it) |
| 255 | { |
| 256 | bool visit = true; |
| 257 | |
| 258 | if (it->preVisit) |
| 259 | visit = it->visitSwitch(PreVisit, this); |
| 260 | |
| 261 | if (visit) |
| 262 | { |
| 263 | it->incrementDepth(this); |
Olli Etuaho | 64f0be9 | 2015-06-03 17:38:34 +0300 | [diff] [blame] | 264 | mInit->traverse(it); |
| 265 | if (it->inVisit) |
| 266 | visit = it->visitSwitch(InVisit, this); |
| 267 | if (visit && mStatementList) |
| 268 | mStatementList->traverse(it); |
Olli Etuaho | a3a3666 | 2015-02-17 13:46:51 +0200 | [diff] [blame] | 269 | it->decrementDepth(); |
| 270 | } |
| 271 | |
| 272 | if (visit && it->postVisit) |
| 273 | it->visitSwitch(PostVisit, this); |
| 274 | } |
| 275 | |
| 276 | // |
| 277 | // Traverse a switch node. Same comments in binary node apply here. |
| 278 | // |
| 279 | void TIntermCase::traverse(TIntermTraverser *it) |
| 280 | { |
| 281 | bool visit = true; |
| 282 | |
| 283 | if (it->preVisit) |
| 284 | visit = it->visitCase(PreVisit, this); |
| 285 | |
| 286 | if (visit && mCondition) |
| 287 | mCondition->traverse(it); |
| 288 | |
| 289 | if (visit && it->postVisit) |
| 290 | it->visitCase(PostVisit, this); |
| 291 | } |
| 292 | |
| 293 | // |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 294 | // Traverse a loop node. Same comments in binary node apply here. |
| 295 | // |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 296 | void TIntermLoop::traverse(TIntermTraverser *it) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 297 | { |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 298 | bool visit = true; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 299 | |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 300 | if (it->preVisit) |
| 301 | visit = it->visitLoop(PreVisit, this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 302 | |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 303 | if (visit) |
| 304 | { |
Zhenyao Mo | 7cab38b | 2013-10-15 12:59:30 -0700 | [diff] [blame] | 305 | it->incrementDepth(this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 306 | |
Olli Etuaho | 64f0be9 | 2015-06-03 17:38:34 +0300 | [diff] [blame] | 307 | if (mInit) |
| 308 | mInit->traverse(it); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 309 | |
Olli Etuaho | 64f0be9 | 2015-06-03 17:38:34 +0300 | [diff] [blame] | 310 | if (mCond) |
| 311 | mCond->traverse(it); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 312 | |
Olli Etuaho | 64f0be9 | 2015-06-03 17:38:34 +0300 | [diff] [blame] | 313 | if (mBody) |
| 314 | mBody->traverse(it); |
Zhenyao Mo | 6cb95f3 | 2013-10-03 17:01:52 -0700 | [diff] [blame] | 315 | |
Olli Etuaho | 64f0be9 | 2015-06-03 17:38:34 +0300 | [diff] [blame] | 316 | if (mExpr) |
| 317 | mExpr->traverse(it); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 318 | |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 319 | it->decrementDepth(); |
| 320 | } |
| 321 | |
| 322 | if (visit && it->postVisit) |
| 323 | it->visitLoop(PostVisit, this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | // |
| 327 | // Traverse a branch node. Same comments in binary node apply here. |
| 328 | // |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 329 | void TIntermBranch::traverse(TIntermTraverser *it) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 330 | { |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 331 | bool visit = true; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 332 | |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 333 | if (it->preVisit) |
| 334 | visit = it->visitBranch(PreVisit, this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 335 | |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 336 | if (visit && mExpression) { |
Zhenyao Mo | 7cab38b | 2013-10-15 12:59:30 -0700 | [diff] [blame] | 337 | it->incrementDepth(this); |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 338 | mExpression->traverse(it); |
Zhenyao Mo | e88dcaf | 2013-10-03 16:55:19 -0700 | [diff] [blame] | 339 | it->decrementDepth(); |
| 340 | } |
| 341 | |
| 342 | if (visit && it->postVisit) |
| 343 | it->visitBranch(PostVisit, this); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 344 | } |
| 345 | |
Jamie Madill | 4cfb1e8 | 2014-07-07 12:49:23 -0400 | [diff] [blame] | 346 | void TIntermRaw::traverse(TIntermTraverser *it) |
| 347 | { |
| 348 | it->visitRaw(this); |
| 349 | } |