blob: cfdb40da9285965977b8c5732ceb8aad44e2f9dc [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
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//
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:
32 const TString& mOldFunctionName;
33 const TString& mNewFunctionName;
34};
35
36#endif // COMPILER_RENAME_FUNCTION