1 // 2 // Copyright (c) 2012 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 7 #include "compiler/depgraph/DependencyGraph.h" 8 9 // These methods do a breadth-first traversal through the graph and mark visited nodes. 10 11 void TGraphNode::traverse(TDependencyGraphTraverser* graphTraverser) 12 { 13 graphTraverser->markVisited(this); 14 } 15 16 void TGraphParentNode::traverse(TDependencyGraphTraverser* graphTraverser) 17 { 18 TGraphNode::traverse(graphTraverser); 19 20 graphTraverser->incrementDepth(); 21 22 // Visit the parent node's children. 23 for (TGraphNodeSet::const_iterator iter = mDependentNodes.begin(); 24 iter != mDependentNodes.end(); 25 ++iter) 26 { 27 TGraphNode* node = *iter; 28 if (!graphTraverser->isVisited(node)) 29 node->traverse(graphTraverser); 30 } 31 32 graphTraverser->decrementDepth(); 33 } 34 35 void TGraphArgument::traverse(TDependencyGraphTraverser* graphTraverser) 36 { 37 graphTraverser->visitArgument(this); 38 TGraphParentNode::traverse(graphTraverser); 39 } 40 41 void TGraphFunctionCall::traverse(TDependencyGraphTraverser* graphTraverser) 42 { 43 graphTraverser->visitFunctionCall(this); 44 TGraphParentNode::traverse(graphTraverser); 45 } 46 47 void TGraphSymbol::traverse(TDependencyGraphTraverser* graphTraverser) 48 { 49 graphTraverser->visitSymbol(this); 50 TGraphParentNode::traverse(graphTraverser); 51 } 52 53 void TGraphSelection::traverse(TDependencyGraphTraverser* graphTraverser) 54 { 55 graphTraverser->visitSelection(this); 56 TGraphNode::traverse(graphTraverser); 57 } 58 59 void TGraphLoop::traverse(TDependencyGraphTraverser* graphTraverser) 60 { 61 graphTraverser->visitLoop(this); 62 TGraphNode::traverse(graphTraverser); 63 } 64 65 void TGraphLogicalOp::traverse(TDependencyGraphTraverser* graphTraverser) 66 { 67 graphTraverser->visitLogicalOp(this); 68 TGraphNode::traverse(graphTraverser); 69 } 70