Welcome to mirror list, hosted at ThFree Co, Russian Federation.

boolean.tq « builtins « src « v8 « deps - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 40a011d4e09e5973d82d2013d9e983035432cb9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// 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');
}
}