зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1198453 - Make ES7 Exponentiation operator nightly only. (r=jorendorff)
This commit is contained in:
Родитель
84431602a4
Коммит
4228187034
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче