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 | |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 19 | #include "compiler/InfoSink.h" |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame^] | 20 | #include "compiler/SymbolTable.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 21 | |
| 22 | class TCompiler; |
alokp@chromium.org | 774d706 | 2010-07-21 18:55:45 +0000 | [diff] [blame] | 23 | class TIntermNode; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 24 | |
| 25 | // |
| 26 | // The base class used to back handles returned to the driver. |
| 27 | // |
| 28 | class TShHandleBase { |
| 29 | public: |
| 30 | TShHandleBase() { } |
| 31 | virtual ~TShHandleBase() { } |
| 32 | virtual TCompiler* getAsCompiler() { return 0; } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | // |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 36 | // The base class for the machine dependent compiler to derive from |
| 37 | // for managing object code from the compile. |
| 38 | // |
| 39 | class TCompiler : public TShHandleBase { |
| 40 | public: |
alokp@chromium.org | 774d706 | 2010-07-21 18:55:45 +0000 | [diff] [blame] | 41 | TCompiler(EShLanguage l, EShSpec s) : language(l), spec(s) { } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 42 | virtual ~TCompiler() { } |
alokp@chromium.org | 613ef31 | 2010-07-21 18:54:22 +0000 | [diff] [blame] | 43 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame^] | 44 | EShLanguage getLanguage() const { return language; } |
| 45 | EShSpec getSpec() const { return spec; } |
| 46 | TSymbolTable& getSymbolTable() { return symbolTable; } |
| 47 | TInfoSink& getInfoSink() { return infoSink; } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 48 | |
| 49 | virtual bool compile(TIntermNode* root) = 0; |
| 50 | |
| 51 | virtual TCompiler* getAsCompiler() { return this; } |
alokp@chromium.org | 76b8208 | 2010-03-24 17:59:39 +0000 | [diff] [blame] | 52 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 53 | protected: |
| 54 | EShLanguage language; |
alokp@chromium.org | 29cd91a | 2010-07-16 19:30:45 +0000 | [diff] [blame] | 55 | EShSpec spec; |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame^] | 56 | |
| 57 | // Built-in symbol table for the given language, spec, and resources. |
| 58 | // It is preserved from compile-to-compile. |
| 59 | TSymbolTable symbolTable; |
| 60 | // Output sink. |
| 61 | TInfoSink infoSink; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | // |
| 65 | // This is the interface between the machine independent code |
| 66 | // and the machine dependent code. |
| 67 | // |
| 68 | // The machine dependent code should derive from the classes |
| 69 | // above. Then Construct*() and Delete*() will create and |
| 70 | // destroy the machine dependent objects, which contain the |
| 71 | // above machine independent information. |
| 72 | // |
alokp@chromium.org | 29cd91a | 2010-07-16 19:30:45 +0000 | [diff] [blame] | 73 | TCompiler* ConstructCompiler(EShLanguage, EShSpec); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 74 | void DeleteCompiler(TCompiler*); |
| 75 | |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 76 | #endif // _SHHANDLE_INCLUDED_ |