Dont create scopes for consts w primitive values
We don't need to create scopes for primitive values that are never reassigned. The actual rules are more complex — we could choose to skip creating scopes for values that don't allocate — but this simple heuristic is good for now.
Joe Savona committed
Dec 14, 2022 at 08:42 UTC
189f48ee0a704b12977742058af7d5f8d8385206
60 files changed
+997
-1081
compiler/forget/src/HIR/InferReactiveScopeVariables.ts
+37
-6
@@ -6,11 +6,13 @@
6
*/
7
8
import invariant from "invariant";
9
+import { assertExhaustive } from "../Common/utils";
10
import DisjointSet from "./DisjointSet";
11
import {
12
HIRFunction,
13
Identifier,
14
Instruction,
15
+ InstructionValue,
16
makeInstructionId,
17
makeScopeId,
18
Place,
@@ -77,7 +79,14 @@ export function inferReactiveScopeVariables(fn: HIRFunction) {
79
for (const instr of block.instructions) {
80
const operands: Array<Identifier> = [];
81
if (instr.lvalue !== null) {
80
- operands.push(instr.lvalue!.place.identifier);
82
+ const range = instr.lvalue.place.identifier.mutableRange;
83
+ if (
84
+ instr.lvalue.place.memberPath !== null ||
85
+ range.end > range.start + 1 ||
86
+ mayAllocate(instr.value)
87
+ ) {
88
+ operands.push(instr.lvalue!.place.identifier);
89
+ }
90
}
91
for (const operand of eachInstructionOperand(instr)) {
92
if (
@@ -145,9 +154,31 @@ export function inferReactiveScopeVariables(fn: HIRFunction) {
154
}
155
156
// Is the operand mutable at this given instruction
148
-function isMutable(instr: Instruction, place: Place): boolean {
149
- return (
150
- instr.id >= place.identifier.mutableRange.start &&
151
- instr.id < place.identifier.mutableRange.end
152
- );
157
+function isMutable({ id }: Instruction, place: Place): boolean {
158
+ const range = place.identifier.mutableRange;
159
+ return id >= range.start && id < range.end;
160
+}
161
+
162
+function mayAllocate(value: InstructionValue): boolean {
163
+ switch (value.kind) {
164
+ case "BinaryExpression":
165
+ case "Identifier":
166
+ case "JSXText":
167
+ case "Primitive": {
168
+ return false;
169
+ }
170
+ case "ArrayExpression":
171
+ case "CallExpression":
172
+ case "JsxExpression":
173
+ case "JsxFragment":
174
+ case "NewExpression":
175
+ case "ObjectExpression":
176
+ case "OtherStatement":
177
+ case "UnaryExpression": {
178
+ return true;
179
+ }
180
+ default: {
181
+ assertExhaustive(value, `Unexpected value kind '${(value as any).kind}'`);
182
+ }
183
+ }
184
}
compiler/forget/src/__tests__/fixtures/hir/_bug_expression-with-assignment.expect.md
+11
-16
@@ -15,17 +15,12 @@ function f() {
15
16
```
17
bb0:
18
- [1] Const mutate x$4_@0:TPrimitive = 1
19
- [2] Const mutate x$5_@1:TPrimitive = 2
20
- [3] Const mutate $6_@2:TPrimitive = Binary read x$5_@1:TPrimitive + read x$5_@1:TPrimitive
21
- [4] Const mutate $7_@3:TPrimitive = Binary read $6_@2:TPrimitive + read x$5_@1:TPrimitive
22
- [5] Return read $7_@3:TPrimitive
23
-scope2 [3:4]:
24
- - dependency: read x$5_@1:TPrimitive
25
- - dependency: read x$5_@1:TPrimitive
26
-scope3 [4:5]:
27
- - dependency: read $6_@2:TPrimitive
28
- - dependency: read x$5_@1:TPrimitive
18
+ [1] Const mutate x$4:TPrimitive = 1
19
+ [2] Const mutate x$5:TPrimitive = 2
20
+ [3] Const mutate $6:TPrimitive = Binary read x$5:TPrimitive + read x$5:TPrimitive
21
+ [4] Const mutate $7:TPrimitive = Binary read $6:TPrimitive + read x$5:TPrimitive
22
+ [5] Return read $7:TPrimitive
23
+
24
```
25
26
## Reactive Scopes
@@ -33,11 +28,11 @@ scope3 [4:5]:
28
```
29
function f(
30
) {
36
- [1] Const mutate x$4_@0:TPrimitive = 1
37
- [2] Const mutate x$5_@1:TPrimitive = 2
38
- [3] Const mutate $6_@2:TPrimitive = Binary read x$5_@1:TPrimitive + read x$5_@1:TPrimitive
39
- [4] Const mutate $7_@3:TPrimitive = Binary read $6_@2:TPrimitive + read x$5_@1:TPrimitive
40
- return read $7_@3:TPrimitive
31
+ [1] Const mutate x$4:TPrimitive = 1
32
+ [2] Const mutate x$5:TPrimitive = 2
33
+ [3] Const mutate $6:TPrimitive = Binary read x$5:TPrimitive + read x$5:TPrimitive
34
+ [4] Const mutate $7:TPrimitive = Binary read $6:TPrimitive + read x$5:TPrimitive
35
+ return read $7:TPrimitive
36
}
37
38
```
compiler/forget/src/__tests__/fixtures/hir/assignment-variations.expect.md
+25
-34
@@ -20,23 +20,15 @@ function g(a) {
20
21
```
22
bb0:
23
- [1] Const mutate x$5_@0:TPrimitive = 1
24
- [2] Const mutate $6_@1:TPrimitive = 1
25
- [3] Const mutate x$7_@2:TPrimitive = Binary read x$5_@0:TPrimitive + read $6_@1:TPrimitive
26
- [4] Const mutate $8_@3:TPrimitive = 1
27
- [5] Const mutate x$9_@4:TPrimitive = Binary read x$7_@2:TPrimitive + read $8_@3:TPrimitive
28
- [6] Const mutate $10_@5:TPrimitive = 1
29
- [7] Const mutate x$11_@6:TPrimitive = Binary read x$9_@4:TPrimitive >>> read $10_@5:TPrimitive
23
+ [1] Const mutate x$5:TPrimitive = 1
24
+ [2] Const mutate $6:TPrimitive = 1
25
+ [3] Const mutate x$7:TPrimitive = Binary read x$5:TPrimitive + read $6:TPrimitive
26
+ [4] Const mutate $8:TPrimitive = 1
27
+ [5] Const mutate x$9:TPrimitive = Binary read x$7:TPrimitive + read $8:TPrimitive
28
+ [6] Const mutate $10:TPrimitive = 1
29
+ [7] Const mutate x$11:TPrimitive = Binary read x$9:TPrimitive >>> read $10:TPrimitive
30
[8] Return
31
-scope2 [3:4]:
32
- - dependency: read x$5_@0:TPrimitive
33
- - dependency: read $6_@1:TPrimitive
34
-scope4 [5:6]:
35
- - dependency: read x$7_@2:TPrimitive
36
- - dependency: read $8_@3:TPrimitive
37
-scope6 [7:8]:
38
- - dependency: read x$9_@4:TPrimitive
39
- - dependency: read $10_@5:TPrimitive
31
+
32
```
33
34
## Reactive Scopes
@@ -44,13 +36,13 @@ scope6 [7:8]:
36
```
37
function f(
38
) {
47
- [1] Const mutate x$5_@0:TPrimitive = 1
48
- [2] Const mutate $6_@1:TPrimitive = 1
49
- [3] Const mutate x$7_@2:TPrimitive = Binary read x$5_@0:TPrimitive + read $6_@1:TPrimitive
50
- [4] Const mutate $8_@3:TPrimitive = 1
51
- [5] Const mutate x$9_@4:TPrimitive = Binary read x$7_@2:TPrimitive + read $8_@3:TPrimitive
52
- [6] Const mutate $10_@5:TPrimitive = 1
53
- [7] Const mutate x$11_@6:TPrimitive = Binary read x$9_@4:TPrimitive >>> read $10_@5:TPrimitive
39
+ [1] Const mutate x$5:TPrimitive = 1
40
+ [2] Const mutate $6:TPrimitive = 1
41
+ [3] Const mutate x$7:TPrimitive = Binary read x$5:TPrimitive + read $6:TPrimitive
42
+ [4] Const mutate $8:TPrimitive = 1
43
+ [5] Const mutate x$9:TPrimitive = Binary read x$7:TPrimitive + read $8:TPrimitive
44
+ [6] Const mutate $10:TPrimitive = 1
45
+ [7] Const mutate x$11:TPrimitive = Binary read x$9:TPrimitive >>> read $10:TPrimitive
46
return
47
}
48
@@ -71,13 +63,12 @@ function f$0() {
63
64
```
65
bb0:
74
- [1] Const mutate $5_@0:TPrimitive = 1
75
- [2] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c + read $5_@0:TPrimitive
76
- [3] Const mutate $6_@2:TPrimitive = 2
77
- [4] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c * read $6_@2:TPrimitive
66
+ [1] Const mutate $5:TPrimitive = 1
67
+ [2] Reassign mutate a$4_@0.b.c[0:5] = Binary read a$4_@0.b.c + read $5:TPrimitive
68
+ [3] Const mutate $6:TPrimitive = 2
69
+ [4] Reassign mutate a$4_@0.b.c[0:5] = Binary read a$4_@0.b.c * read $6:TPrimitive
70
[5] Return
79
-scope2 [3:4]:
80
- - dependency: mutate a$4_@1.b.c
71
+
72
```
73
74
## Reactive Scopes
@@ -86,11 +77,11 @@ scope2 [3:4]:
77
function g(
78
a,
79
) {
89
- [1] Const mutate $5_@0:TPrimitive = 1
90
- scope @1 [0:5] deps=[] {
91
- [2] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c + read $5_@0:TPrimitive
92
- [3] Const mutate $6_@2:TPrimitive = 2
93
- [4] Reassign mutate a$4_@1.b.c[0:5] = Binary read a$4_@1.b.c * read $6_@2:TPrimitive
80
+ [1] Const mutate $5:TPrimitive = 1
81
+ scope @0 [0:5] deps=[] {
82
+ [2] Reassign mutate a$4_@0.b.c[0:5] = Binary read a$4_@0.b.c + read $5:TPrimitive
83
+ [3] Const mutate $6:TPrimitive = 2
84
+ [4] Reassign mutate a$4_@0.b.c[0:5] = Binary read a$4_@0.b.c * read $6:TPrimitive
85
}
86
return
87
}
compiler/forget/src/__tests__/fixtures/hir/call.expect.md
+16
-16
@@ -46,16 +46,16 @@ bb0:
46
[1] Const mutate a$10_@0:TObject[1:7] = Array []
47
[2] Const mutate b$11_@0:TObject[1:7] = Object { }
48
[3] Call mutate foo$4:TFunction(mutate a$10_@0:TObject, mutate b$11_@0:TObject)
49
- [4] Const mutate $12_@1:TPrimitive = "div"
50
- [5] Const mutate _$13_@2 = JSX <read $12_@1:TPrimitive a={freeze a$10_@0:TObject} ></read $12_@1:TPrimitive>
49
+ [4] Const mutate $12:TPrimitive = "div"
50
+ [5] Const mutate _$13_@1 = JSX <read $12:TPrimitive a={freeze a$10_@0:TObject} ></read $12:TPrimitive>
51
[6] Call mutate foo$4:TFunction(mutate b$11_@0:TObject)
52
- [7] Const mutate $14_@3:TPrimitive = "div"
53
- [8] Const mutate $15_@4 = JSX <read $14_@3:TPrimitive a={read a$10_@0:TObject} b={freeze b$11_@0:TObject} ></read $14_@3:TPrimitive>
54
- [9] Return read $15_@4
55
-scope2 [5:6]:
56
- - dependency: read $12_@1:TPrimitive
57
-scope4 [8:9]:
58
- - dependency: read $14_@3:TPrimitive
52
+ [7] Const mutate $14:TPrimitive = "div"
53
+ [8] Const mutate $15_@2 = JSX <read $14:TPrimitive a={read a$10_@0:TObject} b={freeze b$11_@0:TObject} ></read $14:TPrimitive>
54
+ [9] Return read $15_@2
55
+scope1 [5:6]:
56
+ - dependency: read $12:TPrimitive
57
+scope2 [8:9]:
58
+ - dependency: read $14:TPrimitive
59
- dependency: read a$10_@0:TObject
60
- dependency: freeze b$11_@0:TObject
61
```
@@ -70,17 +70,17 @@ function Component(
70
[1] Const mutate a$10_@0:TObject[1:7] = Array []
71
[2] Const mutate b$11_@0:TObject[1:7] = Object { }
72
[3] Call mutate foo$4:TFunction(mutate a$10_@0:TObject, mutate b$11_@0:TObject)
73
- [4] Const mutate $12_@1:TPrimitive = "div"
74
- scope @2 [5:6] deps=[read $12_@1:TPrimitive] {
75
- [5] Const mutate _$13_@2 = JSX <read $12_@1:TPrimitive a={freeze a$10_@0:TObject} ></read $12_@1:TPrimitive>
73
+ [4] Const mutate $12:TPrimitive = "div"
74
+ scope @1 [5:6] deps=[read $12:TPrimitive] {
75
+ [5] Const mutate _$13_@1 = JSX <read $12:TPrimitive a={freeze a$10_@0:TObject} ></read $12:TPrimitive>
76
}
77
[6] Call mutate foo$4:TFunction(mutate b$11_@0:TObject)
78
}
79
- [7] Const mutate $14_@3:TPrimitive = "div"
80
- scope @4 [8:9] deps=[read $14_@3:TPrimitive, read a$10_@0:TObject, freeze b$11_@0:TObject] {
81
- [8] Const mutate $15_@4 = JSX <read $14_@3:TPrimitive a={read a$10_@0:TObject} b={freeze b$11_@0:TObject} ></read $14_@3:TPrimitive>
79
+ [7] Const mutate $14:TPrimitive = "div"
80
+ scope @2 [8:9] deps=[read $14:TPrimitive, read a$10_@0:TObject, freeze b$11_@0:TObject] {
81
+ [8] Const mutate $15_@2 = JSX <read $14:TPrimitive a={read a$10_@0:TObject} b={freeze b$11_@0:TObject} ></read $14:TPrimitive>
82
}
83
- return read $15_@4
83
+ return read $15_@2
84
}
85
86
```
compiler/forget/src/__tests__/fixtures/hir/component.expect.md
+93
-101
@@ -35,95 +35,87 @@ function Component(props) {
35
36
```
37
bb0:
38
- [1] Const mutate items$30_@0:TProp = read props$29.items
39
- [2] Const mutate maxItems$31_@1:TProp = read props$29.maxItems
40
- [3] Const mutate renderedItems$32_@2:TFunction[3:33] = Array []
41
- [4] Const mutate seen$33_@2:TFunction[3:33] = New mutate Set$6()
42
- [5] Const mutate $34_@4:TPrimitive = 0
43
- [6] Const mutate max$35_@5:TPrimitive = Call mutate Math$8.max(read $34_@4:TPrimitive, read maxItems$31_@1:TProp)
38
+ [1] Const mutate items$30:TProp = read props$29.items
39
+ [2] Const mutate maxItems$31:TProp = read props$29.maxItems
40
+ [3] Const mutate renderedItems$32_@0:TFunction[3:33] = Array []
41
+ [4] Const mutate seen$33_@0:TFunction[3:33] = New mutate Set$6()
42
+ [5] Const mutate $34:TPrimitive = 0
43
+ [6] Const mutate max$35_@2:TPrimitive = Call mutate Math$8.max(read $34:TPrimitive, read maxItems$31:TProp)
44
[7] For init=bb3 test=bb1 loop=bb5 update=bb4 fallthrough=bb2
45
bb3:
46
predecessor blocks: bb0
47
- [8] Let mutate i$36_@2:TPrimitive[3:33] = 0
47
+ [8] Let mutate i$36_@0:TPrimitive[3:33] = 0
48
[9] Goto bb1
49
bb1:
50
predecessor blocks: bb3 bb4
51
- [10] Const mutate $39_@2:TPrimitive[3:33] = Binary read i$36_@2:TPrimitive < read items$30_@0.length
52
- [11] If (read $39_@2:TPrimitive) then:bb5 else:bb2 fallthrough=bb2
51
+ [10] Const mutate $39:TPrimitive = Binary read i$36_@0:TPrimitive < read items$30.length
52
+ [11] If (read $39:TPrimitive) then:bb5 else:bb2 fallthrough=bb2
53
bb5:
54
predecessor blocks: bb1
55
- [12] Const mutate item$40_@2:TPrimitive[3:33] = Call read items$30_@0.at(read i$36_@2:TPrimitive)
56
- [13] Const mutate $41_@6:TPrimitive = null
57
- [14] Const mutate $42_@2:TPrimitive[3:33] = Binary read item$40_@2:TPrimitive == read $41_@6:TPrimitive
58
- [15] Let mutate $43_@2:TPrimitive[3:33] = undefined
59
- [15] If (read $42_@2:TPrimitive) then:bb10 else:bb11 fallthrough=bb9
55
+ [12] Const mutate item$40_@0:TPrimitive[3:33] = Call read items$30.at(read i$36_@0:TPrimitive)
56
+ [13] Const mutate $41:TPrimitive = null
57
+ [14] Const mutate $42:TPrimitive = Binary read item$40_@0:TPrimitive == read $41:TPrimitive
58
+ [15] Let mutate $43_@0:TPrimitive[3:33] = undefined
59
+ [15] If (read $42:TPrimitive) then:bb10 else:bb11 fallthrough=bb9
60
bb10:
61
predecessor blocks: bb5
62
- [16] Const mutate $43_@2:TPrimitive[3:33] = read $42_@2:TPrimitive
62
+ [16] Const mutate $43_@0:TPrimitive[3:33] = read $42:TPrimitive
63
[17] Goto bb9
64
bb11:
65
predecessor blocks: bb5
66
- [18] Const mutate $43_@2:TPrimitive[3:33] = Call mutate seen$33_@2.has(mutate item$40_@2:TPrimitive)
66
+ [18] Const mutate $43_@0:TPrimitive[3:33] = Call mutate seen$33_@0.has(mutate item$40_@0:TPrimitive)
67
[19] Goto bb9
68
bb9:
69
predecessor blocks: bb10 bb11
70
- [20] If (read $43_@2:TPrimitive) then:bb7 else:bb6 fallthrough=bb6
70
+ [20] If (read $43_@0:TPrimitive) then:bb7 else:bb6 fallthrough=bb6
71
bb7:
72
predecessor blocks: bb9
73
[21] Goto(Continue) bb4
74
bb6:
75
predecessor blocks: bb9
76
- [22] Call mutate seen$33_@2.add(mutate item$40_@2:TPrimitive)
77
- [23] Const mutate $49_@7:TPrimitive = "div"
78
- [24] Const mutate $50_@8 = JSX <read $49_@7:TPrimitive>{freeze item$40_@2:TPrimitive}</read $49_@7:TPrimitive>
79
- [25] Call mutate renderedItems$32_@2.push(read $50_@8)
80
- [26] Const mutate $55_@9:TPrimitive = Binary read renderedItems$32_@2.length >= read max$35_@5:TPrimitive
81
- [27] If (read $55_@9:TPrimitive) then:bb2 else:bb12 fallthrough=bb12
76
+ [22] Call mutate seen$33_@0.add(mutate item$40_@0:TPrimitive)
77
+ [23] Const mutate $49:TPrimitive = "div"
78
+ [24] Const mutate $50_@3 = JSX <read $49:TPrimitive>{freeze item$40_@0:TPrimitive}</read $49:TPrimitive>
79
+ [25] Call mutate renderedItems$32_@0.push(read $50_@3)
80
+ [26] Const mutate $55:TPrimitive = Binary read renderedItems$32_@0.length >= read max$35_@2:TPrimitive
81
+ [27] If (read $55:TPrimitive) then:bb2 else:bb12 fallthrough=bb12
82
bb12:
83
predecessor blocks: bb6
84
[28] Goto(Continue) bb4
85
bb4:
86
predecessor blocks: bb7 bb12
87
- [29] Const mutate $56_@2:TPrimitive[3:33] = 1
88
- [30] Reassign mutate i$36_@2:TPrimitive[3:33] = Binary read i$36_@2:TPrimitive + read $56_@2:TPrimitive
89
- [31] read i$36_@2:TPrimitive
87
+ [29] Const mutate $56:TPrimitive = 1
88
+ [30] Reassign mutate i$36_@0:TPrimitive[3:33] = Binary read i$36_@0:TPrimitive + read $56:TPrimitive
89
+ [31] read i$36_@0:TPrimitive
90
[32] Goto bb1
91
bb2:
92
predecessor blocks: bb6 bb1
93
- [33] Const mutate count$66_@11:TProp = read renderedItems$32_@2.length
94
- [34] Const mutate $67_@12:TPrimitive = "div"
95
- [35] Const mutate $68_@13 = "\n "
96
- [36] Const mutate $69_@14:TPrimitive = "h1"
97
- [37] Const mutate $70_@15 = " Items"
98
- [38] Const mutate $71_@16 = JSX <read $69_@14:TPrimitive>{freeze count$66_@11:TProp}{read $70_@15}</read $69_@14:TPrimitive>
99
- [39] Const mutate $72_@17 = "\n "
100
- [40] Const mutate $73_@18 = "\n "
101
- [41] Const mutate $74_@19 = JSX <read $67_@12:TPrimitive>{read $68_@13}{read $71_@16}{read $72_@17}{freeze renderedItems$32_@2:TFunction}{read $73_@18}</read $67_@12:TPrimitive>
102
- [42] Return read $74_@19
103
-scope0 [1:2]:
104
- - dependency: read props$29.items
105
-scope1 [2:3]:
106
- - dependency: read props$29.maxItems
107
-scope5 [6:7]:
108
- - dependency: read $34_@4:TPrimitive
109
- - dependency: read maxItems$31_@1:TProp
110
-scope8 [24:25]:
111
- - dependency: read $49_@7:TPrimitive
112
-scope9 [26:27]:
113
- - dependency: read max$35_@5:TPrimitive
114
-scope11 [33:34]:
115
- - dependency: read renderedItems$32_@2.length
116
-scope16 [38:39]:
117
- - dependency: read $69_@14:TPrimitive
118
- - dependency: freeze count$66_@11:TProp
119
- - dependency: read $70_@15
120
-scope19 [41:42]:
121
- - dependency: read $67_@12:TPrimitive
122
- - dependency: read $68_@13
123
- - dependency: read $71_@16
124
- - dependency: read $72_@17
125
- - dependency: freeze renderedItems$32_@2:TFunction
126
- - dependency: read $73_@18
93
+ [33] Const mutate count$66:TProp = read renderedItems$32_@0.length
94
+ [34] Const mutate $67:TPrimitive = "div"
95
+ [35] Const mutate $68 = "\n "
96
+ [36] Const mutate $69:TPrimitive = "h1"
97
+ [37] Const mutate $70 = " Items"
98
+ [38] Const mutate $71_@4 = JSX <read $69:TPrimitive>{freeze count$66:TProp}{read $70}</read $69:TPrimitive>
99
+ [39] Const mutate $72 = "\n "
100
+ [40] Const mutate $73 = "\n "
101
+ [41] Const mutate $74_@5 = JSX <read $67:TPrimitive>{read $68}{read $71_@4}{read $72}{freeze renderedItems$32_@0:TFunction}{read $73}</read $67:TPrimitive>
102
+ [42] Return read $74_@5
103
+scope2 [6:7]:
104
+ - dependency: read $34:TPrimitive
105
+ - dependency: read maxItems$31:TProp
106
+scope3 [24:25]:
107
+ - dependency: read $49:TPrimitive
108
+scope4 [38:39]:
109
+ - dependency: read $69:TPrimitive
110
+ - dependency: freeze count$66:TProp
111
+ - dependency: read $70
112
+scope5 [41:42]:
113
+ - dependency: read $67:TPrimitive
114
+ - dependency: read $68
115
+ - dependency: read $71_@4
116
+ - dependency: read $72
117
+ - dependency: freeze renderedItems$32_@0:TFunction
118
+ - dependency: read $73
119
```
120
121
## Reactive Scopes
@@ -132,63 +124,63 @@ scope19 [41:42]:
124
function Component(
125
props,
126
) {
135
- [1] Const mutate items$30_@0:TProp = read props$29.items
136
- [2] Const mutate maxItems$31_@1:TProp = read props$29.maxItems
137
- scope @2 [3:33] deps=[] {
138
- [3] Const mutate renderedItems$32_@2:TFunction[3:33] = Array []
139
- [4] Const mutate seen$33_@2:TFunction[3:33] = New mutate Set$6()
140
- [5] Const mutate $34_@4:TPrimitive = 0
141
- scope @5 [6:7] deps=[read $34_@4:TPrimitive, read maxItems$31_@1:TProp] {
142
- [6] Const mutate max$35_@5:TPrimitive = Call mutate Math$8.max(read $34_@4:TPrimitive, read maxItems$31_@1:TProp)
127
+ [1] Const mutate items$30:TProp = read props$29.items
128
+ [2] Const mutate maxItems$31:TProp = read props$29.maxItems
129
+ scope @0 [3:33] deps=[] {
130
+ [3] Const mutate renderedItems$32_@0:TFunction[3:33] = Array []
131
+ [4] Const mutate seen$33_@0:TFunction[3:33] = New mutate Set$6()
132
+ [5] Const mutate $34:TPrimitive = 0
133
+ scope @2 [6:7] deps=[read $34:TPrimitive, read maxItems$31:TProp] {
134
+ [6] Const mutate max$35_@2:TPrimitive = Call mutate Math$8.max(read $34:TPrimitive, read maxItems$31:TProp)
135
}
136
for (
145
- [8] Let mutate i$36_@2:TPrimitive[3:33] = 0
137
+ [8] Let mutate i$36_@0:TPrimitive[3:33] = 0
138
;
147
- [10] Const mutate $39_@2:TPrimitive[3:33] = Binary read i$36_@2:TPrimitive < read items$30_@0.length
148
- read $39_@2:TPrimitive
139
+ [10] Const mutate $39:TPrimitive = Binary read i$36_@0:TPrimitive < read items$30.length
140
+ read $39:TPrimitive
141
;
150
- [29] Const mutate $56_@2:TPrimitive[3:33] = 1
151
- [30] Reassign mutate i$36_@2:TPrimitive[3:33] = Binary read i$36_@2:TPrimitive + read $56_@2:TPrimitive
152
- read i$36_@2:TPrimitive
142
+ [29] Const mutate $56:TPrimitive = 1
143
+ [30] Reassign mutate i$36_@0:TPrimitive[3:33] = Binary read i$36_@0:TPrimitive + read $56:TPrimitive
144
+ read i$36_@0:TPrimitive
145
) {
154
- [12] Const mutate item$40_@2:TPrimitive[3:33] = Call read items$30_@0.at(read i$36_@2:TPrimitive)
155
- [13] Const mutate $41_@6:TPrimitive = null
156
- [14] Const mutate $42_@2:TPrimitive[3:33] = Binary read item$40_@2:TPrimitive == read $41_@6:TPrimitive
157
- [15] Let mutate $43_@2:TPrimitive[3:33] = undefined
158
- if (read $42_@2:TPrimitive) {
159
- [16] Const mutate $43_@2:TPrimitive[3:33] = read $42_@2:TPrimitive
146
+ [12] Const mutate item$40_@0:TPrimitive[3:33] = Call read items$30.at(read i$36_@0:TPrimitive)
147
+ [13] Const mutate $41:TPrimitive = null
148
+ [14] Const mutate $42:TPrimitive = Binary read item$40_@0:TPrimitive == read $41:TPrimitive
149
+ [15] Let mutate $43_@0:TPrimitive[3:33] = undefined
150
+ if (read $42:TPrimitive) {
151
+ [16] Const mutate $43_@0:TPrimitive[3:33] = read $42:TPrimitive
152
} else {
161
- [18] Const mutate $43_@2:TPrimitive[3:33] = Call mutate seen$33_@2.has(mutate item$40_@2:TPrimitive)
153
+ [18] Const mutate $43_@0:TPrimitive[3:33] = Call mutate seen$33_@0.has(mutate item$40_@0:TPrimitive)
154
}
163
- if (read $43_@2:TPrimitive) {
155
+ if (read $43_@0:TPrimitive) {
156
continue
157
}
166
- [22] Call mutate seen$33_@2.add(mutate item$40_@2:TPrimitive)
167
- [23] Const mutate $49_@7:TPrimitive = "div"
168
- scope @8 [24:25] deps=[read $49_@7:TPrimitive] {
169
- [24] Const mutate $50_@8 = JSX <read $49_@7:TPrimitive>{freeze item$40_@2:TPrimitive}</read $49_@7:TPrimitive>
158
+ [22] Call mutate seen$33_@0.add(mutate item$40_@0:TPrimitive)
159
+ [23] Const mutate $49:TPrimitive = "div"
160
+ scope @3 [24:25] deps=[read $49:TPrimitive] {
161
+ [24] Const mutate $50_@3 = JSX <read $49:TPrimitive>{freeze item$40_@0:TPrimitive}</read $49:TPrimitive>
162
}
171
- [25] Call mutate renderedItems$32_@2.push(read $50_@8)
172
- [26] Const mutate $55_@9:TPrimitive = Binary read renderedItems$32_@2.length >= read max$35_@5:TPrimitive
173
- if (read $55_@9:TPrimitive) {
163
+ [25] Call mutate renderedItems$32_@0.push(read $50_@3)
164
+ [26] Const mutate $55:TPrimitive = Binary read renderedItems$32_@0.length >= read max$35_@2:TPrimitive
165
+ if (read $55:TPrimitive) {
166
break
167
}
168
}
169
}
178
- [33] Const mutate count$66_@11:TProp = read renderedItems$32_@2.length
179
- [34] Const mutate $67_@12:TPrimitive = "div"
180
- [35] Const mutate $68_@13 = "\n "
181
- [36] Const mutate $69_@14:TPrimitive = "h1"
182
- [37] Const mutate $70_@15 = " Items"
183
- scope @16 [38:39] deps=[read $69_@14:TPrimitive, freeze count$66_@11:TProp, read $70_@15] {
184
- [38] Const mutate $71_@16 = JSX <read $69_@14:TPrimitive>{freeze count$66_@11:TProp}{read $70_@15}</read $69_@14:TPrimitive>
170
+ [33] Const mutate count$66:TProp = read renderedItems$32_@0.length
171
+ [34] Const mutate $67:TPrimitive = "div"
172
+ [35] Const mutate $68 = "\n "
173
+ [36] Const mutate $69:TPrimitive = "h1"
174
+ [37] Const mutate $70 = " Items"
175
+ scope @4 [38:39] deps=[read $69:TPrimitive, freeze count$66:TProp, read $70] {
176
+ [38] Const mutate $71_@4 = JSX <read $69:TPrimitive>{freeze count$66:TProp}{read $70}</read $69:TPrimitive>
177
}
186
- [39] Const mutate $72_@17 = "\n "
187
- [40] Const mutate $73_@18 = "\n "
188
- scope @19 [41:42] deps=[read $67_@12:TPrimitive, read $68_@13, read $71_@16, read $72_@17, freeze renderedItems$32_@2:TFunction, read $73_@18] {
189
- [41] Const mutate $74_@19 = JSX <read $67_@12:TPrimitive>{read $68_@13}{read $71_@16}{read $72_@17}{freeze renderedItems$32_@2:TFunction}{read $73_@18}</read $67_@12:TPrimitive>
178
+ [39] Const mutate $72 = "\n "
179
+ [40] Const mutate $73 = "\n "
180
+ scope @5 [41:42] deps=[read $67:TPrimitive, read $68, read $71_@4, read $72, freeze renderedItems$32_@0:TFunction, read $73] {
181
+ [41] Const mutate $74_@5 = JSX <read $67:TPrimitive>{read $68}{read $71_@4}{read $72}{freeze renderedItems$32_@0:TFunction}{read $73}</read $67:TPrimitive>
182
}
191
- return read $74_@19
183
+ return read $74_@5
184
}
185
186
```
compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md
+8
-8
@@ -83,8 +83,8 @@ bb0:
83
[3] If (read props$4.b) then:bb2 else:bb1 fallthrough=bb1
84
bb2:
85
predecessor blocks: bb0
86
- [4] Const mutate $6_@1:TPrimitive = null
87
- [5] Return read $6_@1:TPrimitive
86
+ [4] Const mutate $6:TPrimitive = null
87
+ [5] Return read $6:TPrimitive
88
bb1:
89
predecessor blocks: bb0
90
[6] Call mutate a_DEBUG$5_@0.push(read props$4.d)
@@ -105,8 +105,8 @@ function Component(
105
[1] Const mutate a_DEBUG$5_@0:TFunction[1:7] = Array []
106
[2] Call mutate a_DEBUG$5_@0.push(read props$4.a)
107
if (read props$4.b) {
108
- [4] Const mutate $6_@1:TPrimitive = null
109
- return read $6_@1:TPrimitive
108
+ [4] Const mutate $6:TPrimitive = null
109
+ return read $6:TPrimitive
110
}
111
[6] Call mutate a_DEBUG$5_@0.push(read props$4.d)
112
}
@@ -196,8 +196,8 @@ bb0:
196
bb2:
197
predecessor blocks: bb0
198
[4] Call mutate a$5_@0.push(read props$4.c)
199
- [5] Const mutate $6_@1:TPrimitive = null
200
- [6] Return read $6_@1:TPrimitive
199
+ [5] Const mutate $6:TPrimitive = null
200
+ [6] Return read $6:TPrimitive
201
bb1:
202
predecessor blocks: bb0
203
[7] Call mutate a$5_@0.push(read props$4.d)
@@ -220,8 +220,8 @@ function Component(
220
[2] Call mutate a$5_@0.push(read props$4.a)
221
if (read props$4.b) {
222
[4] Call mutate a$5_@0.push(read props$4.c)
223
- [5] Const mutate $6_@1:TPrimitive = null
224
- return read $6_@1:TPrimitive
223
+ [5] Const mutate $6:TPrimitive = null
224
+ return read $6:TPrimitive
225
}
226
[7] Call mutate a$5_@0.push(read props$4.d)
227
}
compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md
+16
-16
@@ -46,16 +46,16 @@ bb0:
46
[1] Const mutate a$10_@0[1:7] = Array []
47
[2] Const mutate b$11_@0:TObject[1:7] = Object { }
48
[3] New mutate Foo$4(mutate a$10_@0, mutate b$11_@0:TObject)
49
- [4] Const mutate $12_@1:TPrimitive = "div"
50
- [5] Const mutate _$13_@2 = JSX <read $12_@1:TPrimitive a={freeze a$10_@0} ></read $12_@1:TPrimitive>
49
+ [4] Const mutate $12:TPrimitive = "div"
50
+ [5] Const mutate _$13_@1 = JSX <read $12:TPrimitive a={freeze a$10_@0} ></read $12:TPrimitive>
51
[6] New mutate Foo$4(mutate b$11_@0:TObject)
52
- [7] Const mutate $14_@3:TPrimitive = "div"
53
- [8] Const mutate $15_@4 = JSX <read $14_@3:TPrimitive a={read a$10_@0} b={freeze b$11_@0:TObject} ></read $14_@3:TPrimitive>
54
- [9] Return read $15_@4
55
-scope2 [5:6]:
56
- - dependency: read $12_@1:TPrimitive
57
-scope4 [8:9]:
58
- - dependency: read $14_@3:TPrimitive
52
+ [7] Const mutate $14:TPrimitive = "div"
53
+ [8] Const mutate $15_@2 = JSX <read $14:TPrimitive a={read a$10_@0} b={freeze b$11_@0:TObject} ></read $14:TPrimitive>
54
+ [9] Return read $15_@2
55
+scope1 [5:6]:
56
+ - dependency: read $12:TPrimitive
57
+scope2 [8:9]:
58
+ - dependency: read $14:TPrimitive
59
- dependency: read a$10_@0
60
- dependency: freeze b$11_@0:TObject
61
```
@@ -70,17 +70,17 @@ function Component(
70
[1] Const mutate a$10_@0[1:7] = Array []
71
[2] Const mutate b$11_@0:TObject[1:7] = Object { }
72
[3] New mutate Foo$4(mutate a$10_@0, mutate b$11_@0:TObject)
73
- [4] Const mutate $12_@1:TPrimitive = "div"
74
- scope @2 [5:6] deps=[read $12_@1:TPrimitive] {
75
- [5] Const mutate _$13_@2 = JSX <read $12_@1:TPrimitive a={freeze a$10_@0} ></read $12_@1:TPrimitive>
73
+ [4] Const mutate $12:TPrimitive = "div"
74
+ scope @1 [5:6] deps=[read $12:TPrimitive] {
75
+ [5] Const mutate _$13_@1 = JSX <read $12:TPrimitive a={freeze a$10_@0} ></read $12:TPrimitive>
76
}
77
[6] New mutate Foo$4(mutate b$11_@0:TObject)
78
}
79
- [7] Const mutate $14_@3:TPrimitive = "div"
80
- scope @4 [8:9] deps=[read $14_@3:TPrimitive, read a$10_@0, freeze b$11_@0:TObject] {
81
- [8] Const mutate $15_@4 = JSX <read $14_@3:TPrimitive a={read a$10_@0} b={freeze b$11_@0:TObject} ></read $14_@3:TPrimitive>
79
+ [7] Const mutate $14:TPrimitive = "div"
80
+ scope @2 [8:9] deps=[read $14:TPrimitive, read a$10_@0, freeze b$11_@0:TObject] {
81
+ [8] Const mutate $15_@2 = JSX <read $14:TPrimitive a={read a$10_@0} b={freeze b$11_@0:TObject} ></read $14:TPrimitive>
82
}
83
- return read $15_@4
83
+ return read $15_@2
84
}
85
86
```
compiler/forget/src/__tests__/fixtures/hir/dependencies-outputs.expect.md
+12
-14
@@ -24,29 +24,27 @@ function foo(a, b) {
24
bb0:
25
[1] Const mutate x$8_@0:TFunction[1:3] = Array []
26
[2] Call mutate x$8_@0.push(read a$6)
27
- [3] Const mutate $9_@1:TPrimitive = "div"
28
- [4] JSX <read $9_@1:TPrimitive>{freeze x$8_@0:TFunction}</read $9_@1:TPrimitive>
29
- [5] Const mutate y$10_@2:TFunction[5:12] = Array []
27
+ [3] Const mutate $9:TPrimitive = "div"
28
+ [4] JSX <read $9:TPrimitive>{freeze x$8_@0:TFunction}</read $9:TPrimitive>
29
+ [5] Const mutate y$10_@1:TFunction[5:12] = Array []
30
[6] If (read x$8_@0.length) then:bb2 else:bb1 fallthrough=bb1
31
bb2:
32
predecessor blocks: bb0
33
- [7] Call mutate y$10_@2.push(read x$8_@0:TFunction)
33
+ [7] Call mutate y$10_@1.push(read x$8_@0:TFunction)
34
[8] Goto bb1
35
bb1:
36
predecessor blocks: bb2 bb0
37
[9] If (read b$7:TFunction) then:bb4 else:bb3 fallthrough=bb3
38
bb4:
39
predecessor blocks: bb1
40
- [10] Call mutate y$10_@2.push(read b$7:TFunction)
40
+ [10] Call mutate y$10_@1.push(read b$7:TFunction)
41
[11] Goto bb3
42
bb3:
43
predecessor blocks: bb4 bb1
44
[12] Return
45
scope0 [1:3]:
46
- dependency: read a$6
47
-scope1 [3:4]:
48
- - dependency: freeze x$8_@0:TFunction
49
-scope2 [5:12]:
47
+scope1 [5:12]:
48
- dependency: read x$8_@0:TFunction
49
- dependency: read x$8_@0.length
50
- dependency: read b$7:TFunction
@@ -64,15 +62,15 @@ function foo(
62
[1] Const mutate x$8_@0:TFunction[1:3] = Array []
63
[2] Call mutate x$8_@0.push(read a$6)
64
}
67
- [3] Const mutate $9_@1:TPrimitive = "div"
68
- [4] JSX <read $9_@1:TPrimitive>{freeze x$8_@0:TFunction}</read $9_@1:TPrimitive>
69
- scope @2 [5:12] deps=[read x$8_@0:TFunction, read x$8_@0.length, read b$7:TFunction, read b$7:TFunction] {
70
- [5] Const mutate y$10_@2:TFunction[5:12] = Array []
65
+ [3] Const mutate $9:TPrimitive = "div"
66
+ [4] JSX <read $9:TPrimitive>{freeze x$8_@0:TFunction}</read $9:TPrimitive>
67
+ scope @1 [5:12] deps=[read x$8_@0:TFunction, read x$8_@0.length, read b$7:TFunction, read b$7:TFunction] {
68
+ [5] Const mutate y$10_@1:TFunction[5:12] = Array []
69
if (read x$8_@0.length) {
72
- [7] Call mutate y$10_@2.push(read x$8_@0:TFunction)
70
+ [7] Call mutate y$10_@1.push(read x$8_@0:TFunction)
71
}
72
if (read b$7:TFunction) {
75
- [10] Call mutate y$10_@2.push(read b$7:TFunction)
73
+ [10] Call mutate y$10_@1.push(read b$7:TFunction)
74
}
75
}
76
return
compiler/forget/src/__tests__/fixtures/hir/extend-scopes-if.expect.md
+8
-8
@@ -33,8 +33,8 @@ bb4:
33
[4] If (read c$9) then:bb6 else:bb1 fallthrough=bb1
34
bb6:
35
predecessor blocks: bb4
36
- [5] Const mutate $11_@1:TPrimitive = 0
37
- [6] Call mutate x$10_@0.push(read $11_@1:TPrimitive)
36
+ [5] Const mutate $11:TPrimitive = 0
37
+ [6] Call mutate x$10_@0.push(read $11:TPrimitive)
38
[7] Goto bb1
39
bb1:
40
predecessor blocks: bb6 bb4 bb2 bb0
@@ -44,8 +44,8 @@ bb8:
44
[9] Return read a$7
45
bb7:
46
predecessor blocks: bb1
47
- [10] Const mutate $13_@2:TPrimitive = null
48
- [11] Return read $13_@2:TPrimitive
47
+ [10] Const mutate $13:TPrimitive = null
48
+ [11] Return read $13:TPrimitive
49
scope0 [1:8]:
50
- dependency: read c$9
51
- dependency: read b$8
@@ -65,8 +65,8 @@ function foo(
65
if (read a$7) {
66
if (read b$8) {
67
if (read c$9) {
68
- [5] Const mutate $11_@1:TPrimitive = 0
69
- [6] Call mutate x$10_@0.push(read $11_@1:TPrimitive)
68
+ [5] Const mutate $11:TPrimitive = 0
69
+ [6] Call mutate x$10_@0.push(read $11:TPrimitive)
70
}
71
}
72
}
@@ -74,8 +74,8 @@ function foo(
74
if (read a$7.length) {
75
return read a$7
76
}
77
- [10] Const mutate $13_@2:TPrimitive = null
78
- return read $13_@2:TPrimitive
77
+ [10] Const mutate $13:TPrimitive = null
78
+ return read $13:TPrimitive
79
}
80
81
```
compiler/forget/src/__tests__/fixtures/hir/frozen-after-alias.expect.md
+5
-7
@@ -19,13 +19,11 @@ function foo(x) {}
19
```
20
bb0:
21
[1] Const mutate a$5_@0 = Array []
22
- [2] Const mutate b$6_@1 = read a$5_@0
22
+ [2] Const mutate b$6 = read a$5_@0
23
[3] Call read useFreeze$3:TFunction(freeze a$5_@0)
24
- [4] Call mutate foo$4:TFunction(read b$6_@1)
24
+ [4] Call mutate foo$4:TFunction(read b$6)
25
[5] Return
26
-scope1 [2:3]:
27
- - dependency: read a$5_@0
28
- - dependency: freeze a$5_@0
26
+
27
```
28
29
## Reactive Scopes
@@ -36,9 +34,9 @@ function Component(
34
scope @0 [1:2] deps=[] {
35
[1] Const mutate a$5_@0 = Array []
36
}
39
- [2] Const mutate b$6_@1 = read a$5_@0
37
+ [2] Const mutate b$6 = read a$5_@0
38
[3] Call read useFreeze$3:TFunction(freeze a$5_@0)
41
- [4] Call mutate foo$4:TFunction(read b$6_@1)
39
+ [4] Call mutate foo$4:TFunction(read b$6)
40
return
41
}
42
compiler/forget/src/__tests__/fixtures/hir/hook-call.expect.md
+15
-15
@@ -74,21 +74,21 @@ bb0:
74
[1] Const mutate x$11_@0 = Array []
75
[2] Const mutate y$12_@1 = Call read useFreeze$4:TFunction(freeze x$11_@0)
76
[3] Call mutate foo$5:TFunction(read y$12_@1, read x$11_@0)
77
- [4] Const mutate $13_@2 = "\n "
78
- [5] Const mutate $14_@3 = "\n "
79
- [6] Const mutate $15_@4 = "\n "
80
- [7] Const mutate $16_@5 = JSX <read Component$0>{read $13_@2}{read x$11_@0}{read $14_@3}{read y$12_@1}{read $15_@4}</read Component$0>
81
- [8] Return read $16_@5
77
+ [4] Const mutate $13 = "\n "
78
+ [5] Const mutate $14 = "\n "
79
+ [6] Const mutate $15 = "\n "
80
+ [7] Const mutate $16_@2 = JSX <read Component$0>{read $13}{read x$11_@0}{read $14}{read y$12_@1}{read $15}</read Component$0>
81
+ [8] Return read $16_@2
82
scope1 [2:3]:
83
- dependency: freeze x$11_@0
84
- dependency: read x$11_@0
85
-scope5 [7:8]:
85
+scope2 [7:8]:
86
- dependency: read Component$0
87
- - dependency: read $13_@2
87
+ - dependency: read $13
88
- dependency: read x$11_@0
89
- - dependency: read $14_@3
89
+ - dependency: read $14
90
- dependency: read y$12_@1
91
- - dependency: read $15_@4
91
+ - dependency: read $15
92
```
93
94
## Reactive Scopes
@@ -104,13 +104,13 @@ function Component(
104
[2] Const mutate y$12_@1 = Call read useFreeze$4:TFunction(freeze x$11_@0)
105
}
106
[3] Call mutate foo$5:TFunction(read y$12_@1, read x$11_@0)
107
- [4] Const mutate $13_@2 = "\n "
108
- [5] Const mutate $14_@3 = "\n "
109
- [6] Const mutate $15_@4 = "\n "
110
- scope @5 [7:8] deps=[read Component$0, read $13_@2, read x$11_@0, read $14_@3, read y$12_@1, read $15_@4] {
111
- [7] Const mutate $16_@5 = JSX <read Component$0>{read $13_@2}{read x$11_@0}{read $14_@3}{read y$12_@1}{read $15_@4}</read Component$0>
107
+ [4] Const mutate $13 = "\n "
108
+ [5] Const mutate $14 = "\n "
109
+ [6] Const mutate $15 = "\n "
110
+ scope @2 [7:8] deps=[read Component$0, read $13, read x$11_@0, read $14, read y$12_@1, read $15] {
111
+ [7] Const mutate $16_@2 = JSX <read Component$0>{read $13}{read x$11_@0}{read $14}{read y$12_@1}{read $15}</read Component$0>
112
}
113
- return read $16_@5
113
+ return read $16_@2
114
}
115
116
```
compiler/forget/src/__tests__/fixtures/hir/hooks-freeze-possibly-mutable-arguments.expect.md
+26
-30
@@ -26,32 +26,28 @@ function call(x) {}
26
27
```
28
bb0:
29
- [1] Const mutate cond$8_@0:TProp = read props$7.cond
30
- [2] Const mutate x$9_@1:TProp = read props$7.x
31
- [3] Const mutate a$10_@2:TPrimitive = undefined
32
- [4] Let mutate a$11_@3:TProp[4:9] = undefined
33
- [4] If (read cond$8_@0:TProp) then:bb2 else:bb3 fallthrough=bb1
29
+ [1] Const mutate cond$8:TProp = read props$7.cond
30
+ [2] Const mutate x$9:TProp = read props$7.x
31
+ [3] Const mutate a$10:TPrimitive = undefined
32
+ [4] Let mutate a$11_@0:TProp[4:9] = undefined
33
+ [4] If (read cond$8:TProp) then:bb2 else:bb3 fallthrough=bb1
34
bb2:
35
predecessor blocks: bb0
36
- [5] Reassign mutate a$11_@3:TProp[4:9] = read x$9_@1:TProp
36
+ [5] Reassign mutate a$11_@0:TProp[4:9] = read x$9:TProp
37
[6] Goto bb1
38
bb3:
39
predecessor blocks: bb0
40
- [7] Reassign mutate a$11_@3:TProp[4:9] = Array []
40
+ [7] Reassign mutate a$11_@0:TProp[4:9] = Array []
41
[8] Goto bb1
42
bb1:
43
predecessor blocks: bb2 bb3
44
- [9] Call read useFreeze$5:TFunction(freeze a$11_@3:TProp)
45
- [10] Call read useFreeze$5:TFunction(read a$11_@3:TProp)
46
- [11] Call mutate call$6:TFunction(read a$11_@3:TProp)
47
- [12] Return read a$11_@3:TProp
48
-scope0 [1:2]:
49
- - dependency: read props$7.cond
50
-scope1 [2:3]:
51
- - dependency: read props$7.x
52
-scope3 [4:9]:
53
- - dependency: read x$9_@1:TProp
54
- - dependency: read cond$8_@0:TProp
44
+ [9] Call read useFreeze$5:TFunction(freeze a$11_@0:TProp)
45
+ [10] Call read useFreeze$5:TFunction(read a$11_@0:TProp)
46
+ [11] Call mutate call$6:TFunction(read a$11_@0:TProp)
47
+ [12] Return read a$11_@0:TProp
48
+scope0 [4:9]:
49
+ - dependency: read x$9:TProp
50
+ - dependency: read cond$8:TProp
51
```
52
53
## Reactive Scopes
@@ -60,21 +56,21 @@ scope3 [4:9]:
56
function Component(
57
props,
58
) {
63
- [1] Const mutate cond$8_@0:TProp = read props$7.cond
64
- [2] Const mutate x$9_@1:TProp = read props$7.x
65
- [3] Const mutate a$10_@2:TPrimitive = undefined
66
- scope @3 [4:9] deps=[read x$9_@1:TProp, read cond$8_@0:TProp] {
67
- [4] Let mutate a$11_@3:TProp[4:9] = undefined
68
- if (read cond$8_@0:TProp) {
69
- [5] Reassign mutate a$11_@3:TProp[4:9] = read x$9_@1:TProp
59
+ [1] Const mutate cond$8:TProp = read props$7.cond
60
+ [2] Const mutate x$9:TProp = read props$7.x
61
+ [3] Const mutate a$10:TPrimitive = undefined
62
+ scope @0 [4:9] deps=[read x$9:TProp, read cond$8:TProp] {
63
+ [4] Let mutate a$11_@0:TProp[4:9] = undefined
64
+ if (read cond$8:TProp) {
65
+ [5] Reassign mutate a$11_@0:TProp[4:9] = read x$9:TProp
66
} else {
71
- [7] Reassign mutate a$11_@3:TProp[4:9] = Array []
67
+ [7] Reassign mutate a$11_@0:TProp[4:9] = Array []
68
}
69
}
74
- [9] Call read useFreeze$5:TFunction(freeze a$11_@3:TProp)
75
- [10] Call read useFreeze$5:TFunction(read a$11_@3:TProp)
76
- [11] Call mutate call$6:TFunction(read a$11_@3:TProp)
77
- return read a$11_@3:TProp
70
+ [9] Call read useFreeze$5:TFunction(freeze a$11_@0:TProp)
71
+ [10] Call read useFreeze$5:TFunction(read a$11_@0:TProp)
72
+ [11] Call mutate call$6:TFunction(read a$11_@0:TProp)
73
+ return read a$11_@0:TProp
74
}
75
76
```
compiler/forget/src/__tests__/fixtures/hir/issue852.expect.md
+4
-8
@@ -17,15 +17,11 @@ function Component(c) {
17
bb0:
18
[1] Const mutate x$7_@0:TObject[1:3] = Object { c: read c$6 }
19
[2] Call mutate mutate$3:TFunction(mutate x$7_@0:TObject)
20
- [3] Const mutate a$8_@1:TObject = read x$7_@0:TObject
21
- [4] Const mutate b$9_@2:TObject = read a$8_@1:TObject
20
+ [3] Const mutate a$8:TObject = read x$7_@0:TObject
21
+ [4] Const mutate b$9:TObject = read a$8:TObject
22
[5] Return
23
scope0 [1:3]:
24
- dependency: read c$6
25
-scope1 [3:4]:
26
- - dependency: read x$7_@0:TObject
27
-scope2 [4:5]:
28
- - dependency: read a$8_@1:TObject
25
```
26
27
## Reactive Scopes
@@ -38,8 +34,8 @@ function Component(
34
[1] Const mutate x$7_@0:TObject[1:3] = Object { c: read c$6 }
35
[2] Call mutate mutate$3:TFunction(mutate x$7_@0:TObject)
36
}
41
- [3] Const mutate a$8_@1:TObject = read x$7_@0:TObject
42
- [4] Const mutate b$9_@2:TObject = read a$8_@1:TObject
37
+ [3] Const mutate a$8:TObject = read x$7_@0:TObject
38
+ [4] Const mutate b$9:TObject = read a$8:TObject
39
return
40
}
41
compiler/forget/src/__tests__/fixtures/hir/jsx-fragment.expect.md
+40
-40
@@ -19,32 +19,32 @@ function Foo(props) {
19
20
```
21
bb0:
22
- [1] Const mutate $14_@0 = "\n Hello "
23
- [2] Const mutate $15_@1:TPrimitive = " "
24
- [3] Const mutate $16_@2 = "\n "
25
- [4] Const mutate $17_@3:TPrimitive = "div"
26
- [5] Const mutate $18_@4 = "\n "
27
- [6] Const mutate $19_@5 = "Text"
28
- [7] Const mutate $20_@6 = JsxFragment [read $19_@5]
29
- [8] Const mutate $21_@7 = "\n "
30
- [9] Const mutate $22_@8 = JSX <read $17_@3:TPrimitive>{read $18_@4}{read $20_@6}{read $21_@7}</read $17_@3:TPrimitive>
31
- [10] Const mutate $23_@9 = "\n "
32
- [11] Const mutate $24_@10 = JsxFragment [read $14_@0, read props$13.greeting, read $15_@1:TPrimitive, read $16_@2, read $22_@8, read $23_@9]
33
- [12] Return read $24_@10
34
-scope6 [7:8]:
35
- - dependency: read $19_@5
36
-scope8 [9:10]:
37
- - dependency: read $17_@3:TPrimitive
38
- - dependency: read $18_@4
39
- - dependency: read $20_@6
40
- - dependency: read $21_@7
41
-scope10 [11:12]:
42
- - dependency: read $14_@0
22
+ [1] Const mutate $14 = "\n Hello "
23
+ [2] Const mutate $15:TPrimitive = " "
24
+ [3] Const mutate $16 = "\n "
25
+ [4] Const mutate $17:TPrimitive = "div"
26
+ [5] Const mutate $18 = "\n "
27
+ [6] Const mutate $19 = "Text"
28
+ [7] Const mutate $20_@0 = JsxFragment [read $19]
29
+ [8] Const mutate $21 = "\n "
30
+ [9] Const mutate $22_@1 = JSX <read $17:TPrimitive>{read $18}{read $20_@0}{read $21}</read $17:TPrimitive>
31
+ [10] Const mutate $23 = "\n "
32
+ [11] Const mutate $24_@2 = JsxFragment [read $14, read props$13.greeting, read $15:TPrimitive, read $16, read $22_@1, read $23]
33
+ [12] Return read $24_@2
34
+scope0 [7:8]:
35
+ - dependency: read $19
36
+scope1 [9:10]:
37
+ - dependency: read $17:TPrimitive
38
+ - dependency: read $18
39
+ - dependency: read $20_@0
40
+ - dependency: read $21
41
+scope2 [11:12]:
42
+ - dependency: read $14
43
- dependency: read props$13.greeting
44
- - dependency: read $15_@1:TPrimitive
45
- - dependency: read $16_@2
46
- - dependency: read $22_@8
47
- - dependency: read $23_@9
44
+ - dependency: read $15:TPrimitive
45
+ - dependency: read $16
46
+ - dependency: read $22_@1
47
+ - dependency: read $23
48
```
49
50
## Reactive Scopes
@@ -53,24 +53,24 @@ scope10 [11:12]:
53
function Foo(
54
props,
55
) {
56
- [1] Const mutate $14_@0 = "\n Hello "
57
- [2] Const mutate $15_@1:TPrimitive = " "
58
- [3] Const mutate $16_@2 = "\n "
59
- [4] Const mutate $17_@3:TPrimitive = "div"
60
- [5] Const mutate $18_@4 = "\n "
61
- [6] Const mutate $19_@5 = "Text"
62
- scope @6 [7:8] deps=[read $19_@5] {
63
- [7] Const mutate $20_@6 = JsxFragment [read $19_@5]
56
+ [1] Const mutate $14 = "\n Hello "
57
+ [2] Const mutate $15:TPrimitive = " "
58
+ [3] Const mutate $16 = "\n "
59
+ [4] Const mutate $17:TPrimitive = "div"
60
+ [5] Const mutate $18 = "\n "
61
+ [6] Const mutate $19 = "Text"
62
+ scope @0 [7:8] deps=[read $19] {
63
+ [7] Const mutate $20_@0 = JsxFragment [read $19]
64
}
65
- [8] Const mutate $21_@7 = "\n "
66
- scope @8 [9:10] deps=[read $17_@3:TPrimitive, read $18_@4, read $20_@6, read $21_@7] {
67
- [9] Const mutate $22_@8 = JSX <read $17_@3:TPrimitive>{read $18_@4}{read $20_@6}{read $21_@7}</read $17_@3:TPrimitive>
65
+ [8] Const mutate $21 = "\n "
66
+ scope @1 [9:10] deps=[read $17:TPrimitive, read $18, read $20_@0, read $21] {
67
+ [9] Const mutate $22_@1 = JSX <read $17:TPrimitive>{read $18}{read $20_@0}{read $21}</read $17:TPrimitive>
68
}
69
- [10] Const mutate $23_@9 = "\n "
70
- scope @10 [11:12] deps=[read $14_@0, read props$13.greeting, read $15_@1:TPrimitive, read $16_@2, read $22_@8, read $23_@9] {
71
- [11] Const mutate $24_@10 = JsxFragment [read $14_@0, read props$13.greeting, read $15_@1:TPrimitive, read $16_@2, read $22_@8, read $23_@9]
69
+ [10] Const mutate $23 = "\n "
70
+ scope @2 [11:12] deps=[read $14, read props$13.greeting, read $15:TPrimitive, read $16, read $22_@1, read $23] {
71
+ [11] Const mutate $24_@2 = JsxFragment [read $14, read props$13.greeting, read $15:TPrimitive, read $16, read $22_@1, read $23]
72
}
73
- return read $24_@10
73
+ return read $24_@2
74
}
75
76
```
compiler/forget/src/__tests__/fixtures/hir/logical-expression.expect.md
+17
-20
@@ -134,27 +134,24 @@ function Or$0() {
134
```
135
bb0:
136
[1] Const mutate $9_@0:TPrimitive = Call mutate f$2:TFunction()
137
- [2] Const mutate $10_@1:TPrimitive = null
138
- [3] Const mutate $11_@2:TPrimitive = Binary read $9_@0:TPrimitive != read $10_@1:TPrimitive
139
- [4] Let mutate $12_@3:TPrimitive[4:9] = undefined
140
- [4] If (read $11_@2:TPrimitive) then:bb2 else:bb3 fallthrough=bb1
137
+ [2] Const mutate $10:TPrimitive = null
138
+ [3] Const mutate $11:TPrimitive = Binary read $9_@0:TPrimitive != read $10:TPrimitive
139
+ [4] Let mutate $12_@1:TPrimitive[4:9] = undefined
140
+ [4] If (read $11:TPrimitive) then:bb2 else:bb3 fallthrough=bb1
141
bb2:
142
predecessor blocks: bb0
143
- [5] Const mutate $12_@3:TPrimitive[4:9] = read $9_@0:TPrimitive
143
+ [5] Const mutate $12_@1:TPrimitive[4:9] = read $9_@0:TPrimitive
144
[6] Goto bb1
145
bb3:
146
predecessor blocks: bb0
147
- [7] Const mutate $12_@3:TPrimitive[4:9] = Call mutate g$7:TFunction()
147
+ [7] Const mutate $12_@1:TPrimitive[4:9] = Call mutate g$7:TFunction()
148
[8] Goto bb1
149
bb1:
150
predecessor blocks: bb2 bb3
151
- [9] Return freeze $12_@3:TPrimitive
152
-scope2 [3:4]:
151
+ [9] Return freeze $12_@1:TPrimitive
152
+scope1 [4:9]:
153
- dependency: read $9_@0:TPrimitive
154
- - dependency: read $10_@1:TPrimitive
155
-scope3 [4:9]:
156
- - dependency: read $9_@0:TPrimitive
157
- - dependency: read $11_@2:TPrimitive
154
+ - dependency: read $11:TPrimitive
155
```
156
157
## Reactive Scopes
@@ -166,17 +163,17 @@ function QuestionQuestion(
163
scope @0 [1:2] deps=[] {
164
[1] Const mutate $9_@0:TPrimitive = Call mutate f$2:TFunction()
165
}
169
- [2] Const mutate $10_@1:TPrimitive = null
170
- [3] Const mutate $11_@2:TPrimitive = Binary read $9_@0:TPrimitive != read $10_@1:TPrimitive
171
- scope @3 [4:9] deps=[read $9_@0:TPrimitive, read $11_@2:TPrimitive] {
172
- [4] Let mutate $12_@3:TPrimitive[4:9] = undefined
173
- if (read $11_@2:TPrimitive) {
174
- [5] Const mutate $12_@3:TPrimitive[4:9] = read $9_@0:TPrimitive
166
+ [2] Const mutate $10:TPrimitive = null
167
+ [3] Const mutate $11:TPrimitive = Binary read $9_@0:TPrimitive != read $10:TPrimitive
168
+ scope @1 [4:9] deps=[read $9_@0:TPrimitive, read $11:TPrimitive] {
169
+ [4] Let mutate $12_@1:TPrimitive[4:9] = undefined
170
+ if (read $11:TPrimitive) {
171
+ [5] Const mutate $12_@1:TPrimitive[4:9] = read $9_@0:TPrimitive
172
} else {
176
- [7] Const mutate $12_@3:TPrimitive[4:9] = Call mutate g$7:TFunction()
173
+ [7] Const mutate $12_@1:TPrimitive[4:9] = Call mutate g$7:TFunction()
174
}
175
}
179
- return freeze $12_@3:TPrimitive
176
+ return freeze $12_@1:TPrimitive
177
}
178
179
```
compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-loops.expect.md
+19
-21
@@ -101,8 +101,8 @@ bb0:
101
[5] While test=bb1 loop=bb3 fallthrough=bb2
102
bb1:
103
predecessor blocks: bb0 bb4
104
- [6] Const mutate $17_@1:TPrimitive[6:8] = true
105
- [7] If (read $17_@1:TPrimitive) then:bb3 else:bb2 fallthrough=bb2
104
+ [6] Const mutate $17:TPrimitive = true
105
+ [7] If (read $17:TPrimitive) then:bb3 else:bb2 fallthrough=bb2
106
bb3:
107
predecessor blocks: bb1
108
[8] Const mutate z$19_@0[1:23] = read a$18_@0
@@ -130,8 +130,8 @@ bb11:
130
[20] If (read d$24_@0) then:bb13 else:bb13 fallthrough=bb13
131
bb13:
132
predecessor blocks: bb11
133
- [21] Const mutate $34_@2:TPrimitive = null
134
- [22] Call mutate mutate$7:TFunction(mutate d$24_@0, read $34_@2:TPrimitive)
133
+ [21] Const mutate $34:TPrimitive = null
134
+ [22] Call mutate mutate$7:TFunction(mutate d$24_@0, read $34:TPrimitive)
135
[23] Return
136
137
```
@@ -147,21 +147,19 @@ function Component(
147
[2] Let mutate b$20_@0[1:23] = Object { }
148
[3] Let mutate c$22_@0:TPrimitive[1:23] = Object { }
149
[4] Let mutate d$24_@0[1:23] = Object { }
150
- scope @1 [6:8] deps=[] {
151
- while (
152
- [6] Const mutate $17_@1:TPrimitive[6:8] = true
153
- read $17_@1:TPrimitive
154
- ) {
155
- [8] Const mutate z$19_@0[1:23] = read a$18_@0
156
- [9] Reassign mutate a$18_@0[1:23] = read b$20_@0
157
- [10] Reassign mutate b$20_@0[1:23] = read c$22_@0:TPrimitive
158
- [11] Reassign mutate c$22_@0:TPrimitive[1:23] = read d$24_@0
159
- [12] Reassign mutate d$24_@0[1:23] = read z$19_@0
160
- [13] Call mutate mutate$7:TFunction(mutate a$18_@0, mutate b$20_@0)
161
- [14] Const mutate $29_@0[1:23] = Call mutate cond$8:TFunction(mutate a$18_@0)
162
- if (read $29_@0) {
163
- break
164
- }
150
+ while (
151
+ [6] Const mutate $17:TPrimitive = true
152
+ read $17:TPrimitive
153
+ ) {
154
+ [8] Const mutate z$19_@0[1:23] = read a$18_@0
155
+ [9] Reassign mutate a$18_@0[1:23] = read b$20_@0
156
+ [10] Reassign mutate b$20_@0[1:23] = read c$22_@0:TPrimitive
157
+ [11] Reassign mutate c$22_@0:TPrimitive[1:23] = read d$24_@0
158
+ [12] Reassign mutate d$24_@0[1:23] = read z$19_@0
159
+ [13] Call mutate mutate$7:TFunction(mutate a$18_@0, mutate b$20_@0)
160
+ [14] Const mutate $29_@0[1:23] = Call mutate cond$8:TFunction(mutate a$18_@0)
161
+ if (read $29_@0) {
162
+ break
163
}
164
}
165
if (read a$18_@0) {
@@ -172,8 +170,8 @@ function Component(
170
}
171
if (read d$24_@0) {
172
}
175
- [21] Const mutate $34_@2:TPrimitive = null
176
- [22] Call mutate mutate$7:TFunction(mutate d$24_@0, read $34_@2:TPrimitive)
173
+ [21] Const mutate $34:TPrimitive = null
174
+ [22] Call mutate mutate$7:TFunction(mutate d$24_@0, read $34:TPrimitive)
175
}
176
return
177
}
compiler/forget/src/__tests__/fixtures/hir/mutable-lifetime-with-aliasing.expect.md
+4
-4
@@ -87,8 +87,8 @@ bb7:
87
[12] If (read y$16_@1) then:bb9 else:bb9 fallthrough=bb9
88
bb9:
89
predecessor blocks: bb7
90
- [13] Const mutate $17_@3:TPrimitive = null
91
- [14] Call mutate mutate$8:TFunction(mutate x$15_@1:TObject, read $17_@3:TPrimitive)
90
+ [13] Const mutate $17:TPrimitive = null
91
+ [14] Call mutate mutate$8:TFunction(mutate x$15_@1:TObject, read $17:TPrimitive)
92
[15] Return
93
scope1 [2:15]:
94
- dependency: read a$11_@0:TObject
@@ -123,8 +123,8 @@ function Component(
123
}
124
if (read y$16_@1) {
125
}
126
- [13] Const mutate $17_@3:TPrimitive = null
127
- [14] Call mutate mutate$8:TFunction(mutate x$15_@1:TObject, read $17_@3:TPrimitive)
126
+ [13] Const mutate $17:TPrimitive = null
127
+ [14] Call mutate mutate$8:TFunction(mutate x$15_@1:TObject, read $17:TPrimitive)
128
}
129
return
130
}
compiler/forget/src/__tests__/fixtures/hir/mutable-liverange-loop.expect.md
+14
-16
@@ -93,8 +93,8 @@ bb0:
93
[5] While test=bb1 loop=bb3 fallthrough=bb2
94
bb1:
95
predecessor blocks: bb0 bb4
96
- [6] Const mutate $16_@3:TPrimitive[6:8] = true
97
- [7] If (read $16_@3:TPrimitive) then:bb3 else:bb2 fallthrough=bb2
96
+ [6] Const mutate $16:TPrimitive = true
97
+ [7] If (read $16:TPrimitive) then:bb3 else:bb2 fallthrough=bb2
98
bb3:
99
predecessor blocks: bb1
100
[8] Call mutate mutate$6:TFunction(mutate a$12_@0:TObject, mutate b$13_@0:TObject)
@@ -117,8 +117,8 @@ bb11:
117
[15] If (read d$15_@0:TObject) then:bb13 else:bb13 fallthrough=bb13
118
bb13:
119
predecessor blocks: bb11
120
- [16] Const mutate $28_@4:TPrimitive = null
121
- [17] Call mutate mutate$6:TFunction(mutate d$15_@0:TObject, read $28_@4:TPrimitive)
120
+ [16] Const mutate $28:TPrimitive = null
121
+ [17] Call mutate mutate$6:TFunction(mutate d$15_@0:TObject, read $28:TPrimitive)
122
[18] Return
123
124
```
@@ -136,16 +136,14 @@ function Component(
136
[3] Const mutate c$14_@1:TObject = Object { }
137
}
138
[4] Const mutate d$15_@0:TObject[1:18] = Object { }
139
- scope @3 [6:8] deps=[] {
140
- while (
141
- [6] Const mutate $16_@3:TPrimitive[6:8] = true
142
- read $16_@3:TPrimitive
143
- ) {
144
- [8] Call mutate mutate$6:TFunction(mutate a$12_@0:TObject, mutate b$13_@0:TObject)
145
- [9] Const mutate $21_@0[1:18] = Call mutate cond$7:TFunction(mutate a$12_@0:TObject)
146
- if (read $21_@0) {
147
- break
148
- }
139
+ while (
140
+ [6] Const mutate $16:TPrimitive = true
141
+ read $16:TPrimitive
142
+ ) {
143
+ [8] Call mutate mutate$6:TFunction(mutate a$12_@0:TObject, mutate b$13_@0:TObject)
144
+ [9] Const mutate $21_@0[1:18] = Call mutate cond$7:TFunction(mutate a$12_@0:TObject)
145
+ if (read $21_@0) {
146
+ break
147
}
148
}
149
if (read a$12_@0:TObject) {
@@ -156,8 +154,8 @@ function Component(
154
}
155
if (read d$15_@0:TObject) {
156
}
159
- [16] Const mutate $28_@4:TPrimitive = null
160
- [17] Call mutate mutate$6:TFunction(mutate d$15_@0:TObject, read $28_@4:TPrimitive)
157
+ [16] Const mutate $28:TPrimitive = null
158
+ [17] Call mutate mutate$6:TFunction(mutate d$15_@0:TObject, read $28:TPrimitive)
159
}
160
return
161
}
compiler/forget/src/__tests__/fixtures/hir/overlapping-scopes-shadowing-within-block.expect.md
+9
-9
@@ -33,9 +33,9 @@ bb4:
33
[6] Goto bb3
34
bb3:
35
predecessor blocks: bb4 bb2
36
- [7] Const mutate $13_@2:TPrimitive = "div"
37
- [8] Const mutate $15_@3 = JSX <read $13_@2:TPrimitive>{freeze y$12_@1:TFunction}</read $13_@2:TPrimitive>
38
- [9] Call mutate x$11_@0.push(read $15_@3)
36
+ [7] Const mutate $13:TPrimitive = "div"
37
+ [8] Const mutate $15_@2 = JSX <read $13:TPrimitive>{freeze y$12_@1:TFunction}</read $13:TPrimitive>
38
+ [9] Call mutate x$11_@0.push(read $15_@2)
39
[10] Goto bb1
40
bb1:
41
predecessor blocks: bb3 bb0
@@ -45,8 +45,8 @@ scope0 [1:11]:
45
scope1 [3:7]:
46
- dependency: read c$10
47
- dependency: read b$9
48
-scope3 [8:9]:
49
- - dependency: read $13_@2:TPrimitive
48
+scope2 [8:9]:
49
+ - dependency: read $13:TPrimitive
50
- dependency: freeze y$12_@1:TFunction
51
```
52
@@ -67,11 +67,11 @@ function foo(
67
[5] Call mutate y$12_@1.push(read c$10)
68
}
69
}
70
- [7] Const mutate $13_@2:TPrimitive = "div"
71
- scope @3 [8:9] deps=[read $13_@2:TPrimitive, freeze y$12_@1:TFunction] {
72
- [8] Const mutate $15_@3 = JSX <read $13_@2:TPrimitive>{freeze y$12_@1:TFunction}</read $13_@2:TPrimitive>
70
+ [7] Const mutate $13:TPrimitive = "div"
71
+ scope @2 [8:9] deps=[read $13:TPrimitive, freeze y$12_@1:TFunction] {
72
+ [8] Const mutate $15_@2 = JSX <read $13:TPrimitive>{freeze y$12_@1:TFunction}</read $13:TPrimitive>
73
}
74
- [9] Call mutate x$11_@0.push(read $15_@3)
74
+ [9] Call mutate x$11_@0.push(read $15_@2)
75
}
76
}
77
return freeze x$11_@0:TFunction
compiler/forget/src/__tests__/fixtures/hir/reactive-scopes-if.expect.md
+9
-9
@@ -26,9 +26,9 @@ bb2:
26
predecessor blocks: bb0
27
[3] Const mutate y$12_@1:TFunction[3:5] = Array []
28
[4] Call mutate y$12_@1.push(read b$9)
29
- [5] Const mutate $13_@2:TPrimitive = "div"
30
- [6] Const mutate $14_@3 = JSX <read $13_@2:TPrimitive>{freeze y$12_@1:TFunction}</read $13_@2:TPrimitive>
31
- [7] Call mutate x$11_@0.push(read $14_@3)
29
+ [5] Const mutate $13:TPrimitive = "div"
30
+ [6] Const mutate $14_@2 = JSX <read $13:TPrimitive>{freeze y$12_@1:TFunction}</read $13:TPrimitive>
31
+ [7] Call mutate x$11_@0.push(read $14_@2)
32
[8] Goto bb1
33
bb3:
34
predecessor blocks: bb0
@@ -42,8 +42,8 @@ scope0 [1:11]:
42
- dependency: read a$8
43
scope1 [3:5]:
44
- dependency: read b$9
45
-scope3 [6:7]:
46
- - dependency: read $13_@2:TPrimitive
45
+scope2 [6:7]:
46
+ - dependency: read $13:TPrimitive
47
- dependency: freeze y$12_@1:TFunction
48
```
49
@@ -62,11 +62,11 @@ function foo(
62
[3] Const mutate y$12_@1:TFunction[3:5] = Array []
63
[4] Call mutate y$12_@1.push(read b$9)
64
}
65
- [5] Const mutate $13_@2:TPrimitive = "div"
66
- scope @3 [6:7] deps=[read $13_@2:TPrimitive, freeze y$12_@1:TFunction] {
67
- [6] Const mutate $14_@3 = JSX <read $13_@2:TPrimitive>{freeze y$12_@1:TFunction}</read $13_@2:TPrimitive>
65
+ [5] Const mutate $13:TPrimitive = "div"
66
+ scope @2 [6:7] deps=[read $13:TPrimitive, freeze y$12_@1:TFunction] {
67
+ [6] Const mutate $14_@2 = JSX <read $13:TPrimitive>{freeze y$12_@1:TFunction}</read $13:TPrimitive>
68
}
69
- [7] Call mutate x$11_@0.push(read $14_@3)
69
+ [7] Call mutate x$11_@0.push(read $14_@2)
70
} else {
71
[9] Call mutate x$11_@0.push(read c$10)
72
}
compiler/forget/src/__tests__/fixtures/hir/reactive-scopes.expect.md
+17
-19
@@ -20,9 +20,9 @@ function f(a, b) {
20
```
21
bb0:
22
[1] Const mutate x$10_@0:TFunction[1:8] = Array []
23
- [2] Const mutate $11_@1:TPrimitive = 1
24
- [3] Const mutate $12_@2:TPrimitive = Binary read a$8.length === read $11_@1:TPrimitive
25
- [4] If (read $12_@2:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
23
+ [2] Const mutate $11:TPrimitive = 1
24
+ [3] Const mutate $12:TPrimitive = Binary read a$8.length === read $11:TPrimitive
25
+ [4] If (read $12:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
26
bb2:
27
predecessor blocks: bb0
28
[5] If (read b$9) then:bb4 else:bb1 fallthrough=bb1
@@ -32,17 +32,15 @@ bb4:
32
[7] Goto bb1
33
bb1:
34
predecessor blocks: bb4 bb2 bb0
35
- [8] Const mutate $13_@3:TPrimitive = "div"
36
- [9] Const mutate $15_@4 = JSX <read $13_@3:TPrimitive>{freeze x$10_@0:TFunction}</read $13_@3:TPrimitive>
37
- [10] Return read $15_@4
35
+ [8] Const mutate $13:TPrimitive = "div"
36
+ [9] Const mutate $15_@1 = JSX <read $13:TPrimitive>{freeze x$10_@0:TFunction}</read $13:TPrimitive>
37
+ [10] Return read $15_@1
38
scope0 [1:8]:
39
+ - dependency: read a$8.length
40
- dependency: read b$9
41
- dependency: read b$9
41
-scope2 [3:4]:
42
- - dependency: read a$8.length
43
- - dependency: read $11_@1:TPrimitive
44
-scope4 [9:10]:
45
- - dependency: read $13_@3:TPrimitive
42
+scope1 [9:10]:
43
+ - dependency: read $13:TPrimitive
44
- dependency: freeze x$10_@0:TFunction
45
```
46
@@ -53,21 +51,21 @@ function f(
51
a,
52
b,
53
) {
56
- scope @0 [1:8] deps=[read b$9, read b$9] {
54
+ scope @0 [1:8] deps=[read a$8.length, read b$9, read b$9] {
55
[1] Const mutate x$10_@0:TFunction[1:8] = Array []
58
- [2] Const mutate $11_@1:TPrimitive = 1
59
- [3] Const mutate $12_@2:TPrimitive = Binary read a$8.length === read $11_@1:TPrimitive
60
- if (read $12_@2:TPrimitive) {
56
+ [2] Const mutate $11:TPrimitive = 1
57
+ [3] Const mutate $12:TPrimitive = Binary read a$8.length === read $11:TPrimitive
58
+ if (read $12:TPrimitive) {
59
if (read b$9) {
60
[6] Call mutate x$10_@0.push(read b$9)
61
}
62
}
63
}
66
- [8] Const mutate $13_@3:TPrimitive = "div"
67
- scope @4 [9:10] deps=[read $13_@3:TPrimitive, freeze x$10_@0:TFunction] {
68
- [9] Const mutate $15_@4 = JSX <read $13_@3:TPrimitive>{freeze x$10_@0:TFunction}</read $13_@3:TPrimitive>
64
+ [8] Const mutate $13:TPrimitive = "div"
65
+ scope @1 [9:10] deps=[read $13:TPrimitive, freeze x$10_@0:TFunction] {
66
+ [9] Const mutate $15_@1 = JSX <read $13:TPrimitive>{freeze x$10_@0:TFunction}</read $13:TPrimitive>
67
}
70
- return read $15_@4
68
+ return read $15_@1
69
}
70
71
```
compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md
+10
-10
@@ -25,7 +25,7 @@ function Component(props) {
25
bb0:
26
[1] Let mutate x$7_@0:TFunction[1:7] = Array []
27
[2] Call mutate x$7_@0.push(read props$6.p0)
28
- [3] Const mutate y$8_@0:TFunction[1:7] = read x$7_@0:TFunction
28
+ [3] Const mutate y$8:TFunction = read x$7_@0:TFunction
29
[4] If (read props$6.p1) then:bb2 else:bb1 fallthrough=bb1
30
bb2:
31
predecessor blocks: bb0
@@ -34,8 +34,8 @@ bb2:
34
bb1:
35
predecessor blocks: bb2 bb0
36
[7] Const mutate _$12_@1 = JSX <read Component$0 x={freeze x$7_@0:TFunction} ></read Component$0>
37
- [8] Call read y$8_@0.push(read props$6.p2)
38
- [9] Const mutate $15_@2 = JSX <read Component$0 x={read x$7_@0:TFunction} y={read y$8_@0:TFunction} ></read Component$0>
37
+ [8] Call read y$8.push(read props$6.p2)
38
+ [9] Const mutate $15_@2 = JSX <read Component$0 x={read x$7_@0:TFunction} y={read y$8:TFunction} ></read Component$0>
39
[10] Return read $15_@2
40
scope0 [1:7]:
41
- dependency: read props$6.p0
@@ -43,12 +43,12 @@ scope0 [1:7]:
43
scope1 [7:8]:
44
- dependency: read Component$0
45
- dependency: freeze x$7_@0:TFunction
46
- - dependency: read y$8_@0.push
46
+ - dependency: read y$8.push
47
- dependency: read props$6.p2
48
scope2 [9:10]:
49
- dependency: read Component$0
50
- dependency: read x$7_@0:TFunction
51
- - dependency: read y$8_@0:TFunction
51
+ - dependency: read y$8:TFunction
52
```
53
54
## Reactive Scopes
@@ -60,17 +60,17 @@ function Component(
60
scope @0 [1:7] deps=[read props$6.p0, read props$6.p1] {
61
[1] Let mutate x$7_@0:TFunction[1:7] = Array []
62
[2] Call mutate x$7_@0.push(read props$6.p0)
63
- [3] Const mutate y$8_@0:TFunction[1:7] = read x$7_@0:TFunction
63
+ [3] Const mutate y$8:TFunction = read x$7_@0:TFunction
64
if (read props$6.p1) {
65
[5] Reassign mutate x$7_@0:TFunction[1:7] = Array []
66
}
67
}
68
- scope @1 [7:8] deps=[read Component$0, freeze x$7_@0:TFunction, read y$8_@0.push, read props$6.p2] {
68
+ scope @1 [7:8] deps=[read Component$0, freeze x$7_@0:TFunction, read y$8.push, read props$6.p2] {
69
[7] Const mutate _$12_@1 = JSX <read Component$0 x={freeze x$7_@0:TFunction} ></read Component$0>
70
}
71
- [8] Call read y$8_@0.push(read props$6.p2)
72
- scope @2 [9:10] deps=[read Component$0, read x$7_@0:TFunction, read y$8_@0:TFunction] {
73
- [9] Const mutate $15_@2 = JSX <read Component$0 x={read x$7_@0:TFunction} y={read y$8_@0:TFunction} ></read Component$0>
71
+ [8] Call read y$8.push(read props$6.p2)
72
+ scope @2 [9:10] deps=[read Component$0, read x$7_@0:TFunction, read y$8:TFunction] {
73
+ [9] Const mutate $15_@2 = JSX <read Component$0 x={read x$7_@0:TFunction} y={read y$8:TFunction} ></read Component$0>
74
}
75
return read $15_@2
76
}
compiler/forget/src/__tests__/fixtures/hir/reassignment-separate-scopes.expect.md
+43
-43
@@ -42,49 +42,49 @@ bb2:
42
[4] Goto bb1
43
bb1:
44
predecessor blocks: bb2 bb0
45
- [5] Const mutate $17_@1:TPrimitive = "div"
46
- [6] Const mutate y$19_@2 = JSX <read $17_@1:TPrimitive>{freeze x$16_@0:TFunction}</read $17_@1:TPrimitive>
47
- [7] Const mutate $20_@3:TPrimitive = 0
48
- [8] Let mutate x$22_@4:TFunction[8:15] = undefined
45
+ [5] Const mutate $17:TPrimitive = "div"
46
+ [6] Const mutate y$19_@1 = JSX <read $17:TPrimitive>{freeze x$16_@0:TFunction}</read $17:TPrimitive>
47
+ [7] Const mutate $20:TPrimitive = 0
48
+ [8] Let mutate x$22_@2:TFunction[8:15] = undefined
49
[8] Switch (read b$14)
50
- Case read $20_@3:TPrimitive: bb5
50
+ Case read $20:TPrimitive: bb5
51
Default: bb4
52
Fallthrough: bb3
53
bb5:
54
predecessor blocks: bb1
55
- [9] Reassign mutate x$22_@4:TFunction[8:15] = Array []
56
- [10] Call mutate x$22_@4.push(read b$14)
55
+ [9] Reassign mutate x$22_@2:TFunction[8:15] = Array []
56
+ [10] Call mutate x$22_@2.push(read b$14)
57
[11] Goto bb3
58
bb4:
59
predecessor blocks: bb1
60
- [12] Reassign mutate x$22_@4:TFunction[8:15] = Array []
61
- [13] Call mutate x$22_@4.push(read c$15)
60
+ [12] Reassign mutate x$22_@2:TFunction[8:15] = Array []
61
+ [13] Call mutate x$22_@2.push(read c$15)
62
[14] Goto bb3
63
bb3:
64
predecessor blocks: bb5 bb4
65
- [15] Const mutate $25_@5:TPrimitive = "div"
66
- [16] Const mutate $26_@6 = "\n "
67
- [17] Const mutate $27_@7 = "\n "
68
- [18] Const mutate $28_@8 = "\n "
69
- [19] Const mutate $31_@9 = JSX <read $25_@5:TPrimitive>{read $26_@6}{read y$19_@2}{read $27_@7}{freeze x$22_@4:TFunction}{read $28_@8}</read $25_@5:TPrimitive>
70
- [20] Return read $31_@9
65
+ [15] Const mutate $25:TPrimitive = "div"
66
+ [16] Const mutate $26 = "\n "
67
+ [17] Const mutate $27 = "\n "
68
+ [18] Const mutate $28 = "\n "
69
+ [19] Const mutate $31_@3 = JSX <read $25:TPrimitive>{read $26}{read y$19_@1}{read $27}{freeze x$22_@2:TFunction}{read $28}</read $25:TPrimitive>
70
+ [20] Return read $31_@3
71
scope0 [1:5]:
72
- dependency: read a$13
73
- dependency: read a$13
74
-scope2 [6:7]:
75
- - dependency: read $17_@1:TPrimitive
74
+scope1 [6:7]:
75
+ - dependency: read $17:TPrimitive
76
- dependency: freeze x$16_@0:TFunction
77
-scope4 [8:15]:
77
+scope2 [8:15]:
78
- dependency: read c$15
79
- dependency: read b$14
80
- dependency: read b$14
81
-scope9 [19:20]:
82
- - dependency: read $25_@5:TPrimitive
83
- - dependency: read $26_@6
84
- - dependency: read y$19_@2
85
- - dependency: read $27_@7
86
- - dependency: freeze x$22_@4:TFunction
87
- - dependency: read $28_@8
81
+scope3 [19:20]:
82
+ - dependency: read $25:TPrimitive
83
+ - dependency: read $26
84
+ - dependency: read y$19_@1
85
+ - dependency: read $27
86
+ - dependency: freeze x$22_@2:TFunction
87
+ - dependency: read $28
88
```
89
90
## Reactive Scopes
@@ -101,33 +101,33 @@ function foo(
101
[3] Call mutate x$16_@0.push(read a$13)
102
}
103
}
104
- [5] Const mutate $17_@1:TPrimitive = "div"
105
- scope @2 [6:7] deps=[read $17_@1:TPrimitive, freeze x$16_@0:TFunction] {
106
- [6] Const mutate y$19_@2 = JSX <read $17_@1:TPrimitive>{freeze x$16_@0:TFunction}</read $17_@1:TPrimitive>
104
+ [5] Const mutate $17:TPrimitive = "div"
105
+ scope @1 [6:7] deps=[read $17:TPrimitive, freeze x$16_@0:TFunction] {
106
+ [6] Const mutate y$19_@1 = JSX <read $17:TPrimitive>{freeze x$16_@0:TFunction}</read $17:TPrimitive>
107
}
108
- [7] Const mutate $20_@3:TPrimitive = 0
109
- scope @4 [8:15] deps=[read c$15, read b$14, read b$14] {
110
- [8] Let mutate x$22_@4:TFunction[8:15] = undefined
108
+ [7] Const mutate $20:TPrimitive = 0
109
+ scope @2 [8:15] deps=[read c$15, read b$14, read b$14] {
110
+ [8] Let mutate x$22_@2:TFunction[8:15] = undefined
111
switch (read b$14) {
112
- case read $20_@3:TPrimitive: {
113
- [9] Reassign mutate x$22_@4:TFunction[8:15] = Array []
114
- [10] Call mutate x$22_@4.push(read b$14)
112
+ case read $20:TPrimitive: {
113
+ [9] Reassign mutate x$22_@2:TFunction[8:15] = Array []
114
+ [10] Call mutate x$22_@2.push(read b$14)
115
break bb3
116
}
117
default: {
118
- [12] Reassign mutate x$22_@4:TFunction[8:15] = Array []
119
- [13] Call mutate x$22_@4.push(read c$15)
118
+ [12] Reassign mutate x$22_@2:TFunction[8:15] = Array []
119
+ [13] Call mutate x$22_@2.push(read c$15)
120
}
121
}
122
}
123
- [15] Const mutate $25_@5:TPrimitive = "div"
124
- [16] Const mutate $26_@6 = "\n "
125
- [17] Const mutate $27_@7 = "\n "
126
- [18] Const mutate $28_@8 = "\n "
127
- scope @9 [19:20] deps=[read $25_@5:TPrimitive, read $26_@6, read y$19_@2, read $27_@7, freeze x$22_@4:TFunction, read $28_@8] {
128
- [19] Const mutate $31_@9 = JSX <read $25_@5:TPrimitive>{read $26_@6}{read y$19_@2}{read $27_@7}{freeze x$22_@4:TFunction}{read $28_@8}</read $25_@5:TPrimitive>
123
+ [15] Const mutate $25:TPrimitive = "div"
124
+ [16] Const mutate $26 = "\n "
125
+ [17] Const mutate $27 = "\n "
126
+ [18] Const mutate $28 = "\n "
127
+ scope @3 [19:20] deps=[read $25:TPrimitive, read $26, read y$19_@1, read $27, freeze x$22_@2:TFunction, read $28] {
128
+ [19] Const mutate $31_@3 = JSX <read $25:TPrimitive>{read $26}{read y$19_@1}{read $27}{freeze x$22_@2:TFunction}{read $28}</read $25:TPrimitive>
129
}
130
- return read $31_@9
130
+ return read $31_@3
131
}
132
133
```
compiler/forget/src/__tests__/fixtures/hir/reverse-postorder.expect.md
+30
-30
@@ -36,48 +36,48 @@ function Component(props) {
36
37
```
38
bb0:
39
- [1] Const mutate x$7_@0:TPrimitive = undefined
40
- [2] Let mutate x$11_@1:TProp[2:18] = undefined
39
+ [1] Const mutate x$7:TPrimitive = undefined
40
+ [2] Let mutate x$11_@0:TProp[2:18] = undefined
41
[2] If (read props$6.cond) then:bb2 else:bb10 fallthrough=bb1
42
bb2:
43
predecessor blocks: bb0
44
- [3] Const mutate $8_@2:TPrimitive = 2
45
- [4] Const mutate $9_@3:TPrimitive = 1
46
- [5] Const mutate $10_@4:TPrimitive = 0
44
+ [3] Const mutate $8:TPrimitive = 2
45
+ [4] Const mutate $9:TPrimitive = 1
46
+ [5] Const mutate $10:TPrimitive = 0
47
[6] Switch (read props$6.test)
48
- Case read $10_@4:TPrimitive: bb8
49
- Case read $9_@3:TPrimitive: bb6
50
- Case read $8_@2:TPrimitive: bb4
48
+ Case read $10:TPrimitive: bb8
49
+ Case read $9:TPrimitive: bb6
50
+ Case read $8:TPrimitive: bb4
51
Default: bb4
52
Fallthrough: bb1
53
bb8:
54
predecessor blocks: bb2
55
- [7] Reassign mutate x$11_@1:TProp[2:18] = read props$6.v0
55
+ [7] Reassign mutate x$11_@0:TProp[2:18] = read props$6.v0
56
[8] Goto bb1
57
bb6:
58
predecessor blocks: bb2
59
- [9] Reassign mutate x$11_@1:TProp[2:18] = read props$6.v1
59
+ [9] Reassign mutate x$11_@0:TProp[2:18] = read props$6.v1
60
[10] Goto bb1
61
bb4:
62
predecessor blocks: bb2
63
- [11] Reassign mutate x$11_@1:TProp[2:18] = read props$6.v2
63
+ [11] Reassign mutate x$11_@0:TProp[2:18] = read props$6.v2
64
[12] Goto bb1
65
bb10:
66
predecessor blocks: bb0
67
[13] If (read props$6.cond2) then:bb12 else:bb13 fallthrough=bb1
68
bb12:
69
predecessor blocks: bb10
70
- [14] Reassign mutate x$11_@1:TProp[2:18] = read props$6.b
70
+ [14] Reassign mutate x$11_@0:TProp[2:18] = read props$6.b
71
[15] Goto bb1
72
bb13:
73
predecessor blocks: bb10
74
- [16] Reassign mutate x$11_@1:TProp[2:18] = read props$6.c
74
+ [16] Reassign mutate x$11_@0:TProp[2:18] = read props$6.c
75
[17] Goto bb1
76
bb1:
77
predecessor blocks: bb8 bb6 bb4 bb12 bb13
78
- [18] read x$11_@1:TProp
78
+ [18] read x$11_@0:TProp
79
[19] Return
80
-scope1 [2:18]:
80
+scope0 [2:18]:
81
- dependency: read props$6.v2
82
- dependency: read props$6.v1
83
- dependency: read props$6.v0
@@ -94,37 +94,37 @@ scope1 [2:18]:
94
function Component(
95
props,
96
) {
97
- [1] Const mutate x$7_@0:TPrimitive = undefined
98
- scope @1 [2:18] deps=[read props$6.v2, read props$6.v1, read props$6.v0, read props$6.test, read props$6.b, read props$6.c, read props$6.cond2, read props$6.cond] {
99
- [2] Let mutate x$11_@1:TProp[2:18] = undefined
97
+ [1] Const mutate x$7:TPrimitive = undefined
98
+ scope @0 [2:18] deps=[read props$6.v2, read props$6.v1, read props$6.v0, read props$6.test, read props$6.b, read props$6.c, read props$6.cond2, read props$6.cond] {
99
+ [2] Let mutate x$11_@0:TProp[2:18] = undefined
100
if (read props$6.cond) {
101
- [3] Const mutate $8_@2:TPrimitive = 2
102
- [4] Const mutate $9_@3:TPrimitive = 1
103
- [5] Const mutate $10_@4:TPrimitive = 0
101
+ [3] Const mutate $8:TPrimitive = 2
102
+ [4] Const mutate $9:TPrimitive = 1
103
+ [5] Const mutate $10:TPrimitive = 0
104
switch (read props$6.test) {
105
- case read $10_@4:TPrimitive: {
106
- [7] Reassign mutate x$11_@1:TProp[2:18] = read props$6.v0
105
+ case read $10:TPrimitive: {
106
+ [7] Reassign mutate x$11_@0:TProp[2:18] = read props$6.v0
107
break bb1
108
}
109
- case read $9_@3:TPrimitive: {
110
- [9] Reassign mutate x$11_@1:TProp[2:18] = read props$6.v1
109
+ case read $9:TPrimitive: {
110
+ [9] Reassign mutate x$11_@0:TProp[2:18] = read props$6.v1
111
break bb1
112
}
113
- case read $8_@2:TPrimitive: {
113
+ case read $8:TPrimitive: {
114
}
115
default: {
116
- [11] Reassign mutate x$11_@1:TProp[2:18] = read props$6.v2
116
+ [11] Reassign mutate x$11_@0:TProp[2:18] = read props$6.v2
117
}
118
}
119
} else {
120
if (read props$6.cond2) {
121
- [14] Reassign mutate x$11_@1:TProp[2:18] = read props$6.b
121
+ [14] Reassign mutate x$11_@0:TProp[2:18] = read props$6.b
122
} else {
123
- [16] Reassign mutate x$11_@1:TProp[2:18] = read props$6.c
123
+ [16] Reassign mutate x$11_@0:TProp[2:18] = read props$6.c
124
}
125
}
126
}
127
- [18] read x$11_@1:TProp
127
+ [18] read x$11_@0:TProp
128
return
129
}
130
compiler/forget/src/__tests__/fixtures/hir/simple.expect.md
+20
-23
@@ -18,24 +18,21 @@ bb0:
18
[1] If (read x$8) then:bb2 else:bb1 fallthrough=bb1
19
bb2:
20
predecessor blocks: bb0
21
- [2] Const mutate $10_@0:TPrimitive = false
22
- [3] Const mutate $11_@1 = Call read foo$0:TFunction(read $10_@0:TPrimitive, read y$9:TPrimitive)
23
- [4] Return freeze $11_@1
21
+ [2] Const mutate $10:TPrimitive = false
22
+ [3] Const mutate $11_@0 = Call read foo$0:TFunction(read $10:TPrimitive, read y$9:TPrimitive)
23
+ [4] Return freeze $11_@0
24
bb1:
25
predecessor blocks: bb0
26
- [5] Const mutate $12_@2:TPrimitive = 10
27
- [6] Const mutate $13_@3:TPrimitive = Binary read y$9:TPrimitive * read $12_@2:TPrimitive
28
- [7] Const mutate $14_@4 = Array [read $13_@3:TPrimitive]
29
- [8] Return freeze $14_@4
30
-scope1 [3:4]:
26
+ [5] Const mutate $12:TPrimitive = 10
27
+ [6] Const mutate $13:TPrimitive = Binary read y$9:TPrimitive * read $12:TPrimitive
28
+ [7] Const mutate $14_@1 = Array [read $13:TPrimitive]
29
+ [8] Return freeze $14_@1
30
+scope0 [3:4]:
31
- dependency: read foo$0:TFunction
32
- - dependency: read $10_@0:TPrimitive
32
+ - dependency: read $10:TPrimitive
33
- dependency: read y$9:TPrimitive
34
-scope3 [6:7]:
35
- - dependency: read y$9:TPrimitive
36
- - dependency: read $12_@2:TPrimitive
37
-scope4 [7:8]:
38
- - dependency: read $13_@3:TPrimitive
34
+scope1 [7:8]:
35
+ - dependency: read $13:TPrimitive
36
```
37
38
## Reactive Scopes
@@ -46,18 +43,18 @@ function foo(
43
y,
44
) {
45
if (read x$8) {
49
- [2] Const mutate $10_@0:TPrimitive = false
50
- scope @1 [3:4] deps=[read foo$0:TFunction, read $10_@0:TPrimitive, read y$9:TPrimitive] {
51
- [3] Const mutate $11_@1 = Call read foo$0:TFunction(read $10_@0:TPrimitive, read y$9:TPrimitive)
46
+ [2] Const mutate $10:TPrimitive = false
47
+ scope @0 [3:4] deps=[read foo$0:TFunction, read $10:TPrimitive, read y$9:TPrimitive] {
48
+ [3] Const mutate $11_@0 = Call read foo$0:TFunction(read $10:TPrimitive, read y$9:TPrimitive)
49
}
53
- return freeze $11_@1
50
+ return freeze $11_@0
51
}
55
- [5] Const mutate $12_@2:TPrimitive = 10
56
- [6] Const mutate $13_@3:TPrimitive = Binary read y$9:TPrimitive * read $12_@2:TPrimitive
57
- scope @4 [7:8] deps=[read $13_@3:TPrimitive] {
58
- [7] Const mutate $14_@4 = Array [read $13_@3:TPrimitive]
52
+ [5] Const mutate $12:TPrimitive = 10
53
+ [6] Const mutate $13:TPrimitive = Binary read y$9:TPrimitive * read $12:TPrimitive
54
+ scope @1 [7:8] deps=[read $13:TPrimitive] {
55
+ [7] Const mutate $14_@1 = Array [read $13:TPrimitive]
56
}
60
- return freeze $14_@4
57
+ return freeze $14_@1
58
}
59
60
```
compiler/forget/src/__tests__/fixtures/hir/ssa-arrayexpression.expect.md
+12
-12
@@ -15,13 +15,13 @@ function Component(props) {
15
16
```
17
bb0:
18
- [1] Const mutate a$6_@0:TPrimitive = 1
19
- [2] Const mutate b$7_@1:TPrimitive = 2
20
- [3] Const mutate x$8_@2 = Array [read a$6_@0:TPrimitive, read b$7_@1:TPrimitive]
21
- [4] Return freeze x$8_@2
22
-scope2 [3:4]:
23
- - dependency: read a$6_@0:TPrimitive
24
- - dependency: read b$7_@1:TPrimitive
18
+ [1] Const mutate a$6:TPrimitive = 1
19
+ [2] Const mutate b$7:TPrimitive = 2
20
+ [3] Const mutate x$8_@0 = Array [read a$6:TPrimitive, read b$7:TPrimitive]
21
+ [4] Return freeze x$8_@0
22
+scope0 [3:4]:
23
+ - dependency: read a$6:TPrimitive
24
+ - dependency: read b$7:TPrimitive
25
```
26
27
## Reactive Scopes
@@ -30,12 +30,12 @@ scope2 [3:4]:
30
function Component(
31
props,
32
) {
33
- [1] Const mutate a$6_@0:TPrimitive = 1
34
- [2] Const mutate b$7_@1:TPrimitive = 2
35
- scope @2 [3:4] deps=[read a$6_@0:TPrimitive, read b$7_@1:TPrimitive] {
36
- [3] Const mutate x$8_@2 = Array [read a$6_@0:TPrimitive, read b$7_@1:TPrimitive]
33
+ [1] Const mutate a$6:TPrimitive = 1
34
+ [2] Const mutate b$7:TPrimitive = 2
35
+ scope @0 [3:4] deps=[read a$6:TPrimitive, read b$7:TPrimitive] {
36
+ [3] Const mutate x$8_@0 = Array [read a$6:TPrimitive, read b$7:TPrimitive]
37
}
38
- return freeze x$8_@2
38
+ return freeze x$8_@0
39
}
40
41
```
compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx-2.expect.md
+16
-16
@@ -53,19 +53,19 @@ bb0:
53
[5] If (read $13_@1) then:bb2 else:bb1 fallthrough=bb1
54
bb2:
55
predecessor blocks: bb0
56
- [6] Const mutate $14_@2:TPrimitive = "div"
57
- [7] Const mutate _$15_@3 = JSX <read $14_@2:TPrimitive a={freeze a$11_@0} ></read $14_@2:TPrimitive>
56
+ [6] Const mutate $14:TPrimitive = "div"
57
+ [7] Const mutate _$15_@2 = JSX <read $14:TPrimitive a={freeze a$11_@0} ></read $14:TPrimitive>
58
[8] Goto bb1
59
bb1:
60
predecessor blocks: bb2 bb0
61
[9] Call mutate foo$4:TFunction(read a$11_@0, mutate b$12_@0:TObject)
62
- [10] Const mutate $19_@4:TPrimitive = "div"
63
- [11] Const mutate $20_@5 = JSX <read $19_@4:TPrimitive a={freeze a$11_@0} b={freeze b$12_@0:TObject} ></read $19_@4:TPrimitive>
64
- [12] Return read $20_@5
65
-scope3 [7:8]:
66
- - dependency: read $14_@2:TPrimitive
67
-scope5 [11:12]:
68
- - dependency: read $19_@4:TPrimitive
62
+ [10] Const mutate $19:TPrimitive = "div"
63
+ [11] Const mutate $20_@3 = JSX <read $19:TPrimitive a={freeze a$11_@0} b={freeze b$12_@0:TObject} ></read $19:TPrimitive>
64
+ [12] Return read $20_@3
65
+scope2 [7:8]:
66
+ - dependency: read $14:TPrimitive
67
+scope3 [11:12]:
68
+ - dependency: read $19:TPrimitive
69
- dependency: freeze a$11_@0
70
- dependency: freeze b$12_@0:TObject
71
```
@@ -84,18 +84,18 @@ function Component(
84
[4] Const mutate $13_@1 = Call mutate foo$4:TFunction()
85
}
86
if (read $13_@1) {
87
- [6] Const mutate $14_@2:TPrimitive = "div"
88
- scope @3 [7:8] deps=[read $14_@2:TPrimitive] {
89
- [7] Const mutate _$15_@3 = JSX <read $14_@2:TPrimitive a={freeze a$11_@0} ></read $14_@2:TPrimitive>
87
+ [6] Const mutate $14:TPrimitive = "div"
88
+ scope @2 [7:8] deps=[read $14:TPrimitive] {
89
+ [7] Const mutate _$15_@2 = JSX <read $14:TPrimitive a={freeze a$11_@0} ></read $14:TPrimitive>
90
}
91
}
92
[9] Call mutate foo$4:TFunction(read a$11_@0, mutate b$12_@0:TObject)
93
}
94
- [10] Const mutate $19_@4:TPrimitive = "div"
95
- scope @5 [11:12] deps=[read $19_@4:TPrimitive, freeze a$11_@0, freeze b$12_@0:TObject] {
96
- [11] Const mutate $20_@5 = JSX <read $19_@4:TPrimitive a={freeze a$11_@0} b={freeze b$12_@0:TObject} ></read $19_@4:TPrimitive>
94
+ [10] Const mutate $19:TPrimitive = "div"
95
+ scope @3 [11:12] deps=[read $19:TPrimitive, freeze a$11_@0, freeze b$12_@0:TObject] {
96
+ [11] Const mutate $20_@3 = JSX <read $19:TPrimitive a={freeze a$11_@0} b={freeze b$12_@0:TObject} ></read $19:TPrimitive>
97
}
98
- return read $20_@5
98
+ return read $20_@3
99
}
100
101
```
compiler/forget/src/__tests__/fixtures/hir/ssa-call-jsx.expect.md
+16
-16
@@ -46,16 +46,16 @@ bb0:
46
[1] Const mutate a$10_@0[1:7] = Array []
47
[2] Const mutate b$11_@0:TObject[1:7] = Object { }
48
[3] Call mutate foo$4:TFunction(mutate a$10_@0, mutate b$11_@0:TObject)
49
- [4] Const mutate $12_@1:TPrimitive = "div"
50
- [5] Const mutate _$13_@2 = JSX <read $12_@1:TPrimitive a={freeze a$10_@0} ></read $12_@1:TPrimitive>
49
+ [4] Const mutate $12:TPrimitive = "div"
50
+ [5] Const mutate _$13_@1 = JSX <read $12:TPrimitive a={freeze a$10_@0} ></read $12:TPrimitive>
51
[6] Call mutate foo$4:TFunction(read a$10_@0, mutate b$11_@0:TObject)
52
- [7] Const mutate $14_@3:TPrimitive = "div"
53
- [8] Const mutate $15_@4 = JSX <read $14_@3:TPrimitive a={read a$10_@0} b={freeze b$11_@0:TObject} ></read $14_@3:TPrimitive>
54
- [9] Return read $15_@4
55
-scope2 [5:6]:
56
- - dependency: read $12_@1:TPrimitive
57
-scope4 [8:9]:
58
- - dependency: read $14_@3:TPrimitive
52
+ [7] Const mutate $14:TPrimitive = "div"
53
+ [8] Const mutate $15_@2 = JSX <read $14:TPrimitive a={read a$10_@0} b={freeze b$11_@0:TObject} ></read $14:TPrimitive>
54
+ [9] Return read $15_@2
55
+scope1 [5:6]:
56
+ - dependency: read $12:TPrimitive
57
+scope2 [8:9]:
58
+ - dependency: read $14:TPrimitive
59
- dependency: read a$10_@0
60
- dependency: freeze b$11_@0:TObject
61
```
@@ -70,17 +70,17 @@ function Component(
70
[1] Const mutate a$10_@0[1:7] = Array []
71
[2] Const mutate b$11_@0:TObject[1:7] = Object { }
72
[3] Call mutate foo$4:TFunction(mutate a$10_@0, mutate b$11_@0:TObject)
73
- [4] Const mutate $12_@1:TPrimitive = "div"
74
- scope @2 [5:6] deps=[read $12_@1:TPrimitive] {
75
- [5] Const mutate _$13_@2 = JSX <read $12_@1:TPrimitive a={freeze a$10_@0} ></read $12_@1:TPrimitive>
73
+ [4] Const mutate $12:TPrimitive = "div"
74
+ scope @1 [5:6] deps=[read $12:TPrimitive] {
75
+ [5] Const mutate _$13_@1 = JSX <read $12:TPrimitive a={freeze a$10_@0} ></read $12:TPrimitive>
76
}
77
[6] Call mutate foo$4:TFunction(read a$10_@0, mutate b$11_@0:TObject)
78
}
79
- [7] Const mutate $14_@3:TPrimitive = "div"
80
- scope @4 [8:9] deps=[read $14_@3:TPrimitive, read a$10_@0, freeze b$11_@0:TObject] {
81
- [8] Const mutate $15_@4 = JSX <read $14_@3:TPrimitive a={read a$10_@0} b={freeze b$11_@0:TObject} ></read $14_@3:TPrimitive>
79
+ [7] Const mutate $14:TPrimitive = "div"
80
+ scope @2 [8:9] deps=[read $14:TPrimitive, read a$10_@0, freeze b$11_@0:TObject] {
81
+ [8] Const mutate $15_@2 = JSX <read $14:TPrimitive a={read a$10_@0} b={freeze b$11_@0:TObject} ></read $14:TPrimitive>
82
}
83
- return read $15_@4
83
+ return read $15_@2
84
}
85
86
```
compiler/forget/src/__tests__/fixtures/hir/ssa-complex-multiple-if.expect.md
+17
-24
@@ -22,35 +22,28 @@ function foo() {
22
```
23
bb0:
24
[1] Let mutate x$7_@0:TPrimitive[1:13] = 1
25
- [2] Const mutate y$8_@1:TPrimitive = 2
26
- [3] Const mutate $9_@2:TPrimitive = 2
27
- [4] Const mutate $10_@3:TPrimitive = Binary read y$8_@1:TPrimitive === read $9_@2:TPrimitive
28
- [5] If (read $10_@3:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
25
+ [2] Const mutate y$8:TPrimitive = 2
26
+ [3] Const mutate $9:TPrimitive = 2
27
+ [4] Const mutate $10:TPrimitive = Binary read y$8:TPrimitive === read $9:TPrimitive
28
+ [5] If (read $10:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
29
bb2:
30
predecessor blocks: bb0
31
[6] Reassign mutate x$7_@0:TPrimitive[1:13] = 3
32
[7] Goto bb1
33
bb1:
34
predecessor blocks: bb2 bb0
35
- [8] Const mutate $12_@4:TPrimitive = 3
36
- [9] Const mutate $14_@5:TPrimitive = Binary read y$8_@1:TPrimitive === read $12_@4:TPrimitive
37
- [10] If (read $14_@5:TPrimitive) then:bb4 else:bb3 fallthrough=bb3
35
+ [8] Const mutate $12:TPrimitive = 3
36
+ [9] Const mutate $14:TPrimitive = Binary read y$8:TPrimitive === read $12:TPrimitive
37
+ [10] If (read $14:TPrimitive) then:bb4 else:bb3 fallthrough=bb3
38
bb4:
39
predecessor blocks: bb1
40
[11] Reassign mutate x$7_@0:TPrimitive[1:13] = 5
41
[12] Goto bb3
42
bb3:
43
predecessor blocks: bb4 bb1
44
- [13] Const mutate y$18_@6 = read x$7_@0:TPrimitive
44
+ [13] Const mutate y$18 = read x$7_@0:TPrimitive
45
[14] Return
46
-scope3 [4:5]:
47
- - dependency: read y$8_@1:TPrimitive
48
- - dependency: read $9_@2:TPrimitive
49
-scope5 [9:10]:
50
- - dependency: read y$8_@1:TPrimitive
51
- - dependency: read $12_@4:TPrimitive
52
-scope6 [13:14]:
53
- - dependency: read x$7_@0:TPrimitive
46
+
47
```
48
49
## Reactive Scopes
@@ -60,19 +53,19 @@ function foo(
53
) {
54
scope @0 [1:13] deps=[] {
55
[1] Let mutate x$7_@0:TPrimitive[1:13] = 1
63
- [2] Const mutate y$8_@1:TPrimitive = 2
64
- [3] Const mutate $9_@2:TPrimitive = 2
65
- [4] Const mutate $10_@3:TPrimitive = Binary read y$8_@1:TPrimitive === read $9_@2:TPrimitive
66
- if (read $10_@3:TPrimitive) {
56
+ [2] Const mutate y$8:TPrimitive = 2
57
+ [3] Const mutate $9:TPrimitive = 2
58
+ [4] Const mutate $10:TPrimitive = Binary read y$8:TPrimitive === read $9:TPrimitive
59
+ if (read $10:TPrimitive) {
60
[6] Reassign mutate x$7_@0:TPrimitive[1:13] = 3
61
}
69
- [8] Const mutate $12_@4:TPrimitive = 3
70
- [9] Const mutate $14_@5:TPrimitive = Binary read y$8_@1:TPrimitive === read $12_@4:TPrimitive
71
- if (read $14_@5:TPrimitive) {
62
+ [8] Const mutate $12:TPrimitive = 3
63
+ [9] Const mutate $14:TPrimitive = Binary read y$8:TPrimitive === read $12:TPrimitive
64
+ if (read $14:TPrimitive) {
65
[11] Reassign mutate x$7_@0:TPrimitive[1:13] = 5
66
}
67
}
75
- [13] Const mutate y$18_@6 = read x$7_@0:TPrimitive
68
+ [13] Const mutate y$18 = read x$7_@0:TPrimitive
69
return
70
}
71
compiler/forget/src/__tests__/fixtures/hir/ssa-complex-single-if.expect.md
+11
-15
@@ -19,23 +19,19 @@ function foo() {
19
```
20
bb0:
21
[1] Let mutate x$5_@0:TPrimitive[1:8] = 1
22
- [2] Const mutate y$6_@1:TPrimitive = 2
23
- [3] Const mutate $7_@2:TPrimitive = 2
24
- [4] Const mutate $8_@3:TPrimitive = Binary read y$6_@1:TPrimitive === read $7_@2:TPrimitive
25
- [5] If (read $8_@3:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
22
+ [2] Const mutate y$6:TPrimitive = 2
23
+ [3] Const mutate $7:TPrimitive = 2
24
+ [4] Const mutate $8:TPrimitive = Binary read y$6:TPrimitive === read $7:TPrimitive
25
+ [5] If (read $8:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
26
bb2:
27
predecessor blocks: bb0
28
[6] Reassign mutate x$5_@0:TPrimitive[1:8] = 3
29
[7] Goto bb1
30
bb1:
31
predecessor blocks: bb2 bb0
32
- [8] Const mutate y$11_@4 = read x$5_@0:TPrimitive
32
+ [8] Const mutate y$11 = read x$5_@0:TPrimitive
33
[9] Return
34
-scope3 [4:5]:
35
- - dependency: read y$6_@1:TPrimitive
36
- - dependency: read $7_@2:TPrimitive
37
-scope4 [8:9]:
38
- - dependency: read x$5_@0:TPrimitive
34
+
35
```
36
37
## Reactive Scopes
@@ -45,14 +41,14 @@ function foo(
41
) {
42
scope @0 [1:8] deps=[] {
43
[1] Let mutate x$5_@0:TPrimitive[1:8] = 1
48
- [2] Const mutate y$6_@1:TPrimitive = 2
49
- [3] Const mutate $7_@2:TPrimitive = 2
50
- [4] Const mutate $8_@3:TPrimitive = Binary read y$6_@1:TPrimitive === read $7_@2:TPrimitive
51
- if (read $8_@3:TPrimitive) {
44
+ [2] Const mutate y$6:TPrimitive = 2
45
+ [3] Const mutate $7:TPrimitive = 2
46
+ [4] Const mutate $8:TPrimitive = Binary read y$6:TPrimitive === read $7:TPrimitive
47
+ if (read $8:TPrimitive) {
48
[6] Reassign mutate x$5_@0:TPrimitive[1:8] = 3
49
}
50
}
55
- [8] Const mutate y$11_@4 = read x$5_@0:TPrimitive
51
+ [8] Const mutate y$11 = read x$5_@0:TPrimitive
52
return
53
}
54
compiler/forget/src/__tests__/fixtures/hir/ssa-for-of.expect.md
+2
-2
@@ -26,11 +26,11 @@ bb1:
26
[3] If (read items$5_@0) then:bb3 else:bb2 fallthrough=bb2
27
bb3:
28
predecessor blocks: bb1
29
- [4] Const mutate y$7_@1:TPrimitive = 0
29
+ [4] Const mutate y$7:TPrimitive = 0
30
[5] If (read cond$4) then:bb5 else:bb4 fallthrough=bb4
31
bb5:
32
predecessor blocks: bb3
33
- [6] Const mutate y$9_@2:TPrimitive = 1
33
+ [6] Const mutate y$9:TPrimitive = 1
34
[7] Goto bb4
35
bb4:
36
predecessor blocks: bb5 bb3
compiler/forget/src/__tests__/fixtures/hir/ssa-for-trivial-update.expect.md
+23
-25
@@ -16,29 +16,29 @@ function foo() {
16
17
```
18
bb0:
19
- [1] Let mutate x$6_@1:TPrimitive[1:13] = 1
19
+ [1] Let mutate x$6_@0:TPrimitive[1:13] = 1
20
[2] For init=bb3 test=bb1 loop=bb5 update=bb4 fallthrough=bb2
21
bb3:
22
predecessor blocks: bb0
23
- [3] Const mutate i$7_@1:TPrimitive[1:13] = 0
23
+ [3] Const mutate i$7:TPrimitive = 0
24
[4] Goto bb1
25
bb1:
26
predecessor blocks: bb3 bb4
27
- [5] Const mutate $8_@1:TPrimitive[1:13] = 10
28
- [6] Const mutate $10_@3:TPrimitive[6:8] = Binary read i$7_@1:TPrimitive < read $8_@1:TPrimitive
29
- [7] If (read $10_@3:TPrimitive) then:bb5 else:bb2 fallthrough=bb2
27
+ [5] Const mutate $8:TPrimitive = 10
28
+ [6] Const mutate $10:TPrimitive = Binary read i$7:TPrimitive < read $8:TPrimitive
29
+ [7] If (read $10:TPrimitive) then:bb5 else:bb2 fallthrough=bb2
30
bb5:
31
predecessor blocks: bb1
32
- [8] Const mutate $11_@4:TPrimitive = 1
33
- [9] Reassign mutate x$6_@1:TPrimitive[1:13] = Binary read x$6_@1:TPrimitive + read $11_@4:TPrimitive
32
+ [8] Const mutate $11:TPrimitive = 1
33
+ [9] Reassign mutate x$6_@0:TPrimitive[1:13] = Binary read x$6_@0:TPrimitive + read $11:TPrimitive
34
[10] Goto(Continue) bb4
35
bb4:
36
predecessor blocks: bb5
37
- [11] read i$7_@1:TPrimitive
37
+ [11] read i$7:TPrimitive
38
[12] Goto bb1
39
bb2:
40
predecessor blocks: bb1
41
- [13] Return read x$6_@1:TPrimitive
41
+ [13] Return read x$6_@0:TPrimitive
42
43
```
44
@@ -47,24 +47,22 @@ bb2:
47
```
48
function foo(
49
) {
50
- scope @1 [1:13] deps=[] {
51
- [1] Let mutate x$6_@1:TPrimitive[1:13] = 1
52
- scope @3 [6:8] deps=[] {
53
- for (
54
- [3] Const mutate i$7_@1:TPrimitive[1:13] = 0
55
- ;
56
- [5] Const mutate $8_@1:TPrimitive[1:13] = 10
57
- [6] Const mutate $10_@3:TPrimitive[6:8] = Binary read i$7_@1:TPrimitive < read $8_@1:TPrimitive
58
- read $10_@3:TPrimitive
59
- ;
60
- read i$7_@1:TPrimitive
61
- ) {
62
- [8] Const mutate $11_@4:TPrimitive = 1
63
- [9] Reassign mutate x$6_@1:TPrimitive[1:13] = Binary read x$6_@1:TPrimitive + read $11_@4:TPrimitive
64
- }
50
+ scope @0 [1:13] deps=[] {
51
+ [1] Let mutate x$6_@0:TPrimitive[1:13] = 1
52
+ for (
53
+ [3] Const mutate i$7:TPrimitive = 0
54
+ ;
55
+ [5] Const mutate $8:TPrimitive = 10
56
+ [6] Const mutate $10:TPrimitive = Binary read i$7:TPrimitive < read $8:TPrimitive
57
+ read $10:TPrimitive
58
+ ;
59
+ read i$7:TPrimitive
60
+ ) {
61
+ [8] Const mutate $11:TPrimitive = 1
62
+ [9] Reassign mutate x$6_@0:TPrimitive[1:13] = Binary read x$6_@0:TPrimitive + read $11:TPrimitive
63
}
64
}
67
- return read x$6_@1:TPrimitive
65
+ return read x$6_@0:TPrimitive
66
}
67
68
```
compiler/forget/src/__tests__/fixtures/hir/ssa-for.expect.md
+14
-14
@@ -24,18 +24,18 @@ bb3:
24
[4] Goto bb1
25
bb1:
26
predecessor blocks: bb3 bb4
27
- [5] Const mutate $9_@1:TPrimitive[1:15] = 10
28
- [6] Const mutate $11_@1:TPrimitive[1:15] = Binary read i$8_@1:TPrimitive < read $9_@1:TPrimitive
29
- [7] If (read $11_@1:TPrimitive) then:bb5 else:bb2 fallthrough=bb2
27
+ [5] Const mutate $9:TPrimitive = 10
28
+ [6] Const mutate $11:TPrimitive = Binary read i$8_@1:TPrimitive < read $9:TPrimitive
29
+ [7] If (read $11:TPrimitive) then:bb5 else:bb2 fallthrough=bb2
30
bb5:
31
predecessor blocks: bb1
32
- [8] Const mutate $12_@3:TPrimitive = 1
33
- [9] Reassign mutate x$7_@1:TPrimitive[1:15] = Binary read x$7_@1:TPrimitive + read $12_@3:TPrimitive
32
+ [8] Const mutate $12:TPrimitive = 1
33
+ [9] Reassign mutate x$7_@1:TPrimitive[1:15] = Binary read x$7_@1:TPrimitive + read $12:TPrimitive
34
[10] Goto(Continue) bb4
35
bb4:
36
predecessor blocks: bb5
37
- [11] Const mutate $15_@1:TPrimitive[1:15] = 1
38
- [12] Reassign mutate i$8_@1:TPrimitive[1:15] = Binary read i$8_@1:TPrimitive + read $15_@1:TPrimitive
37
+ [11] Const mutate $15:TPrimitive = 1
38
+ [12] Reassign mutate i$8_@1:TPrimitive[1:15] = Binary read i$8_@1:TPrimitive + read $15:TPrimitive
39
[13] read i$8_@1:TPrimitive
40
[14] Goto bb1
41
bb2:
@@ -54,16 +54,16 @@ function foo(
54
for (
55
[3] Let mutate i$8_@1:TPrimitive[1:15] = 0
56
;
57
- [5] Const mutate $9_@1:TPrimitive[1:15] = 10
58
- [6] Const mutate $11_@1:TPrimitive[1:15] = Binary read i$8_@1:TPrimitive < read $9_@1:TPrimitive
59
- read $11_@1:TPrimitive
57
+ [5] Const mutate $9:TPrimitive = 10
58
+ [6] Const mutate $11:TPrimitive = Binary read i$8_@1:TPrimitive < read $9:TPrimitive
59
+ read $11:TPrimitive
60
;
61
- [11] Const mutate $15_@1:TPrimitive[1:15] = 1
62
- [12] Reassign mutate i$8_@1:TPrimitive[1:15] = Binary read i$8_@1:TPrimitive + read $15_@1:TPrimitive
61
+ [11] Const mutate $15:TPrimitive = 1
62
+ [12] Reassign mutate i$8_@1:TPrimitive[1:15] = Binary read i$8_@1:TPrimitive + read $15:TPrimitive
63
read i$8_@1:TPrimitive
64
) {
65
- [8] Const mutate $12_@3:TPrimitive = 1
66
- [9] Reassign mutate x$7_@1:TPrimitive[1:15] = Binary read x$7_@1:TPrimitive + read $12_@3:TPrimitive
65
+ [8] Const mutate $12:TPrimitive = 1
66
+ [9] Reassign mutate x$7_@1:TPrimitive[1:15] = Binary read x$7_@1:TPrimitive + read $12:TPrimitive
67
}
68
}
69
return read x$7_@1:TPrimitive
compiler/forget/src/__tests__/fixtures/hir/ssa-if-else.expect.md
+11
-15
@@ -19,25 +19,21 @@ function foo() {
19
20
```
21
bb0:
22
- [1] Const mutate x$5_@0:TPrimitive = 1
23
- [2] Const mutate y$6_@1:TPrimitive = 2
24
- [3] If (read y$6_@1:TPrimitive) then:bb2 else:bb3 fallthrough=bb1
22
+ [1] Const mutate x$5:TPrimitive = 1
23
+ [2] Const mutate y$6:TPrimitive = 2
24
+ [3] If (read y$6:TPrimitive) then:bb2 else:bb3 fallthrough=bb1
25
bb2:
26
predecessor blocks: bb0
27
- [4] Const mutate z$7_@2:TPrimitive = Binary read x$5_@0:TPrimitive + read y$6_@1:TPrimitive
27
+ [4] Const mutate z$7:TPrimitive = Binary read x$5:TPrimitive + read y$6:TPrimitive
28
[5] Goto bb1
29
bb3:
30
predecessor blocks: bb0
31
- [6] Const mutate z$8_@3:TPrimitive = read x$5_@0:TPrimitive
31
+ [6] Const mutate z$8:TPrimitive = read x$5:TPrimitive
32
[7] Goto bb1
33
bb1:
34
predecessor blocks: bb2 bb3
35
[8] Return
36
-scope2 [4:5]:
37
- - dependency: read x$5_@0:TPrimitive
38
- - dependency: read y$6_@1:TPrimitive
39
-scope3 [6:7]:
40
- - dependency: read x$5_@0:TPrimitive
36
+
37
```
38
39
## Reactive Scopes
@@ -45,12 +41,12 @@ scope3 [6:7]:
41
```
42
function foo(
43
) {
48
- [1] Const mutate x$5_@0:TPrimitive = 1
49
- [2] Const mutate y$6_@1:TPrimitive = 2
50
- if (read y$6_@1:TPrimitive) {
51
- [4] Const mutate z$7_@2:TPrimitive = Binary read x$5_@0:TPrimitive + read y$6_@1:TPrimitive
44
+ [1] Const mutate x$5:TPrimitive = 1
45
+ [2] Const mutate y$6:TPrimitive = 2
46
+ if (read y$6:TPrimitive) {
47
+ [4] Const mutate z$7:TPrimitive = Binary read x$5:TPrimitive + read y$6:TPrimitive
48
} else {
53
- [6] Const mutate z$8_@3:TPrimitive = read x$5_@0:TPrimitive
49
+ [6] Const mutate z$8:TPrimitive = read x$5:TPrimitive
50
}
51
return
52
}
compiler/forget/src/__tests__/fixtures/hir/ssa-multiple-phis.expect.md
+33
-33
@@ -28,52 +28,52 @@ function foo(a, b, c, d) {
28
29
```
30
bb0:
31
- [1] Const mutate x$13_@0:TPrimitive = 0
32
- [2] Const mutate $14_@1:TPrimitive = true
33
- [3] Let mutate x$18_@2[3:20] = undefined
34
- [3] If (read $14_@1:TPrimitive) then:bb2 else:bb6 fallthrough=bb1
31
+ [1] Const mutate x$13:TPrimitive = 0
32
+ [2] Const mutate $14:TPrimitive = true
33
+ [3] Let mutate x$18_@0[3:20] = undefined
34
+ [3] If (read $14:TPrimitive) then:bb2 else:bb6 fallthrough=bb1
35
bb2:
36
predecessor blocks: bb0
37
- [4] Const mutate $15_@3:TPrimitive = true
38
- [5] If (read $15_@3:TPrimitive) then:bb4 else:bb5 fallthrough=bb3
37
+ [4] Const mutate $15:TPrimitive = true
38
+ [5] If (read $15:TPrimitive) then:bb4 else:bb5 fallthrough=bb3
39
bb4:
40
predecessor blocks: bb2
41
- [6] Reassign mutate x$18_@2[3:20] = read a$9
41
+ [6] Reassign mutate x$18_@0[3:20] = read a$9
42
[7] Goto bb3
43
bb5:
44
predecessor blocks: bb2
45
- [8] Reassign mutate x$18_@2[3:20] = read b$10
45
+ [8] Reassign mutate x$18_@0[3:20] = read b$10
46
[9] Goto bb3
47
bb3:
48
predecessor blocks: bb4 bb5
49
- [10] read x$18_@2
49
+ [10] read x$18_@0
50
[11] Goto bb1
51
bb6:
52
predecessor blocks: bb0
53
- [12] Const mutate $19_@4:TPrimitive = true
54
- [13] If (read $19_@4:TPrimitive) then:bb8 else:bb9 fallthrough=bb7
53
+ [12] Const mutate $19:TPrimitive = true
54
+ [13] If (read $19:TPrimitive) then:bb8 else:bb9 fallthrough=bb7
55
bb8:
56
predecessor blocks: bb6
57
- [14] Reassign mutate x$18_@2[3:20] = read c$11
57
+ [14] Reassign mutate x$18_@0[3:20] = read c$11
58
[15] Goto bb7
59
bb9:
60
predecessor blocks: bb6
61
- [16] Reassign mutate x$18_@2[3:20] = read d$12
61
+ [16] Reassign mutate x$18_@0[3:20] = read d$12
62
[17] Goto bb7
63
bb7:
64
predecessor blocks: bb8 bb9
65
- [18] read x$18_@2
65
+ [18] read x$18_@0
66
[19] Goto bb1
67
bb1:
68
predecessor blocks: bb3 bb7
69
- [20] read x$18_@2
69
+ [20] read x$18_@0
70
[21] Return
71
-scope2 [3:20]:
71
+scope0 [3:20]:
72
- dependency: read a$9
73
- dependency: read b$10
74
- dependency: read c$11
75
- dependency: read d$12
76
- - dependency: read $14_@1:TPrimitive
76
+ - dependency: read $14:TPrimitive
77
```
78
79
## Reactive Scopes
@@ -85,29 +85,29 @@ function foo(
85
c,
86
d,
87
) {
88
- [1] Const mutate x$13_@0:TPrimitive = 0
89
- [2] Const mutate $14_@1:TPrimitive = true
90
- scope @2 [3:20] deps=[read a$9, read b$10, read c$11, read d$12, read $14_@1:TPrimitive] {
91
- [3] Let mutate x$18_@2[3:20] = undefined
92
- if (read $14_@1:TPrimitive) {
93
- [4] Const mutate $15_@3:TPrimitive = true
94
- if (read $15_@3:TPrimitive) {
95
- [6] Reassign mutate x$18_@2[3:20] = read a$9
88
+ [1] Const mutate x$13:TPrimitive = 0
89
+ [2] Const mutate $14:TPrimitive = true
90
+ scope @0 [3:20] deps=[read a$9, read b$10, read c$11, read d$12, read $14:TPrimitive] {
91
+ [3] Let mutate x$18_@0[3:20] = undefined
92
+ if (read $14:TPrimitive) {
93
+ [4] Const mutate $15:TPrimitive = true
94
+ if (read $15:TPrimitive) {
95
+ [6] Reassign mutate x$18_@0[3:20] = read a$9
96
} else {
97
- [8] Reassign mutate x$18_@2[3:20] = read b$10
97
+ [8] Reassign mutate x$18_@0[3:20] = read b$10
98
}
99
- [10] read x$18_@2
99
+ [10] read x$18_@0
100
} else {
101
- [12] Const mutate $19_@4:TPrimitive = true
102
- if (read $19_@4:TPrimitive) {
103
- [14] Reassign mutate x$18_@2[3:20] = read c$11
101
+ [12] Const mutate $19:TPrimitive = true
102
+ if (read $19:TPrimitive) {
103
+ [14] Reassign mutate x$18_@0[3:20] = read c$11
104
} else {
105
- [16] Reassign mutate x$18_@2[3:20] = read d$12
105
+ [16] Reassign mutate x$18_@0[3:20] = read d$12
106
}
107
- [18] read x$18_@2
107
+ [18] read x$18_@0
108
}
109
}
110
- [20] read x$18_@2
110
+ [20] read x$18_@0
111
return
112
}
113
compiler/forget/src/__tests__/fixtures/hir/ssa-nested-loops-no-reassign.expect.md
+9
-10
@@ -21,7 +21,7 @@ function foo(a, b, c) {
21
22
```
23
bb0:
24
- [1] Const mutate x$9_@0:TPrimitive = 0
24
+ [1] Const mutate x$9:TPrimitive = 0
25
[2] While test=bb1 loop=bb3 fallthrough=bb2
26
bb1:
27
predecessor blocks: bb0 bb5
@@ -40,8 +40,8 @@ bb7:
40
[7] If (read c$8) then:bb9 else:bb8 fallthrough=bb8
41
bb9:
42
predecessor blocks: bb7
43
- [8] Const mutate $13_@1:TPrimitive = 1
44
- [9] Binary read x$9_@0:TPrimitive + read $13_@1:TPrimitive
43
+ [8] Const mutate $13:TPrimitive = 1
44
+ [9] Binary read x$9:TPrimitive + read $13:TPrimitive
45
[10] Goto(Continue) bb7
46
bb8:
47
predecessor blocks: bb7
@@ -51,9 +51,8 @@ bb5:
51
[12] Goto(Continue) bb1
52
bb2:
53
predecessor blocks: bb1
54
- [13] Return read x$9_@0:TPrimitive
55
-scope1 [8:9]:
56
- - dependency: read x$9_@0:TPrimitive
54
+ [13] Return read x$9:TPrimitive
55
+
56
```
57
58
## Reactive Scopes
@@ -64,7 +63,7 @@ function foo(
63
b,
64
c,
65
) {
67
- [1] Const mutate x$9_@0:TPrimitive = 0
66
+ [1] Const mutate x$9:TPrimitive = 0
67
while (
68
read a$6
69
) {
@@ -74,12 +73,12 @@ function foo(
73
while (
74
read c$8
75
) {
77
- [8] Const mutate $13_@1:TPrimitive = 1
78
- [9] Binary read x$9_@0:TPrimitive + read $13_@1:TPrimitive
76
+ [8] Const mutate $13:TPrimitive = 1
77
+ [9] Binary read x$9:TPrimitive + read $13:TPrimitive
78
}
79
}
80
}
82
- return read x$9_@0:TPrimitive
81
+ return read x$9:TPrimitive
82
}
83
84
```
compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression-phi.expect.md
+12
-12
@@ -24,9 +24,9 @@ function foo() {
24
bb0:
25
[1] Let mutate x$6_@0:TPrimitive[1:10] = 1
26
[2] Let mutate y$7_@0:TPrimitive[1:10] = 2
27
- [3] Const mutate $8_@2:TPrimitive = 1
28
- [4] Const mutate $9_@0:TPrimitive[1:10] = Binary read x$6_@0:TPrimitive > read $8_@2:TPrimitive
29
- [5] If (read $9_@0:TPrimitive) then:bb2 else:bb3 fallthrough=bb1
27
+ [3] Const mutate $8:TPrimitive = 1
28
+ [4] Const mutate $9:TPrimitive = Binary read x$6_@0:TPrimitive > read $8:TPrimitive
29
+ [5] If (read $9:TPrimitive) then:bb2 else:bb3 fallthrough=bb1
30
bb2:
31
predecessor blocks: bb0
32
[6] Reassign mutate x$6_@0:TPrimitive[1:10] = 2
@@ -37,9 +37,9 @@ bb3:
37
[9] Goto bb1
38
bb1:
39
predecessor blocks: bb2 bb3
40
- [10] Const mutate t$14_@3:TObject = Object { x: read x$6_@0:TPrimitive, y: read y$7_@0:TPrimitive }
41
- [11] Return freeze t$14_@3:TObject
42
-scope3 [10:11]:
40
+ [10] Const mutate t$14_@2:TObject = Object { x: read x$6_@0:TPrimitive, y: read y$7_@0:TPrimitive }
41
+ [11] Return freeze t$14_@2:TObject
42
+scope2 [10:11]:
43
- dependency: read x$6_@0:TPrimitive
44
- dependency: read y$7_@0:TPrimitive
45
```
@@ -52,18 +52,18 @@ function foo(
52
scope @0 [1:10] deps=[] {
53
[1] Let mutate x$6_@0:TPrimitive[1:10] = 1
54
[2] Let mutate y$7_@0:TPrimitive[1:10] = 2
55
- [3] Const mutate $8_@2:TPrimitive = 1
56
- [4] Const mutate $9_@0:TPrimitive[1:10] = Binary read x$6_@0:TPrimitive > read $8_@2:TPrimitive
57
- if (read $9_@0:TPrimitive) {
55
+ [3] Const mutate $8:TPrimitive = 1
56
+ [4] Const mutate $9:TPrimitive = Binary read x$6_@0:TPrimitive > read $8:TPrimitive
57
+ if (read $9:TPrimitive) {
58
[6] Reassign mutate x$6_@0:TPrimitive[1:10] = 2
59
} else {
60
[8] Reassign mutate y$7_@0:TPrimitive[1:10] = 3
61
}
62
}
63
- scope @3 [10:11] deps=[read x$6_@0:TPrimitive, read y$7_@0:TPrimitive] {
64
- [10] Const mutate t$14_@3:TObject = Object { x: read x$6_@0:TPrimitive, y: read y$7_@0:TPrimitive }
63
+ scope @2 [10:11] deps=[read x$6_@0:TPrimitive, read y$7_@0:TPrimitive] {
64
+ [10] Const mutate t$14_@2:TObject = Object { x: read x$6_@0:TPrimitive, y: read y$7_@0:TPrimitive }
65
}
66
- return freeze t$14_@3:TObject
66
+ return freeze t$14_@2:TObject
67
}
68
69
```
compiler/forget/src/__tests__/fixtures/hir/ssa-objectexpression.expect.md
+12
-12
@@ -15,13 +15,13 @@ function Component(props) {
15
16
```
17
bb0:
18
- [1] Const mutate a$6_@0:TPrimitive = 1
19
- [2] Const mutate b$7_@1:TPrimitive = 2
20
- [3] Const mutate x$8_@2:TObject = Object { a: read a$6_@0:TPrimitive, b: read b$7_@1:TPrimitive }
21
- [4] Return freeze x$8_@2:TObject
22
-scope2 [3:4]:
23
- - dependency: read a$6_@0:TPrimitive
24
- - dependency: read b$7_@1:TPrimitive
18
+ [1] Const mutate a$6:TPrimitive = 1
19
+ [2] Const mutate b$7:TPrimitive = 2
20
+ [3] Const mutate x$8_@0:TObject = Object { a: read a$6:TPrimitive, b: read b$7:TPrimitive }
21
+ [4] Return freeze x$8_@0:TObject
22
+scope0 [3:4]:
23
+ - dependency: read a$6:TPrimitive
24
+ - dependency: read b$7:TPrimitive
25
```
26
27
## Reactive Scopes
@@ -30,12 +30,12 @@ scope2 [3:4]:
30
function Component(
31
props,
32
) {
33
- [1] Const mutate a$6_@0:TPrimitive = 1
34
- [2] Const mutate b$7_@1:TPrimitive = 2
35
- scope @2 [3:4] deps=[read a$6_@0:TPrimitive, read b$7_@1:TPrimitive] {
36
- [3] Const mutate x$8_@2:TObject = Object { a: read a$6_@0:TPrimitive, b: read b$7_@1:TPrimitive }
33
+ [1] Const mutate a$6:TPrimitive = 1
34
+ [2] Const mutate b$7:TPrimitive = 2
35
+ scope @0 [3:4] deps=[read a$6:TPrimitive, read b$7:TPrimitive] {
36
+ [3] Const mutate x$8_@0:TObject = Object { a: read a$6:TPrimitive, b: read b$7:TPrimitive }
37
}
38
- return freeze x$8_@2:TObject
38
+ return freeze x$8_@0:TObject
39
}
40
41
```
compiler/forget/src/__tests__/fixtures/hir/ssa-reassign.expect.md
+11
-16
@@ -16,17 +16,12 @@ function foo(a, b, c) {
16
17
```
18
bb0:
19
- [1] Const mutate x$8_@0:TPrimitive = 0
20
- [2] Const mutate x$9_@1 = read a$5
21
- [3] Const mutate x$10_@2 = read b$6
22
- [4] Const mutate x$11_@3 = read c$7
23
- [5] Return read x$11_@3
24
-scope1 [2:3]:
25
- - dependency: read a$5
26
-scope2 [3:4]:
27
- - dependency: read b$6
28
-scope3 [4:5]:
29
- - dependency: read c$7
19
+ [1] Const mutate x$8:TPrimitive = 0
20
+ [2] Const mutate x$9 = read a$5
21
+ [3] Const mutate x$10 = read b$6
22
+ [4] Const mutate x$11 = read c$7
23
+ [5] Return read x$11
24
+
25
```
26
27
## Reactive Scopes
@@ -37,11 +32,11 @@ function foo(
32
b,
33
c,
34
) {
40
- [1] Const mutate x$8_@0:TPrimitive = 0
41
- [2] Const mutate x$9_@1 = read a$5
42
- [3] Const mutate x$10_@2 = read b$6
43
- [4] Const mutate x$11_@3 = read c$7
44
- return read x$11_@3
35
+ [1] Const mutate x$8:TPrimitive = 0
36
+ [2] Const mutate x$9 = read a$5
37
+ [3] Const mutate x$10 = read b$6
38
+ [4] Const mutate x$11 = read c$7
39
+ return read x$11
40
}
41
42
```
compiler/forget/src/__tests__/fixtures/hir/ssa-return.expect.md
+6
-6
@@ -18,9 +18,9 @@ function foo() {
18
```
19
bb0:
20
[1] Let mutate x$4_@0:TPrimitive[1:7] = 1
21
- [2] Const mutate $5_@1:TPrimitive = 1
22
- [3] Const mutate $6_@0:TPrimitive[1:7] = Binary read x$4_@0:TPrimitive === read $5_@1:TPrimitive
23
- [4] If (read $6_@0:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
21
+ [2] Const mutate $5:TPrimitive = 1
22
+ [3] Const mutate $6:TPrimitive = Binary read x$4_@0:TPrimitive === read $5:TPrimitive
23
+ [4] If (read $6:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
24
bb2:
25
predecessor blocks: bb0
26
[5] Reassign mutate x$4_@0:TPrimitive[1:7] = 2
@@ -38,9 +38,9 @@ function foo(
38
) {
39
scope @0 [1:7] deps=[] {
40
[1] Let mutate x$4_@0:TPrimitive[1:7] = 1
41
- [2] Const mutate $5_@1:TPrimitive = 1
42
- [3] Const mutate $6_@0:TPrimitive[1:7] = Binary read x$4_@0:TPrimitive === read $5_@1:TPrimitive
43
- if (read $6_@0:TPrimitive) {
41
+ [2] Const mutate $5:TPrimitive = 1
42
+ [3] Const mutate $6:TPrimitive = Binary read x$4_@0:TPrimitive === read $5:TPrimitive
43
+ if (read $6:TPrimitive) {
44
[5] Reassign mutate x$4_@0:TPrimitive[1:7] = 2
45
}
46
}
compiler/forget/src/__tests__/fixtures/hir/ssa-shadowing.expect.md
+4
-4
@@ -49,8 +49,8 @@ bb0:
49
[2] If (read cond$5) then:bb2 else:bb3 fallthrough=bb1
50
bb2:
51
predecessor blocks: bb0
52
- [3] Const mutate str$7_@1:TPrimitive = "other test"
53
- [4] Call mutate log$4:TFunction(read str$7_@1:TPrimitive)
52
+ [3] Const mutate str$7:TPrimitive = "other test"
53
+ [4] Call mutate log$4:TFunction(read str$7:TPrimitive)
54
[5] Goto bb1
55
bb3:
56
predecessor blocks: bb0
@@ -73,8 +73,8 @@ function Foo(
73
scope @0 [1:8] deps=[read cond$5] {
74
[1] Let mutate str$6_@0:TPrimitive[1:8] = ""
75
if (read cond$5) {
76
- [3] Const mutate str$7_@1:TPrimitive = "other test"
77
- [4] Call mutate log$4:TFunction(read str$7_@1:TPrimitive)
76
+ [3] Const mutate str$7:TPrimitive = "other test"
77
+ [4] Call mutate log$4:TFunction(read str$7:TPrimitive)
78
} else {
79
[6] Reassign mutate str$6_@0:TPrimitive[1:8] = "fallthrough test"
80
}
compiler/forget/src/__tests__/fixtures/hir/ssa-sibling-phis.expect.md
+36
-36
@@ -28,54 +28,54 @@ function foo(a, b, c, d) {
28
29
```
30
bb0:
31
- [1] Const mutate x$13_@0:TPrimitive = 0
32
- [2] Const mutate $14_@1:TPrimitive = true
33
- [3] If (read $14_@1:TPrimitive) then:bb2 else:bb6 fallthrough=bb1
31
+ [1] Const mutate x$13:TPrimitive = 0
32
+ [2] Const mutate $14:TPrimitive = true
33
+ [3] If (read $14:TPrimitive) then:bb2 else:bb6 fallthrough=bb1
34
bb2:
35
predecessor blocks: bb0
36
- [4] Const mutate $15_@2:TPrimitive = true
37
- [5] Let mutate x$16_@3[5:10] = undefined
38
- [5] If (read $15_@2:TPrimitive) then:bb4 else:bb5 fallthrough=bb3
36
+ [4] Const mutate $15:TPrimitive = true
37
+ [5] Let mutate x$16_@0[5:10] = undefined
38
+ [5] If (read $15:TPrimitive) then:bb4 else:bb5 fallthrough=bb3
39
bb4:
40
predecessor blocks: bb2
41
- [6] Reassign mutate x$16_@3[5:10] = read a$9
41
+ [6] Reassign mutate x$16_@0[5:10] = read a$9
42
[7] Goto bb3
43
bb5:
44
predecessor blocks: bb2
45
- [8] Reassign mutate x$16_@3[5:10] = read b$10
45
+ [8] Reassign mutate x$16_@0[5:10] = read b$10
46
[9] Goto bb3
47
bb3:
48
predecessor blocks: bb4 bb5
49
- [10] read x$16_@3
49
+ [10] read x$16_@0
50
[11] Goto bb1
51
bb6:
52
predecessor blocks: bb0
53
- [12] Const mutate $19_@4:TPrimitive = true
54
- [13] Let mutate x$20_@5[13:18] = undefined
55
- [13] If (read $19_@4:TPrimitive) then:bb8 else:bb9 fallthrough=bb7
53
+ [12] Const mutate $19:TPrimitive = true
54
+ [13] Let mutate x$20_@1[13:18] = undefined
55
+ [13] If (read $19:TPrimitive) then:bb8 else:bb9 fallthrough=bb7
56
bb8:
57
predecessor blocks: bb6
58
- [14] Reassign mutate x$20_@5[13:18] = read c$11
58
+ [14] Reassign mutate x$20_@1[13:18] = read c$11
59
[15] Goto bb7
60
bb9:
61
predecessor blocks: bb6
62
- [16] Reassign mutate x$20_@5[13:18] = read d$12
62
+ [16] Reassign mutate x$20_@1[13:18] = read d$12
63
[17] Goto bb7
64
bb7:
65
predecessor blocks: bb8 bb9
66
- [18] read x$20_@5
66
+ [18] read x$20_@1
67
[19] Goto bb1
68
bb1:
69
predecessor blocks: bb3 bb7
70
[20] Return
71
-scope3 [5:10]:
71
+scope0 [5:10]:
72
- dependency: read a$9
73
- dependency: read b$10
74
- - dependency: read $15_@2:TPrimitive
75
-scope5 [13:18]:
74
+ - dependency: read $15:TPrimitive
75
+scope1 [13:18]:
76
- dependency: read c$11
77
- dependency: read d$12
78
- - dependency: read $19_@4:TPrimitive
78
+ - dependency: read $19:TPrimitive
79
```
80
81
## Reactive Scopes
@@ -87,30 +87,30 @@ function foo(
87
c,
88
d,
89
) {
90
- [1] Const mutate x$13_@0:TPrimitive = 0
91
- [2] Const mutate $14_@1:TPrimitive = true
92
- if (read $14_@1:TPrimitive) {
93
- [4] Const mutate $15_@2:TPrimitive = true
94
- scope @3 [5:10] deps=[read a$9, read b$10, read $15_@2:TPrimitive] {
95
- [5] Let mutate x$16_@3[5:10] = undefined
96
- if (read $15_@2:TPrimitive) {
97
- [6] Reassign mutate x$16_@3[5:10] = read a$9
90
+ [1] Const mutate x$13:TPrimitive = 0
91
+ [2] Const mutate $14:TPrimitive = true
92
+ if (read $14:TPrimitive) {
93
+ [4] Const mutate $15:TPrimitive = true
94
+ scope @0 [5:10] deps=[read a$9, read b$10, read $15:TPrimitive] {
95
+ [5] Let mutate x$16_@0[5:10] = undefined
96
+ if (read $15:TPrimitive) {
97
+ [6] Reassign mutate x$16_@0[5:10] = read a$9
98
} else {
99
- [8] Reassign mutate x$16_@3[5:10] = read b$10
99
+ [8] Reassign mutate x$16_@0[5:10] = read b$10
100
}
101
}
102
- [10] read x$16_@3
102
+ [10] read x$16_@0
103
} else {
104
- [12] Const mutate $19_@4:TPrimitive = true
105
- scope @5 [13:18] deps=[read c$11, read d$12, read $19_@4:TPrimitive] {
106
- [13] Let mutate x$20_@5[13:18] = undefined
107
- if (read $19_@4:TPrimitive) {
108
- [14] Reassign mutate x$20_@5[13:18] = read c$11
104
+ [12] Const mutate $19:TPrimitive = true
105
+ scope @1 [13:18] deps=[read c$11, read d$12, read $19:TPrimitive] {
106
+ [13] Let mutate x$20_@1[13:18] = undefined
107
+ if (read $19:TPrimitive) {
108
+ [14] Reassign mutate x$20_@1[13:18] = read c$11
109
} else {
110
- [16] Reassign mutate x$20_@5[13:18] = read d$12
110
+ [16] Reassign mutate x$20_@1[13:18] = read d$12
111
}
112
}
113
- [18] read x$20_@5
113
+ [18] read x$20_@1
114
}
115
return
116
}
compiler/forget/src/__tests__/fixtures/hir/ssa-simple-phi.expect.md
+19
-24
@@ -20,30 +20,25 @@ function foo() {
20
21
```
22
bb0:
23
- [1] Const mutate y$5_@0:TPrimitive = 2
24
- [2] Const mutate $6_@1:TPrimitive = 1
25
- [3] Const mutate $7_@2:TPrimitive = Binary read y$5_@0:TPrimitive > read $6_@1:TPrimitive
26
- [4] Let mutate y$8_@3:TPrimitive[4:9] = undefined
27
- [4] If (read $7_@2:TPrimitive) then:bb2 else:bb3 fallthrough=bb1
23
+ [1] Const mutate y$5:TPrimitive = 2
24
+ [2] Const mutate $6:TPrimitive = 1
25
+ [3] Const mutate $7:TPrimitive = Binary read y$5:TPrimitive > read $6:TPrimitive
26
+ [4] Let mutate y$8_@0:TPrimitive[4:9] = undefined
27
+ [4] If (read $7:TPrimitive) then:bb2 else:bb3 fallthrough=bb1
28
bb2:
29
predecessor blocks: bb0
30
- [5] Reassign mutate y$8_@3:TPrimitive[4:9] = 1
30
+ [5] Reassign mutate y$8_@0:TPrimitive[4:9] = 1
31
[6] Goto bb1
32
bb3:
33
predecessor blocks: bb0
34
- [7] Reassign mutate y$8_@3:TPrimitive[4:9] = 2
34
+ [7] Reassign mutate y$8_@0:TPrimitive[4:9] = 2
35
[8] Goto bb1
36
bb1:
37
predecessor blocks: bb2 bb3
38
- [9] Const mutate x$11_@4 = read y$8_@3:TPrimitive
38
+ [9] Const mutate x$11 = read y$8_@0:TPrimitive
39
[10] Return
40
-scope2 [3:4]:
41
- - dependency: read y$5_@0:TPrimitive
42
- - dependency: read $6_@1:TPrimitive
43
-scope3 [4:9]:
44
- - dependency: read $7_@2:TPrimitive
45
-scope4 [9:10]:
46
- - dependency: read y$8_@3:TPrimitive
40
+scope0 [4:9]:
41
+ - dependency: read $7:TPrimitive
42
```
43
44
## Reactive Scopes
@@ -51,18 +46,18 @@ scope4 [9:10]:
46
```
47
function foo(
48
) {
54
- [1] Const mutate y$5_@0:TPrimitive = 2
55
- [2] Const mutate $6_@1:TPrimitive = 1
56
- [3] Const mutate $7_@2:TPrimitive = Binary read y$5_@0:TPrimitive > read $6_@1:TPrimitive
57
- scope @3 [4:9] deps=[read $7_@2:TPrimitive] {
58
- [4] Let mutate y$8_@3:TPrimitive[4:9] = undefined
59
- if (read $7_@2:TPrimitive) {
60
- [5] Reassign mutate y$8_@3:TPrimitive[4:9] = 1
49
+ [1] Const mutate y$5:TPrimitive = 2
50
+ [2] Const mutate $6:TPrimitive = 1
51
+ [3] Const mutate $7:TPrimitive = Binary read y$5:TPrimitive > read $6:TPrimitive
52
+ scope @0 [4:9] deps=[read $7:TPrimitive] {
53
+ [4] Let mutate y$8_@0:TPrimitive[4:9] = undefined
54
+ if (read $7:TPrimitive) {
55
+ [5] Reassign mutate y$8_@0:TPrimitive[4:9] = 1
56
} else {
62
- [7] Reassign mutate y$8_@3:TPrimitive[4:9] = 2
57
+ [7] Reassign mutate y$8_@0:TPrimitive[4:9] = 2
58
}
59
}
65
- [9] Const mutate x$11_@4 = read y$8_@3:TPrimitive
60
+ [9] Const mutate x$11 = read y$8_@0:TPrimitive
61
return
62
}
63
compiler/forget/src/__tests__/fixtures/hir/ssa-simple.expect.md
+4
-4
@@ -13,8 +13,8 @@ function foo() {
13
14
```
15
bb0:
16
- [1] Const mutate x$3_@0:TPrimitive = 1
17
- [2] Const mutate y$4_@1:TPrimitive = 2
16
+ [1] Const mutate x$3:TPrimitive = 1
17
+ [2] Const mutate y$4:TPrimitive = 2
18
[3] Return
19
20
```
@@ -24,8 +24,8 @@ bb0:
24
```
25
function foo(
26
) {
27
- [1] Const mutate x$3_@0:TPrimitive = 1
28
- [2] Const mutate y$4_@1:TPrimitive = 2
27
+ [1] Const mutate x$3:TPrimitive = 1
28
+ [2] Const mutate y$4:TPrimitive = 2
29
return
30
}
31
compiler/forget/src/__tests__/fixtures/hir/ssa-single-if.expect.md
+9
-11
@@ -17,19 +17,17 @@ function foo() {
17
18
```
19
bb0:
20
- [1] Const mutate x$4_@0:TPrimitive = 1
21
- [2] Const mutate y$5_@1:TPrimitive = 2
22
- [3] If (read y$5_@1:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
20
+ [1] Const mutate x$4:TPrimitive = 1
21
+ [2] Const mutate y$5:TPrimitive = 2
22
+ [3] If (read y$5:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
23
bb2:
24
predecessor blocks: bb0
25
- [4] Const mutate z$6_@2:TPrimitive = Binary read x$4_@0:TPrimitive + read y$5_@1:TPrimitive
25
+ [4] Const mutate z$6:TPrimitive = Binary read x$4:TPrimitive + read y$5:TPrimitive
26
[5] Goto bb1
27
bb1:
28
predecessor blocks: bb2 bb0
29
[6] Return
30
-scope2 [4:5]:
31
- - dependency: read x$4_@0:TPrimitive
32
- - dependency: read y$5_@1:TPrimitive
30
+
31
```
32
33
## Reactive Scopes
@@ -37,10 +35,10 @@ scope2 [4:5]:
35
```
36
function foo(
37
) {
40
- [1] Const mutate x$4_@0:TPrimitive = 1
41
- [2] Const mutate y$5_@1:TPrimitive = 2
42
- if (read y$5_@1:TPrimitive) {
43
- [4] Const mutate z$6_@2:TPrimitive = Binary read x$4_@0:TPrimitive + read y$5_@1:TPrimitive
38
+ [1] Const mutate x$4:TPrimitive = 1
39
+ [2] Const mutate y$5:TPrimitive = 2
40
+ if (read y$5:TPrimitive) {
41
+ [4] Const mutate z$6:TPrimitive = Binary read x$4:TPrimitive + read y$5:TPrimitive
42
}
43
return
44
}
compiler/forget/src/__tests__/fixtures/hir/ssa-switch.expect.md
+38
-49
@@ -28,52 +28,41 @@ function foo() {
28
29
```
30
bb0:
31
- [1] Const mutate x$10_@0:TPrimitive = 1
32
- [2] Const mutate $11_@1:TPrimitive = 2
33
- [3] Const mutate $12_@2:TPrimitive = Binary read x$10_@0:TPrimitive === read $11_@1:TPrimitive
34
- [4] Const mutate $13_@3:TPrimitive = 1
35
- [5] Const mutate $14_@4:TPrimitive = Binary read x$10_@0:TPrimitive === read $13_@3:TPrimitive
36
- [6] Let mutate x$16_@5:TPrimitive[6:16] = undefined
37
- [6] Switch (read x$10_@0:TPrimitive)
38
- Case read $14_@4:TPrimitive: bb5
39
- Case read $12_@2:TPrimitive: bb3
31
+ [1] Const mutate x$10:TPrimitive = 1
32
+ [2] Const mutate $11:TPrimitive = 2
33
+ [3] Const mutate $12:TPrimitive = Binary read x$10:TPrimitive === read $11:TPrimitive
34
+ [4] Const mutate $13:TPrimitive = 1
35
+ [5] Const mutate $14:TPrimitive = Binary read x$10:TPrimitive === read $13:TPrimitive
36
+ [6] Let mutate x$16_@0:TPrimitive[6:16] = undefined
37
+ [6] Switch (read x$10:TPrimitive)
38
+ Case read $14:TPrimitive: bb5
39
+ Case read $12:TPrimitive: bb3
40
Default: bb2
41
Fallthrough: bb1
42
bb5:
43
predecessor blocks: bb0
44
- [7] Const mutate $15_@6:TPrimitive = 1
45
- [8] Reassign mutate x$16_@5:TPrimitive[6:16] = Binary read x$10_@0:TPrimitive + read $15_@6:TPrimitive
44
+ [7] Const mutate $15:TPrimitive = 1
45
+ [8] Reassign mutate x$16_@0:TPrimitive[6:16] = Binary read x$10:TPrimitive + read $15:TPrimitive
46
[9] Goto bb1
47
bb3:
48
predecessor blocks: bb0
49
- [10] Const mutate $17_@7:TPrimitive = 2
50
- [11] Reassign mutate x$16_@5:TPrimitive[6:16] = Binary read x$10_@0:TPrimitive + read $17_@7:TPrimitive
49
+ [10] Const mutate $17:TPrimitive = 2
50
+ [11] Reassign mutate x$16_@0:TPrimitive[6:16] = Binary read x$10:TPrimitive + read $17:TPrimitive
51
[12] Goto bb1
52
bb2:
53
predecessor blocks: bb0
54
- [13] Const mutate $19_@8:TPrimitive = 3
55
- [14] Reassign mutate x$16_@5:TPrimitive[6:16] = Binary read x$10_@0:TPrimitive + read $19_@8:TPrimitive
54
+ [13] Const mutate $19:TPrimitive = 3
55
+ [14] Reassign mutate x$16_@0:TPrimitive[6:16] = Binary read x$10:TPrimitive + read $19:TPrimitive
56
[15] Goto bb1
57
bb1:
58
predecessor blocks: bb5 bb3 bb2
59
- [16] Const mutate y$22_@9 = read x$16_@5:TPrimitive
59
+ [16] Const mutate y$22 = read x$16_@0:TPrimitive
60
[17] Return
61
-scope2 [3:4]:
62
- - dependency: read x$10_@0:TPrimitive
63
- - dependency: read $11_@1:TPrimitive
64
-scope4 [5:6]:
65
- - dependency: read x$10_@0:TPrimitive
66
- - dependency: read $13_@3:TPrimitive
67
-scope5 [6:16]:
68
- - dependency: read x$10_@0:TPrimitive
69
-scope6 [7:8]:
70
- - dependency: read x$10_@0:TPrimitive
71
-scope7 [10:11]:
72
- - dependency: read x$10_@0:TPrimitive
73
-scope8 [13:14]:
74
- - dependency: read x$10_@0:TPrimitive
75
-scope9 [16:17]:
76
- - dependency: read x$16_@5:TPrimitive
61
+scope0 [6:16]:
62
+ - dependency: read x$10:TPrimitive
63
+ - dependency: read x$10:TPrimitive
64
+ - dependency: read x$10:TPrimitive
65
+ - dependency: read x$10:TPrimitive
66
```
67
68
## Reactive Scopes
@@ -81,31 +70,31 @@ scope9 [16:17]:
70
```
71
function foo(
72
) {
84
- [1] Const mutate x$10_@0:TPrimitive = 1
85
- [2] Const mutate $11_@1:TPrimitive = 2
86
- [3] Const mutate $12_@2:TPrimitive = Binary read x$10_@0:TPrimitive === read $11_@1:TPrimitive
87
- [4] Const mutate $13_@3:TPrimitive = 1
88
- [5] Const mutate $14_@4:TPrimitive = Binary read x$10_@0:TPrimitive === read $13_@3:TPrimitive
89
- scope @5 [6:16] deps=[read x$10_@0:TPrimitive] {
90
- [6] Let mutate x$16_@5:TPrimitive[6:16] = undefined
91
- switch (read x$10_@0:TPrimitive) {
92
- case read $14_@4:TPrimitive: {
93
- [7] Const mutate $15_@6:TPrimitive = 1
94
- [8] Reassign mutate x$16_@5:TPrimitive[6:16] = Binary read x$10_@0:TPrimitive + read $15_@6:TPrimitive
73
+ [1] Const mutate x$10:TPrimitive = 1
74
+ [2] Const mutate $11:TPrimitive = 2
75
+ [3] Const mutate $12:TPrimitive = Binary read x$10:TPrimitive === read $11:TPrimitive
76
+ [4] Const mutate $13:TPrimitive = 1
77
+ [5] Const mutate $14:TPrimitive = Binary read x$10:TPrimitive === read $13:TPrimitive
78
+ scope @0 [6:16] deps=[read x$10:TPrimitive, read x$10:TPrimitive, read x$10:TPrimitive, read x$10:TPrimitive] {
79
+ [6] Let mutate x$16_@0:TPrimitive[6:16] = undefined
80
+ switch (read x$10:TPrimitive) {
81
+ case read $14:TPrimitive: {
82
+ [7] Const mutate $15:TPrimitive = 1
83
+ [8] Reassign mutate x$16_@0:TPrimitive[6:16] = Binary read x$10:TPrimitive + read $15:TPrimitive
84
break bb1
85
}
97
- case read $12_@2:TPrimitive: {
98
- [10] Const mutate $17_@7:TPrimitive = 2
99
- [11] Reassign mutate x$16_@5:TPrimitive[6:16] = Binary read x$10_@0:TPrimitive + read $17_@7:TPrimitive
86
+ case read $12:TPrimitive: {
87
+ [10] Const mutate $17:TPrimitive = 2
88
+ [11] Reassign mutate x$16_@0:TPrimitive[6:16] = Binary read x$10:TPrimitive + read $17:TPrimitive
89
break bb1
90
}
91
default: {
103
- [13] Const mutate $19_@8:TPrimitive = 3
104
- [14] Reassign mutate x$16_@5:TPrimitive[6:16] = Binary read x$10_@0:TPrimitive + read $19_@8:TPrimitive
92
+ [13] Const mutate $19:TPrimitive = 3
93
+ [14] Reassign mutate x$16_@0:TPrimitive[6:16] = Binary read x$10:TPrimitive + read $19:TPrimitive
94
}
95
}
96
}
108
- [16] Const mutate y$22_@9 = read x$16_@5:TPrimitive
97
+ [16] Const mutate y$22 = read x$16_@0:TPrimitive
98
return
99
}
100
compiler/forget/src/__tests__/fixtures/hir/ssa-throw.expect.md
+6
-6
@@ -17,9 +17,9 @@ function foo() {
17
```
18
bb0:
19
[1] Let mutate x$4_@0:TPrimitive[1:7] = 1
20
- [2] Const mutate $5_@1:TPrimitive = 1
21
- [3] Const mutate $6_@0:TPrimitive[1:7] = Binary read x$4_@0:TPrimitive === read $5_@1:TPrimitive
22
- [4] If (read $6_@0:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
20
+ [2] Const mutate $5:TPrimitive = 1
21
+ [3] Const mutate $6:TPrimitive = Binary read x$4_@0:TPrimitive === read $5:TPrimitive
22
+ [4] If (read $6:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
23
bb2:
24
predecessor blocks: bb0
25
[5] Reassign mutate x$4_@0:TPrimitive[1:7] = 2
@@ -37,9 +37,9 @@ function foo(
37
) {
38
scope @0 [1:7] deps=[] {
39
[1] Let mutate x$4_@0:TPrimitive[1:7] = 1
40
- [2] Const mutate $5_@1:TPrimitive = 1
41
- [3] Const mutate $6_@0:TPrimitive[1:7] = Binary read x$4_@0:TPrimitive === read $5_@1:TPrimitive
42
- if (read $6_@0:TPrimitive) {
40
+ [2] Const mutate $5:TPrimitive = 1
41
+ [3] Const mutate $6:TPrimitive = Binary read x$4_@0:TPrimitive === read $5:TPrimitive
42
+ if (read $6:TPrimitive) {
43
[5] Reassign mutate x$4_@0:TPrimitive[1:7] = 2
44
}
45
}
compiler/forget/src/__tests__/fixtures/hir/ssa-while-no-reassign.expect.md
+17
-24
@@ -17,25 +17,22 @@ function foo() {
17
18
```
19
bb0:
20
- [1] Const mutate x$5_@0:TPrimitive = 1
20
+ [1] Const mutate x$5:TPrimitive = 1
21
[2] While test=bb1 loop=bb3 fallthrough=bb2
22
bb1:
23
predecessor blocks: bb0 bb3
24
- [3] Const mutate $6_@1:TPrimitive[3:6] = 10
25
- [4] Const mutate $8_@2:TPrimitive[4:6] = Binary read x$5_@0:TPrimitive < read $6_@1:TPrimitive
26
- [5] If (read $8_@2:TPrimitive) then:bb3 else:bb2 fallthrough=bb2
24
+ [3] Const mutate $6:TPrimitive = 10
25
+ [4] Const mutate $8:TPrimitive = Binary read x$5:TPrimitive < read $6:TPrimitive
26
+ [5] If (read $8:TPrimitive) then:bb3 else:bb2 fallthrough=bb2
27
bb3:
28
predecessor blocks: bb1
29
- [6] Const mutate $9_@3:TPrimitive = 1
30
- [7] Binary read x$5_@0:TPrimitive + read $9_@3:TPrimitive
29
+ [6] Const mutate $9:TPrimitive = 1
30
+ [7] Binary read x$5:TPrimitive + read $9:TPrimitive
31
[8] Goto(Continue) bb1
32
bb2:
33
predecessor blocks: bb1
34
- [9] Return read x$5_@0:TPrimitive
35
-scope2 [4:6]:
36
- - dependency: read x$5_@0:TPrimitive
37
-scope3 [6:7]:
38
- - dependency: read x$5_@0:TPrimitive
34
+ [9] Return read x$5:TPrimitive
35
+
36
```
37
38
## Reactive Scopes
@@ -43,20 +40,16 @@ scope3 [6:7]:
40
```
41
function foo(
42
) {
46
- [1] Const mutate x$5_@0:TPrimitive = 1
47
- scope @1 [3:6] deps=[] {
48
- scope @2 [4:6] deps=[read x$5_@0:TPrimitive] {
49
- while (
50
- [3] Const mutate $6_@1:TPrimitive[3:6] = 10
51
- [4] Const mutate $8_@2:TPrimitive[4:6] = Binary read x$5_@0:TPrimitive < read $6_@1:TPrimitive
52
- read $8_@2:TPrimitive
53
- ) {
54
- [6] Const mutate $9_@3:TPrimitive = 1
55
- [7] Binary read x$5_@0:TPrimitive + read $9_@3:TPrimitive
56
- }
57
- }
43
+ [1] Const mutate x$5:TPrimitive = 1
44
+ while (
45
+ [3] Const mutate $6:TPrimitive = 10
46
+ [4] Const mutate $8:TPrimitive = Binary read x$5:TPrimitive < read $6:TPrimitive
47
+ read $8:TPrimitive
48
+ ) {
49
+ [6] Const mutate $9:TPrimitive = 1
50
+ [7] Binary read x$5:TPrimitive + read $9:TPrimitive
51
}
59
- return read x$5_@0:TPrimitive
52
+ return read x$5:TPrimitive
53
}
54
55
```
compiler/forget/src/__tests__/fixtures/hir/ssa-while.expect.md
+10
-10
@@ -21,13 +21,13 @@ bb0:
21
[2] While test=bb1 loop=bb3 fallthrough=bb2
22
bb1:
23
predecessor blocks: bb0 bb3
24
- [3] Const mutate $6_@0:TPrimitive[1:9] = 10
25
- [4] Const mutate $8_@0:TPrimitive[1:9] = Binary read x$5_@0:TPrimitive < read $6_@0:TPrimitive
26
- [5] If (read $8_@0:TPrimitive) then:bb3 else:bb2 fallthrough=bb2
24
+ [3] Const mutate $6:TPrimitive = 10
25
+ [4] Const mutate $8:TPrimitive = Binary read x$5_@0:TPrimitive < read $6:TPrimitive
26
+ [5] If (read $8:TPrimitive) then:bb3 else:bb2 fallthrough=bb2
27
bb3:
28
predecessor blocks: bb1
29
- [6] Const mutate $9_@2:TPrimitive = 1
30
- [7] Reassign mutate x$5_@0:TPrimitive[1:9] = Binary read x$5_@0:TPrimitive + read $9_@2:TPrimitive
29
+ [6] Const mutate $9:TPrimitive = 1
30
+ [7] Reassign mutate x$5_@0:TPrimitive[1:9] = Binary read x$5_@0:TPrimitive + read $9:TPrimitive
31
[8] Goto(Continue) bb1
32
bb2:
33
predecessor blocks: bb1
@@ -43,12 +43,12 @@ function foo(
43
scope @0 [1:9] deps=[] {
44
[1] Let mutate x$5_@0:TPrimitive[1:9] = 1
45
while (
46
- [3] Const mutate $6_@0:TPrimitive[1:9] = 10
47
- [4] Const mutate $8_@0:TPrimitive[1:9] = Binary read x$5_@0:TPrimitive < read $6_@0:TPrimitive
48
- read $8_@0:TPrimitive
46
+ [3] Const mutate $6:TPrimitive = 10
47
+ [4] Const mutate $8:TPrimitive = Binary read x$5_@0:TPrimitive < read $6:TPrimitive
48
+ read $8:TPrimitive
49
) {
50
- [6] Const mutate $9_@2:TPrimitive = 1
51
- [7] Reassign mutate x$5_@0:TPrimitive[1:9] = Binary read x$5_@0:TPrimitive + read $9_@2:TPrimitive
50
+ [6] Const mutate $9:TPrimitive = 1
51
+ [7] Reassign mutate x$5_@0:TPrimitive[1:9] = Binary read x$5_@0:TPrimitive + read $9:TPrimitive
52
}
53
}
54
return read x$5_@0:TPrimitive
compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md
+23
-23
@@ -34,14 +34,14 @@ function Component(props) {
34
bb0:
35
[1] Const mutate x$10_@1:TFunction[1:12] = Array []
36
[2] Let mutate y$11_@1:TPrimitive[1:12] = undefined
37
- [3] Const mutate $12_@2:TPrimitive = false
38
- [4] Const mutate $13_@3:TPrimitive = true
39
- [5] Const mutate $14_@4:TPrimitive = 1
37
+ [3] Const mutate $12:TPrimitive = false
38
+ [4] Const mutate $13:TPrimitive = true
39
+ [5] Const mutate $14:TPrimitive = 1
40
[6] Switch (read props$9.p0)
41
- Case read $14_@4:TPrimitive: bb1
42
- Case read $13_@3:TPrimitive: bb6
41
+ Case read $14:TPrimitive: bb1
42
+ Case read $13:TPrimitive: bb6
43
Default: bb1
44
- Case read $12_@2:TPrimitive: bb2
44
+ Case read $12:TPrimitive: bb2
45
Fallthrough: bb1
46
bb6:
47
predecessor blocks: bb0
@@ -54,19 +54,19 @@ bb2:
54
[11] Goto bb1
55
bb1:
56
predecessor blocks: bb0 bb6 bb2
57
- [12] Const mutate child$19_@5 = JSX <read Component$0 data={freeze x$10_@1:TFunction} ></read Component$0>
57
+ [12] Const mutate child$19_@2 = JSX <read Component$0 data={freeze x$10_@1:TFunction} ></read Component$0>
58
[13] Call read y$11_@1.push(read props$9.p4)
59
- [14] Const mutate $22_@6 = JSX <read Component$0 data={freeze y$11_@1:TPrimitive} >{read child$19_@5}</read Component$0>
60
- [15] Return read $22_@6
61
-scope5 [12:13]:
59
+ [14] Const mutate $22_@3 = JSX <read Component$0 data={freeze y$11_@1:TPrimitive} >{read child$19_@2}</read Component$0>
60
+ [15] Return read $22_@3
61
+scope2 [12:13]:
62
- dependency: read Component$0
63
- dependency: freeze x$10_@1:TFunction
64
- dependency: read y$11_@1.push
65
- dependency: read props$9.p4
66
-scope6 [14:15]:
66
+scope3 [14:15]:
67
- dependency: read Component$0
68
- dependency: freeze y$11_@1:TPrimitive
69
- - dependency: read child$19_@5
69
+ - dependency: read child$19_@2
70
```
71
72
## Reactive Scopes
@@ -78,14 +78,14 @@ function Component(
78
scope @1 [1:12] deps=[] {
79
[1] Const mutate x$10_@1:TFunction[1:12] = Array []
80
[2] Let mutate y$11_@1:TPrimitive[1:12] = undefined
81
- [3] Const mutate $12_@2:TPrimitive = false
82
- [4] Const mutate $13_@3:TPrimitive = true
83
- [5] Const mutate $14_@4:TPrimitive = 1
81
+ [3] Const mutate $12:TPrimitive = false
82
+ [4] Const mutate $13:TPrimitive = true
83
+ [5] Const mutate $14:TPrimitive = 1
84
switch (read props$9.p0) {
85
- case read $14_@4:TPrimitive: {
85
+ case read $14:TPrimitive: {
86
break bb1
87
}
88
- case read $13_@3:TPrimitive: {
88
+ case read $13:TPrimitive: {
89
[7] Call mutate x$10_@1.push(read props$9.p2)
90
[8] Reassign mutate y$11_@1:TPrimitive[1:12] = Array []
91
break bb1
@@ -93,19 +93,19 @@ function Component(
93
default: {
94
break bb1
95
}
96
- case read $12_@2:TPrimitive: {
96
+ case read $12:TPrimitive: {
97
[10] Reassign mutate y$11_@1:TPrimitive[1:12] = read x$10_@1:TFunction
98
}
99
}
100
}
101
- scope @5 [12:13] deps=[read Component$0, freeze x$10_@1:TFunction, read y$11_@1.push, read props$9.p4] {
102
- [12] Const mutate child$19_@5 = JSX <read Component$0 data={freeze x$10_@1:TFunction} ></read Component$0>
101
+ scope @2 [12:13] deps=[read Component$0, freeze x$10_@1:TFunction, read y$11_@1.push, read props$9.p4] {
102
+ [12] Const mutate child$19_@2 = JSX <read Component$0 data={freeze x$10_@1:TFunction} ></read Component$0>
103
}
104
[13] Call read y$11_@1.push(read props$9.p4)
105
- scope @6 [14:15] deps=[read Component$0, freeze y$11_@1:TPrimitive, read child$19_@5] {
106
- [14] Const mutate $22_@6 = JSX <read Component$0 data={freeze y$11_@1:TPrimitive} >{read child$19_@5}</read Component$0>
105
+ scope @3 [14:15] deps=[read Component$0, freeze y$11_@1:TPrimitive, read child$19_@2] {
106
+ [14] Const mutate $22_@3 = JSX <read Component$0 data={freeze y$11_@1:TPrimitive} >{read child$19_@2}</read Component$0>
107
}
108
- return read $22_@6
108
+ return read $22_@3
109
}
110
111
```
compiler/forget/src/__tests__/fixtures/hir/switch-with-fallthrough.expect.md
+38
-38
@@ -36,45 +36,45 @@ function foo(x) {
36
37
```
38
bb0:
39
- [1] Const mutate y$10_@0:TPrimitive = undefined
40
- [2] Const mutate $11_@1:TPrimitive = 5
41
- [3] Const mutate $12_@2:TPrimitive = 4
42
- [4] Const mutate $13_@3:TPrimitive = 3
43
- [5] Const mutate $14_@4:TPrimitive = 2
44
- [6] Const mutate $15_@5:TPrimitive = 1
45
- [7] Const mutate $16_@6:TPrimitive = 0
39
+ [1] Const mutate y$10:TPrimitive = undefined
40
+ [2] Const mutate $11:TPrimitive = 5
41
+ [3] Const mutate $12:TPrimitive = 4
42
+ [4] Const mutate $13:TPrimitive = 3
43
+ [5] Const mutate $14:TPrimitive = 2
44
+ [6] Const mutate $15:TPrimitive = 1
45
+ [7] Const mutate $16:TPrimitive = 0
46
[8] Switch (read x$9)
47
- Case read $16_@6:TPrimitive: bb10
48
- Case read $15_@5:TPrimitive: bb9
49
- Case read $14_@4:TPrimitive: bb1
50
- Case read $13_@3:TPrimitive: bb5
51
- Case read $12_@2:TPrimitive: bb4
52
- Case read $11_@1:TPrimitive: bb3
47
+ Case read $16:TPrimitive: bb10
48
+ Case read $15:TPrimitive: bb9
49
+ Case read $14:TPrimitive: bb1
50
+ Case read $13:TPrimitive: bb5
51
+ Case read $12:TPrimitive: bb4
52
+ Case read $11:TPrimitive: bb3
53
Default: bb2
54
Fallthrough: bb1
55
bb10:
56
predecessor blocks: bb0
57
- [9] Const mutate y$17_@7:TPrimitive = 0
57
+ [9] Const mutate y$17:TPrimitive = 0
58
[10] Goto bb9
59
bb9:
60
predecessor blocks: bb10 bb0
61
- [11] Const mutate y$18_@8:TPrimitive = 1
61
+ [11] Const mutate y$18:TPrimitive = 1
62
[12] Goto bb1
63
bb5:
64
predecessor blocks: bb0
65
- [13] Const mutate y$19_@9:TPrimitive = 3
65
+ [13] Const mutate y$19:TPrimitive = 3
66
[14] Goto bb1
67
bb4:
68
predecessor blocks: bb0
69
- [15] Const mutate y$20_@10:TPrimitive = 4
69
+ [15] Const mutate y$20:TPrimitive = 4
70
[16] Goto bb3
71
bb3:
72
predecessor blocks: bb4 bb0
73
- [17] Const mutate y$21_@11:TPrimitive = 5
73
+ [17] Const mutate y$21:TPrimitive = 5
74
[18] Goto bb2
75
bb2:
76
predecessor blocks: bb3 bb0
77
- [19] Const mutate y$22_@12:TPrimitive = 0
77
+ [19] Const mutate y$22:TPrimitive = 0
78
[20] Goto bb1
79
bb1:
80
predecessor blocks: bb9 bb0 bb5 bb2
@@ -88,36 +88,36 @@ bb1:
88
function foo(
89
x,
90
) {
91
- [1] Const mutate y$10_@0:TPrimitive = undefined
92
- [2] Const mutate $11_@1:TPrimitive = 5
93
- [3] Const mutate $12_@2:TPrimitive = 4
94
- [4] Const mutate $13_@3:TPrimitive = 3
95
- [5] Const mutate $14_@4:TPrimitive = 2
96
- [6] Const mutate $15_@5:TPrimitive = 1
97
- [7] Const mutate $16_@6:TPrimitive = 0
91
+ [1] Const mutate y$10:TPrimitive = undefined
92
+ [2] Const mutate $11:TPrimitive = 5
93
+ [3] Const mutate $12:TPrimitive = 4
94
+ [4] Const mutate $13:TPrimitive = 3
95
+ [5] Const mutate $14:TPrimitive = 2
96
+ [6] Const mutate $15:TPrimitive = 1
97
+ [7] Const mutate $16:TPrimitive = 0
98
switch (read x$9) {
99
- case read $16_@6:TPrimitive: {
100
- [9] Const mutate y$17_@7:TPrimitive = 0
99
+ case read $16:TPrimitive: {
100
+ [9] Const mutate y$17:TPrimitive = 0
101
}
102
- case read $15_@5:TPrimitive: {
103
- [11] Const mutate y$18_@8:TPrimitive = 1
102
+ case read $15:TPrimitive: {
103
+ [11] Const mutate y$18:TPrimitive = 1
104
break bb1
105
}
106
- case read $14_@4:TPrimitive: {
106
+ case read $14:TPrimitive: {
107
break bb1
108
}
109
- case read $13_@3:TPrimitive: {
110
- [13] Const mutate y$19_@9:TPrimitive = 3
109
+ case read $13:TPrimitive: {
110
+ [13] Const mutate y$19:TPrimitive = 3
111
break bb1
112
}
113
- case read $12_@2:TPrimitive: {
114
- [15] Const mutate y$20_@10:TPrimitive = 4
113
+ case read $12:TPrimitive: {
114
+ [15] Const mutate y$20:TPrimitive = 4
115
}
116
- case read $11_@1:TPrimitive: {
117
- [17] Const mutate y$21_@11:TPrimitive = 5
116
+ case read $11:TPrimitive: {
117
+ [17] Const mutate y$21:TPrimitive = 5
118
}
119
default: {
120
- [19] Const mutate y$22_@12:TPrimitive = 0
120
+ [19] Const mutate y$22:TPrimitive = 0
121
}
122
}
123
return
compiler/forget/src/__tests__/fixtures/hir/switch.expect.md
+22
-22
@@ -30,18 +30,18 @@ function Component(props) {
30
bb0:
31
[1] Const mutate x$9_@1:TFunction[1:12] = Array []
32
[2] Let mutate y$10_@1:TPrimitive[1:12] = undefined
33
- [3] Const mutate $11_@2:TPrimitive = false
34
- [4] Const mutate $12_@3:TPrimitive = true
33
+ [3] Const mutate $11:TPrimitive = false
34
+ [4] Const mutate $12:TPrimitive = true
35
[5] Switch (read props$8.p0)
36
- Case read $12_@3:TPrimitive: bb4
37
- Case read $11_@2:TPrimitive: bb2
36
+ Case read $12:TPrimitive: bb4
37
+ Case read $11:TPrimitive: bb2
38
Default: bb1
39
Fallthrough: bb1
40
bb4:
41
predecessor blocks: bb0
42
[6] Call mutate x$9_@1.push(read props$8.p2)
43
[7] Call mutate x$9_@1.push(read props$8.p3)
44
- [8] Const mutate y$13_@4 = Array []
44
+ [8] Const mutate y$13_@2 = Array []
45
[9] Goto bb2
46
bb2:
47
predecessor blocks: bb4 bb0
@@ -49,19 +49,19 @@ bb2:
49
[11] Goto bb1
50
bb1:
51
predecessor blocks: bb2 bb0
52
- [12] Const mutate child$19_@5 = JSX <read Component$0 data={freeze x$9_@1:TFunction} ></read Component$0>
52
+ [12] Const mutate child$19_@3 = JSX <read Component$0 data={freeze x$9_@1:TFunction} ></read Component$0>
53
[13] Call read y$10_@1.push(read props$8.p4)
54
- [14] Const mutate $23_@6 = JSX <read Component$0 data={read y$10_@1:TPrimitive} >{read child$19_@5}</read Component$0>
55
- [15] Return read $23_@6
56
-scope5 [12:13]:
54
+ [14] Const mutate $23_@4 = JSX <read Component$0 data={read y$10_@1:TPrimitive} >{read child$19_@3}</read Component$0>
55
+ [15] Return read $23_@4
56
+scope3 [12:13]:
57
- dependency: read Component$0
58
- dependency: freeze x$9_@1:TFunction
59
- dependency: read y$10_@1.push
60
- dependency: read props$8.p4
61
-scope6 [14:15]:
61
+scope4 [14:15]:
62
- dependency: read Component$0
63
- dependency: read y$10_@1:TPrimitive
64
- - dependency: read child$19_@5
64
+ - dependency: read child$19_@3
65
```
66
67
## Reactive Scopes
@@ -73,29 +73,29 @@ function Component(
73
scope @1 [1:12] deps=[] {
74
[1] Const mutate x$9_@1:TFunction[1:12] = Array []
75
[2] Let mutate y$10_@1:TPrimitive[1:12] = undefined
76
- [3] Const mutate $11_@2:TPrimitive = false
77
- [4] Const mutate $12_@3:TPrimitive = true
76
+ [3] Const mutate $11:TPrimitive = false
77
+ [4] Const mutate $12:TPrimitive = true
78
switch (read props$8.p0) {
79
- case read $12_@3:TPrimitive: {
79
+ case read $12:TPrimitive: {
80
[6] Call mutate x$9_@1.push(read props$8.p2)
81
[7] Call mutate x$9_@1.push(read props$8.p3)
82
- scope @4 [8:9] deps=[] {
83
- [8] Const mutate y$13_@4 = Array []
82
+ scope @2 [8:9] deps=[] {
83
+ [8] Const mutate y$13_@2 = Array []
84
}
85
}
86
- case read $11_@2:TPrimitive: {
86
+ case read $11:TPrimitive: {
87
[10] Reassign mutate y$10_@1:TPrimitive[1:12] = read x$9_@1:TFunction
88
}
89
}
90
}
91
- scope @5 [12:13] deps=[read Component$0, freeze x$9_@1:TFunction, read y$10_@1.push, read props$8.p4] {
92
- [12] Const mutate child$19_@5 = JSX <read Component$0 data={freeze x$9_@1:TFunction} ></read Component$0>
91
+ scope @3 [12:13] deps=[read Component$0, freeze x$9_@1:TFunction, read y$10_@1.push, read props$8.p4] {
92
+ [12] Const mutate child$19_@3 = JSX <read Component$0 data={freeze x$9_@1:TFunction} ></read Component$0>
93
}
94
[13] Call read y$10_@1.push(read props$8.p4)
95
- scope @6 [14:15] deps=[read Component$0, read y$10_@1:TPrimitive, read child$19_@5] {
96
- [14] Const mutate $23_@6 = JSX <read Component$0 data={read y$10_@1:TPrimitive} >{read child$19_@5}</read Component$0>
95
+ scope @4 [14:15] deps=[read Component$0, read y$10_@1:TPrimitive, read child$19_@3] {
96
+ [14] Const mutate $23_@4 = JSX <read Component$0 data={read y$10_@1:TPrimitive} >{read child$19_@3}</read Component$0>
97
}
98
- return read $23_@6
98
+ return read $23_@4
99
}
100
101
```
compiler/forget/src/__tests__/fixtures/hir/type-args-test-binary-operator.expect.md
+8
-10
@@ -14,18 +14,16 @@ function component(a, b) {
14
15
```
16
bb0:
17
- [1] Const mutate $7_@0:TPrimitive = Binary read a$5:TPrimitive > read b$6:TPrimitive
18
- [2] If (read $7_@0:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
17
+ [1] Const mutate $7:TPrimitive = Binary read a$5:TPrimitive > read b$6:TPrimitive
18
+ [2] If (read $7:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
19
bb2:
20
predecessor blocks: bb0
21
- [3] Const mutate m$8_@1:TObject = Object { }
21
+ [3] Const mutate m$8_@0:TObject = Object { }
22
[4] Goto bb1
23
bb1:
24
predecessor blocks: bb2 bb0
25
[5] Return
26
-scope0 [1:2]:
27
- - dependency: read a$5:TPrimitive
28
- - dependency: read b$6:TPrimitive
26
+
27
```
28
29
## Reactive Scopes
@@ -35,10 +33,10 @@ function component(
33
a,
34
b,
35
) {
38
- [1] Const mutate $7_@0:TPrimitive = Binary read a$5:TPrimitive > read b$6:TPrimitive
39
- if (read $7_@0:TPrimitive) {
40
- scope @1 [3:4] deps=[] {
41
- [3] Const mutate m$8_@1:TObject = Object { }
36
+ [1] Const mutate $7:TPrimitive = Binary read a$5:TPrimitive > read b$6:TPrimitive
37
+ if (read $7:TPrimitive) {
38
+ scope @0 [3:4] deps=[] {
39
+ [3] Const mutate m$8_@0:TObject = Object { }
40
}
41
}
42
return
compiler/forget/src/__tests__/fixtures/hir/type-binary-operator.expect.md
+9
-10
@@ -18,18 +18,17 @@ function component() {
18
bb0:
19
[1] Const mutate a$7_@0:TPrimitive = Call mutate some$2:TFunction()
20
[2] Const mutate b$8_@1:TPrimitive = Call mutate someOther$4:TFunction()
21
- [3] Const mutate $9_@2:TPrimitive = Binary read a$7_@0:TPrimitive > read b$8_@1:TPrimitive
22
- [4] If (read $9_@2:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
21
+ [3] Const mutate $9:TPrimitive = Binary read a$7_@0:TPrimitive > read b$8_@1:TPrimitive
22
+ [4] If (read $9:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
23
bb2:
24
predecessor blocks: bb0
25
- [5] Const mutate m$10_@3:TObject = Object { }
25
+ [5] Const mutate m$10_@2:TObject = Object { }
26
[6] Goto bb1
27
bb1:
28
predecessor blocks: bb2 bb0
29
[7] Return
30
-scope2 [3:4]:
30
+scope1 [2:3]:
31
- dependency: read a$7_@0:TPrimitive
32
- - dependency: read b$8_@1:TPrimitive
32
```
33
34
## Reactive Scopes
@@ -40,13 +39,13 @@ function component(
39
scope @0 [1:2] deps=[] {
40
[1] Const mutate a$7_@0:TPrimitive = Call mutate some$2:TFunction()
41
}
43
- scope @1 [2:3] deps=[] {
42
+ scope @1 [2:3] deps=[read a$7_@0:TPrimitive] {
43
[2] Const mutate b$8_@1:TPrimitive = Call mutate someOther$4:TFunction()
44
}
46
- [3] Const mutate $9_@2:TPrimitive = Binary read a$7_@0:TPrimitive > read b$8_@1:TPrimitive
47
- if (read $9_@2:TPrimitive) {
48
- scope @3 [5:6] deps=[] {
49
- [5] Const mutate m$10_@3:TObject = Object { }
45
+ [3] Const mutate $9:TPrimitive = Binary read a$7_@0:TPrimitive > read b$8_@1:TPrimitive
46
+ if (read $9:TPrimitive) {
47
+ scope @2 [5:6] deps=[] {
48
+ [5] Const mutate m$10_@2:TObject = Object { }
49
}
50
}
51
return
compiler/forget/src/__tests__/fixtures/hir/type-field-load.expect.md
+9
-11
@@ -13,14 +13,12 @@ function component() {
13
14
```
15
bb0:
16
- [1] Const mutate $4_@0:TPrimitive = 1
17
- [2] Const mutate x$5_@1:TObject = Object { t: read $4_@0:TPrimitive }
18
- [3] Const mutate p$6_@2:TPrimitive = read x$5_@1.t
16
+ [1] Const mutate $4:TPrimitive = 1
17
+ [2] Const mutate x$5_@0:TObject = Object { t: read $4:TPrimitive }
18
+ [3] Const mutate p$6:TPrimitive = read x$5_@0.t
19
[4] Return
20
-scope1 [2:3]:
21
- - dependency: read $4_@0:TPrimitive
22
-scope2 [3:4]:
23
- - dependency: read x$5_@1.t
20
+scope0 [2:3]:
21
+ - dependency: read $4:TPrimitive
22
```
23
24
## Reactive Scopes
@@ -28,11 +26,11 @@ scope2 [3:4]:
26
```
27
function component(
28
) {
31
- [1] Const mutate $4_@0:TPrimitive = 1
32
- scope @1 [2:3] deps=[read $4_@0:TPrimitive] {
33
- [2] Const mutate x$5_@1:TObject = Object { t: read $4_@0:TPrimitive }
29
+ [1] Const mutate $4:TPrimitive = 1
30
+ scope @0 [2:3] deps=[read $4:TPrimitive] {
31
+ [2] Const mutate x$5_@0:TObject = Object { t: read $4:TPrimitive }
32
}
35
- [3] Const mutate p$6_@2:TPrimitive = read x$5_@1.t
33
+ [3] Const mutate p$6:TPrimitive = read x$5_@0.t
34
return
35
}
36
compiler/forget/src/__tests__/fixtures/hir/type-test-field-load-binary-op.expect.md
+12
-23
@@ -22,29 +22,18 @@ bb0:
22
[1] Const mutate $10_@0:TPrimitive = Call mutate makeSomePrimitive$2:TFunction()
23
[2] Const mutate $11_@1:TPrimitive = Call mutate makeSomePrimitive$2:TFunction()
24
[3] Const mutate x$12_@2:TObject = Object { u: read $10_@0:TPrimitive, v: read $11_@1:TPrimitive }
25
- [4] Const mutate u$13_@3:TPrimitive = read x$12_@2.u
26
- [5] Const mutate v$14_@4:TPrimitive = read x$12_@2.v
27
- [6] Const mutate $15_@5:TPrimitive = Binary read u$13_@3:TPrimitive > read v$14_@4:TPrimitive
28
- [7] If (read $15_@5:TPrimitive) then:bb1 else:bb1 fallthrough=bb1
25
+ [4] Const mutate u$13:TPrimitive = read x$12_@2.u
26
+ [5] Const mutate v$14:TPrimitive = read x$12_@2.v
27
+ [6] Const mutate $15:TPrimitive = Binary read u$13:TPrimitive > read v$14:TPrimitive
28
+ [7] If (read $15:TPrimitive) then:bb1 else:bb1 fallthrough=bb1
29
bb1:
30
predecessor blocks: bb0
31
- [8] Const mutate y$16_@6:TPrimitive = read x$12_@2.u
32
- [9] Const mutate z$17_@7:TPrimitive = read x$12_@2.v
31
+ [8] Const mutate y$16:TPrimitive = read x$12_@2.u
32
+ [9] Const mutate z$17:TPrimitive = read x$12_@2.v
33
[10] Return
34
scope2 [3:4]:
35
- dependency: read $10_@0:TPrimitive
36
- dependency: read $11_@1:TPrimitive
37
-scope3 [4:5]:
38
- - dependency: read x$12_@2.u
39
-scope4 [5:6]:
40
- - dependency: read x$12_@2.v
41
-scope5 [6:7]:
42
- - dependency: read u$13_@3:TPrimitive
43
- - dependency: read v$14_@4:TPrimitive
44
-scope6 [8:9]:
45
- - dependency: read x$12_@2.u
46
-scope7 [9:10]:
47
- - dependency: read x$12_@2.v
37
```
38
39
## Reactive Scopes
@@ -61,13 +50,13 @@ function component(
50
scope @2 [3:4] deps=[read $10_@0:TPrimitive, read $11_@1:TPrimitive] {
51
[3] Const mutate x$12_@2:TObject = Object { u: read $10_@0:TPrimitive, v: read $11_@1:TPrimitive }
52
}
64
- [4] Const mutate u$13_@3:TPrimitive = read x$12_@2.u
65
- [5] Const mutate v$14_@4:TPrimitive = read x$12_@2.v
66
- [6] Const mutate $15_@5:TPrimitive = Binary read u$13_@3:TPrimitive > read v$14_@4:TPrimitive
67
- if (read $15_@5:TPrimitive) {
53
+ [4] Const mutate u$13:TPrimitive = read x$12_@2.u
54
+ [5] Const mutate v$14:TPrimitive = read x$12_@2.v
55
+ [6] Const mutate $15:TPrimitive = Binary read u$13:TPrimitive > read v$14:TPrimitive
56
+ if (read $15:TPrimitive) {
57
}
69
- [8] Const mutate y$16_@6:TPrimitive = read x$12_@2.u
70
- [9] Const mutate z$17_@7:TPrimitive = read x$12_@2.v
58
+ [8] Const mutate y$16:TPrimitive = read x$12_@2.u
59
+ [9] Const mutate z$17:TPrimitive = read x$12_@2.v
60
return
61
}
62
compiler/forget/src/__tests__/fixtures/hir/type-test-field-store.expect.md
+2
-4
@@ -18,12 +18,10 @@ bb0:
18
[1] Const mutate x$4_@0:TObject[1:4] = Object { }
19
[2] Const mutate q$5_@1:TObject = Object { }
20
[3] Reassign mutate x$4_@0.t[1:4] = read q$5_@1:TObject
21
- [4] Const mutate z$6_@2:TObject = read x$4_@0.t
21
+ [4] Const mutate z$6:TObject = read x$4_@0.t
22
[5] Return
23
scope1 [2:3]:
24
- dependency: mutate x$4_@0.t
25
-scope2 [4:5]:
26
- - dependency: read x$4_@0.t
25
```
26
27
## Reactive Scopes
@@ -38,7 +36,7 @@ function component(
36
}
37
[3] Reassign mutate x$4_@0.t[1:4] = read q$5_@1:TObject
38
}
41
- [4] Const mutate z$6_@2:TObject = read x$4_@0.t
39
+ [4] Const mutate z$6:TObject = read x$4_@0.t
40
return
41
}
42
compiler/forget/src/__tests__/fixtures/hir/type-test-polymorphic.expect.md
+2
-4
@@ -29,13 +29,11 @@ bb0:
29
[5] Reassign mutate x$9_@2.t[4:8] = read p$7_@0:TPrimitive
30
[6] Const mutate z$10_@2:TPrimitive[4:8] = read x$9_@2.t
31
[7] Reassign mutate x$9_@2.t[4:8] = read o$8_@1:TObject
32
- [8] Const mutate y$11_@3:TPoly = read x$9_@2.t
32
+ [8] Const mutate y$11:TPoly = read x$9_@2.t
33
[9] Return
34
scope2 [4:8]:
35
- dependency: read p$7_@0:TPrimitive
36
- dependency: read o$8_@1:TObject
37
-scope3 [8:9]:
38
- - dependency: read x$9_@2.t
37
```
38
39
## Reactive Scopes
@@ -56,7 +54,7 @@ function component(
54
[6] Const mutate z$10_@2:TPrimitive[4:8] = read x$9_@2.t
55
[7] Reassign mutate x$9_@2.t[4:8] = read o$8_@1:TObject
56
}
59
- [8] Const mutate y$11_@3:TPoly = read x$9_@2.t
57
+ [8] Const mutate y$11:TPoly = read x$9_@2.t
58
return
59
}
60
compiler/forget/src/__tests__/fixtures/hir/type-test-primitive.expect.md
+4
-4
@@ -13,8 +13,8 @@ function component() {
13
14
```
15
bb0:
16
- [1] Const mutate x$3_@0:TPrimitive = 1
17
- [2] Const mutate y$4_@1:TPrimitive = 2
16
+ [1] Const mutate x$3:TPrimitive = 1
17
+ [2] Const mutate y$4:TPrimitive = 2
18
[3] Return
19
20
```
@@ -24,8 +24,8 @@ bb0:
24
```
25
function component(
26
) {
27
- [1] Const mutate x$3_@0:TPrimitive = 1
28
- [2] Const mutate y$4_@1:TPrimitive = 2
27
+ [1] Const mutate x$3:TPrimitive = 1
28
+ [2] Const mutate y$4:TPrimitive = 2
29
return
30
}
31
compiler/forget/src/__tests__/fixtures/hir/type-test-return-type-inference.expect.md
+12
-13
@@ -20,19 +20,18 @@ function component() {
20
bb0:
21
[1] Const mutate x$7_@0:TPrimitive = Call mutate foo$2:TFunction()
22
[2] Const mutate y$8_@1:TPrimitive = Call mutate foo$2:TFunction()
23
- [3] Const mutate $9_@2:TPrimitive = Binary read x$7_@0:TPrimitive > read y$8_@1:TPrimitive
24
- [4] If (read $9_@2:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
23
+ [3] Const mutate $9:TPrimitive = Binary read x$7_@0:TPrimitive > read y$8_@1:TPrimitive
24
+ [4] If (read $9:TPrimitive) then:bb2 else:bb1 fallthrough=bb1
25
bb2:
26
predecessor blocks: bb0
27
- [5] Const mutate z$10_@3:TObject = Object { }
27
+ [5] Const mutate z$10_@2:TObject = Object { }
28
[6] Goto bb1
29
bb1:
30
predecessor blocks: bb2 bb0
31
- [7] Const mutate z$12_@4:TPrimitive = Call mutate foo$2:TFunction()
31
+ [7] Const mutate z$12_@3:TPrimitive = Call mutate foo$2:TFunction()
32
[8] Return
33
-scope2 [3:4]:
33
+scope1 [2:3]:
34
- dependency: read x$7_@0:TPrimitive
35
- - dependency: read y$8_@1:TPrimitive
35
```
36
37
## Reactive Scopes
@@ -43,17 +42,17 @@ function component(
42
scope @0 [1:2] deps=[] {
43
[1] Const mutate x$7_@0:TPrimitive = Call mutate foo$2:TFunction()
44
}
46
- scope @1 [2:3] deps=[] {
45
+ scope @1 [2:3] deps=[read x$7_@0:TPrimitive] {
46
[2] Const mutate y$8_@1:TPrimitive = Call mutate foo$2:TFunction()
47
}
49
- [3] Const mutate $9_@2:TPrimitive = Binary read x$7_@0:TPrimitive > read y$8_@1:TPrimitive
50
- if (read $9_@2:TPrimitive) {
51
- scope @3 [5:6] deps=[] {
52
- [5] Const mutate z$10_@3:TObject = Object { }
48
+ [3] Const mutate $9:TPrimitive = Binary read x$7_@0:TPrimitive > read y$8_@1:TPrimitive
49
+ if (read $9:TPrimitive) {
50
+ scope @2 [5:6] deps=[] {
51
+ [5] Const mutate z$10_@2:TObject = Object { }
52
}
53
}
55
- scope @4 [7:8] deps=[] {
56
- [7] Const mutate z$12_@4:TPrimitive = Call mutate foo$2:TFunction()
54
+ scope @3 [7:8] deps=[] {
55
+ [7] Const mutate z$12_@3:TPrimitive = Call mutate foo$2:TFunction()
56
}
57
return
58
}