blob: b18f90c0350038d61611bc15bf776fc3d6431237 [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
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.orgea0e1af2010-03-22 19:33:14 +000017#include "GLSLANG/ShaderLang.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000018
alokp@chromium.orgad771eb2010-09-07 17:36:23 +000019#include "compiler/ExtensionBehavior.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000020#include "compiler/InfoSink.h"
alokp@chromium.orge4249f02010-07-26 18:13:52 +000021#include "compiler/SymbolTable.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000022
23class TCompiler;
alokp@chromium.org774d7062010-07-21 18:55:45 +000024class TIntermNode;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000025
26//
27// The base class used to back handles returned to the driver.
28//
29class TShHandleBase {
30public:
31 TShHandleBase() { }
32 virtual ~TShHandleBase() { }
33 virtual TCompiler* getAsCompiler() { return 0; }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000034};
35
36//
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000037// The base class for the machine dependent compiler to derive from
38// for managing object code from the compile.
39//
40class TCompiler : public TShHandleBase {
41public:
alokp@chromium.org774d7062010-07-21 18:55:45 +000042 TCompiler(EShLanguage l, EShSpec s) : language(l), spec(s) { }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000043 virtual ~TCompiler() { }
alokp@chromium.org613ef312010-07-21 18:54:22 +000044
alokp@chromium.orge4249f02010-07-26 18:13:52 +000045 EShLanguage getLanguage() const { return language; }
46 EShSpec getSpec() const { return spec; }
47 TSymbolTable& getSymbolTable() { return symbolTable; }
alokp@chromium.orgad771eb2010-09-07 17:36:23 +000048 TExtensionBehavior& getExtensionBehavior() { return extensionBehavior; }
alokp@chromium.orge4249f02010-07-26 18:13:52 +000049 TInfoSink& getInfoSink() { return infoSink; }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000050
51 virtual bool compile(TIntermNode* root) = 0;
52
53 virtual TCompiler* getAsCompiler() { return this; }
alokp@chromium.org76b82082010-03-24 17:59:39 +000054
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000055protected:
56 EShLanguage language;
alokp@chromium.org29cd91a2010-07-16 19:30:45 +000057 EShSpec spec;
alokp@chromium.orge4249f02010-07-26 18:13:52 +000058
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.orgad771eb2010-09-07 17:36:23 +000062 // Built-in extensions with default behavior.
63 TExtensionBehavior extensionBehavior;
alokp@chromium.orge4249f02010-07-26 18:13:52 +000064 // Output sink.
65 TInfoSink infoSink;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000066};
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.org29cd91a2010-07-16 19:30:45 +000077TCompiler* ConstructCompiler(EShLanguage, EShSpec);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000078void DeleteCompiler(TCompiler*);
79
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000080#endif // _SHHANDLE_INCLUDED_