[cleanup] Unify variable names "method" & "method_name"

Bug: v8:12244
Change-Id: I9ec30012f7238f53448b80cf9d657571a37502a5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3180822
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77030}
This commit is contained in:
Marja Hölttä 2021-09-24 08:41:54 +02:00 committed by V8 LUCI CQ
parent ed10210a2e
commit bb5fa0391d
12 changed files with 144 additions and 129 deletions

View File

@ -125,21 +125,21 @@ Object BigIntToStringImpl(Handle<Object> receiver, Handle<Object> radix,
BUILTIN(BigIntPrototypeToLocaleString) {
HandleScope scope(isolate);
const char* method = "BigInt.prototype.toLocaleString";
const char* method_name = "BigInt.prototype.toLocaleString";
#ifdef V8_INTL_SUPPORT
// 1. Let x be ? thisBigIntValue(this value).
Handle<BigInt> x;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, x, ThisBigIntValue(isolate, args.receiver(), method));
isolate, x, ThisBigIntValue(isolate, args.receiver(), method_name));
RETURN_RESULT_OR_FAILURE(
isolate,
Intl::NumberToLocaleString(isolate, x, args.atOrUndefined(isolate, 1),
args.atOrUndefined(isolate, 2), method));
args.atOrUndefined(isolate, 2), method_name));
// Fallbacks to old toString implemention if no V8_INTL_SUPPORT
#endif // V8_INTL_SUPPORT
Handle<Object> radix = isolate->factory()->undefined_value();
return BigIntToStringImpl(args.receiver(), radix, isolate, method);
return BigIntToStringImpl(args.receiver(), radix, isolate, method_name);
}
BUILTIN(BigIntPrototypeToString) {

View File

@ -775,8 +775,8 @@ BUILTIN(DatePrototypeToLocaleDateString) {
isolate->CountUsage(v8::Isolate::UseCounterFeature::kDateToLocaleDateString);
const char* method = "Date.prototype.toLocaleDateString";
CHECK_RECEIVER(JSDate, date, method);
const char* method_name = "Date.prototype.toLocaleDateString";
CHECK_RECEIVER(JSDate, date, method_name);
RETURN_RESULT_OR_FAILURE(
isolate, JSDateTimeFormat::ToLocaleDateTime(
@ -786,7 +786,7 @@ BUILTIN(DatePrototypeToLocaleDateString) {
args.atOrUndefined(isolate, 2), // options
JSDateTimeFormat::RequiredOption::kDate, // required
JSDateTimeFormat::DefaultsOption::kDate, // defaults
method)); // method
method_name)); // method_name
}
// ecma402 #sup-date.prototype.tolocalestring
@ -795,8 +795,8 @@ BUILTIN(DatePrototypeToLocaleString) {
isolate->CountUsage(v8::Isolate::UseCounterFeature::kDateToLocaleString);
const char* method = "Date.prototype.toLocaleString";
CHECK_RECEIVER(JSDate, date, method);
const char* method_name = "Date.prototype.toLocaleString";
CHECK_RECEIVER(JSDate, date, method_name);
RETURN_RESULT_OR_FAILURE(
isolate, JSDateTimeFormat::ToLocaleDateTime(
@ -806,7 +806,7 @@ BUILTIN(DatePrototypeToLocaleString) {
args.atOrUndefined(isolate, 2), // options
JSDateTimeFormat::RequiredOption::kAny, // required
JSDateTimeFormat::DefaultsOption::kAll, // defaults
method)); // method
method_name)); // method_name
}
// ecma402 #sup-date.prototype.tolocaletimestring
@ -815,8 +815,8 @@ BUILTIN(DatePrototypeToLocaleTimeString) {
isolate->CountUsage(v8::Isolate::UseCounterFeature::kDateToLocaleTimeString);
const char* method = "Date.prototype.toLocaleTimeString";
CHECK_RECEIVER(JSDate, date, method);
const char* method_name = "Date.prototype.toLocaleTimeString";
CHECK_RECEIVER(JSDate, date, method_name);
RETURN_RESULT_OR_FAILURE(
isolate, JSDateTimeFormat::ToLocaleDateTime(
@ -826,7 +826,7 @@ BUILTIN(DatePrototypeToLocaleTimeString) {
args.atOrUndefined(isolate, 2), // options
JSDateTimeFormat::RequiredOption::kTime, // required
JSDateTimeFormat::DefaultsOption::kTime, // defaults
method)); // method
method_name)); // method_name
}
#endif // V8_INTL_SUPPORT

View File

