Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/ast.ls
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ SourceNode::to-string = (...args) ->
that.carp 'inconvertible statement' if @get-jump!
fun = Fun [] Block this
call = Call!
fun.async = true if o.in-async
fun.generator = true if o.in-generator
var hasArgs, hasThis
@traverse-children !->
Expand All @@ -174,6 +175,8 @@ SourceNode::to-string = (...args) ->
out = Parens(Chain fun<<<{+wrapper, @void} [call]; true)
if o.in-generator
out = new Yield 'yieldfrom', out
else if o.in-async
out = new Yield 'await', out
out.compile o

# Compiles a child node as a block statement.
Expand Down Expand Up @@ -1155,7 +1158,6 @@ class exports.Yield extends Node
| 'yield' => ''
| 'yieldfrom' => 'from'
| 'await' => 'await'
| 'awaitall' => 'await all'
| _ => ''

::delegate <[ isCallable ]> -> yes
Expand All @@ -1165,7 +1167,6 @@ class exports.Yield extends Node
| 'yield' => 'yield'
| 'yieldfrom' => 'yield*'
| 'await' => 'await'
| 'awaitall' => 'await*'
)]
if @it then code.push " #{@it.compile o, LEVEL_OP + PREC.unary}"
sn(this, "(", ...code, ")")
Expand Down Expand Up @@ -1917,7 +1918,7 @@ class exports.Fun extends Node
code = [\function]
if @async
@ctor and @carp "a constructor can't be async"
o.in-generator = true
o.in-async = true
code.unshift 'async '
else if @generator
@ctor and @carp "a constructor can't be a generator"
Expand Down