blob: 868e5d566b9cec0f089664e3bae0d922de2ea3aa [file] [log] [blame]
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +00001//
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
Geoff Lang0a73dd82014-11-19 16:18:08 -05007#ifndef COMPILER_TRANSLATOR_RENAMEFUNCTION_H_
8#define COMPILER_TRANSLATOR_RENAMEFUNCTION_H_
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +00009
Jamie Madillb1a85f42014-08-19 15:23:24 -040010#include "compiler/translator/IntermNode.h"
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +000011
12//
13// Renames a function, including its declaration and any calls to it.
14//
15class RenameFunction : public TIntermTraverser
16{
17public:
18 RenameFunction(const TString& oldFunctionName, const TString& newFunctionName)
19 : TIntermTraverser(true, false, false)
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
31private:
maxvujovic@gmail.coma6e94282012-08-27 20:46:41 +000032 const TString mOldFunctionName;
33 const TString mNewFunctionName;
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +000034};
35
Geoff Lang0a73dd82014-11-19 16:18:08 -050036#endif // COMPILER_TRANSLATOR_RENAMEFUNCTION_H_