summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/compiler/translator/RenameFunction.h
blob: 1f7fb16c45979cd1da2bf19ea86179d264d5ffab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//

#ifndef COMPILER_RENAME_FUNCTION
#define COMPILER_RENAME_FUNCTION

#include "compiler/translator/intermediate.h"

//
// Renames a function, including its declaration and any calls to it.
//
class RenameFunction : public TIntermTraverser
{
public:
    RenameFunction(const TString& oldFunctionName, const TString& newFunctionName)
    : TIntermTraverser(true, false, false)
    , mOldFunctionName(oldFunctionName)
    , mNewFunctionName(newFunctionName) {}

    virtual bool visitAggregate(Visit visit, TIntermAggregate* node)
    {
        TOperator op = node->getOp();
        if ((op == EOpFunction || op == EOpFunctionCall) && node->getName() == mOldFunctionName)
            node->setName(mNewFunctionName);
        return true;
    }

private:
    const TString mOldFunctionName;
    const TString mNewFunctionName;
};

#endif  // COMPILER_RENAME_FUNCTION