blob: 794236b3a40d797f72072c2f13cf041cb37c095a [file] [log] [blame]
zmo@google.com5601ea02011-06-10 18:23:25 +00001//
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
11TranslatorESSL::TranslatorESSL(ShShaderType type, ShShaderSpec spec)
12 : TCompiler(type, spec) {
13}
14
15void TranslatorESSL::translate(TIntermNode* root) {
16 TInfoSinkBase& sink = getInfoSink().obj;
17
18 // Write built-in extension behaviors.
19 writeExtensionBehavior();
20
zmo@google.com5601ea02011-06-10 18:23:25 +000021 // Write translated shader.
22 TOutputESSL outputESSL(sink);
23 root->traverse(&outputESSL);
24}
25
26void 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) {
zmo@google.com09c323a2011-08-12 18:22:25 +000031 if (iter->second != EBhUndefined) {
32 sink << "#extension " << iter->first << " : "
33 << getBehaviorString(iter->second) << "\n";
34 }
zmo@google.com5601ea02011-06-10 18:23:25 +000035 }
36}