Stricter tokVal -> tokType comparisons.

This commit is contained in:
Ingvar Stepanyan 2014-07-26 08:19:08 +03:00 committed by Marijn Haverbeke
parent a061f1f0a6
commit eb7ccea743

View File

@ -1634,7 +1634,7 @@
if (tokType.isAssign) { if (tokType.isAssign) {
var node = startNodeFrom(left); var node = startNodeFrom(left);
node.operator = tokVal; node.operator = tokVal;
node.left = tokVal === '=' ? toAssignable(left) : left; node.left = tokType === _eq ? toAssignable(left) : left;
checkLVal(left); checkLVal(left);
next(); next();
node.right = parseMaybeAssign(noIn); node.right = parseMaybeAssign(noIn);
@ -1939,7 +1939,7 @@
if (options.ecmaVersion >= 6) { if (options.ecmaVersion >= 6) {
prop.method = false; prop.method = false;
prop.shorthand = false; prop.shorthand = false;
isGenerator = parseIsGenerator(); isGenerator = isStar(true);
} }
parsePropertyName(prop); parsePropertyName(prop);
if (eat(_colon)) { if (eat(_colon)) {
@ -2014,11 +2014,11 @@
} }
} }
// Checks if there's generator's sign ('*') and moves on. // Checks if there's star sign ('*').
function parseIsGenerator() { function isStar(moveOn) {
if (tokVal === '*') { if (tokType === _multiplyModulo && tokVal === '*') {
next(); if (moveOn) next();
return true; return true;
} else { } else {
return false; return false;
@ -2031,7 +2031,7 @@
function parseFunction(node, isStatement, allowExpressionBody) { function parseFunction(node, isStatement, allowExpressionBody) {
initFunction(node); initFunction(node);
if (options.ecmaVersion >= 6) { if (options.ecmaVersion >= 6) {
node.generator = parseIsGenerator(); node.generator = isStar(true);
} }
if (isStatement || tokType === _name) { if (isStatement || tokType === _name) {
node.id = parseIdent(); node.id = parseIdent();
@ -2106,7 +2106,7 @@
break; break;
} else { } else {
node.params.push(options.ecmaVersion >= 6 ? toAssignable(parseExprAtom(), false, true) : parseIdent()); node.params.push(options.ecmaVersion >= 6 ? toAssignable(parseExprAtom(), false, true) : parseIdent());
if (options.ecmaVersion >= 6 && tokVal === '=') { if (options.ecmaVersion >= 6 && tokType === _eq) {
next(); next();
hasDefaults = true; hasDefaults = true;
defaults.push(parseExpression(true)); defaults.push(parseExpression(true));
@ -2191,7 +2191,7 @@
while (!eat(_braceR)) { while (!eat(_braceR)) {
var method = startNode(); var method = startNode();
method.static = !!eat(_static); method.static = !!eat(_static);
var isGenerator = parseIsGenerator(); var isGenerator = isStar(true);
method.key = parseIdent(true); method.key = parseIdent(true);
if ((method.key.name === "get" || method.key.name === "set") && tokType === _name) { if ((method.key.name === "get" || method.key.name === "set") && tokType === _name) {
if (isGenerator) unexpected(); if (isGenerator) unexpected();
@ -2324,7 +2324,7 @@
} else { } else {
// export * from '...' // export * from '...'
// export { x, y as z } [from '...'] // export { x, y as z } [from '...']
var isBatch = tokVal === '*'; var isBatch = isStar();
node.declaration = null; node.declaration = null;
node.default = false; node.default = false;
node.specifiers = parseExportSpecifiers(); node.specifiers = parseExportSpecifiers();
@ -2342,7 +2342,7 @@
function parseExportSpecifiers() { function parseExportSpecifiers() {
var nodes = [], first = true; var nodes = [], first = true;
if (tokVal === "*") { if (isStar()) {
// export * from '...' // export * from '...'
var node = startNode(); var node = startNode();
next(); next();
@ -2389,7 +2389,7 @@
function parseImportSpecifiers() { function parseImportSpecifiers() {
var nodes = [], first = true; var nodes = [], first = true;
if (tokVal === '*') { if (isStar()) {
var node = startNode(); var node = startNode();
next(); next();
expect(_as); expect(_as);
@ -2430,7 +2430,7 @@
function parseYield() { function parseYield() {
var node = startNode(); var node = startNode();
next(); next();
node.delegate = parseIsGenerator(); node.delegate = isStar(true);
node.argument = parseExpression(true); node.argument = parseExpression(true);
return finishNode(node, "YieldExpression"); return finishNode(node, "YieldExpression");
} }