Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Side by Side Diff: src/builtins/builtins-boolean.cc

Issue 2165593002: [builtins] Move builtins into own files (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove builtins-error.cc from BUILD.gn Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/builtins/builtins-arraybuffer.cc ('k') | src/builtins/builtins-dataview.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/builtins/builtins.h"
6 #include "src/builtins/builtins-utils.h"
7
8 namespace v8 {
9 namespace internal {
10
11 // -----------------------------------------------------------------------------
12 // ES6 section 19.3 Boolean Objects
13
14 // ES6 section 19.3.1.1 Boolean ( value ) for the [[Call]] case.
15 BUILTIN(BooleanConstructor) {
16 HandleScope scope(isolate);
17 Handle<Object> value = args.atOrUndefined(isolate, 1);
18 return isolate->heap()->ToBoolean(value->BooleanValue());
19 }
20
21 // ES6 section 19.3.1.1 Boolean ( value ) for the [[Construct]] case.
22 BUILTIN(BooleanConstructor_ConstructStub) {
23 HandleScope scope(isolate);
24 Handle<Object> value = args.atOrUndefined(isolate, 1);
25 Handle<JSFunction> target = args.target<JSFunction>();
26 Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target());
27 DCHECK(*target == target->native_context()->boolean_function());
28 Handle<JSObject> result;
29 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
30 JSObject::New(target, new_target));
31 Handle<JSValue>::cast(result)->set_value(
32 isolate->heap()->ToBoolean(value->BooleanValue()));
33 return *result;
34 }
35
36 // ES6 section 19.3.3.2 Boolean.prototype.toString ( )
37 void Builtins::Generate_BooleanPrototypeToString(CodeStubAssembler* assembler) {
38 typedef compiler::Node Node;
39
40 Node* receiver = assembler->Parameter(0);
41 Node* context = assembler->Parameter(3);
42
43 Node* value = assembler->ToThisValue(
44 context, receiver, PrimitiveType::kBoolean, "Boolean.prototype.toString");
45 Node* result = assembler->LoadObjectField(value, Oddball::kToStringOffset);
46 assembler->Return(result);
47 }
48
49 // ES6 section 19.3.3.3 Boolean.prototype.valueOf ( )
50 void Builtins::Generate_BooleanPrototypeValueOf(CodeStubAssembler* assembler) {
51 typedef compiler::Node Node;
52
53 Node* receiver = assembler->Parameter(0);
54 Node* context = assembler->Parameter(3);
55
56 Node* result = assembler->ToThisValue(
57 context, receiver, PrimitiveType::kBoolean, "Boolean.prototype.valueOf");
58 assembler->Return(result);
59 }
60
61 } // namespace internal
62 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins-arraybuffer.cc ('k') | src/builtins/builtins-dataview.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698