Small polishing changes to the native js.
R=jkummerow@chromium.org Review URL: https://codereview.chromium.org/1096763003 Cr-Commit-Position: refs/heads/master@{#27949}
This commit is contained in:
parent
abb23b5284
commit
42415bf9bc
16
src/i18n.js
16
src/i18n.js
@ -14,7 +14,9 @@
|
||||
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
var GlobalBoolean = global.Boolean;
|
||||
var GlobalDate = global.Date;
|
||||
var GlobalNumber = global.Number;
|
||||
var GlobalRegExp = global.RegExp;
|
||||
var GlobalString = global.String;
|
||||
|
||||
@ -374,13 +376,13 @@ function getGetOption(options, caller) {
|
||||
var value = options[property];
|
||||
switch (type) {
|
||||
case 'boolean':
|
||||
value = $Boolean(value);
|
||||
value = GlobalBoolean(value);
|
||||
break;
|
||||
case 'string':
|
||||
value = GlobalString(value);
|
||||
break;
|
||||
case 'number':
|
||||
value = $Number(value);
|
||||
value = GlobalNumber(value);
|
||||
break;
|
||||
default:
|
||||
throw new $Error('Internal error. Wrong value type.');
|
||||
@ -1056,7 +1058,7 @@ function isWellFormedCurrencyCode(currency) {
|
||||
function getNumberOption(options, property, min, max, fallback) {
|
||||
var value = options[property];
|
||||
if (value !== undefined) {
|
||||
value = $Number(value);
|
||||
value = GlobalNumber(value);
|
||||
if ($isNaN(value) || value < min || value > max) {
|
||||
throw new $RangeError(property + ' value is out of range.');
|
||||
}
|
||||
@ -1272,7 +1274,7 @@ function initializeNumberFormat(numberFormat, locales, options) {
|
||||
*/
|
||||
function formatNumber(formatter, value) {
|
||||
// Spec treats -0 and +0 as 0.
|
||||
var number = $Number(value) + 0;
|
||||
var number = GlobalNumber(value) + 0;
|
||||
|
||||
return %InternalNumberFormat(%GetImplFromInitializedIntlObject(formatter),
|
||||
number);
|
||||
@ -1668,7 +1670,7 @@ function formatDate(formatter, dateValue) {
|
||||
if (dateValue === undefined) {
|
||||
dateMs = GlobalDate.now();
|
||||
} else {
|
||||
dateMs = $Number(dateValue);
|
||||
dateMs = GlobalNumber(dateValue);
|
||||
}
|
||||
|
||||
if (!$isFinite(dateMs)) {
|
||||
@ -1980,12 +1982,12 @@ OverrideFunction(GlobalString.prototype, 'normalize', function(that) {
|
||||
* Formats a Number object (this) using locale and options values.
|
||||
* If locale or options are omitted, defaults are used.
|
||||
*/
|
||||
OverrideFunction($Number.prototype, 'toLocaleString', function() {
|
||||
OverrideFunction(GlobalNumber.prototype, 'toLocaleString', function() {
|
||||
if (%_IsConstructCall()) {
|
||||
throw new $TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
|
||||
}
|
||||
|
||||
if (!(this instanceof $Number) && typeof(this) !== 'number') {
|
||||
if (!(this instanceof GlobalNumber) && typeof(this) !== 'number') {
|
||||
throw new $TypeError('Method invoked on an object that is not Number.');
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ macro SET_PRIVATE(obj, sym, val) = (obj[sym] = val);
|
||||
macro DELETE_PRIVATE(obj, sym) = (delete obj[sym]);
|
||||
|
||||
# Constants. The compiler constant folds them.
|
||||
const NAN = $NaN;
|
||||
const NAN = (0/0);
|
||||
const INFINITY = (1/0);
|
||||
const UNDEFINED = (void 0);
|
||||
|
||||
|
@ -16,6 +16,7 @@ var $proxyEnumerate;
|
||||
|
||||
%CheckIsBootstrapping();
|
||||
|
||||
var GlobalFunction = global.Function;
|
||||
var GlobalObject = global.Object;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@ -48,7 +49,7 @@ function ProxyCreateFunction(handler, callTrap, constructTrap) {
|
||||
["createFunction", "construct"])
|
||||
}
|
||||
return %CreateJSFunctionProxy(
|
||||
handler, callTrap, constructTrap, $Function.prototype)
|
||||
handler, callTrap, constructTrap, GlobalFunction.prototype)
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@ -57,7 +58,7 @@ function ProxyCreateFunction(handler, callTrap, constructTrap) {
|
||||
function DerivedConstructTrap(callTrap) {
|
||||
return function() {
|
||||
var proto = this.prototype
|
||||
if (!IS_SPEC_OBJECT(proto)) proto = $Object.prototype
|
||||
if (!IS_SPEC_OBJECT(proto)) proto = GlobalObject.prototype
|
||||
var obj = { __proto__: proto };
|
||||
var result = %Apply(callTrap, obj, arguments, 0, %_ArgumentsLength());
|
||||
return IS_SPEC_OBJECT(result) ? result : obj
|
||||
|
@ -22,7 +22,6 @@ var $String = global.String;
|
||||
var $Number = global.Number;
|
||||
var $Function = global.Function;
|
||||
var $Boolean = global.Boolean;
|
||||
var $NaN = %GetRootNaN();
|
||||
|
||||
// ECMA-262 Section 11.9.3.
|
||||
function EQUALS(y) {
|
||||
|
@ -551,14 +551,6 @@ RUNTIME_FUNCTION(Runtime_SmiLexicographicCompare) {
|
||||
}
|
||||
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_GetRootNaN) {
|
||||
SealHandleScope shs(isolate);
|
||||
DCHECK(args.length() == 0);
|
||||
RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
|
||||
return isolate->heap()->nan_value();
|
||||
}
|
||||
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_MaxSmi) {
|
||||
SealHandleScope shs(isolate);
|
||||
DCHECK(args.length() == 0);
|
||||
|
@ -377,7 +377,6 @@ namespace internal {
|
||||
F(NumberEquals, 2, 1) \
|
||||
F(NumberCompare, 3, 1) \
|
||||
F(SmiLexicographicCompare, 2, 1) \
|
||||
F(GetRootNaN, 0, 1) \
|
||||
F(MaxSmi, 0, 1) \
|
||||
F(NumberToString, 1, 1) \
|
||||
F(IsSmi, 1, 1) \
|
||||
|
Loading…
Reference in New Issue
Block a user