Compare commits

...

13 Commits

Author SHA1 Message Date
Sebastian McKenzie
a3b1fcc79c v4.7.9 2015-03-13 13:30:14 +11:00
Sebastian McKenzie
491cb26c1f remove console.log 2015-03-13 13:29:13 +11:00
Sebastian McKenzie
7c3d052714 add 4.7.9 changelog 2015-03-13 13:27:40 +11:00
Sebastian McKenzie
4971d0c7f0 fix labeled nested for ofs - fixes #996 2015-03-13 13:25:37 +11:00
Sebastian McKenzie
eb4922b1ec update acorn-babel 2015-03-13 13:25:19 +11:00
Sebastian McKenzie
bb26183b44 set inputSourceMap to null by default 2015-03-13 13:14:17 +11:00
Sebastian McKenzie
4b066f7f1b add input sourcemap false option #827 2015-03-13 13:12:38 +11:00
Sebastian McKenzie
3cd110a7c9 fix block scoping break switch collision - fixes #998 2015-03-12 14:35:30 +11:00
Sebastian McKenzie
a7f9e035a4 infer computed literal function names - fixes #993 2015-03-12 14:13:24 +11:00
Sebastian McKenzie
146b9e6708 4.7.8 2015-03-11 10:17:09 +11:00
Sebastian McKenzie
0953c48620 v4.7.8 2015-03-11 07:49:54 +11:00
Sebastian McKenzie
056b90831d manually define each property in computed class helper - fixes #984 2015-03-11 07:45:29 +11:00
Sebastian McKenzie
8ba276b209 4.7.7 2015-03-11 01:25:41 +11:00
11 changed files with 133 additions and 43 deletions

View File

@@ -13,6 +13,22 @@ _Note: Gaps between patch versions are faulty/broken releases._
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
## 4.7.9
* **Polish**
* Allow `inputSourceMap` to be set to `false` to skip the source map inference.
* Infer computed literal property names.
* **Bug Fix**
* Fix nested labeled for-ofs.
* Fix block scoping `break` colliding with the parent switch case.
* **Internal**
* Upgrade `acorn-babel`.
## 4.7.8
* **Bug Fix**
* Fix computed classes not properly setting symbols.
## 4.7.7
* **Bug Fix**

View File

