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.
107 lines
3.3 KiB
Plaintext
Vendored
107 lines
3.3 KiB
Plaintext
Vendored
digraph annotatedLocalClass_kt {
|
|
graph [nodesep=3]
|
|
node [shape=box penwidth=2]
|
|
edge [penwidth=2]
|
|
|
|
subgraph cluster_0 {
|
|
color=red
|
|
0 [label="Enter function <init>" style="filled" fillcolor=red];
|
|
1 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
|
|
2 [label="Exit function <init>" style="filled" fillcolor=red];
|
|
}
|
|
0 -> {1};
|
|
1 -> {2};
|
|
|
|
subgraph cluster_1 {
|
|
color=red
|
|
3 [label="Enter class Ann" style="filled" fillcolor=red];
|
|
4 [label="Exit class Ann" style="filled" fillcolor=red];
|
|
}
|
|
3 -> {4} [color=green];
|
|
|
|
subgraph cluster_2 {
|
|
color=red
|
|
5 [label="Enter function foo" style="filled" fillcolor=red];
|
|
subgraph cluster_3 {
|
|
color=blue
|
|
6 [label="Enter block"];
|
|
subgraph cluster_4 {
|
|
color=blue
|
|
7 [label="Enter when"];
|
|
subgraph cluster_5 {
|
|
color=blue
|
|
8 [label="Enter when branch condition "];
|
|
9 [label="Access variable R|<local>/b|"];
|
|
10 [label="Exit when branch condition"];
|
|
}
|
|
11 [label="Synthetic else branch"];
|
|
12 [label="Enter when branch result"];
|
|
subgraph cluster_6 {
|
|
color=blue
|
|
13 [label="Enter block"];
|
|
14 [label="Jump: ^foo Unit"];
|
|
15 [label="Stub" style="filled" fillcolor=gray];
|
|
16 [label="Exit block" style="filled" fillcolor=gray];
|
|
}
|
|
17 [label="Exit when branch result" style="filled" fillcolor=gray];
|
|
18 [label="Exit when"];
|
|
}
|
|
19 [label="Exit local class foo"];
|
|
20 [label="Function call: R|/bar|()" style="filled" fillcolor=yellow];
|
|
21 [label="Exit block"];
|
|
}
|
|
subgraph cluster_7 {
|
|
color=blue
|
|
23 [label="Enter class Local" style="filled" fillcolor=red];
|
|
24 [label="Exit class Local" style="filled" fillcolor=red];
|
|
}
|
|
22 [label="Exit function foo" style="filled" fillcolor=red];
|
|
}
|
|
5 -> {6};
|
|
6 -> {7};
|
|
7 -> {8};
|
|
8 -> {9};
|
|
9 -> {10};
|
|
10 -> {12 11};
|
|
11 -> {18};
|
|
12 -> {13};
|
|
13 -> {14};
|
|
14 -> {22};
|
|
14 -> {15} [style=dotted];
|
|
15 -> {16} [style=dotted];
|
|
16 -> {17} [style=dotted];
|
|
17 -> {18} [style=dotted];
|
|
18 -> {19};
|
|
18 -> {25} [color=red];
|
|
19 -> {20};
|
|
19 -> {25 23} [color=green];
|
|
19 -> {25 23} [style=dashed];
|
|
20 -> {21};
|
|
21 -> {22};
|
|
23 -> {24} [color=green];
|
|
|
|
subgraph cluster_8 {
|
|
color=red
|
|
25 [label="Enter function <init>" style="filled" fillcolor=red];
|
|
26 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
|
|
27 [label="Exit function <init>" style="filled" fillcolor=red];
|
|
}
|
|
25 -> {26};
|
|
26 -> {27};
|
|
|
|
subgraph cluster_9 {
|
|
color=red
|
|
28 [label="Enter function bar" style="filled" fillcolor=red];
|
|
subgraph cluster_10 {
|
|
color=blue
|
|
29 [label="Enter block"];
|
|
30 [label="Exit block"];
|
|
}
|
|
31 [label="Exit function bar" style="filled" fillcolor=red];
|
|
}
|
|
28 -> {29};
|
|
29 -> {30};
|
|
30 -> {31};
|
|
|
|
}
|