blob: 59c3ea0a39de5dca621a56b2aef0f97454d26afa [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
7#ifndef COMPILER_INITIALIZE_VARIABLES_H_
8#define COMPILER_INITIALIZE_VARIABLES_H_
9
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)
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080029 : mCodeInserted(false),
30 mVariables(vars)
31 {
32 }
33
34 protected:
Zhenyao Moe40d1e92014-07-16 17:40:36 -070035 virtual bool visitBinary(Visit, TIntermBinary *node) { return false; }
36 virtual bool visitUnary(Visit, TIntermUnary *node) { return false; }
37 virtual bool visitSelection(Visit, TIntermSelection *node) { return false; }
38 virtual bool visitLoop(Visit, TIntermLoop *node) { return false; }
39 virtual bool visitBranch(Visit, TIntermBranch *node) { return false; }
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080040
41 virtual bool visitAggregate(Visit visit, TIntermAggregate* node);
42
43 private:
Zhenyao Moe40d1e92014-07-16 17:40:36 -070044 void insertInitCode(TIntermSequence *sequence);
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080045
46 InitVariableInfoList mVariables;
47 bool mCodeInserted;
48};
49
50#endif // COMPILER_INITIALIZE_VARIABLES_H_