2 // Copyright (c) 2002-2011 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.
7 #ifndef CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_
8 #define CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_
12 #include "compiler/ForLoopUnroll.h"
13 #include "compiler/intermediate.h"
14 #include "compiler/ParseHelper.h"
16 class TOutputGLSLBase : public TIntermTraverser
19 TOutputGLSLBase(TInfoSinkBase& objSink);
22 TInfoSinkBase& objSink() { return mObjSink; }
23 void writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr);
24 void writeVariableType(const TType& type);
25 virtual bool writeVariablePrecision(TPrecision precision) = 0;
26 void writeFunctionParameters(const TIntermSequence& args);
27 const ConstantUnion* writeConstantUnion(const TType& type, const ConstantUnion* pConstUnion);
29 virtual void visitSymbol(TIntermSymbol* node);
30 virtual void visitConstantUnion(TIntermConstantUnion* node);
31 virtual bool visitBinary(Visit visit, TIntermBinary* node);
32 virtual bool visitUnary(Visit visit, TIntermUnary* node);
33 virtual bool visitSelection(Visit visit, TIntermSelection* node);
34 virtual bool visitAggregate(Visit visit, TIntermAggregate* node);
35 virtual bool visitLoop(Visit visit, TIntermLoop* node);
36 virtual bool visitBranch(Visit visit, TIntermBranch* node);
38 void visitCodeBlock(TIntermNode* node);
41 TInfoSinkBase& mObjSink;
42 bool mDeclaringVariables;
44 // Structs are declared as the tree is traversed. This set contains all
45 // the structs already declared. It is maintained so that a struct is
46 // declared only once.
47 typedef std::set<TString> DeclaredStructs;
48 DeclaredStructs mDeclaredStructs;
50 ForLoopUnroll mLoopUnroll;
53 #endif // CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_