zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RenameFunction.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2012 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_RENAME_FUNCTION
8 #define COMPILER_RENAME_FUNCTION
9 
10 #include "compiler/intermediate.h"
11 
12 //
13 // Renames a function, including its declaration and any calls to it.
14 //
16 {
17 public:
18  RenameFunction(const TString& oldFunctionName, const TString& newFunctionName)
20  , mOldFunctionName(oldFunctionName)
21  , mNewFunctionName(newFunctionName) {}
22 
23  virtual bool visitAggregate(Visit visit, TIntermAggregate* node)
24  {
25  TOperator op = node->getOp();
26  if ((op == EOpFunction || op == EOpFunctionCall) && node->getName() == mOldFunctionName)
27  node->setName(mNewFunctionName);
28  return true;
29  }
30 
31 private:
32  const TString mOldFunctionName;
33  const TString mNewFunctionName;
34 };
35 
36 #endif // COMPILER_RENAME_FUNCTION
TOperator
Definition: intermediate.h:29
Visit
Definition: intermediate.h:524
TOperator getOp() const
Definition: intermediate.h:389
void setName(const TString &n)
Definition: intermediate.h:471
#define true
Definition: ftrandom.c:49
const TString & getName() const
Definition: intermediate.h:472
std::basic_string< char, std::char_traits< char >, TStringAllocator > TString
Definition: Common.h:41
RenameFunction(const TString &oldFunctionName, const TString &newFunctionName)
virtual bool visitAggregate(Visit visit, TIntermAggregate *node)
#define false
Definition: ftrandom.c:50