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.
7 #ifndef COMPILER_RENAME_FUNCTION
8 #define COMPILER_RENAME_FUNCTION
10 #include "compiler/translator/IntermNode.h"
13 // Renames a function, including its declaration and any calls to it.
15 class RenameFunction : public TIntermTraverser
18 RenameFunction(const TString& oldFunctionName, const TString& newFunctionName)
19 : TIntermTraverser(true, false, false)
20 , mOldFunctionName(oldFunctionName)
21 , mNewFunctionName(newFunctionName) {}
23 virtual bool visitAggregate(Visit visit, TIntermAggregate* node)
25 TOperator op = node->getOp();
26 if ((op == EOpFunction || op == EOpFunctionCall) && node->getName() == mOldFunctionName)
27 node->setName(mNewFunctionName);
32 const TString mOldFunctionName;
33 const TString mNewFunctionName;
36 #endif // COMPILER_RENAME_FUNCTION