blob: 8b9aee2171e149c1223b6a8e015b3c31b2dd4d05 [file] [log] [blame]
alokp@chromium.org76b82082010-03-24 17:59:39 +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 CROSSCOMPILERGLSL_OUTPUTGLSL_H_
8#define CROSSCOMPILERGLSL_OUTPUTGLSL_H_
9
alokp@chromium.org4e89d232010-05-14 19:37:21 +000010#include <set>
11
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000012#include "compiler/intermediate.h"
13#include "compiler/ParseHelper.h"
alokp@chromium.org76b82082010-03-24 17:59:39 +000014
15class TOutputGLSL : public TIntermTraverser
16{
17public:
alokp@chromium.orga499cfc2010-05-03 23:14:49 +000018 TOutputGLSL(TInfoSinkBase& objSink);
alokp@chromium.org76b82082010-03-24 17:59:39 +000019
20protected:
alokp@chromium.orga499cfc2010-05-03 23:14:49 +000021 TInfoSinkBase& objSink() { return mObjSink; }
alokp@chromium.org76b82082010-03-24 17:59:39 +000022 void writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr);
alokp@chromium.org194522f2010-05-06 19:09:26 +000023 void writeVariableType(const TType& type);
24 void writeFunctionParameters(const TIntermSequence& args);
alokp@chromium.orgb3f7fb62010-05-05 18:21:51 +000025 const ConstantUnion* writeConstantUnion(const TType& type, const ConstantUnion* pConstUnion);
alokp@chromium.org76b82082010-03-24 17:59:39 +000026
27 virtual void visitSymbol(TIntermSymbol* node);
28 virtual void visitConstantUnion(TIntermConstantUnion* node);
29 virtual bool visitBinary(Visit visit, TIntermBinary* node);
30 virtual bool visitUnary(Visit visit, TIntermUnary* node);
31 virtual bool visitSelection(Visit visit, TIntermSelection* node);
32 virtual bool visitAggregate(Visit visit, TIntermAggregate* node);
33 virtual bool visitLoop(Visit visit, TIntermLoop* node);
34 virtual bool visitBranch(Visit visit, TIntermBranch* node);
35
36private:
alokp@chromium.orga499cfc2010-05-03 23:14:49 +000037 TInfoSinkBase& mObjSink;
alokp@chromium.orgb3f7fb62010-05-05 18:21:51 +000038 bool mScopeSequences;
alokp@chromium.org194522f2010-05-06 19:09:26 +000039 bool mDeclaringVariables;
alokp@chromium.orga499cfc2010-05-03 23:14:49 +000040
41 // Structs are declared as the tree is traversed. This set contains all
42 // the structs already declared. It is maintained so that a struct is
43 // declared only once.
44 typedef std::set<TString> DeclaredStructs;
45 DeclaredStructs mDeclaredStructs;
alokp@chromium.org76b82082010-03-24 17:59:39 +000046};
47
48#endif // CROSSCOMPILERGLSL_OUTPUTGLSL_H_