~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/ThirdParty/ANGLE/src/compiler/DetectRecursion.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// Copyright (c) 2002-2011 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_DETECT_RECURSION_H_
 
8
#define COMPILER_DETECT_RECURSION_H_
 
9
 
 
10
#include "GLSLANG/ShaderLang.h"
 
11
 
 
12
#include "compiler/intermediate.h"
 
13
#include "compiler/VariableInfo.h"
 
14
 
 
15
// Traverses intermediate tree to detect function recursion.
 
16
class DetectRecursion : public TIntermTraverser {
 
17
public:
 
18
    enum ErrorCode {
 
19
        kErrorMissingMain,
 
20
        kErrorRecursion,
 
21
        kErrorNone
 
22
    };
 
23
 
 
24
    DetectRecursion();
 
25
    ~DetectRecursion();
 
26
 
 
27
    virtual bool visitAggregate(Visit, TIntermAggregate*);
 
28
 
 
29
    ErrorCode detectRecursion();
 
30
 
 
31
private:
 
32
    class FunctionNode {
 
33
    public:
 
34
        FunctionNode(const TString& fname);
 
35
 
 
36
        const TString& getName() const;
 
37
 
 
38
        // If a function is already in the callee list, this becomes a no-op.
 
39
        void addCallee(FunctionNode* callee);
 
40
 
 
41
        // Return true if recursive function calls are detected.
 
42
        bool detectRecursion();
 
43
 
 
44
    private:
 
45
        // mangled function name is unique.
 
46
        TString name;
 
47
 
 
48
        // functions that are directly called by this function.
 
49
        TVector<FunctionNode*> callees;
 
50
 
 
51
        Visit visit;
 
52
    };
 
53
 
 
54
    FunctionNode* findFunctionByName(const TString& name);
 
55
 
 
56
    TVector<FunctionNode*> functions;
 
57
    FunctionNode* currentFunction;
 
58
};
 
59
 
 
60
#endif  // COMPILER_DETECT_RECURSION_H_