Olli Etuaho | 00f6fbb | 2016-07-20 16:32:29 +0300 | [diff] [blame^] | 1 | // |
| 2 | // Copyright (c) 2016 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 | // IntermNodePatternMatcher is a helper class for matching node trees to given patterns. |
| 7 | // It can be used whenever the same checks for certain node structures are common to multiple AST |
| 8 | // traversers. |
| 9 | // |
| 10 | |
| 11 | #ifndef COMPILER_TRANSLATOR_INTERMNODEPATTERNMATCHER_H_ |
| 12 | #define COMPILER_TRANSLATOR_INTERMNODEPATTERNMATCHER_H_ |
| 13 | |
| 14 | class TIntermAggregate; |
| 15 | class TIntermBinary; |
| 16 | class TIntermNode; |
| 17 | class TIntermSelection; |
| 18 | |
| 19 | class IntermNodePatternMatcher |
| 20 | { |
| 21 | public: |
| 22 | enum PatternType |
| 23 | { |
| 24 | kUnfoldedShortCircuitExpression = 0x0001, |
| 25 | |
| 26 | // Matches expressions that return arrays with the exception of simple statements where a |
| 27 | // constructor or function call result is assigned. |
| 28 | kExpressionReturningArray = 0x0002 |
| 29 | }; |
| 30 | IntermNodePatternMatcher(const unsigned int mask); |
| 31 | |
| 32 | bool match(TIntermBinary *node, TIntermNode *parentNode); |
| 33 | bool match(TIntermAggregate *node, TIntermNode *parentNode); |
| 34 | bool match(TIntermSelection *node); |
| 35 | |
| 36 | private: |
| 37 | const unsigned int mMask; |
| 38 | }; |
| 39 | |
| 40 | #endif |