Compare commits

...

24 Commits

Author SHA1 Message Date
Sebastian McKenzie
a185f91433 v3.5.2 2015-02-08 21:23:24 +11:00
Sebastian McKenzie
d053622802 add 3.5.2 changelog 2015-02-08 21:21:38 +11:00
Sebastian McKenzie
74d6b61973 disable es6 tail call tests 2015-02-08 21:21:32 +11:00
Sebastian McKenzie
97784c8cca comment out tailCall transformer 2015-02-08 21:19:01 +11:00
Sebastian McKenzie
812d93553a temporairly disable tailCall transformer 2015-02-08 21:17:21 +11:00
Sebastian McKenzie
d251b4cb56 3.5.1 2015-02-08 21:16:34 +11:00
Sebastian McKenzie
caf38e1962 v3.5.1 2015-02-08 21:04:05 +11:00
Sebastian McKenzie
4ccbee4639 fix linting errors 2015-02-08 20:59:48 +11:00
Sebastian McKenzie
84196a3a07 add 3.5.1 changelog 2015-02-08 20:57:58 +11:00
Ingvar Stepanyan
29361c055a Fix #718. 2015-02-08 11:56:39 +02:00
Sebastian McKenzie
4277265591 Merge branch 'master' of github.com:6to5/6to5 2015-02-08 20:40:47 +11:00
Sebastian McKenzie
812a2b315d bump acorn-6to5 2015-02-08 20:40:30 +11:00
Ingvar Stepanyan
0a1724fc3f Remove no more needed returnBlock helper. 2015-02-08 11:31:19 +02:00
Sebastian McKenzie
bcc9e016b1 only evaluate object destructuring pattern once 2015-02-08 20:23:22 +11:00
Sebastian McKenzie
4ea0175ca7 simplify set template 2015-02-08 20:23:22 +11:00
Sebastian McKenzie
799445c745 add property method assignment wrapper generator template 2015-02-08 20:23:22 +11:00
Sebastian McKenzie
481ea12999 add cleanup internal transformer 2015-02-08 20:23:22 +11:00
Sebastian McKenzie
de6b608dda add _declarations and _scopeInfo to t.inherits 2015-02-08 20:23:21 +11:00
Sebastian McKenzie
606f813822 enable traceur test suite by default 2015-02-08 20:23:21 +11:00
Sebastian McKenzie
e06c8cd106 support generators in nameMethod helper 2015-02-08 20:23:21 +11:00
Ingvar Stepanyan
9e3c67a8a2 Clean up functionChildrenVisitor a bit. 2015-02-08 10:53:09 +02:00
Ingvar Stepanyan
91362f80b1 Clean up transformations after #714.
Since now we have runtime helper, we don't need
expression -> statement conversions anymore.
2015-02-08 10:40:03 +02:00
Sebastian McKenzie
cde988f99f update 3.5.0 changelog 2015-02-08 16:53:33 +11:00
Sebastian McKenzie
9ec0854659 3.5.0 2015-02-08 16:37:13 +11:00
34 changed files with 145 additions and 154 deletions

View File

