blob: 2a141ec91cfd2f01812b9e0354baf5542be7e97d [file] [log] [blame]
Zhenyao Mo4a667fe2014-02-11 12:35:01 -08001//
2// Copyright (c) 2002-2013 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
Geoff Lang0a73dd82014-11-19 16:18:08 -05007#ifndef COMPILER_TRANSLATOR_INITIALIZEVARIABLES_H_
8#define COMPILER_TRANSLATOR_INITIALIZEVARIABLES_H_
Zhenyao Mo4a667fe2014-02-11 12:35:01 -08009
Jamie Madillb1a85f42014-08-19 15:23:24 -040010#include "compiler/translator/IntermNode.h"
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080011
12class InitializeVariables : public TIntermTraverser
13{
14 public:
15 struct InitVariableInfo
16 {
17 TString name;
18 TType type;
19
Zhenyao Moe40d1e92014-07-16 17:40:36 -070020 InitVariableInfo(const TString &_name, const TType &_type)
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080021 : name(_name),
22 type(_type)
23 {
24 }
25 };
26 typedef TVector<InitVariableInfo> InitVariableInfoList;
27
Zhenyao Moe40d1e92014-07-16 17:40:36 -070028 InitializeVariables(const InitVariableInfoList &vars)
Olli Etuaho3d0d9a42015-06-01 12:16:36 +030029 : TIntermTraverser(true, false, false),
30 mVariables(vars),
Corentin Wallezbc99bb62015-05-14 17:42:20 -040031 mCodeInserted(false)
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080032 {
33 }
34
35 protected:
Corentin Walleze5a1f272015-08-21 02:58:25 +020036 bool visitBinary(Visit, TIntermBinary *node) override { return false; }
37 bool visitUnary(Visit, TIntermUnary *node) override { return false; }
38 bool visitSelection(Visit, TIntermSelection *node) override { return false; }
39 bool visitLoop(Visit, TIntermLoop *node) override { return false; }
40 bool visitBranch(Visit, TIntermBranch *node) override { return false; }
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080041
Corentin Walleze5a1f272015-08-21 02:58:25 +020042 bool visitAggregate(Visit visit, TIntermAggregate *node) override;
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080043
44 private:
Zhenyao Moe40d1e92014-07-16 17:40:36 -070045 void insertInitCode(TIntermSequence *sequence);
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080046
47 InitVariableInfoList mVariables;
48 bool mCodeInserted;
49};
50
Geoff Lang0a73dd82014-11-19 16:18:08 -050051#endif // COMPILER_TRANSLATOR_INITIALIZEVARIABLES_H_