daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | #ifndef _SHHANDLE_INCLUDED_ |
| 8 | #define _SHHANDLE_INCLUDED_ |
| 9 | |
| 10 | // |
| 11 | // Machine independent part of the compiler private objects |
| 12 | // sent as ShHandle to the driver. |
| 13 | // |
| 14 | // This should not be included by driver code. |
| 15 | // |
| 16 | |
alokp@chromium.org | ea0e1af | 2010-03-22 19:33:14 +0000 | [diff] [blame] | 17 | #include "GLSLANG/ShaderLang.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 18 | |
alokp@chromium.org | ad771eb | 2010-09-07 17:36:23 +0000 | [diff] [blame^] | 19 | #include "compiler/ExtensionBehavior.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 20 | #include "compiler/InfoSink.h" |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 21 | #include "compiler/SymbolTable.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 22 | |
| 23 | class TCompiler; |
alokp@chromium.org | 774d706 | 2010-07-21 18:55:45 +0000 | [diff] [blame] | 24 | class TIntermNode; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 25 | |
| 26 | // |
| 27 | // The base class used to back handles returned to the driver. |
| 28 | // |
| 29 | class TShHandleBase { |
| 30 | public: |
| 31 | TShHandleBase() { } |
| 32 | virtual ~TShHandleBase() { } |
| 33 | virtual TCompiler* getAsCompiler() { return 0; } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | // |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 37 | // The base class for the machine dependent compiler to derive from |
| 38 | // for managing object code from the compile. |
| 39 | // |
| 40 | class TCompiler : public TShHandleBase { |
| 41 | public: |
alokp@chromium.org | 774d706 | 2010-07-21 18:55:45 +0000 | [diff] [blame] | 42 | TCompiler(EShLanguage l, EShSpec s) : language(l), spec(s) { } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 43 | virtual ~TCompiler() { } |
alokp@chromium.org | 613ef31 | 2010-07-21 18:54:22 +0000 | [diff] [blame] | 44 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 45 | EShLanguage getLanguage() const { return language; } |
| 46 | EShSpec getSpec() const { return spec; } |
| 47 | TSymbolTable& getSymbolTable() { return symbolTable; } |
alokp@chromium.org | ad771eb | 2010-09-07 17:36:23 +0000 | [diff] [blame^] | 48 | TExtensionBehavior& getExtensionBehavior() { return extensionBehavior; } |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 49 | TInfoSink& getInfoSink() { return infoSink; } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 50 | |
| 51 | virtual bool compile(TIntermNode* root) = 0; |
| 52 | |
| 53 | virtual TCompiler* getAsCompiler() { return this; } |
alokp@chromium.org | 76b8208 | 2010-03-24 17:59:39 +0000 | [diff] [blame] | 54 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 55 | protected: |
| 56 | EShLanguage language; |
alokp@chromium.org | 29cd91a | 2010-07-16 19:30:45 +0000 | [diff] [blame] | 57 | EShSpec spec; |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 58 | |
| 59 | // Built-in symbol table for the given language, spec, and resources. |
| 60 | // It is preserved from compile-to-compile. |
| 61 | TSymbolTable symbolTable; |
alokp@chromium.org | ad771eb | 2010-09-07 17:36:23 +0000 | [diff] [blame^] | 62 | // Built-in extensions with default behavior. |
| 63 | TExtensionBehavior extensionBehavior; |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 64 | // Output sink. |
| 65 | TInfoSink infoSink; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | // |
| 69 | // This is the interface between the machine independent code |
| 70 | // and the machine dependent code. |
| 71 | // |
| 72 | // The machine dependent code should derive from the classes |
| 73 | // above. Then Construct*() and Delete*() will create and |
| 74 | // destroy the machine dependent objects, which contain the |
| 75 | // above machine independent information. |
| 76 | // |
alokp@chromium.org | 29cd91a | 2010-07-16 19:30:45 +0000 | [diff] [blame] | 77 | TCompiler* ConstructCompiler(EShLanguage, EShSpec); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 78 | void DeleteCompiler(TCompiler*); |
| 79 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 80 | #endif // _SHHANDLE_INCLUDED_ |