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_DIAGNOSTICS_H_ |
| 16 | #define COMPILER_DIAGNOSTICS_H_ |
| 17 | |
Nicolas Capens | cc863da | 2015-01-21 15:50:55 -0500 | [diff] [blame] | 18 | #include "preprocessor/Diagnostics.h" |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 19 | |
| 20 | class TInfoSink; |
| 21 | |
| 22 | class TDiagnostics : public pp::Diagnostics |
| 23 | { |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 24 | public: |
| 25 | TDiagnostics(TInfoSink& infoSink); |
| 26 | virtual ~TDiagnostics(); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 27 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 28 | int shaderVersion() const { return mShaderVersion; } |
| 29 | TInfoSink& infoSink() { return mInfoSink; } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 30 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 31 | int numErrors() const { return mNumErrors; } |
| 32 | int numWarnings() const { return mNumWarnings; } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 33 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 34 | void setShaderVersion(int version); |
Nicolas Capens | b28964b | 2015-02-10 15:23:06 -0500 | [diff] [blame] | 35 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 36 | void writeInfo(Severity severity, |
| 37 | const pp::SourceLocation& loc, |
| 38 | const std::string& reason, |
| 39 | const std::string& token, |
| 40 | const std::string& extra); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 41 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 42 | void writeDebug(const std::string& str); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 43 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 44 | protected: |
| 45 | virtual void print(ID id, |
| 46 | const pp::SourceLocation& loc, |
| 47 | const std::string& text); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 48 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 49 | private: |
| 50 | int mShaderVersion; |
Nicolas Capens | b28964b | 2015-02-10 15:23:06 -0500 | [diff] [blame] | 51 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 52 | TInfoSink& mInfoSink; |
| 53 | int mNumErrors; |
| 54 | int mNumWarnings; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | #endif // COMPILER_DIAGNOSTICS_H_ |