Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assert,deps,repl: fix repl and assert not being able to handle language features properly #27400

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,29 @@ The externally maintained libraries used by Node.js are:
THE SOFTWARE.
"""

- Acorn plugins, located at deps/acorn-plugins, is licensed as follows:
"""
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.
"""

- c-ares, located at deps/cares, is licensed as follows:
"""
Copyright (c) 2007 - 2018, Daniel Stenberg with many contributors, see AUTHORS
Expand Down Expand Up @@ -1103,7 +1126,7 @@ The externally maintained libraries used by Node.js are:
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""

- jinja2, located at tools/jinja2, is licensed as follows:
- jinja2, located at tools/inspector_protocol/jinja2, is licensed as follows:
"""
Copyright (c) 2009 by the Jinja Team, see AUTHORS for more details.

Expand Down Expand Up @@ -1138,7 +1161,7 @@ The externally maintained libraries used by Node.js are:
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""

- markupsafe, located at tools/markupsafe, is licensed as follows:
- markupsafe, located at tools/inspector_protocol/markupsafe, is licensed as follows:
"""
Copyright (c) 2010 by Armin Ronacher and contributors. See AUTHORS
for more details.
Expand Down Expand Up @@ -1255,7 +1278,7 @@ The externally maintained libraries used by Node.js are:
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""

- gtest, located at deps/gtest, is licensed as follows:
- gtest, located at test/cctest/gtest, is licensed as follows:
"""
Copyright 2008, Google Inc.
All rights reserved.
Expand Down
21 changes: 21 additions & 0 deletions deps/acorn-plugins/acorn-bigint/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions deps/acorn-plugins/acorn-bigint/LICENSE
Original file line number Diff line number Diff line change
@@ -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.
21 changes: 21 additions & 0 deletions deps/acorn-plugins/acorn-bigint/README.md
Original file line number Diff line number Diff line change
@@ -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).
59 changes: 59 additions & 0 deletions deps/acorn-plugins/acorn-bigint/index.js
Original file line number Diff line number Diff line change
@@ -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)
}
}
}
65 changes: 65 additions & 0 deletions deps/acorn-plugins/acorn-bigint/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"_from": "acorn-bigint",
"_id": "[email protected]",
"_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": "[email protected]"
}
],
"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"
}
28 changes: 28 additions & 0 deletions deps/acorn-plugins/acorn-class-fields/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions deps/acorn-plugins/acorn-class-fields/LICENSE
Original file line number Diff line number Diff line change
@@ -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.
21 changes: 21 additions & 0 deletions deps/acorn-plugins/acorn-class-fields/README.md
Original file line number Diff line number Diff line change
@@ -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).
59 changes: 59 additions & 0 deletions deps/acorn-plugins/acorn-class-fields/index.js
Original file line number Diff line number Diff line change
@@ -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
}
}
}
Loading