dillon1000/react
Commit
Browse files [hir] Wire up object method lowering and codegen
Object methods are lowered to functions and added to ObjectExpression. The codegen is interesting because we shouldn't emit code that lowers the object method into a separate statement and then stores it into an object expression. An shorthand object method has different semantics than an object method using the function syntax, so we need to preserve the shorthand object method syntax in the generated code. To do this, we don't immediately generate an AST node for the ObjectMethod but instead store it in a side table during codegen. Only when emitting code for an ObjectExpression, we lookup this side table and emit the object method inline in the body.
Changed paths24 files
First-parent comparisoncompiler/packages/babel-plugin-react-forget/src/HIR/BuildHIR.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/HIR/FindContextIdentifiers.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/HIR/HIR.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/HIR/MergeConsecutiveBlocks.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/HIR/PrintHIR.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/HIR/visitors.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/Inference/AnalyseFunctions.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/Inference/InferReferenceEffects.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/Optimization/ConstantPropagation.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/Optimization/DeadCodeElimination.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/InferReactiveScopeVariables.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PruneNonEscapingScopes.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/SSA/EliminateRedundantPhi.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/SSA/EnterSSA.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/TypeInference/InferTypes.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/Validation/ValidateFrozenLambdas.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/Validation/ValidateNoRefAccesInRender.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/Validation/ValidateNoSetStateInRender.ts ModifiedM compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-kitchensink.expect.md ModifiedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-shorthand-method-1.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-shorthand-method-1.js AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-shorthand-method-2.expect.md AddedA compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-shorthand-method-2.js AddedPatch
Files changed
Rendering syntax-highlighted changes…