blob: 5ef5d30cf8b40f13f81aeb86f14b87f593e2e7d4 [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
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000019#include "compiler/InfoSink.h"
alokp@chromium.orge4249f02010-07-26 18:13:52 +000020#include "compiler/SymbolTable.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000021
22class TCompiler;
alokp@chromium.org774d7062010-07-21 18:55:45 +000023class TIntermNode;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000024
25//
26// The base class used to back handles returned to the driver.
27//
28class TShHandleBase {
29public:
30 TShHandleBase() { }
31 virtual ~TShHandleBase() { }
32 virtual TCompiler* getAsCompiler() { return 0; }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000033};
34
35//
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000036// The base class for the machine dependent compiler to derive from
37// for managing object code from the compile.
38//
39class TCompiler : public TShHandleBase {
40public:
alokp@chromium.org774d7062010-07-21 18:55:45 +000041 TCompiler(EShLanguage l, EShSpec s) : language(l), spec(s) { }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000042 virtual ~TCompiler() { }
alokp@chromium.org613ef312010-07-21 18:54:22 +000043
alokp@chromium.orge4249f02010-07-26 18:13:52 +000044 EShLanguage getLanguage() const { return language; }
45 EShSpec getSpec() const { return spec; }
46 TSymbolTable& getSymbolTable() { return symbolTable; }
47 TInfoSink& getInfoSink() { return infoSink; }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000048
49 virtual bool compile(TIntermNode* root) = 0;
50
51 virtual TCompiler* getAsCompiler() { return this; }
alokp@chromium.org76b82082010-03-24 17:59:39 +000052
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000053protected:
54 EShLanguage language;
alokp@chromium.org29cd91a2010-07-16 19:30:45 +000055 EShSpec spec;
alokp@chromium.orge4249f02010-07-26 18:13:52 +000056
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.com4f39fd92010-03-08 20:26:45 +000062};
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.org29cd91a2010-07-16 19:30:45 +000073TCompiler* ConstructCompiler(EShLanguage, EShSpec);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000074void DeleteCompiler(TCompiler*);
75
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000076#endif // _SHHANDLE_INCLUDED_