FIR CFA: remove direction from ControlFlowGraph.traverse.

If you care about direction, then you also care about labels.

3 out of 6 places that use `traverse` are incorrect, by the way.
Node order does not correspond to scoping boundaries.
This commit is contained in:
pyos
2022-12-16 16:42:16 +01:00
committed by Dmitriy Novozhilov
parent de105e602d
commit 5d4b44500a
8 changed files with 25 additions and 36 deletions
@@ -43,6 +43,21 @@ class ControlFlowGraph(val declaration: FirDeclaration?, val name: String, val k
FakeCall,
DefaultArgument,
}
// NOTE: this is only for dynamic dispatch on node types. If you're collecting data from predecessors,
// use `collectDataForNode` instead to account for `finally` block deduplication. If you don't need that,
// then you probably don't need this either. Hint: if the only thing you need from nodes is the corresponding
// FIR structure, then traverse the `FirFile` instead.
fun <D> traverse(visitor: ControlFlowGraphVisitor<*, D>, data: D) {
for (node in nodes) {
node.accept(visitor, data)
(node as? CFGNodeWithSubgraphs<*>)?.subGraphs?.forEach { it.traverse(visitor, data) }
}
}
fun traverse(visitor: ControlFlowGraphVisitorVoid) {
traverse(visitor, null)
}
}
data class Edge(