21
21
*
22
22
* NOTE: This library should only be used for debugging and exploration, not in production code.
23
23
*/
24
+
24
25
import javascript
25
26
private import DataFlow
26
27
@@ -33,37 +34,35 @@ private import DataFlow
33
34
* by being passed to another call.
34
35
*/
35
36
predicate callEdge ( Node pred , Node succ ) {
36
- exists ( InvokeNode invoke , Function f |
37
- invoke .getACallee ( ) = f and
38
- pred = invoke and
39
- succ = f .flow ( )
40
- or
41
- invoke .getContainer ( ) = f and
42
- pred = f .flow ( ) and
43
- succ = invoke
44
- )
37
+ exists ( InvokeNode invoke , Function f |
38
+ invoke .getACallee ( ) = f and
39
+ pred = invoke and
40
+ succ = f .flow ( )
45
41
or
46
- exists ( Function inner , Function outer |
47
- inner .getEnclosingContainer ( ) = outer and
48
- not inner = outer .getAReturnedExpr ( ) and
49
- pred = outer .flow ( ) and
50
- succ = inner .flow ( )
51
- )
42
+ invoke .getContainer ( ) = f and
43
+ pred = f .flow ( ) and
44
+ succ = invoke
45
+ )
46
+ or
47
+ exists ( Function inner , Function outer |
48
+ inner .getEnclosingContainer ( ) = outer and
49
+ not inner = outer .getAReturnedExpr ( ) and
50
+ pred = outer .flow ( ) and
51
+ succ = inner .flow ( )
52
+ )
52
53
}
53
54
54
55
/** Holds if `pred -> succ` is an edge in the call graph. */
55
56
query predicate edges = callEdge / 2 ;
56
57
57
58
/** Holds if `node` is part of the call graph. */
58
59
query predicate nodes ( Node node ) {
59
- node instanceof InvokeNode or
60
- node instanceof FunctionNode
60
+ node instanceof InvokeNode or
61
+ node instanceof FunctionNode
61
62
}
62
63
63
64
/** Gets a call in a function that has no known call sites. */
64
- private InvokeNode rootCall ( ) {
65
- not any ( InvokeNode i ) .getACallee ( ) = result .getContainer ( )
66
- }
65
+ private InvokeNode rootCall ( ) { not any ( InvokeNode i ) .getACallee ( ) = result .getContainer ( ) }
67
66
68
67
/**
69
68
* Holds if `invoke` should be used as the starting point of a call path.
@@ -75,9 +74,7 @@ predicate isStartOfCallPath(InvokeNode invoke) {
75
74
}
76
75
77
76
/** Gets a function that contains no calls to other functions. */
78
- private FunctionNode leafFunction ( ) {
79
- not callEdge ( result , _)
80
- }
77
+ private FunctionNode leafFunction ( ) { not callEdge ( result , _) }
81
78
82
79
/**
83
80
* Holds if `fun` should be used as the end point of a call path.
0 commit comments