Skip to content

Commit afb3d1d

Browse files
committed
Python: move capture node to DataFlowPrivate
1 parent 3cea46f commit afb3d1d

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,36 @@ predicate storeStep(Node nodeFrom, ContentSet c, Node nodeTo) {
688688
VariableCapture::storeStep(nodeFrom, c, nodeTo)
689689
}
690690

691+
/**
692+
* A synthesized data flow node representing a closure object that tracks
693+
* captured variables.
694+
*/
695+
class SynthCaptureNode extends Node, TSynthCaptureNode {
696+
private VariableCapture::Flow::SynthesizedCaptureNode cn;
697+
698+
SynthCaptureNode() { this = TSynthCaptureNode(cn) }
699+
700+
/** Gets the `SynthesizedCaptureNode` that this node represents. */
701+
VariableCapture::Flow::SynthesizedCaptureNode getSynthesizedCaptureNode() { result = cn }
702+
703+
override Scope getScope() { result = cn.getEnclosingCallable() }
704+
705+
override Location getLocation() { result = cn.getLocation() }
706+
707+
override string toString() { result = cn.toString() }
708+
}
709+
710+
private class SynthCapturePostUpdateNode extends PostUpdateNodeImpl, SynthCaptureNode {
711+
private SynthCaptureNode pre;
712+
713+
SynthCapturePostUpdateNode() {
714+
VariableCapture::Flow::capturePostUpdateNode(this.getSynthesizedCaptureNode(),
715+
pre.getSynthesizedCaptureNode())
716+
}
717+
718+
override Node getPreUpdateNode() { result = pre }
719+
}
720+
691721
/**
692722
* INTERNAL: Do not use.
693723
*

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPublic.qll

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -504,36 +504,6 @@ class StarPatternElementNode extends Node, TStarPatternElementNode {
504504
override Location getLocation() { result = consumer.getLocation() }
505505
}
506506

507-
/**
508-
* A synthesized data flow node representing a closure object that tracks
509-
* captured variables.
510-
*/
511-
class SynthCaptureNode extends Node, TSynthCaptureNode {
512-
private VariableCapture::Flow::SynthesizedCaptureNode cn;
513-
514-
SynthCaptureNode() { this = TSynthCaptureNode(cn) }
515-
516-
/** Gets the `SynthesizedCaptureNode` that this node represents. */
517-
VariableCapture::Flow::SynthesizedCaptureNode getSynthesizedCaptureNode() { result = cn }
518-
519-
override Scope getScope() { result = cn.getEnclosingCallable() }
520-
521-
override Location getLocation() { result = cn.getLocation() }
522-
523-
override string toString() { result = cn.toString() }
524-
}
525-
526-
private class SynthCapturePostUpdateNode extends PostUpdateNodeImpl, SynthCaptureNode {
527-
private SynthCaptureNode pre;
528-
529-
SynthCapturePostUpdateNode() {
530-
VariableCapture::Flow::capturePostUpdateNode(this.getSynthesizedCaptureNode(),
531-
pre.getSynthesizedCaptureNode())
532-
}
533-
534-
override Node getPreUpdateNode() { result = pre }
535-
}
536-
537507
/**
538508
* Gets a node that controls whether other nodes are evaluated.
539509
*

0 commit comments

Comments
 (0)