@@ -216,10 +216,43 @@ class SsaNode extends Node, MkSsaNode {
216
216
}
217
217
}
218
218
219
+ private module FunctionNode {
220
+ /** A function, viewed as a node in a data flow graph. */
221
+ abstract class Range extends Node {
222
+ /** Gets the `i`th parameter of this function. */
223
+ abstract ParameterNode getParameter ( int i ) ;
224
+
225
+ /** Gets the name of this function, if it has one. */
226
+ abstract string getName ( ) ;
227
+
228
+ /**
229
+ * Gets the dataflow node holding the value of the receiver, if any.
230
+ */
231
+ abstract ReceiverNode getReceiver ( ) ;
232
+
233
+ /**
234
+ * Gets a value returned by the given function via a return statement or an assignment to a
235
+ * result variable.
236
+ */
237
+ abstract ResultNode getAResult ( ) ;
238
+
239
+ /**
240
+ * Gets the function entity this node corresponds to.
241
+ *
242
+ * Note that this predicate has no result for function literals.
243
+ */
244
+ Function getFunction ( ) { none ( ) }
245
+ }
246
+ }
247
+
219
248
/** A function, viewed as a node in a data flow graph. */
220
- abstract class FunctionNode extends Node {
249
+ class FunctionNode extends Node {
250
+ FunctionNode:: Range self ;
251
+
252
+ FunctionNode ( ) { this = self }
253
+
221
254
/** Gets the `i`th parameter of this function. */
222
- abstract ParameterNode getParameter ( int i ) ;
255
+ ParameterNode getParameter ( int i ) { result = self . getParameter ( i ) }
223
256
224
257
/** Gets a parameter of this function. */
225
258
ParameterNode getAParameter ( ) { result = this .getParameter ( _) }
@@ -228,18 +261,18 @@ abstract class FunctionNode extends Node {
228
261
int getNumParameter ( ) { result = count ( this .getAParameter ( ) ) }
229
262
230
263
/** Gets the name of this function, if it has one. */
231
- abstract string getName ( ) ;
264
+ string getName ( ) { result = self . getName ( ) }
232
265
233
266
/**
234
267
* Gets the dataflow node holding the value of the receiver, if any.
235
268
*/
236
- abstract ReceiverNode getReceiver ( ) ;
269
+ ReceiverNode getReceiver ( ) { result = self . getReceiver ( ) }
237
270
238
271
/**
239
272
* Gets a value returned by the given function via a return statement or an assignment to a
240
273
* result variable.
241
274
*/
242
- abstract ResultNode getAResult ( ) ;
275
+ ResultNode getAResult ( ) { result = self . getAResult ( ) }
243
276
244
277
/**
245
278
* Gets the data-flow node corresponding to the `i`th result of this function.
@@ -251,11 +284,11 @@ abstract class FunctionNode extends Node {
251
284
*
252
285
* Note that this predicate has no result for function literals.
253
286
*/
254
- Function getFunction ( ) { none ( ) }
287
+ Function getFunction ( ) { result = self . getFunction ( ) }
255
288
}
256
289
257
290
/** A representation of a function that is declared in the module scope. */
258
- class GlobalFunctionNode extends FunctionNode , MkGlobalFunctionNode {
291
+ class GlobalFunctionNode extends FunctionNode:: Range , MkGlobalFunctionNode {
259
292
Function func ;
260
293
261
294
GlobalFunctionNode ( ) { this = MkGlobalFunctionNode ( func ) }
@@ -284,7 +317,7 @@ class GlobalFunctionNode extends FunctionNode, MkGlobalFunctionNode {
284
317
}
285
318
286
319
/** A representation of the function that is defined by a function literal. */
287
- class FuncLitNode extends FunctionNode , ExprNode {
320
+ class FuncLitNode extends FunctionNode:: Range , ExprNode {
288
321
override FuncLit expr ;
289
322
290
323
override ParameterNode getParameter ( int i ) { result = parameterNode ( expr .getParameter ( i ) ) }
0 commit comments