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 | #include "compiler/TranslatorESSL.h" |
| 8 | |
| 9 | #include "compiler/OutputESSL.h" |
| 10 | |
| 11 | TranslatorESSL::TranslatorESSL(ShShaderType type, ShShaderSpec spec) |
| 12 | : TCompiler(type, spec) { |
| 13 | } |
| 14 | |
| 15 | void TranslatorESSL::translate(TIntermNode* root) { |
| 16 | TInfoSinkBase& sink = getInfoSink().obj; |
| 17 | |
| 18 | // Write built-in extension behaviors. |
| 19 | writeExtensionBehavior(); |
| 20 | |
zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 21 | // Write translated shader. |
| 22 | TOutputESSL outputESSL(sink); |
| 23 | root->traverse(&outputESSL); |
| 24 | } |
| 25 | |
| 26 | void TranslatorESSL::writeExtensionBehavior() { |
| 27 | TInfoSinkBase& sink = getInfoSink().obj; |
| 28 | const TExtensionBehavior& extensionBehavior = getExtensionBehavior(); |
| 29 | for (TExtensionBehavior::const_iterator iter = extensionBehavior.begin(); |
| 30 | iter != extensionBehavior.end(); ++iter) { |
| 31 | sink << "#extension " << iter->first << " : " |
| 32 | << getBehaviorString(iter->second) << "\n"; |
| 33 | } |
| 34 | } |