a9be27e330
Quick quiz:
Q: In a CFG, what does `a -> b -> c -> d` mean?
A: `a`, then `b`, then `c`, then `d`.
Q: In a CFG, what does `a -> b -> d; a -> c -> d` mean?
A: `a`, then `b` or `c`, then `d`.
Q: So how do you encode "a, then (b, then c) or (c, then b), then d`?
A: You can't.
Problem is, you need to, because that's what `a; run2({ b }, { c }); d`
does when `run2` has a contract that it calls both its lambda arguments
in-place: `shuffle(listOf(block1, block2)).forEach { it() }` is a
perfectly valid implementation for it, as little sense as that makes.
So that's what union nodes solve. When a node implements
`UnionNodeMarker`, its inputs are interpreted as "all visited in some
order" instead of the normal "one of the inputs is visited".
Currently this is used for data flow. It *should* also be used for
control flow, but it isn't. But it should be. But that's not so easy.
BTW, `try` exit is NOT a union node; although lambdas in one branch can
be completed according to types' of lambdas in another, data does not
flow between the branches anyway (since we don't know how much of the
`try` executed before jumping into `catch`, and `catch`es are mutually
exclusive) so a `try` expression is more like `when` than a function
call with called-in-place-exactly-once arguments. The fact that
`exitTryExpression` used `processUnionOfArguments` in a weird way
should've hinted at that, but now we know for certain.
385 lines
13 KiB
Plaintext
Vendored
385 lines
13 KiB
Plaintext
Vendored
digraph flowFromInplaceLambda3_kt {
|
|
graph [nodesep=3]
|
|
node [shape=box penwidth=2]
|
|
edge [penwidth=2]
|
|
|
|
subgraph cluster_0 {
|
|
color=red
|
|
0 [label="Enter function unknown" style="filled" fillcolor=red];
|
|
subgraph cluster_1 {
|
|
color=blue
|
|
1 [label="Enter block"];
|
|
2 [label="Function call: R|<local>/x|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()" style="filled" fillcolor=yellow];
|
|
3 [label="Exit block"];
|
|
}
|
|
4 [label="Exit function unknown" style="filled" fillcolor=red];
|
|
}
|
|
0 -> {1};
|
|
1 -> {2};
|
|
2 -> {3};
|
|
3 -> {4};
|
|
|
|
subgraph cluster_2 {
|
|
color=red
|
|
5 [label="Enter function atLeastOnce" style="filled" fillcolor=red];
|
|
subgraph cluster_3 {
|
|
color=blue
|
|
6 [label="Enter block"];
|
|
7 [label="Function call: R|<local>/x|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()" style="filled" fillcolor=yellow];
|
|
8 [label="Exit block"];
|
|
}
|
|
9 [label="Exit function atLeastOnce" style="filled" fillcolor=red];
|
|
}
|
|
5 -> {6};
|
|
6 -> {7};
|
|
7 -> {8};
|
|
8 -> {9};
|
|
|
|
subgraph cluster_4 {
|
|
color=red
|
|
10 [label="Enter function exactlyOnce" style="filled" fillcolor=red];
|
|
subgraph cluster_5 {
|
|
color=blue
|
|
11 [label="Enter block"];
|
|
12 [label="Function call: R|<local>/x|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()" style="filled" fillcolor=yellow];
|
|
13 [label="Exit block"];
|
|
}
|
|
14 [label="Exit function exactlyOnce" style="filled" fillcolor=red];
|
|
}
|
|
10 -> {11};
|
|
11 -> {12};
|
|
12 -> {13};
|
|
13 -> {14};
|
|
|
|
subgraph cluster_6 {
|
|
color=red
|
|
15 [label="Enter function atMostOnce" style="filled" fillcolor=red];
|
|
subgraph cluster_7 {
|
|
color=blue
|
|
16 [label="Enter block"];
|
|
17 [label="Exit block"];
|
|
}
|
|
18 [label="Exit function atMostOnce" style="filled" fillcolor=red];
|
|
}
|
|
15 -> {16};
|
|
16 -> {17};
|
|
17 -> {18};
|
|
|
|
subgraph cluster_8 {
|
|
color=red
|
|
19 [label="Enter function test1" style="filled" fillcolor=red];
|
|
subgraph cluster_9 {
|
|
color=blue
|
|
20 [label="Enter block"];
|
|
21 [label="Variable declaration: lvar x: R|kotlin/Any?|"];
|
|
22 [label="Const: String()"];
|
|
23 [label="Assignment: R|<local>/x|"];
|
|
24 [label="Access variable R|<local>/x|"];
|
|
25 [label="Smart cast: R|<local>/x|"];
|
|
26 [label="Access variable R|kotlin/String.length|"];
|
|
27 [label="Postponed enter to lambda"];
|
|
subgraph cluster_10 {
|
|
color=blue
|
|
38 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
|
subgraph cluster_11 {
|
|
color=blue
|
|
39 [label="Enter block"];
|
|
40 [label="Const: Int(1)"];
|
|
41 [label="Assignment: R|<local>/x|"];
|
|
42 [label="Exit block"];
|
|
}
|
|
43 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
|
}
|
|
28 [label="Postponed exit from lambda"];
|
|
29 [label="Function call: R|/unknown|(...)" style="filled" fillcolor=yellow];
|
|
30 [label="Access variable R|<local>/x|"];
|
|
31 [label="Smart cast: R|<local>/x|"];
|
|
32 [label="Access variable <Unresolved name: length>#"];
|
|
33 [label="Access variable R|<local>/x|"];
|
|
34 [label="Smart cast: R|<local>/x|"];
|
|
35 [label="Function call: R|<local>/x|.<Unresolved name: inc>#()" style="filled" fillcolor=yellow];
|
|
36 [label="Exit block"];
|
|
}
|
|
37 [label="Exit function test1" style="filled" fillcolor=red];
|
|
}
|
|
19 -> {20};
|
|
20 -> {21};
|
|
21 -> {22};
|
|
22 -> {23};
|
|
23 -> {24};
|
|
24 -> {25};
|
|
25 -> {26};
|
|
26 -> {27};
|
|
27 -> {28 38};
|
|
27 -> {38} [style=dashed];
|
|
28 -> {29};
|
|
28 -> {27} [color=green style=dashed];
|
|
29 -> {30};
|
|
30 -> {31};
|
|
31 -> {32};
|
|
32 -> {33};
|
|
33 -> {34};
|
|
34 -> {35};
|
|
35 -> {36};
|
|
36 -> {37};
|
|
38 -> {39};
|
|
39 -> {40};
|
|
40 -> {41};
|
|
41 -> {42};
|
|
42 -> {43};
|
|
43 -> {28};
|
|
|
|
subgraph cluster_12 {
|
|
color=red
|
|
44 [label="Enter function test1m" style="filled" fillcolor=red];
|
|
subgraph cluster_13 {
|
|
color=blue
|
|
45 [label="Enter block"];
|
|
46 [label="Variable declaration: lvar x: R|kotlin/Any?|"];
|
|
47 [label="Const: String()"];
|
|
48 [label="Assignment: R|<local>/x|"];
|
|
49 [label="Access variable R|<local>/x|"];
|
|
50 [label="Smart cast: R|<local>/x|"];
|
|
51 [label="Access variable R|kotlin/String.length|"];
|
|
52 [label="Postponed enter to lambda"];
|
|
subgraph cluster_14 {
|
|
color=blue
|
|
60 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
|
subgraph cluster_15 {
|
|
color=blue
|
|
61 [label="Enter block"];
|
|
62 [label="Const: String()"];
|
|
63 [label="Assignment: R|<local>/x|"];
|
|
64 [label="Exit block"];
|
|
}
|
|
65 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
|
}
|
|
53 [label="Postponed exit from lambda"];
|
|
54 [label="Function call: R|/unknown|(...)" style="filled" fillcolor=yellow];
|
|
55 [label="Access variable R|<local>/x|"];
|
|
56 [label="Smart cast: R|<local>/x|"];
|
|
57 [label="Access variable R|kotlin/String.length|"];
|
|
58 [label="Exit block"];
|
|
}
|
|
59 [label="Exit function test1m" style="filled" fillcolor=red];
|
|
}
|
|
44 -> {45};
|
|
45 -> {46};
|
|
46 -> {47};
|
|
47 -> {48};
|
|
48 -> {49};
|
|
49 -> {50};
|
|
50 -> {51};
|
|
51 -> {52};
|
|
52 -> {53 60};
|
|
52 -> {60} [style=dashed];
|
|
53 -> {54};
|
|
53 -> {52} [color=green style=dashed];
|
|
54 -> {55};
|
|
55 -> {56};
|
|
56 -> {57};
|
|
57 -> {58};
|
|
58 -> {59};
|
|
60 -> {61};
|
|
61 -> {62};
|
|
62 -> {63};
|
|
63 -> {64};
|
|
64 -> {65};
|
|
65 -> {53};
|
|
|
|
subgraph cluster_16 {
|
|
color=red
|
|
66 [label="Enter function test2" style="filled" fillcolor=red];
|
|
subgraph cluster_17 {
|
|
color=blue
|
|
67 [label="Enter block"];
|
|
68 [label="Variable declaration: lvar x: R|kotlin/Any?|"];
|
|
69 [label="Const: String()"];
|
|
70 [label="Assignment: R|<local>/x|"];
|
|
71 [label="Access variable R|<local>/x|"];
|
|
72 [label="Smart cast: R|<local>/x|"];
|
|
73 [label="Access variable R|kotlin/String.length|"];
|
|
74 [label="Postponed enter to lambda"];
|
|
subgraph cluster_18 {
|
|
color=blue
|
|
85 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
|
subgraph cluster_19 {
|
|
color=blue
|
|
86 [label="Enter block"];
|
|
87 [label="Const: Int(1)"];
|
|
88 [label="Assignment: R|<local>/x|"];
|
|
89 [label="Exit block"];
|
|
}
|
|
90 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
|
}
|
|
75 [label="Postponed exit from lambda"];
|
|
76 [label="Function call: R|/atLeastOnce|(...)" style="filled" fillcolor=yellow];
|
|
77 [label="Access variable R|<local>/x|"];
|
|
78 [label="Smart cast: R|<local>/x|"];
|
|
79 [label="Access variable <Unresolved name: length>#"];
|
|
80 [label="Access variable R|<local>/x|"];
|
|
81 [label="Smart cast: R|<local>/x|"];
|
|
82 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()" style="filled" fillcolor=yellow];
|
|
83 [label="Exit block"];
|
|
}
|
|
84 [label="Exit function test2" style="filled" fillcolor=red];
|
|
}
|
|
66 -> {67};
|
|
67 -> {68};
|
|
68 -> {69};
|
|
69 -> {70};
|
|
70 -> {71};
|
|
71 -> {72};
|
|
72 -> {73};
|
|
73 -> {74};
|
|
74 -> {85};
|
|
74 -> {75} [color=red];
|
|
74 -> {85} [style=dashed];
|
|
75 -> {76};
|
|
75 -> {74} [color=green style=dashed];
|
|
76 -> {77};
|
|
77 -> {78};
|
|
78 -> {79};
|
|
79 -> {80};
|
|
80 -> {81};
|
|
81 -> {82};
|
|
82 -> {83};
|
|
83 -> {84};
|
|
85 -> {86};
|
|
86 -> {87};
|
|
87 -> {88};
|
|
88 -> {89};
|
|
89 -> {90};
|
|
90 -> {76} [color=red];
|
|
90 -> {75} [color=green];
|
|
|
|
subgraph cluster_20 {
|
|
color=red
|
|
91 [label="Enter function test3" style="filled" fillcolor=red];
|
|
subgraph cluster_21 {
|
|
color=blue
|
|
92 [label="Enter block"];
|
|
93 [label="Variable declaration: lvar x: R|kotlin/Any?|"];
|
|
94 [label="Const: String()"];
|
|
95 [label="Assignment: R|<local>/x|"];
|
|
96 [label="Access variable R|<local>/x|"];
|
|
97 [label="Smart cast: R|<local>/x|"];
|
|
98 [label="Access variable R|kotlin/String.length|"];
|
|
99 [label="Postponed enter to lambda"];
|
|
subgraph cluster_22 {
|
|
color=blue
|
|
110 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
|
subgraph cluster_23 {
|
|
color=blue
|
|
111 [label="Enter block"];
|
|
112 [label="Const: Int(1)"];
|
|
113 [label="Assignment: R|<local>/x|"];
|
|
114 [label="Exit block"];
|
|
}
|
|
115 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
|
}
|
|
100 [label="Postponed exit from lambda"];
|
|
101 [label="Function call: R|/exactlyOnce|(...)" style="filled" fillcolor=yellow];
|
|
102 [label="Access variable R|<local>/x|"];
|
|
103 [label="Smart cast: R|<local>/x|"];
|
|
104 [label="Access variable <Unresolved name: length>#"];
|
|
105 [label="Access variable R|<local>/x|"];
|
|
106 [label="Smart cast: R|<local>/x|"];
|
|
107 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()" style="filled" fillcolor=yellow];
|
|
108 [label="Exit block"];
|
|
}
|
|
109 [label="Exit function test3" style="filled" fillcolor=red];
|
|
}
|
|
91 -> {92};
|
|
92 -> {93};
|
|
93 -> {94};
|
|
94 -> {95};
|
|
95 -> {96};
|
|
96 -> {97};
|
|
97 -> {98};
|
|
98 -> {99};
|
|
99 -> {110};
|
|
99 -> {100} [color=red];
|
|
99 -> {110} [style=dashed];
|
|
100 -> {101};
|
|
101 -> {102};
|
|
102 -> {103};
|
|
103 -> {104};
|
|
104 -> {105};
|
|
105 -> {106};
|
|
106 -> {107};
|
|
107 -> {108};
|
|
108 -> {109};
|
|
110 -> {111};
|
|
111 -> {112};
|
|
112 -> {113};
|
|
113 -> {114};
|
|
114 -> {115};
|
|
115 -> {101} [color=red];
|
|
115 -> {100} [color=green];
|
|
|
|
subgraph cluster_24 {
|
|
color=red
|
|
116 [label="Enter function test4" style="filled" fillcolor=red];
|
|
subgraph cluster_25 {
|
|
color=blue
|
|
117 [label="Enter block"];
|
|
118 [label="Variable declaration: lvar x: R|kotlin/Any?|"];
|
|
119 [label="Const: String()"];
|
|
120 [label="Assignment: R|<local>/x|"];
|
|
121 [label="Access variable R|<local>/x|"];
|
|
122 [label="Smart cast: R|<local>/x|"];
|
|
123 [label="Access variable R|kotlin/String.length|"];
|
|
124 [label="Postponed enter to lambda"];
|
|
subgraph cluster_26 {
|
|
color=blue
|
|
135 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
|
subgraph cluster_27 {
|
|
color=blue
|
|
136 [label="Enter block"];
|
|
137 [label="Const: Int(1)"];
|
|
138 [label="Assignment: R|<local>/x|"];
|
|
139 [label="Exit block"];
|
|
}
|
|
140 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
|
}
|
|
125 [label="Postponed exit from lambda"];
|
|
126 [label="Function call: R|/atMostOnce|(...)" style="filled" fillcolor=yellow];
|
|
127 [label="Access variable R|<local>/x|"];
|
|
128 [label="Smart cast: R|<local>/x|"];
|
|
129 [label="Access variable <Unresolved name: length>#"];
|
|
130 [label="Access variable R|<local>/x|"];
|
|
131 [label="Smart cast: R|<local>/x|"];
|
|
132 [label="Function call: R|<local>/x|.<Unresolved name: inc>#()" style="filled" fillcolor=yellow];
|
|
133 [label="Exit block"];
|
|
}
|
|
134 [label="Exit function test4" style="filled" fillcolor=red];
|
|
}
|
|
116 -> {117};
|
|
117 -> {118};
|
|
118 -> {119};
|
|
119 -> {120};
|
|
120 -> {121};
|
|
121 -> {122};
|
|
122 -> {123};
|
|
123 -> {124};
|
|
124 -> {125 135};
|
|
124 -> {135} [style=dashed];
|
|
125 -> {126};
|
|
126 -> {127};
|
|
127 -> {128};
|
|
128 -> {129};
|
|
129 -> {130};
|
|
130 -> {131};
|
|
131 -> {132};
|
|
132 -> {133};
|
|
133 -> {134};
|
|
135 -> {136};
|
|
136 -> {137};
|
|
137 -> {138};
|
|
138 -> {139};
|
|
139 -> {140};
|
|
140 -> {125};
|
|
|
|
}
|