• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2002 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 // NodeSearch.h: Utilities for searching translator node graphs
7 //
8 
9 #ifndef COMPILER_TRANSLATOR_TREEUTIL_NODESEARCH_H_
10 #define COMPILER_TRANSLATOR_TREEUTIL_NODESEARCH_H_
11 
12 #include "compiler/translator/tree_util/IntermTraverse.h"
13 
14 namespace sh
15 {
16 
17 template <class Parent>
18 class NodeSearchTraverser : public TIntermTraverser
19 {
20   public:
NodeSearchTraverser()21     NodeSearchTraverser() : TIntermTraverser(true, false, false), mFound(false) {}
22 
found()23     bool found() const { return mFound; }
24 
search(TIntermNode * node)25     static bool search(TIntermNode *node)
26     {
27         Parent searchTraverser;
28         node->traverse(&searchTraverser);
29         return searchTraverser.found();
30     }
31 
32   protected:
33     bool mFound;
34 };
35 
36 class FindDiscard : public NodeSearchTraverser<FindDiscard>
37 {
38   public:
visitBranch(Visit visit,TIntermBranch * node)39     bool visitBranch(Visit visit, TIntermBranch *node) override
40     {
41         switch (node->getFlowOp())
42         {
43             case EOpKill:
44                 mFound = true;
45                 break;
46 
47             default:
48                 break;
49         }
50 
51         return !mFound;
52     }
53 };
54 }  // namespace sh
55 
56 #endif  // COMPILER_TRANSLATOR_TREEUTIL_NODESEARCH_H_
57