1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/angle/src/compiler/RenameFunction.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,36 @@ 1.4 +// 1.5 +// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. 1.6 +// Use of this source code is governed by a BSD-style license that can be 1.7 +// found in the LICENSE file. 1.8 +// 1.9 + 1.10 +#ifndef COMPILER_RENAME_FUNCTION 1.11 +#define COMPILER_RENAME_FUNCTION 1.12 + 1.13 +#include "compiler/intermediate.h" 1.14 + 1.15 +// 1.16 +// Renames a function, including its declaration and any calls to it. 1.17 +// 1.18 +class RenameFunction : public TIntermTraverser 1.19 +{ 1.20 +public: 1.21 + RenameFunction(const TString& oldFunctionName, const TString& newFunctionName) 1.22 + : TIntermTraverser(true, false, false) 1.23 + , mOldFunctionName(oldFunctionName) 1.24 + , mNewFunctionName(newFunctionName) {} 1.25 + 1.26 + virtual bool visitAggregate(Visit visit, TIntermAggregate* node) 1.27 + { 1.28 + TOperator op = node->getOp(); 1.29 + if ((op == EOpFunction || op == EOpFunctionCall) && node->getName() == mOldFunctionName) 1.30 + node->setName(mNewFunctionName); 1.31 + return true; 1.32 + } 1.33 + 1.34 +private: 1.35 + const TString mOldFunctionName; 1.36 + const TString mNewFunctionName; 1.37 +}; 1.38 + 1.39 +#endif // COMPILER_RENAME_FUNCTION