michael@0: // michael@0: // Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: // michael@0: michael@0: #ifndef CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_ michael@0: #define CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_ michael@0: michael@0: #include michael@0: michael@0: #include "compiler/ForLoopUnroll.h" michael@0: #include "compiler/intermediate.h" michael@0: #include "compiler/ParseHelper.h" michael@0: michael@0: class TOutputGLSLBase : public TIntermTraverser michael@0: { michael@0: public: michael@0: TOutputGLSLBase(TInfoSinkBase& objSink, michael@0: ShArrayIndexClampingStrategy clampingStrategy, michael@0: ShHashFunction64 hashFunction, michael@0: NameMap& nameMap, michael@0: TSymbolTable& symbolTable); michael@0: michael@0: protected: michael@0: TInfoSinkBase& objSink() { return mObjSink; } michael@0: void writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr); michael@0: void writeVariableType(const TType& type); michael@0: virtual bool writeVariablePrecision(TPrecision precision) = 0; michael@0: void writeFunctionParameters(const TIntermSequence& args); michael@0: const ConstantUnion* writeConstantUnion(const TType& type, const ConstantUnion* pConstUnion); michael@0: TString getTypeName(const TType& type); michael@0: michael@0: virtual void visitSymbol(TIntermSymbol* node); michael@0: virtual void visitConstantUnion(TIntermConstantUnion* node); michael@0: virtual bool visitBinary(Visit visit, TIntermBinary* node); michael@0: virtual bool visitUnary(Visit visit, TIntermUnary* node); michael@0: virtual bool visitSelection(Visit visit, TIntermSelection* node); michael@0: virtual bool visitAggregate(Visit visit, TIntermAggregate* node); michael@0: virtual bool visitLoop(Visit visit, TIntermLoop* node); michael@0: virtual bool visitBranch(Visit visit, TIntermBranch* node); michael@0: michael@0: void visitCodeBlock(TIntermNode* node); michael@0: michael@0: michael@0: // Return the original name if hash function pointer is NULL; michael@0: // otherwise return the hashed name. michael@0: TString hashName(const TString& name); michael@0: // Same as hashName(), but without hashing built-in variables. michael@0: TString hashVariableName(const TString& name); michael@0: // Same as hashName(), but without hashing built-in functions. michael@0: TString hashFunctionName(const TString& mangled_name); michael@0: michael@0: private: michael@0: bool structDeclared(const TStructure* structure) const; michael@0: void declareStruct(const TStructure* structure); michael@0: michael@0: TInfoSinkBase& mObjSink; michael@0: bool mDeclaringVariables; michael@0: michael@0: // Structs are declared as the tree is traversed. This set contains all michael@0: // the structs already declared. It is maintained so that a struct is michael@0: // declared only once. michael@0: typedef std::set DeclaredStructs; michael@0: DeclaredStructs mDeclaredStructs; michael@0: michael@0: ForLoopUnroll mLoopUnroll; michael@0: michael@0: ShArrayIndexClampingStrategy mClampingStrategy; michael@0: michael@0: // name hashing. michael@0: ShHashFunction64 mHashFunction; michael@0: michael@0: NameMap& mNameMap; michael@0: michael@0: TSymbolTable& mSymbolTable; michael@0: }; michael@0: michael@0: #endif // CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_