dillon1000/react

Commit

Support chained assignment expressions

Fixes codegen for chained assignment expressions. Previously each intermediate 
assignment would be generated independently _in addition_ to the final chained 
expression being emitted. We now emit a single chained expression, almost 
exactly matching the input except for expanding from `x += 1` into `x = x + 1`. 

There are two key changes: 

* Ensuring that assignment expressions always generate an lvalue, which is 
necessary for alias analysis to kick in, since it relies on the effect of the 
lvalue to know where to look for aliasing. 

* The above makes codegen think the entire assignment expression value is a 
temporary that can be emitted later, but that isn't true. The new 
PruneTemporaryLValue pass nulls out lvalues that are never read later, ensuring 
that codegen can eagerly emit the value instead of saving it as a temporary.
Browse files
Changed paths10 files
First-parent comparison
M compiler/forget/src/CompilerPipeline.ts ModifiedM compiler/forget/src/HIR/BuildHIR.ts ModifiedM compiler/forget/src/HIR/Codegen.ts ModifiedA compiler/forget/src/ReactiveScopes/PruneTemporaryLValues.ts AddedM compiler/forget/src/ReactiveScopes/index.ts ModifiedM compiler/forget/src/ReactiveScopes/visitors.ts ModifiedD compiler/forget/src/__tests__/fixtures/hir/_bug_chained-assignment-expressions.expect.md DeletedD compiler/forget/src/__tests__/fixtures/hir/_bug_chained-assignment-expressions.js DeletedA compiler/forget/src/__tests__/fixtures/hir/chained-assignment-expressions.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/chained-assignment-expressions.js Added
Patch

Files changed

Rendering syntax-highlighted changes…