Bug 1198453 - Make ES7 Exponentiation operator nightly only. (r=jorendorff)

This commit is contained in:
Eric Faust 2015-08-25 16:51:12 -07:00
Родитель 84431602a4
Коммит 4228187034
3 изменённых файлов: 24 добавлений и 3 удалений

Просмотреть файл

@ -1509,9 +1509,11 @@ TokenStream::getTokenInternal(TokenKind* ttp, Modifier modifier)
goto out; goto out;
case '*': case '*':
#ifdef JS_HAS_EXPONENTIATION
if (matchChar('*')) if (matchChar('*'))
tp->type = matchChar('=') ? TOK_POWASSIGN : TOK_POW; tp->type = matchChar('=') ? TOK_POWASSIGN : TOK_POW;
else else
#endif
tp->type = matchChar('=') ? TOK_MULASSIGN : TOK_MUL; tp->type = matchChar('=') ? TOK_MULASSIGN : TOK_MUL;
goto out; goto out;
@ -1823,7 +1825,7 @@ TokenStream::getStringOrTemplateToken(int untilChar, Token** tp)
} }
c = char16_t(val); c = char16_t(val);
} }
break; break;
} }
} else if (TokenBuf::isRawEOLChar(c)) { } else if (TokenBuf::isRawEOLChar(c)) {

Просмотреть файл

@ -41,9 +41,14 @@
*/ */
#define JS_OLD_GETTER_SETTER_METHODS 1 #define JS_OLD_GETTER_SETTER_METHODS 1
/* Support for ES6 Classes. */
#ifdef NIGHTLY_BUILD #ifdef NIGHTLY_BUILD
/* Support for ES6 Classes. */
#define JS_HAS_CLASSES 1 #define JS_HAS_CLASSES 1
#endif
/* Support for ES7 Exponentiation proposal. */
//#define JS_HAS_EXPONENTIATION 1
#endif // NIGHTLY_BUILD
#endif /* jsversion_h */ #endif /* jsversion_h */

Просмотреть файл

@ -9,6 +9,8 @@ var summary = "Implement the exponentiation operator";
print(BUGNUMBER + ": " + summary); print(BUGNUMBER + ": " + summary);
var test = `
// Constant folding // Constant folding
assertEq(2 ** 2 ** 3, 256); assertEq(2 ** 2 ** 3, 256);
assertEq(1 ** 1 ** 4, 1); assertEq(1 ** 1 ** 4, 1);
@ -99,6 +101,18 @@ function assertTrue(v) {
function assertFalse(v) { function assertFalse(v) {
assertEq(v, false); 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") if (typeof reportCompare === "function")
reportCompare(true, true); reportCompare(true, true);