@@ -42,6 +42,12 @@ private import semmle.python.dataflow.new.internal.TypeTracker::CallGraphConstru
42
42
newtype TParameterPosition =
43
43
/** Used for `self` in methods, and `cls` in classmethods. */
44
44
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
+ */
45
51
TLambdaSelfParameterPosition ( ) or
46
52
TPositionalParameterPosition ( int index ) {
47
53
index = any ( Parameter p ) .getPosition ( )
@@ -135,6 +141,12 @@ class ParameterPosition extends TParameterPosition {
135
141
newtype TArgumentPosition =
136
142
/** Used for `self` in methods, and `cls` in classmethods. */
137
143
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
+ */
138
150
TLambdaSelfArgumentPosition ( ) or
139
151
TPositionalArgumentPosition ( int index ) {
140
152
exists ( any ( CallNode c ) .getArg ( index ) )
@@ -1521,20 +1533,19 @@ abstract class ParameterNodeImpl extends Node {
1521
1533
}
1522
1534
1523
1535
/**
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.
1526
1540
*
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.
1531
1542
*/
1532
- class SynthCapturingClosureParameterNode extends ParameterNodeImpl ,
1533
- TSynthCapturingClosureParameterNode
1543
+ class SynthCapturedVariablesParameterNode extends ParameterNodeImpl ,
1544
+ TSynthCapturedVariablesParameterNode
1534
1545
{
1535
1546
private Function callable ;
1536
1547
1537
- SynthCapturingClosureParameterNode ( ) { this = TSynthCapturingClosureParameterNode ( callable ) }
1548
+ SynthCapturedVariablesParameterNode ( ) { this = TSynthCapturedVariablesParameterNode ( callable ) }
1538
1549
1539
1550
final Function getCallable ( ) { result = callable }
1540
1551
@@ -1627,13 +1638,12 @@ private class SummaryPostUpdateNode extends FlowSummaryNode, PostUpdateNodeImpl
1627
1638
}
1628
1639
1629
1640
/**
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.
1632
1645
*
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.
1637
1647
*
1638
1648
* TODO:
1639
1649
* We might want a synthetic node here, but currently that incurs problems
@@ -1642,10 +1652,10 @@ private class SummaryPostUpdateNode extends FlowSummaryNode, PostUpdateNodeImpl
1642
1652
* `CallGraphConstruction::Make` in staed of
1643
1653
* `CallGraphConstruction::Simple::Make` appropriately.
1644
1654
*/
1645
- class CapturingClosureArgumentNode extends CfgNode , ArgumentNode {
1655
+ class CapturedVariablesArgumentNode extends CfgNode , ArgumentNode {
1646
1656
CallNode callNode ;
1647
1657
1648
- CapturingClosureArgumentNode ( ) {
1658
+ CapturedVariablesArgumentNode ( ) {
1649
1659
node = callNode .getFunction ( ) and
1650
1660
exists ( Function target | resolveCall ( callNode , target , _) |
1651
1661
target = any ( VariableCapture:: CapturedVariable v ) .getACapturingScope ( )
0 commit comments