dillon1000/react

Commit

Add instructions for UpdateExpression variants

Adds new instructions to accurately model UpdateExpression semantics, since 
`x++` is un-intuitively not the same as `x = x + 1`. There are a few different 
ways to model the combination of prefix/postfix and increment/decrement: 

* One instruction for all combinations of prefix/postfix and 
increment/decrement, eg 'UpdateExpression' 

* Instructions for Increment/Decrement, each with a property to distinguish 
prefix/postfix 

* Instructions for Prefix/Postfix, each with aproperty to distinguish 
increment/decrement. 

I chose the latter, `PrefixUpdate` and `PostfixUpdate`, because it keeps the 
number of new instructions minimal while keeping separate instructions for the 
most important distinction: whether the result of the instruction is the value 
before applying the operation or after. I'm open to suggestions about this 
though. 

A few quick notes: 

* Constant propagation is supported but only for numbers (we don't support 
bigint yet anyway) 

* LeaveSSA needs to know about these instructions since their presence requires 
making the original variable declaration Let, not Const. 

* EnterSSA mapped lvalues before rvalues, which is out of order but didn't 
previously matter. I just had to flip the order and everything worked.
Browse files
Changed paths22 files
First-parent comparison
M compiler/forget/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/HIR/HIR.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/HIR/PrintHIR.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/HIR/visitors.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/Optimization/ConstantPropagation.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/Optimization/DeadCodeElimination.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/ReactiveScopes/InferReactiveScopeVariables.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/ReactiveScopes/PruneNonEscapingScopes.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/SSA/EnterSSA.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/SSA/LeaveSSA.ts ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/TypeInference/InferTypes.ts ModifiedA compiler/forget/packages/babel-plugin-react-forget/src/__tests__/e2e/update-expressions.e2e.js AddedM compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/dce-loop.expect.md ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-kitchensink.expect.md ModifiedM compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-for.expect.md ModifiedA compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/update-expression-constant-propagation.expect.md AddedA compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/update-expression-constant-propagation.js AddedA compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/update-expression-in-sequence.expect.md AddedA compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/update-expression-in-sequence.js AddedM compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/update-expression.expect.md Modified
Patch

Files changed

Rendering syntax-highlighted changes…