normalise whitespace after function keyword
This commit is contained in:
@@ -78,7 +78,7 @@ exports.Literal = function (node) {
|
||||
val = JSON.stringify(val);
|
||||
|
||||
// escape unicode characters
|
||||
val = val.replace(/[\u007f-\uffff]/g, function(c) {
|
||||
val = val.replace(/[\u007f-\uffff]/g, function (c) {
|
||||
return "\\u" + ("0000" + c.charCodeAt(0).toString(16)).slice(-4);
|
||||
});
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ function loc() {
|
||||
|
||||
// Sets the exact value of the given location to the offset of the next
|
||||
// Statement emitted.
|
||||
Emitter.prototype.mark = function(loc) {
|
||||
Emitter.prototype.mark = function (loc) {
|
||||
t.assertLiteral(loc);
|
||||
var index = this.listing.length;
|
||||
if (loc.value === -1) {
|
||||
@@ -77,7 +77,7 @@ Emitter.prototype.mark = function(loc) {
|
||||
return loc;
|
||||
};
|
||||
|
||||
Emitter.prototype.emit = function(node) {
|
||||
Emitter.prototype.emit = function (node) {
|
||||
if (t.isExpression(node)) node = t.expressionStatement(node);
|
||||
t.assertStatement(node);
|
||||
this.listing.push(node);
|
||||
@@ -85,20 +85,20 @@ Emitter.prototype.emit = function(node) {
|
||||
|
||||
// Shorthand for emitting assignment statements. This will come in handy
|
||||
// for assignments to temporary variables.
|
||||
Emitter.prototype.emitAssign = function(lhs, rhs) {
|
||||
Emitter.prototype.emitAssign = function (lhs, rhs) {
|
||||
this.emit(this.assign(lhs, rhs));
|
||||
return lhs;
|
||||
};
|
||||
|
||||
// Shorthand for an assignment statement.
|
||||
Emitter.prototype.assign = function(lhs, rhs) {
|
||||
Emitter.prototype.assign = function (lhs, rhs) {
|
||||
return t.expressionStatement(
|
||||
t.assignmentExpression("=", lhs, rhs));
|
||||
};
|
||||
|
||||
// Convenience function for generating expressions like context.next,
|
||||
// context.sent, and context.rval.
|
||||
Emitter.prototype.contextProperty = function(name, computed) {
|
||||
Emitter.prototype.contextProperty = function (name, computed) {
|
||||
return t.memberExpression(
|
||||
this.contextId,
|
||||
computed ? t.literal(name) : t.identifier(name),
|
||||
@@ -116,7 +116,7 @@ var volatileContextPropertyNames = {
|
||||
// A "volatile" context property is a MemberExpression like context.sent
|
||||
// that should probably be stored in a temporary variable when there's a
|
||||
// possibility the property will get overwritten.
|
||||
Emitter.prototype.isVolatileContextProperty = function(expr) {
|
||||
Emitter.prototype.isVolatileContextProperty = function (expr) {
|
||||
if (t.isMemberExpression(expr)) {
|
||||
if (expr.computed) {
|
||||
// If it's a computed property such as context[couldBeAnything],
|
||||
@@ -136,7 +136,7 @@ Emitter.prototype.isVolatileContextProperty = function(expr) {
|
||||
};
|
||||
|
||||
// Shorthand for setting context.rval and jumping to `context.stop()`.
|
||||
Emitter.prototype.stop = function(rval) {
|
||||
Emitter.prototype.stop = function (rval) {
|
||||
if (rval) {
|
||||
this.setReturnValue(rval);
|
||||
}
|
||||
@@ -144,7 +144,7 @@ Emitter.prototype.stop = function(rval) {
|
||||
this.jump(this.finalLoc);
|
||||
};
|
||||
|
||||
Emitter.prototype.setReturnValue = function(valuePath) {
|
||||
Emitter.prototype.setReturnValue = function (valuePath) {
|
||||
t.assertExpression(valuePath.value);
|
||||
|
||||
this.emitAssign(
|
||||
@@ -153,7 +153,7 @@ Emitter.prototype.setReturnValue = function(valuePath) {
|
||||
);
|
||||
};
|
||||
|
||||
Emitter.prototype.clearPendingException = function(tryLoc, assignee) {
|
||||
Emitter.prototype.clearPendingException = function (tryLoc, assignee) {
|
||||
t.assertLiteral(tryLoc);
|
||||
|
||||
var catchCall = t.callExpression(
|
||||
@@ -170,13 +170,13 @@ Emitter.prototype.clearPendingException = function(tryLoc, assignee) {
|
||||
|
||||
// Emits code for an unconditional jump to the given location, even if the
|
||||
// exact value of the location is not yet known.
|
||||
Emitter.prototype.jump = function(toLoc) {
|
||||
Emitter.prototype.jump = function (toLoc) {
|
||||
this.emitAssign(this.contextProperty("next"), toLoc);
|
||||
this.emit(t.breakStatement());
|
||||
};
|
||||
|
||||
// Conditional jump.
|
||||
Emitter.prototype.jumpIf = function(test, toLoc) {
|
||||
Emitter.prototype.jumpIf = function (test, toLoc) {
|
||||
t.assertExpression(test);
|
||||
t.assertLiteral(toLoc);
|
||||
|
||||
@@ -190,7 +190,7 @@ Emitter.prototype.jumpIf = function(test, toLoc) {
|
||||
};
|
||||
|
||||
// Conditional jump, with the condition negated.
|
||||
Emitter.prototype.jumpIfNot = function(test, toLoc) {
|
||||
Emitter.prototype.jumpIfNot = function (test, toLoc) {
|
||||
t.assertExpression(test);
|
||||
t.assertLiteral(toLoc);
|
||||
|
||||
@@ -217,11 +217,11 @@ Emitter.prototype.jumpIfNot = function(test, toLoc) {
|
||||
// other local variables, and since we just increment `nextTempId`
|
||||
// monotonically, uniqueness is assured.
|
||||
var nextTempId = 0;
|
||||
Emitter.prototype.makeTempVar = function() {
|
||||
Emitter.prototype.makeTempVar = function () {
|
||||
return this.contextProperty("t" + nextTempId++);
|
||||
};
|
||||
|
||||
Emitter.prototype.getContextFunction = function(id) {
|
||||
Emitter.prototype.getContextFunction = function (id) {
|
||||
var node = t.functionExpression(
|
||||
id || null,
|
||||
[this.contextId],
|
||||
@@ -244,7 +244,7 @@ Emitter.prototype.getContextFunction = function(id) {
|
||||
//
|
||||
// Each marked location in this.listing will correspond to one generated
|
||||
// case statement.
|
||||
Emitter.prototype.getDispatchLoop = function() {
|
||||
Emitter.prototype.getDispatchLoop = function () {
|
||||
var self = this;
|
||||
var cases = [];
|
||||
var current;
|
||||
@@ -253,7 +253,7 @@ Emitter.prototype.getDispatchLoop = function() {
|
||||
// case, we can skip the rest of the statements until the next case.
|
||||
var alreadyEnded = false;
|
||||
|
||||
self.listing.forEach(function(stmt, i) {
|
||||
self.listing.forEach(function (stmt, i) {
|
||||
if (self.marked.hasOwnProperty(i)) {
|
||||
cases.push(t.switchCase(t.literal(i), current = []));
|
||||
alreadyEnded = false;
|
||||
@@ -306,7 +306,7 @@ function isSwitchCaseEnder(stmt) {
|
||||
t.isThrowStatement(stmt);
|
||||
}
|
||||
|
||||
Emitter.prototype.getTryEntryList = function() {
|
||||
Emitter.prototype.getTryEntryList = function () {
|
||||
if (this.tryEntries.length === 0) {
|
||||
// To avoid adding a needless [] to the majority of runtime.wrap
|
||||
// argument lists, force the caller to handle this case specially.
|
||||
@@ -316,7 +316,7 @@ Emitter.prototype.getTryEntryList = function() {
|
||||
var lastLocValue = 0;
|
||||
|
||||
return t.arrayExpression(
|
||||
this.tryEntries.map(function(tryEntry) {
|
||||
this.tryEntries.map(function (tryEntry) {
|
||||
var thisLocValue = tryEntry.firstLoc.value;
|
||||
assert.ok(thisLocValue >= lastLocValue, "try entries out of order");
|
||||
lastLocValue = thisLocValue;
|
||||
@@ -346,7 +346,7 @@ Emitter.prototype.getTryEntryList = function() {
|
||||
|
||||
// No destructive modification of AST nodes.
|
||||
|
||||
Emitter.prototype.explode = function(path, ignoreResult) {
|
||||
Emitter.prototype.explode = function (path, ignoreResult) {
|
||||
assert.ok(path instanceof types.NodePath);
|
||||
|
||||
var node = path.value;
|
||||
@@ -389,7 +389,7 @@ function getDeclError(node) {
|
||||
JSON.stringify(node));
|
||||
}
|
||||
|
||||
Emitter.prototype.explodeStatement = function(path, labelId) {
|
||||
Emitter.prototype.explodeStatement = function (path, labelId) {
|
||||
assert.ok(path instanceof types.NodePath);
|
||||
|
||||
var stmt = path.value;
|
||||
@@ -440,7 +440,7 @@ Emitter.prototype.explodeStatement = function(path, labelId) {
|
||||
self.jumpIfNot(self.explodeExpression(path.get("test")), after);
|
||||
self.leapManager.withEntry(
|
||||
new leap.LoopEntry(after, before, labelId),
|
||||
function() { self.explodeStatement(path.get("body")); }
|
||||
function () { self.explodeStatement(path.get("body")); }
|
||||
);
|
||||
self.jump(before);
|
||||
self.mark(after);
|
||||
@@ -455,7 +455,7 @@ Emitter.prototype.explodeStatement = function(path, labelId) {
|
||||
self.mark(first);
|
||||
self.leapManager.withEntry(
|
||||
new leap.LoopEntry(after, test, labelId),
|
||||
function() { self.explode(path.get("body")); }
|
||||
function () { self.explode(path.get("body")); }
|
||||
);
|
||||
self.mark(test);
|
||||
self.jumpIf(self.explodeExpression(path.get("test")), first);
|
||||
@@ -484,7 +484,7 @@ Emitter.prototype.explodeStatement = function(path, labelId) {
|
||||
|
||||
self.leapManager.withEntry(
|
||||
new leap.LoopEntry(after, update, labelId),
|
||||
function() { self.explodeStatement(path.get("body")); }
|
||||
function () { self.explodeStatement(path.get("body")); }
|
||||
);
|
||||
|
||||
self.mark(update);
|
||||
@@ -543,7 +543,7 @@ Emitter.prototype.explodeStatement = function(path, labelId) {
|
||||
|
||||
self.leapManager.withEntry(
|
||||
new leap.LoopEntry(after, head, labelId),
|
||||
function() { self.explodeStatement(path.get("body")); }
|
||||
function () { self.explodeStatement(path.get("body")); }
|
||||
);
|
||||
|
||||
self.jump(head);
|
||||
@@ -605,8 +605,8 @@ Emitter.prototype.explodeStatement = function(path, labelId) {
|
||||
|
||||
self.leapManager.withEntry(
|
||||
new leap.SwitchEntry(after),
|
||||
function() {
|
||||
path.get("cases").each(function(casePath) {
|
||||
function () {
|
||||
path.get("cases").each(function (casePath) {
|
||||
var i = casePath.name;
|
||||
|
||||
self.mark(caseLocs[i]);
|
||||
@@ -682,7 +682,7 @@ Emitter.prototype.explodeStatement = function(path, labelId) {
|
||||
self.tryEntries.push(tryEntry);
|
||||
self.updateContextPrevLoc(tryEntry.firstLoc);
|
||||
|
||||
self.leapManager.withEntry(tryEntry, function() {
|
||||
self.leapManager.withEntry(tryEntry, function () {
|
||||
self.explodeStatement(path.get("block"));
|
||||
|
||||
if (catchLoc) {
|
||||
@@ -710,7 +710,7 @@ Emitter.prototype.explodeStatement = function(path, labelId) {
|
||||
assert.strictEqual(catchScope.lookup(catchParamName), catchScope);
|
||||
|
||||
types.visit(bodyPath, {
|
||||
visitIdentifier: function(path) {
|
||||
visitIdentifier: function (path) {
|
||||
if (path.value.name === catchParamName &&
|
||||
path.scope.lookup(catchParamName) === catchScope) {
|
||||
return safeParam;
|
||||
@@ -719,7 +719,7 @@ Emitter.prototype.explodeStatement = function(path, labelId) {
|
||||
}
|
||||
});
|
||||
|
||||
self.leapManager.withEntry(catchEntry, function() {
|
||||
self.leapManager.withEntry(catchEntry, function () {
|
||||
self.explodeStatement(bodyPath);
|
||||
});
|
||||
}
|
||||
@@ -727,7 +727,7 @@ Emitter.prototype.explodeStatement = function(path, labelId) {
|
||||
if (finallyLoc) {
|
||||
self.updateContextPrevLoc(self.mark(finallyLoc));
|
||||
|
||||
self.leapManager.withEntry(finallyEntry, function() {
|
||||
self.leapManager.withEntry(finallyEntry, function () {
|
||||
self.explodeStatement(path.get("finalizer"));
|
||||
});
|
||||
|
||||
@@ -754,7 +754,7 @@ Emitter.prototype.explodeStatement = function(path, labelId) {
|
||||
}
|
||||
};
|
||||
|
||||
Emitter.prototype.emitAbruptCompletion = function(record) {
|
||||
Emitter.prototype.emitAbruptCompletion = function (record) {
|
||||
if (!isValidCompletion(record)) {
|
||||
assert.ok(
|
||||
false,
|
||||
@@ -816,7 +816,7 @@ function isValidCompletion(record) {
|
||||
// statements). There's no logical harm in marking such locations as jump
|
||||
// targets, but minimizing the number of switch cases keeps the generated
|
||||
// code shorter.
|
||||
Emitter.prototype.getUnmarkedCurrentLoc = function() {
|
||||
Emitter.prototype.getUnmarkedCurrentLoc = function () {
|
||||
return t.literal(this.listing.length);
|
||||
};
|
||||
|
||||
@@ -830,7 +830,7 @@ Emitter.prototype.getUnmarkedCurrentLoc = function() {
|
||||
// would know the location of the current instruction with complete
|
||||
// precision at all times, but we don't have that luxury here, as it would
|
||||
// be costly and verbose to set context.prev before every statement.
|
||||
Emitter.prototype.updateContextPrevLoc = function(loc) {
|
||||
Emitter.prototype.updateContextPrevLoc = function (loc) {
|
||||
if (loc) {
|
||||
t.assertLiteral(loc);
|
||||
|
||||
@@ -853,7 +853,7 @@ Emitter.prototype.updateContextPrevLoc = function(loc) {
|
||||
this.emitAssign(this.contextProperty("prev"), loc);
|
||||
};
|
||||
|
||||
Emitter.prototype.explodeExpression = function(path, ignoreResult) {
|
||||
Emitter.prototype.explodeExpression = function (path, ignoreResult) {
|
||||
assert.ok(path instanceof types.NodePath);
|
||||
|
||||
var expr = path.value;
|
||||
@@ -964,7 +964,7 @@ Emitter.prototype.explodeExpression = function(path, ignoreResult) {
|
||||
|
||||
return finish(t.callExpression(
|
||||
newCallee,
|
||||
path.get("arguments").map(function(argPath) {
|
||||
path.get("arguments").map(function (argPath) {
|
||||
return explodeViaTempVar(null, argPath);
|
||||
})
|
||||
));
|
||||
@@ -972,14 +972,14 @@ Emitter.prototype.explodeExpression = function(path, ignoreResult) {
|
||||
case "NewExpression":
|
||||
return finish(t.newExpression(
|
||||
explodeViaTempVar(null, path.get("callee")),
|
||||
path.get("arguments").map(function(argPath) {
|
||||
path.get("arguments").map(function (argPath) {
|
||||
return explodeViaTempVar(null, argPath);
|
||||
})
|
||||
));
|
||||
|
||||
case "ObjectExpression":
|
||||
return finish(t.objectExpression(
|
||||
path.get("properties").map(function(propPath) {
|
||||
path.get("properties").map(function (propPath) {
|
||||
return t.property(
|
||||
propPath.value.kind,
|
||||
propPath.value.key,
|
||||
@@ -990,7 +990,7 @@ Emitter.prototype.explodeExpression = function(path, ignoreResult) {
|
||||
|
||||
case "ArrayExpression":
|
||||
return finish(t.arrayExpression(
|
||||
path.get("elements").map(function(elemPath) {
|
||||
path.get("elements").map(function (elemPath) {
|
||||
return explodeViaTempVar(null, elemPath);
|
||||
})
|
||||
));
|
||||
@@ -998,7 +998,7 @@ Emitter.prototype.explodeExpression = function(path, ignoreResult) {
|
||||
case "SequenceExpression":
|
||||
var lastIndex = expr.expressions.length - 1;
|
||||
|
||||
path.get("expressions").each(function(exprPath) {
|
||||
path.get("expressions").each(function (exprPath) {
|
||||
if (exprPath.name === lastIndex) {
|
||||
result = self.explodeExpression(exprPath, ignoreResult);
|
||||
} else {
|
||||
|
||||
@@ -17,7 +17,7 @@ var _ = require("lodash");
|
||||
// and replaces any Declaration nodes in its body with assignments, then
|
||||
// returns a VariableDeclaration containing just the names of the removed
|
||||
// declarations.
|
||||
exports.hoist = function(funPath) {
|
||||
exports.hoist = function (funPath) {
|
||||
assert.ok(funPath instanceof types.NodePath);
|
||||
t.assertFunction(funPath.value);
|
||||
|
||||
@@ -27,7 +27,7 @@ exports.hoist = function(funPath) {
|
||||
t.assertVariableDeclaration(vdec);
|
||||
var exprs = [];
|
||||
|
||||
vdec.declarations.forEach(function(dec) {
|
||||
vdec.declarations.forEach(function (dec) {
|
||||
vars[dec.id.name] = dec.id;
|
||||
|
||||
if (dec.init) {
|
||||
@@ -49,7 +49,7 @@ exports.hoist = function(funPath) {
|
||||
}
|
||||
|
||||
types.visit(funPath.get("body"), {
|
||||
visitVariableDeclaration: function(path) {
|
||||
visitVariableDeclaration: function (path) {
|
||||
var expr = varDeclToExpr(path.value, false);
|
||||
if (expr === null) {
|
||||
path.replace();
|
||||
@@ -64,7 +64,7 @@ exports.hoist = function(funPath) {
|
||||
return false;
|
||||
},
|
||||
|
||||
visitForStatement: function(path) {
|
||||
visitForStatement: function (path) {
|
||||
var init = path.value.init;
|
||||
if (t.isVariableDeclaration(init)) {
|
||||
path.get("init").replace(varDeclToExpr(init, false));
|
||||
@@ -72,7 +72,7 @@ exports.hoist = function(funPath) {
|
||||
this.traverse(path);
|
||||
},
|
||||
|
||||
visitForInStatement: function(path) {
|
||||
visitForInStatement: function (path) {
|
||||
var left = path.value.left;
|
||||
if (t.isVariableDeclaration(left)) {
|
||||
path.get("left").replace(varDeclToExpr(left, true));
|
||||
@@ -80,7 +80,7 @@ exports.hoist = function(funPath) {
|
||||
this.traverse(path);
|
||||
},
|
||||
|
||||
visitFunctionDeclaration: function(path) {
|
||||
visitFunctionDeclaration: function (path) {
|
||||
var node = path.value;
|
||||
vars[node.id.name] = node.id;
|
||||
|
||||
@@ -118,14 +118,14 @@ exports.hoist = function(funPath) {
|
||||
return false;
|
||||
},
|
||||
|
||||
visitFunctionExpression: function() {
|
||||
visitFunctionExpression: function () {
|
||||
// Don't descend into nested function expressions.
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
var paramNames = {};
|
||||
funPath.get("params").each(function(paramPath) {
|
||||
funPath.get("params").each(function (paramPath) {
|
||||
var param = paramPath.value;
|
||||
if (t.isIdentifier(param)) {
|
||||
paramNames[param.name] = param;
|
||||
@@ -137,7 +137,7 @@ exports.hoist = function(funPath) {
|
||||
|
||||
var declarations = [];
|
||||
|
||||
Object.keys(vars).forEach(function(name) {
|
||||
Object.keys(vars).forEach(function (name) {
|
||||
if (!_.has(paramNames, name)) {
|
||||
declarations.push(t.variableDeclarator(vars[name], null));
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ function LeapManager(emitter) {
|
||||
this.entryStack = [new FunctionEntry(emitter.finalLoc)];
|
||||
}
|
||||
|
||||
LeapManager.prototype.withEntry = function(entry, callback) {
|
||||
LeapManager.prototype.withEntry = function (entry, callback) {
|
||||
assert.ok(entry instanceof Entry);
|
||||
this.entryStack.push(entry);
|
||||
try {
|
||||
@@ -135,7 +135,7 @@ LeapManager.prototype.withEntry = function(entry, callback) {
|
||||
}
|
||||
};
|
||||
|
||||
LeapManager.prototype._findLeapLocation = function(property, label) {
|
||||
LeapManager.prototype._findLeapLocation = function (property, label) {
|
||||
for (var i = this.entryStack.length - 1; i >= 0; --i) {
|
||||
var entry = this.entryStack[i];
|
||||
var loc = entry[property];
|
||||
@@ -154,10 +154,10 @@ LeapManager.prototype._findLeapLocation = function(property, label) {
|
||||
return null;
|
||||
};
|
||||
|
||||
LeapManager.prototype.getBreakLoc = function(label) {
|
||||
LeapManager.prototype.getBreakLoc = function (label) {
|
||||
return this._findLeapLocation("breakLoc", label);
|
||||
};
|
||||
|
||||
LeapManager.prototype.getContinueLoc = function(label) {
|
||||
LeapManager.prototype.getContinueLoc = function (label) {
|
||||
return this._findLeapLocation("continueLoc", label);
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ function makePredicate(propertyName, knownTypes) {
|
||||
return result;
|
||||
}
|
||||
|
||||
types.eachField(node, function(name, child) {
|
||||
types.eachField(node, function (name, child) {
|
||||
check(child);
|
||||
});
|
||||
|
||||
|
||||
@@ -38,19 +38,19 @@ var GFName = "GeneratorFunction";
|
||||
if (GF.name !== GFName) GF.name = GFName;
|
||||
if (GF.name !== GFName) throw new Error(GFName + " renamed?");
|
||||
|
||||
runtime.isGeneratorFunction = function(genFun) {
|
||||
runtime.isGeneratorFunction = function (genFun) {
|
||||
var ctor = genFun && genFun.constructor;
|
||||
return ctor ? GF.name === ctor.name : false;
|
||||
};
|
||||
|
||||
runtime.mark = function(genFun) {
|
||||
runtime.mark = function (genFun) {
|
||||
genFun.__proto__ = GFp;
|
||||
genFun.prototype = Object.create(Gp);
|
||||
return genFun;
|
||||
};
|
||||
|
||||
runtime.async = function(innerFn, outerFn, self, tryList) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
runtime.async = function (innerFn, outerFn, self, tryList) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var generator = wrap(innerFn, outerFn, self, tryList);
|
||||
var callNext = step.bind(generator.next);
|
||||
var callThrow = step.bind(generator["throw"]);
|
||||
@@ -202,11 +202,11 @@ function Generator(innerFn, outerFn, self, tryList) {
|
||||
return generator;
|
||||
}
|
||||
|
||||
Gp[iteratorSymbol] = function() {
|
||||
Gp[iteratorSymbol] = function () {
|
||||
return this;
|
||||
};
|
||||
|
||||
Gp.toString = function() {
|
||||
Gp.toString = function () {
|
||||
return "[object Generator]";
|
||||
};
|
||||
|
||||
@@ -240,7 +240,7 @@ function Context(tryList) {
|
||||
this.reset();
|
||||
}
|
||||
|
||||
runtime.keys = function(object) {
|
||||
runtime.keys = function (object) {
|
||||
var keys = [];
|
||||
for (var key in object) {
|
||||
keys.push(key);
|
||||
@@ -293,7 +293,7 @@ runtime.values = values;
|
||||
Context.prototype = {
|
||||
constructor: Context,
|
||||
|
||||
reset: function() {
|
||||
reset: function () {
|
||||
this.prev = 0;
|
||||
this.next = 0;
|
||||
this.sent = undefined;
|
||||
@@ -311,7 +311,7 @@ Context.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
stop: function() {
|
||||
stop: function () {
|
||||
this.done = true;
|
||||
|
||||
var rootEntry = this.tryEntries[0];
|
||||
@@ -323,7 +323,7 @@ Context.prototype = {
|
||||
return this.rval;
|
||||
},
|
||||
|
||||
dispatchException: function(exception) {
|
||||
dispatchException: function (exception) {
|
||||
if (this.done) {
|
||||
throw exception;
|
||||
}
|
||||
@@ -375,7 +375,7 @@ Context.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
_findFinallyEntry: function(finallyLoc) {
|
||||
_findFinallyEntry: function (finallyLoc) {
|
||||
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
||||
var entry = this.tryEntries[i];
|
||||
if (entry.tryLoc <= this.prev &&
|
||||
@@ -387,7 +387,7 @@ Context.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
abrupt: function(type, arg) {
|
||||
abrupt: function (type, arg) {
|
||||
var entry = this._findFinallyEntry();
|
||||
var record = entry ? entry.completion : {};
|
||||
|
||||
@@ -403,7 +403,7 @@ Context.prototype = {
|
||||
return ContinueSentinel;
|
||||
},
|
||||
|
||||
complete: function(record) {
|
||||
complete: function (record) {
|
||||
if (record.type === "throw") {
|
||||
throw record.arg;
|
||||
}
|
||||
@@ -418,12 +418,12 @@ Context.prototype = {
|
||||
return ContinueSentinel;
|
||||
},
|
||||
|
||||
finish: function(finallyLoc) {
|
||||
finish: function (finallyLoc) {
|
||||
var entry = this._findFinallyEntry(finallyLoc);
|
||||
return this.complete(entry.completion);
|
||||
},
|
||||
|
||||
"catch": function(tryLoc) {
|
||||
"catch": function (tryLoc) {
|
||||
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
||||
var entry = this.tryEntries[i];
|
||||
if (entry.tryLoc === tryLoc) {
|
||||
@@ -442,7 +442,7 @@ Context.prototype = {
|
||||
throw new Error("illegal catch attempt");
|
||||
},
|
||||
|
||||
delegateYield: function(iterable, resultName, nextLoc) {
|
||||
delegateYield: function (iterable, resultName, nextLoc) {
|
||||
this.delegate = {
|
||||
iterator: values(iterable),
|
||||
resultName: resultName,
|
||||
|
||||
@@ -23,7 +23,7 @@ exports.transform = function transform(node) {
|
||||
};
|
||||
|
||||
var visitor = types.PathVisitor.fromMethodsObject({
|
||||
visitFunction: function(path) {
|
||||
visitFunction: function (path) {
|
||||
// Calling this.traverse(path) first makes for a post-order traversal.
|
||||
this.traverse(path);
|
||||
|
||||
@@ -208,11 +208,11 @@ function shouldNotHoistAbove(stmtPath) {
|
||||
}
|
||||
|
||||
var awaitVisitor = types.PathVisitor.fromMethodsObject({
|
||||
visitFunction: function() {
|
||||
visitFunction: function () {
|
||||
return false; // Don't descend into nested function scopes.
|
||||
},
|
||||
|
||||
visitAwaitExpression: function(path) {
|
||||
visitAwaitExpression: function (path) {
|
||||
// Convert await expressions to yield expressions.
|
||||
return t.yieldExpression(path.value.argument, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user