dillon1000/react
Commit
Browse files Add PropertyCall/ComputedCall instructions
Adds `PropertyCall` and `ComputedCall`, which are a combination of CallExpression and PropertyLoad/ComputedLoad, respectively. The goal is to ensure that we correctly model the receiver of a call where the callee is a member expression, and also accurately record scope dependencies in for both the computed and non-computed (property) cases. An alternative that I tried first was to add a `receiver: Place | null` to CallExpression. That works well for HIR construction, but it's then very difficult at codegen time to correctly reconstruct the original call: if the receiver and callee share part of their structure then we can transform back to a non-computed member expression, otherwise it has to be computed. Eg we have to distinguish `a.b.c[d.foo]()` from `a.b.c[a.b.c.foo]()`. Given that our target is high-level code, it seems reasonable to have a higher-level representation for these cases. I'm open to feedback but this feels pretty reasonable in terms of complexity / precision of modeling.
Changed paths16 files
First-parent comparisoncompiler/forget/src/HIR/BuildHIR.ts ModifiedM compiler/forget/src/HIR/HIR.ts ModifiedM compiler/forget/src/HIR/PrintHIR.ts ModifiedM compiler/forget/src/HIR/visitors.ts ModifiedM compiler/forget/src/Inference/InferMutableLifetimes.ts ModifiedM compiler/forget/src/Inference/InferReferenceEffects.ts ModifiedM compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts ModifiedM compiler/forget/src/ReactiveScopes/InferReactiveScopeVariables.ts ModifiedM compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts ModifiedM compiler/forget/src/__tests__/fixtures/hir/component.expect.md ModifiedA compiler/forget/src/__tests__/fixtures/hir/method-call-computed.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/method-call-computed.js AddedA compiler/forget/src/__tests__/fixtures/hir/method-call-fn-call.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/method-call-fn-call.js AddedA compiler/forget/src/__tests__/fixtures/hir/method-call.expect.md AddedA compiler/forget/src/__tests__/fixtures/hir/method-call.js AddedPatch
Files changed
Rendering syntax-highlighted changes…