support async await inside of let scoping closure wrapper - fixes #565

This commit is contained in:
Sebastian McKenzie 2015-01-22 10:53:05 +11:00
parent c0a4e7ad55
commit b9b1a44c28

View File

@ -211,12 +211,20 @@ LetScoping.prototype.needsClosure = function () {
var call = t.callExpression(fn, params);
var ret = this.scope.generateUidIdentifier("ret");
// handle generators
var hasYield = traverse.hasType(fn.body, this.scope, "YieldExpression", t.FUNCTION_TYPES);
if (hasYield) {
fn.generator = true;
call = t.yieldExpression(call, true);
}
// handlers async functions
var hasAsync = traverse.hasType(fn.body, this.scope, "AwaitExpression", t.FUNCTION_TYPES);
if (hasAsync) {
fn.async = true;
call = t.awaitExpression(call, true);
}
this.build(ret, call);
};