maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 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 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 7 | #ifndef COMPILER_TRANSLATOR_RENAMEFUNCTION_H_ |
| 8 | #define COMPILER_TRANSLATOR_RENAMEFUNCTION_H_ |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 9 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 10 | #include "compiler/translator/IntermNode.h" |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 11 | |
| 12 | // |
| 13 | // Renames a function, including its declaration and any calls to it. |
| 14 | // |
| 15 | class RenameFunction : public TIntermTraverser |
| 16 | { |
| 17 | public: |
| 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 | |
| 31 | private: |
maxvujovic@gmail.com | a6e9428 | 2012-08-27 20:46:41 +0000 | [diff] [blame] | 32 | const TString mOldFunctionName; |
| 33 | const TString mNewFunctionName; |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 34 | }; |
| 35 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 36 | #endif // COMPILER_TRANSLATOR_RENAMEFUNCTION_H_ |