Bug 1185106 - Part 5.2: Support async function declaration in Reflect.parse. r=efaust,till draft
authorMariusz Kierski <mkierski@mozilla.com>
Sun, 28 Aug 2016 20:42:40 +0900
changeset 430927 6ee2b45128eb1333f5bfe66afd7660d3650a154f
parent 430926 b033a1287e64c4f12345b4b30629ea55344ec61a
child 430928 e6fb7482513d741a778375b9a7b2cb0a5fdf073b
push id33945
push userarai_a@mac.com
push dateFri, 28 Oct 2016 11:34:02 +0000
reviewersefaust, till
bugs1185106
milestone52.0a1
Bug 1185106 - Part 5.2: Support async function declaration in Reflect.parse. r=efaust,till MozReview-Commit-ID: Gbc8dmANx1v
js/src/builtin/ReflectParse.cpp
--- a/js/src/builtin/ReflectParse.cpp
+++ b/js/src/builtin/ReflectParse.cpp
@@ -461,17 +461,17 @@ class NodeBuilder
 
     MOZ_MUST_USE bool literal(HandleValue val, TokenPos* pos, MutableHandleValue dst);
 
     MOZ_MUST_USE bool identifier(HandleValue name, TokenPos* pos, MutableHandleValue dst);
 
     MOZ_MUST_USE bool function(ASTType type, TokenPos* pos,
                                HandleValue id, NodeVector& args, NodeVector& defaults,
                                HandleValue body, HandleValue rest, GeneratorStyle generatorStyle,
-                               bool isExpression, MutableHandleValue dst);
+                               bool isAsync, bool isExpression, MutableHandleValue dst);
 
     MOZ_MUST_USE bool variableDeclarator(HandleValue id, HandleValue init, TokenPos* pos,
                                          MutableHandleValue dst);
 
     MOZ_MUST_USE bool switchCase(HandleValue expr, NodeVector& elts, TokenPos* pos, MutableHandleValue dst);
 
     MOZ_MUST_USE bool catchClause(HandleValue var, HandleValue guard, HandleValue body, TokenPos* pos,
                                   MutableHandleValue dst);
@@ -1585,27 +1585,28 @@ NodeBuilder::arrayPattern(NodeVector& el
 {
     return listNode(AST_ARRAY_PATT, "elements", elts, pos, dst);
 }
 
 bool
 NodeBuilder::function(ASTType type, TokenPos* pos,
                       HandleValue id, NodeVector& args, NodeVector& defaults,
                       HandleValue body, HandleValue rest,
-                      GeneratorStyle generatorStyle, bool isExpression,
+                      GeneratorStyle generatorStyle, bool isAsync, bool isExpression,
                       MutableHandleValue dst)
 {
     RootedValue array(cx), defarray(cx);
     if (!newArray(args, &array))
         return false;
     if (!newArray(defaults, &defarray))
         return false;
 
     bool isGenerator = generatorStyle != GeneratorStyle::None;
     RootedValue isGeneratorVal(cx, BooleanValue(isGenerator));
+    RootedValue isAsyncVal(cx, BooleanValue(isAsync));
     RootedValue isExpressionVal(cx, BooleanValue(isExpression));
 
     RootedValue cb(cx, callbacks[type]);
     if (!cb.isNull()) {
         return callback(cb, opt(id), array, body, isGeneratorVal, isExpressionVal, pos, dst);
     }
 
     if (isGenerator) {
@@ -1619,28 +1620,30 @@ NodeBuilder::function(ASTType type, Toke
         styleVal.setString(styleStr);
         return newNode(type, pos,
                        "id", id,
                        "params", array,
                        "defaults", defarray,
                        "body", body,
                        "rest", rest,
                        "generator", isGeneratorVal,
+                       "async", isAsyncVal,
                        "style", styleVal,
                        "expression", isExpressionVal,
                        dst);
     }
 
     return newNode(type, pos,
                    "id", id,
                    "params", array,
                    "defaults", defarray,
                    "body", body,
                    "rest", rest,
                    "generator", isGeneratorVal,
+                   "async", isAsyncVal,
                    "expression", isExpressionVal,
                    dst);
 }
 
 bool
 NodeBuilder::classMethod(HandleValue name, HandleValue body, PropKind kind, bool isStatic,
                          TokenPos* pos, MutableHandleValue dst)
 {
@@ -3391,16 +3394,17 @@ ASTSerializer::function(ParseNode* pn, A
 
     GeneratorStyle generatorStyle =
         pn->pn_funbox->isGenerator()
         ? (pn->pn_funbox->isLegacyGenerator()
            ? GeneratorStyle::Legacy
            : GeneratorStyle::ES6)
         : GeneratorStyle::None;
 
+    bool isAsync = pn->pn_funbox->isAsync();
     bool isExpression =
 #if JS_HAS_EXPR_CLOSURES
         func->isExprBody();
 #else
         false;
 #endif
 
     RootedValue id(cx);
@@ -3412,18 +3416,18 @@ ASTSerializer::function(ParseNode* pn, A
     NodeVector defaults(cx);
 
     RootedValue body(cx), rest(cx);
     if (func->hasRest())
         rest.setUndefined();
     else
         rest.setNull();
     return functionArgsAndBody(pn->pn_body, args, defaults, &body, &rest) &&
-        builder.function(type, &pn->pn_pos, id, args, defaults, body,
-                         rest, generatorStyle, isExpression, dst);
+           builder.function(type, &pn->pn_pos, id, args, defaults, body,
+                            rest, generatorStyle, isAsync, isExpression, dst);
 }
 
 bool
 ASTSerializer::functionArgsAndBody(ParseNode* pn, NodeVector& args, NodeVector& defaults,
                                    MutableHandleValue body, MutableHandleValue rest)
 {
     ParseNode* pnargs;
     ParseNode* pnbody;