Olli Etuaho | 2cd7a0e | 2015-02-27 13:57:32 +0200 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2002-2015 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 | #ifndef COMPILER_TRANSLATOR_REMOVESWITCHFALLTHROUGH_H_ |
| 8 | #define COMPILER_TRANSLATOR_REMOVESWITCHFALLTHROUGH_H_ |
| 9 | |
| 10 | #include "compiler/translator/IntermNode.h" |
| 11 | |
| 12 | class RemoveSwitchFallThrough : public TIntermTraverser |
| 13 | { |
| 14 | public: |
| 15 | // When given a statementList from a switch AST node, return an updated |
| 16 | // statementList that has fall-through removed. |
| 17 | static TIntermAggregate *removeFallThrough(TIntermAggregate *statementList); |
| 18 | |
| 19 | private: |
| 20 | RemoveSwitchFallThrough(TIntermAggregate *statementList); |
| 21 | |
| 22 | void visitSymbol(TIntermSymbol *node) override; |
| 23 | void visitConstantUnion(TIntermConstantUnion *node) override; |
| 24 | bool visitBinary(Visit, TIntermBinary *node) override; |
| 25 | bool visitUnary(Visit, TIntermUnary *node) override; |
| 26 | bool visitSelection(Visit visit, TIntermSelection *node) override; |
| 27 | bool visitSwitch(Visit, TIntermSwitch *node) override; |
| 28 | bool visitCase(Visit, TIntermCase *node) override; |
| 29 | bool visitAggregate(Visit, TIntermAggregate *node) override; |
| 30 | bool visitLoop(Visit, TIntermLoop *node) override; |
| 31 | bool visitBranch(Visit, TIntermBranch *node) override; |
| 32 | |
| 33 | void outputSequence(TIntermSequence *sequence, size_t startIndex); |
| 34 | void handlePreviousCase(); |
| 35 | |
| 36 | TIntermAggregate *mStatementList; |
| 37 | TIntermAggregate *mStatementListOut; |
| 38 | bool mLastStatementWasBreak; |
| 39 | TIntermAggregate *mPreviousCase; |
| 40 | std::vector<TIntermAggregate *> mCasesSharingBreak; |
| 41 | }; |
| 42 | |
| 43 | #endif // COMPILER_TRANSLATOR_REMOVESWITCHFALLTHROUGH_H_ |