zenilib: zenilib/jni/external/angle/src/compiler/DetectCallDepth.h Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DetectCallDepth.h
Go to the documentation of this file.
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 <limits.h>
13 #include "compiler/intermediate.h"
14 #include "compiler/VariableInfo.h"
15
16 class TInfoSink;
17
18 // Traverses intermediate tree to detect function recursion.
19 class DetectCallDepth : public TIntermTraverser {
20 public:
21 enum ErrorCode {
22 kErrorMissingMain,
23 kErrorRecursion,
24 kErrorMaxDepthExceeded,
25 kErrorNone
26 };
27
28 DetectCallDepth(TInfoSink& infoSync, bool limitCallStackDepth, int maxCallStackDepth);
29 ~DetectCallDepth();
30
31 virtual bool visitAggregate(Visit, TIntermAggregate*);
32
33 bool checkExceedsMaxDepth(int depth);
34
35 ErrorCode detectCallDepth();
36
37 private:
38 class FunctionNode {
39 public:
40 static const int kInfiniteCallDepth = INT_MAX;
41
42 FunctionNode(const TString& fname);
43
44 const TString& getName() const;
45
46 // If a function is already in the callee list, this becomes a no-op.
47 void addCallee(FunctionNode* callee);
48
49 // Returns kInifinityCallDepth if recursive function calls are detected.
50 int detectCallDepth(DetectCallDepth* detectCallDepth, int depth);
51
52 // Reset state.
53 void reset();
54
55 private:
56 // mangled function name is unique.
57 TString name;
58
59 // functions that are directly called by this function.
60 TVector<FunctionNode*> callees;
61
62 Visit visit;
63 };
64
65 ErrorCode detectCallDepthForFunction(FunctionNode* func);
66 FunctionNode* findFunctionByName(const TString& name);
67 void resetFunctionNodes();
68
69 TInfoSink& getInfoSink() { return infoSink; }
70
71 TVector<FunctionNode*> functions;
72 FunctionNode* currentFunction;
73 TInfoSink& infoSink;
74 int maxDepth;
75
76 DetectCallDepth(const DetectCallDepth&);
77 void operator=(const DetectCallDepth&);
78 };
79
80 #endif // COMPILER_DETECT_RECURSION_H_
Visit
Visit
Definition: intermediate.h:524
ShaderLang.h
intermediate.h
DetectCallDepth::~DetectCallDepth
~DetectCallDepth()
Definition: DetectCallDepth.cpp:80
name
EGLImageKHR EGLint * name
Definition: eglext.h:284
reset
GLboolean reset
Definition: glew.h:4441
func
GLenum func
Definition: SDL_opengl.h:5654
TIntermAggregate
Definition: intermediate.h:460
VariableInfo.h
DetectCallDepth
Definition: DetectCallDepth.h:19
DetectCallDepth::kErrorNone
Definition: DetectCallDepth.h:25
depth
GLint GLenum GLsizei GLsizei GLsizei depth
Definition: gl2ext.h:845
DetectCallDepth::visitAggregate
virtual bool visitAggregate(Visit, TIntermAggregate *)
Definition: DetectCallDepth.cpp:86
TIntermTraverser
Definition: intermediate.h:539
TString
std::basic_string< char, std::char_traits< char >, TStringAllocator > TString
Definition: Common.h:41
DetectCallDepth::checkExceedsMaxDepth
bool checkExceedsMaxDepth(int depth)
Definition: DetectCallDepth.cpp:127
DetectCallDepth::kErrorRecursion
Definition: DetectCallDepth.h:23
DetectCallDepth::kErrorMissingMain
Definition: DetectCallDepth.h:22
DetectCallDepth::detectCallDepth
ErrorCode detectCallDepth()
Definition: DetectCallDepth.cpp:155
TVector< FunctionNode * >
DetectCallDepth::kErrorMaxDepthExceeded
Definition: DetectCallDepth.h:24
DetectCallDepth::DetectCallDepth
DetectCallDepth(TInfoSink &infoSync, bool limitCallStackDepth, int maxCallStackDepth)
Definition: DetectCallDepth.cpp:72
DetectCallDepth::ErrorCode
ErrorCode
Definition: DetectCallDepth.h:21
TInfoSink
Definition: InfoSink.h:108