1 //
2 // Copyright 2012 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_DIRECTIVEHANDLER_H_
8 #define COMPILER_TRANSLATOR_DIRECTIVEHANDLER_H_
9 
10 #include "GLSLANG/ShaderLang.h"
11 #include "common/angleutils.h"
12 #include "compiler/preprocessor/DirectiveHandlerBase.h"
13 #include "compiler/translator/ExtensionBehavior.h"
14 #include "compiler/translator/Pragma.h"
15 
16 namespace sh
17 {
18 class TDiagnostics;
19 
20 class TDirectiveHandler : public angle::pp::DirectiveHandler, angle::NonCopyable
21 {
22   public:
23     TDirectiveHandler(TExtensionBehavior &extBehavior,
24                       TDiagnostics &diagnostics,
25                       int &shaderVersion,
26                       sh::GLenum shaderType,
27                       bool debugShaderPrecisionSupported);
28     ~TDirectiveHandler() override;
29 
pragma()30     const TPragma &pragma() const { return mPragma; }
extensionBehavior()31     const TExtensionBehavior &extensionBehavior() const { return mExtensionBehavior; }
32 
33     void handleError(const angle::pp::SourceLocation &loc, const std::string &msg) override;
34 
35     void handlePragma(const angle::pp::SourceLocation &loc,
36                       const std::string &name,
37                       const std::string &value,
38                       bool stdgl) override;
39 
40     void handleExtension(const angle::pp::SourceLocation &loc,
41                          const std::string &name,
42                          const std::string &behavior) override;
43 
44     void handleVersion(const angle::pp::SourceLocation &loc,
45                        int version,
46                        ShShaderSpec spec) override;
47 
48   private:
49     TPragma mPragma;
50     TExtensionBehavior &mExtensionBehavior;
51     TDiagnostics &mDiagnostics;
52     int &mShaderVersion;
53     sh::GLenum mShaderType;
54     bool mDebugShaderPrecisionSupported;
55 };
56 
57 }  // namespace sh
58 
59 #endif  // COMPILER_TRANSLATOR_DIRECTIVEHANDLER_H_
60