Bug 1183400 - Fold class nodes by kind. r=shu
authorJeff Walden <jwalden@mit.edu>
Mon, 13 Jul 2015 13:09:54 -0700
changeset 288560 c753a5b5cfb5f2fddf484e9b23fa86a8174aeb46
parent 288559 0ca4340aaf49a8b547011987958756d5b54277fa
child 288561 d263ff7885e9270e42320ecf5b64d801edb30134
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshu
bugs1183400
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1183400 - Fold class nodes by kind. r=shu
js/src/frontend/FoldConstants.cpp
--- a/js/src/frontend/FoldConstants.cpp
+++ b/js/src/frontend/FoldConstants.cpp
@@ -1362,16 +1362,37 @@ FoldCatch(ExclusiveContext* cx, ParseNod
     if (ParseNode*& statements = node->pn_kid3) {
         if (!Fold(cx, &statements, parser, inGenexpLambda, SyntacticContext::Other))
             return false;
     }
 
     return true;
 }
 
+static bool
+FoldClass(ExclusiveContext* cx, ParseNode* node, Parser<FullParseHandler>& parser,
+          bool inGenexpLambda)
+{
+    MOZ_ASSERT(node->isKind(PNK_CLASS));
+    MOZ_ASSERT(node->isArity(PN_TERNARY));
+
+    if (ParseNode*& classNames = node->pn_kid1) {
+        if (!Fold(cx, &classNames, parser, inGenexpLambda, SyntacticContext::Other))
+            return false;
+    }
+
+    if (ParseNode*& heritage = node->pn_kid2) {
+        if (!Fold(cx, &heritage, parser, inGenexpLambda, SyntacticContext::Other))
+            return false;
+    }
+
+    ParseNode*& body = node->pn_kid3;
+    return Fold(cx, &body, parser, inGenexpLambda, SyntacticContext::Other);
+}
+
 bool
 Fold(ExclusiveContext* cx, ParseNode** pnp, Parser<FullParseHandler>& parser, bool inGenexpLambda,
      SyntacticContext sc)
 {
     JS_CHECK_RECURSION(cx, return false);
 
     ParseNode* pn = *pnp;
     ParseNode* pn1 = nullptr;
@@ -1536,16 +1557,19 @@ Fold(ExclusiveContext* cx, ParseNode** p
         return FoldReturn(cx, pn, parser, inGenexpLambda);
 
       case PNK_TRY:
         return FoldTry(cx, pn, parser, inGenexpLambda);
 
       case PNK_CATCH:
         return FoldCatch(cx, pn, parser, inGenexpLambda);
 
+      case PNK_CLASS:
+        return FoldClass(cx, pn, parser, inGenexpLambda);
+
       case PNK_EXPORT:
       case PNK_ASSIGN:
       case PNK_ADDASSIGN:
       case PNK_SUBASSIGN:
       case PNK_BITORASSIGN:
       case PNK_BITXORASSIGN:
       case PNK_BITANDASSIGN:
       case PNK_LSHASSIGN:
@@ -1569,17 +1593,16 @@ Fold(ExclusiveContext* cx, ParseNode** p
       case PNK_CLASSNAMES:
       case PNK_DEFAULT:
       case PNK_IMPORT:
       case PNK_EXPORT_FROM:
       case PNK_EXPORT_DEFAULT:
       case PNK_FORIN:
       case PNK_FOROF:
       case PNK_FORHEAD:
-      case PNK_CLASS:
       case PNK_ADD:
       case PNK_NEW:
       case PNK_CALL:
       case PNK_GENEXP:
       case PNK_TAGGED_TEMPLATE:
       case PNK_LABEL:
       case PNK_DOT:
       case PNK_LEXICALSCOPE: