• 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/DirectiveHandlerBase.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 	                          bool stdgl);
42 
43 	virtual void handleExtension(const pp::SourceLocation& loc,
44 	                             const std::string& name,
45 	                             const std::string& behavior);
46 
47 	virtual void handleVersion(const pp::SourceLocation& loc,
48 	                           int version);
49 
50 private:
51 	TPragma mPragma;
52 	TExtensionBehavior& mExtensionBehavior;
53 	TDiagnostics& mDiagnostics;
54 	int& mShaderVersion;
55 };
56 
57 #endif  // COMPILER_DIRECTIVE_HANDLER_H_
58