diff --git a/src/parser/statement.js b/src/parser/statement.js index 614951c802..9f96ccf826 100644 --- a/src/parser/statement.js +++ b/src/parser/statement.js @@ -96,7 +96,7 @@ pp.parseStatement = function (declaration, topLevel) { return starttype === tt._import ? this.parseImport(node) : this.parseExport(node); case tt.name: - if (this.options.features["es7.asyncFunctions"] && this.state.value === "async") { + if (this.hasFeature("asyncFunctions") && this.state.value === "async") { // peek ahead and see if next token is a function let state = this.state.clone(); this.next(); @@ -145,7 +145,7 @@ pp.parseDecorators = function (allowExport) { }; pp.parseDecorator = function () { - if (!this.options.features["es7.decorators"]) { + if (!this.hasFeature("decorators")) { this.unexpected(); } let node = this.startNode(); @@ -511,7 +511,7 @@ pp.parseFunction = function (node, isStatement, allowExpressionBody, isAsync, op pp.parseFunctionParams = function (node) { this.expect(tt.parenL); - node.params = this.parseBindingList(tt.parenR, false, this.options.features["es7.trailingFunctionCommas"]); + node.params = this.parseBindingList(tt.parenR, false, this.hasFeature("trailingFunctionCommas")); }; // Parse a class declaration or literal (depending on the @@ -550,7 +550,7 @@ pp.parseClass = function (node, isStatement, optionalId) { classBody.body.push(this.parseClassProperty(method)); continue; } - if (this.options.features["es7.asyncFunctions"] && !this.match(tt.parenL) && + if (this.hasFeature("asyncFunctions") && !this.match(tt.parenL) && !method.computed && method.key.type === "Identifier" && method.key.name === "async") { isAsync = true; this.parsePropertyName(method); @@ -605,7 +605,7 @@ pp.isClassProperty = function () { pp.parseClassProperty = function (node) { if (this.match(tt.eq)) { - if (!this.options.features["es7.classProperties"]) this.unexpected(); + if (!this.hasFeature("classProperties")) this.unexpected(); this.next(); node.value = this.parseMaybeAssign(); } else { @@ -644,7 +644,7 @@ pp.parseExport = function (node) { if (this.match(tt.star)) { let specifier = this.startNode(); this.next(); - if (this.options.features["es7.exportExtensions"] && this.eatContextual("as")) { + if (this.hasFeature("exportExtensions") && this.eatContextual("as")) { specifier.exported = this.parseIdentifier(); node.specifiers = [this.finishNode(specifier, "ExportNamespaceSpecifier")]; this.parseExportSpecifiersMaybe(node); @@ -653,7 +653,7 @@ pp.parseExport = function (node) { this.parseExportFrom(node, true); return this.finishNode(node, "ExportAllDeclaration"); } - } else if (this.options.features["es7.exportExtensions"] && this.isExportDefaultSpecifier()) { + } else if (this.hasFeature("exportExtensions") && this.isExportDefaultSpecifier()) { let specifier = this.startNode(); specifier.exported = this.parseIdentifier(true); node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")]; @@ -735,7 +735,7 @@ pp.parseExportFrom = function (node, expect?) { }; pp.shouldParseExportDeclaration = function () { - return this.options.features["es7.asyncFunctions"] && this.isContextual("async"); + return this.hasFeature("asyncFunctions") && this.isContextual("async"); }; pp.checkExport = function (node) { diff --git a/src/tokenizer/index.js b/src/tokenizer/index.js index b1b4f16f0d..3839f81e58 100644 --- a/src/tokenizer/index.js +++ b/src/tokenizer/index.js @@ -308,7 +308,7 @@ export default class Tokenizer { var width = 1; var next = this.input.charCodeAt(this.state.pos + 1); - if (next === 42 && this.options.features["es7.exponentiationOperator"]) { // '*' + if (next === 42 && this.hasFeature("exponentiationOperator")) { // '*' width++; next = this.input.charCodeAt(this.state.pos + 2); type = tt.exponent; @@ -411,7 +411,7 @@ export default class Tokenizer { case 125: ++this.state.pos; return this.finishToken(tt.braceR); case 58: - if (this.options.features["es7.functionBind"] && this.input.charCodeAt(this.state.pos + 1) === 58) { + if (this.hasFeature("functionBind") && this.input.charCodeAt(this.state.pos + 1) === 58) { return this.finishOp(tt.doubleColon, 2); } else { ++this.state.pos; diff --git a/src/tokenizer/state.js b/src/tokenizer/state.js index 4765017de3..b5a846ae20 100644 --- a/src/tokenizer/state.js +++ b/src/tokenizer/state.js @@ -60,7 +60,6 @@ export default class State { // Used to signal to callers of `readWord1` whether the word // contained any escape sequences. This is needed because words with // escape sequences must not be interpreted as keywords. - this.containsEsc = false; return this;