@ -79,9 +79,9 @@ BUILTIN(NumberFormatSupportedLocalesOf) {
}
BUILTIN(NumberFormatPrototypeFormatToParts) {
const char* const method = "Intl.NumberFormat.prototype.formatToParts";
const char* const method_name = "Intl.NumberFormat.prototype.formatToParts";
HandleScope handle_scope(isolate);
CHECK_RECEIVER(JSNumberFormat, number_format, method);
CHECK_RECEIVER(JSNumberFormat, number_format, method_name);
Handle<Object> x;
if (args.length() >= 2) {
@ -96,9 +96,10 @@ BUILTIN(NumberFormatPrototypeFormatToParts) {
}
BUILTIN(DateTimeFormatPrototypeResolvedOptions) {
const char* const method = "Intl.DateTimeFormat.prototype.resolvedOptions";
const char* const method_name =
"Intl.DateTimeFormat.prototype.resolvedOptions";
HandleScope scope(isolate);
CHECK_RECEIVER(JSReceiver, format_holder, method);
CHECK_RECEIVER(JSReceiver, format_holder, method_name);
// 3. Let dtf be ? UnwrapDateTimeFormat(dtf).
Handle<JSDateTimeFormat> date_time_format;
@ -122,15 +123,15 @@ BUILTIN(DateTimeFormatSupportedLocalesOf) {
}
BUILTIN(DateTimeFormatPrototypeFormatToParts) {
const char* const method = "Intl.DateTimeFormat.prototype.formatToParts";
const char* const method_name = "Intl.DateTimeFormat.prototype.formatToParts";
HandleScope handle_scope(isolate);
CHECK_RECEIVER(JSObject, date_format_holder, method);
CHECK_RECEIVER(JSObject, date_format_holder, method_name);
Factory* factory = isolate->factory();
if (!date_format_holder->IsJSDateTimeFormat()) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver,
factory->NewStringFromAsciiChecked(method),
factory->NewStringFromAsciiChecked(method_name),
date_format_holder));
}
Handle<JSDateTimeFormat> dtf =
@ -157,12 +158,12 @@ BUILTIN(DateTimeFormatPrototypeFormatToParts) {
// Common code for DateTimeFormatPrototypeFormtRange(|ToParts)
template <class T>
V8_WARN_UNUSED_RESULT Object DateTimeFormatRange(
BuiltinArguments args, Isolate* isolate, const char* const method,
BuiltinArguments args, Isolate* isolate, const char* const method_name,
MaybeHandle<T> (*format)(Isolate*, Handle<JSDateTimeFormat>, double,
double)) {
// 1. Let dtf be this value.
// 2. If Type(dtf) is not Object, throw a TypeError exception.
CHECK_RECEIVER(JSObject, date_format_holder, method);
CHECK_RECEIVER(JSObject, date_format_holder, method_name);
Factory* factory = isolate->factory();
@ -171,7 +172,7 @@ V8_WARN_UNUSED_RESULT Object DateTimeFormatRange(
if (!date_format_holder->IsJSDateTimeFormat()) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver,
factory->NewStringFromAsciiChecked(method),
factory->NewStringFromAsciiChecked(method_name),
date_format_holder));
}
Handle<JSDateTimeFormat> dtf =
@ -207,16 +208,17 @@ V8_WARN_UNUSED_RESULT Object DateTimeFormatRange(
}
BUILTIN(DateTimeFormatPrototypeFormatRange) {
const char* const method = "Intl.DateTimeFormat.prototype.formatRange";
const char* const method_name = "Intl.DateTimeFormat.prototype.formatRange";
HandleScope handle_scope(isolate);
return DateTimeFormatRange<String>(args, isolate, method,
return DateTimeFormatRange<String>(args, isolate, method_name,
JSDateTimeFormat::FormatRange);
}
BUILTIN(DateTimeFormatPrototypeFormatRangeToParts) {
const char* const method = "Intl.DateTimeFormat.prototype.formatRangeToParts";
const char* const method_name =
"Intl.DateTimeFormat.prototype.formatRangeToParts";
HandleScope handle_scope(isolate);
return DateTimeFormatRange<JSArray>(args, isolate, method,
return DateTimeFormatRange<JSArray>(args, isolate, method_name,
JSDateTimeFormat::FormatRangeToParts);
}
@ -252,7 +254,8 @@ Handle<JSFunction> CreateBoundFunction(Isolate* isolate,
template <class T>
Object LegacyFormatConstructor(BuiltinArguments args, Isolate* isolate,
v8::Isolate::UseCounterFeature feature,
Handle<Object> constructor, const char* method) {
Handle<Object> constructor,
const char* method_name) {
isolate->CountUsage(feature);
Handle<JSReceiver> new_target;
// 1. If NewTarget is undefined, let newTarget be the active
@ -277,7 +280,7 @@ Object LegacyFormatConstructor(BuiltinArguments args, Isolate* isolate,
// 3. Perform ? Initialize<T>(Format, locales, options).
Handle<T> format;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, format, T::New(isolate, map, locales, options, method));
isolate, format, T::New(isolate, map, locales, options, method_name));
// 4. Let this be the this value.
if (args.new_target()->IsUndefined(isolate)) {
Handle<Object> receiver = args.receiver();
@ -291,10 +294,10 @@ Object LegacyFormatConstructor(BuiltinArguments args, Isolate* isolate,
if (ordinary_has_instance_obj->BooleanValue(isolate)) {
if (!receiver->IsJSReceiver()) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate,
NewTypeError(MessageTemplate::kIncompatibleMethodReceiver,
isolate->factory()->NewStringFromAsciiChecked(method),
receiver));
isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver,
isolate->factory()->NewStringFromAsciiChecked(
method_name),
receiver));
}
Handle<JSReceiver> rec = Handle<JSReceiver>::cast(receiver);
// a. Perform ? DefinePropertyOrThrow(this,
@ -325,15 +328,15 @@ Object LegacyFormatConstructor(BuiltinArguments args, Isolate* isolate,
template <class T>
Object DisallowCallConstructor(BuiltinArguments args, Isolate* isolate,
v8::Isolate::UseCounterFeature feature,
const char* method) {
const char* method_name) {
isolate->CountUsage(feature);
// 1. If NewTarget is undefined, throw a TypeError exception.
if (args.new_target()->IsUndefined(isolate)) { // [[Call]]
THROW_NEW_ERROR_RETURN_FAILURE(
isolate,
NewTypeError(MessageTemplate::kConstructorNotFunction,
isolate->factory()->NewStringFromAsciiChecked(method)));
isolate, NewTypeError(MessageTemplate::kConstructorNotFunction,
isolate->factory()->NewStringFromAsciiChecked(
method_name)));
}
// [[Construct]]
Handle<JSFunction> target = args.target();
@ -357,7 +360,7 @@ Object DisallowCallConstructor(BuiltinArguments args, Isolate* isolate,
*/
template <class T>
Object CallOrConstructConstructor(BuiltinArguments args, Isolate* isolate,
const char* method) {
const char* method_name) {
Handle<JSReceiver> new_target;
if (args.new_target()->IsUndefined(isolate)) {
@ -377,7 +380,7 @@ Object CallOrConstructConstructor(BuiltinArguments args, Isolate* isolate,
isolate, map, JSFunction::GetDerivedMap(isolate, target, new_target));
RETURN_RESULT_OR_FAILURE(isolate,
T::New(isolate, map, locales, options, method));
T::New(isolate, map, locales, options, method_name));
}
} // namespace
@ -431,11 +434,11 @@ BUILTIN(NumberFormatConstructor) {
BUILTIN(NumberFormatPrototypeResolvedOptions) {
HandleScope scope(isolate);
const char* const method = "Intl.NumberFormat.prototype.resolvedOptions";
const char* const method_name = "Intl.NumberFormat.prototype.resolvedOptions";
// 1. Let nf be the this value.
// 2. If Type(nf) is not Object, throw a TypeError exception.
CHECK_RECEIVER(JSReceiver, number_format_holder, method);
CHECK_RECEIVER(JSReceiver, number_format_holder, method_name);
// 3. Let nf be ? UnwrapNumberFormat(nf)
Handle<JSNumberFormat> number_format;
@ -447,12 +450,12 @@ BUILTIN(NumberFormatPrototypeResolvedOptions) {
}
BUILTIN(NumberFormatPrototypeFormatNumber) {
const char* const method = "get Intl.NumberFormat.prototype.format";
const char* const method_name = "get Intl.NumberFormat.prototype.format";
HandleScope scope(isolate);
// 1. Let nf be the this value.
// 2. If Type(nf) is not Object, throw a TypeError exception.
CHECK_RECEIVER(JSReceiver, receiver, method);
CHECK_RECEIVER(JSReceiver, receiver, method_name);
// 3. Let nf be ? UnwrapNumberFormat(nf).
Handle<JSNumberFormat> number_format;
@ -519,12 +522,12 @@ BUILTIN(DateTimeFormatConstructor) {
}
BUILTIN(DateTimeFormatPrototypeFormat) {
const char* const method = "get Intl.DateTimeFormat.prototype.format";
const char* const method_name = "get Intl.DateTimeFormat.prototype.format";
HandleScope scope(isolate);
// 1. Let dtf be this value.
// 2. If Type(dtf) is not Object, throw a TypeError exception.
CHECK_RECEIVER(JSReceiver, receiver, method);
CHECK_RECEIVER(JSReceiver, receiver, method_name);
// 3. Let dtf be ? UnwrapDateTimeFormat(dtf).
Handle<JSDateTimeFormat> format;
@ -616,12 +619,12 @@ BUILTIN(LocaleConstructor) {
isolate->CountUsage(v8::Isolate::UseCounterFeature::kLocale);
const char* method = "Intl.Locale";
const char* method_name = "Intl.Locale";
if (args.new_target()->IsUndefined(isolate)) { // [[Call]]
THROW_NEW_ERROR_RETURN_FAILURE(
isolate,
NewTypeError(MessageTemplate::kConstructorNotFunction,
isolate->factory()->NewStringFromAsciiChecked(method)));
isolate, NewTypeError(MessageTemplate::kConstructorNotFunction,
isolate->factory()->NewStringFromAsciiChecked(
method_name)));
}
// [[Construct]]
Handle<JSFunction> target = args.target();
@ -657,7 +660,8 @@ BUILTIN(LocaleConstructor) {
// 10. Set options to ? CoerceOptionsToObject(options).
Handle<JSReceiver> options_object;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, options_object, CoerceOptionsToObject(isolate, options, method));
isolate, options_object,
CoerceOptionsToObject(isolate, options, method_name));
RETURN_RESULT_OR_FAILURE(
isolate, JSLocale::New(isolate, map, locale_string, options_object));
@ -953,14 +957,14 @@ BUILTIN(CollatorSupportedLocalesOf) {
}
BUILTIN(CollatorPrototypeCompare) {
const char* const method = "get Intl.Collator.prototype.compare";
const char* const method_name = "get Intl.Collator.prototype.compare";
HandleScope scope(isolate);
// 1. Let collator be this value.
// 2. If Type(collator) is not Object, throw a TypeError exception.
// 3. If collator does not have an [[InitializedCollator]] internal slot,
// throw a TypeError exception.
CHECK_RECEIVER(JSCollator, collator, method);
CHECK_RECEIVER(JSCollator, collator, method_name);
// 4. If collator.[[BoundCompare]] is undefined, then
Handle<Object> bound_compare(collator->bound_compare(), isolate);
@ -1015,9 +1019,9 @@ BUILTIN(CollatorInternalCompare) {
// ecma402 #sec-%segmentiteratorprototype%.next
BUILTIN(SegmentIteratorPrototypeNext) {
const char* const method = "%SegmentIterator.prototype%.next";
const char* const method_name = "%SegmentIterator.prototype%.next";
HandleScope scope(isolate);
CHECK_RECEIVER(JSSegmentIterator, segment_iterator, method);
CHECK_RECEIVER(JSSegmentIterator, segment_iterator, method_name);
RETURN_RESULT_OR_FAILURE(isolate,
JSSegmentIterator::Next(isolate, segment_iterator));
@ -1069,9 +1073,9 @@ BUILTIN(SegmenterPrototypeSegment) {
// ecma402 #sec-%segmentsprototype%.containing
BUILTIN(SegmentsPrototypeContaining) {
const char* const method = "%Segments.prototype%.containing";
const char* const method_name = "%Segments.prototype%.containing";
HandleScope scope(isolate);
CHECK_RECEIVER(JSSegments, segments, method);
CHECK_RECEIVER(JSSegments, segments, method_name);
Handle<Object> index = args.atOrUndefined(isolate, 1);
// 6. Let n be ? ToInteger(index).
@ -1085,9 +1089,9 @@ BUILTIN(SegmentsPrototypeContaining) {
// ecma402 #sec-%segmentsprototype%-@@iterator
BUILTIN(SegmentsPrototypeIterator) {
const char* const method = "%SegmentIsPrototype%[@@iterator]";
const char* const method_name = "%SegmentIsPrototype%[@@iterator]";
HandleScope scope(isolate);
CHECK_RECEIVER(JSSegments, segments, method);
CHECK_RECEIVER(JSSegments, segments, method_name);
RETURN_RESULT_OR_FAILURE(
isolate,
JSSegmentIterator::Create(isolate, segments->icu_break_iterator().raw(),
@ -1109,10 +1113,11 @@ BUILTIN(V8BreakIteratorPrototypeResolvedOptions) {
}
BUILTIN(V8BreakIteratorPrototypeAdoptText) {
const char* const method = "get Intl.v8BreakIterator.prototype.adoptText";
const char* const method_name =
"get Intl.v8BreakIterator.prototype.adoptText";
HandleScope scope(isolate);
CHECK_RECEIVER(JSV8BreakIterator, break_iterator, method);
CHECK_RECEIVER(JSV8BreakIterator, break_iterator, method_name);
Handle<Object> bound_adopt_text(break_iterator->bound_adopt_text(), isolate);
if (!bound_adopt_text->IsUndefined(isolate)) {
@ -1145,10 +1150,10 @@ BUILTIN(V8BreakIteratorInternalAdoptText) {
}
BUILTIN(V8BreakIteratorPrototypeFirst) {
const char* const method = "get Intl.v8BreakIterator.prototype.first";
const char* const method_name = "get Intl.v8BreakIterator.prototype.first";
HandleScope scope(isolate);
CHECK_RECEIVER(JSV8BreakIterator, break_iterator, method);
CHECK_RECEIVER(JSV8BreakIterator, break_iterator, method_name);
Handle<Object> bound_first(break_iterator->bound_first(), isolate);
if (!bound_first->IsUndefined(isolate)) {
@ -1175,10 +1180,10 @@ BUILTIN(V8BreakIteratorInternalFirst) {
}
BUILTIN(V8BreakIteratorPrototypeNext) {
const char* const method = "get Intl.v8BreakIterator.prototype.next";
const char* const method_name = "get Intl.v8BreakIterator.prototype.next";
HandleScope scope(isolate);
CHECK_RECEIVER(JSV8BreakIterator, break_iterator, method);
CHECK_RECEIVER(JSV8BreakIterator, break_iterator, method_name);
Handle<Object> bound_next(break_iterator->bound_next(), isolate);
if (!bound_next->IsUndefined(isolate)) {
@ -1204,10 +1209,10 @@ BUILTIN(V8BreakIteratorInternalNext) {
}
BUILTIN(V8BreakIteratorPrototypeCurrent) {
const char* const method = "get Intl.v8BreakIterator.prototype.current";
const char* const method_name = "get Intl.v8BreakIterator.prototype.current";
HandleScope scope(isolate);
CHECK_RECEIVER(JSV8BreakIterator, break_iterator, method);
CHECK_RECEIVER(JSV8BreakIterator, break_iterator, method_name);
Handle<Object> bound_current(break_iterator->bound_current(), isolate);
if (!bound_current->IsUndefined(isolate)) {
@ -1233,10 +1238,11 @@ BUILTIN(V8BreakIteratorInternalCurrent) {
}
BUILTIN(V8BreakIteratorPrototypeBreakType) {
const char* const method = "get Intl.v8BreakIterator.prototype.breakType";
const char* const method_name =
"get Intl.v8BreakIterator.prototype.breakType";
HandleScope scope(isolate);
CHECK_RECEIVER(JSV8BreakIterator, break_iterator, method);
CHECK_RECEIVER(JSV8BreakIterator, break_iterator, method_name);
Handle<Object> bound_break_type(break_iterator->bound_break_type(), isolate);
if (!bound_break_type->IsUndefined(isolate)) {

View File

@ -111,7 +111,7 @@ BUILTIN(NumberPrototypeToFixed) {
// ES6 section 20.1.3.4 Number.prototype.toLocaleString ( [ r1 [ , r2 ] ] )
BUILTIN(NumberPrototypeToLocaleString) {
HandleScope scope(isolate);
const char* method = "Number.prototype.toLocaleString";
const char* method_name = "Number.prototype.toLocaleString";
isolate->CountUsage(v8::Isolate::UseCounterFeature::kNumberToLocaleString);
@ -126,7 +126,7 @@ BUILTIN(NumberPrototypeToLocaleString) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate,
NewTypeError(MessageTemplate::kNotGeneric,
isolate->factory()->NewStringFromAsciiChecked(method),
isolate->factory()->NewStringFromAsciiChecked(method_name),
isolate->factory()->Number_string()));
}
@ -134,7 +134,7 @@ BUILTIN(NumberPrototypeToLocaleString) {
RETURN_RESULT_OR_FAILURE(
isolate,
Intl::NumberToLocaleString(isolate, value, args.atOrUndefined(isolate, 1),
args.atOrUndefined(isolate, 2), method));
args.atOrUndefined(isolate, 2), method_name));
#else
// Turn the {value} into a String.
return *isolate->factory()->NumberToString(value);

View File

@ -47,9 +47,10 @@ BUILTIN(TypedArrayPrototypeCopyWithin) {
HandleScope scope(isolate);
Handle<JSTypedArray> array;
const char* method = "%TypedArray%.prototype.copyWithin";
const char* method_name = "%TypedArray%.prototype.copyWithin";
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, array, JSTypedArray::Validate(isolate, args.receiver(), method));
isolate, array,
JSTypedArray::Validate(isolate, args.receiver(), method_name));
int64_t len = array->GetLength();
int64_t to = 0;
@ -92,7 +93,7 @@ BUILTIN(TypedArrayPrototypeCopyWithin) {
if (out_of_bounds) {
const MessageTemplate message = MessageTemplate::kDetachedOperation;
Handle<String> operation =
isolate->factory()->NewStringFromAsciiChecked(method);
isolate->factory()->NewStringFromAsciiChecked(method_name);
THROW_NEW_ERROR_RETURN_FAILURE(isolate, NewTypeError(message, operation));
}
if (new_len < len) {
@ -137,9 +138,10 @@ BUILTIN(TypedArrayPrototypeFill) {
HandleScope scope(isolate);
Handle<JSTypedArray> array;
const char* method = "%TypedArray%.prototype.fill";
const char* method_name = "%TypedArray%.prototype.fill";
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, array, JSTypedArray::Validate(isolate, args.receiver(), method));
isolate, array,
JSTypedArray::Validate(isolate, args.receiver(), method_name));
ElementsKind kind = array->GetElementsKind();
Handle<Object> obj_value = args.atOrUndefined(isolate, 1);
@ -181,7 +183,7 @@ BUILTIN(TypedArrayPrototypeFill) {
if (out_of_bounds) {
const MessageTemplate message = MessageTemplate::kDetachedOperation;
Handle<String> operation =
isolate->factory()->NewStringFromAsciiChecked(method);
isolate->factory()->NewStringFromAsciiChecked(method_name);
THROW_NEW_ERROR_RETURN_FAILURE(isolate, NewTypeError(message, operation));
}
}
@ -204,9 +206,10 @@ BUILTIN(TypedArrayPrototypeIncludes) {
HandleScope scope(isolate);
Handle<JSTypedArray> array;
const char* method = "%TypedArray%.prototype.includes";
const char* method_name = "%TypedArray%.prototype.includes";
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, array, JSTypedArray::Validate(isolate, args.receiver(), method));
isolate, array,
JSTypedArray::Validate(isolate, args.receiver(), method_name));
if (args.length() < 2) return ReadOnlyRoots(isolate).false_value();
@ -237,9 +240,10 @@ BUILTIN(TypedArrayPrototypeIndexOf) {
HandleScope scope(isolate);
Handle<JSTypedArray> array;
const char* method = "%TypedArray%.prototype.indexOf";
const char* method_name = "%TypedArray%.prototype.indexOf";
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, array, JSTypedArray::Validate(isolate, args.receiver(), method));
isolate, array,
JSTypedArray::Validate(isolate, args.receiver(), method_name));
int64_t len = array->length();
if (len == 0) return Smi::FromInt(-1);
@ -267,9 +271,10 @@ BUILTIN(TypedArrayPrototypeLastIndexOf) {
HandleScope scope(isolate);
Handle<JSTypedArray> array;
const char* method = "%TypedArray%.prototype.lastIndexOf";
const char* method_name = "%TypedArray%.prototype.lastIndexOf";
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, array, JSTypedArray::Validate(isolate, args.receiver(), method));
isolate, array,
JSTypedArray::Validate(isolate, args.receiver(), method_name));
int64_t len = array->length();
if (len == 0) return Smi::FromInt(-1);
@ -301,9 +306,10 @@ BUILTIN(TypedArrayPrototypeReverse) {
HandleScope scope(isolate);
Handle<JSTypedArray> array;
const char* method = "%TypedArray%.prototype.reverse";
const char* method_name = "%TypedArray%.prototype.reverse";
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, array, JSTypedArray::Validate(isolate, args.receiver(), method));
isolate, array,
JSTypedArray::Validate(isolate, args.receiver(), method_name));
ElementsAccessor* elements = array->GetElementsAccessor();
elements->Reverse(*array);

View File

@ -183,12 +183,12 @@ const UChar* GetUCharBufferFromFlat(const String::FlatContent& flat,
template <typename T>
MaybeHandle<T> New(Isolate* isolate, Handle<JSFunction> constructor,
Handle<Object> locales, Handle<Object> options,
const char* method) {
const char* method_name) {
Handle<Map> map;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, map,
JSFunction::GetDerivedMap(isolate, constructor, constructor), T);
return T::New(isolate, map, locales, options, method);
return T::New(isolate, map, locales, options, method_name);
}
} // namespace
@ -927,7 +927,7 @@ MaybeHandle<String> Intl::StringLocaleConvertCase(Isolate* isolate,
base::Optional<int> Intl::StringLocaleCompare(
Isolate* isolate, Handle<String> string1, Handle<String> string2,
Handle<Object> locales, Handle<Object> options, const char* method) {
Handle<Object> locales, Handle<Object> options, const char* method_name) {
// We only cache the instance when locales is a string/undefined and
// options is undefined, as that is the only case when the specified
// side-effects of examining those arguments are unobservable.
@ -952,7 +952,7 @@ base::Optional<int> Intl::StringLocaleCompare(
Handle<JSCollator> collator;
MaybeHandle<JSCollator> maybe_collator =
New<JSCollator>(isolate, constructor, locales, options, method);
New<JSCollator>(isolate, constructor, locales, options, method_name);
if (!maybe_collator.ToHandle(&collator)) return {};
if (can_cache) {
isolate->set_icu_object_in_cache(
@ -1005,7 +1005,7 @@ MaybeHandle<String> Intl::NumberToLocaleString(Isolate* isolate,
Handle<Object> num,
Handle<Object> locales,
Handle<Object> options,
const char* method) {
const char* method_name) {
Handle<Object> numeric_obj;
ASSIGN_RETURN_ON_EXCEPTION(isolate, numeric_obj,
Object::ToNumeric(isolate, num), String);
@ -1035,7 +1035,7 @@ MaybeHandle<String> Intl::NumberToLocaleString(Isolate* isolate,
// 2. Let numberFormat be ? Construct(%NumberFormat%, « locales, options »).
ASSIGN_RETURN_ON_EXCEPTION(
isolate, number_format,
New<JSNumberFormat>(isolate, constructor, locales, options, method),
New<JSNumberFormat>(isolate, constructor, locales, options, method_name),
String);
if (can_cache) {
@ -1482,21 +1482,21 @@ MaybeHandle<JSArray> CreateArrayFromList(Isolate* isolate,
// ECMA 402 9.2.9 SupportedLocales(availableLocales, requestedLocales, options)
// https://tc39.github.io/ecma402/#sec-supportedlocales
MaybeHandle<JSObject> SupportedLocales(
Isolate* isolate, const char* method,
Isolate* isolate, const char* method_name,
const std::set<std::string>& available_locales,
const std::vector<std::string>& requested_locales, Handle<Object> options) {
std::vector<std::string> supported_locales;
// 1. Set options to ? CoerceOptionsToObject(options).
Handle<JSReceiver> options_obj;
ASSIGN_RETURN_ON_EXCEPTION(isolate, options_obj,
CoerceOptionsToObject(isolate, options, method),
JSObject);
ASSIGN_RETURN_ON_EXCEPTION(
isolate, options_obj,
CoerceOptionsToObject(isolate, options, method_name), JSObject);
// 2. Let matcher be ? GetOption(options, "localeMatcher", "string",
// « "lookup", "best fit" », "best fit").
Maybe<Intl::MatcherOption> maybe_locale_matcher =
Intl::GetLocaleMatcher(isolate, options_obj, method);
Intl::GetLocaleMatcher(isolate, options_obj, method_name);
MAYBE_RETURN(maybe_locale_matcher, MaybeHandle<JSObject>());
Intl::MatcherOption matcher = maybe_locale_matcher.FromJust();
@ -1676,7 +1676,7 @@ MaybeHandle<JSArray> Intl::SupportedValuesOf(Isolate* isolate,
// ECMA 402 Intl.*.supportedLocalesOf
MaybeHandle<JSObject> Intl::SupportedLocalesOf(
Isolate* isolate, const char* method,
Isolate* isolate, const char* method_name,
const std::set<std::string>& available_locales, Handle<Object> locales,
Handle<Object> options) {
// Let availableLocales be %Collator%.[[AvailableLocales]].
@ -1687,7 +1687,7 @@ MaybeHandle<JSObject> Intl::SupportedLocalesOf(
MAYBE_RETURN(requested_locales, MaybeHandle<JSObject>());
// Return ? SupportedLocales(availableLocales, requestedLocales, options).
return SupportedLocales(isolate, method, available_locales,
return SupportedLocales(isolate, method_name, available_locales,
requested_locales.FromJust(), options);
}
@ -2098,20 +2098,20 @@ base::TimezoneCache* Intl::CreateTimeZoneCache() {
Maybe<Intl::MatcherOption> Intl::GetLocaleMatcher(Isolate* isolate,
Handle<JSReceiver> options,
const char* method) {
const char* method_name) {
return GetStringOption<Intl::MatcherOption>(
isolate, options, "localeMatcher", method, {"best fit", "lookup"},
isolate, options, "localeMatcher", method_name, {"best fit", "lookup"},
{Intl::MatcherOption::kBestFit, Intl::MatcherOption::kLookup},
Intl::MatcherOption::kBestFit);
}
Maybe<bool> Intl::GetNumberingSystem(Isolate* isolate,
Handle<JSReceiver> options,
const char* method,
const char* method_name,
std::unique_ptr<char[]>* result) {
const std::vector<const char*> empty_values = {};
Maybe<bool> maybe = GetStringOption(isolate, options, "numberingSystem",
empty_values, method, result);
empty_values, method_name, result);
MAYBE_RETURN(maybe, Nothing<bool>());
if (maybe.FromJust() && *result != nullptr) {
if (!IsWellFormedNumberingSystem(result->get())) {

View File

@ -62,7 +62,7 @@ class Intl {
static std::string GetNumberingSystem(const icu::Locale& icu_locale);
static V8_WARN_UNUSED_RESULT MaybeHandle<JSObject> SupportedLocalesOf(
Isolate* isolate, const char* method,
Isolate* isolate, const char* method_name,
const std::set<std::string>& available_locales, Handle<Object> locales_in,
Handle<Object> options_in);
@ -94,7 +94,7 @@ class Intl {
V8_WARN_UNUSED_RESULT static base::Optional<int> StringLocaleCompare(
Isolate* isolate, Handle<String> s1, Handle<String> s2,
Handle<Object> locales, Handle<Object> options, const char* method);
Handle<Object> locales, Handle<Object> options, const char* method_name);
V8_WARN_UNUSED_RESULT static int CompareStrings(Isolate* isolate,
const icu::Collator& collator,
@ -104,7 +104,7 @@ class Intl {
// ecma402/#sup-properties-of-the-number-prototype-object
V8_WARN_UNUSED_RESULT static MaybeHandle<String> NumberToLocaleString(
Isolate* isolate, Handle<Object> num, Handle<Object> locales,
Handle<Object> options, const char* method);
Handle<Object> options, const char* method_name);
// ecma402/#sec-setnfdigitoptions
struct NumberFormatDigitOptions {
@ -172,11 +172,11 @@ class Intl {
// Shared function to read the "localeMatcher" option.
V8_WARN_UNUSED_RESULT static Maybe<MatcherOption> GetLocaleMatcher(
Isolate* isolate, Handle<JSReceiver> options, const char* method);
Isolate* isolate, Handle<JSReceiver> options, const char* method_name);
// Shared function to read the "numberingSystem" option.
V8_WARN_UNUSED_RESULT static Maybe<bool> GetNumberingSystem(
Isolate* isolate, Handle<JSReceiver> options, const char* method,
Isolate* isolate, Handle<JSReceiver> options, const char* method_name,
std::unique_ptr<char[]>* result);
// Check the calendar is valid or not for that locale.

View File

@ -44,9 +44,9 @@ enum class Sensitivity {
enum class CaseFirst { kUndefined, kUpper, kLower, kFalse };
Maybe<CaseFirst> GetCaseFirst(Isolate* isolate, Handle<JSReceiver> options,
const char* method) {
const char* method_name) {
return GetStringOption<CaseFirst>(
isolate, options, "caseFirst", method, {"upper", "lower", "false"},
isolate, options, "caseFirst", method_name, {"upper", "lower", "false"},
{CaseFirst::kUpper, CaseFirst::kLower, CaseFirst::kFalse},
CaseFirst::kUndefined);
}

View File

@ -77,9 +77,9 @@ JSDateTimeFormat::HourCycle ToHourCycle(UDateFormatHourCycle hc) {
Maybe<JSDateTimeFormat::HourCycle> GetHourCycle(Isolate* isolate,
Handle<JSReceiver> options,
const char* method) {
const char* method_name) {
return GetStringOption<JSDateTimeFormat::HourCycle>(
isolate, options, "hourCycle", method, {"h11", "h12", "h23", "h24"},
isolate, options, "hourCycle", method_name, {"h11", "h12", "h23", "h24"},
{JSDateTimeFormat::HourCycle::kH11, JSDateTimeFormat::HourCycle::kH12,
JSDateTimeFormat::HourCycle::kH23, JSDateTimeFormat::HourCycle::kH24},
JSDateTimeFormat::HourCycle::kUndefined);
@ -772,7 +772,7 @@ Isolate::ICUObjectCacheType ConvertToCacheType(
MaybeHandle<String> JSDateTimeFormat::ToLocaleDateTime(
Isolate* isolate, Handle<Object> date, Handle<Object> locales,
Handle<Object> options, RequiredOption required, DefaultsOption defaults,
const char* method) {
const char* method_name) {
Isolate::ICUObjectCacheType cache_type = ConvertToCacheType(defaults);
Factory* factory = isolate->factory();
@ -822,7 +822,8 @@ MaybeHandle<String> JSDateTimeFormat::ToLocaleDateTime(
Handle<JSDateTimeFormat> date_time_format;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, date_time_format,
JSDateTimeFormat::New(isolate, map, locales, internal_options, method),
JSDateTimeFormat::New(isolate, map, locales, internal_options,
method_name),
String);
if (can_cache) {

View File

@ -82,7 +82,7 @@ class JSDateTimeFormat
V8_WARN_UNUSED_RESULT static MaybeHandle<String> ToLocaleDateTime(
Isolate* isolate, Handle<Object> date, Handle<Object> locales,
Handle<Object> options, RequiredOption required, DefaultsOption defaults,
const char* method);
const char* method_name);
V8_EXPORT_PRIVATE static const std::set<std::string>& GetAvailableLocales();

View File

@ -13,7 +13,7 @@ namespace internal {
// ecma402/#sec-getoptionsobject
MaybeHandle<JSReceiver> GetOptionsObject(Isolate* isolate,
Handle<Object> options,
const char* method) {
const char* method_name) {
// 1. If options is undefined, then
if (options->IsUndefined(isolate)) {
// a. Return ! ObjectCreate(null).
@ -32,21 +32,23 @@ MaybeHandle<JSReceiver> GetOptionsObject(Isolate* isolate,
// ecma402/#sec-coerceoptionstoobject
MaybeHandle<JSReceiver> CoerceOptionsToObject(Isolate* isolate,
Handle<Object> options,
const char* method) {
const char* method_name) {
// 1. If options is undefined, then
if (options->IsUndefined(isolate)) {
// a. Return ! ObjectCreate(null).
return isolate->factory()->NewJSObjectWithNullProto();
}
// 2. Return ? ToObject(options).
ASSIGN_RETURN_ON_EXCEPTION(
isolate, options, Object::ToObject(isolate, options, method), JSReceiver);
ASSIGN_RETURN_ON_EXCEPTION(isolate, options,
Object::ToObject(isolate, options, method_name),
JSReceiver);
return Handle<JSReceiver>::cast(options);
}
Maybe<bool> GetStringOption(Isolate* isolate, Handle<JSReceiver> options,
const char* property,
std::vector<const char*> values, const char* method,
std::vector<const char*> values,
const char* method_name,
std::unique_ptr<char[]>* result) {
Handle<String> property_str =
isolate->factory()->NewStringFromAsciiChecked(property);
@ -81,7 +83,7 @@ Maybe<bool> GetStringOption(Isolate* isolate, Handle<JSReceiver> options,
}
Handle<String> method_str =
isolate->factory()->NewStringFromAsciiChecked(method);
isolate->factory()->NewStringFromAsciiChecked(method_name);
THROW_NEW_ERROR_RETURN_VALUE(
isolate,
NewRangeError(MessageTemplate::kValueOutOfRange, value, method_str,
@ -97,7 +99,7 @@ Maybe<bool> GetStringOption(Isolate* isolate, Handle<JSReceiver> options,
V8_WARN_UNUSED_RESULT Maybe<bool> GetBoolOption(Isolate* isolate,
Handle<JSReceiver> options,
const char* property,
const char* method,
const char* method_name,
bool* result) {
Handle<String> property_str =
isolate->factory()->NewStringFromAsciiChecked(property);

View File

@ -13,11 +13,11 @@ namespace internal {
// ecma402/#sec-getoptionsobject and temporal/#sec-getoptionsobject
V8_WARN_UNUSED_RESULT MaybeHandle<JSReceiver> GetOptionsObject(
Isolate* isolate, Handle<Object> options, const char* method);
Isolate* isolate, Handle<Object> options, const char* method_name);
// ecma402/#sec-coerceoptionstoobject
V8_WARN_UNUSED_RESULT MaybeHandle<JSReceiver> CoerceOptionsToObject(
Isolate* isolate, Handle<Object> options, const char* method);
Isolate* isolate, Handle<Object> options, const char* method_name);
// ECMA402 9.2.10. GetOption( options, property, type, values, fallback)
// ecma402/#sec-getoption and temporal/#sec-getoption
@ -32,11 +32,11 @@ V8_WARN_UNUSED_RESULT MaybeHandle<JSReceiver> CoerceOptionsToObject(
// caller is required to use fallback value appropriately in this
// case.
//
// method is a string denoting the method the call from; used when
// method_name is a string denoting the method the call from; used when
// printing the error message.
V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT Maybe<bool> GetStringOption(
Isolate* isolate, Handle<JSReceiver> options, const char* property,
std::vector<const char*> values, const char* method,
std::vector<const char*> values, const char* method_name,
std::unique_ptr<char[]>* result);
// A helper template to get string from option into a enum.
@ -46,12 +46,12 @@ V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT Maybe<bool> GetStringOption(
template <typename T>
V8_WARN_UNUSED_RESULT static Maybe<T> GetStringOption(
Isolate* isolate, Handle<JSReceiver> options, const char* name,
const char* method, const std::vector<const char*>& str_values,
const char* method_name, const std::vector<const char*>& str_values,
const std::vector<T>& enum_values, T default_value) {
DCHECK_EQ(str_values.size(), enum_values.size());
std::unique_ptr<char[]> cstr;
Maybe<bool> found =
GetStringOption(isolate, options, name, str_values, method, &cstr);
GetStringOption(isolate, options, name, str_values, method_name, &cstr);
MAYBE_RETURN(found, Nothing<T>());
if (found.FromJust()) {
DCHECK_NOT_NULL(cstr.get());
@ -75,11 +75,11 @@ V8_WARN_UNUSED_RESULT static Maybe<T> GetStringOption(
// caller is required to use fallback value appropriately in this
// case.
//
// method is a string denoting the method it called from; used when
// method_name is a string denoting the method it called from; used when
// printing the error message.
V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT Maybe<bool> GetBoolOption(
Isolate* isolate, Handle<JSReceiver> options, const char* property,
const char* method, bool* result);
const char* method_name, bool* result);
V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT Maybe<int> GetNumberOption(
Isolate* isolate, Handle<JSReceiver> options, Handle<String> property,