-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Call AST #5117
Call AST #5117
Changes from 16 commits
256ea8e
52eb39c
bf253cd
a835986
d6c124a
ffd17f2
355ac60
1c995db
da28395
e5f56a8
b3d5cdb
51f566f
fc2c48f
c17fd7d
90a3ceb
defd087
133c099
093439b
8007e6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1285,6 +1285,7 @@ exports.Call = class Call extends Base | |
constructor: (@variable, @args = [], @soak, @token) -> | ||
super() | ||
|
||
@implicit = @args.implicit | ||
@isNew = no | ||
if @variable instanceof Value and @variable.isNotCallable() | ||
@variable.error "literal is not a function" | ||
|
@@ -1426,6 +1427,19 @@ exports.Call = class Call extends Base | |
fragments.push @makeCode(' />') | ||
fragments | ||
|
||
astType: -> | ||
if @isNew | ||
'NewExpression' | ||
else | ||
'CallExpression' | ||
|
||
astProperties: -> | ||
return | ||
callee: @variable.ast() | ||
arguments: arg.ast() for arg in @args | ||
optional: !!@soak | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So shouldn’t we go with what Babel 7 is using? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably, but I'd like to see if I can find an explanation as to why they switched There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you're curious, babel/babel#7256 discusses the switch (to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well if this is the Babel spec now, I would think that we should follow it, yes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @GeoffreyBooth yes I think so. But I'd like to tackle that as a separate PR as there's some complexity there. And in the meantime I'll keep putting up individual node class PRs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a test for the new form so we don't forget to do it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @GeoffreyBooth sure added a TODO comment on a test that should end up using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking we'd add a commented out failing test, but either way works. |
||
implicit: !!@implicit | ||
GeoffreyBooth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### Super | ||
|
||
# Takes care of converting `super()` calls into calls against the prototype's | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -655,7 +655,7 @@ exports.Rewriter = class Rewriter | |
# primitive string and separately passing any expected token data properties | ||
exposeTokenDataToGrammar: -> | ||
@scanTokens (token, i) -> | ||
if token.data and Object.keys(token.data).length or token[0] is 'JS' and token.generated | ||
if token.data and Object.keys(token.data).length or token[0] in ['JS', 'CALL_START'] and token.generated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please explain this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From my understanding, I guess one option would be to update all current uses of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe rather than looking for token tag, should we look for if token.generated or (token.data and Object.keys(token.data).length isnt 0) I guess the question is, what’s the harm in applying this for all generated tokens rather than only generated Just wanting to make sure we understand what’s going on here. A comment explaining it might be good to add. Also I think you’re right in that |
||
token[1] = new String token[1] | ||
token[1][key] = val for own key, val of (token.data ? {}) | ||
token[1].generated = yes if token.generated | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preserve whether the call was implicit through the grammar