Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 1 | // |
| 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 Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 7 | #ifndef COMPILER_TRANSLATOR_INITIALIZEVARIABLES_H_ |
| 8 | #define COMPILER_TRANSLATOR_INITIALIZEVARIABLES_H_ |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 9 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 10 | #include "compiler/translator/IntermNode.h" |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 11 | |
| 12 | class InitializeVariables : public TIntermTraverser |
| 13 | { |
| 14 | public: |
| 15 | struct InitVariableInfo |
| 16 | { |
| 17 | TString name; |
| 18 | TType type; |
| 19 | |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 20 | InitVariableInfo(const TString &_name, const TType &_type) |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 21 | : name(_name), |
| 22 | type(_type) |
| 23 | { |
| 24 | } |
| 25 | }; |
| 26 | typedef TVector<InitVariableInfo> InitVariableInfoList; |
| 27 | |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 28 | InitializeVariables(const InitVariableInfoList &vars) |
Olli Etuaho | 3d0d9a4 | 2015-06-01 12:16:36 +0300 | [diff] [blame^] | 29 | : TIntermTraverser(true, false, false), |
| 30 | mVariables(vars), |
Corentin Wallez | bc99bb6 | 2015-05-14 17:42:20 -0400 | [diff] [blame] | 31 | mCodeInserted(false) |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 32 | { |
| 33 | } |
| 34 | |
| 35 | protected: |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 36 | virtual bool visitBinary(Visit, TIntermBinary *node) { return false; } |
| 37 | virtual bool visitUnary(Visit, TIntermUnary *node) { return false; } |
| 38 | virtual bool visitSelection(Visit, TIntermSelection *node) { return false; } |
| 39 | virtual bool visitLoop(Visit, TIntermLoop *node) { return false; } |
| 40 | virtual bool visitBranch(Visit, TIntermBranch *node) { return false; } |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 41 | |
| 42 | virtual bool visitAggregate(Visit visit, TIntermAggregate* node); |
| 43 | |
| 44 | private: |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 45 | void insertInitCode(TIntermSequence *sequence); |
Zhenyao Mo | 4a667fe | 2014-02-11 12:35:01 -0800 | [diff] [blame] | 46 | |
| 47 | InitVariableInfoList mVariables; |
| 48 | bool mCodeInserted; |
| 49 | }; |
| 50 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 51 | #endif // COMPILER_TRANSLATOR_INITIALIZEVARIABLES_H_ |