[FIR] Create separated FirBlock for loop local val

Refactor FIR builders code for ForExpression
This commit is contained in:
Ivan Kochurkin
2022-12-05 18:02:22 +01:00
committed by Space Team
parent e49bb1fe37
commit a3e7a35cb1
30 changed files with 1426 additions and 1222 deletions
@@ -24,6 +24,9 @@ FILE: components.kt
lval <destruct>: R|D| = R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|D|>|()
lval x: R|kotlin/Int| = R|<local>/<destruct>|.R|/D.component1|()
lval y: R|kotlin/String| = R|<local>/<destruct>|.R|/D.component2|()
{
}
}
}
@@ -167,49 +167,54 @@ digraph flow_kt {
74 [label="Access variable R|<local>/<iterator>|"];
75 [label="Function call: R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()" style="filled" fillcolor=yellow];
76 [label="Variable declaration: lval i: R|kotlin/Int|"];
77 [label="Access variable R|<local>/x|"];
78 [label="Function call: R|<local>/x|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()" style="filled" fillcolor=yellow];
79 [label="Exit block"];
subgraph cluster_24 {
color=blue
77 [label="Enter block"];
78 [label="Access variable R|<local>/x|"];
79 [label="Function call: R|<local>/x|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()" style="filled" fillcolor=yellow];
80 [label="Exit block"];
}
81 [label="Exit block"];
}
80 [label="Exit loop block"];
82 [label="Exit loop block"];
}
81 [label="Exit while loop"];
83 [label="Exit while loop"];
}
82 [label="Exit block"];
84 [label="Exit block"];
}
83 [label="Access variable R|<local>/y|"];
84 [label="Function call: R|<local>/y|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()" style="filled" fillcolor=yellow];
85 [label="Exit block"];
85 [label="Access variable R|<local>/y|"];
86 [label="Function call: R|<local>/y|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()" style="filled" fillcolor=yellow];
87 [label="Exit block"];
}
86 [label="Exit when branch result"];
87 [label="Exit when"];
88 [label="Exit when branch result"];
89 [label="Exit when"];
}
subgraph cluster_24 {
subgraph cluster_25 {
color=blue
88 [label="Enter do-while loop"];
subgraph cluster_25 {
90 [label="Enter do-while loop"];
subgraph cluster_26 {
color=blue
89 [label="Enter loop block"];
subgraph cluster_26 {
91 [label="Enter loop block"];
subgraph cluster_27 {
color=blue
90 [label="Enter block"];
91 [label="Access variable R|<local>/z|"];
92 [label="Function call: R|/bar|(...)" style="filled" fillcolor=yellow];
93 [label="Exit block"];
92 [label="Enter block"];
93 [label="Access variable R|<local>/z|"];
94 [label="Function call: R|/bar|(...)" style="filled" fillcolor=yellow];
95 [label="Exit block"];
}
94 [label="Exit loop block"];
96 [label="Exit loop block"];
}
subgraph cluster_27 {
subgraph cluster_28 {
color=blue
95 [label="Enter loop condition"];
96 [label="Const: Boolean(true)"];
97 [label="Exit loop condition"];
97 [label="Enter loop condition"];
98 [label="Const: Boolean(true)"];
99 [label="Exit loop condition"];
}
98 [label="Exit do-while loop" style="filled" fillcolor=gray];
100 [label="Exit do-while loop" style="filled" fillcolor=gray];
}
99 [label="Exit block" style="filled" fillcolor=gray];
101 [label="Exit block" style="filled" fillcolor=gray];
}
100 [label="Exit function foo" style="filled" fillcolor=red];
102 [label="Exit function foo" style="filled" fillcolor=red];
}
22 -> {23};
23 -> {24};
@@ -235,7 +240,7 @@ digraph flow_kt {
43 -> {44};
44 -> {45};
45 -> {46};
46 -> {100};
46 -> {102};
46 -> {47} [style=dotted];
47 -> {48} [style=dotted];
48 -> {49} [style=dotted];
@@ -248,7 +253,7 @@ digraph flow_kt {
55 -> {56};
56 -> {57};
57 -> {58};
58 -> {87};
58 -> {89};
59 -> {60};
60 -> {61};
61 -> {62};
@@ -261,7 +266,7 @@ digraph flow_kt {
68 -> {69};
69 -> {70};
70 -> {71};
71 -> {72 81};
71 -> {72 83};
72 -> {73};
73 -> {74};
74 -> {75};
@@ -270,9 +275,9 @@ digraph flow_kt {
77 -> {78};
78 -> {79};
79 -> {80};
80 -> {68} [color=green style=dashed];
80 -> {81};
81 -> {82};
82 -> {83};
82 -> {68} [color=green style=dashed];
83 -> {84};
84 -> {85};
85 -> {86};
@@ -287,9 +292,11 @@ digraph flow_kt {
94 -> {95};
95 -> {96};
96 -> {97};
97 -> {89} [color=green style=dashed];
97 -> {98} [style=dotted];
98 -> {99} [style=dotted];
97 -> {98};
98 -> {99};
99 -> {91} [color=green style=dashed];
99 -> {100} [style=dotted];
100 -> {101} [style=dotted];
101 -> {102} [style=dotted];
}
@@ -44,7 +44,10 @@ FILE: flow.kt
lval <iterator>: R|kotlin/collections/IntIterator| = Int(0).R|kotlin/Int.rangeTo|(Int(0)).R|kotlin/ranges/IntProgression.iterator|()
while(R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/IntIterator.hasNext: R|kotlin/Boolean|>|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()
R|<local>/x|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
{
R|<local>/x|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()
}
}
}
@@ -175,6 +175,9 @@ FILE: forLoopChecker.kt
lval <iterator>: <ERROR TYPE REF: Unresolved name: iterator> = R|<local>/notRange1|.<Unresolved name: iterator>#()
while(R|<local>/<iterator>|.<Unresolved name: hasNext>#()) {
lval i: <ERROR TYPE REF: Unresolved name: next> = R|<local>/<iterator>|.<Unresolved name: next>#()
{
}
}
}
@@ -183,6 +186,9 @@ FILE: forLoopChecker.kt
lval <iterator>: R|kotlin/Unit| = R|<local>/notRange2|.R|/NotRange2.iterator|()
while(R|<local>/<iterator>|.<Unresolved name: hasNext>#()) {
lval i: <ERROR TYPE REF: Unresolved name: next> = R|<local>/<iterator>|.<Unresolved name: next>#()
{
}
}
}
@@ -191,6 +197,9 @@ FILE: forLoopChecker.kt
lval <iterator>: R|ImproperIterator1| = R|<local>/notRange3|.R|/NotRange3.iterator|()
while(R|<local>/<iterator>|.R|/ImproperIterator1.hasNext|()) {
lval i: <ERROR TYPE REF: Unresolved name: next> = R|<local>/<iterator>|.<Unresolved name: next>#()
{
}
}
}
@@ -199,6 +208,9 @@ FILE: forLoopChecker.kt
lval <iterator>: R|ImproperIterator2| = R|<local>/notRange4|.R|/NotRange4.iterator|()
while(R|<local>/<iterator>|.<Unresolved name: hasNext>#()) {
lval i: R|kotlin/Boolean| = R|<local>/<iterator>|.R|/ImproperIterator2.next|()
{
}
}
}
@@ -207,6 +219,9 @@ FILE: forLoopChecker.kt
lval <iterator>: R|ImproperIterator3| = R|<local>/notRange5|.R|/NotRange5.iterator|()
while(R|<local>/<iterator>|.R|/ImproperIterator3.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/ImproperIterator3.next|()
{
}
}
}
@@ -215,6 +230,9 @@ FILE: forLoopChecker.kt
lval <iterator>: R|AmbiguousHasNextIterator| = R|<local>/notRange6|.R|/NotRange6.iterator|()
while(R|<local>/<iterator>|.R|/AmbiguousHasNextIterator.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/AmbiguousHasNextIterator.next|()
{
}
}
}
@@ -223,6 +241,9 @@ FILE: forLoopChecker.kt
lval <iterator>: R|ImproperIterator3| = R|<local>/notRange7|.R|/NotRange7.iterator|()
while(R|<local>/<iterator>|.R|/ImproperIterator3.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/ImproperIterator3.next|()
{
}
}
}
@@ -231,6 +252,9 @@ FILE: forLoopChecker.kt
lval <iterator>: R|ImproperIterator5| = R|<local>/notRange8|.R|/NotRange8.iterator|()
while(R|<local>/<iterator>|.<Unresolved name: hasNext>#()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/ImproperIterator5.next|()
{
}
}
}
@@ -239,6 +263,9 @@ FILE: forLoopChecker.kt
lval <iterator>: R|ImproperIterator6| = R|<local>/notRange9|.R|/NotRange9.iterator|()
while(R|<local>/<iterator>|.R|/ImproperIterator6.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/ImproperIterator6.next|()
{
}
}
}
@@ -247,6 +274,9 @@ FILE: forLoopChecker.kt
lval <iterator>: R|GoodIterator| = R|<local>/range0|.R|/Range0.iterator|()
while(R|<local>/<iterator>|.R|/GoodIterator.hasNext|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|/GoodIterator.next|()
{
}
}
}
@@ -255,6 +285,9 @@ FILE: forLoopChecker.kt
lval <iterator>: R|kotlin/collections/Iterator<kotlin/Int>| = R|<local>/range1|.R|/Range1.iterator|()
while(R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.hasNext: R|kotlin/Boolean|>|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|kotlin/Int|>|()
{
}
}
}
@@ -48,10 +48,13 @@ FILE: DeepCopyIrTree.kt
lval <destruct>: R|kotlin/Pair<IrTypeParameter, IrTypeParameter>| = R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|kotlin/Pair<IrTypeParameter, IrTypeParameter>|>|()
lval thisTypeParameter: R|IrTypeParameter| = R|<local>/<destruct>|.R|SubstitutionOverride<kotlin/Pair.component1: R|IrTypeParameter|>|()
lval otherTypeParameter: R|IrTypeParameter| = R|<local>/<destruct>|.R|SubstitutionOverride<kotlin/Pair.component2: R|IrTypeParameter|>|()
R|<local>/otherTypeParameter|.R|/IrTypeParameter.superTypes|.R|kotlin/collections/mapTo|<R|IrType|, R|IrType|, R|kotlin/collections/MutableList<IrType>|>(R|<local>/thisTypeParameter|.R|/IrTypeParameter.superTypes|, <L> = mapTo@fun <anonymous>(it: R|IrType|): R|IrType| <inline=Inline, kind=UNKNOWN> {
^ this@R|/DeepCopyIrTreeWithSymbols|.R|/DeepCopyIrTreeWithSymbols.typeRemapper|.R|/TypeRemapper.remapType|(R|<local>/it|)
{
R|<local>/otherTypeParameter|.R|/IrTypeParameter.superTypes|.R|kotlin/collections/mapTo|<R|IrType|, R|IrType|, R|kotlin/collections/MutableList<IrType>|>(R|<local>/thisTypeParameter|.R|/IrTypeParameter.superTypes|, <L> = mapTo@fun <anonymous>(it: R|IrType|): R|IrType| <inline=Inline, kind=UNKNOWN> {
^ this@R|/DeepCopyIrTreeWithSymbols|.R|/DeepCopyIrTreeWithSymbols.typeRemapper|.R|/TypeRemapper.remapType|(R|<local>/it|)
}
)
}
)
}
}
@@ -51,10 +51,13 @@ FILE: valueOfOrNull.kt
lval <iterator>: R|kotlin/collections/Iterator<E>| = R|kotlin/enumValues|<R|E|>().R|SubstitutionOverride<kotlin/Array.iterator: R|kotlin/collections/Iterator<E>|>|()
while(R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.hasNext: R|kotlin/Boolean|>|()) {
lval enumValue: R|E| = R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|E|>|()
when () {
==(R|<local>/enumValue|.R|SubstitutionOverride<kotlin/Enum.name: R|kotlin/String|>|, R|<local>/value|) -> {
^valueOfOrNull R|<local>/enumValue|
{
when () {
==(R|<local>/enumValue|.R|SubstitutionOverride<kotlin/Enum.name: R|kotlin/String|>|, R|<local>/value|) -> {
^valueOfOrNull R|<local>/enumValue|
}
}
}
}