[7.0] Remove ForAwaitStatement, add await flag to ForOfStatement (#349)
* Remove ForAwaitStatement, add await flag to ForOfStatement * Set await flag for all ForOfStatements
This commit is contained in:
parent
0834cb5b72
commit
56928dca66
12
ast/spec.md
12
ast/spec.md
@ -35,7 +35,6 @@ These are the core Babylon AST node types.
|
||||
- [ForStatement](#forstatement)
|
||||
- [ForInStatement](#forinstatement)
|
||||
- [ForOfStatement](#forofstatement)
|
||||
- [ForAwaitStatement](#forawaitstatement)
|
||||
- [Declarations](#declarations)
|
||||
- [FunctionDeclaration](#functiondeclaration)
|
||||
- [VariableDeclaration](#variabledeclaration)
|
||||
@ -478,16 +477,7 @@ A `for`/`in` statement.
|
||||
```js
|
||||
interface ForOfStatement <: ForInStatement {
|
||||
type: "ForOfStatement";
|
||||
}
|
||||
```
|
||||
|
||||
A `for`/`await` statement.
|
||||
|
||||
## ForAwaitStatement
|
||||
|
||||
```js
|
||||
interface ForAwaitStatement <: ForInStatement {
|
||||
type: "ForAwaitStatement";
|
||||
await: boolean;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@ -530,14 +530,13 @@ pp.parseFor = function (node, init) {
|
||||
// same from parser's perspective.
|
||||
|
||||
pp.parseForIn = function (node, init, forAwait) {
|
||||
let type;
|
||||
const type = this.match(tt._in) ? "ForInStatement" : "ForOfStatement";
|
||||
if (forAwait) {
|
||||
this.eatContextual("of");
|
||||
type = "ForAwaitStatement";
|
||||
} else {
|
||||
type = this.match(tt._in) ? "ForInStatement" : "ForOfStatement";
|
||||
this.next();
|
||||
}
|
||||
node.await = !!forAwait;
|
||||
node.left = init;
|
||||
node.right = this.parseExpression();
|
||||
this.expect(tt.parenR);
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
"type": "ForOfStatement",
|
||||
"start": 0,
|
||||
"end": 13,
|
||||
"await": false,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
|
||||
@ -78,7 +78,7 @@
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ForAwaitStatement",
|
||||
"type": "ForOfStatement",
|
||||
"start": 23,
|
||||
"end": 46,
|
||||
"loc": {
|
||||
@ -91,6 +91,7 @@
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"await": true,
|
||||
"left": {
|
||||
"type": "VariableDeclaration",
|
||||
"start": 34,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user