remove isDynamic checks and always execute those expressions **once**
This commit is contained in:
parent
5a622ac9c7
commit
d945379b5b
@ -89,7 +89,7 @@ Class.prototype.run = function () {
|
|||||||
this.closure = true;
|
this.closure = true;
|
||||||
|
|
||||||
// so we're only evaluating it once
|
// so we're only evaluating it once
|
||||||
var superRef = t.getUid(superName, this.file);
|
var superRef = this.scope.generateUidBasedOnNode(superName, this.file);
|
||||||
body.unshift(t.variableDeclaration("var", [
|
body.unshift(t.variableDeclaration("var", [
|
||||||
t.variableDeclarator(superRef, superName)
|
t.variableDeclarator(superRef, superName)
|
||||||
]));
|
]));
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
var t = require("../../types");
|
var t = require("../../types");
|
||||||
|
|
||||||
exports.ObjectExpression = function (node, parent, file) {
|
exports.ObjectExpression = function (node, parent, file, scope) {
|
||||||
var hasComputed = false;
|
var hasComputed = false;
|
||||||
var prop;
|
var prop;
|
||||||
var key;
|
var key;
|
||||||
@ -13,7 +13,7 @@ exports.ObjectExpression = function (node, parent, file) {
|
|||||||
|
|
||||||
if (!hasComputed) return;
|
if (!hasComputed) return;
|
||||||
|
|
||||||
var objId = t.getUid(parent, file);
|
var objId = scope.generateUidBasedOnNode(parent, file);
|
||||||
|
|
||||||
var body = [];
|
var body = [];
|
||||||
var container = t.functionExpression(null, [], t.blockStatement(body));
|
var container = t.functionExpression(null, [], t.blockStatement(body));
|
||||||
|
|||||||
@ -75,7 +75,7 @@ var pushArrayPattern = function (opts, nodes, pattern, parentId) {
|
|||||||
|
|
||||||
var toArray = opts.file.toArray(parentId, !hasSpreadElement && pattern.elements.length);
|
var toArray = opts.file.toArray(parentId, !hasSpreadElement && pattern.elements.length);
|
||||||
|
|
||||||
var _parentId = t.getUid(parentId, opts.file, opts.scope);
|
var _parentId = opts.scope.generateUidBasedOnNode(parentId, opts.file);
|
||||||
nodes.push(t.variableDeclaration("var", [
|
nodes.push(t.variableDeclaration("var", [
|
||||||
t.variableDeclarator(_parentId, toArray)
|
t.variableDeclarator(_parentId, toArray)
|
||||||
]));
|
]));
|
||||||
@ -113,7 +113,7 @@ var pushPattern = function (opts) {
|
|||||||
var scope = opts.scope;
|
var scope = opts.scope;
|
||||||
|
|
||||||
if (!t.isMemberExpression(parentId) && !t.isIdentifier(parentId)) {
|
if (!t.isMemberExpression(parentId) && !t.isIdentifier(parentId)) {
|
||||||
var key = t.getUid(parentId, file, scope);
|
var key = scope.generateUidBasedOnNode(parentId, file);
|
||||||
|
|
||||||
nodes.push(t.variableDeclaration("var", [
|
nodes.push(t.variableDeclaration("var", [
|
||||||
t.variableDeclarator(key, parentId)
|
t.variableDeclarator(key, parentId)
|
||||||
|
|||||||
@ -7,7 +7,7 @@ exports.Property = function (node, parent, file, scope) {
|
|||||||
|
|
||||||
node.method = false;
|
node.method = false;
|
||||||
|
|
||||||
var key = t.toComputedPropertyKey(node);
|
var key = t.toComputedKey(node, node.key);
|
||||||
if (!t.isLiteral(key)) return; // we can't set a function id with this
|
if (!t.isLiteral(key)) return; // we can't set a function id with this
|
||||||
|
|
||||||
var id = t.toIdentifier(key.value);
|
var id = t.toIdentifier(key.value);
|
||||||
@ -46,7 +46,7 @@ exports.Property = function (node, parent, file, scope) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.ObjectExpression = function (node, parent, file) {
|
exports.ObjectExpression = function (node, parent, file, scope) {
|
||||||
var mutatorMap = {};
|
var mutatorMap = {};
|
||||||
var hasAny = false;
|
var hasAny = false;
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ exports.ObjectExpression = function (node, parent, file) {
|
|||||||
if (!hasAny) return;
|
if (!hasAny) return;
|
||||||
|
|
||||||
if (node.properties.length) {
|
if (node.properties.length) {
|
||||||
var objId = t.getUid(parent, file);
|
var objId = scope.generateUidBasedOnNode(parent, file);
|
||||||
|
|
||||||
return util.template("object-define-properties-closure", {
|
return util.template("object-define-properties-closure", {
|
||||||
KEY: objId,
|
KEY: objId,
|
||||||
|
|||||||
@ -77,16 +77,13 @@ exports.CallExpression = function (node, parent, file, scope) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var callee = node.callee;
|
var callee = node.callee;
|
||||||
var temp;
|
|
||||||
|
|
||||||
if (t.isMemberExpression(callee)) {
|
if (t.isMemberExpression(callee)) {
|
||||||
contextLiteral = callee.object;
|
var temp = scope.generateTempBasedOnNode(callee.object, file);
|
||||||
|
if (temp) {
|
||||||
if (t.isDynamic(contextLiteral)) {
|
|
||||||
temp = contextLiteral = scope.generateTemp(file);
|
|
||||||
callee.object = t.assignmentExpression("=", temp, callee.object);
|
callee.object = t.assignmentExpression("=", temp, callee.object);
|
||||||
|
contextLiteral = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
t.appendToMemberExpression(callee, t.identifier("apply"));
|
t.appendToMemberExpression(callee, t.identifier("apply"));
|
||||||
} else {
|
} else {
|
||||||
node.callee = t.memberExpression(node.callee, t.identifier("apply"));
|
node.callee = t.memberExpression(node.callee, t.identifier("apply"));
|
||||||
|
|||||||
@ -30,10 +30,8 @@ exports.AssignmentExpression = function (node, parent, file, scope) {
|
|||||||
|
|
||||||
// we need to return `node.right`
|
// we need to return `node.right`
|
||||||
if (!t.isExpressionStatement(parent)) {
|
if (!t.isExpressionStatement(parent)) {
|
||||||
// `node.right` isn't a simple identifier so we need to reference it
|
temp = scope.generateTempBasedOnNode(node.right, file);
|
||||||
if (t.isDynamic(value)) {
|
if (temp) value = temp;
|
||||||
temp = value = scope.generateTemp(file);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.operator !== "=") {
|
if (node.operator !== "=") {
|
||||||
@ -80,11 +78,7 @@ exports.CallExpression = function (node, parent, file, scope) {
|
|||||||
var callee = node.callee;
|
var callee = node.callee;
|
||||||
if (!t.isVirtualPropertyExpression(callee)) return;
|
if (!t.isVirtualPropertyExpression(callee)) return;
|
||||||
|
|
||||||
var temp;
|
var temp = scope.generateTempBasedOnNode(callee.object, file);
|
||||||
if (t.isDynamic(callee.object)) {
|
|
||||||
// we need to save `callee.object` so we can call it again
|
|
||||||
temp = scope.generateTemp(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
var call = util.template("abstract-expression-call", {
|
var call = util.template("abstract-expression-call", {
|
||||||
PROPERTY: callee.property,
|
PROPERTY: callee.property,
|
||||||
|
|||||||
@ -5,7 +5,7 @@ var t = require("../../types");
|
|||||||
exports.experimental = true;
|
exports.experimental = true;
|
||||||
|
|
||||||
var build = function (node, parent, file, scope) {
|
var build = function (node, parent, file, scope) {
|
||||||
var uid = t.getUid(parent, file, scope);
|
var uid = scope.generateUidBasedOnNode(parent, file);
|
||||||
|
|
||||||
var container = util.template("array-comprehension-container", {
|
var container = util.template("array-comprehension-container", {
|
||||||
KEY: uid
|
KEY: uid
|
||||||
|
|||||||
@ -10,7 +10,7 @@ var getPropRef = function (nodes, prop, file, scope) {
|
|||||||
if (t.isIdentifier(prop)) {
|
if (t.isIdentifier(prop)) {
|
||||||
return t.literal(prop.name);
|
return t.literal(prop.name);
|
||||||
} else {
|
} else {
|
||||||
var temp = t.getUid(prop, file, scope);
|
var temp = scope.generateUidBasedOnNode(prop, file);
|
||||||
nodes.push(t.variableDeclaration("var", [
|
nodes.push(t.variableDeclaration("var", [
|
||||||
t.variableDeclarator(temp, prop)
|
t.variableDeclarator(temp, prop)
|
||||||
]));
|
]));
|
||||||
@ -19,15 +19,11 @@ var getPropRef = function (nodes, prop, file, scope) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var getObjRef = function (nodes, obj, file, scope) {
|
var getObjRef = function (nodes, obj, file, scope) {
|
||||||
if (t.isDynamic(obj)) {
|
var temp = scope.generateUidBasedOnNode(obj, file);
|
||||||
var temp = t.getUid(obj, file, scope);
|
|
||||||
nodes.push(t.variableDeclaration("var", [
|
nodes.push(t.variableDeclaration("var", [
|
||||||
t.variableDeclarator(temp, obj)
|
t.variableDeclarator(temp, obj)
|
||||||
]));
|
]));
|
||||||
return temp;
|
return temp;
|
||||||
} else {
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var buildHasOwn = function (obj, prop, file) {
|
var buildHasOwn = function (obj, prop, file) {
|
||||||
|
|||||||
@ -5,10 +5,8 @@ exports.BindMemberExpression = function (node, parent, file, scope) {
|
|||||||
var object = node.object;
|
var object = node.object;
|
||||||
var prop = node.property;
|
var prop = node.property;
|
||||||
|
|
||||||
var temp;
|
var temp = scope.generateTempBasedOnNode(node.object, file);
|
||||||
if (t.isDynamic(object)) {
|
if (temp) object = temp;
|
||||||
temp = object = scope.generateTemp(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
var call = t.callExpression(
|
var call = t.callExpression(
|
||||||
t.memberExpression(t.memberExpression(object, prop), t.identifier("bind")),
|
t.memberExpression(t.memberExpression(object, prop), t.identifier("bind")),
|
||||||
@ -33,7 +31,6 @@ exports.BindFunctionExpression = function (node, parent, file, scope) {
|
|||||||
]));
|
]));
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_.find(node.arguments, t.isDynamic)) {
|
|
||||||
var temp = scope.generateTemp(file, "args");
|
var temp = scope.generateTemp(file, "args");
|
||||||
|
|
||||||
return t.sequenceExpression([
|
return t.sequenceExpression([
|
||||||
@ -42,7 +39,4 @@ exports.BindFunctionExpression = function (node, parent, file, scope) {
|
|||||||
return t.memberExpression(temp, t.literal(i), true);
|
return t.memberExpression(temp, t.literal(i), true);
|
||||||
}))
|
}))
|
||||||
]);
|
]);
|
||||||
} else {
|
|
||||||
return buildCall(node.arguments);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -31,6 +31,13 @@ Scope.add = function (node, references) {
|
|||||||
_.defaults(references, t.getIds(node, true));
|
_.defaults(references, t.getIds(node, true));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description
|
||||||
|
*
|
||||||
|
* @param {File} file
|
||||||
|
* @param {String} [name="temp"]
|
||||||
|
*/
|
||||||
|
|
||||||
Scope.prototype.generateTemp = function (file, name) {
|
Scope.prototype.generateTemp = function (file, name) {
|
||||||
var id = file.generateUidIdentifier(name || "temp", this);
|
var id = file.generateUidIdentifier(name || "temp", this);
|
||||||
this.push({
|
this.push({
|
||||||
@ -40,6 +47,83 @@ Scope.prototype.generateTemp = function (file, name) {
|
|||||||
return id;
|
return id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Description
|
||||||
|
*
|
||||||
|
* @param {Object} parent
|
||||||
|
* @param {File} file
|
||||||
|
* @param {Scope} scope
|
||||||
|
* @returns {Object}
|
||||||
|
*/
|
||||||
|
|
||||||
|
Scope.prototype.generateUidBasedOnNode = function (parent, file) {
|
||||||
|
var node = parent;
|
||||||
|
|
||||||
|
if (t.isAssignmentExpression(parent)) {
|
||||||
|
node = parent.left;
|
||||||
|
} else if (t.isVariableDeclarator(parent)) {
|
||||||
|
node = parent.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
var id = "ref";
|
||||||
|
|
||||||
|
if (t.isProperty(node)) {
|
||||||
|
node = node.key;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t.isIdentifier(node)) {
|
||||||
|
id = node.name;
|
||||||
|
} else if (t.isLiteral(node)) {
|
||||||
|
id = node.value;
|
||||||
|
} else if (t.isMemberExpression(node)) {
|
||||||
|
var parts = [];
|
||||||
|
|
||||||
|
var add = function (node) {
|
||||||
|
if (t.isMemberExpression(node)) {
|
||||||
|
add(node.object);
|
||||||
|
add(node.property);
|
||||||
|
} else if (t.isIdentifier(node)) {
|
||||||
|
parts.push(node.name);
|
||||||
|
} else if (t.isLiteral(node)) {
|
||||||
|
parts.push(node.value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
add(node);
|
||||||
|
|
||||||
|
id = parts.join("$");
|
||||||
|
}
|
||||||
|
|
||||||
|
id = id.replace(/^_/, "");
|
||||||
|
|
||||||
|
return file.generateUidIdentifier(id, this);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description
|
||||||
|
*
|
||||||
|
* @param {Object} node
|
||||||
|
* @param {File} file
|
||||||
|
* @returns {Object}
|
||||||
|
*/
|
||||||
|
|
||||||
|
Scope.prototype.generateTempBasedOnNode = function (node, file) {
|
||||||
|
if (!t.isIdentifier(node) && !t.isMemberExpression(node)) {
|
||||||
|
throw new TypeError("Invalid node type " + JSON.stringify(node.type) + " passed to Scope.prototype.generateTempBasedOnNode");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t.isIdentifier(node) && this.has(node.name, true)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var id = this.generateUidBasedOnNode(node, file);
|
||||||
|
this.push({
|
||||||
|
key: id.name,
|
||||||
|
id: id
|
||||||
|
});
|
||||||
|
return id;
|
||||||
|
};
|
||||||
|
|
||||||
Scope.prototype.getInfo = function () {
|
Scope.prototype.getInfo = function () {
|
||||||
var block = this.block;
|
var block = this.block;
|
||||||
if (block._scopeInfo) return block._scopeInfo;
|
if (block._scopeInfo) return block._scopeInfo;
|
||||||
@ -123,6 +207,12 @@ Scope.prototype.getInfo = function () {
|
|||||||
return info;
|
return info;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description
|
||||||
|
*
|
||||||
|
* @param {Object} opts
|
||||||
|
*/
|
||||||
|
|
||||||
Scope.prototype.push = function (opts) {
|
Scope.prototype.push = function (opts) {
|
||||||
var block = this.block;
|
var block = this.block;
|
||||||
|
|
||||||
@ -143,33 +233,84 @@ Scope.prototype.push = function (opts) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description
|
||||||
|
*
|
||||||
|
* @param {Object} node
|
||||||
|
*/
|
||||||
|
|
||||||
Scope.prototype.add = function (node) {
|
Scope.prototype.add = function (node) {
|
||||||
Scope.add(node, this.references);
|
Scope.add(node, this.references);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description
|
||||||
|
*
|
||||||
|
* @param {String} [id]
|
||||||
|
* @param {Boolean} [decl]
|
||||||
|
*/
|
||||||
|
|
||||||
Scope.prototype.get = function (id, decl) {
|
Scope.prototype.get = function (id, decl) {
|
||||||
return id && (this.getOwn(id, decl) || this.parentGet(id, decl));
|
return id && (this.getOwn(id, decl) || this.parentGet(id, decl));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description
|
||||||
|
*
|
||||||
|
* @param {String} [id]
|
||||||
|
* @param {Boolean} [decl]
|
||||||
|
*/
|
||||||
|
|
||||||
Scope.prototype.getOwn = function (id, decl) {
|
Scope.prototype.getOwn = function (id, decl) {
|
||||||
var refs = this.references;
|
var refs = this.references;
|
||||||
if (decl) refs = this.declarations;
|
if (decl) refs = this.declarations;
|
||||||
return _.has(refs, id) && refs[id];
|
return _.has(refs, id) && refs[id];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description
|
||||||
|
*
|
||||||
|
* @param {String} [id]
|
||||||
|
* @param {Boolean} [decl]
|
||||||
|
*/
|
||||||
|
|
||||||
Scope.prototype.parentGet = function (id, decl) {
|
Scope.prototype.parentGet = function (id, decl) {
|
||||||
return this.parent && this.parent.get(id, decl);
|
return this.parent && this.parent.get(id, decl);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description
|
||||||
|
*
|
||||||
|
* @param {String} [id]
|
||||||
|
* @param {Boolean} [decl]
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
|
||||||
Scope.prototype.has = function (id, decl) {
|
Scope.prototype.has = function (id, decl) {
|
||||||
return (id && (this.hasOwn(id, decl) || this.parentHas(id, decl))) ||
|
return (id && (this.hasOwn(id, decl) || this.parentHas(id, decl))) ||
|
||||||
_.contains(Scope.defaultDeclarations, id);
|
_.contains(Scope.defaultDeclarations, id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description
|
||||||
|
*
|
||||||
|
* @param {String} [id]
|
||||||
|
* @param {Boolean} [decl]
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
|
||||||
Scope.prototype.hasOwn = function (id, decl) {
|
Scope.prototype.hasOwn = function (id, decl) {
|
||||||
return !!this.getOwn(id, decl);
|
return !!this.getOwn(id, decl);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description
|
||||||
|
*
|
||||||
|
* @param {String} [id]
|
||||||
|
* @param {Boolean} [decl]
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
|
||||||
Scope.prototype.parentHas = function (id, decl) {
|
Scope.prototype.parentHas = function (id, decl) {
|
||||||
return this.parent && this.parent.has(id, decl);
|
return this.parent && this.parent.has(id, decl);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -71,9 +71,8 @@ _.each(t.FLIPPED_ALIAS_KEYS, function (types, type) {
|
|||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
t.toComputedPropertyKey = function (prop) {
|
t.toComputedKey = function (node, key) {
|
||||||
var key = prop.key;
|
if (!node.computed) {
|
||||||
if (!prop.computed) {
|
|
||||||
if (t.isIdentifier(key)) key = t.literal(key.name);
|
if (t.isIdentifier(key)) key = t.literal(key.name);
|
||||||
}
|
}
|
||||||
return key;
|
return key;
|
||||||
@ -126,6 +125,10 @@ t.toSequenceExpression = function (nodes, scope) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (exprs.length === 1) {
|
||||||
|
return exprs[0]
|
||||||
|
}
|
||||||
|
|
||||||
return t.sequenceExpression(exprs);
|
return t.sequenceExpression(exprs);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -174,25 +177,6 @@ t.prependToMemberExpression = function (member, append) {
|
|||||||
return member;
|
return member;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Description
|
|
||||||
*
|
|
||||||
* @param {Object} node
|
|
||||||
* @returns {Boolean}
|
|
||||||
*/
|
|
||||||
|
|
||||||
t.isDynamic = function (node) {
|
|
||||||
if (t.isExpressionStatement(node)) {
|
|
||||||
return t.isDynamic(node.expression);
|
|
||||||
} else if (t.isIdentifier(node) || t.isLiteral(node) || t.isThisExpression(node)) {
|
|
||||||
return false;
|
|
||||||
} else if (t.isMemberExpression(node)) {
|
|
||||||
return t.isDynamic(node.object) || t.isDynamic(node.property);
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description
|
* Description
|
||||||
*
|
*
|
||||||
@ -341,58 +325,6 @@ t.toBlock = function (node, parent) {
|
|||||||
return t.blockStatement(node);
|
return t.blockStatement(node);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Description
|
|
||||||
*
|
|
||||||
* @param {Object} parent
|
|
||||||
* @param {File} file
|
|
||||||
* @param {Scope} scope
|
|
||||||
* @returns {Object}
|
|
||||||
*/
|
|
||||||
|
|
||||||
t.getUid = function (parent, file, scope) {
|
|
||||||
var node = parent;
|
|
||||||
|
|
||||||
if (t.isAssignmentExpression(parent)) {
|
|
||||||
node = parent.left;
|
|
||||||
} else if (t.isVariableDeclarator(parent)) {
|
|
||||||
node = parent.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
var id = "ref";
|
|
||||||
|
|
||||||
if (t.isProperty(node)) {
|
|
||||||
node = node.key;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (t.isIdentifier(node)) {
|
|
||||||
id = node.name;
|
|
||||||
} else if (t.isLiteral(node)) {
|
|
||||||
id = node.value;
|
|
||||||
} else if (t.isMemberExpression(node)) {
|
|
||||||
var parts = [];
|
|
||||||
|
|
||||||
var add = function (node) {
|
|
||||||
if (t.isMemberExpression(node)) {
|
|
||||||
add(node.object);
|
|
||||||
add(node.property);
|
|
||||||
} else if (t.isIdentifier(node)) {
|
|
||||||
parts.push(node.name);
|
|
||||||
} else if (t.isLiteral(node)) {
|
|
||||||
parts.push(node.value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
add(node);
|
|
||||||
|
|
||||||
id = parts.join("$");
|
|
||||||
}
|
|
||||||
|
|
||||||
id = id.replace(/^_/, "");
|
|
||||||
|
|
||||||
return file.generateUidIdentifier(id, scope);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description
|
* Description
|
||||||
*
|
*
|
||||||
|
|||||||
@ -16,30 +16,33 @@ var _inherits = function (child, parent) {
|
|||||||
var Test = (function () {
|
var Test = (function () {
|
||||||
var _Foo = Foo;
|
var _Foo = Foo;
|
||||||
var Test = function Test() {
|
var Test = function Test() {
|
||||||
|
var _Foo$prototype$test, _Foo$prototype$test2;
|
||||||
woops["super"].test();
|
woops["super"].test();
|
||||||
_Foo.call(this);
|
_Foo.call(this);
|
||||||
_Foo.prototype.test.call(this);
|
_Foo.prototype.test.call(this);
|
||||||
foob(_Foo);
|
foob(_Foo);
|
||||||
|
|
||||||
_Foo.call.apply(_Foo, [this].concat(_slice.call(arguments)));
|
_Foo.call.apply(null, [this].concat(_slice.call(arguments)));
|
||||||
_Foo.call.apply(_Foo, [this, "test"].concat(_slice.call(arguments)));
|
_Foo.call.apply(null, [this, "test"].concat(_slice.call(arguments)));
|
||||||
|
|
||||||
_Foo.prototype.test.call.apply(_Foo.prototype.test, [this].concat(_slice.call(arguments)));
|
(_Foo$prototype$test = _Foo.prototype.test).call.apply(_Foo$prototype$test, [this].concat(_slice.call(arguments)));
|
||||||
_Foo.prototype.test.call.apply(_Foo.prototype.test, [this, "test"].concat(_slice.call(arguments)));
|
(_Foo$prototype$test2 = _Foo.prototype.test).call.apply(_Foo$prototype$test2, [this, "test"].concat(_slice.call(arguments)));
|
||||||
};
|
};
|
||||||
|
|
||||||
_inherits(Test, _Foo);
|
_inherits(Test, _Foo);
|
||||||
|
|
||||||
Test.prototype.test = function () {
|
Test.prototype.test = function () {
|
||||||
|
var _Foo$prototype$test3, _Foo$prototype$test4;
|
||||||
_Foo.prototype.test.call(this);
|
_Foo.prototype.test.call(this);
|
||||||
_Foo.prototype.test.call.apply(_Foo.prototype.test, [this].concat(_slice.call(arguments)));
|
(_Foo$prototype$test3 = _Foo.prototype.test).call.apply(_Foo$prototype$test3, [this].concat(_slice.call(arguments)));
|
||||||
_Foo.prototype.test.call.apply(_Foo.prototype.test, [this, "test"].concat(_slice.call(arguments)));
|
(_Foo$prototype$test4 = _Foo.prototype.test).call.apply(_Foo$prototype$test4, [this, "test"].concat(_slice.call(arguments)));
|
||||||
};
|
};
|
||||||
|
|
||||||
Test.foo = function () {
|
Test.foo = function () {
|
||||||
|
var _Foo$foo, _Foo$foo2;
|
||||||
_Foo.foo.call(this);
|
_Foo.foo.call(this);
|
||||||
_Foo.foo.call.apply(_Foo.foo, [this].concat(_slice.call(arguments)));
|
(_Foo$foo = _Foo.foo).call.apply(_Foo$foo, [this].concat(_slice.call(arguments)));
|
||||||
_Foo.foo.call.apply(_Foo.foo, [this, "test"].concat(_slice.call(arguments)));
|
(_Foo$foo2 = _Foo.foo).call.apply(_Foo$foo2, [this, "test"].concat(_slice.call(arguments)));
|
||||||
};
|
};
|
||||||
|
|
||||||
return Test;
|
return Test;
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var _obj;
|
||||||
var _toArray = function (arr) {
|
var _toArray = function (arr) {
|
||||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||||
};
|
};
|
||||||
|
|
||||||
obj[method].apply(obj, [foo, bar].concat(_toArray(args)));
|
(_obj = obj)[method].apply(_obj, [foo, bar].concat(_toArray(args)));
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var _obj;
|
||||||
var _toArray = function (arr) {
|
var _toArray = function (arr) {
|
||||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||||
};
|
};
|
||||||
|
|
||||||
obj[method].apply(obj, _toArray(args));
|
(_obj = obj)[method].apply(_obj, _toArray(args));
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var _foob, _foob$test;
|
||||||
var _toArray = function (arr) {
|
var _toArray = function (arr) {
|
||||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||||
};
|
};
|
||||||
|
|
||||||
foob.add.apply(foob, [foo, bar].concat(_toArray(numbers)));
|
(_foob = foob).add.apply(_foob, [foo, bar].concat(_toArray(numbers)));
|
||||||
foob.test.add.apply(foob.test, [foo, bar].concat(_toArray(numbers)));
|
(_foob$test = foob.test).add.apply(_foob$test, [foo, bar].concat(_toArray(numbers)));
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var _foob, _foob$test;
|
||||||
var _toArray = function (arr) {
|
var _toArray = function (arr) {
|
||||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||||
};
|
};
|
||||||
|
|
||||||
foob.add.apply(foob, _toArray(numbers));
|
(_foob = foob).add.apply(_foob, _toArray(numbers));
|
||||||
foob.test.add.apply(foob.test, _toArray(numbers));
|
(_foob$test = foob.test).add.apply(_foob$test, _toArray(numbers));
|
||||||
|
|||||||
@ -1,2 +1,6 @@
|
|||||||
foo::bar();
|
foo::bar();
|
||||||
foo::bar("arg");
|
foo::bar("arg");
|
||||||
|
|
||||||
|
var test = "test";
|
||||||
|
test::bar();
|
||||||
|
test::bar("arg");
|
||||||
|
|||||||
@ -1,4 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
bar[Symbol.referenceGet](foo).call(foo);
|
var _foo, _foo2;
|
||||||
bar[Symbol.referenceGet](foo).call(foo, "arg");
|
_foo = foo, bar[Symbol.referenceGet](_foo).call(_foo);
|
||||||
|
_foo2 = foo, bar[Symbol.referenceGet](_foo2).call(_foo2, "arg");
|
||||||
|
|
||||||
|
var test = "test";
|
||||||
|
bar[Symbol.referenceGet](test).call(test);
|
||||||
|
bar[Symbol.referenceGet](test).call(test, "arg");
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
delete foo::bar;
|
delete foo::bar;
|
||||||
|
|
||||||
if (delete foo::bar);
|
if (delete foo::bar) {}
|
||||||
|
|||||||
@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
bar[Symbol.referenceDelete](foo);
|
bar[Symbol.referenceDelete](foo);
|
||||||
|
|
||||||
if ((bar[Symbol.referenceDelete](foo), true)) ;
|
if ((bar[Symbol.referenceDelete](foo), true)) {}
|
||||||
|
|||||||
@ -1,2 +1,3 @@
|
|||||||
|
var baz = "foo";
|
||||||
foo::bar = baz;
|
foo::bar = baz;
|
||||||
if (foo::bar = baz);
|
if (foo::bar = baz) {}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var baz = "foo";
|
||||||
bar[Symbol.referenceSet](foo, baz);
|
bar[Symbol.referenceSet](foo, baz);
|
||||||
if ((bar[Symbol.referenceSet](foo, baz), baz)) ;
|
if ((bar[Symbol.referenceSet](foo, baz), baz)) {}
|
||||||
|
|||||||
@ -1,25 +1,27 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var _ref2, _obj2, _ref4;
|
var _obj2, _obj4, _ref2, _obj6, _ref4;
|
||||||
var _hasOwn = Object.prototype.hasOwnProperty;
|
var _hasOwn = Object.prototype.hasOwnProperty;
|
||||||
var obj = {};
|
var obj = {};
|
||||||
|
|
||||||
if (!_hasOwn.call(obj, "x")) obj.x = 2;
|
var _obj = obj;
|
||||||
|
if (!_hasOwn.call(_obj, "x")) _obj.x = 2;
|
||||||
|
|
||||||
|
|
||||||
console.log((!_hasOwn.call(obj, "x") && (obj.x = 2), obj.x));
|
console.log((_obj2 = obj, !_hasOwn.call(_obj2, "x") && (_obj2.x = 2), _obj2.x));
|
||||||
|
|
||||||
|
var _obj3 = obj;
|
||||||
var _ref = x();
|
var _ref = x();
|
||||||
|
|
||||||
if (!_hasOwn.call(obj, _ref)) obj[_ref] = 2;
|
if (!_hasOwn.call(_obj3, _ref)) _obj3[_ref] = 2;
|
||||||
|
|
||||||
|
|
||||||
console.log((_ref2 = x(), !_hasOwn.call(obj, _ref2) && (obj[_ref2] = 2), obj[_ref2]));
|
console.log((_obj4 = obj, _ref2 = x(), !_hasOwn.call(_obj4, _ref2) && (_obj4[_ref2] = 2), _obj4[_ref2]));
|
||||||
|
|
||||||
var _obj = obj[y()];
|
var _obj5 = obj[y()];
|
||||||
var _ref3 = x();
|
var _ref3 = x();
|
||||||
|
|
||||||
if (!_hasOwn.call(_obj, _ref3)) _obj[_ref3] = 2;
|
if (!_hasOwn.call(_obj5, _ref3)) _obj5[_ref3] = 2;
|
||||||
|
|
||||||
|
|
||||||
console.log((_obj2 = obj[y()], _ref4 = x(), !_hasOwn.call(_obj2, _ref4) && (_obj2[_ref4] = 2), _obj2[_ref4]));
|
console.log((_obj6 = obj[y()], _ref4 = x(), !_hasOwn.call(_obj6, _ref4) && (_obj6[_ref4] = 2), _obj6[_ref4]));
|
||||||
|
|||||||
@ -1,22 +1,22 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var _temp, _args;
|
var _obj, _obj2, _obj$foo, _obj$foo2, _obj3, _args, _args2, _args3;
|
||||||
var fn = obj.method.bind(obj);
|
var fn = (_obj = obj, _obj.method.bind(_obj));
|
||||||
var fn = obj.method.bind(obj, "foob");
|
var fn = (_obj2 = obj, _obj2.method.bind(_obj2, "foob"));
|
||||||
var fn = obj[foo].method.bind(obj[foo]);
|
var fn = (_obj$foo = obj[foo], _obj$foo.method.bind(_obj$foo));
|
||||||
var fn = obj.foo.method.bind(obj.foo);
|
var fn = (_obj$foo2 = obj.foo, _obj$foo2.method.bind(_obj$foo2));
|
||||||
var fn = (_temp = obj[foo()], _temp.method.bind(_temp));
|
var fn = (_obj3 = obj[foo()], _obj3.method.bind(_obj3));
|
||||||
|
|
||||||
["foo", "bar"].map(function (_val) {
|
["foo", "bar"].map((_args = [], function (_val) {
|
||||||
return _val.toUpperCase();
|
return _val.toUpperCase();
|
||||||
});
|
}));
|
||||||
[1.1234, 23.53245, 3].map(function (_val2) {
|
[1.1234, 23.53245, 3].map((_args2 = [2], function (_val2) {
|
||||||
return _val2.toFixed(2);
|
return _val2.toFixed(_args2[0]);
|
||||||
});
|
}));
|
||||||
|
|
||||||
var get = function () {
|
var get = function () {
|
||||||
return 2;
|
return 2;
|
||||||
};
|
};
|
||||||
[1.1234, 23.53245, 3].map((_args = [get()], function (_val3) {
|
[1.1234, 23.53245, 3].map((_args3 = [get()], function (_val3) {
|
||||||
return _val3.toFixed(_args[0]);
|
return _val3.toFixed(_args3[0]);
|
||||||
}));
|
}));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user