@@ -11,6 +11,17 @@
_Note: Gaps between patch versions are faulty/broken releases._
## 3.5.2
* Disable `es6.tailCall` temporairly after reports of it breaking.
## 3.5.1
* **Polish**
* Allow tail calls to work across files without the runtime.
* **Internal**
* Upgrade `acorn-6to5`.
## 3.5.0
* **Bug Fix**
@@ -18,6 +29,9 @@ _Note: Gaps between patch versions are faulty/broken releases._
* **Polish**
* Make default parameter IIFE invocation smarter.
* Make `__esModule` flag non-enumerable. Thanks [@daliwali](https://github.com/daliwali)!
* **Internal**
* More performance improvements.
* Parsing is now ~30% faster thanks to [marijnh/acorn@7264bc0178e7e6af7cfe02e9e0c6b26ee0e6007f](https://github.com/marijnh/acorn/commit/7264bc0178e7e6af7cfe02e9e0c6b26ee0e6007f).
* **New Feature**
* Optional `es6.blockScopingTDZ` is now completely functional and handles all edgecases.
* `super` in object literals.

View File

@@ -36,15 +36,18 @@ exports.property = function (node, file, scope) {
scope.traverse(node, visitor, state);
var method = node.value;
if (state.selfReference) {
// todo: support generators
node.value = util.template("property-method-assignment-wrapper", {
FUNCTION: node.value,
var templateName = "property-method-assignment-wrapper";
if (method.generator) templateName += "-generator";
node.value = util.template(templateName, {
FUNCTION: method,
FUNCTION_ID: key,
FUNCTION_KEY: scope.generateUidIdentifier(id),
WRAPPER_KEY: scope.generateUidIdentifier(id + "Wrapper")
});
} else {
node.value.id = key;
method.id = key;
}
};

View File

@@ -0,0 +1,11 @@
(function (FUNCTION_KEY) {
var WRAPPER_KEY = function* FUNCTION_ID() {
return yield* FUNCTION_KEY.apply(this, arguments);
};
WRAPPER_KEY.toString = function () {
return FUNCTION_KEY.toString();
};
return WRAPPER_KEY;
})(FUNCTION)

View File

@@ -4,21 +4,16 @@
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent === null) {
return;
} else {
if (parent !== null) {
return set(parent, property, value, receiver);
}
} else if ("value" in desc && desc.writable) {
desc.value = value;
return;
return desc.value = value;
} else {
var setter = desc.set;
if (setter === undefined) {
return;
if (setter !== undefined) {
return setter.call(receiver, value);
}
return setter.call(receiver, value);
}
});

View File

@@ -5,6 +5,8 @@
this.context = context;
}
Tail.prototype._isTailDescriptor = true;
var isRunning = false;
return function (func, args, context) {
@@ -13,7 +15,7 @@
isRunning = true;
do {
result = result.func.apply(result.context, result.args);
} while (result instanceof Tail);
} while (result instanceof Tail || (result && result._isTailDescriptor));
isRunning = false;
}
return result;

View File

