michael@0: // michael@0: // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: // michael@0: michael@0: #ifndef COMPILER_RENAME_FUNCTION michael@0: #define COMPILER_RENAME_FUNCTION michael@0: michael@0: #include "compiler/intermediate.h" michael@0: michael@0: // michael@0: // Renames a function, including its declaration and any calls to it. michael@0: // michael@0: class RenameFunction : public TIntermTraverser michael@0: { michael@0: public: michael@0: RenameFunction(const TString& oldFunctionName, const TString& newFunctionName) michael@0: : TIntermTraverser(true, false, false) michael@0: , mOldFunctionName(oldFunctionName) michael@0: , mNewFunctionName(newFunctionName) {} michael@0: michael@0: virtual bool visitAggregate(Visit visit, TIntermAggregate* node) michael@0: { michael@0: TOperator op = node->getOp(); michael@0: if ((op == EOpFunction || op == EOpFunctionCall) && node->getName() == mOldFunctionName) michael@0: node->setName(mNewFunctionName); michael@0: return true; michael@0: } michael@0: michael@0: private: michael@0: const TString mOldFunctionName; michael@0: const TString mNewFunctionName; michael@0: }; michael@0: michael@0: #endif // COMPILER_RENAME_FUNCTION