[bigint] Implement BigInt.prototype.toLocaleString
It does the same as .toString, which is "permissible but not encouraged" per the spec and matches our behavior for Number.prototype.toString. Bug: v8:6791 Change-Id: I25a565391abe0d055b8ef814214ecdad254f75e2 Reviewed-on: https://chromium-review.googlesource.com/917025 Reviewed-by: Georg Neis <neis@chromium.org> Commit-Queue: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#51296}
This commit is contained in:
parent
1827b521fb
commit
bedff08691
@ -70,14 +70,6 @@ BUILTIN(BigIntAsIntN) {
|
||||
return *BigInt::AsIntN(bits->Number(), bigint);
|
||||
}
|
||||
|
||||
BUILTIN(BigIntPrototypeToLocaleString) {
|
||||
HandleScope scope(isolate);
|
||||
|
||||
// TODO(jkummerow): Implement.
|
||||
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
MaybeHandle<BigInt> ThisBigIntValue(Isolate* isolate, Handle<Object> value,
|
||||
@ -100,18 +92,14 @@ MaybeHandle<BigInt> ThisBigIntValue(Isolate* isolate, Handle<Object> value,
|
||||
BigInt);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
BUILTIN(BigIntPrototypeToString) {
|
||||
HandleScope scope(isolate);
|
||||
Object* BigIntToStringImpl(Handle<Object> receiver, Handle<Object> radix,
|
||||
Isolate* isolate, const char* builtin_name) {
|
||||
// 1. Let x be ? thisBigIntValue(this value).
|
||||
Handle<BigInt> x;
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, x,
|
||||
ThisBigIntValue(isolate, args.receiver(), "BigInt.prototype.toString"));
|
||||
isolate, x, ThisBigIntValue(isolate, receiver, builtin_name));
|
||||
// 2. If radix is not present, let radixNumber be 10.
|
||||
// 3. Else if radix is undefined, let radixNumber be 10.
|
||||
Handle<Object> radix = args.atOrUndefined(isolate, 1);
|
||||
int radix_number;
|
||||
if (radix->IsUndefined(isolate)) {
|
||||
radix_number = 10;
|
||||
@ -131,6 +119,22 @@ BUILTIN(BigIntPrototypeToString) {
|
||||
RETURN_RESULT_OR_FAILURE(isolate, BigInt::ToString(x, radix_number));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
BUILTIN(BigIntPrototypeToLocaleString) {
|
||||
HandleScope scope(isolate);
|
||||
Handle<Object> radix = args.atOrUndefined(isolate, 1);
|
||||
return BigIntToStringImpl(args.receiver(), radix, isolate,
|
||||
"BigInt.prototype.toLocaleString");
|
||||
}
|
||||
|
||||
BUILTIN(BigIntPrototypeToString) {
|
||||
HandleScope scope(isolate);
|
||||
Handle<Object> radix = args.atOrUndefined(isolate, 1);
|
||||
return BigIntToStringImpl(args.receiver(), radix, isolate,
|
||||
"BigInt.prototype.toString");
|
||||
}
|
||||
|
||||
BUILTIN(BigIntPrototypeValueOf) {
|
||||
HandleScope scope(isolate);
|
||||
RETURN_RESULT_OR_FAILURE(
|
||||
|
Loading…
Reference in New Issue
Block a user