@samitouri / QOS-React-2 / commits / 447f401f32

[be][tests] Remove all hir-tests (cleanup for ObjectShape stack)

--- +10 −1,698 lines [[insert impacc macro]] The ObjectShape stacks (#1350, #1358) used these tests to record changes in inferred types (and associated ObjectShapes), reference effects, and mutable ranges. Now that those PRs have landed, we can delete these tests. They are somewhat fragile (changing anytime HIR / printHIR is changed) and easily cause rebase/merge conflicts.

Mofei Zhang committed Mar 23, 2023 at 15:08 UTC 447f401f32594087e9fe312021ef04d2479f651c
38 files changed +318 -823
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-destruction-with-mutation.expect.md new
+41
@@ -0,0 +1,41 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function foo(props) {
6 + let x = [];
7 + x.push(props.bar);
8 + const _ = props.cond
9 + ? (({ x } = { x: {} }), ([x] = [[]]), x.push(props.foo))
10 + : null;
11 + console.log(_);
12 + mut(x);
13 + return x;
14 +}
15 +
16 +```
17 +
18 +## Code
19 +
20 +```javascript
21 +function foo(props) {
22 + const $ = React.unstable_useMemoCache(2);
23 + const c_0 = $[0] !== props;
24 + let x;
25 + if (c_0) {
26 + x = [];
27 + x.push(props.bar);
28 + const _ = props.cond ? (([x] = [[]]), x.push(props.foo)) : null;
29 +
30 + console.log(_);
31 + mut(x);
32 + $[0] = props;
33 + $[1] = x;
34 + } else {
35 + x = $[1];
36 + }
37 + return x;
38 +}
39 +
40 +```
41 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-destruction-with-mutation.js renamed
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-destruction.expect.md new
+46
@@ -0,0 +1,46 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function foo(props) {
6 + let x = [];
7 + x.push(props.bar);
8 + const _ = props.cond
9 + ? (({ x } = { x: {} }), ([x] = [[]]), x.push(props.foo))
10 + : null;
11 + console.log(_);
12 + return x;
13 +}
14 +
15 +```
16 +
17 +## Code
18 +
19 +```javascript
20 +function foo(props) {
21 + const $ = React.unstable_useMemoCache(4);
22 + const c_0 = $[0] !== props.bar;
23 + let x;
24 + if (c_0) {
25 + x = [];
26 + x.push(props.bar);
27 + $[0] = props.bar;
28 + $[1] = x;
29 + } else {
30 + x = $[1];
31 + }
32 + const c_2 = $[2] !== props;
33 + if (c_2) {
34 + const _ = props.cond ? (([x] = [[]]), x.push(props.foo)) : null;
35 +
36 + console.log(_);
37 + $[2] = props;
38 + $[3] = x;
39 + } else {
40 + x = $[3];
41 + }
42 + return x;
43 +}
44 +
45 +```
46 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-destruction.js renamed
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-with-mutation.expect.md new
+38
@@ -0,0 +1,38 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function foo(props) {
6 + let x = [];
7 + x.push(props.bar);
8 + const _ = props.cond ? ((x = {}), (x = []), x.push(props.foo)) : null;
9 + console.log(_);
10 + mut(x);
11 + return x;
12 +}
13 +
14 +```
15 +
16 +## Code
17 +
18 +```javascript
19 +function foo(props) {
20 + const $ = React.unstable_useMemoCache(2);
21 + const c_0 = $[0] !== props;
22 + let x;
23 + if (c_0) {
24 + x = [];
25 + x.push(props.bar);
26 + const _ = props.cond ? ((x = []), x.push(props.foo)) : null;
27 + console.log(_);
28 + mut(x);
29 + $[0] = props;
30 + $[1] = x;
31 + } else {
32 + x = $[1];
33 + }
34 + return x;
35 +}
36 +
37 +```
38 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-with-mutation.js renamed
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary.expect.md new
+43
@@ -0,0 +1,43 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function foo(props) {
6 + let x = [];
7 + x.push(props.bar);
8 + const _ = props.cond ? ((x = {}), (x = []), x.push(props.foo)) : null;
9 + console.log(_);
10 + return x;
11 +}
12 +
13 +```
14 +
15 +## Code
16 +
17 +```javascript
18 +function foo(props) {
19 + const $ = React.unstable_useMemoCache(4);
20 + const c_0 = $[0] !== props.bar;
21 + let x;
22 + if (c_0) {
23 + x = [];
24 + x.push(props.bar);
25 + $[0] = props.bar;
26 + $[1] = x;
27 + } else {
28 + x = $[1];
29 + }
30 + const c_2 = $[2] !== props;
31 + if (c_2) {
32 + const _ = props.cond ? ((x = []), x.push(props.foo)) : null;
33 + console.log(_);
34 + $[2] = props;
35 + $[3] = x;
36 + } else {
37 + x = $[3];
38 + }
39 + return x;
40 +}
41 +
42 +```
43 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary.js renamed
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-ternary-with-mutation.expect.md new
+42
@@ -0,0 +1,42 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function foo(props) {
6 + let x = [];
7 + x.push(props.bar);
8 + const _ = props.cond
9 + ? ((x = {}), (x = []), x.push(props.foo))
10 + : ((x = []), (x = []), x.push(props.bar));
11 + console.log(_);
12 + mut(x);
13 + return x;
14 +}
15 +
16 +```
17 +
18 +## Code
19 +
20 +```javascript
21 +function foo(props) {
22 + const $ = React.unstable_useMemoCache(2);
23 + const c_0 = $[0] !== props;
24 + let x;
25 + if (c_0) {
26 + x = [];
27 + x.push(props.bar);
28 + const _ = props.cond
29 + ? ((x = []), x.push(props.foo))
30 + : ((x = []), x.push(props.bar));
31 + console.log(_);
32 + mut(x);
33 + $[0] = props;
34 + $[1] = x;
35 + } else {
36 + x = $[1];
37 + }
38 + return x;
39 +}
40 +
41 +```
42 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-ternary-with-mutation.js renamed
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-ternary.expect.md new
+47
@@ -0,0 +1,47 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function foo(props) {
6 + let x = [];
7 + x.push(props.bar);
8 + const _ = props.cond
9 + ? ((x = {}), (x = []), x.push(props.foo))
10 + : ((x = []), (x = []), x.push(props.bar));
11 + console.log(_);
12 + return x;
13 +}
14 +
15 +```
16 +
17 +## Code
18 +
19 +```javascript
20 +function foo(props) {
21 + const $ = React.unstable_useMemoCache(4);
22 + const c_0 = $[0] !== props.bar;
23 + let x;
24 + if (c_0) {
25 + x = [];
26 + x.push(props.bar);
27 + $[0] = props.bar;
28 + $[1] = x;
29 + } else {
30 + x = $[1];
31 + }
32 + const c_2 = $[2] !== props;
33 + if (c_2) {
34 + const _ = props.cond
35 + ? ((x = []), x.push(props.foo))
36 + : ((x = []), x.push(props.bar));
37 + console.log(_);
38 + $[2] = props;
39 + $[3] = x;
40 + } else {
41 + x = $[3];
42 + }
43 + return x;
44 +}
45 +
46 +```
47 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-ternary.js renamed
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-with-mutation.expect.md new
+51
@@ -0,0 +1,51 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function foo(props) {
6 + let x = [];
7 + x.push(props.bar);
8 + if (props.cond) {
9 + x = {};
10 + x = [];
11 + x.push(props.foo);
12 + } else {
13 + x = [];
14 + x = [];
15 + x.push(props.bar);
16 + }
17 + mut(x);
18 + return x;
19 +}
20 +
21 +```
22 +
23 +## Code
24 +
25 +```javascript
26 +function foo(props) {
27 + const $ = React.unstable_useMemoCache(2);
28 + const c_0 = $[0] !== props;
29 + let x;
30 + if (c_0) {
31 + x = [];
32 + x.push(props.bar);
33 + if (props.cond) {
34 + x = [];
35 + x.push(props.foo);
36 + } else {
37 + x = [];
38 + x.push(props.bar);
39 + }
40 +
41 + mut(x);
42 + $[0] = props;
43 + $[1] = x;
44 + } else {
45 + x = $[1];
46 + }
47 + return x;
48 +}
49 +
50 +```
51 +
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-with-mutation.js renamed
compiler/forget/src/__tests__/fixtures/hir/array-at-closure.expect.md deleted
-47
@@ -1,47 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function Component(props) {
6 - const x = foo(props.x);
7 - const fn = function () {
8 - const arr = [...bar(props)];
9 - return arr.at(x);
10 - };
11 - const fnResult = fn();
12 - return fnResult;
13 -}
14 -
15 -```
16 -
17 -## HIR
18 -
19 -```javascript
20 -bb0 (block):
21 - [1] mutate $31:TFunction = Global foo
22 - [2] mutate $32 = LoadLocal read props$30
23 - [3] mutate $33 = PropertyLoad read $32.x
24 - [4] mutate $34 = Call read $31:TFunction(read $33)
25 - [5] store $36 = StoreLocal Const mutate x$35 = capture $34
26 - [6] mutate $37 = LoadLocal read props$30
27 - [7] mutate $38 = LoadLocal capture x$35
28 - [8] store $39[8:12]:TFunction = Function @deps[read $37,read $38]:
29 - bb0 (block):
30 - [1] mutate $49:TFunction = Global bar
31 - [2] mutate $50[2:4] = LoadLocal capture props$47[0:4]
32 - [3] mutate $51 = Call read $49:TFunction(mutate $50[2:4])
33 - [4] store $52:TObject<Array> = Array [...capture $51]
34 - [5] store $54:TObject<Array> = StoreLocal Const store arr$53:TObject<Array> = capture $52:TObject<Array>
35 - [6] mutate $55:TObject<Array> = LoadLocal capture arr$53:TObject<Array>
36 - [7] mutate $56:TFunction<<generated_0>> = PropertyLoad read $55:TObject<Array>.at
37 - [8] mutate $57 = LoadLocal capture x$48
38 - [9] mutate $58 = MethodCall read $55:TObject<Array>.read $56:TFunction<<generated_0>>(read $57)
39 - [10] Return freeze $58
40 - [9] store $41[9:12]:TFunction = StoreLocal Const mutate fn$40[9:12]:TFunction = capture $39[8:12]:TFunction
41 - [10] mutate $42[10:12]:TFunction = LoadLocal capture fn$40[9:12]:TFunction
42 - [11] mutate $43 = Call mutate $42[10:12]:TFunction()
43 - [12] store $45 = StoreLocal Const mutate fnResult$44 = capture $43
44 - [13] mutate $46 = LoadLocal capture fnResult$44
45 - [14] Return freeze $46
46 -```
47 -
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/array-at-closure.js deleted
-9
@@ -1,9 +0,0 @@
1 -function Component(props) {
2 - const x = foo(props.x);
3 - const fn = function () {
4 - const arr = [...bar(props)];
5 - return arr.at(x);
6 - };
7 - const fnResult = fn();
8 - return fnResult;
9 -}
compiler/forget/src/__tests__/fixtures/hir/array-at-effect.expect.md deleted
-38
@@ -1,38 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -// arrayInstance.at should have the following effects:
6 -// - read on arg0
7 -// - read on receiver
8 -// - mutate on lvalue
9 -function ArrayAtTest(props) {
10 - const arr = [foo(props.x)];
11 - const result = arr.at(bar(props.y));
12 - return result;
13 -}
14 -
15 -```
16 -
17 -## HIR
18 -
19 -```javascript
20 -bb0 (block):
21 - [1] mutate $20:TFunction = Global foo
22 - [2] mutate $21 = LoadLocal read props$19
23 - [3] mutate $22 = PropertyLoad read $21.x
24 - [4] mutate $23 = Call read $20:TFunction(read $22)
25 - [5] store $24:TObject<Array> = Array [capture $23]
26 - [6] store $26:TObject<Array> = StoreLocal Const store arr$25:TObject<Array> = capture $24:TObject<Array>
27 - [7] mutate $27:TObject<Array> = LoadLocal capture arr$25:TObject<Array>
28 - [8] mutate $28:TFunction<<generated_0>> = PropertyLoad read $27:TObject<Array>.at
29 - [9] mutate $29:TFunction = Global bar
30 - [10] mutate $30 = LoadLocal read props$19
31 - [11] mutate $31 = PropertyLoad read $30.y
32 - [12] mutate $32 = Call read $29:TFunction(read $31)
33 - [13] mutate $33 = MethodCall read $27:TObject<Array>.read $28:TFunction<<generated_0>>(read $32)
34 - [14] store $35 = StoreLocal Const mutate result$34 = capture $33
35 - [15] mutate $36 = LoadLocal capture result$34
36 - [16] Return freeze $36
37 -```
38 -
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/array-at-effect.js deleted
-9
@@ -1,9 +0,0 @@
1 -// arrayInstance.at should have the following effects:
2 -// - read on arg0
3 -// - read on receiver
4 -// - mutate on lvalue
5 -function ArrayAtTest(props) {
6 - const arr = [foo(props.x)];
7 - const result = arr.at(bar(props.y));
8 - return result;
9 -}
compiler/forget/src/__tests__/fixtures/hir/array-properties.expect.md deleted
-39
@@ -1,39 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function Component(props) {
6 - const a = [props.a, props.b, "hello"];
7 - const x = a.length;
8 - const y = a.push;
9 - return { a, x, y, z: a.concat };
10 -}
11 -
12 -```
13 -
14 -## HIR
15 -
16 -```javascript
17 -bb0 (block):
18 - [1] mutate $25 = LoadLocal read props$24
19 - [2] mutate $26 = PropertyLoad read $25.a
20 - [3] mutate $27 = LoadLocal read props$24
21 - [4] mutate $28 = PropertyLoad read $27.b
22 - [5] mutate $29:TPrimitive = "hello"
23 - [6] store $30:TObject<Array> = Array [read $26, read $28, read $29:TPrimitive]
24 - [7] store $32:TObject<Array> = StoreLocal Const store a$31:TObject<Array> = capture $30:TObject<Array>
25 - [8] mutate $33:TObject<Array> = LoadLocal capture a$31:TObject<Array>
26 - [9] mutate $34:TPrimitive = PropertyLoad read $33:TObject<Array>.length
27 - [10] store $36:TPrimitive = StoreLocal Const mutate x$35:TPrimitive = capture $34:TPrimitive
28 - [11] mutate $37:TObject<Array> = LoadLocal capture a$31:TObject<Array>
29 - [12] mutate $38:TFunction<<generated_2>> = PropertyLoad read $37:TObject<Array>.push
30 - [13] store $40:TFunction<<generated_2>> = StoreLocal Const mutate y$39:TFunction<<generated_2>> = capture $38:TFunction<<generated_2>>
31 - [14] mutate $41:TObject<Array> = LoadLocal capture a$31:TObject<Array>
32 - [15] mutate $42:TPrimitive = LoadLocal capture x$35:TPrimitive
33 - [16] mutate $43:TFunction<<generated_2>> = LoadLocal capture y$39:TFunction<<generated_2>>
34 - [17] mutate $44:TObject<Array> = LoadLocal capture a$31:TObject<Array>
35 - [18] mutate $45:TFunction<<generated_1>> = PropertyLoad read $44:TObject<Array>.concat
36 - [19] store $46:TObject<Object> = Object { a: capture $41:TObject<Array>, x: capture $42:TPrimitive, y: capture $43:TFunction<<generated_2>>, z: capture $45:TFunction<<generated_1>> }
37 - [20] Return freeze $46:TObject<Object>
38 -```
39 -
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/array-properties.js deleted
-6
@@ -1,6 +0,0 @@
1 -function Component(props) {
2 - const a = [props.a, props.b, "hello"];
3 - const x = a.length;
4 - const y = a.push;
5 - return { a, x, y, z: a.concat };
6 -}
compiler/forget/src/__tests__/fixtures/hir/array-property-call.expect.md deleted
-43
@@ -1,43 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function Component(props) {
6 - const a = [props.a, props.b, "hello"];
7 - const x = a.push(42);
8 - const y = a.at(props.c);
9 -
10 - return { a, x, y };
11 -}
12 -
13 -```
14 -
15 -## HIR
16 -
17 -```javascript
18 -bb0 (block):
19 - [1] mutate $28 = LoadLocal read props$27
20 - [2] mutate $29 = PropertyLoad read $28.a
21 - [3] mutate $30 = LoadLocal read props$27
22 - [4] mutate $31 = PropertyLoad read $30.b
23 - [5] mutate $32:TPrimitive = "hello"
24 - [6] store $33[6:12]:TObject<Array> = Array [read $29, read $31, read $32:TPrimitive]
25 - [7] store $35[7:12]:TObject<Array> = StoreLocal Const store a$34[7:12]:TObject<Array> = capture $33[6:12]:TObject<Array>
26 - [8] mutate $36[8:12]:TObject<Array> = LoadLocal capture a$34[7:12]:TObject<Array>
27 - [9] mutate $37[9:12]:TFunction<<generated_2>> = PropertyLoad read $36[8:12]:TObject<Array>.push
28 - [10] mutate $38:TPrimitive = 42
29 - [11] mutate $39:TPrimitive = MethodCall mutate $36[8:12]:TObject<Array>.read $37[9:12]:TFunction<<generated_2>>(read $38:TPrimitive)
30 - [12] store $41:TPrimitive = StoreLocal Const mutate x$40:TPrimitive = capture $39:TPrimitive
31 - [13] mutate $42:TObject<Array> = LoadLocal capture a$34[7:12]:TObject<Array>
32 - [14] mutate $43:TFunction<<generated_0>> = PropertyLoad read $42:TObject<Array>.at
33 - [15] mutate $44 = LoadLocal read props$27
34 - [16] mutate $45 = PropertyLoad read $44.c
35 - [17] mutate $46 = MethodCall read $42:TObject<Array>.read $43:TFunction<<generated_0>>(read $45)
36 - [18] store $48 = StoreLocal Const mutate y$47 = capture $46
37 - [19] mutate $49:TObject<Array> = LoadLocal capture a$34[7:12]:TObject<Array>
38 - [20] mutate $50:TPrimitive = LoadLocal capture x$40:TPrimitive
39 - [21] mutate $51 = LoadLocal capture y$47
40 - [22] store $52:TObject<Object> = Object { a: capture $49:TObject<Array>, x: capture $50:TPrimitive, y: capture $51 }
41 - [23] Return freeze $52:TObject<Object>
42 -```
43 -
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/array-property-call.js deleted
-7
@@ -1,7 +0,0 @@
1 -function Component(props) {
2 - const a = [props.a, props.b, "hello"];
3 - const x = a.push(42);
4 - const y = a.at(props.c);
5 -
6 - return { a, x, y };
7 -}
compiler/forget/src/__tests__/fixtures/hir/array-push-effect.expect.md deleted
-46
@@ -1,46 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -// arrayInstance.push should have the following effects:
6 -// - read on all args (rest parameter)
7 -// - mutate on receiver
8 -function Component(props) {
9 - const x = foo(props.x);
10 - const y = { y: props.y };
11 - const arr = [];
12 - arr.push({});
13 - arr.push(x, y);
14 - return arr;
15 -}
16 -
17 -```
18 -
19 -## HIR
20 -
21 -```javascript
22 -bb0 (block):
23 - [1] mutate $27:TFunction = Global foo
24 - [2] mutate $28 = LoadLocal read props$26
25 - [3] mutate $29 = PropertyLoad read $28.x
26 - [4] mutate $30 = Call read $27:TFunction(read $29)
27 - [5] store $32 = StoreLocal Const mutate x$31 = capture $30
28 - [6] mutate $33 = LoadLocal read props$26
29 - [7] mutate $34 = PropertyLoad read $33.y
30 - [8] store $35:TObject<Object> = Object { y: read $34 }
31 - [9] store $37:TObject<Object> = StoreLocal Const store y$36:TObject<Object> = capture $35:TObject<Object>
32 - [10] store $38[10:21]:TObject<Array> = Array []
33 - [11] store $40[11:21]:TObject<Array> = StoreLocal Const store arr$39[11:21]:TObject<Array> = capture $38[10:21]:TObject<Array>
34 - [12] mutate $41[12:21]:TObject<Array> = LoadLocal capture arr$39[11:21]:TObject<Array>
35 - [13] mutate $42[13:21]:TFunction<<generated_2>> = PropertyLoad read $41[12:21]:TObject<Array>.push
36 - [14] store $43:TObject<Object> = Object { }
37 - [15] mutate $44:TPrimitive = MethodCall mutate $41[12:21]:TObject<Array>.read $42[13:21]:TFunction<<generated_2>>(capture $43:TObject<Object>)
38 - [16] mutate $45[16:21]:TObject<Array> = LoadLocal capture arr$39[11:21]:TObject<Array>
39 - [17] mutate $46[17:21]:TFunction<<generated_2>> = PropertyLoad read $45[16:21]:TObject<Array>.push
40 - [18] mutate $47 = LoadLocal capture x$31
41 - [19] mutate $48:TObject<Object> = LoadLocal capture y$36:TObject<Object>
42 - [20] mutate $49:TPrimitive = MethodCall mutate $45[16:21]:TObject<Array>.read $46[17:21]:TFunction<<generated_2>>(capture $47, capture $48:TObject<Object>)
43 - [21] mutate $50:TObject<Array> = LoadLocal capture arr$39[11:21]:TObject<Array>
44 - [22] Return freeze $50:TObject<Array>
45 -```
46 -
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/array-push-effect.js deleted
-11
@@ -1,11 +0,0 @@
1 -// arrayInstance.push should have the following effects:
2 -// - read on all args (rest parameter)
3 -// - mutate on receiver
4 -function Component(props) {
5 - const x = foo(props.x);
6 - const y = { y: props.y };
7 - const arr = [];
8 - arr.push({});
9 - arr.push(x, y);
10 - return arr;
11 -}
compiler/forget/src/__tests__/fixtures/hir/infer-call-array-length.expect.md deleted
-26
@@ -1,26 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function Component() {
6 - let x = [];
7 - let y = x.length();
8 - return y;
9 -}
10 -
11 -```
12 -
13 -## HIR
14 -
15 -```javascript
16 -bb0 (block):
17 - [1] store $10[1:6]:TObject<Array> = Array []
18 - [2] store $12[2:6]:TObject<Array> = StoreLocal Const store x$11[2:6]:TObject<Array> = capture $10[1:6]:TObject<Array>
19 - [3] mutate $13[3:6]:TObject<Array> = LoadLocal capture x$11[2:6]:TObject<Array>
20 - [4] mutate $14[4:6]:TPrimitive = PropertyLoad read $13[3:6]:TObject<Array>.length
21 - [5] mutate $15 = MethodCall mutate $13[3:6]:TObject<Array>.read $14[4:6]:TPrimitive()
22 - [6] store $17 = StoreLocal Const mutate y$16 = capture $15
23 - [7] mutate $18 = LoadLocal capture y$16
24 - [8] Return freeze $18
25 -```
26 -
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/infer-call-array-length.js deleted
-5
@@ -1,5 +0,0 @@
1 -function Component() {
2 - let x = [];
3 - let y = x.length();
4 - return y;
5 -}
compiler/forget/src/__tests__/fixtures/hir/simple-array.expect.md deleted
-31
@@ -1,31 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function Component(props) {
6 - const x = props.a + 3;
7 - const y = foo(x);
8 - return [x, y];
9 -}
10 -
11 -```
12 -
13 -## HIR
14 -
15 -```javascript
16 -bb0 (block):
17 - [1] mutate $17 = LoadLocal read props$16
18 - [2] mutate $18:TPrimitive = PropertyLoad read $17.a
19 - [3] mutate $19:TPrimitive = 3
20 - [4] mutate $20:TPrimitive = Binary read $18:TPrimitive + read $19:TPrimitive
21 - [5] store $22:TPrimitive = StoreLocal Const mutate x$21:TPrimitive = read $20:TPrimitive
22 - [6] mutate $23:TFunction = Global foo
23 - [7] mutate $24:TPrimitive = LoadLocal read x$21:TPrimitive
24 - [8] mutate $25 = Call read $23:TFunction(read $24:TPrimitive)
25 - [9] store $27 = StoreLocal Const mutate y$26 = capture $25
26 - [10] mutate $28:TPrimitive = LoadLocal read x$21:TPrimitive
27 - [11] mutate $29 = LoadLocal capture y$26
28 - [12] store $30:TObject<Array> = Array [read $28:TPrimitive, capture $29]
29 - [13] Return freeze $30:TObject<Array>
30 -```
31 -
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/simple-array.js deleted
-5
@@ -1,5 +0,0 @@
1 -function Component(props) {
2 - const x = props.a + 3;
3 - const y = foo(x);
4 - return [x, y];
5 -}
compiler/forget/src/__tests__/fixtures/hir/simple-object.expect.md deleted
-31
@@ -1,31 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function Component(props) {
6 - const x = props.a + 3;
7 - const y = foo(x);
8 - return { x, y };
9 -}
10 -
11 -```
12 -
13 -## HIR
14 -
15 -```javascript
16 -bb0 (block):
17 - [1] mutate $17 = LoadLocal read props$16
18 - [2] mutate $18:TPrimitive = PropertyLoad read $17.a
19 - [3] mutate $19:TPrimitive = 3
20 - [4] mutate $20:TPrimitive = Binary read $18:TPrimitive + read $19:TPrimitive
21 - [5] store $22:TPrimitive = StoreLocal Const mutate x$21:TPrimitive = read $20:TPrimitive
22 - [6] mutate $23:TFunction = Global foo
23 - [7] mutate $24:TPrimitive = LoadLocal read x$21:TPrimitive
24 - [8] mutate $25 = Call read $23:TFunction(read $24:TPrimitive)
25 - [9] store $27 = StoreLocal Const mutate y$26 = capture $25
26 - [10] mutate $28:TPrimitive = LoadLocal read x$21:TPrimitive
27 - [11] mutate $29 = LoadLocal capture y$26
28 - [12] store $30:TObject<Object> = Object { x: read $28:TPrimitive, y: capture $29 }
29 - [13] Return freeze $30:TObject<Object>
30 -```
31 -
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/simple-object.js deleted
-5
@@ -1,5 +0,0 @@
1 -function Component(props) {
2 - const x = props.a + 3;
3 - const y = foo(x);
4 - return { x, y };
5 -}
compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-ternary-destruction-with-mutation.expect.md deleted
-67
@@ -1,67 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function foo(props) {
6 - let x = [];
7 - x.push(props.bar);
8 - const _ = props.cond
9 - ? (({ x } = { x: {} }), ([x] = [[]]), x.push(props.foo))
10 - : null;
11 - console.log(_);
12 - mut(x);
13 - return x;
14 -}
15 -
16 -```
17 -
18 -## HIR
19 -
20 -```javascript
21 -bb0 (block):
22 - [1] store $38[1:36]:TObject<Array> = Array []
23 - [2] store $40[2:36]:TObject<Array> = StoreLocal Let store x$39[2:36]:TObject<Array> = capture $38[1:36]:TObject<Array>
24 - [3] mutate $41[3:36]:TObject<Array> = LoadLocal capture x$39[2:36]:TObject<Array>
25 - [4] mutate $42[4:36]:TFunction<<generated_2>> = PropertyLoad read $41[3:36]:TObject<Array>.push
26 - [5] mutate $43 = LoadLocal read props$37
27 - [6] mutate $44 = PropertyLoad read $43.bar
28 - [7] mutate $45:TPrimitive = MethodCall mutate $41[3:36]:TObject<Array>.read $42[4:36]:TFunction<<generated_2>>(read $44)
29 - [8] Ternary test:bb2 fallthrough=bb1
30 -bb2 (value):
31 - predecessor blocks: bb0
32 - [9] mutate $46 = LoadLocal read props$37
33 - [10] mutate $47 = PropertyLoad read $46.cond
34 - [11] Branch (read $47) then:bb3 else:bb4
35 -bb3 (value):
36 - predecessor blocks: bb2
37 - [15] store $52[15:36]:TObject<Array> = Array []
38 - [16] store $53[16:36]:TObject<Array> = Array [capture $52[15:36]:TObject<Array>]
39 - [17] store $55[17:36] = Destructure Reassign [ mutate x$39[17:36] ] = capture $53[16:36]:TObject<Array>
40 - [18] mutate $56[18:36] = LoadLocal capture x$39[17:36]
41 - [19] mutate $57[19:36] = PropertyLoad read $56[18:36].push
42 - [20] mutate $58 = LoadLocal read props$37
43 - [21] mutate $59 = PropertyLoad read $58.foo
44 - [22] mutate $60[22:33] = MethodCall mutate $56[18:36].read $57[19:36](read $59)
45 - [23] store $62[23:33] = StoreLocal Const mutate $61[8:33] = capture $60[22:33]
46 - [24] Goto bb1
47 -bb4 (value):
48 - predecessor blocks: bb2
49 - [25] mutate $63[25:33]:TPrimitive = null
50 - [26] store $65[26:33]:TPrimitive = StoreLocal Const mutate $61[8:33] = read $63[25:33]:TPrimitive
51 - [27] Goto bb1
52 -bb1 (block):
53 - predecessor blocks: bb3 bb4
54 - $68[8:33]:TPhi: phi(bb3: $61, bb4: $64)
55 - x$39[2:36]:TPhi: phi(bb3: x$39, bb4: x$39)
56 - [28] store $67[28:33] = StoreLocal Const mutate _$66[28:33] = capture $61[8:33]
57 - [29] mutate $69 = Global console
58 - [30] mutate $70 = PropertyLoad read $69.log
59 - [31] mutate $71[31:33] = LoadLocal capture _$66[28:33]
60 - [32] mutate $72 = MethodCall read $69.read $70(mutate $71[31:33])
61 - [33] mutate $73:TFunction = Global mut
62 - [34] mutate $74[34:36] = LoadLocal capture x$39[2:36]
63 - [35] mutate $76 = Call read $73:TFunction(mutate $74[34:36])
64 - [36] mutate $77 = LoadLocal capture x$39[2:36]
65 - [37] Return freeze $77
66 -```
67 -
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-ternary-destruction.expect.md deleted
-63
@@ -1,63 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function foo(props) {
6 - let x = [];
7 - x.push(props.bar);
8 - const _ = props.cond
9 - ? (({ x } = { x: {} }), ([x] = [[]]), x.push(props.foo))
10 - : null;
11 - console.log(_);
12 - return x;
13 -}
14 -
15 -```
16 -
17 -## HIR
18 -
19 -```javascript
20 -bb0 (block):
21 - [1] store $35[1:8]:TObject<Array> = Array []
22 - [2] store $37[2:8]:TObject<Array> = StoreLocal Let store x$36[2:8]:TObject<Array> = capture $35[1:8]:TObject<Array>
23 - [3] mutate $38[3:8]:TObject<Array> = LoadLocal capture x$36[2:8]:TObject<Array>
24 - [4] mutate $39[4:8]:TFunction<<generated_2>> = PropertyLoad read $38[3:8]:TObject<Array>.push
25 - [5] mutate $40 = LoadLocal read props$34
26 - [6] mutate $41 = PropertyLoad read $40.bar
27 - [7] mutate $42:TPrimitive = MethodCall mutate $38[3:8]:TObject<Array>.read $39[4:8]:TFunction<<generated_2>>(read $41)
28 - [8] Ternary test:bb2 fallthrough=bb1
29 -bb2 (value):
30 - predecessor blocks: bb0
31 - [9] mutate $43 = LoadLocal read props$34
32 - [10] mutate $44 = PropertyLoad read $43.cond
33 - [11] Branch (read $44) then:bb3 else:bb4
34 -bb3 (value):
35 - predecessor blocks: bb2
36 - [15] store $49[15:23]:TObject<Array> = Array []
37 - [16] store $50[16:23]:TObject<Array> = Array [capture $49[15:23]:TObject<Array>]
38 - [17] store $52[17:23] = Destructure Reassign [ mutate x$36[17:23] ] = capture $50[16:23]:TObject<Array>
39 - [18] mutate $53[18:23] = LoadLocal capture x$36[17:23]
40 - [19] mutate $54[19:23] = PropertyLoad read $53[18:23].push
41 - [20] mutate $55 = LoadLocal read props$34
42 - [21] mutate $56 = PropertyLoad read $55.foo
43 - [22] mutate $57[22:33] = MethodCall mutate $53[18:23].read $54[19:23](read $56)
44 - [23] store $59[23:33] = StoreLocal Const mutate $58[8:33] = capture $57[22:33]
45 - [24] Goto bb1
46 -bb4 (value):
47 - predecessor blocks: bb2
48 - [25] mutate $60[25:33]:TPrimitive = null
49 - [26] store $62[26:33]:TPrimitive = StoreLocal Const mutate $58[8:33] = read $60[25:33]:TPrimitive
50 - [27] Goto bb1
51 -bb1 (block):
52 - predecessor blocks: bb3 bb4
53 - $65[8:33]:TPhi: phi(bb3: $58, bb4: $61)
54 - x$36:TPhi: phi(bb3: x$36, bb4: x$36)
55 - [28] store $64[28:33] = StoreLocal Const mutate _$63[28:33] = capture $58[8:33]
56 - [29] mutate $66 = Global console
57 - [30] mutate $67 = PropertyLoad read $66.log
58 - [31] mutate $68[31:33] = LoadLocal capture _$63[28:33]
59 - [32] mutate $69 = MethodCall read $66.read $67(mutate $68[31:33])
60 - [33] mutate $70 = LoadLocal capture x$36
61 - [34] Return freeze $70
62 -```
63 -
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-ternary-with-mutation.expect.md deleted
-64
@@ -1,64 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function foo(props) {
6 - let x = [];
7 - x.push(props.bar);
8 - const _ = props.cond ? ((x = {}), (x = []), x.push(props.foo)) : null;
9 - console.log(_);
10 - mut(x);
11 - return x;
12 -}
13 -
14 -```
15 -
16 -## HIR
17 -
18 -```javascript
19 -bb0 (block):
20 - [1] store $36[1:34]:TObject<Array> = Array []
21 - [2] store $38[2:34]:TObject<Array> = StoreLocal Let store x$37[2:34]:TObject<Array> = capture $36[1:34]:TObject<Array>
22 - [3] mutate $39[3:34]:TObject<Array> = LoadLocal capture x$37[2:34]:TObject<Array>
23 - [4] mutate $40[4:34]:TFunction<<generated_2>> = PropertyLoad read $39[3:34]:TObject<Array>.push
24 - [5] mutate $41 = LoadLocal read props$35
25 - [6] mutate $42 = PropertyLoad read $41.bar
26 - [7] mutate $43:TPrimitive = MethodCall mutate $39[3:34]:TObject<Array>.read $40[4:34]:TFunction<<generated_2>>(read $42)
27 - [8] Ternary test:bb2 fallthrough=bb1
28 -bb2 (value):
29 - predecessor blocks: bb0
30 - [9] mutate $44 = LoadLocal read props$35
31 - [10] mutate $45 = PropertyLoad read $44.cond
32 - [11] Branch (read $45) then:bb3 else:bb4
33 -bb3 (value):
34 - predecessor blocks: bb2
35 - [14] store $49[14:34]:TObject<Array> = Array []
36 - [15] store $51[15:34]:TObject<Array> = StoreLocal Reassign store x$37[15:34]:TObject<Array> = capture $49[14:34]:TObject<Array>
37 - [16] mutate $52[16:34]:TObject<Array> = LoadLocal capture x$37[15:34]:TObject<Array>
38 - [17] mutate $53[17:34]:TFunction<<generated_2>> = PropertyLoad read $52[16:34]:TObject<Array>.push
39 - [18] mutate $54 = LoadLocal read props$35
40 - [19] mutate $55 = PropertyLoad read $54.foo
41 - [20] mutate $56[20:31]:TPrimitive = MethodCall mutate $52[16:34]:TObject<Array>.read $53[17:34]:TFunction<<generated_2>>(read $55)
42 - [21] store $58[21:31]:TPrimitive = StoreLocal Const mutate $57[8:31]:TPrimitive = capture $56[20:31]:TPrimitive
43 - [22] Goto bb1
44 -bb4 (value):
45 - predecessor blocks: bb2
46 - [23] mutate $59[23:31]:TPrimitive = null
47 - [24] store $61[24:31]:TPrimitive = StoreLocal Const mutate $57[8:31]:TPrimitive = read $59[23:31]:TPrimitive
48 - [25] Goto bb1
49 -bb1 (block):
50 - predecessor blocks: bb3 bb4
51 - $64[8:31]:TPrimitive: phi(bb3: $57, bb4: $60)
52 - x$37[2:34]:TObject<Array>: phi(bb3: x$37, bb4: x$37)
53 - [26] store $63[26:31] = StoreLocal Const mutate _$62[26:31] = capture $57[8:31]:TPrimitive
54 - [27] mutate $65 = Global console
55 - [28] mutate $66 = PropertyLoad read $65.log
56 - [29] mutate $67[29:31] = LoadLocal capture _$62[26:31]
57 - [30] mutate $68 = MethodCall read $65.read $66(mutate $67[29:31])
58 - [31] mutate $69:TFunction = Global mut
59 - [32] mutate $70[32:34] = LoadLocal capture x$37[2:34]
60 - [33] mutate $72 = Call read $69:TFunction(mutate $70[32:34])
61 - [34] mutate $73 = LoadLocal capture x$37[2:34]
62 - [35] Return freeze $73
63 -```
64 -
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-ternary.expect.md deleted
-60
@@ -1,60 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function foo(props) {
6 - let x = [];
7 - x.push(props.bar);
8 - const _ = props.cond ? ((x = {}), (x = []), x.push(props.foo)) : null;
9 - console.log(_);
10 - return x;
11 -}
12 -
13 -```
14 -
15 -## HIR
16 -
17 -```javascript
18 -bb0 (block):
19 - [1] store $33[1:8]:TObject<Array> = Array []
20 - [2] store $35[2:8]:TObject<Array> = StoreLocal Let store x$34[2:8]:TObject<Array> = capture $33[1:8]:TObject<Array>
21 - [3] mutate $36[3:8]:TObject<Array> = LoadLocal capture x$34[2:8]:TObject<Array>
22 - [4] mutate $37[4:8]:TFunction<<generated_2>> = PropertyLoad read $36[3:8]:TObject<Array>.push
23 - [5] mutate $38 = LoadLocal read props$32
24 - [6] mutate $39 = PropertyLoad read $38.bar
25 - [7] mutate $40:TPrimitive = MethodCall mutate $36[3:8]:TObject<Array>.read $37[4:8]:TFunction<<generated_2>>(read $39)
26 - [8] Ternary test:bb2 fallthrough=bb1
27 -bb2 (value):
28 - predecessor blocks: bb0
29 - [9] mutate $41 = LoadLocal read props$32
30 - [10] mutate $42 = PropertyLoad read $41.cond
31 - [11] Branch (read $42) then:bb3 else:bb4
32 -bb3 (value):
33 - predecessor blocks: bb2
34 - [14] store $46[14:21]:TObject<Array> = Array []
35 - [15] store $48[15:21]:TObject<Array> = StoreLocal Reassign store x$34[15:21]:TObject<Array> = capture $46[14:21]:TObject<Array>
36 - [16] mutate $49[16:21]:TObject<Array> = LoadLocal capture x$34[15:21]:TObject<Array>
37 - [17] mutate $50[17:21]:TFunction<<generated_2>> = PropertyLoad read $49[16:21]:TObject<Array>.push
38 - [18] mutate $51 = LoadLocal read props$32
39 - [19] mutate $52 = PropertyLoad read $51.foo
40 - [20] mutate $53[20:31]:TPrimitive = MethodCall mutate $49[16:21]:TObject<Array>.read $50[17:21]:TFunction<<generated_2>>(read $52)
41 - [21] store $55[21:31]:TPrimitive = StoreLocal Const mutate $54[8:31]:TPrimitive = capture $53[20:31]:TPrimitive
42 - [22] Goto bb1
43 -bb4 (value):
44 - predecessor blocks: bb2
45 - [23] mutate $56[23:31]:TPrimitive = null
46 - [24] store $58[24:31]:TPrimitive = StoreLocal Const mutate $54[8:31]:TPrimitive = read $56[23:31]:TPrimitive
47 - [25] Goto bb1
48 -bb1 (block):
49 - predecessor blocks: bb3 bb4
50 - $61[8:31]:TPrimitive: phi(bb3: $54, bb4: $57)
51 - x$34:TObject<Array>: phi(bb3: x$34, bb4: x$34)
52 - [26] store $60[26:31] = StoreLocal Const mutate _$59[26:31] = capture $54[8:31]:TPrimitive
53 - [27] mutate $62 = Global console
54 - [28] mutate $63 = PropertyLoad read $62.log
55 - [29] mutate $64[29:31] = LoadLocal capture _$59[26:31]
56 - [30] mutate $65 = MethodCall read $62.read $63(mutate $64[29:31])
57 - [31] mutate $66 = LoadLocal capture x$34
58 - [32] Return freeze $66
59 -```
60 -
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-unconditional-ternary-with-mutation.expect.md deleted
-72
@@ -1,72 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function foo(props) {
6 - let x = [];
7 - x.push(props.bar);
8 - const _ = props.cond
9 - ? ((x = {}), (x = []), x.push(props.foo))
10 - : ((x = []), (x = []), x.push(props.bar));
11 - console.log(_);
12 - mut(x);
13 - return x;
14 -}
15 -
16 -```
17 -
18 -## HIR
19 -
20 -```javascript
21 -bb0 (block):
22 - [1] store $44[1:8]:TObject<Array> = Array []
23 - [2] store $46[2:8]:TObject<Array> = StoreLocal Let store x$45[2:42]:TObject<Array> = capture $44[1:8]:TObject<Array>
24 - [3] mutate $47[3:8]:TObject<Array> = LoadLocal capture x$45[2:42]:TObject<Array>
25 - [4] mutate $48[4:8]:TFunction<<generated_2>> = PropertyLoad read $47[3:8]:TObject<Array>.push
26 - [5] mutate $49 = LoadLocal read props$43
27 - [6] mutate $50 = PropertyLoad read $49.bar
28 - [7] mutate $51:TPrimitive = MethodCall mutate $47[3:8]:TObject<Array>.read $48[4:8]:TFunction<<generated_2>>(read $50)
29 - [8] Ternary test:bb2 fallthrough=bb1
30 -bb2 (value):
31 - predecessor blocks: bb0
32 - [9] mutate $52 = LoadLocal read props$43
33 - [10] mutate $53 = PropertyLoad read $52.cond
34 - [11] Branch (read $53) then:bb3 else:bb4
35 -bb3 (value):
36 - predecessor blocks: bb2
37 - [14] store $57[14:42]:TObject<Array> = Array []
38 - [15] store $59[15:42]:TObject<Array> = StoreLocal Reassign store x$45[15:42]:TObject<Array> = capture $57[14:42]:TObject<Array>
39 - [16] mutate $60[16:42]:TObject<Array> = LoadLocal capture x$45[15:42]:TObject<Array>
40 - [17] mutate $61[17:42]:TFunction<<generated_2>> = PropertyLoad read $60[16:42]:TObject<Array>.push
41 - [18] mutate $62 = LoadLocal read props$43
42 - [19] mutate $63 = PropertyLoad read $62.foo
43 - [20] mutate $64[20:39]:TPrimitive = MethodCall mutate $60[16:42]:TObject<Array>.read $61[17:42]:TFunction<<generated_2>>(read $63)
44 - [21] store $66[21:39]:TPrimitive = StoreLocal Const mutate $65[8:39]:TPrimitive = capture $64[20:39]:TPrimitive
45 - [22] Goto bb1
46 -bb4 (value):
47 - predecessor blocks: bb2
48 - [25] store $70[25:42]:TObject<Array> = Array []
49 - [26] store $72[26:42]:TObject<Array> = StoreLocal Reassign store x$45[26:42]:TObject<Array> = capture $70[25:42]:TObject<Array>
50 - [27] mutate $73[27:42]:TObject<Array> = LoadLocal capture x$45[26:42]:TObject<Array>
51 - [28] mutate $74[28:42]:TFunction<<generated_2>> = PropertyLoad read $73[27:42]:TObject<Array>.push
52 - [29] mutate $75 = LoadLocal read props$43
53 - [30] mutate $76 = PropertyLoad read $75.bar
54 - [31] mutate $77[31:39]:TPrimitive = MethodCall mutate $73[27:42]:TObject<Array>.read $74[28:42]:TFunction<<generated_2>>(read $76)
55 - [32] store $79[32:39]:TPrimitive = StoreLocal Const mutate $65[8:39]:TPrimitive = capture $77[31:39]:TPrimitive
56 - [33] Goto bb1
57 -bb1 (block):
58 - predecessor blocks: bb3 bb4
59 - $82[8:39]:TPrimitive: phi(bb3: $65, bb4: $78)
60 - x$45[15:42]:TObject<Array>: phi(bb3: x$45, bb4: x$45)
61 - [34] store $81[34:39] = StoreLocal Const mutate _$80[34:39] = capture $65[8:39]:TPrimitive
62 - [35] mutate $83 = Global console
63 - [36] mutate $84 = PropertyLoad read $83.log
64 - [37] mutate $85[37:39] = LoadLocal capture _$80[34:39]
65 - [38] mutate $86 = MethodCall read $83.read $84(mutate $85[37:39])
66 - [39] mutate $87:TFunction = Global mut
67 - [40] mutate $88[40:42] = LoadLocal capture x$45[15:42]
68 - [41] mutate $90 = Call read $87:TFunction(mutate $88[40:42])
69 - [42] mutate $91 = LoadLocal capture x$45[15:42]
70 - [43] Return freeze $91
71 -```
72 -
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-unconditional-ternary.expect.md deleted
-68
@@ -1,68 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function foo(props) {
6 - let x = [];
7 - x.push(props.bar);
8 - const _ = props.cond
9 - ? ((x = {}), (x = []), x.push(props.foo))
10 - : ((x = []), (x = []), x.push(props.bar));
11 - console.log(_);
12 - return x;
13 -}
14 -
15 -```
16 -
17 -## HIR
18 -
19 -```javascript
20 -bb0 (block):
21 - [1] store $41[1:8]:TObject<Array> = Array []
22 - [2] store $43[2:8]:TObject<Array> = StoreLocal Let store x$42[2:8]:TObject<Array> = capture $41[1:8]:TObject<Array>
23 - [3] mutate $44[3:8]:TObject<Array> = LoadLocal capture x$42[2:8]:TObject<Array>
24 - [4] mutate $45[4:8]:TFunction<<generated_2>> = PropertyLoad read $44[3:8]:TObject<Array>.push
25 - [5] mutate $46 = LoadLocal read props$40
26 - [6] mutate $47 = PropertyLoad read $46.bar
27 - [7] mutate $48:TPrimitive = MethodCall mutate $44[3:8]:TObject<Array>.read $45[4:8]:TFunction<<generated_2>>(read $47)
28 - [8] Ternary test:bb2 fallthrough=bb1
29 -bb2 (value):
30 - predecessor blocks: bb0
31 - [9] mutate $49 = LoadLocal read props$40
32 - [10] mutate $50 = PropertyLoad read $49.cond
33 - [11] Branch (read $50) then:bb3 else:bb4
34 -bb3 (value):
35 - predecessor blocks: bb2
36 - [14] store $54[14:21]:TObject<Array> = Array []
37 - [15] store $56[15:21]:TObject<Array> = StoreLocal Reassign store x$42[15:21]:TObject<Array> = capture $54[14:21]:TObject<Array>
38 - [16] mutate $57[16:21]:TObject<Array> = LoadLocal capture x$42[15:21]:TObject<Array>
39 - [17] mutate $58[17:21]:TFunction<<generated_2>> = PropertyLoad read $57[16:21]:TObject<Array>.push
40 - [18] mutate $59 = LoadLocal read props$40
41 - [19] mutate $60 = PropertyLoad read $59.foo
42 - [20] mutate $61[20:39]:TPrimitive = MethodCall mutate $57[16:21]:TObject<Array>.read $58[17:21]:TFunction<<generated_2>>(read $60)
43 - [21] store $63[21:39]:TPrimitive = StoreLocal Const mutate $62[8:39]:TPrimitive = capture $61[20:39]:TPrimitive
44 - [22] Goto bb1
45 -bb4 (value):
46 - predecessor blocks: bb2
47 - [25] store $67[25:32]:TObject<Array> = Array []
48 - [26] store $69[26:32]:TObject<Array> = StoreLocal Reassign store x$42[26:32]:TObject<Array> = capture $67[25:32]:TObject<Array>
49 - [27] mutate $70[27:32]:TObject<Array> = LoadLocal capture x$42[26:32]:TObject<Array>
50 - [28] mutate $71[28:32]:TFunction<<generated_2>> = PropertyLoad read $70[27:32]:TObject<Array>.push
51 - [29] mutate $72 = LoadLocal read props$40
52 - [30] mutate $73 = PropertyLoad read $72.bar
53 - [31] mutate $74[31:39]:TPrimitive = MethodCall mutate $70[27:32]:TObject<Array>.read $71[28:32]:TFunction<<generated_2>>(read $73)
54 - [32] store $76[32:39]:TPrimitive = StoreLocal Const mutate $62[8:39]:TPrimitive = capture $74[31:39]:TPrimitive
55 - [33] Goto bb1
56 -bb1 (block):
57 - predecessor blocks: bb3 bb4
58 - $79[8:39]:TPrimitive: phi(bb3: $62, bb4: $75)
59 - x$42:TObject<Array>: phi(bb3: x$42, bb4: x$42)
60 - [34] store $78[34:39] = StoreLocal Const mutate _$77[34:39] = capture $62[8:39]:TPrimitive
61 - [35] mutate $80 = Global console
62 - [36] mutate $81 = PropertyLoad read $80.log
63 - [37] mutate $82[37:39] = LoadLocal capture _$77[34:39]
64 - [38] mutate $83 = MethodCall read $80.read $81(mutate $82[37:39])
65 - [39] mutate $84 = LoadLocal capture x$42
66 - [40] Return freeze $84
67 -```
68 -
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/ssa-renaming-unconditional-with-mutation.expect.md deleted
-66
@@ -1,66 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -function foo(props) {
6 - let x = [];
7 - x.push(props.bar);
8 - if (props.cond) {
9 - x = {};
10 - x = [];
11 - x.push(props.foo);
12 - } else {
13 - x = [];
14 - x = [];
15 - x.push(props.bar);
16 - }
17 - mut(x);
18 - return x;
19 -}
20 -
21 -```
22 -
23 -## HIR
24 -
25 -```javascript
26 -bb0 (block):
27 - [1] store $35[1:8]:TObject<Array> = Array []
28 - [2] store $37[2:8]:TObject<Array> = StoreLocal Let store x$36[2:34]:TObject<Array> = capture $35[1:8]:TObject<Array>
29 - [3] mutate $38[3:8]:TObject<Array> = LoadLocal capture x$36[2:34]:TObject<Array>
30 - [4] mutate $39[4:8]:TFunction<<generated_2>> = PropertyLoad read $38[3:8]:TObject<Array>.push
31 - [5] mutate $40 = LoadLocal read props$34
32 - [6] mutate $41 = PropertyLoad read $40.bar
33 - [7] mutate $42:TPrimitive = MethodCall mutate $38[3:8]:TObject<Array>.read $39[4:8]:TFunction<<generated_2>>(read $41)
34 - [8] mutate $43 = LoadLocal read props$34
35 - [9] mutate $44 = PropertyLoad read $43.cond
36 - [10] If (read $44) then:bb2 else:bb3 fallthrough=bb1
37 -bb2 (block):
38 - predecessor blocks: bb0
39 - [13] store $48[13:34]:TObject<Array> = Array []
40 - [14] store $50[14:34]:TObject<Array> = StoreLocal Reassign store x$36[14:34]:TObject<Array> = capture $48[13:34]:TObject<Array>
41 - [15] mutate $51[15:34]:TObject<Array> = LoadLocal capture x$36[14:34]:TObject<Array>
42 - [16] mutate $52[16:34]:TFunction<<generated_2>> = PropertyLoad read $51[15:34]:TObject<Array>.push
43 - [17] mutate $53 = LoadLocal read props$34
44 - [18] mutate $54 = PropertyLoad read $53.foo
45 - [19] mutate $55:TPrimitive = MethodCall mutate $51[15:34]:TObject<Array>.read $52[16:34]:TFunction<<generated_2>>(read $54)
46 - [20] Goto bb1
47 -bb3 (block):
48 - predecessor blocks: bb0
49 - [23] store $59[23:34]:TObject<Array> = Array []
50 - [24] store $61[24:34]:TObject<Array> = StoreLocal Reassign store x$36[24:34]:TObject<Array> = capture $59[23:34]:TObject<Array>
51 - [25] mutate $62[25:34]:TObject<Array> = LoadLocal capture x$36[24:34]:TObject<Array>
52 - [26] mutate $63[26:34]:TFunction<<generated_2>> = PropertyLoad read $62[25:34]:TObject<Array>.push
53 - [27] mutate $64 = LoadLocal read props$34
54 - [28] mutate $65 = PropertyLoad read $64.bar
55 - [29] mutate $66:TPrimitive = MethodCall mutate $62[25:34]:TObject<Array>.read $63[26:34]:TFunction<<generated_2>>(read $65)
56 - [30] Goto bb1
57 -bb1 (block):
58 - predecessor blocks: bb2 bb3
59 - x$36[14:34]:TObject<Array>: phi(bb2: x$36, bb3: x$36)
60 - [31] mutate $67:TFunction = Global mut
61 - [32] mutate $68[32:34] = LoadLocal capture x$36[14:34]
62 - [33] mutate $70 = Call read $67:TFunction(mutate $68[32:34])
63 - [34] mutate $71 = LoadLocal capture x$36[14:34]
64 - [35] Return freeze $71
65 -```
66 -
\ No newline at end of file
compiler/forget/src/__tests__/test-utils/generateTestsFromFixtures.ts
+10 -5
@@ -53,15 +53,20 @@ export default function generateTestsFromFixtures(
53 }
54 ) => string
55 ) {
56 - const files = fs.readdirSync(fixturesPath);
56 + let files: Array<string>;
57 + try {
58 + files = fs.readdirSync(fixturesPath);
59 + } catch (e) {
60 + if (e.code === "ENOENT") {
61 + files = [];
62 + } else {
63 + throw e;
64 + }
65 + }
66 const fixtures = matchInputOutputFixtures(files, fixturesPath);
67
68 const relativeFixturesPath = path.relative(PROJECT_ROOT, fixturesPath);
69 describe(relativeFixturesPath, () => {
61 - test("has input fixtures", () => {
62 - expect(fixtures.size).toBeGreaterThan(0);
63 - });
64 -
70 test("has a consistent extension for input fixtures", () => {
71 const extensions = Array.from(
72 new Set(