diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp index 0c21ba6f7fa0..248c32ada93d 100644 --- a/js/src/frontend/TokenStream.cpp +++ b/js/src/frontend/TokenStream.cpp @@ -1509,9 +1509,11 @@ TokenStream::getTokenInternal(TokenKind* ttp, Modifier modifier) 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; @@ -1823,7 +1825,7 @@ TokenStream::getStringOrTemplateToken(int untilChar, Token** tp) } c = char16_t(val); - } + } break; } } else if (TokenBuf::isRawEOLChar(c)) { diff --git a/js/src/jsversion.h b/js/src/jsversion.h index bc2f833c1353..cf93a6aa6e5d 100644 --- a/js/src/jsversion.h +++ b/js/src/jsversion.h @@ -41,9 +41,14 @@ */ #define JS_OLD_GETTER_SETTER_METHODS 1 -/* Support for ES6 Classes. */ #ifdef NIGHTLY_BUILD + +/* Support for ES6 Classes. */ #define JS_HAS_CLASSES 1 -#endif + +/* Support for ES7 Exponentiation proposal. */ +//#define JS_HAS_EXPONENTIATION 1 + +#endif // NIGHTLY_BUILD #endif /* jsversion_h */ diff --git a/js/src/tests/ecma_7/Math/Pow.js b/js/src/tests/ecma_7/Math/Pow.js index 31c64770100f..c7cba3391aef 100644 --- a/js/src/tests/ecma_7/Math/Pow.js +++ b/js/src/tests/ecma_7/Math/Pow.js @@ -9,6 +9,8 @@ var summary = "Implement the exponentiation operator"; print(BUGNUMBER + ": " + summary); +var test = ` + // Constant folding assertEq(2 ** 2 ** 3, 256); assertEq(1 ** 1 ** 4, 1); @@ -99,6 +101,18 @@ function assertTrue(v) { 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);