Bug 1066827 - Part7: Check error in TokenStream.nextTokenEndsExpr. r=jwalden
☠☠ backed out by b02f4abef018 ☠ ☠
authorTooru Fujisawa <arai_a@mac.com>
Fri, 24 Oct 2014 21:03:00 +0200
changeset 212612 f9c84399eb72da94d1ef82826ed9621962048290
parent 212611 0243acc10d0e5574b1d0fc611a8a09768890c83e
child 212613 7829b67bfb7a58cb5aafc104cad5614e87a04454
push id27721
push usercbook@mozilla.com
push dateTue, 28 Oct 2014 14:55:05 +0000
treeherdermozilla-central@c0ddb1b098ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalden
bugs1066827
milestone36.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 1066827 - Part7: Check error in TokenStream.nextTokenEndsExpr. r=jwalden
js/src/frontend/Parser.cpp
js/src/frontend/TokenStream.h
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -6038,24 +6038,38 @@ Parser<ParseHandler>::assignExpr()
     // In such cases, we can avoid the full expression parsing route through
     // assignExpr(), condExpr1(), orExpr1(), unaryExpr(), memberExpr(), and
     // primaryExpr().
 
     TokenKind tt;
     if (!tokenStream.getToken(&tt, TokenStream::Operand))
         return null();
 
-    if (tt == TOK_NAME && tokenStream.nextTokenEndsExpr())
-        return identifierName();
-
-    if (tt == TOK_NUMBER && tokenStream.nextTokenEndsExpr())
-        return newNumber(tokenStream.currentToken());
-
-    if (tt == TOK_STRING && tokenStream.nextTokenEndsExpr())
-        return stringLiteral();
+    bool endsExpr;
+
+    if (tt == TOK_NAME) {
+        if (!tokenStream.nextTokenEndsExpr(&endsExpr))
+            return null();
+        if (endsExpr)
+            return identifierName();
+    }
+
+    if (tt == TOK_NUMBER) {
+        if (!tokenStream.nextTokenEndsExpr(&endsExpr))
+            return null();
+        if (endsExpr)
+            return newNumber(tokenStream.currentToken());
+    }
+
+    if (tt == TOK_STRING) {
+        if (!tokenStream.nextTokenEndsExpr(&endsExpr))
+            return null();
+        if (endsExpr)
+            return stringLiteral();
+    }
 
     if (tt == TOK_YIELD && (versionNumber() >= JSVERSION_1_7 || pc->isGenerator()))
         return yieldExpression();
 
     tokenStream.ungetToken();
 
     // Save the tokenizer state in case we find an arrow function and have to
     // rewind.
--- a/js/src/frontend/TokenStream.h
+++ b/js/src/frontend/TokenStream.h
@@ -483,21 +483,22 @@ class MOZ_STACK_CLASS TokenStream
             *matchedp = true;
         } else {
             *matchedp = false;
             ungetToken();
         }
         return true;
     }
 
-    bool nextTokenEndsExpr() {
+    bool nextTokenEndsExpr(bool *endsExpr) {
         TokenKind tt;
         if (!peekToken(&tt))
             return false;
-        return isExprEnding[tt];
+        *endsExpr = isExprEnding[tt];
+        return true;
     }
 
     class MOZ_STACK_CLASS Position {
       public:
         // The Token fields may contain pointers to atoms, so for correct
         // rooting we must ensure collection of atoms is disabled while objects
         // of this class are live.  Do this by requiring a dummy AutoKeepAtoms
         // reference in the constructor.