• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef COMPILER_DIRECTIVE_HANDLER_H_
16 #define COMPILER_DIRECTIVE_HANDLER_H_
17 
18 #include "ExtensionBehavior.h"
19 #include "Pragma.h"
20 #include "preprocessor/DirectiveHandler.h"
21 
22 class TDiagnostics;
23 
24 class TDirectiveHandler : public pp::DirectiveHandler
25 {
26 public:
27 	TDirectiveHandler(TExtensionBehavior& extBehavior,
28 	                  TDiagnostics& diagnostics,
29 	                  int& shaderVersion);
30 	virtual ~TDirectiveHandler();
31 
pragma()32 	const TPragma& pragma() const { return mPragma; }
extensionBehavior()33 	const TExtensionBehavior& extensionBehavior() const { return mExtensionBehavior; }
34 
35 	virtual void handleError(const pp::SourceLocation& loc,
36 	                         const std::string& msg);
37 
38 	virtual void handlePragma(const pp::SourceLocation& loc,
39 	                          const std::string& name,
40 	                          const std::string& value);
41 
42 	virtual void handleExtension(const pp::SourceLocation& loc,
43 	                             const std::string& name,
44 	                             const std::string& behavior);
45 
46 	virtual void handleVersion(const pp::SourceLocation& loc,
47 	                           int version);
48 
49 private:
50 	TPragma mPragma;
51 	TExtensionBehavior& mExtensionBehavior;
52 	TDiagnostics& mDiagnostics;
53 	int& mShaderVersion;
54 };
55 
56 #endif  // COMPILER_DIRECTIVE_HANDLER_H_
57