Chromium Code Reviews| Index: src/builtins.cc |
| diff --git a/src/builtins.cc b/src/builtins.cc |
| index 1ed2fd125315eea8ca4af113cab5a668ad25cb3c..e7e096216feb90c7cf7cbe7fcba18f164d033b16 100644 |
| --- a/src/builtins.cc |
| +++ b/src/builtins.cc |
| @@ -17,6 +17,7 @@ |
| #include "src/isolate-inl.h" |
| #include "src/messages.h" |
| #include "src/profiler/cpu-profiler.h" |
| +#include "src/property-descriptor.h" |
| #include "src/prototype.h" |
| #include "src/vm-state-inl.h" |
| @@ -1499,6 +1500,33 @@ BUILTIN(ReflectGet) { |
| } |
| +// ES6 section 26.1.7 Reflect.getOwnPropertyDescriptor |
| +BUILTIN(ReflectGetOwnPropertyDescriptor) { |
| + HandleScope scope(isolate); |
| + DCHECK_EQ(3, args.length()); |
| + Handle<Object> target = args.at<Object>(1); |
| + Handle<Object> key = args.at<Object>(2); |
| + |
| + if (!target->IsJSReceiver()) { |
| + THROW_NEW_ERROR_RETURN_FAILURE( |
| + isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, |
| + isolate->factory()->NewStringFromAsciiChecked( |
| + "Reflect.getOwnPropertyDescriptor"))); |
| + } |
| + |
| + Handle<Name> name; |
| + ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
| + Object::ToName(isolate, key)); |
| + |
| + PropertyDescriptor desc; |
| + bool found = JSReceiver::GetOwnPropertyDescriptor( |
| + isolate, Handle<JSReceiver>::cast(target), name, &desc); |
| + if (isolate->has_pending_exception()) return isolate->heap()->exception(); |
| + 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"
|
| + return *desc.ToObject(isolate); |
| +} |
| + |
| + |
| // ES6 section 26.1.8 Reflect.getPrototypeOf |
| BUILTIN(ReflectGetPrototypeOf) { |
| HandleScope scope(isolate); |