[FIR] Choose right cfg owner for postponed lambdas
This commit is contained in:
+3
-1
@@ -54,6 +54,7 @@ class ControlFlowGraphBuilder {
|
|||||||
|
|
||||||
private val entersToPostponedAnonymousFunctions: MutableMap<FirFunctionSymbol<*>, PostponedLambdaEnterNode> = mutableMapOf()
|
private val entersToPostponedAnonymousFunctions: MutableMap<FirFunctionSymbol<*>, PostponedLambdaEnterNode> = mutableMapOf()
|
||||||
private val exitsFromPostponedAnonymousFunctions: MutableMap<FirFunctionSymbol<*>, PostponedLambdaExitNode> = mutableMapOf()
|
private val exitsFromPostponedAnonymousFunctions: MutableMap<FirFunctionSymbol<*>, PostponedLambdaExitNode> = mutableMapOf()
|
||||||
|
private val parentGraphForAnonymousFunctions: MutableMap<FirFunctionSymbol<*>, ControlFlowGraph> = mutableMapOf()
|
||||||
|
|
||||||
private val exitsFromCompletedPostponedAnonymousFunctions: MutableList<PostponedLambdaExitNode> = mutableListOf()
|
private val exitsFromCompletedPostponedAnonymousFunctions: MutableList<PostponedLambdaExitNode> = mutableListOf()
|
||||||
|
|
||||||
@@ -178,7 +179,7 @@ class ControlFlowGraphBuilder {
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
if (graph != null) {
|
if (graph != null) {
|
||||||
val previousGraph = graphs.top()
|
val previousGraph = parentGraphForAnonymousFunctions.remove(function.symbol) ?: graphs.top()
|
||||||
if (previousGraph.kind == ControlFlowGraph.Kind.Function) {
|
if (previousGraph.kind == ControlFlowGraph.Kind.Function) {
|
||||||
previousGraph.addSubGraph(graph)
|
previousGraph.addSubGraph(graph)
|
||||||
}
|
}
|
||||||
@@ -213,6 +214,7 @@ class ControlFlowGraphBuilder {
|
|||||||
val symbol = anonymousFunction.symbol
|
val symbol = anonymousFunction.symbol
|
||||||
entersToPostponedAnonymousFunctions[symbol] = enterNode
|
entersToPostponedAnonymousFunctions[symbol] = enterNode
|
||||||
exitsFromPostponedAnonymousFunctions[symbol] = exitNode
|
exitsFromPostponedAnonymousFunctions[symbol] = exitNode
|
||||||
|
parentGraphForAnonymousFunctions[symbol] = graph
|
||||||
CFGNode.addEdge(lastNodes.pop(), enterNode, kind = EdgeKind.Simple, propagateDeadness = true)
|
CFGNode.addEdge(lastNodes.pop(), enterNode, kind = EdgeKind.Simple, propagateDeadness = true)
|
||||||
CFGNode.addEdge(enterNode, exitNode, kind = EdgeKind.Dfg, propagateDeadness = true)
|
CFGNode.addEdge(enterNode, exitNode, kind = EdgeKind.Dfg, propagateDeadness = true)
|
||||||
lastNodes.push(exitNode)
|
lastNodes.push(exitNode)
|
||||||
|
|||||||
Reference in New Issue
Block a user