@@ -1,7 +1,7 @@
{
"name": "babel",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "4.7.7",
"version": "4.7.9",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"repository": "babel/babel",
@@ -36,7 +36,7 @@
"test": "make test"
},
"dependencies": {
"acorn-babel": "0.11.1-37",
"acorn-babel": "0.11.1-38",
"ast-types": "~0.7.0",
"chalk": "^1.0.0",
"chokidar": "^0.12.6",

View File

@@ -1,7 +1,7 @@
{
"name": "babel-runtime",
"description": "babel selfContained runtime",
"version": "4.7.6",
"version": "4.7.8",
"repository": "babel/babel",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"dependencies": {

View File

@@ -139,7 +139,7 @@ export default class File {
returnUsedHelpers: false,
externalHelpers: false,
auxilaryComment: "",
inputSourceMap: false,
inputSourceMap: null,
experimental: false,
reactCompat: false,
playground: false,
@@ -280,10 +280,12 @@ export default class File {
parseInputSourceMap(code: string) {
var opts = this.opts;
var inputMap = convertSourceMap.fromSource(code);
if (inputMap) {
opts.inputSourceMap = inputMap.toObject();
code = convertSourceMap.removeComments(code);
if (opts.inputSourceMap === false) {
var inputMap = convertSourceMap.fromSource(code);
if (inputMap) {
opts.inputSourceMap = inputMap.toObject();
code = convertSourceMap.removeComments(code);
}
}
return code;

View File

@@ -111,7 +111,7 @@ export function bare(node, parent, scope) {
if (node.id) return node;
var id;
if (t.isProperty(parent) && parent.kind === "init" && !parent.computed) {
if (t.isProperty(parent) && parent.kind === "init" && (!parent.computed || t.isLiteral(parent.key))) {
// { foo() {} };
id = parent.key;
} else if (t.isVariableDeclarator(parent)) {
@@ -121,9 +121,16 @@ export function bare(node, parent, scope) {
return node;
}
if (!t.isIdentifier(id)) return node;
var name;
if (t.isLiteral(id)) {
name = id.value;
} else if (t.isIdentifier(id)) {
name = id.name;
} else {
return;
}
var name = t.toIdentifier(id.name);
name = t.toIdentifier(name);
id = t.identifier(name);
var state = visit(node, name, scope);

View File

@@ -1,13 +1,11 @@
(function() {
function defineProperties(target, rawProps) {
var props = {};
for (var i = 0; i < rawProps.length; i ++) {
var prop = rawProps[i];
function defineProperties(target, props) {
for (var i = 0; i < props.length; i ++) {
var prop = props[i];
prop.configurable = true;
if (prop.value) prop.writable = true;
props[prop.key] = prop;
Object.defineProperty(target, prop.key, prop);
}
Object.defineProperties(target, props);
}
return function (Constructor, protoProps, staticProps) {

View File

@@ -69,8 +69,9 @@ export function Loop(node, parent, scope, file) {
t.ensureBlock(node);
node.body._letDeclarators = [init];
}
var blockScoping = new BlockScoping(node, node.body, parent, scope, file);
blockScoping.run();
var blockScoping = new BlockScoping(this, node.body, parent, scope, file);
return blockScoping.run();
}
export function BlockStatement(block, parent, scope, file) {
@@ -224,17 +225,22 @@ class BlockScoping {
* Description
*/
constructor(loopParent?: Object, block: Object, parent: Object, scope: Scope, file: File) {
this.loopParent = loopParent;
this.parent = parent;
this.scope = scope;
this.block = block;
this.file = file;
constructor(loopPath?: TraversalPath, block: Object, parent: Object, scope: Scope, file: File) {
this.parent = parent;
this.scope = scope;
this.block = block;
this.file = file;
this.outsideLetReferences = object();
this.hasLetReferences = false;
this.letReferences = block._letReferences = object();
this.body = [];
if (loopPath) {
this.loopParent = loopPath.parent;
this.loopLabel = t.isLabeledStatement(this.loopParent) && this.loopParent.label;
this.loop = loopPath.node;
}
}
/**
@@ -259,6 +265,10 @@ class BlockScoping {
} else {
this.remap();
}
if (this.loopLabel && !t.isLabeledStatement(this.loopParent)) {
return t.labeledStatement(this.loopLabel, this.loop);
}
}
/**
@@ -297,11 +307,11 @@ class BlockScoping {
//
var loopParent = this.loopParent;
if (loopParent) {
traverseReplace(loopParent.right, loopParent, scope, remaps);
traverseReplace(loopParent.test, loopParent, scope, remaps);
traverseReplace(loopParent.update, loopParent, scope, remaps);
var loop = this.loop;
if (loop) {
traverseReplace(loop.right, loop, scope, remaps);
traverseReplace(loop.test, loop, scope, remaps);
traverseReplace(loop.update, loop, scope, remaps);
}
scope.traverse(this.block, replaceVisitor, remaps);
@@ -317,7 +327,7 @@ class BlockScoping {
var outsideRefs = this.outsideLetReferences;
// remap loop heads with colliding variables
if (this.loopParent) {
if (this.loop) {
for (var name in outsideRefs) {
var id = outsideRefs[name];
@@ -438,7 +448,7 @@ class BlockScoping {
ignoreLabeless: false,
innerLabels: [],
hasReturn: false,
isLoop: !!this.loopParent,
isLoop: !!this.loop,
map: {}
};
@@ -504,7 +514,7 @@ class BlockScoping {
t.variableDeclarator(ret, call)
]));
var loopParent = this.loopParent;
var loop = this.loop;
var retCheck;
var has = this.has;
var cases = [];
@@ -517,9 +527,8 @@ class BlockScoping {
}
if (has.hasBreakContinue) {
if (!loopParent) {
throw new Error("Has no loop parent but we're trying to reassign breaks " +
"and continues, something is going wrong here.");
if (!loop) {
throw new Error("Aren't in a loop and we're trying to reassign breaks and continues, something is going wrong here.");
}
for (var key in has.map) {
@@ -537,6 +546,14 @@ class BlockScoping {
single.consequent[0]
)));
} else {
// #998
for (var i = 0; i < cases.length; i++) {
var caseConsequent = cases[i].consequent[0];
if (t.isBreakStatement(caseConsequent) && !caseConsequent.label) {
caseConsequent.label = this.loopLabel ||= this.file.scope.generateUidIdentifier("loop");
}
}
body.push(this.file.attachAuxiliaryComment(t.switchStatement(ret, cases)));
}
} else {

View File

@@ -32,11 +32,8 @@ export function ForOfStatement(node, parent, scope, file) {
// todo: find out why this is necessary? #538
loop._scopeInfo = node._scopeInfo;
if (build.replaceParent) {
this.parentPath.node = build.node;
} else {
return build.node;
}
if (build.replaceParent) this.parentPath.node = build.node;
return build.node;
}
var loose = function (node, parent, scope, file) {

View File

@@ -1,7 +1,7 @@
"use strict";
(function () {
for (var i in nums) {
_loop: for (var i in nums) {
var _ret = (function (i) {
fns.push(function () {
return i;
@@ -22,7 +22,7 @@
continue;
case "break":
break;
break _loop;
default:
if (typeof _ret === "object") return _ret.v;

View File

@@ -0,0 +1,5 @@
b: for (let c of d()) {
for (let e of f()) {
continue b;
}
}

View File

@@ -0,0 +1,48 @@
"use strict";
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
b: for (var _iterator = d()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var c = _step.value;
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = f()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var e = _step2.value;
continue b;
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2["return"]) {
_iterator2["return"]();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"]) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}