Files
react/compiler
Joe Savona ca9d49090a New destructuring representation modeled on StoreLocal
Changes to explicitly model destructuring (array and object patterns), expanding 
support to include rest elements and preserving destructuring through the 
output. The new "Destructure" instruction is similar to "StoreLocal" but has a 
pattern instead of a place. For now each level of nested array/object patterns 
creates a separate destructure instruction, which ensures we have a temporary 
Place to talk about the intermediate array/object and its type/effects etc. 
Example: 

``` 

// INPUT 

const [x, {y}, ...z] = a; // yay rest elements work now! 

// HIR 

[1] <unknown> $2 = LoadLocal a$1 

[2] <unknown> $6 = Destructure Const [ <unknown> x$3, <unknown> $4, ...<unknown> 
z$5 ] = <unknown> $2 

[3] <unknown> $8 = Destructure Const { y: <unknown> y$8 } = <unknown> $4 

// OUTPUT 

const [x, t0, ...z] = a; 

const {y} = t0; 

``` 

Note that we can still collapse to a single destructure statement during 
codegen, independently of whether we have separate instructions internally. For 
now i'm going w the simple approach of emitting multiple statements in codegen 
(the code will very likely get further rewritten by downstream babel passes 
anyway). 

Also, I don't love the "if StoreLocal/Destructure else ..." pattern that the 
StoreLocal created and that this PR entrenches. As discussed w @gsathya offline, 
the long-term direction will be to add a separate visitor, roughly 
`eachLValue()` and `eachOperand()` so that we can treat all instructions the 
same. Existing Instruction.lvalue will go away and become a property of the 
other types of instructions.
2023-03-03 17:09:25 -08:00
..
2024-03-25 10:39:47 +00:00
2024-03-25 10:39:47 +00:00
2022-11-15 13:24:14 -05:00
2024-03-25 10:39:47 +00:00
2024-03-25 10:39:47 +00:00
2024-03-25 10:39:47 +00:00