Bug 1195578 - Consolidate NoneIsOperand and NoneIsOperandYieldEOL modifier exceptions into simply NoneIsOperand. r=arai
authorJeff Walden <jwalden@mit.edu>
Fri, 04 Sep 2015 16:44:29 -0700
changeset 293676 9027319a95525e47817e9b709e08a1cdb6d57676
parent 293675 e0d198f50e59bcaebea8fa4eaa27d647f5eb8356
child 293677 6b19b4a888c5df05991a047616cc069378cf5fea
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1195578
milestone43.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 1195578 - Consolidate NoneIsOperand and NoneIsOperandYieldEOL modifier exceptions into simply NoneIsOperand. r=arai
js/src/frontend/Parser.cpp
js/src/frontend/TokenStream.h
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -5908,19 +5908,17 @@ Parser<ParseHandler>::yieldExpression(In
           case TOK_SEMI:
           case TOK_RC:
           case TOK_RB:
           case TOK_RP:
           case TOK_COLON:
           case TOK_COMMA:
             // No value.
             exprNode = null();
-            tokenStream.addModifierException((tt == TOK_EOL || tt == TOK_EOF)
-                                             ? TokenStream::NoneIsOperandYieldEOL
-                                             : TokenStream::NoneIsOperand);
+            tokenStream.addModifierException(TokenStream::NoneIsOperand);
             break;
           case TOK_MUL:
             kind = PNK_YIELD_STAR;
             tokenStream.consumeKnownToken(TOK_MUL, TokenStream::Operand);
             // Fall through.
           default:
             exprNode = assignExpr(inHandling, YieldIsKeyword);
             if (!exprNode)
@@ -5973,19 +5971,17 @@ Parser<ParseHandler>::yieldExpression(In
           case TOK_SEMI:
           case TOK_RC:
           case TOK_RB:
           case TOK_RP:
           case TOK_COLON:
           case TOK_COMMA:
             // No value.
             exprNode = null();
-            tokenStream.addModifierException((tt == TOK_EOL || tt == TOK_EOF)
-                                             ? TokenStream::NoneIsOperandYieldEOL
-                                             : TokenStream::NoneIsOperand);
+            tokenStream.addModifierException(TokenStream::NoneIsOperand);
             break;
           default:
             exprNode = assignExpr(inHandling, YieldIsKeyword);
             if (!exprNode)
                 return null();
         }
 
         return newYieldExpression(begin, exprNode);
--- a/js/src/frontend/TokenStream.h
+++ b/js/src/frontend/TokenStream.h
@@ -116,27 +116,26 @@ struct Token
         //   var s = `Hello ${entity}!`;
         //                          ^ TemplateTail context
         TemplateTail,
     };
     enum ModifierException
     {
         NoException,
 
-        // If an yield expression operand is omitted and yield expression is
-        // followed by non-EOL, the next token is already gotten with Operand,
-        // but we expect operator (None).
+        // After |yield| we look for a token on the same line that starts an
+        // expression (Operand): |yield <expr>|.  If no token is found, the
+        // |yield| stands alone, and the next token on a subsequent line must
+        // be: a comma continuing a comma expression, a semicolon terminating
+        // the statement that ended with |yield|, or the start of another
+        // statement (possibly an expression statement).  The comma/semicolon
+        // cases are gotten as operators (None), contrasting with Operand
+        // earlier.
         NoneIsOperand,
 
-        // If an yield expression operand is omitted and yield expression is
-        // followed by EOL, the next token is already gotten with Operand, and
-        // we expect Operand in next statement, but MatchOrInsertSemicolon
-        // after expression statement expects operator (None).
-        NoneIsOperandYieldEOL,
-
         // If a semicolon is inserted automatically, the next token is already
         // gotten with None, but we expect Operand.
         OperandIsNone,
 
         // If name of method definition is `get` or `set`, the next token is
         // already gotten with KeywordIsName, but we expect None.
         NoneIsKeywordIsName,
     };
