Bug 1198453 - Make ES7 Exponentiation operator nightly only. (r=jorendorff)
authorEric Faust <efaustbmo@gmail.com>
Tue, 25 Aug 2015 16:51:12 -0700
changeset 259345 dba2e2a8a37c607134f0a7f8060d75684b733721
parent 259344 7a1c73b41bb5dd5d9435b70b376257fc9ba3909f
child 259346 2b45f6b6d29fed190e5a4aae78c8fffcf2ec01e9
push id29277
push userryanvm@gmail.com
push dateWed, 26 Aug 2015 18:32:23 +0000
treeherdermozilla-central@fea87cbeaa6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1198453
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 1198453 - Make ES7 Exponentiation operator nightly only. (r=jorendorff)
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 == '#') {
@@ -1818,17 +1820,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);