FIR CFA: remove infinite loops from toposort

Finally, no more tests getting stuck on `orderNodes`. Only took me what,
75 commits to fix enough things to make this actually work?
This commit is contained in:
pyos
2022-12-11 01:25:53 +01:00
committed by Dmitriy Novozhilov
parent 54f32a6fba
commit b9f366af05
4 changed files with 37 additions and 39 deletions
@@ -73,11 +73,6 @@ class ControlFlowGraphBuilder {
private val notCompletedFunctionCalls: Stack<MutableList<FunctionCallNode>> = stackOf()
// ----------------------------------- API for node builders -----------------------------------
private var idCounter: Int = Random.nextInt()
fun createId(): Int = idCounter++
// ----------------------------------- Public API -----------------------------------
fun returnExpressionsOfAnonymousFunction(function: FirAnonymousFunction): Collection<FirExpression>? {
@@ -130,7 +125,6 @@ class ControlFlowGraphBuilder {
private fun popGraph(): ControlFlowGraph {
levelCounter--
// TODO: count nodes per graph, validate the list after sorting
return graphs.pop().also { it.complete() }
}
@@ -9,6 +9,9 @@ import org.jetbrains.kotlin.fir.FirElement
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.expressions.*
@OptIn(CfgInternals::class)
private fun ControlFlowGraphBuilder.createId(): Int = currentGraph.nodeCount++
fun ControlFlowGraphBuilder.createStubNode(): StubNode = StubNode(currentGraph, levelCounter, createId())
fun ControlFlowGraphBuilder.createFakeExpressionEnterNode(): FakeExpressionEnterNode =