• 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_DIAGNOSTICS_H_
16 #define COMPILER_DIAGNOSTICS_H_
17 
18 #include "preprocessor/Diagnostics.h"
19 
20 class TInfoSink;
21 
22 class TDiagnostics : public pp::Diagnostics
23 {
24 public:
25 	TDiagnostics(TInfoSink& infoSink);
26 	virtual ~TDiagnostics();
27 
shaderVersion()28 	int shaderVersion() const { return mShaderVersion; }
infoSink()29 	TInfoSink& infoSink() { return mInfoSink; }
30 
numErrors()31 	int numErrors() const { return mNumErrors; }
numWarnings()32 	int numWarnings() const { return mNumWarnings; }
33 
34 	void setShaderVersion(int version);
35 
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);
41 
42 	void writeDebug(const std::string& str);
43 
44 protected:
45 	virtual void print(ID id,
46 					   const pp::SourceLocation& loc,
47 					   const std::string& text);
48 
49 private:
50 	int mShaderVersion;
51 
52 	TInfoSink& mInfoSink;
53 	int mNumErrors;
54 	int mNumWarnings;
55 };
56 
57 #endif  // COMPILER_DIAGNOSTICS_H_
58