blob: bb201a48c97c7398724d05ce7867b4fb72766d6b [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) {
31 sink << "#extension " << iter->first << " : "
32 << getBehaviorString(iter->second) << "\n";
33 }
34}