@@ -216,10 +216,43 @@ class SsaNode extends Node, MkSsaNode {
216216 }
217217}
218218
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+
219248/** 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+
221254 /** Gets the `i`th parameter of this function. */
222- abstract ParameterNode getParameter ( int i ) ;
255+ ParameterNode getParameter ( int i ) { result = self . getParameter ( i ) }
223256
224257 /** Gets a parameter of this function. */
225258 ParameterNode getAParameter ( ) { result = this .getParameter ( _) }
@@ -228,18 +261,18 @@ abstract class FunctionNode extends Node {
228261 int getNumParameter ( ) { result = count ( this .getAParameter ( ) ) }
229262
230263 /** Gets the name of this function, if it has one. */
231- abstract string getName ( ) ;
264+ string getName ( ) { result = self . getName ( ) }
232265
233266 /**
234267 * Gets the dataflow node holding the value of the receiver, if any.
235268 */
236- abstract ReceiverNode getReceiver ( ) ;
269+ ReceiverNode getReceiver ( ) { result = self . getReceiver ( ) }
237270
238271 /**
239272 * Gets a value returned by the given function via a return statement or an assignment to a
240273 * result variable.
241274 */
242- abstract ResultNode getAResult ( ) ;
275+ ResultNode getAResult ( ) { result = self . getAResult ( ) }
243276
244277 /**
245278 * Gets the data-flow node corresponding to the `i`th result of this function.
@@ -251,11 +284,11 @@ abstract class FunctionNode extends Node {
251284 *
252285 * Note that this predicate has no result for function literals.
253286 */
254- Function getFunction ( ) { none ( ) }
287+ Function getFunction ( ) { result = self . getFunction ( ) }
255288}
256289
257290/** 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 {
259292 Function func ;
260293
261294 GlobalFunctionNode ( ) { this = MkGlobalFunctionNode ( func ) }
@@ -284,7 +317,7 @@ class GlobalFunctionNode extends FunctionNode, MkGlobalFunctionNode {
284317}
285318
286319/** 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 {
288321 override FuncLit expr ;
289322
290323 override ParameterNode getParameter ( int i ) { result = parameterNode ( expr .getParameter ( i ) ) }
0 commit comments