diff options
Diffstat (limited to 'deps/acorn-plugins')
30 files changed, 1180 insertions, 0 deletions
diff --git a/deps/acorn-plugins/acorn-bigint/CHANGELOG.md b/deps/acorn-plugins/acorn-bigint/CHANGELOG.md new file mode 100644 index 0000000000..1d12d708f2 --- /dev/null +++ b/deps/acorn-plugins/acorn-bigint/CHANGELOG.md @@ -0,0 +1,21 @@ +## 0.4.0 (2019-04-04) + +* Make compatible with acorn-numeric-separator + +## 0.3.1 (2018-10-06) + +* Fix creation of BigInt values everywhere (Thanks, Gus Caplan!) + +## 0.3.0 (2018-09-14) + +* Update to new acorn 6 interface +* Actually support creating BigInt values in AST in Chrome +* Change license to MIT + +## 0.2.0 (2017-12-20) + +* Emit BigInt values in AST if supported by runtime engine + +## 0.1.0 (2017-12-19) + +Initial release diff --git a/deps/acorn-plugins/acorn-bigint/LICENSE b/deps/acorn-plugins/acorn-bigint/LICENSE new file mode 100644 index 0000000000..7c2b27a19c --- /dev/null +++ b/deps/acorn-plugins/acorn-bigint/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2017-2018 by Adrian Heine + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/deps/acorn-plugins/acorn-bigint/README.md b/deps/acorn-plugins/acorn-bigint/README.md new file mode 100644 index 0000000000..b0b6bb5554 --- /dev/null +++ b/deps/acorn-plugins/acorn-bigint/README.md @@ -0,0 +1,21 @@ +# BigInt support for Acorn + +[![NPM version](https://img.shields.io/npm/v/acorn-bigint.svg)](https://www.npmjs.org/package/acorn-bigint) + +This is a plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript. + +It implements support for arbitrary precision integers as defined in the stage 3 proposal [BigInt: Arbitrary precision integers in JavaScript](https://github.com/tc39/proposal-bigint). The emitted AST follows [an ESTree proposal](https://github.com/estree/estree/blob/132be9b9ec376adbc082dd5f6ba78aefd7a1a864/experimental/bigint.md). + +## Usage + +This module provides a plugin that can be used to extend the Acorn `Parser` class: + +```javascript +const {Parser} = require('acorn'); +const bigInt = require('acorn-bigint'); +Parser.extend(bigInt).parse('100n'); +``` + +## License + +This plugin is released under an [MIT License](./LICENSE). diff --git a/deps/acorn-plugins/acorn-bigint/index.js b/deps/acorn-plugins/acorn-bigint/index.js new file mode 100644 index 0000000000..8e63515e11 --- /dev/null +++ b/deps/acorn-plugins/acorn-bigint/index.js @@ -0,0 +1,59 @@ +"use strict" + +const acorn = require('internal/deps/acorn/acorn/dist/acorn') +const tt = acorn.tokTypes +const isIdentifierStart = acorn.isIdentifierStart + +module.exports = function(Parser) { + return class extends Parser { + parseLiteral(value) { + const node = super.parseLiteral(value) + if (node.raw.charCodeAt(node.raw.length - 1) == 110) node.bigint = this.getNumberInput(node.start, node.end) + return node + } + + readRadixNumber(radix) { + let start = this.pos + this.pos += 2 // 0x + let val = this.readInt(radix) + if (val === null) this.raise(this.start + 2, `Expected number in radix ${radix}`) + if (this.input.charCodeAt(this.pos) == 110) { + let str = this.getNumberInput(start, this.pos) + val = typeof BigInt !== "undefined" ? BigInt(str) : null + ++this.pos + } else if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after number") + return this.finishToken(tt.num, val) + } + + readNumber(startsWithDot) { + let start = this.pos + + // Not an int + if (startsWithDot) return super.readNumber(startsWithDot) + + // Legacy octal + if (this.input.charCodeAt(start) === 48 && this.input.charCodeAt(start + 1) !== 110) { + return super.readNumber(startsWithDot) + } + + if (this.readInt(10) === null) this.raise(start, "Invalid number") + + // Not a BigInt, reset and parse again + if (this.input.charCodeAt(this.pos) != 110) { + this.pos = start + return super.readNumber(startsWithDot) + } + + let str = this.getNumberInput(start, this.pos) + let val = typeof BigInt !== "undefined" ? BigInt(str) : null + ++this.pos + return this.finishToken(tt.num, val) + } + + // This is basically a hook for acorn-numeric-separator + getNumberInput(start, end) { + if (super.getNumberInput) return super.getNumberInput(start, end) + return this.input.slice(start, end) + } + } +} diff --git a/deps/acorn-plugins/acorn-bigint/package.json b/deps/acorn-plugins/acorn-bigint/package.json new file mode 100644 index 0000000000..073cdfb86c --- /dev/null +++ b/deps/acorn-plugins/acorn-bigint/package.json @@ -0,0 +1,65 @@ +{ + "_from": "acorn-bigint", + "_id": "acorn-bigint@0.4.0", + "_inBundle": false, + "_integrity": "sha512-W9iaqWzqFo7ZBLmI9dMjHYGrN0Nm/ZgToqhvd3RELJux7RsX6k1/80h+bD9TtTpeKky/kYNbr3+vHWqI3hdyfA==", + "_location": "/acorn-bigint", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "acorn-bigint", + "name": "acorn-bigint", + "escapedName": "acorn-bigint", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/acorn-bigint/-/acorn-bigint-0.4.0.tgz", + "_shasum": "af3245ed8a7c3747387fca4680ae1960f617c4cd", + "_spec": "acorn-bigint", + "_where": "/home/ruben/repos/node/node", + "bugs": { + "url": "https://github.com/acornjs/acorn-bigint/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Adrian Heine", + "email": "mail@adrianheine.de" + } + ], + "deprecated": false, + "description": "Support for BigInt in acorn", + "devDependencies": { + "acorn": "^6.1.1", + "eslint": "^5.16.0", + "eslint-plugin-node": "^8.0.1", + "mocha": "^6.0.2", + "test262": "git+https://github.com/tc39/test262.git#611919174ffe060503691a0c7e3eb2a65b646124", + "test262-parser-runner": "^0.5.0" + }, + "engines": { + "node": ">=4.8.2" + }, + "homepage": "https://github.com/acornjs/acorn-bigint", + "license": "MIT", + "name": "acorn-bigint", + "peerDependencies": { + "acorn": "^6.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/acornjs/acorn-bigint.git" + }, + "scripts": { + "lint": "eslint -c .eslintrc.json .", + "test": "mocha", + "test:test262": "node run_test262.js" + }, + "version": "0.4.0" +} diff --git a/deps/acorn-plugins/acorn-class-fields/CHANGELOG.md b/deps/acorn-plugins/acorn-class-fields/CHANGELOG.md new file mode 100644 index 0000000000..de2c66b0c3 --- /dev/null +++ b/deps/acorn-plugins/acorn-class-fields/CHANGELOG.md @@ -0,0 +1,28 @@ +## 0.3.1 (2019-02-09) + +* Restore compatibility with acorn-private-methods + +## 0.3.0 (2019-02-09) + +* Require acorn >= 6.1.0 + +## 0.2.1 (2018-11-06) + +* Adapt to changes in acorn 6.0.3 + +## 0.2.0 (2018-09-14) + +* Update to new acorn 6 interface +* Change license to MIT + +## 0.1.2 (2018-01-26) + +* Don't accept whitespace between hash and private name + +## 0.1.1 (2018-01-17) + +* Correctly parse all fields named `async` + +## 0.1.0 (2018-01-13) + +Initial release diff --git a/deps/acorn-plugins/acorn-class-fields/LICENSE b/deps/acorn-plugins/acorn-class-fields/LICENSE new file mode 100644 index 0000000000..7c2b27a19c --- /dev/null +++ b/deps/acorn-plugins/acorn-class-fields/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2017-2018 by Adrian Heine + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/deps/acorn-plugins/acorn-class-fields/README.md b/deps/acorn-plugins/acorn-class-fields/README.md new file mode 100644 index 0000000000..60f3463e94 --- /dev/null +++ b/deps/acorn-plugins/acorn-class-fields/README.md @@ -0,0 +1,21 @@ +# Class fields support for Acorn + +[![NPM version](https://img.shields.io/npm/v/acorn-class-fields.svg)](https://www.npmjs.org/package/acorn-class-fields) + +This is a plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript. + +It implements support for class fields as defined in the stage 3 proposal [Class field declarations for JavaScript](https://github.com/tc39/proposal-class-fields). The emitted AST follows [an ESTree proposal](https://github.com/estree/estree/pull/180). + +## Usage + +This module provides a plugin that can be used to extend the Acorn `Parser` class: + +```javascript +const {Parser} = require('acorn'); +const classFields = require('acorn-class-fields'); +Parser.extend(classFields).parse('class X { x = 0 }'); +``` + +## License + +This plugin is released under an [MIT License](./LICENSE). diff --git a/deps/acorn-plugins/acorn-class-fields/index.js b/deps/acorn-plugins/acorn-class-fields/index.js new file mode 100644 index 0000000000..20348c80c6 --- /dev/null +++ b/deps/acorn-plugins/acorn-class-fields/index.js @@ -0,0 +1,59 @@ +"use strict" + +const acorn = require('internal/deps/acorn/acorn/dist/acorn') +const tt = acorn.tokTypes +const privateClassElements = require('internal/deps/acorn-plugins/acorn-private-class-elements/index') + +function maybeParseFieldValue(field) { + if (this.eat(tt.eq)) { + const oldInFieldValue = this._inFieldValue + this._inFieldValue = true + field.value = this.parseExpression() + this._inFieldValue = oldInFieldValue + } else field.value = null +} + +module.exports = function(Parser) { + Parser = privateClassElements(Parser) + return class extends Parser { + // Parse fields + parseClassElement(_constructorAllowsSuper) { + if (this.options.ecmaVersion >= 8 && (this.type == tt.name || this.type == this.privateNameToken || this.type == tt.bracketL || this.type == tt.string)) { + const branch = this._branch() + if (branch.type == tt.bracketL) { + let count = 0 + do { + if (branch.eat(tt.bracketL)) ++count + else if (branch.eat(tt.bracketR)) --count + else branch.next() + } while (count > 0) + } else branch.next() + if (branch.type == tt.eq || branch.canInsertSemicolon() || branch.type == tt.semi) { + const node = this.startNode() + if (this.type == this.privateNameToken) { + this.parsePrivateClassElementName(node) + } else { + this.parsePropertyName(node) + } + if ((node.key.type === "Identifier" && node.key.name === "constructor") || + (node.key.type === "Literal" && node.key.value === "constructor")) { + this.raise(node.key.start, "Classes may not have a field called constructor") + } + maybeParseFieldValue.call(this, node) + this.finishNode(node, "FieldDefinition") + this.semicolon() + return node + } + } + + return super.parseClassElement.apply(this, arguments) + } + + // Prohibit arguments in class field initializers + parseIdent(liberal, isBinding) { + const ident = super.parseIdent(liberal, isBinding) + if (this._inFieldValue && ident.name == "arguments") this.raise(ident.start, "A class field initializer may not contain arguments") + return ident + } + } +} diff --git a/deps/acorn-plugins/acorn-class-fields/package.json b/deps/acorn-plugins/acorn-class-fields/package.json new file mode 100644 index 0000000000..4df166ba19 --- /dev/null +++ b/deps/acorn-plugins/acorn-class-fields/package.json @@ -0,0 +1,68 @@ +{ + "_from": "acorn-class-fields", + "_id": "acorn-class-fields@0.3.1", + "_inBundle": false, + "_integrity": "sha512-X/8hSJuregAnrvfV1Y80VJNfeJx1uhw7yskOwvL631ygYeCGVLPumCnnPDHYZ8acV3ytHhg53K171H3tAemgiw==", + "_location": "/acorn-class-fields", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "acorn-class-fields", + "name": "acorn-class-fields", + "escapedName": "acorn-class-fields", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/acorn-class-fields/-/acorn-class-fields-0.3.1.tgz", + "_shasum": "032ce47a9688a71d4713ee366fadcb7fefaea9e0", + "_spec": "acorn-class-fields", + "_where": "/home/ruben/repos/node/node", + "bugs": { + "url": "https://github.com/acornjs/acorn-class-fields/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Adrian Heine", + "email": "mail@adrianheine.de" + } + ], + "dependencies": { + "acorn-private-class-elements": "^0.1.1" + }, + "deprecated": false, + "description": "Support for class fields in acorn", + "devDependencies": { + "acorn": "^6.1.0", + "eslint": "^5.13.0", + "eslint-plugin-node": "^8.0.1", + "mocha": "^5.2.0", + "test262": "git+https://github.com/tc39/test262.git#33a306d1026b72227eb50a918db19ada16f12b3d", + "test262-parser-runner": "^0.5.0" + }, + "engines": { + "node": ">=4.8.2" + }, + "homepage": "https://github.com/acornjs/acorn-class-fields", + "license": "MIT", + "name": "acorn-class-fields", + "peerDependencies": { + "acorn": "^6.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/acornjs/acorn-class-fields.git" + }, + "scripts": { + "lint": "eslint -c .eslintrc.json .", + "test": "mocha", + "test:test262": "node run_test262.js" + }, + "version": "0.3.1" +} diff --git a/deps/acorn-plugins/acorn-numeric-separator/CHANGELOG.md b/deps/acorn-plugins/acorn-numeric-separator/CHANGELOG.md new file mode 100644 index 0000000000..dfe8e3ea9d --- /dev/null +++ b/deps/acorn-plugins/acorn-numeric-separator/CHANGELOG.md @@ -0,0 +1,16 @@ +## 0.3.0 (2019-04-04) + +* Make compatible with acorn-bigint + +## 0.2.0 (2018-09-14) + +* Update to new acorn 6 interface +* Change license to MIT + +## 0.1.1 (2018-01-16) + +* Don't bail on empty integers as in `1.` + +## 0.1.0 (2017-12-19) + +Initial release diff --git a/deps/acorn-plugins/acorn-numeric-separator/LICENSE b/deps/acorn-plugins/acorn-numeric-separator/LICENSE new file mode 100644 index 0000000000..7c2b27a19c --- /dev/null +++ b/deps/acorn-plugins/acorn-numeric-separator/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2017-2018 by Adrian Heine + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/deps/acorn-plugins/acorn-numeric-separator/README.md b/deps/acorn-plugins/acorn-numeric-separator/README.md new file mode 100644 index 0000000000..27188572d1 --- /dev/null +++ b/deps/acorn-plugins/acorn-numeric-separator/README.md @@ -0,0 +1,21 @@ +# Numeric separator support for Acorn + +[![NPM version](https://img.shields.io/npm/v/acorn-numeric-separator.svg)](https://www.npmjs.org/package/acorn-numeric-separator) + +This is a plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript. + +It implements support for numeric separators as defined in the stage 3 proposal [Numeric Separators](https://github.com/tc39/proposal-numeric-separator). + +## Usage + +This module provides a plugin that can be used to extend the Acorn `Parser` class to parse numeric separators: + +```javascript +var acorn = require('acorn'); +var numericSeparator = require('acorn-numeric-separator'); +acorn.Parser.extend(numericSeparator).parse('100_000'); +``` + +## License + +This plugin is released under an [MIT License](./LICENSE). diff --git a/deps/acorn-plugins/acorn-numeric-separator/index.js b/deps/acorn-plugins/acorn-numeric-separator/index.js new file mode 100644 index 0000000000..52f207cfd8 --- /dev/null +++ b/deps/acorn-plugins/acorn-numeric-separator/index.js @@ -0,0 +1,49 @@ +"use strict" + +module.exports = function(Parser) { + return class extends Parser { + readInt(radix, len) { + // Hack: len is only != null for unicode escape sequences, + // where numeric separators are not allowed + if (len != null) return super.readInt(radix, len) + + let start = this.pos, total = 0, acceptUnderscore = false + for (;;) { + let code = this.input.charCodeAt(this.pos), val + if (code >= 97) val = code - 97 + 10 // a + else if (code == 95) { + if (!acceptUnderscore) this.raise(this.pos, "Invalid numeric separator") + ++this.pos + acceptUnderscore = false + continue + } else if (code >= 65) val = code - 65 + 10 // A + else if (code >= 48 && code <= 57) val = code - 48 // 0-9 + else val = Infinity + if (val >= radix) break + ++this.pos + total = total * radix + val + acceptUnderscore = true + } + if (this.pos === start) return null + if (!acceptUnderscore) this.raise(this.pos - 1, "Invalid numeric separator") + + return total + } + + readNumber(startsWithDot) { + const token = super.readNumber(startsWithDot) + let octal = this.end - this.start >= 2 && this.input.charCodeAt(this.start) === 48 + const stripped = this.getNumberInput(this.start, this.end) + if (stripped.length < this.end - this.start) { + if (octal) this.raise(this.start, "Invalid number") + this.value = parseFloat(stripped) + } + return token + } + + // This is used by acorn-bigint + getNumberInput(start, end) { + return this.input.slice(start, end).replace(/_/g, "") + } + } +} diff --git a/deps/acorn-plugins/acorn-numeric-separator/package.json b/deps/acorn-plugins/acorn-numeric-separator/package.json new file mode 100644 index 0000000000..bf3615e6b7 --- /dev/null +++ b/deps/acorn-plugins/acorn-numeric-separator/package.json @@ -0,0 +1,65 @@ +{ + "_from": "acorn-numeric-separator", + "_id": "acorn-numeric-separator@0.3.0", + "_inBundle": false, + "_integrity": "sha512-g9FikQZHwG/P1Xs+dDzecqagmGBbU4b8OF4UbDQK8Wr8apwuFGG1c7KiaFxC4ClYU8D7zNl60vzqOCUuhKM3kA==", + "_location": "/acorn-numeric-separator", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "acorn-numeric-separator", + "name": "acorn-numeric-separator", + "escapedName": "acorn-numeric-separator", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/acorn-numeric-separator/-/acorn-numeric-separator-0.3.0.tgz", + "_shasum": "15e2f9a698bbec83a339a70a7026ab1d9d257de2", + "_spec": "acorn-numeric-separator", + "_where": "/home/ruben/repos/node/node", + "bugs": { + "url": "https://github.com/acornjs/acorn-numeric-separator/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Adrian Heine", + "email": "mail@adrianheine.de" + } + ], + "deprecated": false, + "description": "Support for numeric separators in acorn", + "devDependencies": { + "acorn": "^6.0.0", + "eslint": "^5.5.0", + "eslint-plugin-node": "^8.0.1", + "mocha": "^6.0.2", + "test262": "git+https://github.com/tc39/test262.git#de567d3aa5de4eaa11e00131d26b9fe77997dfb0", + "test262-parser-runner": "^0.5.0" + }, + "engines": { + "node": ">=4.8.2" + }, + "homepage": "https://github.com/acornjs/acorn-numeric-separator", + "license": "MIT", + "name": "acorn-numeric-separator", + "peerDependencies": { + "acorn": "^6.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/acornjs/acorn-numeric-separator.git" + }, + "scripts": { + "lint": "eslint -c .eslintrc.json .", + "test": "mocha", + "test:test262": "node run_test262.js" + }, + "version": "0.3.0" +} diff --git a/deps/acorn-plugins/acorn-private-class-elements/CHANGELOG.md b/deps/acorn-plugins/acorn-private-class-elements/CHANGELOG.md new file mode 100644 index 0000000000..5b49344b7a --- /dev/null +++ b/deps/acorn-plugins/acorn-private-class-elements/CHANGELOG.md @@ -0,0 +1,7 @@ +## 0.1.1 (2019-02-09) + +* Add \_branch() method + +## 0.1.0 (2019-02-09) + +Initial release diff --git a/deps/acorn-plugins/acorn-private-class-elements/LICENSE b/deps/acorn-plugins/acorn-private-class-elements/LICENSE new file mode 100644 index 0000000000..7c2b27a19c --- /dev/null +++ b/deps/acorn-plugins/acorn-private-class-elements/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2017-2018 by Adrian Heine + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/deps/acorn-plugins/acorn-private-class-elements/README.md b/deps/acorn-plugins/acorn-private-class-elements/README.md new file mode 100644 index 0000000000..0d228820cd --- /dev/null +++ b/deps/acorn-plugins/acorn-private-class-elements/README.md @@ -0,0 +1,11 @@ +# Helpers for supporting private class methods and fields for Acorn + +[![NPM version](https://img.shields.io/npm/v/acorn-private-class-elements.svg)](https://www.npmjs.org/package/acorn-private-class-elements) + +This is a plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript. + +It provides helpers for implementing support for private class elements. The emitted AST follows [an ESTree proposal](https://github.com/estree/estree/pull/180). + +## License + +This plugin is released under an [MIT License](./LICENSE). diff --git a/deps/acorn-plugins/acorn-private-class-elements/index.js b/deps/acorn-plugins/acorn-private-class-elements/index.js new file mode 100644 index 0000000000..90f2b70437 --- /dev/null +++ b/deps/acorn-plugins/acorn-private-class-elements/index.js @@ -0,0 +1,123 @@ +"use strict" + +const acorn = require('internal/deps/acorn/acorn/dist/acorn') +if (acorn.version.indexOf("6.") != 0 || acorn.version.indexOf("6.0.") == 0) { + throw new Error(`acorn-private-class-elements requires acorn@^6.1.0, not ${acorn.version}`) +} +const tt = acorn.tokTypes +const TokenType = acorn.TokenType + +module.exports = function(Parser) { + // Only load this plugin once. + if (Parser.prototype.parsePrivateName) { + return Parser + } + + // Make sure `Parser` comes from the same acorn as our `tt`, + // otherwise the comparisons fail. + let cur = Parser + while (cur && cur !== acorn.Parser) { + cur = cur.__proto__ + } + if (cur !== acorn.Parser) { + throw new Error("acorn-private-class-elements does not support mixing different acorn copies") + } + + Parser = class extends Parser { + _branch() { + this.__branch = this.__branch || new Parser({ecmaVersion: this.options.ecmaVersion}, this.input) + this.__branch.end = this.end + this.__branch.pos = this.pos + this.__branch.type = this.type + this.__branch.value = this.value + this.__branch.containsEsc = this.containsEsc + return this.__branch + } + + parsePrivateClassElementName(element) { + element.computed = false + element.key = this.parsePrivateName() + if (element.key.name == "constructor") this.raise(element.key.start, "Classes may not have a private element named constructor") + const accept = {get: "set", set: "get"}[element.kind] + const privateBoundNames = this._privateBoundNamesStack[this._privateBoundNamesStack.length - 1] + if (Object.prototype.hasOwnProperty.call(privateBoundNames, element.key.name) && privateBoundNames[element.key.name] !== accept) { + this.raise(element.start, "Duplicate private element") + } + privateBoundNames[element.key.name] = element.kind || true + delete this._unresolvedPrivateNamesStack[this._unresolvedPrivateNamesStack.length - 1][element.key.name] + return element.key + } + + parsePrivateName() { + const node = this.startNode() + node.name = this.value + this.next() + this.finishNode(node, "PrivateName") + if (this.options.allowReserved == "never") this.checkUnreserved(node) + return node + } + + // Parse # token + getTokenFromCode(code) { + if (code === 35) { + ++this.pos + const word = this.readWord1() + return this.finishToken(this.privateNameToken, word) + } + return super.getTokenFromCode(code) + } + + // Manage stacks and check for undeclared private names + parseClass(node, isStatement) { + this._privateBoundNamesStack = this._privateBoundNamesStack || [] + const privateBoundNames = Object.create(this._privateBoundNamesStack[this._privateBoundNamesStack.length - 1] || null) + this._privateBoundNamesStack.push(privateBoundNames) + this._unresolvedPrivateNamesStack = this._unresolvedPrivateNamesStack || [] + const unresolvedPrivateNames = Object.create(null) + this._unresolvedPrivateNamesStack.push(unresolvedPrivateNames) + const _return = super.parseClass(node, isStatement) + this._privateBoundNamesStack.pop() + this._unresolvedPrivateNamesStack.pop() + if (!this._unresolvedPrivateNamesStack.length) { + const names = Object.keys(unresolvedPrivateNames) + if (names.length) { + names.sort((n1, n2) => unresolvedPrivateNames[n1] - unresolvedPrivateNames[n2]) + this.raise(unresolvedPrivateNames[names[0]], "Usage of undeclared private name") + } + } else Object.assign(this._unresolvedPrivateNamesStack[this._unresolvedPrivateNamesStack.length - 1], unresolvedPrivateNames) + return _return + } + + // Parse private element access + parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow) { + if (!this.eat(tt.dot)) { + return super.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow) + } + let node = this.startNodeAt(startPos, startLoc) + node.object = base + node.computed = false + if (this.type == this.privateNameToken) { + node.property = this.parsePrivateName() + if (!this._privateBoundNamesStack.length || !this._privateBoundNamesStack[this._privateBoundNamesStack.length - 1][node.property.name]) { + this._unresolvedPrivateNamesStack[this._unresolvedPrivateNamesStack.length - 1][node.property.name] = node.property.start + } + } else { + node.property = this.parseIdent(true) + } + return this.finishNode(node, "MemberExpression") + } + + // Prohibit delete of private class elements + parseMaybeUnary(refDestructuringErrors, sawUnary) { + const _return = super.parseMaybeUnary(refDestructuringErrors, sawUnary) + if (_return.operator == "delete") { + if (_return.argument.type == "MemberExpression" && _return.argument.property.type == "PrivateName") { + this.raise(_return.start, "Private elements may not be deleted") + } + } + return _return + } + } + Parser.prototype.privateNameToken = new TokenType("privateName") + return Parser +} diff --git a/deps/acorn-plugins/acorn-private-class-elements/package.json b/deps/acorn-plugins/acorn-private-class-elements/package.json new file mode 100644 index 0000000000..cd43012dc7 --- /dev/null +++ b/deps/acorn-plugins/acorn-private-class-elements/package.json @@ -0,0 +1,63 @@ +{ + "_from": "acorn-private-class-elements@^0.1.1", + "_id": "acorn-private-class-elements@0.1.1", + "_inBundle": false, + "_integrity": "sha512-bZpmSnaOsK3jkF7J8xaLJ05f008vapPX+XliIv8+jjkclvDR+M4OnTHLhFnCCSeJ0fMwRKjbY+BXsglSNpVZtw==", + "_location": "/acorn-private-class-elements", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "acorn-private-class-elements@^0.1.1", + "name": "acorn-private-class-elements", + "escapedName": "acorn-private-class-elements", + "rawSpec": "^0.1.1", + "saveSpec": null, + "fetchSpec": "^0.1.1" + }, + "_requiredBy": [ + "/acorn-class-fields" + ], + "_resolved": "https://registry.npmjs.org/acorn-private-class-elements/-/acorn-private-class-elements-0.1.1.tgz", + "_shasum": "85209cb5791ab84fde2362cb208fa51e7679bcdc", + "_spec": "acorn-private-class-elements@^0.1.1", + "_where": "/home/ruben/repos/node/node/node_modules/acorn-class-fields", + "bugs": { + "url": "https://github.com/acornjs/acorn-private-class-elements/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Adrian Heine", + "email": "mail@adrianheine.de" + } + ], + "dependencies": { + "mocha": "^5.2.0" + }, + "deprecated": false, + "description": "Helpers for supporting private class methods and fields in acorn", + "devDependencies": { + "acorn": "^6.1.0", + "eslint": "^5.13.0", + "eslint-plugin-node": "^8.0.1" + }, + "engines": { + "node": ">=4.8.2" + }, + "homepage": "https://github.com/acornjs/acorn-private-class-elements", + "license": "MIT", + "name": "acorn-private-class-elements", + "peerDependencies": { + "acorn": "^6.1.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/acornjs/acorn-private-class-elements.git" + }, + "scripts": { + "lint": "eslint -c .eslintrc.json .", + "test": "mocha" + }, + "version": "0.1.1" +} diff --git a/deps/acorn-plugins/acorn-private-methods/CHANGELOG.md b/deps/acorn-plugins/acorn-private-methods/CHANGELOG.md new file mode 100644 index 0000000000..5de4b97b81 --- /dev/null +++ b/deps/acorn-plugins/acorn-private-methods/CHANGELOG.md @@ -0,0 +1,29 @@ +## 0.3.0 (2019-02-09) + +* Require acorn >= 6.1.0 + +## 0.2.3 (2019-02-09) + +* Forbid binding await in async arrow function's parameter list + +## 0.2.2 (2019-01-30) + +* Fix parsing of chained subscripts + +## 0.2.1 (2018-11-06) + +* Adapt to changes in acorn 6.0.3 + +## 0.2.0 (2018-09-14) + +* Update to new acorn 6 interface +* Change license to MIT +* Don't allow direct super() calls in private methods + +## 0.1.1 (2018-02-09) + +* Don't accept whitespace between hash and private name + +## 0.1.0 (2018-01-13) + +Initial release diff --git a/deps/acorn-plugins/acorn-private-methods/LICENSE b/deps/acorn-plugins/acorn-private-methods/LICENSE new file mode 100644 index 0000000000..7c2b27a19c --- /dev/null +++ b/deps/acorn-plugins/acorn-private-methods/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2017-2018 by Adrian Heine + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/deps/acorn-plugins/acorn-private-methods/README.md b/deps/acorn-plugins/acorn-private-methods/README.md new file mode 100644 index 0000000000..6929e84ba6 --- /dev/null +++ b/deps/acorn-plugins/acorn-private-methods/README.md @@ -0,0 +1,21 @@ +# Private methods and getter/setters support for Acorn + +[![NPM version](https://img.shields.io/npm/v/acorn-private-methods.svg)](https://www.npmjs.org/package/acorn-private-methods) + +This is a plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript. + +It implements support for private methods, getters and setters as defined in the stage 3 proposal [Private methods and getter/setters for JavaScript classes](https://github.com/tc39/proposal-private-methods). The emitted AST follows [an ESTree proposal](https://github.com/estree/estree/pull/180). + +## Usage + +This module provides a plugin that can be used to extend the Acorn `Parser` class: + +```javascript +const {Parser} = require('acorn'); +const privateMethods = require('acorn-private-methods'); +Parser.extend(privateMethods).parse('class X { #a() {} }'); +``` + +## License + +This plugin is released under an [MIT License](./LICENSE). diff --git a/deps/acorn-plugins/acorn-private-methods/index.js b/deps/acorn-plugins/acorn-private-methods/index.js new file mode 100644 index 0000000000..a296425168 --- /dev/null +++ b/deps/acorn-plugins/acorn-private-methods/index.js @@ -0,0 +1,25 @@ +"use strict" + +const privateClassElements = require('internal/deps/acorn-plugins/acorn-private-class-elements/index') + +module.exports = function(Parser) { + const ExtendedParser = privateClassElements(Parser) + + return class extends ExtendedParser { + // Parse private methods + parseClassElement(_constructorAllowsSuper) { + const oldInClassMemberName = this._inClassMemberName + this._inClassMemberName = true + const result = super.parseClassElement.apply(this, arguments) + this._inClassMemberName = oldInClassMemberName + return result + } + + parsePropertyName(prop) { + const isPrivate = this.options.ecmaVersion >= 8 && this._inClassMemberName && this.type == this.privateNameToken + this._inClassMemberName = false + if (!isPrivate) return super.parsePropertyName(prop) + return this.parsePrivateClassElementName(prop) + } + } +} diff --git a/deps/acorn-plugins/acorn-private-methods/package.json b/deps/acorn-plugins/acorn-private-methods/package.json new file mode 100644 index 0000000000..d25c611316 --- /dev/null +++ b/deps/acorn-plugins/acorn-private-methods/package.json @@ -0,0 +1,68 @@ +{ + "_from": "acorn-private-methods", + "_id": "acorn-private-methods@0.3.0", + "_inBundle": false, + "_integrity": "sha512-+gWTjSA+13lsv1mwCPosSrLzEyghYtWgrr/1Ck7i7Pu5iK7Ke0hOgw3IW1RUxhc4qS2QTQBQx2+qHYqsa4Qlqw==", + "_location": "/acorn-private-methods", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "acorn-private-methods", + "name": "acorn-private-methods", + "escapedName": "acorn-private-methods", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/acorn-private-methods/-/acorn-private-methods-0.3.0.tgz", + "_shasum": "a5a9f8cd83d175bc138fa22592fababd0afda35d", + "_spec": "acorn-private-methods", + "_where": "/home/ruben/repos/node/node", + "bugs": { + "url": "https://github.com/acornjs/acorn-private-methods/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Adrian Heine", + "email": "mail@adrianheine.de" + } + ], + "dependencies": { + "acorn-private-class-elements": "^0.1.0" + }, + "deprecated": false, + "description": "Support for private methods in acorn", + "devDependencies": { + "acorn": "^6.1.0", + "eslint": "^5.13.0", + "eslint-plugin-node": "^8.0.1", + "mocha": "^5.2.0", + "test262": "git+https://github.com/tc39/test262.git#33a306d1026b72227eb50a918db19ada16f12b3d", + "test262-parser-runner": "^0.5.0" + }, + "engines": { + "node": ">=4.8.2" + }, + "homepage": "https://github.com/acornjs/acorn-private-methods", + "license": "MIT", + "name": "acorn-private-methods", + "peerDependencies": { + "acorn": "^6.1.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/acornjs/acorn-private-methods.git" + }, + "scripts": { + "lint": "eslint -c .eslintrc.json .", + "test": "mocha", + "test:test262": "node run_test262.js" + }, + "version": "0.3.0" +} diff --git a/deps/acorn-plugins/acorn-static-class-features/CHANGELOG.md b/deps/acorn-plugins/acorn-static-class-features/CHANGELOG.md new file mode 100644 index 0000000000..b9896a4bc5 --- /dev/null +++ b/deps/acorn-plugins/acorn-static-class-features/CHANGELOG.md @@ -0,0 +1,11 @@ +## 0.2.0 (2019-02-09) + +* Require acorn >= 6.1.0 + +## 0.1.1 (2018-11-06) + +* Adapt to changes in acorn 6.0.3 + +## 0.1.0 (2018-09-14) + +Initial release diff --git a/deps/acorn-plugins/acorn-static-class-features/LICENSE b/deps/acorn-plugins/acorn-static-class-features/LICENSE new file mode 100644 index 0000000000..7c2b27a19c --- /dev/null +++ b/deps/acorn-plugins/acorn-static-class-features/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2017-2018 by Adrian Heine + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/deps/acorn-plugins/acorn-static-class-features/README.md b/deps/acorn-plugins/acorn-static-class-features/README.md new file mode 100644 index 0000000000..bb214fce16 --- /dev/null +++ b/deps/acorn-plugins/acorn-static-class-features/README.md @@ -0,0 +1,21 @@ +# Static class features support for Acorn + +[![NPM version](https://img.shields.io/npm/v/acorn-class-fields.svg)](https://www.npmjs.org/package/acorn-static-class-features) + +This is a plugin for [Acorn](http://marijnhaverbeke.nl/acorn/) - a tiny, fast JavaScript parser, written completely in JavaScript. + +It implements support for static class features as defined in the stage 3 proposal [Static class features](https://github.com/tc39/proposal-static-class-features). The emitted AST follows [an ESTree proposal](https://github.com/estree/estree/pull/180). + +## Usage + +This module provides a plugin that can be used to extend the Acorn `Parser` class: + +```javascript +const {Parser} = require('acorn'); +const staticClassFeatures = require('acorn-static-class-features'); +Parser.extend(staticClassFeatures).parse('class X { static x = 0 }'); +``` + +## License + +This plugin is released under an [MIT License](./LICENSE). diff --git a/deps/acorn-plugins/acorn-static-class-features/index.js b/deps/acorn-plugins/acorn-static-class-features/index.js new file mode 100644 index 0000000000..d8954bf327 --- /dev/null +++ b/deps/acorn-plugins/acorn-static-class-features/index.js @@ -0,0 +1,126 @@ +"use strict" + +const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g + +const acorn = require('internal/deps/acorn/acorn/dist/acorn') +const tt = acorn.tokTypes + +function maybeParseFieldValue(field) { + if (this.eat(tt.eq)) { + const oldInFieldValue = this._inStaticFieldValue + this._inStaticFieldValue = true + field.value = this.parseExpression() + this._inStaticFieldValue = oldInFieldValue + } else field.value = null +} + +const privateClassElements = require("internal/deps/acorn-plugins/acorn-private-class-elements/index") + +module.exports = function(Parser) { + const ExtendedParser = privateClassElements(Parser) + + return class extends ExtendedParser { + // Parse private fields + parseClassElement(_constructorAllowsSuper) { + if (this.eat(tt.semi)) return null + + const node = this.startNode() + + const tryContextual = (k, noLineBreak) => { + if (typeof noLineBreak == "undefined") noLineBreak = false + const start = this.start, startLoc = this.startLoc + if (!this.eatContextual(k)) return false + if (this.type !== tt.parenL && (!noLineBreak || !this.canInsertSemicolon())) return true + if (node.key) this.unexpected() + node.computed = false + node.key = this.startNodeAt(start, startLoc) + node.key.name = k + this.finishNode(node.key, "Identifier") + return false + } + + node.static = tryContextual("static") + if (!node.static) return super.parseClassElement.apply(this, arguments) + + let isGenerator = this.eat(tt.star) + let isAsync = false + if (!isGenerator) { + // Special-case for `async`, since `parseClassMember` currently looks + // for `(` to determine whether `async` is a method name + if (this.options.ecmaVersion >= 8 && this.isContextual("async")) { + skipWhiteSpace.lastIndex = this.pos + let skip = skipWhiteSpace.exec(this.input) + let next = this.input.charAt(this.pos + skip[0].length) + if (next === ";" || next === "=") { + node.key = this.parseIdent(true) + node.computed = false + maybeParseFieldValue.call(this, node) + this.finishNode(node, "FieldDefinition") + this.semicolon() + return node + } else if (this.options.ecmaVersion >= 8 && tryContextual("async", true)) { + isAsync = true + isGenerator = this.options.ecmaVersion >= 9 && this.eat(tt.star) + } + } else if (tryContextual("get")) { + node.kind = "get" + } else if (tryContextual("set")) { + node.kind = "set" + } + } + if (this.type === this.privateNameToken) { + this.parsePrivateClassElementName(node) + if (this.type !== tt.parenL) { + if (node.key.name === "prototype") { + this.raise(node.key.start, "Classes may not have a private static property named prototype") + } + maybeParseFieldValue.call(this, node) + this.finishNode(node, "FieldDefinition") + this.semicolon() + return node + } + } else if (!node.key) { + this.parsePropertyName(node) + if ((node.key.name || node.key.value) === "prototype" && !node.computed) { + this.raise(node.key.start, "Classes may not have a static property named prototype") + } + } + if (!node.kind) node.kind = "method" + this.parseClassMethod(node, isGenerator, isAsync) + if (!node.kind && (node.key.name || node.key.value) === "constructor" && !node.computed) { + this.raise(node.key.start, "Classes may not have a static field named constructor") + } + if (node.kind === "get" && node.value.params.length !== 0) { + this.raiseRecoverable(node.value.start, "getter should have no params") + } + if (node.kind === "set" && node.value.params.length !== 1) { + this.raiseRecoverable(node.value.start, "setter should have exactly one param") + } + if (node.kind === "set" && node.value.params[0].type === "RestElement") { + this.raiseRecoverable(node.value.params[0].start, "Setter cannot use rest params") + } + + return node + + } + + // Parse public static fields + parseClassMethod(method, isGenerator, isAsync, _allowsDirectSuper) { + if (isGenerator || isAsync || method.kind != "method" || !method.static || this.options.ecmaVersion < 8 || this.type == tt.parenL) { + return super.parseClassMethod.apply(this, arguments) + } + maybeParseFieldValue.call(this, method) + delete method.kind + method = this.finishNode(method, "FieldDefinition") + this.semicolon() + return method + } + + // Prohibit arguments in class field initializers + parseIdent(liberal, isBinding) { + const ident = super.parseIdent(liberal, isBinding) + if (this._inStaticFieldValue && ident.name == "arguments") this.raise(ident.start, "A static class field initializer may not contain arguments") + return ident + } + } +} diff --git a/deps/acorn-plugins/acorn-static-class-features/package.json b/deps/acorn-plugins/acorn-static-class-features/package.json new file mode 100644 index 0000000000..ff9ff30c05 --- /dev/null +++ b/deps/acorn-plugins/acorn-static-class-features/package.json @@ -0,0 +1,68 @@ +{ + "_from": "acorn-static-class-features", + "_id": "acorn-static-class-features@0.2.0", + "_inBundle": false, + "_integrity": "sha512-46IooHSRsvgSi+t36Wx9iPfF9BKFKVDcAWELXVqvKHmZogSCk11iUCi2FiZmLeTaM0hlJ3EYDyYiVmHRUGPzWA==", + "_location": "/acorn-static-class-features", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "acorn-static-class-features", + "name": "acorn-static-class-features", + "escapedName": "acorn-static-class-features", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/acorn-static-class-features/-/acorn-static-class-features-0.2.0.tgz", + "_shasum": "8a12b0b280b2e067e268fdbb14116a5b02affd71", + "_spec": "acorn-static-class-features", + "_where": "/home/ruben/repos/node/node", + "bugs": { + "url": "https://github.com/acornjs/acorn-static-class-features/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Adrian Heine", + "email": "mail@adrianheine.de" + } + ], + "dependencies": { + "acorn-private-class-elements": "^0.1.0" + }, + "deprecated": false, + "description": "Support for static class features in acorn", + "devDependencies": { + "acorn": "^6.1.0", + "eslint": "^5.13.0", + "eslint-plugin-node": "^8.0.1", + "mocha": "^5.2.0", + "test262": "git+https://github.com/tc39/test262.git#33a306d1026b72227eb50a918db19ada16f12b3d", + "test262-parser-runner": "^0.5.0" + }, + "engines": { + "node": ">=4.8.2" + }, + "homepage": "https://github.com/acornjs/acorn-static-class-features", + "license": "MIT", + "name": "acorn-static-class-features", + "peerDependencies": { + "acorn": "^6.1.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/acornjs/acorn-static-class-features.git" + }, + "scripts": { + "lint": "eslint -c .eslintrc.json .", + "test": "mocha", + "test:test262": "node run_test262.js" + }, + "version": "0.2.0" +} |