FIR DFA: split flow for postponed lambdas from a single node
This removes the need for hacks around the order in which function call arguments are visited, fixes called-in-place lambda arguments for augmented assignment operators, and makes CFG dumps a bit prettier.
This commit is contained in:
+431
-463
File diff suppressed because it is too large
Load Diff
+34
-36
@@ -5,26 +5,26 @@ digraph lambdaAsReturnOfLambda_kt {
|
|||||||
|
|
||||||
subgraph cluster_0 {
|
subgraph cluster_0 {
|
||||||
color=red
|
color=red
|
||||||
14 [label="Enter property" style="filled" fillcolor=red];
|
13 [label="Enter property" style="filled" fillcolor=red];
|
||||||
15 [label="Postponed enter to lambda"];
|
14 [label="Postponed enter to lambda"];
|
||||||
subgraph cluster_1 {
|
subgraph cluster_1 {
|
||||||
color=blue
|
color=blue
|
||||||
0 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
0 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||||
subgraph cluster_2 {
|
subgraph cluster_2 {
|
||||||
color=blue
|
color=blue
|
||||||
1 [label="Enter block"];
|
1 [label="Enter block"];
|
||||||
2 [label="Postponed enter to lambda"];
|
2 [label="Exit anonymous function expression"];
|
||||||
subgraph cluster_3 {
|
subgraph cluster_3 {
|
||||||
color=blue
|
color=blue
|
||||||
8 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
7 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||||
subgraph cluster_4 {
|
subgraph cluster_4 {
|
||||||
color=blue
|
color=blue
|
||||||
9 [label="Enter block"];
|
8 [label="Enter block"];
|
||||||
10 [label="Access variable R|<local>/foo|"];
|
9 [label="Access variable R|<local>/foo|"];
|
||||||
11 [label="Function call: R|/bar|(...)" style="filled" fillcolor=yellow];
|
10 [label="Function call: R|/bar|(...)" style="filled" fillcolor=yellow];
|
||||||
12 [label="Exit block"];
|
11 [label="Exit block"];
|
||||||
}
|
}
|
||||||
13 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
12 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
3 [label="Jump: ^@run lambda@fun <anonymous>(foo: R|kotlin/String|): R|kotlin/Unit| <inline=Unknown> {
|
3 [label="Jump: ^@run lambda@fun <anonymous>(foo: R|kotlin/String|): R|kotlin/Unit| <inline=Unknown> {
|
||||||
R|/bar|(R|<local>/foo|)
|
R|/bar|(R|<local>/foo|)
|
||||||
@@ -35,64 +35,62 @@ digraph lambdaAsReturnOfLambda_kt {
|
|||||||
}
|
}
|
||||||
6 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
6 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
7 [label="Postponed exit from lambda"];
|
15 [label="Postponed exit from lambda"];
|
||||||
16 [label="Postponed exit from lambda"];
|
16 [label="Function call: R|/run|<R|(kotlin/String) -> kotlin/Unit|>(...)" style="filled" fillcolor=yellow];
|
||||||
17 [label="Function call: R|/run|<R|(kotlin/String) -> kotlin/Unit|>(...)" style="filled" fillcolor=yellow];
|
17 [label="Exit property" style="filled" fillcolor=red];
|
||||||
18 [label="Exit property" style="filled" fillcolor=red];
|
|
||||||
}
|
}
|
||||||
14 -> {15};
|
13 -> {14};
|
||||||
15 -> {16 0 17};
|
14 -> {15 0 16};
|
||||||
15 -> {0} [style=dashed];
|
14 -> {0} [style=dashed];
|
||||||
|
15 -> {16};
|
||||||
16 -> {17};
|
16 -> {17};
|
||||||
17 -> {18};
|
|
||||||
0 -> {1};
|
0 -> {1};
|
||||||
1 -> {2};
|
1 -> {2};
|
||||||
2 -> {7 3 8};
|
2 -> {3 7};
|
||||||
2 -> {8} [style=dashed];
|
2 -> {7} [style=dashed];
|
||||||
3 -> {6};
|
3 -> {6};
|
||||||
3 -> {4} [style=dotted];
|
3 -> {4} [style=dotted];
|
||||||
4 -> {5} [style=dotted];
|
4 -> {5} [style=dotted];
|
||||||
5 -> {6} [style=dotted];
|
5 -> {6} [style=dotted];
|
||||||
7 -> {17};
|
7 -> {8};
|
||||||
8 -> {9};
|
8 -> {9};
|
||||||
9 -> {10};
|
9 -> {10};
|
||||||
10 -> {11};
|
10 -> {11};
|
||||||
11 -> {12};
|
11 -> {12};
|
||||||
12 -> {13};
|
|
||||||
|
|
||||||
subgraph cluster_5 {
|
subgraph cluster_5 {
|
||||||
color=red
|
color=red
|
||||||
19 [label="Enter function bar" style="filled" fillcolor=red];
|
18 [label="Enter function bar" style="filled" fillcolor=red];
|
||||||
subgraph cluster_6 {
|
subgraph cluster_6 {
|
||||||
color=blue
|
color=blue
|
||||||
20 [label="Enter block"];
|
19 [label="Enter block"];
|
||||||
21 [label="Exit block"];
|
20 [label="Exit block"];
|
||||||
}
|
}
|
||||||
22 [label="Exit function bar" style="filled" fillcolor=red];
|
21 [label="Exit function bar" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
|
18 -> {19};
|
||||||
19 -> {20};
|
19 -> {20};
|
||||||
20 -> {21};
|
20 -> {21};
|
||||||
21 -> {22};
|
|
||||||
|
|
||||||
subgraph cluster_7 {
|
subgraph cluster_7 {
|
||||||
color=red
|
color=red
|
||||||
23 [label="Enter function run" style="filled" fillcolor=red];
|
22 [label="Enter function run" style="filled" fillcolor=red];
|
||||||
subgraph cluster_8 {
|
subgraph cluster_8 {
|
||||||
color=blue
|
color=blue
|
||||||
24 [label="Enter block"];
|
23 [label="Enter block"];
|
||||||
25 [label="Function call: R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|R|>|()" style="filled" fillcolor=yellow];
|
24 [label="Function call: R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|R|>|()" style="filled" fillcolor=yellow];
|
||||||
26 [label="Jump: ^run R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|R|>|()"];
|
25 [label="Jump: ^run R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|R|>|()"];
|
||||||
27 [label="Stub" style="filled" fillcolor=gray];
|
26 [label="Stub" style="filled" fillcolor=gray];
|
||||||
28 [label="Exit block" style="filled" fillcolor=gray];
|
27 [label="Exit block" style="filled" fillcolor=gray];
|
||||||
}
|
}
|
||||||
29 [label="Exit function run" style="filled" fillcolor=red];
|
28 [label="Exit function run" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
|
22 -> {23};
|
||||||
23 -> {24};
|
23 -> {24};
|
||||||
24 -> {25};
|
24 -> {25};
|
||||||
25 -> {26};
|
25 -> {28};
|
||||||
26 -> {29};
|
25 -> {26} [style=dotted];
|
||||||
26 -> {27} [style=dotted];
|
26 -> {27} [style=dotted];
|
||||||
27 -> {28} [style=dotted];
|
27 -> {28} [style=dotted];
|
||||||
28 -> {29} [style=dotted];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+83
-85
@@ -113,30 +113,29 @@ digraph lambdas_kt {
|
|||||||
subgraph cluster_13 {
|
subgraph cluster_13 {
|
||||||
color=blue
|
color=blue
|
||||||
39 [label="Enter block"];
|
39 [label="Enter block"];
|
||||||
40 [label="Local function declaration test_2"];
|
40 [label="Exit anonymous function expression"];
|
||||||
41 [label="Exit anonymous function expression"];
|
41 [label="Variable declaration: lval lambda: R|() -> kotlin/Int|"];
|
||||||
42 [label="Variable declaration: lval lambda: R|() -> kotlin/Int|"];
|
42 [label="Exit block"];
|
||||||
43 [label="Exit block"];
|
|
||||||
}
|
}
|
||||||
44 [label="Exit when branch result"];
|
43 [label="Exit when branch result"];
|
||||||
45 [label="Exit when"];
|
44 [label="Exit when"];
|
||||||
}
|
}
|
||||||
46 [label="Exit block"];
|
45 [label="Exit block"];
|
||||||
}
|
}
|
||||||
47 [label="Exit function test_2" style="filled" fillcolor=red];
|
46 [label="Exit function test_2" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
subgraph cluster_14 {
|
subgraph cluster_14 {
|
||||||
color=blue
|
color=blue
|
||||||
48 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
47 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||||
subgraph cluster_15 {
|
subgraph cluster_15 {
|
||||||
color=blue
|
color=blue
|
||||||
49 [label="Enter block"];
|
48 [label="Enter block"];
|
||||||
50 [label="Access variable R|<local>/x|"];
|
49 [label="Access variable R|<local>/x|"];
|
||||||
51 [label="Smart cast: R|<local>/x|"];
|
50 [label="Smart cast: R|<local>/x|"];
|
||||||
52 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()" style="filled" fillcolor=yellow];
|
51 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()" style="filled" fillcolor=yellow];
|
||||||
53 [label="Exit block"];
|
52 [label="Exit block"];
|
||||||
}
|
}
|
||||||
54 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
53 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
30 -> {31};
|
30 -> {31};
|
||||||
31 -> {32};
|
31 -> {32};
|
||||||
@@ -145,147 +144,146 @@ digraph lambdas_kt {
|
|||||||
34 -> {35};
|
34 -> {35};
|
||||||
35 -> {36};
|
35 -> {36};
|
||||||
36 -> {38 37};
|
36 -> {38 37};
|
||||||
37 -> {45};
|
37 -> {44};
|
||||||
38 -> {39};
|
38 -> {39};
|
||||||
39 -> {40};
|
39 -> {40};
|
||||||
40 -> {48 41};
|
40 -> {47 41};
|
||||||
40 -> {48} [style=dashed];
|
40 -> {47} [style=dashed];
|
||||||
41 -> {42};
|
41 -> {42};
|
||||||
42 -> {43};
|
42 -> {43};
|
||||||
43 -> {44};
|
43 -> {44};
|
||||||
44 -> {45};
|
44 -> {45};
|
||||||
45 -> {46};
|
45 -> {46};
|
||||||
46 -> {47};
|
47 -> {48};
|
||||||
48 -> {49};
|
48 -> {49};
|
||||||
49 -> {50};
|
49 -> {50};
|
||||||
50 -> {51};
|
50 -> {51};
|
||||||
51 -> {52};
|
51 -> {52};
|
||||||
52 -> {53};
|
52 -> {53};
|
||||||
53 -> {54};
|
|
||||||
|
|
||||||
subgraph cluster_16 {
|
subgraph cluster_16 {
|
||||||
color=red
|
color=red
|
||||||
55 [label="Enter function getInt" style="filled" fillcolor=red];
|
54 [label="Enter function getInt" style="filled" fillcolor=red];
|
||||||
subgraph cluster_17 {
|
subgraph cluster_17 {
|
||||||
color=blue
|
color=blue
|
||||||
56 [label="Enter block"];
|
55 [label="Enter block"];
|
||||||
57 [label="Function call: R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()" style="filled" fillcolor=yellow];
|
56 [label="Function call: R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()" style="filled" fillcolor=yellow];
|
||||||
58 [label="Const: Int(1)"];
|
57 [label="Const: Int(1)"];
|
||||||
59 [label="Jump: ^getInt Int(1)"];
|
58 [label="Jump: ^getInt Int(1)"];
|
||||||
60 [label="Stub" style="filled" fillcolor=gray];
|
59 [label="Stub" style="filled" fillcolor=gray];
|
||||||
61 [label="Exit block" style="filled" fillcolor=gray];
|
60 [label="Exit block" style="filled" fillcolor=gray];
|
||||||
}
|
}
|
||||||
62 [label="Exit function getInt" style="filled" fillcolor=red];
|
61 [label="Exit function getInt" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
|
54 -> {55};
|
||||||
55 -> {56};
|
55 -> {56};
|
||||||
56 -> {57};
|
56 -> {57};
|
||||||
57 -> {58};
|
57 -> {58};
|
||||||
58 -> {59};
|
58 -> {61};
|
||||||
59 -> {62};
|
58 -> {59} [style=dotted];
|
||||||
59 -> {60} [style=dotted];
|
59 -> {60} [style=dotted];
|
||||||
60 -> {61} [style=dotted];
|
60 -> {61} [style=dotted];
|
||||||
61 -> {62} [style=dotted];
|
|
||||||
|
|
||||||
subgraph cluster_18 {
|
subgraph cluster_18 {
|
||||||
color=red
|
color=red
|
||||||
63 [label="Enter function test_3" style="filled" fillcolor=red];
|
62 [label="Enter function test_3" style="filled" fillcolor=red];
|
||||||
subgraph cluster_19 {
|
subgraph cluster_19 {
|
||||||
color=blue
|
color=blue
|
||||||
64 [label="Enter block"];
|
63 [label="Enter block"];
|
||||||
65 [label="Postponed enter to lambda"];
|
64 [label="Postponed enter to lambda"];
|
||||||
subgraph cluster_20 {
|
subgraph cluster_20 {
|
||||||
color=blue
|
color=blue
|
||||||
72 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
71 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||||
subgraph cluster_21 {
|
subgraph cluster_21 {
|
||||||
color=blue
|
color=blue
|
||||||
73 [label="Enter block"];
|
72 [label="Enter block"];
|
||||||
74 [label="Const: Int(1)"];
|
73 [label="Const: Int(1)"];
|
||||||
75 [label="Jump: ^test_3 Int(1)"];
|
74 [label="Jump: ^test_3 Int(1)"];
|
||||||
76 [label="Stub" style="filled" fillcolor=gray];
|
75 [label="Stub" style="filled" fillcolor=gray];
|
||||||
77 [label="Exit block" style="filled" fillcolor=gray];
|
76 [label="Exit block" style="filled" fillcolor=gray];
|
||||||
}
|
}
|
||||||
78 [label="Exit function anonymousFunction" style="filled" fillcolor=red style="filled" fillcolor=gray];
|
77 [label="Exit function anonymousFunction" style="filled" fillcolor=red style="filled" fillcolor=gray];
|
||||||
}
|
}
|
||||||
66 [label="Postponed exit from lambda"];
|
65 [label="Postponed exit from lambda"];
|
||||||
67 [label="Function call: R|/getInt|(...)" style="filled" fillcolor=yellow];
|
66 [label="Function call: R|/getInt|(...)" style="filled" fillcolor=yellow];
|
||||||
68 [label="Jump: ^test_3 R|/getInt|(<L> = getInt@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
|
67 [label="Jump: ^test_3 R|/getInt|(<L> = getInt@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
|
||||||
^test_3 Int(1)
|
^test_3 Int(1)
|
||||||
}
|
}
|
||||||
)"];
|
)"];
|
||||||
69 [label="Stub" style="filled" fillcolor=gray];
|
68 [label="Stub" style="filled" fillcolor=gray];
|
||||||
70 [label="Exit block" style="filled" fillcolor=gray];
|
69 [label="Exit block" style="filled" fillcolor=gray];
|
||||||
}
|
}
|
||||||
71 [label="Exit function test_3" style="filled" fillcolor=red];
|
70 [label="Exit function test_3" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
|
62 -> {63};
|
||||||
63 -> {64};
|
63 -> {64};
|
||||||
64 -> {65};
|
64 -> {65 71 66};
|
||||||
65 -> {66 72 67};
|
64 -> {71} [style=dashed];
|
||||||
65 -> {72} [style=dashed];
|
65 -> {66};
|
||||||
|
65 -> {64} [color=green style=dashed];
|
||||||
66 -> {67};
|
66 -> {67};
|
||||||
66 -> {65} [color=green style=dashed];
|
67 -> {70};
|
||||||
67 -> {68};
|
67 -> {68} [style=dotted];
|
||||||
68 -> {71};
|
|
||||||
68 -> {69} [style=dotted];
|
68 -> {69} [style=dotted];
|
||||||
69 -> {70} [style=dotted];
|
69 -> {70} [style=dotted];
|
||||||
70 -> {71} [style=dotted];
|
71 -> {72};
|
||||||
72 -> {73};
|
72 -> {73};
|
||||||
73 -> {74};
|
73 -> {74};
|
||||||
74 -> {75};
|
74 -> {70};
|
||||||
75 -> {71};
|
74 -> {75} [style=dotted];
|
||||||
75 -> {76} [style=dotted];
|
75 -> {76} [style=dotted];
|
||||||
76 -> {77} [style=dotted];
|
76 -> {77} [style=dotted];
|
||||||
77 -> {78} [style=dotted];
|
77 -> {65} [style=dotted];
|
||||||
78 -> {66} [style=dotted];
|
|
||||||
|
|
||||||
subgraph cluster_22 {
|
subgraph cluster_22 {
|
||||||
color=red
|
color=red
|
||||||
79 [label="Enter function test_4" style="filled" fillcolor=red];
|
78 [label="Enter function test_4" style="filled" fillcolor=red];
|
||||||
subgraph cluster_23 {
|
subgraph cluster_23 {
|
||||||
color=blue
|
color=blue
|
||||||
80 [label="Enter block"];
|
79 [label="Enter block"];
|
||||||
81 [label="Postponed enter to lambda"];
|
80 [label="Postponed enter to lambda"];
|
||||||
subgraph cluster_24 {
|
subgraph cluster_24 {
|
||||||
color=blue
|
color=blue
|
||||||
88 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
87 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||||
subgraph cluster_25 {
|
subgraph cluster_25 {
|
||||||
color=blue
|
color=blue
|
||||||
89 [label="Enter block"];
|
88 [label="Enter block"];
|
||||||
90 [label="Const: Int(1)"];
|
89 [label="Const: Int(1)"];
|
||||||
91 [label="Jump: ^test_4 Int(1)"];
|
90 [label="Jump: ^test_4 Int(1)"];
|
||||||
92 [label="Stub" style="filled" fillcolor=gray];
|
91 [label="Stub" style="filled" fillcolor=gray];
|
||||||
93 [label="Exit block" style="filled" fillcolor=gray];
|
92 [label="Exit block" style="filled" fillcolor=gray];
|
||||||
}
|
}
|
||||||
94 [label="Exit function anonymousFunction" style="filled" fillcolor=red style="filled" fillcolor=gray];
|
93 [label="Exit function anonymousFunction" style="filled" fillcolor=red style="filled" fillcolor=gray];
|
||||||
}
|
}
|
||||||
82 [label="Postponed exit from lambda"];
|
81 [label="Postponed exit from lambda"];
|
||||||
83 [label="Function call: R|/getInt|(...)" style="filled" fillcolor=yellow];
|
82 [label="Function call: R|/getInt|(...)" style="filled" fillcolor=yellow];
|
||||||
84 [label="Jump: ^test_4 R|/getInt|(block = getInt@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
|
83 [label="Jump: ^test_4 R|/getInt|(block = getInt@fun <anonymous>(): R|kotlin/Unit| <inline=Inline, kind=UNKNOWN> {
|
||||||
^test_4 Int(1)
|
^test_4 Int(1)
|
||||||
}
|
}
|
||||||
)"];
|
)"];
|
||||||
85 [label="Stub" style="filled" fillcolor=gray];
|
84 [label="Stub" style="filled" fillcolor=gray];
|
||||||
86 [label="Exit block" style="filled" fillcolor=gray];
|
85 [label="Exit block" style="filled" fillcolor=gray];
|
||||||
}
|
}
|
||||||
87 [label="Exit function test_4" style="filled" fillcolor=red];
|
86 [label="Exit function test_4" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
|
78 -> {79};
|
||||||
79 -> {80};
|
79 -> {80};
|
||||||
80 -> {81};
|
80 -> {81 87 82};
|
||||||
81 -> {82 88 83};
|
80 -> {87} [style=dashed];
|
||||||
81 -> {88} [style=dashed];
|
81 -> {82};
|
||||||
|
81 -> {80} [color=green style=dashed];
|
||||||
82 -> {83};
|
82 -> {83};
|
||||||
82 -> {81} [color=green style=dashed];
|
83 -> {86};
|
||||||
83 -> {84};
|
83 -> {84} [style=dotted];
|
||||||
84 -> {87};
|
|
||||||
84 -> {85} [style=dotted];
|
84 -> {85} [style=dotted];
|
||||||
85 -> {86} [style=dotted];
|
85 -> {86} [style=dotted];
|
||||||
86 -> {87} [style=dotted];
|
87 -> {88};
|
||||||
88 -> {89};
|
88 -> {89};
|
||||||
89 -> {90};
|
89 -> {90};
|
||||||
90 -> {91};
|
90 -> {86};
|
||||||
91 -> {87};
|
90 -> {91} [style=dotted];
|
||||||
91 -> {92} [style=dotted];
|
91 -> {92} [style=dotted];
|
||||||
92 -> {93} [style=dotted];
|
92 -> {93} [style=dotted];
|
||||||
93 -> {94} [style=dotted];
|
93 -> {81} [style=dotted];
|
||||||
94 -> {82} [style=dotted];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-30
@@ -30,23 +30,22 @@ digraph postponedLambdaInConstructor_kt {
|
|||||||
subgraph cluster_4 {
|
subgraph cluster_4 {
|
||||||
color=blue
|
color=blue
|
||||||
13 [label="Enter block"];
|
13 [label="Enter block"];
|
||||||
14 [label="Postponed enter to lambda"];
|
14 [label="Exit anonymous function expression"];
|
||||||
subgraph cluster_5 {
|
subgraph cluster_5 {
|
||||||
color=blue
|
color=blue
|
||||||
18 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
17 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||||
subgraph cluster_6 {
|
subgraph cluster_6 {
|
||||||
color=blue
|
color=blue
|
||||||
19 [label="Enter block"];
|
18 [label="Enter block"];
|
||||||
20 [label="Access variable R|<local>/it|"];
|
19 [label="Access variable R|<local>/it|"];
|
||||||
21 [label="Exit block"];
|
20 [label="Exit block"];
|
||||||
}
|
}
|
||||||
22 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
21 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
15 [label="Exit block"];
|
15 [label="Exit block"];
|
||||||
}
|
}
|
||||||
16 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
16 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
17 [label="Postponed exit from lambda"];
|
|
||||||
8 [label="Postponed exit from lambda"];
|
8 [label="Postponed exit from lambda"];
|
||||||
9 [label="Function call: R|<local>/s|.R|kotlin/let|<R|kotlin/String|, R|() -> kotlin/String|>(...)" style="filled" fillcolor=yellow];
|
9 [label="Function call: R|<local>/s|.R|kotlin/let|<R|kotlin/String|, R|() -> kotlin/String|>(...)" style="filled" fillcolor=yellow];
|
||||||
10 [label="Delegated constructor call: super<R|A|>(...)" style="filled" fillcolor=yellow];
|
10 [label="Delegated constructor call: super<R|A|>(...)" style="filled" fillcolor=yellow];
|
||||||
@@ -63,52 +62,50 @@ digraph postponedLambdaInConstructor_kt {
|
|||||||
10 -> {11};
|
10 -> {11};
|
||||||
12 -> {13};
|
12 -> {13};
|
||||||
13 -> {14};
|
13 -> {14};
|
||||||
14 -> {17 15 18};
|
14 -> {15 17};
|
||||||
14 -> {18} [style=dashed];
|
14 -> {17} [style=dashed];
|
||||||
15 -> {16};
|
15 -> {16};
|
||||||
16 -> {8};
|
16 -> {8};
|
||||||
17 -> {10} [color=red];
|
17 -> {18};
|
||||||
17 -> {9} [color=green];
|
|
||||||
18 -> {19};
|
18 -> {19};
|
||||||
19 -> {20};
|
19 -> {20};
|
||||||
20 -> {21};
|
20 -> {21};
|
||||||
21 -> {22};
|
|
||||||
|
|
||||||
subgraph cluster_7 {
|
subgraph cluster_7 {
|
||||||
color=red
|
color=red
|
||||||
23 [label="Enter property" style="filled" fillcolor=red];
|
22 [label="Enter property" style="filled" fillcolor=red];
|
||||||
24 [label="Access variable R|<local>/s|"];
|
23 [label="Access variable R|<local>/s|"];
|
||||||
25 [label="Exit property" style="filled" fillcolor=red];
|
24 [label="Exit property" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
|
22 -> {23};
|
||||||
23 -> {24};
|
23 -> {24};
|
||||||
24 -> {25};
|
24 -> {32} [color=green];
|
||||||
25 -> {33} [color=green];
|
|
||||||
|
|
||||||
subgraph cluster_8 {
|
subgraph cluster_8 {
|
||||||
color=red
|
color=red
|
||||||
26 [label="Enter function foo" style="filled" fillcolor=red];
|
25 [label="Enter function foo" style="filled" fillcolor=red];
|
||||||
subgraph cluster_9 {
|
subgraph cluster_9 {
|
||||||
color=blue
|
color=blue
|
||||||
27 [label="Enter block"];
|
26 [label="Enter block"];
|
||||||
28 [label="Function call: this@R|/B|.R|/B.foo|()" style="filled" fillcolor=yellow];
|
27 [label="Function call: this@R|/B|.R|/B.foo|()" style="filled" fillcolor=yellow];
|
||||||
29 [label="Exit block"];
|
28 [label="Exit block"];
|
||||||
}
|
}
|
||||||
30 [label="Exit function foo" style="filled" fillcolor=red];
|
29 [label="Exit function foo" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
|
25 -> {26};
|
||||||
26 -> {27};
|
26 -> {27};
|
||||||
27 -> {28};
|
27 -> {28};
|
||||||
28 -> {29};
|
28 -> {29};
|
||||||
29 -> {30};
|
|
||||||
|
|
||||||
subgraph cluster_10 {
|
subgraph cluster_10 {
|
||||||
color=red
|
color=red
|
||||||
31 [label="Enter class B" style="filled" fillcolor=red];
|
30 [label="Enter class B" style="filled" fillcolor=red];
|
||||||
32 [label="Part of class initialization"];
|
31 [label="Part of class initialization"];
|
||||||
33 [label="Exit class B" style="filled" fillcolor=red];
|
32 [label="Exit class B" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
31 -> {32} [color=green];
|
30 -> {31} [color=green];
|
||||||
32 -> {33} [style=dotted];
|
31 -> {32} [style=dotted];
|
||||||
32 -> {23} [color=green];
|
31 -> {22} [color=green];
|
||||||
32 -> {23} [style=dashed];
|
31 -> {22} [style=dashed];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+85
-91
@@ -95,7 +95,8 @@ digraph callsInPlace_kt {
|
|||||||
subgraph cluster_9 {
|
subgraph cluster_9 {
|
||||||
color=blue
|
color=blue
|
||||||
30 [label="Enter block"];
|
30 [label="Enter block"];
|
||||||
31 [label="Postponed enter to lambda"];
|
31 [label="Const: Int(10)"];
|
||||||
|
32 [label="Postponed enter to lambda"];
|
||||||
subgraph cluster_10 {
|
subgraph cluster_10 {
|
||||||
color=blue
|
color=blue
|
||||||
37 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
37 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||||
@@ -107,8 +108,7 @@ digraph callsInPlace_kt {
|
|||||||
}
|
}
|
||||||
41 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
41 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
33 [label="Const: Int(10)"];
|
33 [label="Postponed exit from lambda"];
|
||||||
32 [label="Postponed exit from lambda"];
|
|
||||||
34 [label="Function call: R|kotlin/repeat|(...)" style="filled" fillcolor=yellow];
|
34 [label="Function call: R|kotlin/repeat|(...)" style="filled" fillcolor=yellow];
|
||||||
35 [label="Exit block"];
|
35 [label="Exit block"];
|
||||||
}
|
}
|
||||||
@@ -116,18 +116,18 @@ digraph callsInPlace_kt {
|
|||||||
}
|
}
|
||||||
29 -> {30};
|
29 -> {30};
|
||||||
30 -> {31};
|
30 -> {31};
|
||||||
31 -> {32 33 37};
|
31 -> {32};
|
||||||
31 -> {37} [style=dashed];
|
32 -> {33 37 34};
|
||||||
32 -> {34};
|
32 -> {37} [style=dashed];
|
||||||
32 -> {31} [color=green style=dashed];
|
|
||||||
33 -> {34};
|
33 -> {34};
|
||||||
|
33 -> {32} [color=green style=dashed];
|
||||||
34 -> {35};
|
34 -> {35};
|
||||||
35 -> {36};
|
35 -> {36};
|
||||||
37 -> {38};
|
37 -> {38};
|
||||||
38 -> {39};
|
38 -> {39};
|
||||||
39 -> {40};
|
39 -> {40};
|
||||||
40 -> {41};
|
40 -> {41};
|
||||||
41 -> {32};
|
41 -> {33};
|
||||||
|
|
||||||
subgraph cluster_12 {
|
subgraph cluster_12 {
|
||||||
color=red
|
color=red
|
||||||
@@ -252,167 +252,161 @@ digraph callsInPlace_kt {
|
|||||||
84 [label="Postponed enter to lambda"];
|
84 [label="Postponed enter to lambda"];
|
||||||
subgraph cluster_24 {
|
subgraph cluster_24 {
|
||||||
color=blue
|
color=blue
|
||||||
96 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
95 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||||
subgraph cluster_25 {
|
subgraph cluster_25 {
|
||||||
color=blue
|
color=blue
|
||||||
97 [label="Enter block"];
|
96 [label="Enter block"];
|
||||||
98 [label="Const: String(test_6_2)"];
|
97 [label="Const: String(test_6_2)"];
|
||||||
99 [label="Exit block"];
|
98 [label="Exit block"];
|
||||||
}
|
}
|
||||||
100 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
99 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
86 [label="Postponed enter to lambda"];
|
|
||||||
subgraph cluster_26 {
|
subgraph cluster_26 {
|
||||||
color=blue
|
color=blue
|
||||||
91 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
90 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||||
subgraph cluster_27 {
|
subgraph cluster_27 {
|
||||||
color=blue
|
color=blue
|
||||||
92 [label="Enter block"];
|
91 [label="Enter block"];
|
||||||
93 [label="Const: String(test_6_1)"];
|
92 [label="Const: String(test_6_1)"];
|
||||||
94 [label="Exit block"];
|
93 [label="Exit block"];
|
||||||
}
|
}
|
||||||
95 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
94 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
87 [label="Postponed exit from lambda"];
|
|
||||||
85 [label="Postponed exit from lambda"];
|
85 [label="Postponed exit from lambda"];
|
||||||
88 [label="Function call: R|/myRun|(...)" style="filled" fillcolor=yellow];
|
86 [label="Postponed exit from lambda"];
|
||||||
89 [label="Exit block"];
|
87 [label="Function call: R|/myRun|(...)" style="filled" fillcolor=yellow];
|
||||||
|
88 [label="Exit block"];
|
||||||
}
|
}
|
||||||
90 [label="Exit function test_6" style="filled" fillcolor=red];
|
89 [label="Exit function test_6" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
82 -> {83};
|
82 -> {83};
|
||||||
83 -> {84};
|
83 -> {84};
|
||||||
84 -> {85 86 96};
|
84 -> {86 85 90 95 87};
|
||||||
84 -> {96} [style=dashed];
|
84 -> {90 95} [style=dashed];
|
||||||
85 -> {88};
|
85 -> {87};
|
||||||
85 -> {84} [color=green style=dashed];
|
85 -> {84} [color=green style=dashed];
|
||||||
86 -> {87 91 88};
|
86 -> {87};
|
||||||
86 -> {91} [style=dashed];
|
86 -> {84} [color=green style=dashed];
|
||||||
87 -> {88};
|
87 -> {88};
|
||||||
87 -> {86} [color=green style=dashed];
|
|
||||||
88 -> {89};
|
88 -> {89};
|
||||||
89 -> {90};
|
90 -> {91};
|
||||||
91 -> {92};
|
91 -> {92};
|
||||||
92 -> {93};
|
92 -> {93};
|
||||||
93 -> {94};
|
93 -> {94};
|
||||||
94 -> {95};
|
94 -> {86};
|
||||||
95 -> {87};
|
95 -> {96};
|
||||||
96 -> {97};
|
96 -> {97};
|
||||||
97 -> {98};
|
97 -> {98};
|
||||||
98 -> {99};
|
98 -> {99};
|
||||||
99 -> {100};
|
99 -> {85};
|
||||||
100 -> {85};
|
|
||||||
|
|
||||||
subgraph cluster_28 {
|
subgraph cluster_28 {
|
||||||
color=red
|
color=red
|
||||||
101 [label="Enter function test_7" style="filled" fillcolor=red];
|
100 [label="Enter function test_7" style="filled" fillcolor=red];
|
||||||
subgraph cluster_29 {
|
subgraph cluster_29 {
|
||||||
color=blue
|
color=blue
|
||||||
102 [label="Enter block"];
|
101 [label="Enter block"];
|
||||||
103 [label="Postponed enter to lambda"];
|
102 [label="Postponed enter to lambda"];
|
||||||
subgraph cluster_30 {
|
subgraph cluster_30 {
|
||||||
color=blue
|
color=blue
|
||||||
110 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
113 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||||
subgraph cluster_31 {
|
subgraph cluster_31 {
|
||||||
color=blue
|
color=blue
|
||||||
111 [label="Enter block"];
|
114 [label="Enter block"];
|
||||||
112 [label="Const: String(test_7_2)"];
|
115 [label="Const: String(test_7_1)"];
|
||||||
113 [label="Exit block"];
|
116 [label="Exit block"];
|
||||||
}
|
}
|
||||||
114 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
117 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
105 [label="Postponed enter to lambda"];
|
|
||||||
subgraph cluster_32 {
|
subgraph cluster_32 {
|
||||||
color=blue
|
color=blue
|
||||||
115 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
108 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||||
subgraph cluster_33 {
|
subgraph cluster_33 {
|
||||||
color=blue
|
color=blue
|
||||||
116 [label="Enter block"];
|
109 [label="Enter block"];
|
||||||
117 [label="Const: String(test_7_1)"];
|
110 [label="Const: String(test_7_2)"];
|
||||||
118 [label="Exit block"];
|
111 [label="Exit block"];
|
||||||
}
|
}
|
||||||
119 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
112 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
106 [label="Postponed exit from lambda"];
|
103 [label="Postponed exit from lambda"];
|
||||||
104 [label="Postponed exit from lambda"];
|
104 [label="Postponed exit from lambda"];
|
||||||
107 [label="Function call: R|/myRun|(...)" style="filled" fillcolor=yellow];
|
105 [label="Function call: R|/myRun|(...)" style="filled" fillcolor=yellow];
|
||||||
108 [label="Exit block"];
|
106 [label="Exit block"];
|
||||||
}
|
}
|
||||||
109 [label="Exit function test_7" style="filled" fillcolor=red];
|
107 [label="Exit function test_7" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
|
100 -> {101};
|
||||||
101 -> {102};
|
101 -> {102};
|
||||||
102 -> {103};
|
102 -> {104 103 108 113 105};
|
||||||
103 -> {104 105 110};
|
102 -> {108 113} [style=dashed];
|
||||||
103 -> {110} [style=dashed];
|
103 -> {105};
|
||||||
104 -> {107};
|
103 -> {102} [color=green style=dashed];
|
||||||
104 -> {103} [color=green style=dashed];
|
104 -> {105};
|
||||||
105 -> {106 115 107};
|
104 -> {102} [color=green style=dashed];
|
||||||
105 -> {115} [style=dashed];
|
105 -> {106};
|
||||||
106 -> {107};
|
106 -> {107};
|
||||||
106 -> {105} [color=green style=dashed];
|
|
||||||
107 -> {108};
|
|
||||||
108 -> {109};
|
108 -> {109};
|
||||||
|
109 -> {110};
|
||||||
110 -> {111};
|
110 -> {111};
|
||||||
111 -> {112};
|
111 -> {112};
|
||||||
112 -> {113};
|
112 -> {104};
|
||||||
113 -> {114};
|
113 -> {114};
|
||||||
114 -> {104};
|
114 -> {115};
|
||||||
115 -> {116};
|
115 -> {116};
|
||||||
116 -> {117};
|
116 -> {117};
|
||||||
117 -> {118};
|
117 -> {103};
|
||||||
118 -> {119};
|
|
||||||
119 -> {106};
|
|
||||||
|
|
||||||
subgraph cluster_34 {
|
subgraph cluster_34 {
|
||||||
color=red
|
color=red
|
||||||
120 [label="Enter function myDummyRun" style="filled" fillcolor=red];
|
118 [label="Enter function myDummyRun" style="filled" fillcolor=red];
|
||||||
subgraph cluster_35 {
|
subgraph cluster_35 {
|
||||||
color=blue
|
color=blue
|
||||||
121 [label="Enter block"];
|
119 [label="Enter block"];
|
||||||
122 [label="Function call: R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()" style="filled" fillcolor=yellow];
|
120 [label="Function call: R|<local>/block|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()" style="filled" fillcolor=yellow];
|
||||||
123 [label="Exit block"];
|
121 [label="Exit block"];
|
||||||
}
|
}
|
||||||
124 [label="Exit function myDummyRun" style="filled" fillcolor=red];
|
122 [label="Exit function myDummyRun" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
|
118 -> {119};
|
||||||
|
119 -> {120};
|
||||||
120 -> {121};
|
120 -> {121};
|
||||||
121 -> {122};
|
121 -> {122};
|
||||||
122 -> {123};
|
|
||||||
123 -> {124};
|
|
||||||
|
|
||||||
subgraph cluster_36 {
|
subgraph cluster_36 {
|
||||||
color=red
|
color=red
|
||||||
125 [label="Enter function test_8" style="filled" fillcolor=red];
|
123 [label="Enter function test_8" style="filled" fillcolor=red];
|
||||||
subgraph cluster_37 {
|
subgraph cluster_37 {
|
||||||
color=blue
|
color=blue
|
||||||
126 [label="Enter block"];
|
124 [label="Enter block"];
|
||||||
127 [label="Postponed enter to lambda"];
|
125 [label="Postponed enter to lambda"];
|
||||||
subgraph cluster_38 {
|
subgraph cluster_38 {
|
||||||
color=blue
|
color=blue
|
||||||
132 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
130 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||||
subgraph cluster_39 {
|
subgraph cluster_39 {
|
||||||
color=blue
|
color=blue
|
||||||
133 [label="Enter block"];
|
131 [label="Enter block"];
|
||||||
134 [label="Const: String(test_8)"];
|
132 [label="Const: String(test_8)"];
|
||||||
135 [label="Exit block"];
|
133 [label="Exit block"];
|
||||||
}
|
}
|
||||||
136 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
134 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
128 [label="Postponed exit from lambda"];
|
126 [label="Postponed exit from lambda"];
|
||||||
129 [label="Function call: R|/myDummyRun|(...)" style="filled" fillcolor=yellow];
|
127 [label="Function call: R|/myDummyRun|(...)" style="filled" fillcolor=yellow];
|
||||||
130 [label="Exit block"];
|
128 [label="Exit block"];
|
||||||
}
|
}
|
||||||
131 [label="Exit function test_8" style="filled" fillcolor=red];
|
129 [label="Exit function test_8" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
125 -> {126};
|
123 -> {124};
|
||||||
|
124 -> {125};
|
||||||
|
125 -> {126 130 127};
|
||||||
|
125 -> {130} [style=dashed];
|
||||||
126 -> {127};
|
126 -> {127};
|
||||||
127 -> {128 132 129};
|
127 -> {128};
|
||||||
127 -> {132} [style=dashed];
|
|
||||||
128 -> {129};
|
128 -> {129};
|
||||||
129 -> {130};
|
|
||||||
130 -> {131};
|
130 -> {131};
|
||||||
|
131 -> {132};
|
||||||
132 -> {133};
|
132 -> {133};
|
||||||
133 -> {134};
|
133 -> {134};
|
||||||
134 -> {135};
|
|
||||||
135 -> {136};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -39,11 +39,15 @@ class LocalPropertyAndCapturedWriteCollector private constructor() : ControlFlow
|
|||||||
symbols[node.fir.symbol] = lambdaOrLocalFunctionStack.lastOrNull() == null
|
symbols[node.fir.symbol] = lambdaOrLocalFunctionStack.lastOrNull() == null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitPostponedLambdaEnterNode(node: PostponedLambdaEnterNode) {
|
override fun visitSplitPostponedLambdasNode(node: SplitPostponedLambdasNode) {
|
||||||
|
lambdaOrLocalFunctionStack.addAll(node.lambdas)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun visitAnonymousFunctionExpressionNode(node: AnonymousFunctionExpressionNode) {
|
||||||
lambdaOrLocalFunctionStack.add(node.fir.anonymousFunction)
|
lambdaOrLocalFunctionStack.add(node.fir.anonymousFunction)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitLocalFunctionDeclarationNode(node: LocalFunctionDeclarationNode, data: Nothing?) {
|
override fun visitLocalFunctionDeclarationNode(node: LocalFunctionDeclarationNode) {
|
||||||
lambdaOrLocalFunctionStack.add(node.fir)
|
lambdaOrLocalFunctionStack.add(node.fir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
@@ -49,6 +49,7 @@ object UnreachableCodeChecker : FirControlFlowChecker() {
|
|||||||
val skipType = this is ExitNodeMarker ||
|
val skipType = this is ExitNodeMarker ||
|
||||||
this is EnterNodeMarker ||
|
this is EnterNodeMarker ||
|
||||||
this is StubNode ||
|
this is StubNode ||
|
||||||
|
this is SplitPostponedLambdasNode ||
|
||||||
this is BinaryOrExitLeftOperandNode ||
|
this is BinaryOrExitLeftOperandNode ||
|
||||||
this is BinaryOrEnterRightOperandNode ||
|
this is BinaryOrEnterRightOperandNode ||
|
||||||
this is BinaryAndExitLeftOperandNode ||
|
this is BinaryAndExitLeftOperandNode ||
|
||||||
|
|||||||
@@ -68,21 +68,7 @@ class FirCallResolver(
|
|||||||
val conflictResolver: ConeCallConflictResolver =
|
val conflictResolver: ConeCallConflictResolver =
|
||||||
session.callConflictResolverFactory.create(TypeSpecificityComparator.NONE, session.inferenceComponents, components)
|
session.callConflictResolverFactory.create(TypeSpecificityComparator.NONE, session.inferenceComponents, components)
|
||||||
|
|
||||||
@PrivateForInline
|
|
||||||
var needTransformArguments: Boolean = true
|
|
||||||
|
|
||||||
@OptIn(PrivateForInline::class)
|
|
||||||
fun resolveCallAndSelectCandidate(functionCall: FirFunctionCall): FirFunctionCall {
|
fun resolveCallAndSelectCandidate(functionCall: FirFunctionCall): FirFunctionCall {
|
||||||
@Suppress("NAME_SHADOWING")
|
|
||||||
val functionCall = if (needTransformArguments) {
|
|
||||||
functionCall.transformExplicitReceiver().also {
|
|
||||||
components.dataFlowAnalyzer.enterQualifiedAccessExpression()
|
|
||||||
functionCall.replaceArgumentList(functionCall.argumentList.transform(transformer, ResolutionMode.ContextDependent))
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
functionCall
|
|
||||||
}
|
|
||||||
|
|
||||||
val name = functionCall.calleeReference.name
|
val name = functionCall.calleeReference.name
|
||||||
val result = collectCandidates(functionCall, name, origin = functionCall.origin)
|
val result = collectCandidates(functionCall, name, origin = functionCall.origin)
|
||||||
|
|
||||||
@@ -132,29 +118,6 @@ class FirCallResolver(
|
|||||||
return resultFunctionCall
|
return resultFunctionCall
|
||||||
}
|
}
|
||||||
|
|
||||||
private inline fun <reified Q : FirQualifiedAccess> Q.transformExplicitReceiver(): Q {
|
|
||||||
val explicitReceiver =
|
|
||||||
explicitReceiver as? FirQualifiedAccessExpression
|
|
||||||
?: return transformExplicitReceiver(transformer, ResolutionMode.ReceiverResolution) as Q
|
|
||||||
|
|
||||||
(explicitReceiver.calleeReference as? FirSuperReference)?.let {
|
|
||||||
transformer.transformSuperReceiver(it, explicitReceiver, this)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
if (explicitReceiver is FirPropertyAccessExpression) {
|
|
||||||
this.replaceExplicitReceiver(
|
|
||||||
transformer.transformQualifiedAccessExpression(
|
|
||||||
explicitReceiver, ResolutionMode.ReceiverResolution,
|
|
||||||
isUsedAsReceiver = true
|
|
||||||
) as FirExpression
|
|
||||||
)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
return transformExplicitReceiver(transformer, ResolutionMode.ReceiverResolution) as Q
|
|
||||||
}
|
|
||||||
|
|
||||||
private data class ResolutionResult(
|
private data class ResolutionResult(
|
||||||
val info: CallInfo, val applicability: CandidateApplicability, val candidates: Collection<Candidate>,
|
val info: CallInfo, val applicability: CandidateApplicability, val candidates: Collection<Candidate>,
|
||||||
)
|
)
|
||||||
@@ -249,7 +212,7 @@ class FirCallResolver(
|
|||||||
val callee = qualifiedAccess.calleeReference as? FirSimpleNamedReference ?: return qualifiedAccess
|
val callee = qualifiedAccess.calleeReference as? FirSimpleNamedReference ?: return qualifiedAccess
|
||||||
|
|
||||||
@Suppress("NAME_SHADOWING")
|
@Suppress("NAME_SHADOWING")
|
||||||
val qualifiedAccess = qualifiedAccess.transformExplicitReceiver<FirQualifiedAccess>()
|
val qualifiedAccess = transformer.transformExplicitReceiver(qualifiedAccess)
|
||||||
val nonFatalDiagnosticFromExpression = (qualifiedAccess as? FirPropertyAccessExpression)?.nonFatalDiagnostics
|
val nonFatalDiagnosticFromExpression = (qualifiedAccess as? FirPropertyAccessExpression)?.nonFatalDiagnostics
|
||||||
|
|
||||||
val basicResult by lazy(LazyThreadSafetyMode.NONE) {
|
val basicResult by lazy(LazyThreadSafetyMode.NONE) {
|
||||||
@@ -605,17 +568,6 @@ class FirCallResolver(
|
|||||||
return ResolutionResult(callInfo, applicability, listOf(candidate))
|
return ResolutionResult(callInfo, applicability, listOf(candidate))
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(PrivateForInline::class)
|
|
||||||
inline fun <T> withNoArgumentsTransform(block: () -> T): T {
|
|
||||||
val oldValue = needTransformArguments
|
|
||||||
needTransformArguments = false
|
|
||||||
return try {
|
|
||||||
block()
|
|
||||||
} finally {
|
|
||||||
needTransformArguments = oldValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun selectDelegatingConstructorCall(
|
private fun selectDelegatingConstructorCall(
|
||||||
call: FirDelegatedConstructorCall, name: Name, result: CandidateCollector, callInfo: CallInfo
|
call: FirDelegatedConstructorCall, name: Name, result: CandidateCollector, callInfo: CallInfo
|
||||||
): FirDelegatedConstructorCall {
|
): FirDelegatedConstructorCall {
|
||||||
|
|||||||
+10
-41
@@ -152,7 +152,7 @@ abstract class FirDataFlowAnalyzer(
|
|||||||
if (function is FirDefaultPropertyAccessor) return
|
if (function is FirDefaultPropertyAccessor) return
|
||||||
|
|
||||||
val (localFunctionNode, functionEnterNode) = if (function is FirAnonymousFunction) {
|
val (localFunctionNode, functionEnterNode) = if (function is FirAnonymousFunction) {
|
||||||
graphBuilder.enterAnonymousFunction(function)
|
null to graphBuilder.enterAnonymousFunction(function)
|
||||||
} else {
|
} else {
|
||||||
graphBuilder.enterFunction(function)
|
graphBuilder.enterFunction(function)
|
||||||
}
|
}
|
||||||
@@ -201,12 +201,8 @@ abstract class FirDataFlowAnalyzer(
|
|||||||
|
|
||||||
// ----------------------------------- Anonymous function -----------------------------------
|
// ----------------------------------- Anonymous function -----------------------------------
|
||||||
|
|
||||||
fun visitPostponedAnonymousFunction(anonymousFunctionExpression: FirAnonymousFunctionExpression) {
|
fun enterAnonymousFunctionExpression(anonymousFunctionExpression: FirAnonymousFunctionExpression) {
|
||||||
graphBuilder.visitPostponedAnonymousFunction(anonymousFunctionExpression).mergeIncomingFlow()
|
graphBuilder.enterAnonymousFunctionExpression(anonymousFunctionExpression)?.mergeIncomingFlow()
|
||||||
}
|
|
||||||
|
|
||||||
fun exitAnonymousFunctionExpression(anonymousFunctionExpression: FirAnonymousFunctionExpression) {
|
|
||||||
graphBuilder.exitAnonymousFunctionExpression(anonymousFunctionExpression).mergeIncomingFlow()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------- Classes -----------------------------------
|
// ----------------------------------- Classes -----------------------------------
|
||||||
@@ -739,9 +735,6 @@ abstract class FirDataFlowAnalyzer(
|
|||||||
|
|
||||||
// ----------------------------------- Resolvable call -----------------------------------
|
// ----------------------------------- Resolvable call -----------------------------------
|
||||||
|
|
||||||
// Intentionally left empty for potential future needs (call sites are preserved)
|
|
||||||
fun enterQualifiedAccessExpression() {}
|
|
||||||
|
|
||||||
fun exitQualifiedAccessExpression(qualifiedAccessExpression: FirQualifiedAccessExpression) {
|
fun exitQualifiedAccessExpression(qualifiedAccessExpression: FirQualifiedAccessExpression) {
|
||||||
graphBuilder.exitQualifiedAccessExpression(qualifiedAccessExpression).mergeIncomingFlow { flow ->
|
graphBuilder.exitQualifiedAccessExpression(qualifiedAccessExpression).mergeIncomingFlow { flow ->
|
||||||
processConditionalContract(flow, qualifiedAccessExpression)
|
processConditionalContract(flow, qualifiedAccessExpression)
|
||||||
@@ -780,50 +773,26 @@ abstract class FirDataFlowAnalyzer(
|
|||||||
graphBuilder.exitResolvedQualifierNode(resolvedQualifier).mergeIncomingFlow()
|
graphBuilder.exitResolvedQualifierNode(resolvedQualifier).mergeIncomingFlow()
|
||||||
}
|
}
|
||||||
|
|
||||||
private var resolvingAugmentedAssignmentOptions: Boolean = false
|
fun enterCallArguments(call: FirStatement, arguments: List<FirExpression>) {
|
||||||
|
val lambdas = arguments.mapNotNull { it.unwrapAnonymousFunctionExpression() }
|
||||||
// The expected sequence of calls for augmented assignment:
|
context.variableAssignmentAnalyzer.enterFunctionCall(lambdas)
|
||||||
// 1. enterAugmentedAssignmentCall()
|
|
||||||
// 2. resolve arguments
|
|
||||||
// 3. enterSelectAugmentedAssignmentCall()
|
|
||||||
// 4. resolve all options for calls in context-independent mode
|
|
||||||
// 5. exitSelectAugmentedAssignmentCall()
|
|
||||||
// 6. complete the chosen version
|
|
||||||
// 7. exitFunctionCall(top-level call in the chosen option)
|
|
||||||
fun enterAugmentedAssignmentCall() {
|
|
||||||
graphBuilder.enterCall()
|
graphBuilder.enterCall()
|
||||||
context.variableAssignmentAnalyzer.enterFunctionCall(emptyList())
|
graphBuilder.enterCallArguments(call, lambdas)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun enterSelectAugmentedAssignmentCall() {
|
fun exitCallArguments() {
|
||||||
assert(!resolvingAugmentedAssignmentOptions) { "resolving augmented assignment while resolving augmented assignment?" }
|
graphBuilder.exitCallArguments()?.mergeIncomingFlow()
|
||||||
resolvingAugmentedAssignmentOptions = true
|
|
||||||
}
|
|
||||||
|
|
||||||
fun exitSelectAugmentedAssignmentCall() {
|
|
||||||
assert(resolvingAugmentedAssignmentOptions) { "no enterSelectAugmentedAssignmentCall before exitSelectAugmentedAssignmentCall" }
|
|
||||||
resolvingAugmentedAssignmentOptions = false
|
|
||||||
}
|
|
||||||
|
|
||||||
fun enterFunctionCall(functionCall: FirFunctionCall) {
|
|
||||||
if (resolvingAugmentedAssignmentOptions) return // shouldn't be any lambda arguments anyway, they're visited before that
|
|
||||||
context.variableAssignmentAnalyzer.enterFunctionCall(functionCall.arguments.mapNotNull { it.unwrapAnonymousFunctionExpression() })
|
|
||||||
graphBuilder.enterCall()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun exitFunctionCall(functionCall: FirFunctionCall, callCompleted: Boolean) {
|
fun exitFunctionCall(functionCall: FirFunctionCall, callCompleted: Boolean) {
|
||||||
if (resolvingAugmentedAssignmentOptions) return
|
|
||||||
context.variableAssignmentAnalyzer.exitFunctionCall(callCompleted)
|
context.variableAssignmentAnalyzer.exitFunctionCall(callCompleted)
|
||||||
graphBuilder.exitFunctionCall(functionCall, callCompleted).mergeIncomingFlow {
|
graphBuilder.exitFunctionCall(functionCall, callCompleted).mergeIncomingFlow {
|
||||||
processConditionalContract(it, functionCall)
|
processConditionalContract(it, functionCall)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun enterDelegatedConstructorCall() {
|
|
||||||
graphBuilder.enterCall()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun exitDelegatedConstructorCall(call: FirDelegatedConstructorCall, callCompleted: Boolean) {
|
fun exitDelegatedConstructorCall(call: FirDelegatedConstructorCall, callCompleted: Boolean) {
|
||||||
|
context.variableAssignmentAnalyzer.exitFunctionCall(callCompleted)
|
||||||
graphBuilder.exitDelegatedConstructorCall(call, callCompleted).mergeIncomingFlow()
|
graphBuilder.exitDelegatedConstructorCall(call, callCompleted).mergeIncomingFlow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+57
-38
@@ -61,14 +61,15 @@ class ControlFlowGraphBuilder {
|
|||||||
//return jumps via finally blocks, target -> jumps
|
//return jumps via finally blocks, target -> jumps
|
||||||
private val nonDirectJumps: ListMultimap<CFGNode<*>, CFGNode<*>> = listMultimapOf()
|
private val nonDirectJumps: ListMultimap<CFGNode<*>, CFGNode<*>> = listMultimapOf()
|
||||||
|
|
||||||
|
private val argumentListSplitNodes: Stack<SplitPostponedLambdasNode?> = stackOf()
|
||||||
private val postponedAnonymousFunctionNodes =
|
private val postponedAnonymousFunctionNodes =
|
||||||
mutableMapOf<FirFunctionSymbol<*>, Pair<PostponedLambdaEnterNode, PostponedLambdaExitNode>>()
|
mutableMapOf<FirFunctionSymbol<*>, Pair<CFGNodeWithSubgraphs<*>, PostponedLambdaExitNode?>>()
|
||||||
private val postponedLambdaExits: Stack<MutableList<Pair<CFGNode<*>, EdgeKind>>> = stackOf()
|
private val postponedLambdaExits: Stack<MutableList<Pair<CFGNode<*>, EdgeKind>>> = stackOf()
|
||||||
|
|
||||||
private val loopConditionEnterNodes: NodeStorage<FirElement, LoopConditionEnterNode> = NodeStorage()
|
private val loopConditionEnterNodes: NodeStorage<FirElement, LoopConditionEnterNode> = NodeStorage()
|
||||||
private val loopExitNodes: NodeStorage<FirLoop, LoopExitNode> = NodeStorage()
|
private val loopExitNodes: NodeStorage<FirLoop, LoopExitNode> = NodeStorage()
|
||||||
|
|
||||||
private val whenExitNodes: NodeStorage<FirWhenExpression, WhenExitNode> = NodeStorage()
|
private val whenExitNodes: Stack<WhenExitNode> = stackOf()
|
||||||
|
|
||||||
private val binaryLogicExpressionExitNodes: Stack<AbstractBinaryExitNode<FirBinaryLogicExpression>> = stackOf()
|
private val binaryLogicExpressionExitNodes: Stack<AbstractBinaryExitNode<FirBinaryLogicExpression>> = stackOf()
|
||||||
|
|
||||||
@@ -236,23 +237,28 @@ class ControlFlowGraphBuilder {
|
|||||||
// for them may not have been computed yet. Instead, these edges are redirected
|
// for them may not have been computed yet. Instead, these edges are redirected
|
||||||
// into the outer call. The outermost call *has* to be completed, so at some point
|
// into the outer call. The outermost call *has* to be completed, so at some point
|
||||||
// all data will be unified in a single call node.
|
// all data will be unified in a single call node.
|
||||||
fun visitPostponedAnonymousFunction(anonymousFunctionExpression: FirAnonymousFunctionExpression): PostponedLambdaEnterNode {
|
fun enterAnonymousFunctionExpression(anonymousFunctionExpression: FirAnonymousFunctionExpression): AnonymousFunctionExpressionNode? {
|
||||||
// TODO: should only have 1 enter node for all lambdas in a single call.
|
|
||||||
val enterNode = createPostponedLambdaEnterNode(anonymousFunctionExpression)
|
|
||||||
val exitNode = createPostponedLambdaExitNode(anonymousFunctionExpression)
|
|
||||||
val symbol = anonymousFunctionExpression.anonymousFunction.symbol
|
val symbol = anonymousFunctionExpression.anonymousFunction.symbol
|
||||||
postponedAnonymousFunctionNodes[symbol] = enterNode to exitNode
|
val enterNode = postponedAnonymousFunctionNodes[symbol]?.first
|
||||||
addNewSimpleNode(enterNode)
|
?: return createAnonymousFunctionExpressionNode(anonymousFunctionExpression).also {
|
||||||
|
addNewSimpleNode(it)
|
||||||
|
// Not in an argument list, won't be called in-place, don't need an exit node.
|
||||||
|
postponedAnonymousFunctionNodes[symbol] = it to null
|
||||||
|
}
|
||||||
|
val exitNode = createPostponedLambdaExitNode(anonymousFunctionExpression)
|
||||||
|
// Ideally we'd only add this edge in `exitAnonymousFunction`, but unfortunately it's possible
|
||||||
|
// that the function won't be visited for so long, we'll exit `currentGraph` before that.
|
||||||
|
// When exiting a graph, all nodes in it are topologically sorted, so unless we add some edge
|
||||||
|
// here, `exitNode` will be dropped from the node list. Oops. TODO: fix `orderNodes` someday.
|
||||||
addEdge(enterNode, exitNode)
|
addEdge(enterNode, exitNode)
|
||||||
|
postponedAnonymousFunctionNodes[symbol] = enterNode to exitNode
|
||||||
postponedLambdaExits.top().add(exitNode to EdgeKind.Forward)
|
postponedLambdaExits.top().add(exitNode to EdgeKind.Forward)
|
||||||
return enterNode
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun enterAnonymousFunction(anonymousFunction: FirAnonymousFunction): Pair<LocalFunctionDeclarationNode?, FunctionEnterNode> {
|
fun enterAnonymousFunction(anonymousFunction: FirAnonymousFunction): FunctionEnterNode {
|
||||||
val symbol = anonymousFunction.symbol
|
val symbol = anonymousFunction.symbol
|
||||||
val flowSourceNode = postponedAnonymousFunctionNodes[symbol]?.first
|
val flowSourceNode = postponedAnonymousFunctionNodes.getValue(symbol).first
|
||||||
?: createLocalFunctionDeclarationNode(anonymousFunction).also { addNewSimpleNode(it) }
|
|
||||||
|
|
||||||
pushGraph(ControlFlowGraph(anonymousFunction, "<anonymous>", ControlFlowGraph.Kind.AnonymousFunction), Mode.Function)
|
pushGraph(ControlFlowGraph(anonymousFunction, "<anonymous>", ControlFlowGraph.Kind.AnonymousFunction), Mode.Function)
|
||||||
val enterNode = createFunctionEnterNode(anonymousFunction)
|
val enterNode = createFunctionEnterNode(anonymousFunction)
|
||||||
val exitNode = createFunctionExitNode(anonymousFunction)
|
val exitNode = createFunctionExitNode(anonymousFunction)
|
||||||
@@ -260,10 +266,9 @@ class ControlFlowGraphBuilder {
|
|||||||
if (!anonymousFunction.invocationKind.isInPlace) {
|
if (!anonymousFunction.invocationKind.isInPlace) {
|
||||||
exitTargetsForTry.push(exitNode)
|
exitTargetsForTry.push(exitNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
addEdge(flowSourceNode, enterNode)
|
addEdge(flowSourceNode, enterNode)
|
||||||
lastNodes.push(enterNode)
|
lastNodes.push(enterNode)
|
||||||
return (flowSourceNode as? LocalFunctionDeclarationNode) to enterNode
|
return enterNode
|
||||||
}
|
}
|
||||||
|
|
||||||
fun exitAnonymousFunction(anonymousFunction: FirAnonymousFunction): Triple<FunctionExitNode, PostponedLambdaExitNode?, ControlFlowGraph> {
|
fun exitAnonymousFunction(anonymousFunction: FirAnonymousFunction): Triple<FunctionExitNode, PostponedLambdaExitNode?, ControlFlowGraph> {
|
||||||
@@ -276,41 +281,41 @@ class ControlFlowGraphBuilder {
|
|||||||
popAndAddEdge(exitNode)
|
popAndAddEdge(exitNode)
|
||||||
exitNode.updateDeadStatus()
|
exitNode.updateDeadStatus()
|
||||||
|
|
||||||
val graph = popGraph().also { graph ->
|
val graph = popGraph()
|
||||||
assert(graph.declaration == anonymousFunction)
|
assert(graph.declaration == anonymousFunction)
|
||||||
assert(graph.exitNode == exitNode)
|
assert(graph.exitNode == exitNode)
|
||||||
}
|
|
||||||
|
|
||||||
val (postponedEnterNode, postponedExitNode) = postponedAnonymousFunctionNodes.remove(symbol)
|
val (splitNode, postponedExitNode) = postponedAnonymousFunctionNodes.remove(symbol)!!
|
||||||
?: return Triple(exitNode, null, graph).also { currentGraph.addSubGraph(graph) }
|
splitNode.addSubGraph(graph)
|
||||||
|
// May not be the current graph: `select(run { run { generic() } }, 1)`
|
||||||
|
splitNode.owner.addSubGraph(graph)
|
||||||
|
|
||||||
val invocationKind = anonymousFunction.invocationKind
|
val invocationKind = anonymousFunction.invocationKind
|
||||||
|
if (postponedExitNode == null) {
|
||||||
|
// Postponed exit node was needed so we could create lambda->call edges without having the subgraph ready. If it
|
||||||
|
// doesn't exist, then we probably can't do that anymore, and the lambda won't be called-in-place in the CFG.
|
||||||
|
// TODO: verify & enable this assertion?
|
||||||
|
//assert(invocationKind?.canBeVisited() != true) { "no exit node for calledInPlace($invocationKind) lambda" }
|
||||||
|
return Triple(exitNode, null, graph)
|
||||||
|
}
|
||||||
|
|
||||||
// Lambdas not called in-place behave as if called never, but with extra invalidation of all smart casts
|
// Lambdas not called in-place behave as if called never, but with extra invalidation of all smart casts
|
||||||
// for all variables that they reassign. That second part is handled by `FirDataFlowAnalyzer`.
|
// for all variables that they reassign. That second part is handled by `FirDataFlowAnalyzer`.
|
||||||
|
val isDefinitelyVisited = invocationKind?.isDefinitelyVisited() == true
|
||||||
|
if (isDefinitelyVisited || splitNode.isDead) {
|
||||||
|
// The edge that was added as a hack to enforce ordering of nodes needs to be marked as dead if this lambda is never
|
||||||
|
// skipped. Or if the entry node is dead, because at the time we added the hack-edge we didn't know that.
|
||||||
|
CFGNode.addJustKindEdge(splitNode, postponedExitNode, EdgeKind.DeadForward, propagateDeadness = !isDefinitelyVisited)
|
||||||
|
}
|
||||||
if (invocationKind?.canBeVisited() == true) {
|
if (invocationKind?.canBeVisited() == true) {
|
||||||
addEdge(exitNode, postponedExitNode, propagateDeadness = invocationKind.isDefinitelyVisited())
|
addEdge(exitNode, postponedExitNode, propagateDeadness = isDefinitelyVisited)
|
||||||
if (invocationKind.isDefinitelyVisited()) {
|
|
||||||
// We had to create this edge so that if the lambda is postponed for so long that we exit the subgraph
|
|
||||||
// before visiting it, `orderNodes` can still find an ordering. Now we can kill it.
|
|
||||||
CFGNode.addJustKindEdge(postponedEnterNode, postponedExitNode, EdgeKind.DeadForward, propagateDeadness = false)
|
|
||||||
}
|
|
||||||
if (invocationKind.canBeRevisited()) {
|
if (invocationKind.canBeRevisited()) {
|
||||||
addBackEdge(postponedExitNode, postponedEnterNode)
|
addBackEdge(postponedExitNode, splitNode, label = LoopBackPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
postponedEnterNode.addSubGraph(graph)
|
|
||||||
// May not be the current graph: `nearestCompletedCall(run { run { generic() } }, 1)`
|
|
||||||
postponedEnterNode.owner.addSubGraph(graph)
|
|
||||||
return Triple(exitNode, postponedExitNode, graph)
|
return Triple(exitNode, postponedExitNode, graph)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun exitAnonymousFunctionExpression(anonymousFunctionExpression: FirAnonymousFunctionExpression): AnonymousFunctionExpressionExitNode {
|
|
||||||
return createAnonymousFunctionExpressionExitNode(anonymousFunctionExpression).also {
|
|
||||||
addNewSimpleNode(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun splitDataFlowForPostponedLambdas() {
|
private fun splitDataFlowForPostponedLambdas() {
|
||||||
postponedLambdaExits.push(mutableListOf())
|
postponedLambdaExits.push(mutableListOf())
|
||||||
}
|
}
|
||||||
@@ -1084,6 +1089,20 @@ class ControlFlowGraphBuilder {
|
|||||||
splitDataFlowForPostponedLambdas()
|
splitDataFlowForPostponedLambdas()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun enterCallArguments(fir: FirStatement, anonymousFunctions: List<FirAnonymousFunction>) {
|
||||||
|
if (anonymousFunctions.isEmpty()) {
|
||||||
|
argumentListSplitNodes.push(null)
|
||||||
|
} else {
|
||||||
|
val splitNode = createSplitPostponedLambdasNode(fir, anonymousFunctions)
|
||||||
|
anonymousFunctions.associateTo(postponedAnonymousFunctionNodes) { it.symbol to (splitNode to null) }
|
||||||
|
argumentListSplitNodes.push(splitNode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun exitCallArguments(): SplitPostponedLambdasNode? {
|
||||||
|
return argumentListSplitNodes.pop()?.also { addNewSimpleNode(it) }
|
||||||
|
}
|
||||||
|
|
||||||
fun exitFunctionCall(functionCall: FirFunctionCall, callCompleted: Boolean): FunctionCallNode {
|
fun exitFunctionCall(functionCall: FirFunctionCall, callCompleted: Boolean): FunctionCallNode {
|
||||||
levelCounter--
|
levelCounter--
|
||||||
val returnsNothing = functionCall.resultType.isNothing
|
val returnsNothing = functionCall.resultType.isNothing
|
||||||
|
|||||||
+7
-7
@@ -223,11 +223,14 @@ fun ControlFlowGraphBuilder.createEnterSafeCallNode(fir: FirSafeCallExpression):
|
|||||||
fun ControlFlowGraphBuilder.createPostponedLambdaExitNode(fir: FirAnonymousFunctionExpression): PostponedLambdaExitNode =
|
fun ControlFlowGraphBuilder.createPostponedLambdaExitNode(fir: FirAnonymousFunctionExpression): PostponedLambdaExitNode =
|
||||||
PostponedLambdaExitNode(currentGraph, fir, levelCounter, createId())
|
PostponedLambdaExitNode(currentGraph, fir, levelCounter, createId())
|
||||||
|
|
||||||
fun ControlFlowGraphBuilder.createPostponedLambdaEnterNode(fir: FirAnonymousFunctionExpression): PostponedLambdaEnterNode =
|
fun ControlFlowGraphBuilder.createSplitPostponedLambdasNode(fir: FirStatement, lambdas: List<FirAnonymousFunction>): SplitPostponedLambdasNode =
|
||||||
PostponedLambdaEnterNode(currentGraph, fir, levelCounter, createId())
|
SplitPostponedLambdasNode(currentGraph, fir, lambdas, levelCounter, createId())
|
||||||
|
|
||||||
fun ControlFlowGraphBuilder.createAnonymousFunctionExpressionExitNode(fir: FirAnonymousFunctionExpression): AnonymousFunctionExpressionExitNode =
|
fun ControlFlowGraphBuilder.createMergePostponedLambdaExitsNode(fir: FirElement): MergePostponedLambdaExitsNode =
|
||||||
AnonymousFunctionExpressionExitNode(currentGraph, fir, levelCounter, createId())
|
MergePostponedLambdaExitsNode(currentGraph, fir, levelCounter, createId())
|
||||||
|
|
||||||
|
fun ControlFlowGraphBuilder.createAnonymousFunctionExpressionNode(fir: FirAnonymousFunctionExpression): AnonymousFunctionExpressionNode =
|
||||||
|
AnonymousFunctionExpressionNode(currentGraph, fir, levelCounter, createId())
|
||||||
|
|
||||||
fun ControlFlowGraphBuilder.createAnonymousObjectEnterNode(fir: FirAnonymousObject): AnonymousObjectEnterNode =
|
fun ControlFlowGraphBuilder.createAnonymousObjectEnterNode(fir: FirAnonymousObject): AnonymousObjectEnterNode =
|
||||||
AnonymousObjectEnterNode(currentGraph, fir, levelCounter, createId())
|
AnonymousObjectEnterNode(currentGraph, fir, levelCounter, createId())
|
||||||
@@ -244,9 +247,6 @@ fun ControlFlowGraphBuilder.createScriptEnterNode(fir: FirScript): ScriptEnterNo
|
|||||||
fun ControlFlowGraphBuilder.createScriptExitNode(fir: FirScript): ScriptExitNode =
|
fun ControlFlowGraphBuilder.createScriptExitNode(fir: FirScript): ScriptExitNode =
|
||||||
ScriptExitNode(currentGraph, fir, levelCounter, createId())
|
ScriptExitNode(currentGraph, fir, levelCounter, createId())
|
||||||
|
|
||||||
fun ControlFlowGraphBuilder.createMergePostponedLambdaExitsNode(fir: FirElement): MergePostponedLambdaExitsNode =
|
|
||||||
MergePostponedLambdaExitsNode(currentGraph, fir, levelCounter, createId())
|
|
||||||
|
|
||||||
fun ControlFlowGraphBuilder.createClassEnterNode(fir: FirClass): ClassEnterNode =
|
fun ControlFlowGraphBuilder.createClassEnterNode(fir: FirClass): ClassEnterNode =
|
||||||
ClassEnterNode(currentGraph, fir, levelCounter, createId())
|
ClassEnterNode(currentGraph, fir, levelCounter, createId())
|
||||||
|
|
||||||
|
|||||||
+49
-55
@@ -164,8 +164,6 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
|
|||||||
}
|
}
|
||||||
when (result) {
|
when (result) {
|
||||||
is FirQualifiedAccessExpression -> {
|
is FirQualifiedAccessExpression -> {
|
||||||
// TODO: Is it really needed?
|
|
||||||
dataFlowAnalyzer.enterQualifiedAccessExpression()
|
|
||||||
dataFlowAnalyzer.exitQualifiedAccessExpression(result)
|
dataFlowAnalyzer.exitQualifiedAccessExpression(result)
|
||||||
result = components.transformQualifiedAccessUsingSmartcastInfo(result)
|
result = components.transformQualifiedAccessUsingSmartcastInfo(result)
|
||||||
if (result is FirSmartCastExpression) {
|
if (result is FirSmartCastExpression) {
|
||||||
@@ -179,6 +177,27 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun <Q : FirQualifiedAccess> transformExplicitReceiver(qualifiedAccessExpression: Q): Q {
|
||||||
|
val explicitReceiver = qualifiedAccessExpression.explicitReceiver as? FirQualifiedAccessExpression
|
||||||
|
if (explicitReceiver is FirQualifiedAccessExpression) {
|
||||||
|
val superReference = explicitReceiver.calleeReference as? FirSuperReference
|
||||||
|
if (superReference != null) {
|
||||||
|
transformSuperReceiver(superReference, explicitReceiver, qualifiedAccessExpression)
|
||||||
|
return qualifiedAccessExpression
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (explicitReceiver is FirPropertyAccessExpression) {
|
||||||
|
qualifiedAccessExpression.replaceExplicitReceiver(
|
||||||
|
transformQualifiedAccessExpression(
|
||||||
|
explicitReceiver, ResolutionMode.ReceiverResolution, isUsedAsReceiver = true
|
||||||
|
) as FirExpression
|
||||||
|
)
|
||||||
|
return qualifiedAccessExpression
|
||||||
|
}
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
return qualifiedAccessExpression.transformExplicitReceiver(transformer, ResolutionMode.ReceiverResolution) as Q
|
||||||
|
}
|
||||||
|
|
||||||
override fun transformPropertyAccessExpression(
|
override fun transformPropertyAccessExpression(
|
||||||
propertyAccessExpression: FirPropertyAccessExpression,
|
propertyAccessExpression: FirPropertyAccessExpression,
|
||||||
data: ResolutionMode
|
data: ResolutionMode
|
||||||
@@ -379,11 +398,19 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
|
|||||||
functionCall.transformAnnotations(transformer, data)
|
functionCall.transformAnnotations(transformer, data)
|
||||||
functionCall.replaceLambdaArgumentInvocationKinds(session)
|
functionCall.replaceLambdaArgumentInvocationKinds(session)
|
||||||
functionCall.transformTypeArguments(transformer, ResolutionMode.ContextIndependent)
|
functionCall.transformTypeArguments(transformer, ResolutionMode.ContextIndependent)
|
||||||
dataFlowAnalyzer.enterFunctionCall(functionCall)
|
|
||||||
val (completeInference, callCompleted) =
|
val (completeInference, callCompleted) =
|
||||||
try {
|
try {
|
||||||
val initialExplicitReceiver = functionCall.explicitReceiver
|
val initialExplicitReceiver = functionCall.explicitReceiver
|
||||||
val resultExpression = callResolver.resolveCallAndSelectCandidate(functionCall)
|
val withTransformedArguments = if (!resolvingAugmentedAssignment) {
|
||||||
|
dataFlowAnalyzer.enterCallArguments(functionCall, functionCall.arguments)
|
||||||
|
transformExplicitReceiver(functionCall).also {
|
||||||
|
it.replaceArgumentList(it.argumentList.transform(this, ResolutionMode.ContextDependent))
|
||||||
|
dataFlowAnalyzer.exitCallArguments()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
functionCall
|
||||||
|
}
|
||||||
|
val resultExpression = callResolver.resolveCallAndSelectCandidate(withTransformedArguments)
|
||||||
val resultExplicitReceiver = resultExpression.explicitReceiver?.unwrapSmartcastExpression()
|
val resultExplicitReceiver = resultExpression.explicitReceiver?.unwrapSmartcastExpression()
|
||||||
if (initialExplicitReceiver !== resultExplicitReceiver && resultExplicitReceiver is FirQualifiedAccess) {
|
if (initialExplicitReceiver !== resultExplicitReceiver && resultExplicitReceiver is FirQualifiedAccess) {
|
||||||
// name.invoke() case
|
// name.invoke() case
|
||||||
@@ -395,7 +422,9 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
|
|||||||
throw RuntimeException("While resolving call ${functionCall.render()}", e)
|
throw RuntimeException("While resolving call ${functionCall.render()}", e)
|
||||||
}
|
}
|
||||||
val result = completeInference.transformToIntegerOperatorCallOrApproximateItIfNeeded(data)
|
val result = completeInference.transformToIntegerOperatorCallOrApproximateItIfNeeded(data)
|
||||||
dataFlowAnalyzer.exitFunctionCall(result, callCompleted)
|
if (!resolvingAugmentedAssignment) {
|
||||||
|
dataFlowAnalyzer.exitFunctionCall(result, callCompleted)
|
||||||
|
}
|
||||||
|
|
||||||
addReceiversFromExtensions(result)
|
addReceiversFromExtensions(result)
|
||||||
|
|
||||||
@@ -533,12 +562,12 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
|
|||||||
require(operation != FirOperation.ASSIGN)
|
require(operation != FirOperation.ASSIGN)
|
||||||
|
|
||||||
assignmentOperatorStatement.transformAnnotations(transformer, ResolutionMode.ContextIndependent)
|
assignmentOperatorStatement.transformAnnotations(transformer, ResolutionMode.ContextIndependent)
|
||||||
dataFlowAnalyzer.enterAugmentedAssignmentCall()
|
dataFlowAnalyzer.enterCallArguments(assignmentOperatorStatement, listOf(assignmentOperatorStatement.rightArgument))
|
||||||
val leftArgument = assignmentOperatorStatement.leftArgument.transformSingle(transformer, ResolutionMode.ContextIndependent)
|
val leftArgument = assignmentOperatorStatement.leftArgument.transformSingle(transformer, ResolutionMode.ContextIndependent)
|
||||||
val rightArgument = assignmentOperatorStatement.rightArgument.transformSingle(transformer, ResolutionMode.ContextDependent)
|
val rightArgument = assignmentOperatorStatement.rightArgument.transformSingle(transformer, ResolutionMode.ContextDependent)
|
||||||
|
dataFlowAnalyzer.exitCallArguments()
|
||||||
|
|
||||||
val generator = GeneratorOfPlusAssignCalls(assignmentOperatorStatement, operation, leftArgument, rightArgument)
|
val generator = GeneratorOfPlusAssignCalls(assignmentOperatorStatement, operation, leftArgument, rightArgument)
|
||||||
dataFlowAnalyzer.enterSelectAugmentedAssignmentCall()
|
|
||||||
|
|
||||||
// x.plusAssign(y)
|
// x.plusAssign(y)
|
||||||
val assignOperatorCall = generator.createAssignOperatorCall()
|
val assignOperatorCall = generator.createAssignOperatorCall()
|
||||||
@@ -556,8 +585,6 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
|
|||||||
val operatorCallReference = resolvedOperatorCall.calleeReference as? FirNamedReferenceWithCandidate
|
val operatorCallReference = resolvedOperatorCall.calleeReference as? FirNamedReferenceWithCandidate
|
||||||
val operatorIsSuccessful = operatorCallReference?.isError == false
|
val operatorIsSuccessful = operatorCallReference?.isError == false
|
||||||
|
|
||||||
dataFlowAnalyzer.exitSelectAugmentedAssignmentCall()
|
|
||||||
|
|
||||||
fun operatorReturnTypeMatches(candidate: Candidate): Boolean {
|
fun operatorReturnTypeMatches(candidate: Candidate): Boolean {
|
||||||
// After KT-45503, non-assign flavor of operator is checked more strictly: the return type must be assignable to the variable.
|
// After KT-45503, non-assign flavor of operator is checked more strictly: the return type must be assignable to the variable.
|
||||||
val operatorCallReturnType = resolvedOperatorCall.typeRef.coneType
|
val operatorCallReturnType = resolvedOperatorCall.typeRef.coneType
|
||||||
@@ -671,11 +698,17 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
|
|||||||
return equalityOperatorCall
|
return equalityOperatorCall
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var resolvingAugmentedAssignment: Boolean = false
|
||||||
|
|
||||||
private inline fun <T> resolveCandidateForAssignmentOperatorCall(block: () -> T): T {
|
private inline fun <T> resolveCandidateForAssignmentOperatorCall(block: () -> T): T {
|
||||||
return callResolver.withNoArgumentsTransform {
|
assert(!resolvingAugmentedAssignment)
|
||||||
|
resolvingAugmentedAssignment = true
|
||||||
|
return try {
|
||||||
context.withInferenceSession(InferenceSessionForAssignmentOperatorCall) {
|
context.withInferenceSession(InferenceSessionForAssignmentOperatorCall) {
|
||||||
block()
|
block()
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
resolvingAugmentedAssignment = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1121,12 +1154,12 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
dataFlowAnalyzer.enterDelegatedConstructorCall()
|
dataFlowAnalyzer.enterCallArguments(delegatedConstructorCall, delegatedConstructorCall.arguments)
|
||||||
|
|
||||||
val lastDispatchReceiver = implicitReceiverStack.lastDispatchReceiver()
|
val lastDispatchReceiver = implicitReceiverStack.lastDispatchReceiver()
|
||||||
context.forDelegatedConstructorCall(containingConstructor, containingClass as? FirRegularClass, components) {
|
context.forDelegatedConstructorCall(containingConstructor, containingClass as? FirRegularClass, components) {
|
||||||
delegatedConstructorCall.transformChildren(transformer, ResolutionMode.ContextDependent)
|
delegatedConstructorCall.transformChildren(transformer, ResolutionMode.ContextDependent)
|
||||||
}
|
}
|
||||||
|
dataFlowAnalyzer.exitCallArguments()
|
||||||
|
|
||||||
val reference = delegatedConstructorCall.calleeReference
|
val reference = delegatedConstructorCall.calleeReference
|
||||||
val constructorType: ConeClassLikeType? = when (reference) {
|
val constructorType: ConeClassLikeType? = when (reference) {
|
||||||
@@ -1225,15 +1258,14 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
|
|||||||
|
|
||||||
augmentedArraySetCall.transformAnnotations(transformer, data)
|
augmentedArraySetCall.transformAnnotations(transformer, data)
|
||||||
|
|
||||||
|
dataFlowAnalyzer.enterCallArguments(augmentedArraySetCall, listOf(augmentedArraySetCall.rhs))
|
||||||
// transformedLhsCall: a.get(index)
|
// transformedLhsCall: a.get(index)
|
||||||
dataFlowAnalyzer.enterAugmentedAssignmentCall()
|
|
||||||
val transformedLhsCall = augmentedArraySetCall.lhsGetCall.transformSingle(transformer, ResolutionMode.ContextIndependent)
|
val transformedLhsCall = augmentedArraySetCall.lhsGetCall.transformSingle(transformer, ResolutionMode.ContextIndependent)
|
||||||
val transformedRhs = augmentedArraySetCall.rhs.transformSingle(transformer, ResolutionMode.ContextDependent)
|
val transformedRhs = augmentedArraySetCall.rhs.transformSingle(transformer, ResolutionMode.ContextDependent)
|
||||||
|
dataFlowAnalyzer.exitCallArguments()
|
||||||
|
|
||||||
val generator = GeneratorOfPlusAssignCalls(augmentedArraySetCall, operation, transformedLhsCall, transformedRhs)
|
val generator = GeneratorOfPlusAssignCalls(augmentedArraySetCall, operation, transformedLhsCall, transformedRhs)
|
||||||
|
|
||||||
dataFlowAnalyzer.enterSelectAugmentedAssignmentCall()
|
|
||||||
|
|
||||||
// a.get(b).plusAssign(c)
|
// a.get(b).plusAssign(c)
|
||||||
val assignOperatorCall = generator.createAssignOperatorCall()
|
val assignOperatorCall = generator.createAssignOperatorCall()
|
||||||
val resolvedAssignCall = resolveCandidateForAssignmentOperatorCall {
|
val resolvedAssignCall = resolveCandidateForAssignmentOperatorCall {
|
||||||
@@ -1250,15 +1282,12 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
|
|||||||
|
|
||||||
// prefer a "simpler" variant for dynamics
|
// prefer a "simpler" variant for dynamics
|
||||||
if (transformedLhsCall.calleeReference.resolvedSymbol?.origin == FirDeclarationOrigin.DynamicScope) {
|
if (transformedLhsCall.calleeReference.resolvedSymbol?.origin == FirDeclarationOrigin.DynamicScope) {
|
||||||
dataFlowAnalyzer.exitSelectAugmentedAssignmentCall()
|
|
||||||
return chooseAssign()
|
return chooseAssign()
|
||||||
}
|
}
|
||||||
|
|
||||||
// <array>.set(<index_i>, <array>.get(<index_i>).plus(c))
|
// <array>.set(<index_i>, <array>.get(<index_i>).plus(c))
|
||||||
val info = tryResolveAugmentedArraySetCallAsSetGetBlock(augmentedArraySetCall, transformedLhsCall, transformedRhs)
|
val info = tryResolveAugmentedArraySetCallAsSetGetBlock(augmentedArraySetCall, transformedLhsCall, transformedRhs)
|
||||||
|
|
||||||
dataFlowAnalyzer.exitSelectAugmentedAssignmentCall()
|
|
||||||
|
|
||||||
val resolvedOperatorCall = info.operatorCall
|
val resolvedOperatorCall = info.operatorCall
|
||||||
val operatorCallReference = resolvedOperatorCall.calleeReference as? FirNamedReferenceWithCandidate
|
val operatorCallReference = resolvedOperatorCall.calleeReference as? FirNamedReferenceWithCandidate
|
||||||
val operatorIsSuccessful = operatorCallReference?.isError == false
|
val operatorIsSuccessful = operatorCallReference?.isError == false
|
||||||
@@ -1482,47 +1511,12 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
|
|||||||
return anonymousObjectExpression
|
return anonymousObjectExpression
|
||||||
}
|
}
|
||||||
|
|
||||||
private val nonLambdaArgumentTransformer = object : FirTransformer<ResolutionMode>() {
|
|
||||||
override fun <E : FirElement> transformElement(element: E, data: ResolutionMode): E =
|
|
||||||
element.transform(this@FirExpressionsResolveTransformer, data)
|
|
||||||
|
|
||||||
override fun transformAnonymousFunctionExpression(
|
|
||||||
anonymousFunctionExpression: FirAnonymousFunctionExpression,
|
|
||||||
data: ResolutionMode
|
|
||||||
): FirStatement = anonymousFunctionExpression
|
|
||||||
}
|
|
||||||
|
|
||||||
private val lambdaArgumentTransformer = object : FirTransformer<ResolutionMode>() {
|
|
||||||
override fun <E : FirElement> transformElement(element: E, data: ResolutionMode): E =
|
|
||||||
element
|
|
||||||
|
|
||||||
override fun transformAnonymousFunctionExpression(
|
|
||||||
anonymousFunctionExpression: FirAnonymousFunctionExpression,
|
|
||||||
data: ResolutionMode
|
|
||||||
): FirStatement = this@FirExpressionsResolveTransformer.transformAnonymousFunctionExpression(anonymousFunctionExpression, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun transformArgumentList(argumentList: FirArgumentList, data: ResolutionMode): FirArgumentList {
|
|
||||||
// Transform all normal arguments first and then lambda to make CFG correct. See KT-46825
|
|
||||||
return argumentList
|
|
||||||
.transformArguments(nonLambdaArgumentTransformer, data)
|
|
||||||
.transformArguments(lambdaArgumentTransformer, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun transformAnonymousFunctionExpression(
|
override fun transformAnonymousFunctionExpression(
|
||||||
anonymousFunctionExpression: FirAnonymousFunctionExpression,
|
anonymousFunctionExpression: FirAnonymousFunctionExpression,
|
||||||
data: ResolutionMode
|
data: ResolutionMode
|
||||||
): FirStatement {
|
): FirStatement {
|
||||||
anonymousFunctionExpression.transformAnonymousFunction(transformer, data)
|
dataFlowAnalyzer.enterAnonymousFunctionExpression(anonymousFunctionExpression)
|
||||||
when (data) {
|
return anonymousFunctionExpression.transformAnonymousFunction(transformer, data)
|
||||||
is ResolutionMode.ContextDependent, is ResolutionMode.ContextDependentDelegate -> {
|
|
||||||
dataFlowAnalyzer.visitPostponedAnonymousFunction(anonymousFunctionExpression)
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
dataFlowAnalyzer.exitAnonymousFunctionExpression(anonymousFunctionExpression)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return anonymousFunctionExpression
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -243,9 +243,10 @@ class ExitDefaultArgumentsNode(owner: ControlFlowGraph, override val fir: FirVal
|
|||||||
|
|
||||||
// ----------------------------------- Anonymous function -----------------------------------
|
// ----------------------------------- Anonymous function -----------------------------------
|
||||||
|
|
||||||
class PostponedLambdaEnterNode(owner: ControlFlowGraph, override val fir: FirAnonymousFunctionExpression, level: Int, id: Int) : CFGNodeWithSubgraphs<FirAnonymousFunctionExpression>(owner, level, id) {
|
class SplitPostponedLambdasNode(owner: ControlFlowGraph, override val fir: FirStatement, val lambdas: List<FirAnonymousFunction>, level: Int, id: Int)
|
||||||
|
: CFGNodeWithSubgraphs<FirStatement>(owner, level, id) {
|
||||||
override fun <R, D> accept(visitor: ControlFlowGraphVisitor<R, D>, data: D): R {
|
override fun <R, D> accept(visitor: ControlFlowGraphVisitor<R, D>, data: D): R {
|
||||||
return visitor.visitPostponedLambdaEnterNode(this, data)
|
return visitor.visitSplitPostponedLambdasNode(this, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,9 +262,9 @@ class MergePostponedLambdaExitsNode(owner: ControlFlowGraph, override val fir: F
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AnonymousFunctionExpressionExitNode(owner: ControlFlowGraph, override val fir: FirAnonymousFunctionExpression, level: Int, id: Int) : CFGNode<FirAnonymousFunctionExpression>(owner, level, id) {
|
class AnonymousFunctionExpressionNode(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 {
|
override fun <R, D> accept(visitor: ControlFlowGraphVisitor<R, D>, data: D): R {
|
||||||
return visitor.visitAnonymousFunctionExpressionExitNode(this, data)
|
return visitor.visitAnonymousFunctionExpressionNode(this, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-4
@@ -98,12 +98,10 @@ fun CFGNode<*>.render(): String =
|
|||||||
|
|
||||||
is WhenSubjectExpressionExitNode -> "Exit ${'$'}subj"
|
is WhenSubjectExpressionExitNode -> "Exit ${'$'}subj"
|
||||||
|
|
||||||
is PostponedLambdaEnterNode -> "Postponed enter to lambda"
|
is SplitPostponedLambdasNode -> "Postponed enter to lambda"
|
||||||
is PostponedLambdaExitNode -> "Postponed exit from lambda"
|
is PostponedLambdaExitNode -> "Postponed exit from lambda"
|
||||||
|
|
||||||
is AnonymousFunctionExpressionExitNode -> "Exit anonymous function expression"
|
|
||||||
|
|
||||||
is MergePostponedLambdaExitsNode -> "Merge postponed lambda exits"
|
is MergePostponedLambdaExitsNode -> "Merge postponed lambda exits"
|
||||||
|
is AnonymousFunctionExpressionNode -> "Exit anonymous function expression"
|
||||||
|
|
||||||
is ClassEnterNode -> "Enter class ${owner.name}"
|
is ClassEnterNode -> "Enter class ${owner.name}"
|
||||||
is ClassExitNode -> "Exit class ${owner.name}"
|
is ClassExitNode -> "Exit class ${owner.name}"
|
||||||
|
|||||||
+2
-2
@@ -36,7 +36,7 @@ abstract class ControlFlowGraphVisitor<out R, in D> {
|
|||||||
|
|
||||||
// ----------------------------------- Anonymous function -----------------------------------
|
// ----------------------------------- Anonymous function -----------------------------------
|
||||||
|
|
||||||
open fun visitPostponedLambdaEnterNode(node: PostponedLambdaEnterNode, data: D): R {
|
open fun visitSplitPostponedLambdasNode(node: SplitPostponedLambdasNode, data: D): R {
|
||||||
return visitNode(node, data)
|
return visitNode(node, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ abstract class ControlFlowGraphVisitor<out R, in D> {
|
|||||||
return visitNode(node, data)
|
return visitNode(node, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun visitAnonymousFunctionExpressionExitNode(node: AnonymousFunctionExpressionExitNode, data: D): R {
|
open fun visitAnonymousFunctionExpressionNode(node: AnonymousFunctionExpressionNode, data: D): R {
|
||||||
return visitNode(node, data)
|
return visitNode(node, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+19
-3
@@ -20,9 +20,13 @@ abstract class ControlFlowGraphVisitorVoid : ControlFlowGraphVisitor<Unit, Nothi
|
|||||||
visitNode(node)
|
visitNode(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun visitLocalFunctionDeclarationNode(node: LocalFunctionDeclarationNode) {
|
||||||
|
visitNode(node)
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------- Anonymous function -----------------------------------
|
// ----------------------------------- Anonymous function -----------------------------------
|
||||||
|
|
||||||
open fun visitPostponedLambdaEnterNode(node: PostponedLambdaEnterNode) {
|
open fun visitSplitPostponedLambdasNode(node: SplitPostponedLambdasNode) {
|
||||||
visitNode(node)
|
visitNode(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,6 +38,10 @@ abstract class ControlFlowGraphVisitorVoid : ControlFlowGraphVisitor<Unit, Nothi
|
|||||||
visitNode(node)
|
visitNode(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun visitAnonymousFunctionExpressionNode(node: AnonymousFunctionExpressionNode) {
|
||||||
|
visitNode(node)
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------- Anonymous object -----------------------------------
|
// ----------------------------------- Anonymous object -----------------------------------
|
||||||
|
|
||||||
open fun visitAnonymousObjectExitNode(node: AnonymousObjectExitNode) {
|
open fun visitAnonymousObjectExitNode(node: AnonymousObjectExitNode) {
|
||||||
@@ -313,10 +321,14 @@ abstract class ControlFlowGraphVisitorVoid : ControlFlowGraphVisitor<Unit, Nothi
|
|||||||
visitFunctionExitNode(node)
|
visitFunctionExitNode(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final override fun visitLocalFunctionDeclarationNode(node: LocalFunctionDeclarationNode, data: Nothing?) {
|
||||||
|
visitLocalFunctionDeclarationNode(node)
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------- Anonymous function -----------------------------------
|
// ----------------------------------- Anonymous function -----------------------------------
|
||||||
|
|
||||||
final override fun visitPostponedLambdaEnterNode(node: PostponedLambdaEnterNode, data: Nothing?) {
|
final override fun visitSplitPostponedLambdasNode(node: SplitPostponedLambdasNode, data: Nothing?) {
|
||||||
visitPostponedLambdaEnterNode(node)
|
visitSplitPostponedLambdasNode(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
final override fun visitPostponedLambdaExitNode(node: PostponedLambdaExitNode, data: Nothing?) {
|
final override fun visitPostponedLambdaExitNode(node: PostponedLambdaExitNode, data: Nothing?) {
|
||||||
@@ -327,6 +339,10 @@ abstract class ControlFlowGraphVisitorVoid : ControlFlowGraphVisitor<Unit, Nothi
|
|||||||
visitMergePostponedLambdaExitsNode(node)
|
visitMergePostponedLambdaExitsNode(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final override fun visitAnonymousFunctionExpressionNode(node: AnonymousFunctionExpressionNode, data: Nothing?) {
|
||||||
|
visitAnonymousFunctionExpressionNode(node)
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------- Anonymous object -----------------------------------
|
// ----------------------------------- Anonymous object -----------------------------------
|
||||||
|
|
||||||
final override fun visitAnonymousObjectExitNode(node: AnonymousObjectExitNode, data: Nothing?) {
|
final override fun visitAnonymousObjectExitNode(node: AnonymousObjectExitNode, data: Nothing?) {
|
||||||
|
|||||||
Reference in New Issue
Block a user