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.
291 lines
11 KiB
Plaintext
Vendored
291 lines
11 KiB
Plaintext
Vendored
digraph complex_kt {
|
|
graph [nodesep=3]
|
|
node [shape=box penwidth=2]
|
|
edge [penwidth=2]
|
|
|
|
subgraph cluster_0 {
|
|
color=red
|
|
0 [label="Enter function close" style="filled" fillcolor=red];
|
|
1 [label="Exit function close" style="filled" fillcolor=red];
|
|
}
|
|
0 -> {1};
|
|
|
|
subgraph cluster_1 {
|
|
color=red
|
|
2 [label="Enter class AutoCloseable" style="filled" fillcolor=red];
|
|
3 [label="Exit class AutoCloseable" style="filled" fillcolor=red];
|
|
}
|
|
2 -> {3} [color=green];
|
|
|
|
subgraph cluster_2 {
|
|
color=red
|
|
4 [label="Enter function closeFinally" style="filled" fillcolor=red];
|
|
subgraph cluster_3 {
|
|
color=blue
|
|
5 [label="Enter block"];
|
|
subgraph cluster_4 {
|
|
color=blue
|
|
6 [label="Enter when"];
|
|
subgraph cluster_5 {
|
|
color=blue
|
|
7 [label="Enter when branch condition "];
|
|
8 [label="Access variable this@R|/closeFinally|"];
|
|
9 [label="Const: Null(null)"];
|
|
10 [label="Equality operator =="];
|
|
11 [label="Exit when branch condition"];
|
|
}
|
|
subgraph cluster_6 {
|
|
color=blue
|
|
12 [label="Enter when branch condition "];
|
|
13 [label="Access variable R|<local>/cause|"];
|
|
14 [label="Const: Null(null)"];
|
|
15 [label="Equality operator =="];
|
|
16 [label="Exit when branch condition"];
|
|
}
|
|
subgraph cluster_7 {
|
|
color=blue
|
|
17 [label="Enter when branch condition else"];
|
|
18 [label="Exit when branch condition"];
|
|
}
|
|
19 [label="Enter when branch result"];
|
|
subgraph cluster_8 {
|
|
color=blue
|
|
20 [label="Enter block"];
|
|
subgraph cluster_9 {
|
|
color=blue
|
|
21 [label="Try expression enter"];
|
|
subgraph cluster_10 {
|
|
color=blue
|
|
22 [label="Try main block enter"];
|
|
subgraph cluster_11 {
|
|
color=blue
|
|
23 [label="Enter block"];
|
|
24 [label="Function call: this@R|/closeFinally|.R|/AutoCloseable.close|()" style="filled" fillcolor=yellow];
|
|
25 [label="Exit block"];
|
|
}
|
|
26 [label="Try main block exit"];
|
|
}
|
|
subgraph cluster_12 {
|
|
color=blue
|
|
27 [label="Catch enter"];
|
|
28 [label="Variable declaration: closeException: R|kotlin/Throwable|"];
|
|
subgraph cluster_13 {
|
|
color=blue
|
|
29 [label="Enter block"];
|
|
30 [label="Access variable R|<local>/cause|"];
|
|
31 [label="Smart cast: R|<local>/cause|"];
|
|
32 [label="Access variable R|<local>/closeException|"];
|
|
33 [label="Function call: R|<local>/cause|.R|kotlin/Throwable.addSuppressed|(...)" style="filled" fillcolor=yellow];
|
|
34 [label="Exit block"];
|
|
}
|
|
35 [label="Catch exit"];
|
|
}
|
|
36 [label="Try expression exit"];
|
|
}
|
|
37 [label="Exit block"];
|
|
}
|
|
38 [label="Exit when branch result"];
|
|
39 [label="Enter when branch result"];
|
|
subgraph cluster_14 {
|
|
color=blue
|
|
40 [label="Enter block"];
|
|
41 [label="Function call: this@R|/closeFinally|.R|/AutoCloseable.close|()" style="filled" fillcolor=yellow];
|
|
42 [label="Exit block"];
|
|
}
|
|
43 [label="Exit when branch result"];
|
|
44 [label="Enter when branch result"];
|
|
subgraph cluster_15 {
|
|
color=blue
|
|
45 [label="Enter block"];
|
|
46 [label="Exit block"];
|
|
}
|
|
47 [label="Exit when branch result"];
|
|
48 [label="Exit when"];
|
|
}
|
|
49 [label="Jump: ^closeFinally when () {
|
|
==(this@R|/closeFinally|, Null(null)) -> {
|
|
}
|
|
==(R|<local>/cause|, Null(null)) -> {
|
|
this@R|/closeFinally|.R|/AutoCloseable.close|()
|
|
}
|
|
else -> {
|
|
try {
|
|
this@R|/closeFinally|.R|/AutoCloseable.close|()
|
|
}
|
|
catch (closeException: R|kotlin/Throwable|) {
|
|
R|<local>/cause|.R|kotlin/Throwable.addSuppressed|(R|<local>/closeException|)
|
|
}
|
|
|
|
}
|
|
}
|
|
"];
|
|
50 [label="Stub" style="filled" fillcolor=gray];
|
|
51 [label="Exit block" style="filled" fillcolor=gray];
|
|
}
|
|
52 [label="Exit function closeFinally" style="filled" fillcolor=red];
|
|
}
|
|
4 -> {5};
|
|
5 -> {6};
|
|
6 -> {7};
|
|
7 -> {8};
|
|
8 -> {9};
|
|
9 -> {10};
|
|
10 -> {11};
|
|
11 -> {44 12};
|
|
12 -> {13};
|
|
13 -> {14};
|
|
14 -> {15};
|
|
15 -> {16};
|
|
16 -> {39 17};
|
|
17 -> {18};
|
|
18 -> {19};
|
|
19 -> {20};
|
|
20 -> {21};
|
|
21 -> {22 27};
|
|
22 -> {23};
|
|
23 -> {24};
|
|
24 -> {25};
|
|
25 -> {26};
|
|
26 -> {36 27};
|
|
27 -> {28};
|
|
27 -> {52} [label=onUncaughtException];
|
|
28 -> {29};
|
|
29 -> {30};
|
|
30 -> {31};
|
|
31 -> {32};
|
|
32 -> {33};
|
|
33 -> {34};
|
|
34 -> {35};
|
|
35 -> {36};
|
|
36 -> {37};
|
|
37 -> {38};
|
|
38 -> {48};
|
|
39 -> {40};
|
|
40 -> {41};
|
|
41 -> {42};
|
|
42 -> {43};
|
|
43 -> {48};
|
|
44 -> {45};
|
|
45 -> {46};
|
|
46 -> {47};
|
|
47 -> {48};
|
|
48 -> {49};
|
|
49 -> {52};
|
|
49 -> {50} [style=dotted];
|
|
50 -> {51} [style=dotted];
|
|
51 -> {52} [style=dotted];
|
|
|
|
subgraph cluster_16 {
|
|
color=red
|
|
53 [label="Enter function firstIsInstanceOrNull" style="filled" fillcolor=red];
|
|
subgraph cluster_17 {
|
|
color=blue
|
|
54 [label="Enter block"];
|
|
subgraph cluster_18 {
|
|
color=blue
|
|
55 [label="Enter block"];
|
|
56 [label="Access variable this@R|/firstIsInstanceOrNull|"];
|
|
57 [label="Function call: this@R|/firstIsInstanceOrNull|.R|SubstitutionOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<CapturedType(*)>|>|()" style="filled" fillcolor=yellow];
|
|
58 [label="Variable declaration: lval <iterator>: R|kotlin/collections/Iterator<kotlin/Any?>|"];
|
|
subgraph cluster_19 {
|
|
color=blue
|
|
59 [label="Enter while loop"];
|
|
subgraph cluster_20 {
|
|
color=blue
|
|
60 [label="Enter loop condition"];
|
|
61 [label="Access variable R|<local>/<iterator>|"];
|
|
62 [label="Function call: R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.hasNext: R|kotlin/Boolean|>|()" style="filled" fillcolor=yellow];
|
|
63 [label="Exit loop condition"];
|
|
}
|
|
subgraph cluster_21 {
|
|
color=blue
|
|
64 [label="Enter loop block"];
|
|
subgraph cluster_22 {
|
|
color=blue
|
|
65 [label="Enter block"];
|
|
66 [label="Access variable R|<local>/<iterator>|"];
|
|
67 [label="Function call: R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|kotlin/Any?|>|()" style="filled" fillcolor=yellow];
|
|
68 [label="Variable declaration: lval element: R|kotlin/Any?|"];
|
|
subgraph cluster_23 {
|
|
color=blue
|
|
69 [label="Enter when"];
|
|
subgraph cluster_24 {
|
|
color=blue
|
|
70 [label="Enter when branch condition "];
|
|
71 [label="Access variable R|<local>/element|"];
|
|
72 [label="Type operator: (R|<local>/element| is R|T|)"];
|
|
73 [label="Exit when branch condition"];
|
|
}
|
|
74 [label="Synthetic else branch"];
|
|
75 [label="Enter when branch result"];
|
|
subgraph cluster_25 {
|
|
color=blue
|
|
76 [label="Enter block"];
|
|
77 [label="Access variable R|<local>/element|"];
|
|
78 [label="Smart cast: R|<local>/element|"];
|
|
79 [label="Jump: ^firstIsInstanceOrNull R|<local>/element|"];
|
|
80 [label="Stub" style="filled" fillcolor=gray];
|
|
81 [label="Exit block" style="filled" fillcolor=gray];
|
|
}
|
|
82 [label="Exit when branch result" style="filled" fillcolor=gray];
|
|
83 [label="Exit when"];
|
|
}
|
|
84 [label="Exit block"];
|
|
}
|
|
85 [label="Exit loop block"];
|
|
}
|
|
86 [label="Exit whileloop"];
|
|
}
|
|
87 [label="Exit block"];
|
|
}
|
|
88 [label="Const: Null(null)"];
|
|
89 [label="Jump: ^firstIsInstanceOrNull Null(null)"];
|
|
90 [label="Stub" style="filled" fillcolor=gray];
|
|
91 [label="Exit block" style="filled" fillcolor=gray];
|
|
}
|
|
92 [label="Exit function firstIsInstanceOrNull" style="filled" fillcolor=red];
|
|
}
|
|
53 -> {54};
|
|
54 -> {55};
|
|
55 -> {56};
|
|
56 -> {57};
|
|
57 -> {58};
|
|
58 -> {59};
|
|
59 -> {60};
|
|
60 -> {61};
|
|
61 -> {62};
|
|
62 -> {63};
|
|
63 -> {86 64};
|
|
64 -> {65};
|
|
65 -> {66};
|
|
66 -> {67};
|
|
67 -> {68};
|
|
68 -> {69};
|
|
69 -> {70};
|
|
70 -> {71};
|
|
71 -> {72};
|
|
72 -> {73};
|
|
73 -> {75 74};
|
|
74 -> {83};
|
|
75 -> {76};
|
|
76 -> {77};
|
|
77 -> {78};
|
|
78 -> {79};
|
|
79 -> {92};
|
|
79 -> {80} [style=dotted];
|
|
80 -> {81} [style=dotted];
|
|
81 -> {82} [style=dotted];
|
|
82 -> {83} [style=dotted];
|
|
83 -> {84};
|
|
84 -> {85};
|
|
85 -> {60} [color=green style=dashed];
|
|
86 -> {87};
|
|
87 -> {88};
|
|
88 -> {89};
|
|
89 -> {92};
|
|
89 -> {90} [style=dotted];
|
|
90 -> {91} [style=dotted];
|
|
91 -> {92} [style=dotted];
|
|
|
|
}
|