@@ -112,6 +112,12 @@ Destructuring.prototype.pushObjectPattern = function (pattern, parentId) {
));
}
if (pattern.properties.length > 1 && t.isMemberExpression(parentId)) {
var temp = this.scope.generateUidBasedOnNode(parentId, this.file);
this.nodes.push(this.buildVariableDeclaration(temp, parentId));
parentId = temp;
}
for (var i = 0; i < pattern.properties.length; i++) {
var prop = pattern.properties[i];
if (t.isSpreadProperty(prop)) {

View File

@@ -27,7 +27,8 @@ exports.ForOfStatement = function (node, parent, scope, file) {
// push the rest of the original loop body onto our new body
block.body = block.body.concat(node.body.body);
block._declarations = node.body._declarations;
t.inherits(loop, node);
// todo: find out why this is necessary? #538
loop._scopeInfo = node._scopeInfo;

View File

@@ -1,62 +1,29 @@
"use strict";
/*
var t = require("../../../types");
function returnBlock(expr) {
return t.blockStatement([t.returnStatement(expr)]);
}
function transformExpression(node, scope, state) {
if (!node) return;
return (function subTransform(node) {
switch (node.type) {
case "ConditionalExpression":
var callConsequent = subTransform(node.consequent);
var callAlternate = subTransform(node.alternate);
if (!callConsequent && !callAlternate) {
return;
}
// if ternary operator had tail recursion in value, convert to optimized if-statement
node.type = "IfStatement";
node.consequent = callConsequent ? t.toBlock(callConsequent) : returnBlock(node.consequent);
if (callAlternate) {
node.alternate = t.isIfStatement(callAlternate) ? callAlternate : t.toBlock(callAlternate);
} else {
node.alternate = returnBlock(node.alternate);
}
return [node];
// any value of ternary operator can be final one
subTransform(node.consequent);
subTransform(node.alternate);
break;
case "LogicalExpression":
// only call in right-value of can be optimized
var callRight = subTransform(node.right);
if (!callRight) {
return;
}
var test = state.wrapSideEffect(node.left);
if (node.operator === "&&") {
test.expr = t.unaryExpression("!", test.expr);
}
return [t.ifStatement(test.expr, returnBlock(test.ref))].concat(callRight);
// only right expression can be final and so optimized
subTransform(node.right);
break;
case "SequenceExpression":
// only last element of sequence can be optimized
var seq = node.expressions;
// only last element can be optimized
var lastCall = subTransform(seq[seq.length - 1]);
if (!lastCall) {
return;
}
// remove converted expression from sequence
// and convert to regular expression if needed
if (--seq.length === 1) {
node = seq[0];
}
return [t.expressionStatement(node)].concat(lastCall);
subTransform(seq[seq.length - 1]);
break;
case "CallExpression":
var callee = node.callee, thisBinding;
@@ -77,10 +44,9 @@ function transformExpression(node, scope, state) {
args.push(thisBinding);
}
return [t.returnStatement(t.callExpression(
state.getHelperRef(),
args
))];
node.callee = state.getHelperRef();
node.arguments = args;
break;
}
})(node);
}
@@ -92,19 +58,17 @@ var functionChildrenVisitor = {
this.skip();
// transform return argument into statement if
// it contains tail recursion
return transformExpression(node.argument, scope, state);
transformExpression(node.argument, scope, state);
} else if (t.isFunction(node)) {
return this.skip();
// inner function's bodies are irrelevant
this.skip();
} else if (t.isTryStatement(parent)) {
if (node === parent.block) {
return this.skip();
} else if (node === parent.finalizer) {
return;
} else {
if (parent.finalizer) {
this.skip();
}
return;
// `try`-blocks can't be optimized
this.skip();
} else if (parent.finalizer && node !== parent.finalizer) {
// `catch` clause followed by `finally` can't be optimized
this.skip();
}
}
}
@@ -151,3 +115,4 @@ exports.FunctionExpression = function (node, parent, scope, file) {
]));
}
};
*/

View File

@@ -92,5 +92,7 @@ module.exports = {
"minification.removeDebugger": require("./minification/remove-debugger"),
"minification.removeConsoleCalls": require("./minification/remove-console-calls"),
"minification.deadCodeElimination": require("./minification/dead-code-elimination"),
"minification.renameLocalVariables": require("./minification/rename-local-variables")
"minification.renameLocalVariables": require("./minification/rename-local-variables"),
_cleanUp: require("./internal/cleanup")
};

View File

@@ -0,0 +1,5 @@
exports.SequenceExpression = function (node) {
if (node.expressions.length === 1) {
return node.expressions[0];
}
};

View File

@@ -690,10 +690,12 @@ t.inheritsComments = function (child, parent) {
*/
t.inherits = function (child, parent) {
child.range = parent.range;
child.start = parent.start;
child.loc = parent.loc;
child.end = parent.end;
child._declarations = parent._declarations;
child._scopeInfo = parent._scopeInfo;
child.range = parent.range;
child.start = parent.start;
child.loc = parent.loc;
child.end = parent.end;
t.inheritsComments(child, parent);
return child;
};

View File

@@ -1,7 +1,7 @@
{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "3.5.0",
"version": "3.5.2",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://6to5.org/",
"repository": "6to5/6to5",
@@ -33,7 +33,7 @@
"test": "make test"
},
"dependencies": {
"acorn-6to5": "0.11.1-27",
"acorn-6to5": "0.11.1-28",
"ast-types": "~0.6.1",
"chalk": "^0.5.1",
"chokidar": "0.12.6",

View File

@@ -1,7 +1,7 @@
{
"name": "6to5-runtime",
"description": "6to5 selfContained runtime",
"version": "3.4.1",
"version": "3.5.1",
"repository": "6to5/6to5",
"author": "Sebastian McKenzie <sebmck@gmail.com>"
}

View File

@@ -37,6 +37,8 @@ chai.assert.throw = function (fn, msg) {
msg = "Generator is already running";
} else if (msg === "Sent value to newborn generator") {
msg = /^attempt to send (.*?) to newborn generator$/;
} else if (msg === "super prototype must be an Object or null") {
msg = "Object prototype may only be an Object or null";
}
return chai.assert._throw(fn, msg);

View File

@@ -0,0 +1,9 @@
"use strict";
(function f(n) {
if (n <= 0) {
console.log(this, arguments);
return "foo";
}
return Math.random() > 0.5 ? to5Runtime.tailCall(f.call, [this, n - 1], f) : to5Runtime.tailCall(f.apply, [this, [n - 1]], f);
})(1000000) === "foo";

View File

@@ -0,0 +1,7 @@
function f(n) {
return n <= 0 ? "foo" : g(n - 1);
}
function g(n) {
return n <= 0 ? "goo" : f(n - 1);
}

View File

@@ -0,0 +1,9 @@
"use strict";
function f(n) {
return n <= 0 ? "foo" : to5Runtime.tailCall(g, [n - 1]);
}
function g(n) {
return n <= 0 ? "goo" : to5Runtime.tailCall(f, [n - 1]);
}

View File

@@ -0,0 +1,5 @@
"use strict";
(function f(n) {
return n <= 0 ? "foo" : (doSmth(), getTrueValue() && (getFalseValue() || to5Runtime.tailCall(f, [n - 1])));
})(1000000, true) === "foo";

View File

@@ -1,5 +1,5 @@
function f() {
return getObj().method();
return getObj().method();
}
function g() {

View File

@@ -6,9 +6,5 @@ function f() {
}
function g() {
var _temp;
if (_temp = getFalseValue()) {
return _temp;
}
return to5Runtime.tailCall(getValue);
return getFalseValue() || to5Runtime.tailCall(getValue);
}

View File

@@ -1,6 +1,8 @@
"use strict";
var x1 = rect.topLeft.x;
var y1 = rect.topLeft.y;
var x2 = rect.bottomRight.x;
var y2 = rect.bottomRight.y;
var _rect$topLeft = rect.topLeft;
var x1 = _rect$topLeft.x;
var y1 = _rect$topLeft.y;
var _rect$bottomRight = rect.bottomRight;
var x2 = _rect$bottomRight.x;
var y2 = _rect$bottomRight.y;

View File

@@ -3,10 +3,12 @@
var _slicedToArray = function (arr, i) { if (Array.isArray(arr)) { return arr; } else { var _arr = []; for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { _arr.push(_step.value); if (i && _arr.length === i) break; } return _arr; } };
function somethingAdvanced(_ref) {
var x1 = _ref.topLeft.x;
var y1 = _ref.topLeft.y;
var x2 = _ref.bottomRight.x;
var y2 = _ref.bottomRight.y;
var _ref$topLeft = _ref.topLeft;
var x1 = _ref$topLeft.x;
var y1 = _ref$topLeft.y;
var _ref$bottomRight = _ref.bottomRight;
var x2 = _ref$bottomRight.x;
var y2 = _ref$bottomRight.y;
}
function unpackObject(_ref) {

View File

@@ -1,13 +0,0 @@
"use strict";
(function f(n) {
if (n <= 0) {
console.log(this, arguments);
return "foo";
}
if (Math.random() > 0.5) {
return to5Runtime.tailCall(f.call, [this, n - 1], f);
} else {
return to5Runtime.tailCall(f.apply, [this, [n - 1]], f);
}
})(1000000) === "foo";

View File

@@ -1,7 +0,0 @@
function f(n) {
return n <= 0 ? "foo" : g(n - 1);
}
function g(n) {
return n <= 0 ? "goo" : f(n - 1);
}

View File

@@ -1,17 +0,0 @@
"use strict";
function f(n) {
if (n <= 0) {
return "foo";
} else {
return to5Runtime.tailCall(g, [n - 1]);
}
}
function g(n) {
if (n <= 0) {
return "goo";
} else {
return to5Runtime.tailCall(f, [n - 1]);
}
}

View File

@@ -1,18 +0,0 @@
"use strict";
(function f(n) {
var _temp;
if (n <= 0) {
return "foo";
} else {
doSmth();
if (!(_temp = getTrueValue())) {
return _temp;
}
if (_temp = getFalseValue()) {
return _temp;
}
return to5Runtime.tailCall(f, [n - 1]);
}
})(1000000, true) === "foo";

View File

@@ -1,5 +1,3 @@
if (!process.env.ALL_6TO5_TESTS) return;
require("./_helper").assertVendor("traceur");
var fs = require("fs");
@@ -10,8 +8,8 @@ require("./_transformation-helper")({
loc: __dirname + "/../vendor/traceur/test/feature",
ignoreSuites: [
// weird environmental issue make these hard to test
"Modules",
"Classes",
// these are the responsibility of regenerator
"AsyncFunctions",
@@ -36,6 +34,16 @@ require("./_transformation-helper")({
],
ignoreTasks: [
// TODO: #426
"Classes/SuperUnary",
"Classes/SuperPostfix",
// TODO: investigate
"Classes/SuperSet",
"Classes/PrototypeDescriptor",
"Classes/ExtendStrange",
"Classes/ClassNameBinding",
// these are the responsibility of core-js
"Symbol/GetOwnPropertySymbols",
"Spread/Type",
@@ -59,7 +67,7 @@ require("./_transformation-helper")({
// they have no names
"PropertyMethodAssignment/PropertyMethodAssignment",
// 6to5 assumes that all code transformed is a module
// 6to5 assumes that all code transformed is a module so this isn't necessary
"Strict",
"Syntax/UseStrictEscapeSequence",
"Syntax/UseStrictLineContinuation",