зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1437842: [Part 9] Convert IsRelativeTimeFormat to GuardToRelativeTimeFormat r=jandem
--HG-- extra : rebase_source : dd13a8ab7f667afcce804595e9dc932c70a253d6
This commit is contained in:
Родитель
c03138e2b9
Коммит
b7fe2f988a
|
@ -1447,8 +1447,8 @@ function initializeIntlObject(obj, type, lazyData) {
|
|||
assert((type === "Collator" && GuardToCollator(obj) !== null) ||
|
||||
(type === "DateTimeFormat" && GuardToDateTimeFormat(obj) !== null) ||
|
||||
(type === "NumberFormat" && GuardToNumberFormat(obj) !== null) ||
|
||||
(type === "RelativeTimeFormat" && IsRelativeTimeFormat(obj)),
|
||||
(type === "PluralRules" && GuardToPluralRules(obj) !== null) ||
|
||||
(type === "RelativeTimeFormat" && GuardToRelativeTimeFormat(obj) !== null),
|
||||
"type must match the object's class");
|
||||
assert(IsObject(lazyData), "non-object lazy data");
|
||||
|
||||
|
@ -1513,8 +1513,8 @@ function maybeInternalProperties(internals) {
|
|||
function getIntlObjectInternals(obj) {
|
||||
assert(IsObject(obj), "getIntlObjectInternals called with non-Object");
|
||||
assert(GuardToCollator(obj) !== null || GuardToDateTimeFormat(obj) !== null ||
|
||||
IsRelativeTimeFormat(obj),
|
||||
GuardToNumberFormat(obj) !== null || GuardToPluralRules(obj) !== null ||
|
||||
GuardToRelativeTimeFormat(obj) !== null,
|
||||
"getIntlObjectInternals called with non-Intl object");
|
||||
|
||||
var internals = UnsafeGetReservedSlot(obj, INTL_INTERNALS_OBJECT_SLOT);
|
||||
|
@ -1524,8 +1524,8 @@ function getIntlObjectInternals(obj) {
|
|||
assert((internals.type === "Collator" && GuardToCollator(obj) !== null) ||
|
||||
(internals.type === "DateTimeFormat" && GuardToDateTimeFormat(obj) !== null) ||
|
||||
(internals.type === "NumberFormat" && GuardToNumberFormat(obj) !== null) ||
|
||||
(internals.type === "RelativeTimeFormat" && IsRelativeTimeFormat(obj)),
|
||||
(internals.type === "PluralRules" && GuardToPluralRules(obj) !== null) ||
|
||||
(internals.type === "RelativeTimeFormat" && GuardToRelativeTimeFormat(obj) !== null),
|
||||
"type must match the object's class");
|
||||
assert(hasOwn("lazyData", internals), "missing lazyData");
|
||||
assert(hasOwn("internalProps", internals), "missing internalProps");
|
||||
|
|
|
@ -63,7 +63,7 @@ function resolveRelativeTimeFormatInternals(lazyRelativeTimeFormatData) {
|
|||
*/
|
||||
function getRelativeTimeFormatInternals(obj, methodName) {
|
||||
assert(IsObject(obj), "getRelativeTimeFormatInternals called with non-object");
|
||||
assert(IsRelativeTimeFormat(obj), "getRelativeTimeFormatInternals called with non-RelativeTimeFormat");
|
||||
assert(GuardToRelativeTimeFormat(obj) !== null, "getRelativeTimeFormatInternals called with non-RelativeTimeFormat");
|
||||
|
||||
var internals = getIntlObjectInternals(obj);
|
||||
assert(internals.type === "RelativeTimeFormat", "bad type escaped getIntlObjectInternals");
|
||||
|
@ -91,7 +91,7 @@ function getRelativeTimeFormatInternals(obj, methodName) {
|
|||
function InitializeRelativeTimeFormat(relativeTimeFormat, locales, options) {
|
||||
assert(IsObject(relativeTimeFormat),
|
||||
"InitializeRelativeimeFormat called with non-object");
|
||||
assert(IsRelativeTimeFormat(relativeTimeFormat),
|
||||
assert(GuardToRelativeTimeFormat(relativeTimeFormat) !== null,
|
||||
"InitializeRelativeTimeFormat called with non-RelativeTimeFormat");
|
||||
|
||||
// Lazy RelativeTimeFormat data has the following structure:
|
||||
|
@ -174,7 +174,7 @@ function Intl_RelativeTimeFormat_format(value, unit) {
|
|||
let relativeTimeFormat = this;
|
||||
|
||||
// Step 2.
|
||||
if (!IsObject(relativeTimeFormat) || !IsRelativeTimeFormat(relativeTimeFormat))
|
||||
if (!IsObject(relativeTimeFormat) || (relativeTimeFormat = GuardToRelativeTimeFormat(relativeTimeFormat)) === null)
|
||||
ThrowTypeError(JSMSG_INTL_OBJECT_NOT_INITED, "RelativeTimeFormat", "format", "RelativeTimeFormat");
|
||||
|
||||
// Ensure the RelativeTimeFormat internals are resolved.
|
||||
|
@ -210,13 +210,14 @@ function Intl_RelativeTimeFormat_format(value, unit) {
|
|||
* Spec: ECMAScript 402 API, RelativeTimeFormat, 1.4.4.
|
||||
*/
|
||||
function Intl_RelativeTimeFormat_resolvedOptions() {
|
||||
var relativeTimeFormat;
|
||||
// Check "this RelativeTimeFormat object" per introduction of section 1.4.
|
||||
if (!IsObject(this) || !IsRelativeTimeFormat(this)) {
|
||||
if (!IsObject(this) || (relativeTimeFormat = GuardToRelativeTimeFormat(this)) === null) {
|
||||
ThrowTypeError(JSMSG_INTL_OBJECT_NOT_INITED, "RelativeTimeFormat", "resolvedOptions",
|
||||
"RelativeTimeFormat");
|
||||
}
|
||||
|
||||
var internals = getRelativeTimeFormatInternals(this, "resolvedOptions");
|
||||
var internals = getRelativeTimeFormatInternals(relativeTimeFormat, "resolvedOptions");
|
||||
|
||||
var result = {
|
||||
locale: internals.locale,
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
_(IntlGuardToCollator) \
|
||||
_(IntlGuardToDateTimeFormat) \
|
||||
_(IntlGuardToNumberFormat) \
|
||||
_(IntlIsRelativeTimeFormat) \
|
||||
_(IntlGuardToPluralRules) \
|
||||
_(IntlGuardToRelativeTimeFormat) \
|
||||
\
|
||||
_(MathAbs) \
|
||||
_(MathFloor) \
|
||||
|
|
|
@ -125,10 +125,10 @@ IonBuilder::inlineNativeCall(CallInfo& callInfo, JSFunction* target)
|
|||
return inlineGuardToClass(callInfo, &DateTimeFormatObject::class_);
|
||||
case InlinableNative::IntlGuardToNumberFormat:
|
||||
return inlineGuardToClass(callInfo, &NumberFormatObject::class_);
|
||||
case InlinableNative::IntlIsRelativeTimeFormat:
|
||||
return inlineHasClass(callInfo, &RelativeTimeFormatObject::class_);
|
||||
case InlinableNative::IntlGuardToPluralRules:
|
||||
return inlineGuardToClass(callInfo, &PluralRulesObject::class_);
|
||||
case InlinableNative::IntlGuardToRelativeTimeFormat:
|
||||
return inlineGuardToClass(callInfo, &RelativeTimeFormatObject::class_);
|
||||
|
||||
// Math natives.
|
||||
case InlinableNative::MathAbs:
|
||||
|
|
|
@ -2572,12 +2572,12 @@ static const JSFunctionSpec intrinsic_functions[] = {
|
|||
JS_INLINABLE_FN("GuardToNumberFormat",
|
||||
intrinsic_GuardToBuiltin<NumberFormatObject>, 1,0,
|
||||
IntlGuardToNumberFormat),
|
||||
JS_INLINABLE_FN("IsRelativeTimeFormat",
|
||||
intrinsic_IsInstanceOfBuiltin<RelativeTimeFormatObject>, 1,0,
|
||||
IntlIsRelativeTimeFormat),
|
||||
JS_INLINABLE_FN("GuardToPluralRules",
|
||||
intrinsic_GuardToBuiltin<PluralRulesObject>, 1,0,
|
||||
IntlGuardToPluralRules),
|
||||
JS_INLINABLE_FN("GuardToRelativeTimeFormat",
|
||||
intrinsic_GuardToBuiltin<RelativeTimeFormatObject>, 1,0,
|
||||
IntlGuardToRelativeTimeFormat),
|
||||
JS_FN("GetDateTimeFormatConstructor",
|
||||
intrinsic_GetBuiltinIntlConstructor<GlobalObject::getOrCreateDateTimeFormatConstructor>,
|
||||
0,0),
|
||||
|
|
Загрузка…
Ссылка в новой задаче