• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 CROSSCOMPILERGLSL_OUTPUTGLSL_H_
8 #define CROSSCOMPILERGLSL_OUTPUTGLSL_H_
9 
10 #include <set>
11 
12 #include "compiler/intermediate.h"
13 #include "compiler/ParseHelper.h"
14 
15 class TOutputGLSL : public TIntermTraverser
16 {
17 public:
18     TOutputGLSL(TInfoSinkBase& objSink);
19 
20 protected:
objSink()21     TInfoSinkBase& objSink() { return mObjSink; }
22     void writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr);
23     void writeVariableType(const TType& type);
24     void writeFunctionParameters(const TIntermSequence& args);
25     const ConstantUnion* writeConstantUnion(const TType& type, const ConstantUnion* pConstUnion);
26 
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 
36     void visitCodeBlock(TIntermNode* node);
37 
38 private:
39     TInfoSinkBase& mObjSink;
40     bool mDeclaringVariables;
41 
42     // Structs are declared as the tree is traversed. This set contains all
43     // the structs already declared. It is maintained so that a struct is
44     // declared only once.
45     typedef std::set<TString> DeclaredStructs;
46     DeclaredStructs mDeclaredStructs;
47 };
48 
49 #endif  // CROSSCOMPILERGLSL_OUTPUTGLSL_H_
50