refactor(compiler): combine call ASTs#42882
Closed
crisbeto wants to merge 3 commits intoangular:masterfrom
Closed
Conversation
0120220 to
9968b3b
Compare
9968b3b to
32f9b5c
Compare
79b1771 to
37db16e
Compare
alxhub
reviewed
Aug 2, 2021
6b9f01c to
c850981
Compare
Member
820a4cb to
226d958
Compare
6e5449b to
8921861
Compare
Currently the compiler has three different classes to represent a "call to something": 1. `MethodCall` - `foo.bar()` 2. `SafeMethodCall` - `foo?.bar()`. 3. `FunctionCall` - Any calls that don't fit into the first two classes. E.g. `foo.bar()()`. There are a few problems with this approach: 1. It is inconistent with the TypeScript AST which only has one node: `CallExpression`. 2. It means that we have to maintain more code, because the various parts of the compiler need to know about three node types. 3. It doesn't allow us to easily implement some new JS features like safe calls (e.g. `foo.bar?.())`). These changes rework the compiler so that it produces only one node: `Call`. The new node behaves similarly to the TypeScript `CallExpression` whose `receiver` can be any expression. There was a similar situation in the output AST where we had an `InvokeMethodExpression` and `InvokeFunctionExpression`. I've combined both of them into `InvokeFunctionExpression`.
8921861 to
3db29f6
Compare
alxhub
approved these changes
Sep 20, 2021
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently the compiler has three different classes to represent a "call to something":
MethodCall-foo.bar()SafeMethodCall-foo?.bar().FunctionCall- Any calls that don't fit into the first two classes. E.g.foo.bar()().There are a few problems with this approach:
CallExpression.foo.bar?.())).These changes rework the compiler so that it produces only one node:
Call. The new node behaves similarly to the TypeScriptCallExpressionwhosereceivercan be any expression.There was a similar situation in the output AST where we had an
InvokeMethodExpressionandInvokeFunctionExpression. I've combined both of them intoInvokeFunctionExpression.