@@ -16,6 +16,7 @@ private import internal.GlobalFlow as GlobalFlow
16
16
*/
17
17
class Node extends TNode {
18
18
string toString ( ) { none ( ) } // overridden in subclasses
19
+
19
20
Location getLocation ( ) { none ( ) } // overridden in subclasses
20
21
21
22
/**
@@ -48,31 +49,21 @@ class AstNodeNode extends Node, MkAstNodeNode {
48
49
49
50
AstNodeNode ( ) { this = MkAstNodeNode ( ast ) }
50
51
51
- override string toString ( ) {
52
- result = ast .toString ( )
53
- }
52
+ override string toString ( ) { result = ast .toString ( ) }
54
53
55
- override Location getLocation ( ) {
56
- result = ast .getLocation ( )
57
- }
54
+ override Location getLocation ( ) { result = ast .getLocation ( ) }
58
55
59
56
/** Gets the AST node. */
60
- AstNode getAstNode ( ) {
61
- result = ast
62
- }
57
+ AstNode getAstNode ( ) { result = ast }
63
58
64
- override Predicate getEnclosingPredicate ( ) {
65
- result = ast .getEnclosingPredicate ( )
66
- }
59
+ override Predicate getEnclosingPredicate ( ) { result = ast .getEnclosingPredicate ( ) }
67
60
}
68
61
69
62
/**
70
63
* Gets the data-flow node correspoinding to the given AST node.
71
64
*/
72
65
pragma [ inline]
73
- Node astNode ( AstNode node ) {
74
- result = MkAstNodeNode ( node )
75
- }
66
+ Node astNode ( AstNode node ) { result = MkAstNodeNode ( node ) }
76
67
77
68
/**
78
69
* A data-flow node representing a variable within a specific scope.
@@ -84,35 +75,27 @@ class ScopedVariableNode extends Node, MkScopedVariable {
84
75
ScopedVariableNode ( ) { this = MkScopedVariable ( var , scope ) }
85
76
86
77
override string toString ( ) {
87
- result = "Variable '" + var .getName ( ) + "' scoped to " + scope .getLocation ( ) .getStartLine ( ) + ":" + scope .getLocation ( ) .getStartColumn ( )
78
+ result =
79
+ "Variable '" + var .getName ( ) + "' scoped to " + scope .getLocation ( ) .getStartLine ( ) + ":" +
80
+ scope .getLocation ( ) .getStartColumn ( )
88
81
}
89
82
90
- override Location getLocation ( ) {
91
- result = scope .getLocation ( )
92
- }
83
+ override Location getLocation ( ) { result = scope .getLocation ( ) }
93
84
94
85
/** Gets the variable being refined to a specific scope. */
95
- VarDef getVariable ( ) {
96
- result = var
97
- }
86
+ VarDef getVariable ( ) { result = var }
98
87
99
88
/** Gets the scope to which this variable has been refined. */
100
- AstNode getScope ( ) {
101
- result = scope
102
- }
89
+ AstNode getScope ( ) { result = scope }
103
90
104
- override Predicate getEnclosingPredicate ( ) {
105
- result = var .getEnclosingPredicate ( )
106
- }
91
+ override Predicate getEnclosingPredicate ( ) { result = var .getEnclosingPredicate ( ) }
107
92
}
108
93
109
94
/**
110
95
* Gets the data-flow node corresponding to `var` restricted to `scope`.
111
96
*/
112
97
pragma [ inline]
113
- Node scopedVariable ( VarDef var , AstNode scope ) {
114
- result = MkScopedVariable ( var , scope )
115
- }
98
+ Node scopedVariable ( VarDef var , AstNode scope ) { result = MkScopedVariable ( var , scope ) }
116
99
117
100
/**
118
101
* A data-flow node representing `this` within a class predicate, charpred, or newtype branch.
@@ -122,31 +105,21 @@ class ThisNode extends Node, MkThisNode {
122
105
123
106
ThisNode ( ) { this = MkThisNode ( pred ) }
124
107
125
- override string toString ( ) {
126
- result = "'this' in " + pred .getName ( )
127
- }
108
+ override string toString ( ) { result = "'this' in " + pred .getName ( ) }
128
109
129
- override Location getLocation ( ) {
130
- result = pred .getLocation ( )
131
- }
110
+ override Location getLocation ( ) { result = pred .getLocation ( ) }
132
111
133
112
/** Gets the class predicate, charpred, or newtype branch whose 'this' parameter is represented by this node. */
134
- Predicate getPredicate ( ) {
135
- result = pred
136
- }
113
+ Predicate getPredicate ( ) { result = pred }
137
114
138
- override Predicate getEnclosingPredicate ( ) {
139
- result = pred
140
- }
115
+ override Predicate getEnclosingPredicate ( ) { result = pred }
141
116
}
142
117
143
118
/**
144
119
* Gets the data-flow node representing `this` within the given class predicate, charpred, or newtype branch.
145
120
*/
146
121
pragma [ inline]
147
- Node thisNode ( Predicate pred ) {
148
- result = MkThisNode ( pred )
149
- }
122
+ Node thisNode ( Predicate pred ) { result = MkThisNode ( pred ) }
150
123
151
124
/**
152
125
* A data-flow node representing `result` within a predicate that has a result.
@@ -156,31 +129,21 @@ class ResultNode extends Node, MkResultNode {
156
129
157
130
ResultNode ( ) { this = MkResultNode ( pred ) }
158
131
159
- override string toString ( ) {
160
- result = "'result' in " + pred .getName ( )
161
- }
132
+ override string toString ( ) { result = "'result' in " + pred .getName ( ) }
162
133
163
- override Location getLocation ( ) {
164
- result = pred .getLocation ( )
165
- }
134
+ override Location getLocation ( ) { result = pred .getLocation ( ) }
166
135
167
136
/** Gets the predicate whose 'result' parameter is represented by this node. */
168
- Predicate getPredicate ( ) {
169
- result = pred
170
- }
137
+ Predicate getPredicate ( ) { result = pred }
171
138
172
- override Predicate getEnclosingPredicate ( ) {
173
- result = pred
174
- }
139
+ override Predicate getEnclosingPredicate ( ) { result = pred }
175
140
}
176
141
177
142
/**
178
143
* Gets the data-flow node representing `result` within the given predicate.
179
144
*/
180
145
pragma [ inline]
181
- Node resultNode ( Predicate pred ) {
182
- result = MkResultNode ( pred )
183
- }
146
+ Node resultNode ( Predicate pred ) { result = MkResultNode ( pred ) }
184
147
185
148
/**
186
149
* A data-flow node representing the view of a field in the enclosing class, as seen
@@ -193,39 +156,25 @@ class FieldNode extends Node, MkFieldNode {
193
156
FieldNode ( ) { this = MkFieldNode ( pred , fieldDecl ) }
194
157
195
158
/** Gets the member predicate or charpred for which this node represents access to the field. */
196
- Predicate getPredicate ( ) {
197
- result = pred
198
- }
159
+ Predicate getPredicate ( ) { result = pred }
199
160
200
- FieldDecl getFieldDeclaration ( ) {
201
- result = fieldDecl
202
- }
161
+ FieldDecl getFieldDeclaration ( ) { result = fieldDecl }
203
162
204
- string getFieldName ( ) {
205
- result = fieldDecl .getName ( )
206
- }
163
+ string getFieldName ( ) { result = fieldDecl .getName ( ) }
207
164
208
- override string toString ( ) {
209
- result = "'" + this .getFieldName ( ) + "' in " + pred .getName ( )
210
- }
165
+ override string toString ( ) { result = "'" + this .getFieldName ( ) + "' in " + pred .getName ( ) }
211
166
212
- override Location getLocation ( ) {
213
- result = pred .getLocation ( )
214
- }
167
+ override Location getLocation ( ) { result = pred .getLocation ( ) }
215
168
216
- override Predicate getEnclosingPredicate ( ) {
217
- result = pred
218
- }
169
+ override Predicate getEnclosingPredicate ( ) { result = pred }
219
170
}
220
171
221
172
/**
222
173
* Gets the data-flow node representing the given predicate's view of the given field
223
174
* in the enclosing class.
224
175
*/
225
176
pragma [ inline]
226
- Node fieldNode ( Predicate pred , FieldDecl fieldDecl ) {
227
- result = MkFieldNode ( pred , fieldDecl )
228
- }
177
+ Node fieldNode ( Predicate pred , FieldDecl fieldDecl ) { result = MkFieldNode ( pred , fieldDecl ) }
229
178
230
179
/**
231
180
* A collection of data-flow nodes in the same predicate, locally bound by equalities.
@@ -238,14 +187,10 @@ class SuperNode extends LocalFlow::TSuperNode {
238
187
SuperNode ( ) { this = LocalFlow:: MkSuperNode ( repr ) }
239
188
240
189
/** Gets a data-flow node that is part of this super node. */
241
- Node getANode ( ) {
242
- LocalFlow:: getRepr ( result ) = repr
243
- }
190
+ Node getANode ( ) { LocalFlow:: getRepr ( result ) = repr }
244
191
245
192
/** Gets an AST node from any of the nodes in this super node. */
246
- AstNode asAstNode ( ) {
247
- result = getANode ( ) .asAstNode ( )
248
- }
193
+ AstNode asAstNode ( ) { result = getANode ( ) .asAstNode ( ) }
249
194
250
195
/**
251
196
* Gets a single node from this super node.
@@ -255,16 +200,12 @@ class SuperNode extends LocalFlow::TSuperNode {
255
200
* - An `AstNodeNode` is preferred over other nodes.
256
201
* - A node occuring earlier is preferred over one occurring later.
257
202
*/
258
- Node getArbitraryRepr ( ) {
259
- result = min ( Node n | n = getANode ( ) | n order by getInternalId ( n ) )
260
- }
203
+ Node getArbitraryRepr ( ) { result = min ( Node n | n = getANode ( ) | n order by getInternalId ( n ) ) }
261
204
262
205
/**
263
206
* Gets the predicate containing all nodes that are part of this super node.
264
207
*/
265
- Predicate getEnclosingPredicate ( ) {
266
- result = getANode ( ) .getEnclosingPredicate ( )
267
- }
208
+ Predicate getEnclosingPredicate ( ) { result = getANode ( ) .getEnclosingPredicate ( ) }
268
209
269
210
/** Gets a string representation of this super node. */
270
211
string toString ( ) {
@@ -275,14 +216,10 @@ class SuperNode extends LocalFlow::TSuperNode {
275
216
}
276
217
277
218
/** Gets the location of an arbitrary node in this super node. */
278
- Location getLocation ( ) {
279
- result = getArbitraryRepr ( ) .getLocation ( )
280
- }
219
+ Location getLocation ( ) { result = getArbitraryRepr ( ) .getLocation ( ) }
281
220
282
221
/** Gets any member call whose receiver is in the same super node. */
283
- MemberCall getALocalMemberCall ( ) {
284
- superNode ( result .getBase ( ) ) = this
285
- }
222
+ MemberCall getALocalMemberCall ( ) { superNode ( result .getBase ( ) ) = this }
286
223
287
224
/** Gets any member call whose receiver is in the same super node. */
288
225
MemberCall getALocalMemberCall ( string name ) {
@@ -382,9 +319,7 @@ class SuperNode extends LocalFlow::TSuperNode {
382
319
383
320
/** Gets the super node for the given AST node. */
384
321
pragma [ inline]
385
- SuperNode superNode ( AstNode node ) {
386
- result = astNode ( node ) .getSuperNode ( )
387
- }
322
+ SuperNode superNode ( AstNode node ) { result = astNode ( node ) .getSuperNode ( ) }
388
323
389
324
/**
390
325
* A summary of the steps needed to reach a node in the global data flow graph,
0 commit comments