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_VALIDATESWITCH_H_
8 : #define COMPILER_TRANSLATOR_VALIDATESWITCH_H_
9 :
10 : #include "compiler/translator/IntermNode.h"
11 :
12 : namespace sh
13 : {
14 : class TParseContext;
15 :
16 0 : class ValidateSwitch : public TIntermTraverser
17 : {
18 : public:
19 : // Check for errors and output messages any remaining errors on the context.
20 : // Returns true if there are no errors.
21 : static bool validate(TBasicType switchType,
22 : TParseContext *context,
23 : TIntermBlock *statementList,
24 : const TSourceLoc &loc);
25 :
26 : void visitSymbol(TIntermSymbol *) override;
27 : void visitConstantUnion(TIntermConstantUnion *) override;
28 : bool visitBinary(Visit, TIntermBinary *) override;
29 : bool visitUnary(Visit, TIntermUnary *) override;
30 : bool visitTernary(Visit, TIntermTernary *) override;
31 : bool visitIfElse(Visit visit, TIntermIfElse *) override;
32 : bool visitSwitch(Visit, TIntermSwitch *) override;
33 : bool visitCase(Visit, TIntermCase *node) override;
34 : bool visitAggregate(Visit, TIntermAggregate *) override;
35 : bool visitLoop(Visit visit, TIntermLoop *) override;
36 : bool visitBranch(Visit, TIntermBranch *) override;
37 :
38 : private:
39 : ValidateSwitch(TBasicType switchType, TParseContext *context);
40 :
41 : bool validateInternal(const TSourceLoc &loc);
42 :
43 : TBasicType mSwitchType;
44 : TParseContext *mContext;
45 : bool mCaseTypeMismatch;
46 : bool mFirstCaseFound;
47 : bool mStatementBeforeCase;
48 : bool mLastStatementWasCase;
49 : int mControlFlowDepth;
50 : bool mCaseInsideControlFlow;
51 : int mDefaultCount;
52 : std::set<int> mCasesSigned;
53 : std::set<unsigned int> mCasesUnsigned;
54 : bool mDuplicateCases;
55 : };
56 :
57 : } // namespace sh
58 :
59 : #endif // COMPILER_TRANSLATOR_VALIDATESWITCH_H_
|