zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 1 | // |
| 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. |
| 5 | // |
| 6 | |
| 7 | #ifndef CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_ |
| 8 | #define CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_ |
| 9 | |
| 10 | #include <set> |
| 11 | |
| 12 | #include "compiler/ForLoopUnroll.h" |
| 13 | #include "compiler/intermediate.h" |
| 14 | #include "compiler/ParseHelper.h" |
| 15 | |
| 16 | class TOutputGLSLBase : public TIntermTraverser |
| 17 | { |
| 18 | public: |
| 19 | TOutputGLSLBase(TInfoSinkBase& objSink); |
| 20 | |
| 21 | protected: |
| 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); |
| 28 | |
| 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); |
| 37 | |
| 38 | void visitCodeBlock(TIntermNode* node); |
| 39 | |
| 40 | private: |
| 41 | TInfoSinkBase& mObjSink; |
| 42 | bool mDeclaringVariables; |
| 43 | |
| 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; |
| 49 | |
| 50 | ForLoopUnroll mLoopUnroll; |
| 51 | }; |
| 52 | |
| 53 | #endif // CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_ |