blob: 0538c597a0ce820bf24f4554605403e572aee085 [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_DIRECTIVE_HANDLER_H_
16#define COMPILER_DIRECTIVE_HANDLER_H_
17
Nicolas Capenscc863da2015-01-21 15:50:55 -050018#include "ExtensionBehavior.h"
19#include "Pragma.h"
Alexis Hetue13238e2017-12-15 18:01:07 -050020#include "preprocessor/DirectiveHandlerBase.h"
John Bauman66b8ab22014-05-06 15:57:45 -040021
22class TDiagnostics;
23
24class TDirectiveHandler : public pp::DirectiveHandler
25{
Nicolas Capensc6841852015-02-15 14:25:37 -050026public:
Nicolas Capens0bac2852016-05-07 06:09:58 -040027 TDirectiveHandler(TExtensionBehavior& extBehavior,
28 TDiagnostics& diagnostics,
29 int& shaderVersion);
30 virtual ~TDirectiveHandler();
John Bauman66b8ab22014-05-06 15:57:45 -040031
Nicolas Capens0bac2852016-05-07 06:09:58 -040032 const TPragma& pragma() const { return mPragma; }
33 const TExtensionBehavior& extensionBehavior() const { return mExtensionBehavior; }
John Bauman66b8ab22014-05-06 15:57:45 -040034
Nicolas Capens0bac2852016-05-07 06:09:58 -040035 virtual void handleError(const pp::SourceLocation& loc,
36 const std::string& msg);
John Bauman66b8ab22014-05-06 15:57:45 -040037
Nicolas Capens0bac2852016-05-07 06:09:58 -040038 virtual void handlePragma(const pp::SourceLocation& loc,
39 const std::string& name,
Alexis Hetue13238e2017-12-15 18:01:07 -050040 const std::string& value,
41 bool stdgl);
John Bauman66b8ab22014-05-06 15:57:45 -040042
Nicolas Capens0bac2852016-05-07 06:09:58 -040043 virtual void handleExtension(const pp::SourceLocation& loc,
44 const std::string& name,
45 const std::string& behavior);
John Bauman66b8ab22014-05-06 15:57:45 -040046
Nicolas Capens0bac2852016-05-07 06:09:58 -040047 virtual void handleVersion(const pp::SourceLocation& loc,
48 int version);
John Bauman66b8ab22014-05-06 15:57:45 -040049
Nicolas Capensc6841852015-02-15 14:25:37 -050050private:
Nicolas Capens0bac2852016-05-07 06:09:58 -040051 TPragma mPragma;
52 TExtensionBehavior& mExtensionBehavior;
53 TDiagnostics& mDiagnostics;
54 int& mShaderVersion;
John Bauman66b8ab22014-05-06 15:57:45 -040055};
56
57#endif // COMPILER_DIRECTIVE_HANDLER_H_