blob: b088633c327372a2d7440ef8319d1e46bc9c2cee [file] [log] [blame]
Olli Etuaho00f6fbb2016-07-20 16:32:29 +03001//
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
14class TIntermAggregate;
15class TIntermBinary;
16class TIntermNode;
17class TIntermSelection;
18
19class 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