FIR CFA: add control flow between default parameter values

function enter -> default 1 -> default 2 -> rest of function
                   \----------^ \----------^

This probably has no effect (in non-stupid code, at least), but it makes
graph construction more architecturally correct (now value parameters'
subgraphs get attached to a node).
This commit is contained in:
pyos
2022-12-09 13:48:15 +01:00
committed by Dmitriy Novozhilov
parent 74758278d7
commit 5d4fb3ead8
9 changed files with 656 additions and 599 deletions
@@ -27,59 +27,69 @@ digraph defaultArguments_kt {
subgraph cluster_2 { subgraph cluster_2 {
color=red color=red
7 [label="Enter function test" style="filled" fillcolor=red]; 7 [label="Enter function test" style="filled" fillcolor=red];
8 [label="Enter default value of y"];
subgraph cluster_3 { subgraph cluster_3 {
color=blue color=blue
16 [label="Enter default value of z" style="filled" fillcolor=red]; 16 [label="Enter default value of y" style="filled" fillcolor=red];
17 [label="Postponed enter to lambda"]; 17 [label="Access variable R|<local>/x|"];
subgraph cluster_4 { 18 [label="Type operator: (R|<local>/x| as R|kotlin/String|)"];
color=blue 19 [label="Exit default value of y" style="filled" fillcolor=red];
21 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_5 {
color=blue
22 [label="Enter block"];
23 [label="Function call: R|/foo|()" style="filled" fillcolor=yellow];
24 [label="Exit block"];
}
25 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
18 [label="Postponed exit from lambda"];
19 [label="Function call: R|kotlin/run|<R|kotlin/Int|>(...)" style="filled" fillcolor=yellow];
20 [label="Exit default value of z" style="filled" fillcolor=red];
} }
subgraph cluster_6 { 9 [label="Exit default value of y"];
10 [label="Enter default value of z"];
subgraph cluster_4 {
color=blue color=blue
12 [label="Enter default value of y" style="filled" fillcolor=red]; 20 [label="Enter default value of z" style="filled" fillcolor=red];
13 [label="Access variable R|<local>/x|"]; 21 [label="Postponed enter to lambda"];
14 [label="Type operator: (R|<local>/x| as R|kotlin/String|)"]; subgraph cluster_5 {
15 [label="Exit default value of y" style="filled" fillcolor=red]; color=blue
25 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_6 {
color=blue
26 [label="Enter block"];
27 [label="Function call: R|/foo|()" style="filled" fillcolor=yellow];
28 [label="Exit block"];
}
29 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
22 [label="Postponed exit from lambda"];
23 [label="Function call: R|kotlin/run|<R|kotlin/Int|>(...)" style="filled" fillcolor=yellow];
24 [label="Exit default value of z" style="filled" fillcolor=red];
} }
11 [label="Exit default value of z"];
subgraph cluster_7 { subgraph cluster_7 {
color=blue color=blue
8 [label="Enter block"]; 12 [label="Enter block"];
9 [label="Function call: R|/foo|()" style="filled" fillcolor=yellow]; 13 [label="Function call: R|/foo|()" style="filled" fillcolor=yellow];
10 [label="Exit block"]; 14 [label="Exit block"];
} }
11 [label="Exit function test" style="filled" fillcolor=red]; 15 [label="Exit function test" style="filled" fillcolor=red];
} }
7 -> {8 12 16}; 7 -> {8};
8 -> {9}; 8 -> {9 16};
8 -> {16 16} [style=dashed];
9 -> {10}; 9 -> {10};
10 -> {11}; 10 -> {11 20};
10 -> {20 20} [style=dashed];
11 -> {12};
12 -> {13}; 12 -> {13};
12 -> {12} [style=dashed];
13 -> {14}; 13 -> {14};
14 -> {15}; 14 -> {15};
16 -> {17}; 16 -> {17};
16 -> {16} [style=dashed]; 17 -> {18};
17 -> {19 21};
17 -> {18} [style=dotted];
17 -> {21} [style=dashed];
18 -> {19}; 18 -> {19};
19 -> {20}; 19 -> {9};
21 -> {22}; 20 -> {21};
21 -> {23 25};
21 -> {22} [style=dotted];
21 -> {25} [style=dashed];
22 -> {23}; 22 -> {23};
23 -> {24}; 23 -> {24};
24 -> {25}; 24 -> {11};
25 -> {18}; 25 -> {26};
26 -> {27};
27 -> {28};
28 -> {29};
29 -> {22};
} }
@@ -22,26 +22,28 @@ digraph lambdaInWhenBranch_kt {
subgraph cluster_2 { subgraph cluster_2 {
color=red color=red
18 [label="Enter class SubClass1" style="filled" fillcolor=red]; 20 [label="Enter class SubClass1" style="filled" fillcolor=red];
19 [label="Part of class initialization"]; 21 [label="Part of class initialization"];
subgraph cluster_3 { subgraph cluster_3 {
color=blue color=blue
8 [label="Enter property" style="filled" fillcolor=red]; 8 [label="Enter property" style="filled" fillcolor=red];
9 [label="Access variable R|<local>/t|"]; 9 [label="Access variable R|<local>/t|"];
10 [label="Exit property" style="filled" fillcolor=red]; 10 [label="Exit property" style="filled" fillcolor=red];
} }
20 [label="Exit class SubClass1" style="filled" fillcolor=red]; 22 [label="Exit class SubClass1" style="filled" fillcolor=red];
} }
subgraph cluster_4 { subgraph cluster_4 {
color=blue color=blue
13 [label="Enter function copy" style="filled" fillcolor=red]; 13 [label="Enter function copy" style="filled" fillcolor=red];
14 [label="Exit function copy" style="filled" fillcolor=red]; 14 [label="Enter default value of t"];
} subgraph cluster_5 {
subgraph cluster_5 { color=blue
color=blue 17 [label="Enter default value of t" style="filled" fillcolor=red];
15 [label="Enter default value of t" style="filled" fillcolor=red]; 18 [label="Access variable R|/SubClass1.t|"];
16 [label="Access variable R|/SubClass1.t|"]; 19 [label="Exit default value of t" style="filled" fillcolor=red];
17 [label="Exit default value of t" style="filled" fillcolor=red]; }
15 [label="Exit default value of t"];
16 [label="Exit function copy" style="filled" fillcolor=red];
} }
subgraph cluster_6 { subgraph cluster_6 {
color=blue color=blue
@@ -54,174 +56,175 @@ digraph lambdaInWhenBranch_kt {
6 [label="Delegated constructor call: super<R|Sealed|>()" style="filled" fillcolor=yellow]; 6 [label="Delegated constructor call: super<R|Sealed|>()" style="filled" fillcolor=yellow];
7 [label="Exit function <init>" style="filled" fillcolor=red]; 7 [label="Exit function <init>" style="filled" fillcolor=red];
} }
18 -> {19} [color=green]; 20 -> {21} [color=green];
19 -> {8} [color=green]; 21 -> {8} [color=green];
19 -> {20} [style=dotted]; 21 -> {22} [style=dotted];
19 -> {8} [style=dashed]; 21 -> {8} [style=dashed];
20 -> {5 11 13} [color=green]; 22 -> {5 11 13} [color=green];
20 -> {5 11 13} [style=dashed]; 22 -> {5 11 13} [style=dashed];
8 -> {9}; 8 -> {9};
9 -> {10}; 9 -> {10};
10 -> {20} [color=green]; 10 -> {22} [color=green];
5 -> {6}; 5 -> {6};
6 -> {7}; 6 -> {7};
11 -> {12}; 11 -> {12};
13 -> {14 15}; 13 -> {14};
14 -> {15 17};
14 -> {17 17} [style=dashed];
15 -> {16}; 15 -> {16};
15 -> {15} [style=dashed]; 17 -> {18};
16 -> {17}; 18 -> {19};
19 -> {15};
subgraph cluster_8 { subgraph cluster_8 {
color=red color=red
26 [label="Enter class SubClass2" style="filled" fillcolor=red]; 28 [label="Enter class SubClass2" style="filled" fillcolor=red];
27 [label="Exit class SubClass2" style="filled" fillcolor=red]; 29 [label="Exit class SubClass2" style="filled" fillcolor=red];
} }
subgraph cluster_9 { subgraph cluster_9 {
color=blue color=blue
24 [label="Enter function copy" style="filled" fillcolor=red]; 26 [label="Enter function copy" style="filled" fillcolor=red];
25 [label="Exit function copy" style="filled" fillcolor=red]; 27 [label="Exit function copy" style="filled" fillcolor=red];
} }
subgraph cluster_10 { subgraph cluster_10 {
color=blue color=blue
21 [label="Enter function <init>" style="filled" fillcolor=red]; 23 [label="Enter function <init>" style="filled" fillcolor=red];
22 [label="Delegated constructor call: super<R|Sealed|>()" style="filled" fillcolor=yellow]; 24 [label="Delegated constructor call: super<R|Sealed|>()" style="filled" fillcolor=yellow];
23 [label="Exit function <init>" style="filled" fillcolor=red]; 25 [label="Exit function <init>" style="filled" fillcolor=red];
} }
26 -> {27} [color=green]; 28 -> {29} [color=green];
27 -> {21 24} [color=green]; 29 -> {23 26} [color=green];
27 -> {21 24} [style=dashed]; 29 -> {23 26} [style=dashed];
21 -> {22}; 23 -> {24};
22 -> {23};
24 -> {25}; 24 -> {25};
26 -> {27};
subgraph cluster_11 { subgraph cluster_11 {
color=red color=red
28 [label="Enter function foo" style="filled" fillcolor=red]; 30 [label="Enter function foo" style="filled" fillcolor=red];
subgraph cluster_12 { subgraph cluster_12 {
color=blue color=blue
29 [label="Enter block"]; 31 [label="Enter block"];
subgraph cluster_13 { subgraph cluster_13 {
color=blue color=blue
30 [label="Enter when"]; 32 [label="Enter when"];
31 [label="Access variable R|<local>/p|"]; 33 [label="Access variable R|<local>/p|"];
subgraph cluster_14 { subgraph cluster_14 {
color=blue color=blue
32 [label="Enter when branch condition "]; 34 [label="Enter when branch condition "];
33 [label="Exit $subj"]; 35 [label="Exit $subj"];
34 [label="Type operator: ($subj$ is R|SubClass1|)"]; 36 [label="Type operator: ($subj$ is R|SubClass1|)"];
35 [label="Exit when branch condition"]; 37 [label="Exit when branch condition"];
} }
subgraph cluster_15 { subgraph cluster_15 {
color=blue color=blue
36 [label="Enter when branch condition "]; 38 [label="Enter when branch condition "];
37 [label="Exit $subj"]; 39 [label="Exit $subj"];
38 [label="Type operator: ($subj$ is R|SubClass2|)"]; 40 [label="Type operator: ($subj$ is R|SubClass2|)"];
39 [label="Exit when branch condition"]; 41 [label="Exit when branch condition"];
} }
40 [label="Enter when branch result"]; 42 [label="Enter when branch result"];
subgraph cluster_16 { subgraph cluster_16 {
color=blue color=blue
41 [label="Enter block"]; 43 [label="Enter block"];
42 [label="Const: String()"]; 44 [label="Const: String()"];
43 [label="Exit block"]; 45 [label="Exit block"];
} }
44 [label="Exit when branch result"]; 46 [label="Exit when branch result"];
45 [label="Enter when branch result"]; 47 [label="Enter when branch result"];
subgraph cluster_17 { subgraph cluster_17 {
color=blue color=blue
46 [label="Enter block"]; 48 [label="Enter block"];
47 [label="Const: String()"]; 49 [label="Const: String()"];
48 [label="Postponed enter to lambda"]; 50 [label="Postponed enter to lambda"];
subgraph cluster_18 { subgraph cluster_18 {
color=blue color=blue
82 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; 84 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_19 { subgraph cluster_19 {
color=blue color=blue
83 [label="Enter block"]; 85 [label="Enter block"];
84 [label="Access variable R|<local>/it|"]; 86 [label="Access variable R|<local>/it|"];
85 [label="Exit block"]; 87 [label="Exit block"];
} }
86 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; 88 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
} }
49 [label="Postponed exit from lambda"]; 51 [label="Postponed exit from lambda"];
50 [label="Function call: String().R|kotlin/let|<R|kotlin/String|, R|kotlin/String|>(...)" style="filled" fillcolor=yellow]; 52 [label="Function call: String().R|kotlin/let|<R|kotlin/String|, R|kotlin/String|>(...)" style="filled" fillcolor=yellow];
51 [label="Exit block"]; 53 [label="Exit block"];
} }
52 [label="Exit when branch result"]; 54 [label="Exit when branch result"];
53 [label="Exit when"]; 55 [label="Exit when"];
} }
54 [label="Access variable R|<local>/p|"]; 56 [label="Access variable R|<local>/p|"];
55 [label="Access variable <Unresolved name: t>#"]; 57 [label="Access variable <Unresolved name: t>#"];
subgraph cluster_20 { subgraph cluster_20 {
color=blue color=blue
56 [label="Enter when"]; 58 [label="Enter when"];
57 [label="Access variable R|<local>/p|"]; 59 [label="Access variable R|<local>/p|"];
subgraph cluster_21 { subgraph cluster_21 {
color=blue color=blue
58 [label="Enter when branch condition "]; 60 [label="Enter when branch condition "];
59 [label="Exit $subj"]; 61 [label="Exit $subj"];
60 [label="Type operator: ($subj$ is R|SubClass1|)"]; 62 [label="Type operator: ($subj$ is R|SubClass1|)"];
61 [label="Exit when branch condition"]; 63 [label="Exit when branch condition"];
} }
subgraph cluster_22 { subgraph cluster_22 {
color=blue color=blue
62 [label="Enter when branch condition "]; 64 [label="Enter when branch condition "];
63 [label="Exit $subj"]; 65 [label="Exit $subj"];
64 [label="Type operator: ($subj$ is R|SubClass2|)"]; 66 [label="Type operator: ($subj$ is R|SubClass2|)"];
65 [label="Exit when branch condition"]; 67 [label="Exit when branch condition"];
} }
66 [label="Enter when branch result"]; 68 [label="Enter when branch result"];
subgraph cluster_23 { subgraph cluster_23 {
color=blue color=blue
67 [label="Enter block"]; 69 [label="Enter block"];
68 [label="Const: String(2)"]; 70 [label="Const: String(2)"];
69 [label="Exit block"]; 71 [label="Exit block"];
} }
70 [label="Exit when branch result"]; 72 [label="Exit when branch result"];
71 [label="Enter when branch result"]; 73 [label="Enter when branch result"];
subgraph cluster_24 { subgraph cluster_24 {
color=blue color=blue
72 [label="Enter block"]; 74 [label="Enter block"];
73 [label="Access variable R|<local>/p|"]; 75 [label="Access variable R|<local>/p|"];
74 [label="Smart cast: R|<local>/p|"]; 76 [label="Smart cast: R|<local>/p|"];
75 [label="Access variable R|/SubClass1.t|"]; 77 [label="Access variable R|/SubClass1.t|"];
76 [label="Exit block"]; 78 [label="Exit block"];
} }
77 [label="Exit when branch result"]; 79 [label="Exit when branch result"];
78 [label="Exit when"]; 80 [label="Exit when"];
} }
79 [label="Access variable R|kotlin/String.length|"]; 81 [label="Access variable R|kotlin/String.length|"];
80 [label="Exit block"]; 82 [label="Exit block"];
} }
81 [label="Exit function foo" style="filled" fillcolor=red]; 83 [label="Exit function foo" style="filled" fillcolor=red];
} }
28 -> {29};
29 -> {30};
30 -> {31}; 30 -> {31};
31 -> {32}; 31 -> {32};
32 -> {33}; 32 -> {33};
33 -> {34}; 33 -> {34};
34 -> {35}; 34 -> {35};
35 -> {36 45}; 35 -> {36};
36 -> {37}; 36 -> {37};
37 -> {38}; 37 -> {38 47};
38 -> {39}; 38 -> {39};
39 -> {40}; 39 -> {40};
40 -> {41}; 40 -> {41};
41 -> {42}; 41 -> {42};
42 -> {43}; 42 -> {43};
43 -> {44}; 43 -> {44};
44 -> {53}; 44 -> {45};
45 -> {46}; 45 -> {46};
46 -> {47}; 46 -> {55};
47 -> {48}; 47 -> {48};
48 -> {50 82}; 48 -> {49};
48 -> {49} [style=dotted]; 49 -> {50};
48 -> {82} [style=dashed]; 50 -> {52 84};
49 -> {50} [color=green]; 50 -> {51} [style=dotted];
49 -> {53} [color=red]; 50 -> {84} [style=dashed];
50 -> {51}; 51 -> {52} [color=green];
51 -> {52}; 51 -> {55} [color=red];
52 -> {53}; 52 -> {53};
53 -> {54}; 53 -> {54};
54 -> {55}; 54 -> {55};
@@ -231,18 +234,18 @@ digraph lambdaInWhenBranch_kt {
58 -> {59}; 58 -> {59};
59 -> {60}; 59 -> {60};
60 -> {61}; 60 -> {61};
61 -> {62 71}; 61 -> {62};
62 -> {63}; 62 -> {63};
63 -> {64}; 63 -> {64 73};
64 -> {65}; 64 -> {65};
65 -> {66}; 65 -> {66};
66 -> {67}; 66 -> {67};
67 -> {68}; 67 -> {68};
68 -> {69}; 68 -> {69};
69 -> {70}; 69 -> {70};
70 -> {78}; 70 -> {71};
71 -> {72}; 71 -> {72};
72 -> {73}; 72 -> {80};
73 -> {74}; 73 -> {74};
74 -> {75}; 74 -> {75};
75 -> {76}; 75 -> {76};
@@ -251,10 +254,12 @@ digraph lambdaInWhenBranch_kt {
78 -> {79}; 78 -> {79};
79 -> {80}; 79 -> {80};
80 -> {81}; 80 -> {81};
81 -> {82};
82 -> {83}; 82 -> {83};
83 -> {84};
84 -> {85}; 84 -> {85};
85 -> {86}; 85 -> {86};
86 -> {49}; 86 -> {87};
87 -> {88};
88 -> {51};
} }
@@ -252,12 +252,15 @@ abstract class FirDataFlowAnalyzer(
// ----------------------------------- Value parameters (and it's defaults) ----------------------------------- // ----------------------------------- Value parameters (and it's defaults) -----------------------------------
fun enterValueParameter(valueParameter: FirValueParameter) { fun enterValueParameter(valueParameter: FirValueParameter) {
graphBuilder.enterValueParameter(valueParameter)?.mergeIncomingFlow() val (outerNode, innerNode) = graphBuilder.enterValueParameter(valueParameter) ?: return
outerNode.mergeIncomingFlow()
innerNode.mergeIncomingFlow()
} }
fun exitValueParameter(valueParameter: FirValueParameter): ControlFlowGraph? { fun exitValueParameter(valueParameter: FirValueParameter): ControlFlowGraph? {
val (node, graph) = graphBuilder.exitValueParameter(valueParameter) ?: return null val (innerNode, outerNode, graph) = graphBuilder.exitValueParameter(valueParameter) ?: return null
node.mergeIncomingFlow() innerNode.mergeIncomingFlow()
outerNode.mergeIncomingFlow()
return graph return graph
} }
@@ -542,29 +542,35 @@ class ControlFlowGraphBuilder {
// ----------------------------------- Value parameters (and it's defaults) ----------------------------------- // ----------------------------------- Value parameters (and it's defaults) -----------------------------------
fun enterValueParameter(valueParameter: FirValueParameter): EnterDefaultArgumentsNode? { fun enterValueParameter(valueParameter: FirValueParameter): Pair<EnterValueParameterNode, EnterDefaultArgumentsNode>? {
if (valueParameter.defaultValue == null) return null if (valueParameter.defaultValue == null) return null
val outerEnterNode = createEnterValueParameterNode(valueParameter)
val graph = ControlFlowGraph(valueParameter, "default value of ${valueParameter.name}", ControlFlowGraph.Kind.DefaultArgument) val graph = ControlFlowGraph(valueParameter, "default value of ${valueParameter.name}", ControlFlowGraph.Kind.DefaultArgument)
currentGraph.addSubGraph(graph)
pushGraph(graph, Mode.Body) pushGraph(graph, Mode.Body)
val innerExitNode = createExitDefaultArgumentsNode(valueParameter)
createExitDefaultArgumentsNode(valueParameter).also { val innerEnterNode = createEnterDefaultArgumentsNode(valueParameter)
exitTargetsForTry.push(it) addNewSimpleNode(outerEnterNode)
} addEdge(outerEnterNode, innerEnterNode)
lastNodes.push(innerEnterNode)
return createEnterDefaultArgumentsNode(valueParameter).also { exitTargetsForTry.push(innerExitNode)
addEdge(lastNode, it) return outerEnterNode to innerEnterNode
lastNodes.push(it)
}
} }
fun exitValueParameter(valueParameter: FirValueParameter): Pair<ExitDefaultArgumentsNode, ControlFlowGraph>? { fun exitValueParameter(valueParameter: FirValueParameter): Triple<ExitDefaultArgumentsNode, ExitValueParameterNode, ControlFlowGraph>? {
if (valueParameter.defaultValue == null) return null if (valueParameter.defaultValue == null) return null
val exitNode = exitTargetsForTry.pop() as ExitDefaultArgumentsNode val exitNode = exitTargetsForTry.pop() as ExitDefaultArgumentsNode
popAndAddEdge(exitNode) popAndAddEdge(exitNode)
val graph = popGraph() val graph = popGraph()
require(exitNode == graph.exitNode) require(exitNode == graph.exitNode)
return exitNode to graph val outerEnterNode = lastNode as EnterValueParameterNode
val outerExitNode = createExitValueParameterNode(valueParameter)
addNewSimpleNode(outerExitNode)
addEdge(exitNode, outerExitNode, propagateDeadness = false)
outerEnterNode.addSubGraph(graph)
currentGraph.addSubGraph(graph)
return Triple(exitNode, outerExitNode, graph)
} }
// ----------------------------------- Block ----------------------------------- // ----------------------------------- Block -----------------------------------
@@ -256,12 +256,18 @@ fun ControlFlowGraphBuilder.createClassExitNode(fir: FirClass): ClassExitNode =
fun ControlFlowGraphBuilder.createLocalClassExitNode(fir: FirRegularClass): LocalClassExitNode = fun ControlFlowGraphBuilder.createLocalClassExitNode(fir: FirRegularClass): LocalClassExitNode =
LocalClassExitNode(currentGraph, fir, levelCounter, createId()) LocalClassExitNode(currentGraph, fir, levelCounter, createId())
fun ControlFlowGraphBuilder.createEnterValueParameterNode(fir: FirValueParameter): EnterValueParameterNode =
EnterValueParameterNode(currentGraph, fir, levelCounter, createId())
fun ControlFlowGraphBuilder.createEnterDefaultArgumentsNode(fir: FirValueParameter): EnterDefaultArgumentsNode = fun ControlFlowGraphBuilder.createEnterDefaultArgumentsNode(fir: FirValueParameter): EnterDefaultArgumentsNode =
EnterDefaultArgumentsNode(currentGraph, fir, levelCounter, createId()) EnterDefaultArgumentsNode(currentGraph, fir, levelCounter, createId())
fun ControlFlowGraphBuilder.createExitDefaultArgumentsNode(fir: FirValueParameter): ExitDefaultArgumentsNode = fun ControlFlowGraphBuilder.createExitDefaultArgumentsNode(fir: FirValueParameter): ExitDefaultArgumentsNode =
ExitDefaultArgumentsNode(currentGraph, fir, levelCounter, createId()) ExitDefaultArgumentsNode(currentGraph, fir, levelCounter, createId())
fun ControlFlowGraphBuilder.createExitValueParameterNode(fir: FirValueParameter): ExitValueParameterNode =
ExitValueParameterNode(currentGraph, fir, levelCounter, createId())
fun ControlFlowGraphBuilder.createComparisonExpressionNode(fir: FirComparisonExpression): ComparisonExpressionNode = fun ControlFlowGraphBuilder.createComparisonExpressionNode(fir: FirComparisonExpression): ComparisonExpressionNode =
ComparisonExpressionNode(currentGraph, fir, levelCounter, createId()) ComparisonExpressionNode(currentGraph, fir, levelCounter, createId())
@@ -182,8 +182,14 @@ class LocalFunctionDeclarationNode(owner: ControlFlowGraph, override val fir: Fi
// ----------------------------------- Default arguments ----------------------------------- // ----------------------------------- Default arguments -----------------------------------
class EnterValueParameterNode(owner: ControlFlowGraph, override val fir: FirValueParameter, level: Int, id: Int) : CFGNodeWithCfgOwner<FirValueParameter>(owner, level, id) {
override fun <R, D> accept(visitor: ControlFlowGraphVisitor<R, D>, data: D): R {
return visitor.visitEnterValueParameterNode(this, data)
}
}
@OptIn(CfgInternals::class) @OptIn(CfgInternals::class)
class EnterDefaultArgumentsNode(owner: ControlFlowGraph, override val fir: FirValueParameter, level: Int, id: Int) : CFGNodeWithCfgOwner<FirValueParameter>(owner, level, id), class EnterDefaultArgumentsNode(owner: ControlFlowGraph, override val fir: FirValueParameter, level: Int, id: Int) : CFGNode<FirValueParameter>(owner, level, id),
EnterNodeMarker { EnterNodeMarker {
init { init {
owner.enterNode = this owner.enterNode = this
@@ -206,6 +212,12 @@ class ExitDefaultArgumentsNode(owner: ControlFlowGraph, override val fir: FirVal
} }
} }
class ExitValueParameterNode(owner: ControlFlowGraph, override val fir: FirValueParameter, level: Int, id: Int) : CFGNode<FirValueParameter>(owner, level, id) {
override fun <R, D> accept(visitor: ControlFlowGraphVisitor<R, D>, data: D): R {
return visitor.visitExitValueParameterNode(this, data)
}
}
// ----------------------------------- Anonymous function ----------------------------------- // ----------------------------------- Anonymous function -----------------------------------
class SplitPostponedLambdasNode(owner: ControlFlowGraph, override val fir: FirStatement, val lambdas: List<FirAnonymousFunction>, level: Int, id: Int) class SplitPostponedLambdasNode(owner: ControlFlowGraph, override val fir: FirStatement, val lambdas: List<FirAnonymousFunction>, level: Int, id: Int)
@@ -115,8 +115,10 @@ fun CFGNode<*>.render(): String =
is ContractDescriptionEnterNode -> "Enter contract description" is ContractDescriptionEnterNode -> "Enter contract description"
is EnterValueParameterNode -> "Enter default value of ${fir.name}"
is EnterDefaultArgumentsNode -> "Enter default value of ${fir.name}" is EnterDefaultArgumentsNode -> "Enter default value of ${fir.name}"
is ExitDefaultArgumentsNode -> "Exit default value of ${fir.name}" is ExitDefaultArgumentsNode -> "Exit default value of ${fir.name}"
is ExitValueParameterNode -> "Exit default value of ${fir.name}"
is ElvisLhsExitNode -> "Exit lhs of ?:" is ElvisLhsExitNode -> "Exit lhs of ?:"
is ElvisLhsIsNotNullNode -> "Lhs of ?: is not null" is ElvisLhsIsNotNullNode -> "Lhs of ?: is not null"
@@ -26,7 +26,7 @@ abstract class ControlFlowGraphVisitor<out R, in D> {
// ----------------------------------- Default arguments ----------------------------------- // ----------------------------------- Default arguments -----------------------------------
open fun visitExitDefaultArgumentsNode(node: ExitDefaultArgumentsNode, data: D): R { open fun visitEnterValueParameterNode(node: EnterValueParameterNode, data: D): R {
return visitNode(node, data) return visitNode(node, data)
} }
@@ -34,6 +34,14 @@ abstract class ControlFlowGraphVisitor<out R, in D> {
return visitNode(node, data) return visitNode(node, data)
} }
open fun visitExitDefaultArgumentsNode(node: ExitDefaultArgumentsNode, data: D): R {
return visitNode(node, data)
}
open fun visitExitValueParameterNode(node: ExitValueParameterNode, data: D): R {
return visitNode(node, data)
}
// ----------------------------------- Anonymous function ----------------------------------- // ----------------------------------- Anonymous function -----------------------------------
open fun visitSplitPostponedLambdasNode(node: SplitPostponedLambdasNode, data: D): R { open fun visitSplitPostponedLambdasNode(node: SplitPostponedLambdasNode, data: D): R {
File diff suppressed because it is too large Load Diff