From 9535df5e2ef6b42f6abf1b24f16dceb56efe406b Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 19 Mar 2020 16:38:28 +0300 Subject: [PATCH] [FIR] Add owner to ControlFlowGraph --- .../kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt | 2 +- .../kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt index cac00f9cb3e..0d113d71918 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt @@ -14,7 +14,7 @@ import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.visitors.FirTransformer import org.jetbrains.kotlin.fir.visitors.FirVisitor -class ControlFlowGraph(val name: String, val kind: Kind) { +class ControlFlowGraph(val owner: FirDeclaration?, val name: String, val kind: Kind) { private val _nodes: MutableList> = mutableListOf() val nodes: List> get() = _nodes diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt index aa85a75b5d7..e16b305e547 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt @@ -16,7 +16,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.fir.types.isNothing class ControlFlowGraphBuilder { - private val graphs: Stack = stackOf(ControlFlowGraph("", ControlFlowGraph.Kind.TopLevel)) + private val graphs: Stack = stackOf(ControlFlowGraph(null, "", ControlFlowGraph.Kind.TopLevel)) val graph: ControlFlowGraph get() = graphs.top() private val lexicalScopes: Stack>> = stackOf(stackOf()) @@ -88,7 +88,7 @@ class ControlFlowGraphBuilder { } if (!isInplace) { - graphs.push(ControlFlowGraph(name, ControlFlowGraph.Kind.Function)) + graphs.push(ControlFlowGraph(function, name, ControlFlowGraph.Kind.Function)) } val enterNode = createFunctionEnterNode(function, isInplace).also { @@ -240,7 +240,7 @@ class ControlFlowGraphBuilder { // ----------------------------------- Property ----------------------------------- fun enterProperty(property: FirProperty): PropertyInitializerEnterNode { - graphs.push(ControlFlowGraph("val ${property.name}", ControlFlowGraph.Kind.PropertyInitializer)) + graphs.push(ControlFlowGraph(property, "val ${property.name}", ControlFlowGraph.Kind.PropertyInitializer)) val enterNode = createPropertyInitializerEnterNode(property) val exitNode = createPropertyInitializerExitNode(property) topLevelVariableInitializerExitNodes.push(exitNode) @@ -729,7 +729,7 @@ class ControlFlowGraphBuilder { // ----------------------------------- Block ----------------------------------- fun enterInitBlock(initBlock: FirAnonymousInitializer): InitBlockEnterNode { - graphs.push(ControlFlowGraph("init block", ControlFlowGraph.Kind.ClassInitializer)) + graphs.push(ControlFlowGraph(initBlock, "init block", ControlFlowGraph.Kind.ClassInitializer)) val enterNode = createInitBlockEnterNode(initBlock).also { lexicalScopes.push(stackOf(it)) }