@@ -42,6 +42,12 @@ private import semmle.python.dataflow.new.internal.TypeTracker::CallGraphConstru
4242newtype TParameterPosition =
4343 /** Used for `self` in methods, and `cls` in classmethods. */
4444 TSelfParameterPosition ( ) or
45+ /**
46+ * This is used for tracking flow through captured variables, and
47+ * we use separate parameter/argument positions in order to distinguish
48+ * "lambda self" from "normal self", as lambdas may also access outer `self`
49+ * variables (through variable capture).
50+ */
4551 TLambdaSelfParameterPosition ( ) or
4652 TPositionalParameterPosition ( int index ) {
4753 index = any ( Parameter p ) .getPosition ( )
@@ -135,6 +141,12 @@ class ParameterPosition extends TParameterPosition {
135141newtype TArgumentPosition =
136142 /** Used for `self` in methods, and `cls` in classmethods. */
137143 TSelfArgumentPosition ( ) or
144+ /**
145+ * This is used for tracking flow through captured variables, and
146+ * we use separate parameter/argument positions in order to distinguish
147+ * "lambda self" from "normal self", as lambdas may also access outer `self`
148+ * variables (through variable capture).
149+ */
138150 TLambdaSelfArgumentPosition ( ) or
139151 TPositionalArgumentPosition ( int index ) {
140152 exists ( any ( CallNode c ) .getArg ( index ) )
@@ -1521,20 +1533,19 @@ abstract class ParameterNodeImpl extends Node {
15211533}
15221534
15231535/**
1524- * The value of a closure itself at function entry, viewed as a node in the data
1525- * flow graph.
1536+ * A sythetic parameter representing the values of the variables captured
1537+ * by the callable being called. This parameter represents a single object
1538+ * where all the values are stored as attributes.
1539+ * This is also known as the environment part of a closure.
15261540 *
1527- * This is used for tracking flow through captured variables, and we use
1528- * separate argument/parameter nodes at their own parameter/argument positions in order to distinguish
1529- * "lambda self" from "normal self", as lambdas may also access outer `self`
1530- * variables (through variable capture).
1541+ * This is used for tracking flow through captured variables.
15311542 */
1532- class SynthCapturingClosureParameterNode extends ParameterNodeImpl ,
1533- TSynthCapturingClosureParameterNode
1543+ class SynthCapturedVariablesParameterNode extends ParameterNodeImpl ,
1544+ TSynthCapturedVariablesParameterNode
15341545{
15351546 private Function callable ;
15361547
1537- SynthCapturingClosureParameterNode ( ) { this = TSynthCapturingClosureParameterNode ( callable ) }
1548+ SynthCapturedVariablesParameterNode ( ) { this = TSynthCapturedVariablesParameterNode ( callable ) }
15381549
15391550 final Function getCallable ( ) { result = callable }
15401551
@@ -1627,13 +1638,12 @@ private class SummaryPostUpdateNode extends FlowSummaryNode, PostUpdateNodeImpl
16271638}
16281639
16291640/**
1630- * The value of a closure itself being passed to the funciton, viewed as a
1631- * node in the data flow graph.
1641+ * A sythetic argument representing the values of the variables captured
1642+ * by the callable being called. This argument represents a single object
1643+ * where all the values are stored as attributes.
1644+ * This is also known as the environment part of a closure.
16321645 *
1633- * This is used for tracking flow through captured variables, and we use a
1634- * separate node and parameter/argument positions in order to distinguish
1635- * "lambda self" from "normal self", as lambdas may also access outer `self`
1636- * variables (through variable capture).
1646+ * This is used for tracking flow through captured variables.
16371647 *
16381648 * TODO:
16391649 * We might want a synthetic node here, but currently that incurs problems
@@ -1642,10 +1652,10 @@ private class SummaryPostUpdateNode extends FlowSummaryNode, PostUpdateNodeImpl
16421652 * `CallGraphConstruction::Make` in staed of
16431653 * `CallGraphConstruction::Simple::Make` appropriately.
16441654 */
1645- class CapturingClosureArgumentNode extends CfgNode , ArgumentNode {
1655+ class CapturedVariablesArgumentNode extends CfgNode , ArgumentNode {
16461656 CallNode callNode ;
16471657
1648- CapturingClosureArgumentNode ( ) {
1658+ CapturedVariablesArgumentNode ( ) {
16491659 node = callNode .getFunction ( ) and
16501660 exists ( Function target | resolveCall ( callNode , target , _) |
16511661 target = any ( VariableCapture:: CapturedVariable v ) .getACapturingScope ( )
0 commit comments