45557b1f89
Bug: v8:7793 Change-Id: Id2a93f8ac8c512dbc5cdeb43a97e04d8d6684954 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2196130 Commit-Queue: Tobias Tebbi <tebbi@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#67748}
46 lines
1.5 KiB
Plaintext
46 lines
1.5 KiB
Plaintext
// Copyright 2019 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
namespace boolean {
|
|
transitioning macro ThisBooleanValue(implicit context: Context)(
|
|
receiver: JSAny, method: constexpr string): Boolean {
|
|
return UnsafeCast<Boolean>(
|
|
ToThisValue(receiver, PrimitiveType::kBoolean, method));
|
|
}
|
|
|
|
javascript builtin
|
|
BooleanConstructor(
|
|
js-implicit context: NativeContext, receiver: JSAny, newTarget: JSAny,
|
|
target: JSFunction)(...arguments): JSAny {
|
|
const value = SelectBooleanConstant(ToBoolean(arguments[0]));
|
|
|
|
if (newTarget == Undefined) {
|
|
return value;
|
|
}
|
|
|
|
const map = GetDerivedMap(target, UnsafeCast<JSReceiver>(newTarget));
|
|
|
|
const obj =
|
|
UnsafeCast<JSPrimitiveWrapper>(AllocateFastOrSlowJSObjectFromMap(map));
|
|
obj.value = value;
|
|
return obj;
|
|
}
|
|
|
|
// ES #sec-boolean.prototype.tostring
|
|
transitioning javascript builtin BooleanPrototypeToString(
|
|
js-implicit context: NativeContext, receiver: JSAny)(): JSAny {
|
|
// 1. Let b be ? thisBooleanValue(this value).
|
|
const b = ThisBooleanValue(receiver, 'Boolean.prototype.toString');
|
|
// 2. If b is true, return "true"; else return "false".
|
|
return b.to_string;
|
|
}
|
|
|
|
// ES #sec-boolean.prototype.valueof
|
|
transitioning javascript builtin BooleanPrototypeValueOf(
|
|
js-implicit context: NativeContext, receiver: JSAny)(): JSAny {
|
|
// 1. Return ? thisBooleanValue(this value).
|
|
return ThisBooleanValue(receiver, 'Boolean.prototype.valueOf');
|
|
}
|
|
}
|