@@ -432,49 +431,38 @@ class MOZ_STACK_CLASS TokenStream
     static MOZ_CONSTEXPR_VAR Modifier None = Token::None;
     static MOZ_CONSTEXPR_VAR Modifier Operand = Token::Operand;
     static MOZ_CONSTEXPR_VAR Modifier KeywordIsName = Token::KeywordIsName;
     static MOZ_CONSTEXPR_VAR Modifier TemplateTail = Token::TemplateTail;
 
     typedef Token::ModifierException ModifierException;
     static MOZ_CONSTEXPR_VAR ModifierException NoException = Token::NoException;
     static MOZ_CONSTEXPR_VAR ModifierException NoneIsOperand = Token::NoneIsOperand;
-    static MOZ_CONSTEXPR_VAR ModifierException NoneIsOperandYieldEOL = Token::NoneIsOperandYieldEOL;
     static MOZ_CONSTEXPR_VAR ModifierException OperandIsNone = Token::OperandIsNone;
     static MOZ_CONSTEXPR_VAR ModifierException NoneIsKeywordIsName = Token::NoneIsKeywordIsName;
 
     void addModifierException(ModifierException modifierException) {
 #ifdef DEBUG
         const Token& next = nextToken();
-        if (next.modifierException == NoneIsOperand ||
-            next.modifierException == NoneIsOperandYieldEOL)
+        if (next.modifierException == NoneIsOperand)
         {
             // Token after yield expression without operand already has
-            // NoneIsOperand or NoneIsOperandYieldEOL exception.
+            // NoneIsOperand exception.
             MOZ_ASSERT(modifierException == OperandIsNone);
-            if (next.modifierException == NoneIsOperand)
-                MOZ_ASSERT(next.type != TOK_DIV && next.type != TOK_REGEXP,
-                           "next token requires contextual specifier to be parsed unambiguously");
-            else
-                MOZ_ASSERT(next.type != TOK_DIV,
-                           "next token requires contextual specifier to be parsed unambiguously");
+            MOZ_ASSERT(next.type != TOK_DIV,
+                       "next token requires contextual specifier to be parsed unambiguously");
 
             // Do not update modifierException.
             return;
         }
 
         MOZ_ASSERT(next.modifierException == NoException);
         switch (modifierException) {
           case NoneIsOperand:
             MOZ_ASSERT(next.modifier == Operand);
-            MOZ_ASSERT(next.type != TOK_DIV && next.type != TOK_REGEXP,
-                       "next token requires contextual specifier to be parsed unambiguously");
-            break;
-          case NoneIsOperandYieldEOL:
-            MOZ_ASSERT(next.modifier == Operand);
             MOZ_ASSERT(next.type != TOK_DIV,
                        "next token requires contextual specifier to be parsed unambiguously");
             break;
           case OperandIsNone:
             MOZ_ASSERT(next.modifier == None);
             MOZ_ASSERT(next.type != TOK_DIV && next.type != TOK_REGEXP,
                        "next token requires contextual specifier to be parsed unambiguously");
             break;
@@ -497,19 +485,17 @@ class MOZ_STACK_CLASS TokenStream
             return;
 
         if (lookaheadToken.modifierException == OperandIsNone) {
             // getToken(Operand) permissibly following getToken().
             if (modifier == Operand && lookaheadToken.modifier == None)
                 return;
         }
 
-        if (lookaheadToken.modifierException == NoneIsOperand ||
-            lookaheadToken.modifierException == NoneIsOperandYieldEOL)
-        {
+        if (lookaheadToken.modifierException == NoneIsOperand) {
             // getToken() permissibly following getToken(Operand).
             if (modifier == None && lookaheadToken.modifier == Operand)
                 return;
         }
 
         if (lookaheadToken.modifierException == NoneIsKeywordIsName) {
             // getToken() permissibly following getToken(KeywordIsName).
             if (modifier == None && lookaheadToken.modifier == KeywordIsName)