remove use of exports

This commit is contained in:
Sebastian McKenzie 2015-05-10 16:09:43 +01:00
parent d38f18af40
commit 65a44a1e13
11 changed files with 35 additions and 19 deletions

View File

@ -1,7 +1,9 @@
import explode from "./explode-assignable-expression";
import * as t from "../../types";
export default function (exports, opts) {
export default function (opts) {
var exports = {};
var isAssignment = function (node) {
return node.operator === opts.operator + "=";
};
@ -40,4 +42,6 @@ export default function (exports, opts) {
if (node.operator !== opts.operator) return;
return opts.build(node.left, node.right);
};
return exports;
};

View File

@ -55,7 +55,7 @@ export function ForOfStatement(node, parent, scope, file) {
export { ForOfStatement as ForInStatement };
exports.Function = function (node, parent, scope, file) {
export function Func(node, parent, scope, file) {
var nodes = [];
var hasDestructuring = false;
@ -85,7 +85,7 @@ exports.Function = function (node, parent, scope, file) {
var block = node.body;
block.body = nodes.concat(block.body);
};
}
export function CatchClause(node, parent, scope, file) {
var pattern = node.param;

View File

@ -20,7 +20,7 @@ var iifeVisitor = {
}
};
exports.Function = function (node, parent, scope, file) {
export function Func(node, parent, scope, file) {
if (!hasDefaults(node)) return;
t.ensureBlock(node);
@ -92,4 +92,4 @@ exports.Function = function (node, parent, scope, file) {
} else {
node.body.body = body.concat(node.body.body);
}
};
}

View File

@ -53,7 +53,7 @@ var hasRest = function (node) {
return t.isRestElement(node.params[node.params.length - 1]);
};
exports.Function = function (node, parent, scope, file) {
export function Func(node, parent, scope, file) {
if (!hasRest(node)) return;
var rest = node.params.pop().argument;
@ -135,4 +135,4 @@ exports.Function = function (node, parent, scope, file) {
});
loop._blockHoist = node.params.length + 1;
node.body.body.unshift(loop);
};
}

View File

@ -10,11 +10,11 @@ export var metadata = {
group: "builtin-trailing"
};
exports.Function = function (node, parent, scope, file) {
export function Func(node, parent, scope, file) {
if (node.generator || node.async) return;
var tailCall = new TailCallTransformer(this, scope, file);
tailCall.run();
};
}
function returnBlock(expr) {
return t.blockStatement([t.returnStatement(expr)]);

View File

@ -9,10 +9,20 @@ export var metadata = {
var MATH_POW = t.memberExpression(t.identifier("Math"), t.identifier("pow"));
build(exports, {
var {
ExpressionStatement,
AssignmentExpression,
BinaryExpression
} = build({
operator: "**",
build(left, right) {
return t.callExpression(MATH_POW, [left, right]);
}
});
export {
ExpressionStatement,
AssignmentExpression,
BinaryExpression
};

View File

@ -7,8 +7,8 @@ export var metadata = {
dependencies: ["es7.asyncFunctions", "es6.classes"]
};
exports.Function = function (node, parent, scope, file) {
export function Func(node, parent, scope, file) {
if (!node.async || node.generator) return;
return remapAsyncToGenerator(node, file.addHelper("async-to-generator"), scope);
};
}

View File

@ -10,7 +10,7 @@ export var metadata = {
dependencies: ["es7.asyncFunctions", "es6.classes"]
};
exports.Function = function (node, parent, scope, file) {
export function Func(node, parent, scope, file) {
if (!node.async || node.generator) return;
return remapAsyncToGenerator(
@ -18,4 +18,4 @@ exports.Function = function (node, parent, scope, file) {
t.memberExpression(file.addImport("bluebird", null, "absolute"), t.identifier("coroutine")),
scope
);
};
}

View File

@ -12,12 +12,12 @@ export function Class(node) {
node.implements = null;
}
exports.Function = function (node) {
export function Func(node) {
for (var i = 0; i < node.params.length; i++) {
var param = node.params[i];
param.optional = false;
}
};
}
export function TypeCastExpression(node) {
return node.expression;

View File

@ -26,9 +26,9 @@
"ExportNamedDeclaration": ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
"ImportDeclaration": ["Statement", "Declaration", "ModuleDeclaration"],
"ArrowFunctionExpression": ["Scopable", "Function", "Expression", "Pure"],
"FunctionDeclaration": ["Scopable", "Function", "Statement", "Pure", "Declaration"],
"FunctionExpression": ["Scopable", "Function", "Expression", "Pure"],
"ArrowFunctionExpression": ["Scopable", "Function", "Func", "Expression", "Pure"],
"FunctionDeclaration": ["Scopable", "Function", "Func", "Statement", "Pure", "Declaration"],
"FunctionExpression": ["Scopable", "Function", "Func", "Expression", "Pure"],
"BlockStatement": ["Scopable", "Statement"],
"Program": ["Scopable"],

View File

@ -79,6 +79,8 @@ export function isType(nodeType, targetType) {
var aliases = t.FLIPPED_ALIAS_KEYS[targetType];
if (aliases) {
if (aliases[0] === nodeType) return true;
for (var alias of (aliases: Array)) {
if (nodeType === alias) return true;
}