FIR CFG: remove ordering from control flow through in-place lambdas

Old graph:

  arg -> lambda enter -> ... -> lambda exit -> lambda enter -> ... ->
   -> lambda exit -> call

New graph:

  arg -+-> lambda enter -> ... -> lambda exit -+-> call
       \-> lambda enter -> ... -> lambda exit -/
This commit is contained in:
pyos
2022-11-23 10:10:16 +01:00
committed by teamcity
parent 5dce772f0b
commit c4c05f5248
41 changed files with 515 additions and 555 deletions
@@ -129,7 +129,10 @@ sealed class CFGNode<out E : FirElement>(val owner: ControlFlowGraph, val level:
open var flow: PersistentFlow
get() = _flow ?: throw IllegalStateException("flow for $this not initialized - traversing nodes in wrong order?")
@CfgInternals
set(value) { _flow = value } // TODO: forbid reassignment
set(value) {
assert(_flow == null) { "reassigning flow for $this" }
_flow = value
}
@CfgInternals
fun updateDeadStatus() {
@@ -240,7 +243,7 @@ class ExitDefaultArgumentsNode(owner: ControlFlowGraph, override val fir: FirVal
// ----------------------------------- Anonymous function -----------------------------------
class PostponedLambdaEnterNode(owner: ControlFlowGraph, override val fir: FirAnonymousFunction, level: Int, id: Int) : CFGNodeWithSubgraphs<FirAnonymousFunction>(owner, level, id) {
class PostponedLambdaEnterNode(owner: ControlFlowGraph, override val fir: FirAnonymousFunctionExpression, level: Int, id: Int) : CFGNodeWithSubgraphs<FirAnonymousFunctionExpression>(owner, level, id) {
override fun <R, D> accept(visitor: ControlFlowGraphVisitor<R, D>, data: D): R {
return visitor.visitPostponedLambdaEnterNode(this, data)
}