2 // Copyright (c) 2002-2013 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.
6 // NodeSearch.h: Utilities for searching translator node graphs
9 #ifndef TRANSLATOR_NODESEARCH_H_
10 #define TRANSLATOR_NODESEARCH_H_
12 #include "compiler/translator/intermediate.h"
17 template <class Parent>
18 class NodeSearchTraverser : public TIntermTraverser
25 bool found() const { return mFound; }
27 static bool search(TIntermNode *node)
29 Parent searchTraverser;
30 node->traverse(&searchTraverser);
31 return searchTraverser.found();
38 class FindDiscard : public NodeSearchTraverser<FindDiscard>
41 virtual bool visitBranch(Visit visit, TIntermBranch *node)
43 switch (node->getFlowOp())
56 class FindSideEffectRewriting : public NodeSearchTraverser<FindSideEffectRewriting>
59 virtual bool visitBinary(Visit visit, TIntermBinary *node)
61 switch (node->getOp())
65 if (node->getRight()->hasSideEffects())
80 #endif // TRANSLATOR_NODESEARCH_H_