support for [await]...of statements (#4627)
This commit is contained in:
21
lib/ast.js
21
lib/ast.js
@@ -422,11 +422,11 @@ var AST_For = DEFNODE("For", "init condition step", {
|
||||
},
|
||||
}, AST_IterationStatement);
|
||||
|
||||
var AST_ForIn = DEFNODE("ForIn", "init object", {
|
||||
$documentation: "A `for ... in` statement",
|
||||
var AST_ForEnumeration = DEFNODE("ForEnumeration", "init object", {
|
||||
$documentation: "Base class for enumeration loops, i.e. `for ... in`, `for ... of` & `for await ... of`",
|
||||
$propdoc: {
|
||||
init: "[AST_Node] the `for/in` initialization code",
|
||||
object: "[AST_Node] the object that we're looping through"
|
||||
init: "[AST_Node] the assignment target during iteration",
|
||||
object: "[AST_Node] the object to iterate over"
|
||||
},
|
||||
walk: function(visitor) {
|
||||
var node = this;
|
||||
@@ -437,6 +437,7 @@ var AST_ForIn = DEFNODE("ForIn", "init object", {
|
||||
});
|
||||
},
|
||||
_validate: function() {
|
||||
if (this.TYPE == "ForEnumeration") throw new Error("should not instantiate AST_ForEnumeration");
|
||||
if (this.init instanceof AST_Definitions) {
|
||||
if (this.init.definitions.length != 1) throw new Error("init must have single declaration");
|
||||
} else {
|
||||
@@ -450,6 +451,18 @@ var AST_ForIn = DEFNODE("ForIn", "init object", {
|
||||
},
|
||||
}, AST_IterationStatement);
|
||||
|
||||
var AST_ForIn = DEFNODE("ForIn", null, {
|
||||
$documentation: "A `for ... in` statement",
|
||||
}, AST_ForEnumeration);
|
||||
|
||||
var AST_ForOf = DEFNODE("ForOf", null, {
|
||||
$documentation: "A `for ... of` statement",
|
||||
}, AST_ForEnumeration);
|
||||
|
||||
var AST_ForAwaitOf = DEFNODE("ForAwaitOf", null, {
|
||||
$documentation: "A `for await ... of` statement",
|
||||
}, AST_ForOf);
|
||||
|
||||
var AST_With = DEFNODE("With", "expression", {
|
||||
$documentation: "A `with` statement",
|
||||
$propdoc: {
|
||||
|
||||
Reference in New Issue
Block a user