builtins-boolean-gen.cc 1.26 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2017 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.

#include "src/builtins/builtins-utils-gen.h"
#include "src/builtins/builtins.h"
#include "src/code-stub-assembler.h"
8
#include "src/objects/oddball.h"
9 10 11 12 13 14 15

namespace v8 {
namespace internal {

// -----------------------------------------------------------------------------
// ES6 section 19.3 Boolean Objects

16
// ES6 #sec-boolean.prototype.tostring
17
TF_BUILTIN(BooleanPrototypeToString, CodeStubAssembler) {
18 19
  Node* context = Parameter(Descriptor::kContext);
  Node* receiver = Parameter(Descriptor::kReceiver);
20 21 22 23 24 25 26

  Node* value = ToThisValue(context, receiver, PrimitiveType::kBoolean,
                            "Boolean.prototype.toString");
  Node* result = LoadObjectField(value, Oddball::kToStringOffset);
  Return(result);
}

27
// ES6 #sec-boolean.prototype.valueof
28
TF_BUILTIN(BooleanPrototypeValueOf, CodeStubAssembler) {
29 30
  Node* context = Parameter(Descriptor::kContext);
  Node* receiver = Parameter(Descriptor::kReceiver);
31 32 33 34 35 36 37 38

  Node* result = ToThisValue(context, receiver, PrimitiveType::kBoolean,
                             "Boolean.prototype.valueOf");
  Return(result);
}

}  // namespace internal
}  // namespace v8