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

Side by Side Diff: src/builtins.cc

Issue 1408163005: [es6] Partially implement Reflect.getOwnPropertyDescriptor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/builtins.h" 5 #include "src/builtins.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
11 #include "src/bootstrapper.h" 11 #include "src/bootstrapper.h"
12 #include "src/elements.h" 12 #include "src/elements.h"
13 #include "src/frames-inl.h" 13 #include "src/frames-inl.h"
14 #include "src/gdb-jit.h" 14 #include "src/gdb-jit.h"
15 #include "src/ic/handler-compiler.h" 15 #include "src/ic/handler-compiler.h"
16 #include "src/ic/ic.h" 16 #include "src/ic/ic.h"
17 #include "src/isolate-inl.h" 17 #include "src/isolate-inl.h"
18 #include "src/messages.h" 18 #include "src/messages.h"
19 #include "src/profiler/cpu-profiler.h" 19 #include "src/profiler/cpu-profiler.h"
20 #include "src/property-descriptor.h"
20 #include "src/prototype.h" 21 #include "src/prototype.h"
21 #include "src/vm-state-inl.h" 22 #include "src/vm-state-inl.h"
22 23
23 namespace v8 { 24 namespace v8 {
24 namespace internal { 25 namespace internal {
25 26
26 namespace { 27 namespace {
27 28
28 // Arguments object passed to C++ builtins. 29 // Arguments object passed to C++ builtins.
29 template <BuiltinExtraArguments extra_args> 30 template <BuiltinExtraArguments extra_args>
(...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 1493
1493 Handle<Object> result; 1494 Handle<Object> result;
1494 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1495 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1495 isolate, result, Object::GetPropertyOrElement( 1496 isolate, result, Object::GetPropertyOrElement(
1496 Handle<JSReceiver>::cast(target), name, receiver)); 1497 Handle<JSReceiver>::cast(target), name, receiver));
1497 1498
1498 return *result; 1499 return *result;
1499 } 1500 }
1500 1501
1501 1502
1503 // ES6 section 26.1.7 Reflect.getOwnPropertyDescriptor
1504 BUILTIN(ReflectGetOwnPropertyDescriptor) {
1505 HandleScope scope(isolate);
1506 DCHECK_EQ(3, args.length());
1507 Handle<Object> target = args.at<Object>(1);
1508 Handle<Object> key = args.at<Object>(2);
1509
1510 if (!target->IsJSReceiver()) {
1511 THROW_NEW_ERROR_RETURN_FAILURE(
1512 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject,
1513 isolate->factory()->NewStringFromAsciiChecked(
1514 "Reflect.getOwnPropertyDescriptor")));
1515 }
1516
1517 Handle<Name> name;
1518 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name,
1519 Object::ToName(isolate, key));
1520
1521 PropertyDescriptor desc;
1522 bool found = JSReceiver::GetOwnPropertyDescriptor(
1523 isolate, Handle<JSReceiver>::cast(target), name, &desc);
1524 if (isolate->has_pending_exception()) return isolate->heap()->exception();
1525 if (!found) return isolate->heap()->undefined_value();
Jakob Kummerow 2015/10/26 13:58:26 How about folding this into PropertyDescriptor::To
neis 2015/10/29 16:48:39 This doesn't quite work without passing in "found"
1526 return *desc.ToObject(isolate);
1527 }
1528
1529
1502 // ES6 section 26.1.8 Reflect.getPrototypeOf 1530 // ES6 section 26.1.8 Reflect.getPrototypeOf
1503 BUILTIN(ReflectGetPrototypeOf) { 1531 BUILTIN(ReflectGetPrototypeOf) {
1504 HandleScope scope(isolate); 1532 HandleScope scope(isolate);
1505 DCHECK_EQ(2, args.length()); 1533 DCHECK_EQ(2, args.length());
1506 Handle<Object> target = args.at<Object>(1); 1534 Handle<Object> target = args.at<Object>(1);
1507 1535
1508 if (!target->IsJSReceiver()) { 1536 if (!target->IsJSReceiver()) {
1509 THROW_NEW_ERROR_RETURN_FAILURE( 1537 THROW_NEW_ERROR_RETURN_FAILURE(
1510 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, 1538 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject,
1511 isolate->factory()->NewStringFromAsciiChecked( 1539 isolate->factory()->NewStringFromAsciiChecked(
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
2265 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 2293 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
2266 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 2294 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
2267 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 2295 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
2268 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 2296 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
2269 #undef DEFINE_BUILTIN_ACCESSOR_C 2297 #undef DEFINE_BUILTIN_ACCESSOR_C
2270 #undef DEFINE_BUILTIN_ACCESSOR_A 2298 #undef DEFINE_BUILTIN_ACCESSOR_A
2271 2299
2272 2300
2273 } // namespace internal 2301 } // namespace internal
2274 } // namespace v8 2302 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins.h ('k') | src/objects.h » ('j') | src/property-descriptor.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698