Bug 1198453 - Make ES7 Exponentiation operator nightly only. r=jorendorff, a=sledru
authorEric Faust <efaustbmo@gmail.com>
Tue, 25 Aug 2015 16:51:12 -0700
changeset 288951 80c9f107c3aedea0da43ef1c3769b644b83ec654
parent 288950 cf044859a757e0a34fc2078e5e10d4567bb31704
child 288952 bd7b9630b3d8fcc04766275a80d2f13cfcb957f1
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)
reviewersjorendorff, sledru
bugs1198453
milestone42.0a2
Bug 1198453 - Make ES7 Exponentiation operator nightly only. r=jorendorff, a=sledru
js/src/frontend/TokenStream.cpp
js/src/jsversion.h
js/src/tests/ecma_7/Math/Pow.js
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -1504,19 +1504,21 @@ TokenStream::getTokenInternal(TokenKind*
             else
                 tp->type = matchChar('=') ? TOK_RSHASSIGN : TOK_RSH;
         } else {
             tp->type = matchChar('=') ? TOK_GE : TOK_GT;
         }
         goto out;
 
       case '*':
+#ifdef JS_HAS_EXPONENTIATION
         if (matchChar('*'))
             tp->type = matchChar('=') ? TOK_POWASSIGN : TOK_POW;
         else
+#endif
             tp->type = matchChar('=') ? TOK_MULASSIGN : TOK_MUL;
         goto out;
 
       case '/':
         // Look for a single-line comment.
         if (matchChar('/')) {
             c = peekChar();
             if (c == '@' || c == '#') {
@@ -1811,17 +1813,17 @@ TokenStream::getStringOrTemplateToken(in
                             if (val <= 0xFF)
                                 getChar();
                             else
                                 val = save;
                         }
                     }
 
                     c = char16_t(val);
-                } 
+                }
                 break;
             }
         } else if (TokenBuf::isRawEOLChar(c)) {
             if (!parsingTemplate) {
                 ungetCharIgnoreEOL(c);
                 reportError(JSMSG_UNTERMINATED_STRING);
                 return false;
             }
--- a/js/src/jsversion.h
+++ b/js/src/jsversion.h
@@ -36,14 +36,19 @@
 #define JS_HAS_DESTRUCTURING_SHORTHAND  (JS_HAS_DESTRUCTURING == 2)
 
 /*
  * Feature for Object.prototype.__{define,lookup}{G,S}etter__ legacy support;
  * support likely to be made opt-in at some future time.
  */
 #define JS_OLD_GETTER_SETTER_METHODS    1
 
+#ifdef NIGHTLY_BUILD
+
 /* Support for ES6 Classes. */
-#ifdef NIGHTLY_BUILD
 #define JS_HAS_CLASSES 1
-#endif
+
+/* Support for ES7 Exponentiation proposal. */
+//#define JS_HAS_EXPONENTIATION 1
+
+#endif // NIGHTLY_BUILD
 
 #endif /* jsversion_h */
--- a/js/src/tests/ecma_7/Math/Pow.js
+++ b/js/src/tests/ecma_7/Math/Pow.js
@@ -4,16 +4,18 @@
  * http://creativecommons.org/licenses/publicdomain/
  */
 
 var BUGNUMBER = 1135708;
 var summary = "Implement the exponentiation operator";
 
 print(BUGNUMBER + ": " + summary);
 
+var test = `
+
 // Constant folding
 assertEq(2 ** 2 ** 3, 256);
 assertEq(1 ** 1 ** 4, 1);
 
 // No folding
 var two = 2;
 var three = 3;
 var four = 4;
@@ -94,11 +96,23 @@ assertEq(parseTree.body[0].expression.ri
 
 function assertTrue(v) {
     assertEq(v, true);
 }
 
 function assertFalse(v) {
     assertEq(v, false);
 }
+`;
+
+function exponentiationEnabled() {
+    try {
+        Function("1 ** 1");
+        return true;
+    } catch (e if e instanceof SyntaxError) { }
+    return false;
+}
+
+if (exponentiationEnabled())
+    eval(test);
 
 if (typeof reportCompare === "function")
     reportCompare(true, true);