cached stages iteration 5

This commit is contained in:
Erik Krogh Kristensen
2021-12-08 14:47:41 +01:00
parent a8f9a91e38
commit c9e3a62953
2 changed files with 8 additions and 0 deletions

View File

@@ -619,7 +619,9 @@ class UnaryExprNode extends ControlFlowNode {
* and nodes implicitly assigned in class and function definitions and imports.
*/
class DefinitionNode extends ControlFlowNode {
cached
DefinitionNode() {
Stages::SSA::ref() and
exists(Assign a | a.getATarget().getAFlowNode() = this)
or
exists(AnnAssign a | a.getTarget().getAFlowNode() = this and exists(a.getValue()))
@@ -678,6 +680,7 @@ abstract class SequenceNode extends ControlFlowNode {
ControlFlowNode getAnElement() { result = this.getElement(_) }
/** Gets the control flow node for the nth element of this sequence */
cached
abstract ControlFlowNode getElement(int n);
}
@@ -686,6 +689,7 @@ class TupleNode extends SequenceNode {
TupleNode() { toAst(this) instanceof Tuple }
override ControlFlowNode getElement(int n) {
Stages::SSA::ref() and
exists(Tuple t | this.getNode() = t and result.getNode() = t.getElt(n)) and
(
result.getBasicBlock().dominates(this.getBasicBlock())

View File

@@ -86,6 +86,10 @@ module Stages {
any(PyFlow::BasicBlock b).dominates(_)
or
exists(any(PyFlow::ControlFlowNode b).getScope())
or
exists(PyFlow::DefinitionNode b)
or
exists(any(PyFlow::SequenceNode n).getElement(_))
}
}