From 8afec8b12ac65f3d82a3c19395b7047a427a1465 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Wed, 14 Jan 2015 00:24:34 +1100 Subject: [PATCH] rename fast mode to loose #465 --- bin/6to5/index.js | 4 ++-- lib/6to5/file.js | 12 ++++++------ ....js => class-super-constructor-call-loose.js} | 0 .../{for-of-fast.js => for-of-loose.js} | 0 .../transformation/transformers/es6-classes.js | 16 ++++++++-------- .../transformation/transformers/es6-for-of.js | 6 +++--- .../transformation/es6-classes-fast/options.json | 3 --- .../accessing-super-class/actual.js | 0 .../accessing-super-class/expected.js | 0 .../accessing-super-properties/actual.js | 0 .../accessing-super-properties/expected.js | 0 .../calling-super-properties/actual.js | 0 .../calling-super-properties/expected.js | 0 .../es6-classes-loose/options.json | 3 +++ .../super-class-id-member-expression/actual.js | 0 .../super-class-id-member-expression/expected.js | 0 .../super-class/actual.js | 0 .../super-class/expected.js | 0 .../super-function-fallback/actual.js | 0 .../super-function-fallback/expected.js | 0 .../transformation/es6-for-of-fast/options.json | 3 --- .../identifier/actual.js | 0 .../identifier/expected.js | 0 .../let/actual.js | 0 .../let/expected.js | 0 .../multiple/actual.js | 0 .../multiple/expected.js | 0 .../transformation/es6-for-of-loose/options.json | 3 +++ .../var/actual.js | 0 .../var/expected.js | 0 30 files changed, 25 insertions(+), 25 deletions(-) rename lib/6to5/transformation/templates/{class-super-constructor-call-fast.js => class-super-constructor-call-loose.js} (100%) rename lib/6to5/transformation/templates/{for-of-fast.js => for-of-loose.js} (100%) delete mode 100644 test/fixtures/transformation/es6-classes-fast/options.json rename test/fixtures/transformation/{es6-classes-fast => es6-classes-loose}/accessing-super-class/actual.js (100%) rename test/fixtures/transformation/{es6-classes-fast => es6-classes-loose}/accessing-super-class/expected.js (100%) rename test/fixtures/transformation/{es6-classes-fast => es6-classes-loose}/accessing-super-properties/actual.js (100%) rename test/fixtures/transformation/{es6-classes-fast => es6-classes-loose}/accessing-super-properties/expected.js (100%) rename test/fixtures/transformation/{es6-classes-fast => es6-classes-loose}/calling-super-properties/actual.js (100%) rename test/fixtures/transformation/{es6-classes-fast => es6-classes-loose}/calling-super-properties/expected.js (100%) create mode 100644 test/fixtures/transformation/es6-classes-loose/options.json rename test/fixtures/transformation/{es6-classes-fast => es6-classes-loose}/super-class-id-member-expression/actual.js (100%) rename test/fixtures/transformation/{es6-classes-fast => es6-classes-loose}/super-class-id-member-expression/expected.js (100%) rename test/fixtures/transformation/{es6-classes-fast => es6-classes-loose}/super-class/actual.js (100%) rename test/fixtures/transformation/{es6-classes-fast => es6-classes-loose}/super-class/expected.js (100%) rename test/fixtures/transformation/{es6-classes-fast => es6-classes-loose}/super-function-fallback/actual.js (100%) rename test/fixtures/transformation/{es6-classes-fast => es6-classes-loose}/super-function-fallback/expected.js (100%) delete mode 100644 test/fixtures/transformation/es6-for-of-fast/options.json rename test/fixtures/transformation/{es6-for-of-fast => es6-for-of-loose}/identifier/actual.js (100%) rename test/fixtures/transformation/{es6-for-of-fast => es6-for-of-loose}/identifier/expected.js (100%) rename test/fixtures/transformation/{es6-for-of-fast => es6-for-of-loose}/let/actual.js (100%) rename test/fixtures/transformation/{es6-for-of-fast => es6-for-of-loose}/let/expected.js (100%) rename test/fixtures/transformation/{es6-for-of-fast => es6-for-of-loose}/multiple/actual.js (100%) rename test/fixtures/transformation/{es6-for-of-fast => es6-for-of-loose}/multiple/expected.js (100%) create mode 100644 test/fixtures/transformation/es6-for-of-loose/options.json rename test/fixtures/transformation/{es6-for-of-fast => es6-for-of-loose}/var/actual.js (100%) rename test/fixtures/transformation/{es6-for-of-fast => es6-for-of-loose}/var/expected.js (100%) diff --git a/bin/6to5/index.js b/bin/6to5/index.js index b5dd079d29..955671555d 100755 --- a/bin/6to5/index.js +++ b/bin/6to5/index.js @@ -18,7 +18,7 @@ commander.option("-m, --modules [modules]", "Module formatter type to use [commo commander.option("-l, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util.list); commander.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", util.list); commander.option("-i, --optional [list]", "List of optional transformers to enable", util.list); -commander.option("--fast [list]", "List of transformers to enable their fast mode", util.list); +commander.option("--loose [list]", "List of transformers to enable their loose mode", util.list); commander.option("-o, --out-file [out]", "Compile all input files into a single file"); commander.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory"); commander.option("-c, --remove-comments", "Remove comments from the compiled code", false); @@ -117,7 +117,7 @@ exports.opts = { comments: !commander.removeComments, runtime: commander.runtime, modules: commander.modules, - fast: commander.fast, + loose: commander.loose, format: { indent: { style: util.repeat(parseInt(commander.indent)) diff --git a/lib/6to5/file.js b/lib/6to5/file.js index ef830e1ab6..2757dcb1e2 100644 --- a/lib/6to5/file.js +++ b/lib/6to5/file.js @@ -63,7 +63,7 @@ File.normaliseOptions = function (opts) { filename: "unknown", modules: "common", runtime: false, - fast: [], + loose: [], code: true, ast: true }); @@ -74,7 +74,7 @@ File.normaliseOptions = function (opts) { opts.blacklist = util.arrayify(opts.blacklist); opts.whitelist = util.arrayify(opts.whitelist); opts.optional = util.arrayify(opts.optional); - opts.fast = util.arrayify(opts.fast); + opts.loose = util.arrayify(opts.loose); // todo: remove in 3.0.0 _.each({ @@ -83,7 +83,7 @@ File.normaliseOptions = function (opts) { }, function (newTransformer, oldTransformer) { if (_.contains(opts.optional, oldTransformer)) { _.pull(opts.optional, oldTransformer); - opts.fast.push(newTransformer); + opts.loose.push(newTransformer); } }); @@ -115,13 +115,13 @@ File.normaliseOptions = function (opts) { transform._ensureTransformerNames("blacklist", opts.blacklist); transform._ensureTransformerNames("whitelist", opts.whitelist); transform._ensureTransformerNames("optional", opts.optional); - transform._ensureTransformerNames("fast", opts.fast); + transform._ensureTransformerNames("loose", opts.loose); return opts; }; -File.prototype.isFast = function (key) { - return _.contains(this.opts.fast, key); +File.prototype.isLoose = function (key) { + return _.contains(this.opts.loose, key); }; File.prototype.getTransformers = function () { diff --git a/lib/6to5/transformation/templates/class-super-constructor-call-fast.js b/lib/6to5/transformation/templates/class-super-constructor-call-loose.js similarity index 100% rename from lib/6to5/transformation/templates/class-super-constructor-call-fast.js rename to lib/6to5/transformation/templates/class-super-constructor-call-loose.js diff --git a/lib/6to5/transformation/templates/for-of-fast.js b/lib/6to5/transformation/templates/for-of-loose.js similarity index 100% rename from lib/6to5/transformation/templates/for-of-fast.js rename to lib/6to5/transformation/templates/for-of-loose.js diff --git a/lib/6to5/transformation/transformers/es6-classes.js b/lib/6to5/transformation/transformers/es6-classes.js index 2e7fb8b06f..c31d1787b9 100644 --- a/lib/6to5/transformation/transformers/es6-classes.js +++ b/lib/6to5/transformation/transformers/es6-classes.js @@ -33,7 +33,7 @@ function Class(node, file, scope, isStatement) { this.hasConstructor = false; this.className = node.id || file.generateUidIdentifier("class", scope); this.superName = node.superClass; - this.isFast = file.isFast("classes"); + this.isLoose = file.isLoose("classes"); } /** @@ -138,7 +138,7 @@ Class.prototype.buildBody = function () { // we have no constructor, we have a super, and the super doesn't appear to be falsy if (!this.hasConstructor && superName && !t.isFalsyExpression(superName)) { var defaultConstructorTemplate = "class-super-constructor-call"; - if (this.isFast) defaultConstructorTemplate += "-fast"; + if (this.isLoose) defaultConstructorTemplate += "-loose"; constructor.body.body.push(util.template(defaultConstructorTemplate, { CLASS_NAME: className, @@ -188,8 +188,8 @@ Class.prototype.pushMethod = function (node) { } if (kind === "") { - if (this.isFast) { - // use assignments instead of define properties for fast classes + if (this.isLoose) { + // use assignments instead of define properties for loose classes var className = this.className; if (!node.static) className = t.memberExpression(className, t.identifier("prototype")); @@ -246,7 +246,7 @@ Class.prototype.superProperty = function (property, isStatic, isComputed, thisEx * @returns {Object} */ -Class.prototype.fastSuperProperty = function (methodNode, id, parent) { +Class.prototype.looseSuperProperty = function (methodNode, id, parent) { var methodName = methodNode.key; var superName = this.superName || t.identifier("Function"); @@ -318,15 +318,15 @@ Class.prototype.replaceInstanceSuperReferences = function (methodNode) { }; var callback = specHandle; - if (self.isFast) callback = fastHandle; + if (self.isLoose) callback = looseHandle; return callback(getThisReference, node, parent); } }); } - function fastHandle(getThisReference, node, parent) { + function looseHandle(getThisReference, node, parent) { if (t.isIdentifier(node, { name: "super" })) { - return self.fastSuperProperty(methodNode, node, parent); + return self.looseSuperProperty(methodNode, node, parent); } else if (t.isCallExpression(node)) { var callee = node.callee; if (!t.isMemberExpression(callee)) return; diff --git a/lib/6to5/transformation/transformers/es6-for-of.js b/lib/6to5/transformation/transformers/es6-for-of.js index b0ab43a191..61357cfbad 100644 --- a/lib/6to5/transformation/transformers/es6-for-of.js +++ b/lib/6to5/transformation/transformers/es6-for-of.js @@ -3,7 +3,7 @@ var t = require("../../types"); exports.ForOfStatement = function (node, parent, file, scope) { var callback = spec; - if (file.isFast("forOf")) callback = fast; + if (file.isLoose("forOf")) callback = loose; var build = callback(node, parent, file, scope); var declar = build.declar; @@ -31,7 +31,7 @@ exports.ForOfStatement = function (node, parent, file, scope) { return loop; }; -var fast = function (node, parent, file, scope) { +var loose = function (node, parent, file, scope) { var left = node.left; var declar, id; @@ -48,7 +48,7 @@ var fast = function (node, parent, file, scope) { throw file.errorWithNode(left, "Unknown node type " + left.type + " in ForOfStatement"); } - var loop = util.template("for-of-fast", { + var loop = util.template("for-of-loose", { LOOP_OBJECT: file.generateUidIdentifier("iterator", scope), IS_ARRAY: file.generateUidIdentifier("isArray", scope), OBJECT: node.right, diff --git a/test/fixtures/transformation/es6-classes-fast/options.json b/test/fixtures/transformation/es6-classes-fast/options.json deleted file mode 100644 index 1777a323e1..0000000000 --- a/test/fixtures/transformation/es6-classes-fast/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "fast": ["classes"] -} diff --git a/test/fixtures/transformation/es6-classes-fast/accessing-super-class/actual.js b/test/fixtures/transformation/es6-classes-loose/accessing-super-class/actual.js similarity index 100% rename from test/fixtures/transformation/es6-classes-fast/accessing-super-class/actual.js rename to test/fixtures/transformation/es6-classes-loose/accessing-super-class/actual.js diff --git a/test/fixtures/transformation/es6-classes-fast/accessing-super-class/expected.js b/test/fixtures/transformation/es6-classes-loose/accessing-super-class/expected.js similarity index 100% rename from test/fixtures/transformation/es6-classes-fast/accessing-super-class/expected.js rename to test/fixtures/transformation/es6-classes-loose/accessing-super-class/expected.js diff --git a/test/fixtures/transformation/es6-classes-fast/accessing-super-properties/actual.js b/test/fixtures/transformation/es6-classes-loose/accessing-super-properties/actual.js similarity index 100% rename from test/fixtures/transformation/es6-classes-fast/accessing-super-properties/actual.js rename to test/fixtures/transformation/es6-classes-loose/accessing-super-properties/actual.js diff --git a/test/fixtures/transformation/es6-classes-fast/accessing-super-properties/expected.js b/test/fixtures/transformation/es6-classes-loose/accessing-super-properties/expected.js similarity index 100% rename from test/fixtures/transformation/es6-classes-fast/accessing-super-properties/expected.js rename to test/fixtures/transformation/es6-classes-loose/accessing-super-properties/expected.js diff --git a/test/fixtures/transformation/es6-classes-fast/calling-super-properties/actual.js b/test/fixtures/transformation/es6-classes-loose/calling-super-properties/actual.js similarity index 100% rename from test/fixtures/transformation/es6-classes-fast/calling-super-properties/actual.js rename to test/fixtures/transformation/es6-classes-loose/calling-super-properties/actual.js diff --git a/test/fixtures/transformation/es6-classes-fast/calling-super-properties/expected.js b/test/fixtures/transformation/es6-classes-loose/calling-super-properties/expected.js similarity index 100% rename from test/fixtures/transformation/es6-classes-fast/calling-super-properties/expected.js rename to test/fixtures/transformation/es6-classes-loose/calling-super-properties/expected.js diff --git a/test/fixtures/transformation/es6-classes-loose/options.json b/test/fixtures/transformation/es6-classes-loose/options.json new file mode 100644 index 0000000000..b928f940e6 --- /dev/null +++ b/test/fixtures/transformation/es6-classes-loose/options.json @@ -0,0 +1,3 @@ +{ + "loose": ["classes"] +} diff --git a/test/fixtures/transformation/es6-classes-fast/super-class-id-member-expression/actual.js b/test/fixtures/transformation/es6-classes-loose/super-class-id-member-expression/actual.js similarity index 100% rename from test/fixtures/transformation/es6-classes-fast/super-class-id-member-expression/actual.js rename to test/fixtures/transformation/es6-classes-loose/super-class-id-member-expression/actual.js diff --git a/test/fixtures/transformation/es6-classes-fast/super-class-id-member-expression/expected.js b/test/fixtures/transformation/es6-classes-loose/super-class-id-member-expression/expected.js similarity index 100% rename from test/fixtures/transformation/es6-classes-fast/super-class-id-member-expression/expected.js rename to test/fixtures/transformation/es6-classes-loose/super-class-id-member-expression/expected.js diff --git a/test/fixtures/transformation/es6-classes-fast/super-class/actual.js b/test/fixtures/transformation/es6-classes-loose/super-class/actual.js similarity index 100% rename from test/fixtures/transformation/es6-classes-fast/super-class/actual.js rename to test/fixtures/transformation/es6-classes-loose/super-class/actual.js diff --git a/test/fixtures/transformation/es6-classes-fast/super-class/expected.js b/test/fixtures/transformation/es6-classes-loose/super-class/expected.js similarity index 100% rename from test/fixtures/transformation/es6-classes-fast/super-class/expected.js rename to test/fixtures/transformation/es6-classes-loose/super-class/expected.js diff --git a/test/fixtures/transformation/es6-classes-fast/super-function-fallback/actual.js b/test/fixtures/transformation/es6-classes-loose/super-function-fallback/actual.js similarity index 100% rename from test/fixtures/transformation/es6-classes-fast/super-function-fallback/actual.js rename to test/fixtures/transformation/es6-classes-loose/super-function-fallback/actual.js diff --git a/test/fixtures/transformation/es6-classes-fast/super-function-fallback/expected.js b/test/fixtures/transformation/es6-classes-loose/super-function-fallback/expected.js similarity index 100% rename from test/fixtures/transformation/es6-classes-fast/super-function-fallback/expected.js rename to test/fixtures/transformation/es6-classes-loose/super-function-fallback/expected.js diff --git a/test/fixtures/transformation/es6-for-of-fast/options.json b/test/fixtures/transformation/es6-for-of-fast/options.json deleted file mode 100644 index 20a82b96e0..0000000000 --- a/test/fixtures/transformation/es6-for-of-fast/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "fast": ["forOf"] -} diff --git a/test/fixtures/transformation/es6-for-of-fast/identifier/actual.js b/test/fixtures/transformation/es6-for-of-loose/identifier/actual.js similarity index 100% rename from test/fixtures/transformation/es6-for-of-fast/identifier/actual.js rename to test/fixtures/transformation/es6-for-of-loose/identifier/actual.js diff --git a/test/fixtures/transformation/es6-for-of-fast/identifier/expected.js b/test/fixtures/transformation/es6-for-of-loose/identifier/expected.js similarity index 100% rename from test/fixtures/transformation/es6-for-of-fast/identifier/expected.js rename to test/fixtures/transformation/es6-for-of-loose/identifier/expected.js diff --git a/test/fixtures/transformation/es6-for-of-fast/let/actual.js b/test/fixtures/transformation/es6-for-of-loose/let/actual.js similarity index 100% rename from test/fixtures/transformation/es6-for-of-fast/let/actual.js rename to test/fixtures/transformation/es6-for-of-loose/let/actual.js diff --git a/test/fixtures/transformation/es6-for-of-fast/let/expected.js b/test/fixtures/transformation/es6-for-of-loose/let/expected.js similarity index 100% rename from test/fixtures/transformation/es6-for-of-fast/let/expected.js rename to test/fixtures/transformation/es6-for-of-loose/let/expected.js diff --git a/test/fixtures/transformation/es6-for-of-fast/multiple/actual.js b/test/fixtures/transformation/es6-for-of-loose/multiple/actual.js similarity index 100% rename from test/fixtures/transformation/es6-for-of-fast/multiple/actual.js rename to test/fixtures/transformation/es6-for-of-loose/multiple/actual.js diff --git a/test/fixtures/transformation/es6-for-of-fast/multiple/expected.js b/test/fixtures/transformation/es6-for-of-loose/multiple/expected.js similarity index 100% rename from test/fixtures/transformation/es6-for-of-fast/multiple/expected.js rename to test/fixtures/transformation/es6-for-of-loose/multiple/expected.js diff --git a/test/fixtures/transformation/es6-for-of-loose/options.json b/test/fixtures/transformation/es6-for-of-loose/options.json new file mode 100644 index 0000000000..c2821829bf --- /dev/null +++ b/test/fixtures/transformation/es6-for-of-loose/options.json @@ -0,0 +1,3 @@ +{ + "loose": ["forOf"] +} diff --git a/test/fixtures/transformation/es6-for-of-fast/var/actual.js b/test/fixtures/transformation/es6-for-of-loose/var/actual.js similarity index 100% rename from test/fixtures/transformation/es6-for-of-fast/var/actual.js rename to test/fixtures/transformation/es6-for-of-loose/var/actual.js diff --git a/test/fixtures/transformation/es6-for-of-fast/var/expected.js b/test/fixtures/transformation/es6-for-of-loose/var/expected.js similarity index 100% rename from test/fixtures/transformation/es6-for-of-fast/var/expected.js rename to test/fixtures/transformation/es6-for-of-loose/var/expected.js