Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 1 | // Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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 |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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. |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 14 | |
| 15 | #ifndef COMPILER_DIRECTIVE_HANDLER_H_ |
| 16 | #define COMPILER_DIRECTIVE_HANDLER_H_ |
| 17 | |
Nicolas Capens | cc863da | 2015-01-21 15:50:55 -0500 | [diff] [blame] | 18 | #include "ExtensionBehavior.h" |
| 19 | #include "Pragma.h" |
Alexis Hetu | e13238e | 2017-12-15 18:01:07 -0500 | [diff] [blame] | 20 | #include "preprocessor/DirectiveHandlerBase.h" |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 21 | |
| 22 | class TDiagnostics; |
| 23 | |
| 24 | class TDirectiveHandler : public pp::DirectiveHandler |
| 25 | { |
Nicolas Capens | c684185 | 2015-02-15 14:25:37 -0500 | [diff] [blame] | 26 | public: |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 27 | TDirectiveHandler(TExtensionBehavior& extBehavior, |
| 28 | TDiagnostics& diagnostics, |
| 29 | int& shaderVersion); |
| 30 | virtual ~TDirectiveHandler(); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 31 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 32 | const TPragma& pragma() const { return mPragma; } |
| 33 | const TExtensionBehavior& extensionBehavior() const { return mExtensionBehavior; } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 34 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 35 | virtual void handleError(const pp::SourceLocation& loc, |
| 36 | const std::string& msg); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 37 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 38 | virtual void handlePragma(const pp::SourceLocation& loc, |
| 39 | const std::string& name, |
Alexis Hetu | e13238e | 2017-12-15 18:01:07 -0500 | [diff] [blame] | 40 | const std::string& value, |
| 41 | bool stdgl); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 42 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 43 | virtual void handleExtension(const pp::SourceLocation& loc, |
| 44 | const std::string& name, |
| 45 | const std::string& behavior); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 46 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 47 | virtual void handleVersion(const pp::SourceLocation& loc, |
| 48 | int version); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 49 | |
Nicolas Capens | c684185 | 2015-02-15 14:25:37 -0500 | [diff] [blame] | 50 | private: |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 51 | TPragma mPragma; |
| 52 | TExtensionBehavior& mExtensionBehavior; |
| 53 | TDiagnostics& mDiagnostics; |
| 54 | int& mShaderVersion; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | #endif // COMPILER_DIRECTIVE_HANDLER_H_ |