Improve yield support and restrict usage of strict
- Partially reverting91cdb93e57andeaf3911c31and reimplement - Add generators support for objects and classes - Only classes can have static methods so restrict use of it Special thanks to @rvanvelzen and @kzc for reviewing this patch and providing constructive feedback over and over again.
This commit is contained in:
18
lib/ast.js
18
lib/ast.js
@@ -487,8 +487,9 @@ var AST_Arrow = DEFNODE("Arrow", null, {
|
||||
$documentation: "An ES6 Arrow function ((a) => b)"
|
||||
}, AST_Lambda);
|
||||
|
||||
var AST_ConciseMethod = DEFNODE("ConciseMethod", "static", {
|
||||
var AST_ConciseMethod = DEFNODE("ConciseMethod", "is_generator static", {
|
||||
$propdoc: {
|
||||
is_generator: "is generatorFn or not",
|
||||
static: "[boolean] whether this method is static (classes only)",
|
||||
},
|
||||
$documentation: "An ES6 concise method inside an object or class"
|
||||
@@ -1241,6 +1242,21 @@ var AST_True = DEFNODE("True", null, {
|
||||
value: true
|
||||
}, AST_Boolean);
|
||||
|
||||
/* -----[ Yield ]----- */
|
||||
|
||||
var AST_Yield = DEFNODE("Yield", "expression is_star", {
|
||||
$documentation: "A `yield` statement",
|
||||
$propdoc: {
|
||||
expression: "[AST_Node?] the value returned or thrown by this statement; could be null (representing undefined) but only when is_star is set to false",
|
||||
is_star: "[Boolean] Whether this is a yield or yield* statement"
|
||||
},
|
||||
_walk: function(visitor) {
|
||||
return visitor._visit(this, this.expression && function(){
|
||||
this.expression._walk(visitor);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/* -----[ TreeWalker ]----- */
|
||||
|
||||
function TreeWalker(callback) {
|
||||
|
||||
Reference in New Issue
Block a user