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: #include "compiler/TranslatorESSL.h" michael@0: michael@0: #include "compiler/OutputESSL.h" michael@0: michael@0: TranslatorESSL::TranslatorESSL(ShShaderType type, ShShaderSpec spec) michael@0: : TCompiler(type, spec) { michael@0: } michael@0: michael@0: void TranslatorESSL::translate(TIntermNode* root) { michael@0: TInfoSinkBase& sink = getInfoSink().obj; michael@0: michael@0: // Write built-in extension behaviors. michael@0: writeExtensionBehavior(); michael@0: michael@0: // Write emulated built-in functions if needed. michael@0: getBuiltInFunctionEmulator().OutputEmulatedFunctionDefinition( michael@0: sink, getShaderType() == SH_FRAGMENT_SHADER); michael@0: michael@0: // Write array bounds clamping emulation if needed. michael@0: getArrayBoundsClamper().OutputClampingFunctionDefinition(sink); michael@0: michael@0: // Write translated shader. michael@0: TOutputESSL outputESSL(sink, getArrayIndexClampingStrategy(), getHashFunction(), getNameMap(), getSymbolTable()); michael@0: root->traverse(&outputESSL); michael@0: } michael@0: michael@0: void TranslatorESSL::writeExtensionBehavior() { michael@0: TInfoSinkBase& sink = getInfoSink().obj; michael@0: const TExtensionBehavior& extensionBehavior = getExtensionBehavior(); michael@0: for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin(); michael@0: iter != extensionBehavior.end(); ++iter) { michael@0: if (iter->second != EBhUndefined) { michael@0: sink << "#extension " << iter->first << " : " michael@0: << getBehaviorString(iter->second) << "\n"; michael@0: } michael@0: } michael@0: }