add callDelegate transformation helper - fixes #1064

This commit is contained in:
Sebastian McKenzie 2015-03-23 16:47:17 +11:00
parent ca79fff0c4
commit b234603e24
2 changed files with 13 additions and 5 deletions

View File

@ -0,0 +1,11 @@
import * as t from "../../types";
export default function (node) {
var container = t.functionExpression(null, [], node.body, node.generator, node.async);
container.shadow = true;
var call = t.callExpression(container, []);
if (node.generator) call = t.yieldExpression(call, true);
return t.returnStatement(call);
}

View File

@ -1,3 +1,4 @@
import callDelegate from "../../helpers/call-delegate";
import * as util from "../../../util";
import * as t from "../../../types";
@ -91,11 +92,7 @@ exports.Function = function (node, parent, scope, file) {
node.params = node.params.slice(0, lastNonDefaultParam);
if (state.iife) {
var container = t.functionExpression(null, [], node.body, node.generator);
container.shadow = true;
body.push(t.returnStatement(t.callExpression(container, [])));
body.push(callDelegate(node));
node.body = t.blockStatement(body);
} else {
node.body.body = body.concat(node.body.body);