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.
256 lines
8.0 KiB
Plaintext
Vendored
256 lines
8.0 KiB
Plaintext
Vendored
digraph smartcastInByClause_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 property" style="filled" fillcolor=red];
|
|
4 [label="Access variable R|<local>/path|"];
|
|
5 [label="Exit property" style="filled" fillcolor=red];
|
|
}
|
|
3 -> {4};
|
|
4 -> {5};
|
|
5 -> {11} [color=green];
|
|
|
|
subgraph cluster_2 {
|
|
color=red
|
|
6 [label="Enter property" style="filled" fillcolor=red];
|
|
7 [label="Access variable R|<local>/index|"];
|
|
8 [label="Exit property" style="filled" fillcolor=red];
|
|
}
|
|
6 -> {7};
|
|
7 -> {8};
|
|
8 -> {12} [color=green];
|
|
|
|
subgraph cluster_3 {
|
|
color=red
|
|
9 [label="Enter class A" style="filled" fillcolor=red];
|
|
10 [label="Part of class initialization"];
|
|
11 [label="Part of class initialization"];
|
|
12 [label="Exit class A" style="filled" fillcolor=red];
|
|
}
|
|
9 -> {10} [color=green];
|
|
10 -> {11} [style=dotted];
|
|
10 -> {3} [color=green];
|
|
10 -> {3} [style=dashed];
|
|
11 -> {12} [style=dotted];
|
|
11 -> {6} [color=green];
|
|
11 -> {6} [style=dashed];
|
|
|
|
subgraph cluster_4 {
|
|
color=red
|
|
13 [label="Enter class Base" style="filled" fillcolor=red];
|
|
14 [label="Exit class Base" style="filled" fillcolor=red];
|
|
}
|
|
13 -> {14} [color=green];
|
|
|
|
subgraph cluster_5 {
|
|
color=red
|
|
15 [label="Enter function <init>" style="filled" fillcolor=red];
|
|
16 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
|
|
17 [label="Exit function <init>" style="filled" fillcolor=red];
|
|
}
|
|
15 -> {16};
|
|
16 -> {17};
|
|
|
|
subgraph cluster_6 {
|
|
color=red
|
|
18 [label="Enter property" style="filled" fillcolor=red];
|
|
19 [label="Access variable R|<local>/index|"];
|
|
20 [label="Exit property" style="filled" fillcolor=red];
|
|
}
|
|
18 -> {19};
|
|
19 -> {20};
|
|
20 -> {23} [color=green];
|
|
|
|
subgraph cluster_7 {
|
|
color=red
|
|
21 [label="Enter class Derived" style="filled" fillcolor=red];
|
|
22 [label="Part of class initialization"];
|
|
23 [label="Exit class Derived" style="filled" fillcolor=red];
|
|
}
|
|
21 -> {22} [color=green];
|
|
22 -> {23} [style=dotted];
|
|
22 -> {18} [color=green];
|
|
22 -> {18} [style=dashed];
|
|
|
|
subgraph cluster_8 {
|
|
color=red
|
|
24 [label="Enter function test" style="filled" fillcolor=red];
|
|
subgraph cluster_9 {
|
|
color=blue
|
|
25 [label="Enter block"];
|
|
26 [label="Access variable R|<local>/a|"];
|
|
27 [label="Enter safe call"];
|
|
28 [label="Access variable R|/A.path|"];
|
|
29 [label="Exit safe call"];
|
|
30 [label="Exit lhs of ?:"];
|
|
31 [label="Enter rhs of ?:"];
|
|
32 [label="Const: Null(null)"];
|
|
33 [label="Jump: ^test Null(null)"];
|
|
34 [label="Stub" style="filled" fillcolor=gray];
|
|
35 [label="Lhs of ?: is not null"];
|
|
36 [label="Exit ?:"];
|
|
37 [label="Variable declaration: lval path: R|kotlin/String|"];
|
|
38 [label="Access variable R|<local>/a|"];
|
|
39 [label="Smart cast: R|<local>/a|"];
|
|
40 [label="Access variable R|/A.index|"];
|
|
41 [label="Function call: R|/takeInt|(...)" style="filled" fillcolor=yellow];
|
|
42 [label="Enter anonymous object"];
|
|
subgraph cluster_10 {
|
|
color=blue
|
|
49 [label="Enter class <anonymous object>" style="filled" fillcolor=red];
|
|
50 [label="Part of class initialization"];
|
|
51 [label="Part of class initialization"];
|
|
52 [label="Exit class <anonymous object>" style="filled" fillcolor=red];
|
|
}
|
|
43 [label="Exit anonymous object"];
|
|
44 [label="Exit anonymous object expression"];
|
|
45 [label="Jump: ^test object : R|Base| {
|
|
private constructor(): R|<anonymous>| {
|
|
super<R|kotlin/Any|>()
|
|
}
|
|
|
|
private final field $$delegate_0: R|Base| = R|/Derived.Derived|(R|<local>/a|.R|/A.index|)
|
|
|
|
public final val x: R|kotlin/Int| = R|<local>/a|.R|/A.index|
|
|
public get(): R|kotlin/Int|
|
|
|
|
public final fun foo(): R|kotlin/Unit| {
|
|
R|/takeInt|(R|<local>/a|.R|/A.index|)
|
|
}
|
|
|
|
}
|
|
"];
|
|
46 [label="Stub" style="filled" fillcolor=gray];
|
|
47 [label="Exit block" style="filled" fillcolor=gray];
|
|
}
|
|
48 [label="Exit function test" style="filled" fillcolor=red];
|
|
}
|
|
24 -> {25};
|
|
25 -> {26};
|
|
26 -> {27 31};
|
|
27 -> {28};
|
|
28 -> {29};
|
|
29 -> {30};
|
|
30 -> {35 31};
|
|
31 -> {32};
|
|
32 -> {33};
|
|
33 -> {48};
|
|
33 -> {34} [style=dotted];
|
|
34 -> {36} [style=dotted];
|
|
35 -> {36};
|
|
36 -> {37};
|
|
37 -> {38};
|
|
38 -> {39};
|
|
39 -> {40};
|
|
40 -> {41};
|
|
41 -> {42};
|
|
41 -> {53 56 62 67} [color=red];
|
|
42 -> {43} [color=red];
|
|
42 -> {49} [color=green];
|
|
42 -> {49} [style=dashed];
|
|
43 -> {44};
|
|
43 -> {53 67} [color=green];
|
|
43 -> {53 67} [style=dashed];
|
|
44 -> {45};
|
|
45 -> {48};
|
|
45 -> {46} [style=dotted];
|
|
46 -> {47} [style=dotted];
|
|
47 -> {48} [style=dotted];
|
|
49 -> {50} [color=green];
|
|
50 -> {51} [style=dotted];
|
|
50 -> {56} [color=green];
|
|
50 -> {56} [style=dashed];
|
|
51 -> {52} [style=dotted];
|
|
51 -> {62} [color=green];
|
|
51 -> {62} [style=dashed];
|
|
52 -> {43} [color=green];
|
|
|
|
subgraph cluster_11 {
|
|
color=red
|
|
53 [label="Enter function <init>" style="filled" fillcolor=red];
|
|
54 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
|
|
55 [label="Exit function <init>" style="filled" fillcolor=red];
|
|
}
|
|
53 -> {54};
|
|
54 -> {55};
|
|
|
|
subgraph cluster_12 {
|
|
color=red
|
|
56 [label="Enter field" style="filled" fillcolor=red];
|
|
57 [label="Access variable R|<local>/a|"];
|
|
58 [label="Smart cast: R|<local>/a|"];
|
|
59 [label="Access variable R|/A.index|"];
|
|
60 [label="Function call: R|/Derived.Derived|(...)" style="filled" fillcolor=yellow];
|
|
61 [label="Exit field" style="filled" fillcolor=red];
|
|
}
|
|
56 -> {57};
|
|
57 -> {58};
|
|
58 -> {59};
|
|
59 -> {60};
|
|
60 -> {61};
|
|
61 -> {51} [color=green];
|
|
|
|
subgraph cluster_13 {
|
|
color=red
|
|
62 [label="Enter property" style="filled" fillcolor=red];
|
|
63 [label="Access variable R|<local>/a|"];
|
|
64 [label="Smart cast: R|<local>/a|"];
|
|
65 [label="Access variable R|/A.index|"];
|
|
66 [label="Exit property" style="filled" fillcolor=red];
|
|
}
|
|
62 -> {63};
|
|
63 -> {64};
|
|
64 -> {65};
|
|
65 -> {66};
|
|
66 -> {52} [color=green];
|
|
|
|
subgraph cluster_14 {
|
|
color=red
|
|
67 [label="Enter function foo" style="filled" fillcolor=red];
|
|
subgraph cluster_15 {
|
|
color=blue
|
|
68 [label="Enter block"];
|
|
69 [label="Access variable R|<local>/a|"];
|
|
70 [label="Smart cast: R|<local>/a|"];
|
|
71 [label="Access variable R|/A.index|"];
|
|
72 [label="Function call: R|/takeInt|(...)" style="filled" fillcolor=yellow];
|
|
73 [label="Exit block"];
|
|
}
|
|
74 [label="Exit function foo" style="filled" fillcolor=red];
|
|
}
|
|
67 -> {68};
|
|
68 -> {69};
|
|
69 -> {70};
|
|
70 -> {71};
|
|
71 -> {72};
|
|
72 -> {73};
|
|
73 -> {74};
|
|
|
|
subgraph cluster_16 {
|
|
color=red
|
|
75 [label="Enter function takeInt" style="filled" fillcolor=red];
|
|
subgraph cluster_17 {
|
|
color=blue
|
|
76 [label="Enter block"];
|
|
77 [label="Exit block"];
|
|
}
|
|
78 [label="Exit function takeInt" style="filled" fillcolor=red];
|
|
}
|
|
75 -> {76};
|
|
76 -> {77};
|
|
77 -> {78};
|
|
|
|
}
|