Line data Source code
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 : namespace sh
13 : {
14 :
15 0 : class RemoveSwitchFallThrough : public TIntermTraverser
16 : {
17 : public:
18 : // When given a statementList from a switch AST node, return an updated
19 : // statementList that has fall-through removed.
20 : static TIntermBlock *removeFallThrough(TIntermBlock *statementList);
21 :
22 : private:
23 : RemoveSwitchFallThrough(TIntermBlock *statementList);
24 :
25 : void visitSymbol(TIntermSymbol *node) override;
26 : void visitConstantUnion(TIntermConstantUnion *node) override;
27 : bool visitBinary(Visit, TIntermBinary *node) override;
28 : bool visitUnary(Visit, TIntermUnary *node) override;
29 : bool visitTernary(Visit visit, TIntermTernary *node) override;
30 : bool visitIfElse(Visit visit, TIntermIfElse *node) override;
31 : bool visitSwitch(Visit, TIntermSwitch *node) override;
32 : bool visitCase(Visit, TIntermCase *node) override;
33 : bool visitAggregate(Visit, TIntermAggregate *node) override;
34 : bool visitBlock(Visit, TIntermBlock *node) override;
35 : bool visitLoop(Visit, TIntermLoop *node) override;
36 : bool visitBranch(Visit, TIntermBranch *node) override;
37 :
38 : void outputSequence(TIntermSequence *sequence, size_t startIndex);
39 : void handlePreviousCase();
40 :
41 : TIntermBlock *mStatementList;
42 : TIntermBlock *mStatementListOut;
43 : bool mLastStatementWasBreak;
44 : TIntermBlock *mPreviousCase;
45 : std::vector<TIntermBlock *> mCasesSharingBreak;
46 : };
47 :
48 : } // namespace sh
49 :
50 : #endif // COMPILER_TRANSLATOR_REMOVESWITCHFALLTHROUGH_H_
|