blob: e4fc67e6524937f1794c5c9913ab573cec766017 [file] [log] [blame]
Zhenyao Moe740add2014-07-18 17:01:01 -07001//
2// Copyright (c) 2002-2014 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_REGENERATESTRUCTNAMES_H_
8#define COMPILER_TRANSLATOR_REGENERATESTRUCTNAMES_H_
Zhenyao Moe740add2014-07-18 17:01:01 -07009
Jamie Madillb9b5c102014-08-20 17:28:54 -040010#include "compiler/translator/Intermediate.h"
Zhenyao Moe740add2014-07-18 17:01:01 -070011#include "compiler/translator/SymbolTable.h"
12
13#include <set>
14
Jamie Madill45bcc782016-11-07 13:58:48 -050015namespace sh
16{
17
Zhenyao Moe740add2014-07-18 17:01:01 -070018class RegenerateStructNames : public TIntermTraverser
19{
20 public:
Jamie Madilld7b1ab52016-12-12 14:42:19 -050021 RegenerateStructNames(const TSymbolTable &symbolTable, int shaderVersion)
Olli Etuaho3d0d9a42015-06-01 12:16:36 +030022 : TIntermTraverser(true, false, false),
23 mSymbolTable(symbolTable),
Zhenyao Moe740add2014-07-18 17:01:01 -070024 mShaderVersion(shaderVersion),
Jamie Madilld7b1ab52016-12-12 14:42:19 -050025 mScopeDepth(0)
26 {
27 }
Zhenyao Moe740add2014-07-18 17:01:01 -070028
29 protected:
Corentin Walleze5a1f272015-08-21 02:58:25 +020030 void visitSymbol(TIntermSymbol *) override;
Olli Etuaho6d40bbd2016-09-30 13:49:38 +010031 bool visitBlock(Visit, TIntermBlock *block) override;
Zhenyao Moe740add2014-07-18 17:01:01 -070032
33 private:
34 const TSymbolTable &mSymbolTable;
35 int mShaderVersion;
36
37 // Indicating the depth of the current scope.
38 // The global scope is 1.
39 int mScopeDepth;
40
41 // If a struct's declared globally, push its ID in this set.
42 std::set<int> mDeclaredGlobalStructs;
43};
44
Jamie Madill45bcc782016-11-07 13:58:48 -050045} // namespace sh
46
Geoff Lang0a73dd82014-11-19 16:18:08 -050047#endif // COMPILER_TRANSLATOR_REGENERATESTRUCTNAMES_H_