blob: 35983ac450dab2da464190a412c21dfbc130c3fa [file] [log] [blame]
Nicolas Capens0bac2852016-05-07 06:09:58 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
John Bauman66b8ab22014-05-06 15:57:45 -04002//
Nicolas Capens0bac2852016-05-07 06:09:58 -04003// 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 Bauman66b8ab22014-05-06 15:57:45 -04006//
Nicolas Capens0bac2852016-05-07 06:09:58 -04007// 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 Bauman66b8ab22014-05-06 15:57:45 -040014
15#ifndef COMPILER_DIAGNOSTICS_H_
16#define COMPILER_DIAGNOSTICS_H_
17
Nicolas Capenscc863da2015-01-21 15:50:55 -050018#include "preprocessor/Diagnostics.h"
John Bauman66b8ab22014-05-06 15:57:45 -040019
20class TInfoSink;
21
22class TDiagnostics : public pp::Diagnostics
23{
Nicolas Capens0bac2852016-05-07 06:09:58 -040024public:
25 TDiagnostics(TInfoSink& infoSink);
26 virtual ~TDiagnostics();
John Bauman66b8ab22014-05-06 15:57:45 -040027
Nicolas Capens0bac2852016-05-07 06:09:58 -040028 int shaderVersion() const { return mShaderVersion; }
29 TInfoSink& infoSink() { return mInfoSink; }
John Bauman66b8ab22014-05-06 15:57:45 -040030
Nicolas Capens0bac2852016-05-07 06:09:58 -040031 int numErrors() const { return mNumErrors; }
32 int numWarnings() const { return mNumWarnings; }
John Bauman66b8ab22014-05-06 15:57:45 -040033
Nicolas Capens0bac2852016-05-07 06:09:58 -040034 void setShaderVersion(int version);
Nicolas Capensb28964b2015-02-10 15:23:06 -050035
Nicolas Capens0bac2852016-05-07 06:09:58 -040036 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 Bauman66b8ab22014-05-06 15:57:45 -040041
Nicolas Capens0bac2852016-05-07 06:09:58 -040042 void writeDebug(const std::string& str);
John Bauman66b8ab22014-05-06 15:57:45 -040043
Nicolas Capens0bac2852016-05-07 06:09:58 -040044protected:
45 virtual void print(ID id,
46 const pp::SourceLocation& loc,
47 const std::string& text);
John Bauman66b8ab22014-05-06 15:57:45 -040048
Nicolas Capens0bac2852016-05-07 06:09:58 -040049private:
50 int mShaderVersion;
Nicolas Capensb28964b2015-02-10 15:23:06 -050051
Nicolas Capens0bac2852016-05-07 06:09:58 -040052 TInfoSink& mInfoSink;
53 int mNumErrors;
54 int mNumWarnings;
John Bauman66b8ab22014-05-06 15:57:45 -040055};
56
57#endif // COMPILER_DIAGNOSTICS_H_