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.
363 lines
12 KiB
Plaintext
Vendored
363 lines
12 KiB
Plaintext
Vendored
digraph equalsAndIdentity_kt {
|
|
graph [nodesep=3]
|
|
node [shape=box penwidth=2]
|
|
edge [penwidth=2]
|
|
|
|
subgraph cluster_0 {
|
|
color=red
|
|
0 [label="Enter function foo" style="filled" fillcolor=red];
|
|
1 [label="Exit function foo" style="filled" fillcolor=red];
|
|
}
|
|
0 -> {1};
|
|
|
|
subgraph cluster_1 {
|
|
color=red
|
|
2 [label="Enter class A" style="filled" fillcolor=red];
|
|
3 [label="Exit class A" style="filled" fillcolor=red];
|
|
}
|
|
2 -> {3} [color=green];
|
|
|
|
subgraph cluster_2 {
|
|
color=red
|
|
4 [label="Enter function test_1" 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 R|<local>/x|"];
|
|
9 [label="Access variable R|<local>/y|"];
|
|
10 [label="Equality operator =="];
|
|
11 [label="Exit when branch condition"];
|
|
}
|
|
12 [label="Synthetic else branch"];
|
|
13 [label="Enter when branch result"];
|
|
subgraph cluster_6 {
|
|
color=blue
|
|
14 [label="Enter block"];
|
|
15 [label="Access variable R|<local>/x|"];
|
|
16 [label="Function call: R|<local>/x|.R|/A.foo|()" style="filled" fillcolor=yellow];
|
|
17 [label="Access variable R|<local>/y|"];
|
|
18 [label="Smart cast: R|<local>/y|"];
|
|
19 [label="Function call: R|<local>/y|.R|/A.foo|()" style="filled" fillcolor=yellow];
|
|
20 [label="Exit block"];
|
|
}
|
|
21 [label="Exit when branch result"];
|
|
22 [label="Exit when"];
|
|
}
|
|
subgraph cluster_7 {
|
|
color=blue
|
|
23 [label="Enter when"];
|
|
subgraph cluster_8 {
|
|
color=blue
|
|
24 [label="Enter when branch condition "];
|
|
25 [label="Access variable R|<local>/x|"];
|
|
26 [label="Access variable R|<local>/y|"];
|
|
27 [label="Equality operator ==="];
|
|
28 [label="Exit when branch condition"];
|
|
}
|
|
29 [label="Synthetic else branch"];
|
|
30 [label="Enter when branch result"];
|
|
subgraph cluster_9 {
|
|
color=blue
|
|
31 [label="Enter block"];
|
|
32 [label="Access variable R|<local>/x|"];
|
|
33 [label="Function call: R|<local>/x|.R|/A.foo|()" style="filled" fillcolor=yellow];
|
|
34 [label="Access variable R|<local>/y|"];
|
|
35 [label="Smart cast: R|<local>/y|"];
|
|
36 [label="Function call: R|<local>/y|.R|/A.foo|()" style="filled" fillcolor=yellow];
|
|
37 [label="Exit block"];
|
|
}
|
|
38 [label="Exit when branch result"];
|
|
39 [label="Exit when"];
|
|
}
|
|
40 [label="Exit block"];
|
|
}
|
|
41 [label="Exit function test_1" style="filled" fillcolor=red];
|
|
}
|
|
4 -> {5};
|
|
5 -> {6};
|
|
6 -> {7};
|
|
7 -> {8};
|
|
8 -> {9};
|
|
9 -> {10};
|
|
10 -> {11};
|
|
11 -> {13 12};
|
|
12 -> {22};
|
|
13 -> {14};
|
|
14 -> {15};
|
|
15 -> {16};
|
|
16 -> {17};
|
|
17 -> {18};
|
|
18 -> {19};
|
|
19 -> {20};
|
|
20 -> {21};
|
|
21 -> {22};
|
|
22 -> {23};
|
|
23 -> {24};
|
|
24 -> {25};
|
|
25 -> {26};
|
|
26 -> {27};
|
|
27 -> {28};
|
|
28 -> {30 29};
|
|
29 -> {39};
|
|
30 -> {31};
|
|
31 -> {32};
|
|
32 -> {33};
|
|
33 -> {34};
|
|
34 -> {35};
|
|
35 -> {36};
|
|
36 -> {37};
|
|
37 -> {38};
|
|
38 -> {39};
|
|
39 -> {40};
|
|
40 -> {41};
|
|
|
|
subgraph cluster_10 {
|
|
color=red
|
|
42 [label="Enter function test_2" style="filled" fillcolor=red];
|
|
subgraph cluster_11 {
|
|
color=blue
|
|
43 [label="Enter block"];
|
|
subgraph cluster_12 {
|
|
color=blue
|
|
44 [label="Enter when"];
|
|
subgraph cluster_13 {
|
|
color=blue
|
|
45 [label="Enter when branch condition "];
|
|
46 [label="Access variable R|<local>/x|"];
|
|
47 [label="Access variable R|<local>/y|"];
|
|
48 [label="Equality operator =="];
|
|
49 [label="Exit when branch condition"];
|
|
}
|
|
50 [label="Synthetic else branch"];
|
|
51 [label="Enter when branch result"];
|
|
subgraph cluster_14 {
|
|
color=blue
|
|
52 [label="Enter block"];
|
|
53 [label="Access variable R|<local>/x|"];
|
|
54 [label="Function call: R|<local>/x|.<Inapplicable(UNSAFE_CALL): /A.foo>#()" style="filled" fillcolor=yellow];
|
|
55 [label="Access variable R|<local>/y|"];
|
|
56 [label="Function call: R|<local>/y|.<Inapplicable(UNSAFE_CALL): /A.foo>#()" style="filled" fillcolor=yellow];
|
|
57 [label="Exit block"];
|
|
}
|
|
58 [label="Exit when branch result"];
|
|
59 [label="Exit when"];
|
|
}
|
|
subgraph cluster_15 {
|
|
color=blue
|
|
60 [label="Enter when"];
|
|
subgraph cluster_16 {
|
|
color=blue
|
|
61 [label="Enter when branch condition "];
|
|
62 [label="Access variable R|<local>/x|"];
|
|
63 [label="Access variable R|<local>/y|"];
|
|
64 [label="Equality operator ==="];
|
|
65 [label="Exit when branch condition"];
|
|
}
|
|
66 [label="Synthetic else branch"];
|
|
67 [label="Enter when branch result"];
|
|
subgraph cluster_17 {
|
|
color=blue
|
|
68 [label="Enter block"];
|
|
69 [label="Access variable R|<local>/x|"];
|
|
70 [label="Function call: R|<local>/x|.<Inapplicable(UNSAFE_CALL): /A.foo>#()" style="filled" fillcolor=yellow];
|
|
71 [label="Access variable R|<local>/y|"];
|
|
72 [label="Function call: R|<local>/y|.<Inapplicable(UNSAFE_CALL): /A.foo>#()" style="filled" fillcolor=yellow];
|
|
73 [label="Exit block"];
|
|
}
|
|
74 [label="Exit when branch result"];
|
|
75 [label="Exit when"];
|
|
}
|
|
76 [label="Exit block"];
|
|
}
|
|
77 [label="Exit function test_2" style="filled" fillcolor=red];
|
|
}
|
|
42 -> {43};
|
|
43 -> {44};
|
|
44 -> {45};
|
|
45 -> {46};
|
|
46 -> {47};
|
|
47 -> {48};
|
|
48 -> {49};
|
|
49 -> {51 50};
|
|
50 -> {59};
|
|
51 -> {52};
|
|
52 -> {53};
|
|
53 -> {54};
|
|
54 -> {55};
|
|
55 -> {56};
|
|
56 -> {57};
|
|
57 -> {58};
|
|
58 -> {59};
|
|
59 -> {60};
|
|
60 -> {61};
|
|
61 -> {62};
|
|
62 -> {63};
|
|
63 -> {64};
|
|
64 -> {65};
|
|
65 -> {67 66};
|
|
66 -> {75};
|
|
67 -> {68};
|
|
68 -> {69};
|
|
69 -> {70};
|
|
70 -> {71};
|
|
71 -> {72};
|
|
72 -> {73};
|
|
73 -> {74};
|
|
74 -> {75};
|
|
75 -> {76};
|
|
76 -> {77};
|
|
|
|
subgraph cluster_18 {
|
|
color=red
|
|
78 [label="Enter function test_3" style="filled" fillcolor=red];
|
|
subgraph cluster_19 {
|
|
color=blue
|
|
79 [label="Enter block"];
|
|
subgraph cluster_20 {
|
|
color=blue
|
|
80 [label="Enter when"];
|
|
subgraph cluster_21 {
|
|
color=blue
|
|
81 [label="Enter when branch condition "];
|
|
82 [label="Access variable R|<local>/y|"];
|
|
83 [label="Const: Null(null)"];
|
|
84 [label="Equality operator =="];
|
|
85 [label="Exit when branch condition"];
|
|
}
|
|
86 [label="Synthetic else branch"];
|
|
87 [label="Enter when branch result"];
|
|
subgraph cluster_22 {
|
|
color=blue
|
|
88 [label="Enter block"];
|
|
89 [label="Jump: ^test_3 Unit"];
|
|
90 [label="Stub" style="filled" fillcolor=gray];
|
|
91 [label="Exit block" style="filled" fillcolor=gray];
|
|
}
|
|
92 [label="Exit when branch result" style="filled" fillcolor=gray];
|
|
93 [label="Exit when"];
|
|
}
|
|
subgraph cluster_23 {
|
|
color=blue
|
|
94 [label="Enter when"];
|
|
subgraph cluster_24 {
|
|
color=blue
|
|
95 [label="Enter when branch condition "];
|
|
96 [label="Access variable R|<local>/x|"];
|
|
97 [label="Access variable R|<local>/y|"];
|
|
98 [label="Smart cast: R|<local>/y|"];
|
|
99 [label="Equality operator =="];
|
|
100 [label="Exit when branch condition"];
|
|
}
|
|
101 [label="Synthetic else branch"];
|
|
102 [label="Enter when branch result"];
|
|
subgraph cluster_25 {
|
|
color=blue
|
|
103 [label="Enter block"];
|
|
104 [label="Access variable R|<local>/x|"];
|
|
105 [label="Smart cast: R|<local>/x|"];
|
|
106 [label="Function call: R|<local>/x|.R|/A.foo|()" style="filled" fillcolor=yellow];
|
|
107 [label="Access variable R|<local>/y|"];
|
|
108 [label="Smart cast: R|<local>/y|"];
|
|
109 [label="Function call: R|<local>/y|.R|/A.foo|()" style="filled" fillcolor=yellow];
|
|
110 [label="Exit block"];
|
|
}
|
|
111 [label="Exit when branch result"];
|
|
112 [label="Exit when"];
|
|
}
|
|
subgraph cluster_26 {
|
|
color=blue
|
|
113 [label="Enter when"];
|
|
subgraph cluster_27 {
|
|
color=blue
|
|
114 [label="Enter when branch condition "];
|
|
115 [label="Access variable R|<local>/x|"];
|
|
116 [label="Access variable R|<local>/y|"];
|
|
117 [label="Smart cast: R|<local>/y|"];
|
|
118 [label="Equality operator ==="];
|
|
119 [label="Exit when branch condition"];
|
|
}
|
|
120 [label="Synthetic else branch"];
|
|
121 [label="Enter when branch result"];
|
|
subgraph cluster_28 {
|
|
color=blue
|
|
122 [label="Enter block"];
|
|
123 [label="Access variable R|<local>/x|"];
|
|
124 [label="Smart cast: R|<local>/x|"];
|
|
125 [label="Function call: R|<local>/x|.R|/A.foo|()" style="filled" fillcolor=yellow];
|
|
126 [label="Access variable R|<local>/y|"];
|
|
127 [label="Smart cast: R|<local>/y|"];
|
|
128 [label="Function call: R|<local>/y|.R|/A.foo|()" style="filled" fillcolor=yellow];
|
|
129 [label="Exit block"];
|
|
}
|
|
130 [label="Exit when branch result"];
|
|
131 [label="Exit when"];
|
|
}
|
|
132 [label="Exit block"];
|
|
}
|
|
133 [label="Exit function test_3" style="filled" fillcolor=red];
|
|
}
|
|
78 -> {79};
|
|
79 -> {80};
|
|
80 -> {81};
|
|
81 -> {82};
|
|
82 -> {83};
|
|
83 -> {84};
|
|
84 -> {85};
|
|
85 -> {87 86};
|
|
86 -> {93};
|
|
87 -> {88};
|
|
88 -> {89};
|
|
89 -> {133};
|
|
89 -> {90} [style=dotted];
|
|
90 -> {91} [style=dotted];
|
|
91 -> {92} [style=dotted];
|
|
92 -> {93} [style=dotted];
|
|
93 -> {94};
|
|
94 -> {95};
|
|
95 -> {96};
|
|
96 -> {97};
|
|
97 -> {98};
|
|
98 -> {99};
|
|
99 -> {100};
|
|
100 -> {102 101};
|
|
101 -> {112};
|
|
102 -> {103};
|
|
103 -> {104};
|
|
104 -> {105};
|
|
105 -> {106};
|
|
106 -> {107};
|
|
107 -> {108};
|
|
108 -> {109};
|
|
109 -> {110};
|
|
110 -> {111};
|
|
111 -> {112};
|
|
112 -> {113};
|
|
113 -> {114};
|
|
114 -> {115};
|
|
115 -> {116};
|
|
116 -> {117};
|
|
117 -> {118};
|
|
118 -> {119};
|
|
119 -> {121 120};
|
|
120 -> {131};
|
|
121 -> {122};
|
|
122 -> {123};
|
|
123 -> {124};
|
|
124 -> {125};
|
|
125 -> {126};
|
|
126 -> {127};
|
|
127 -> {128};
|
|
128 -> {129};
|
|
129 -> {130};
|
|
130 -> {131};
|
|
131 -> {132};
|
|
132 -> {133};
|
|
|
|
}
|