Index: src/builtins.cc |
diff --git a/src/builtins.cc b/src/builtins.cc |
index d1ed05ad0678685683cc3cd9b21b00cb27d95518..4cf93ead630d90b5653e60123e7b8850da802bc5 100644 |
--- a/src/builtins.cc |
+++ b/src/builtins.cc |
@@ -1661,6 +1661,30 @@ BUILTIN(ObjectFreeze) { |
} |
+// ES6 section 19.1.2.6 Object.getOwnPropertyDescriptor ( O, P ) |
+BUILTIN(ObjectGetOwnPropertyDescriptor) { |
+ HandleScope scope(isolate); |
+ // 1. Let obj be ? ToObject(O). |
+ Handle<Object> object = args.atOrUndefined(isolate, 1); |
+ Handle<JSReceiver> receiver; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, |
+ Object::ToObject(isolate, object)); |
+ // 2. Let key be ? ToPropertyKey(P). |
+ Handle<Object> property = args.atOrUndefined(isolate, 2); |
+ Handle<Name> key; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, key, |
+ Object::ToName(isolate, property)); |
+ // 3. Let desc be ? obj.[[GetOwnProperty]](key). |
+ PropertyDescriptor desc; |
+ Maybe<bool> found = |
+ JSReceiver::GetOwnPropertyDescriptor(isolate, receiver, key, &desc); |
+ MAYBE_RETURN(found, isolate->heap()->exception()); |
+ // 4. Return FromPropertyDescriptor(desc). |
+ if (!found.FromJust()) return isolate->heap()->undefined_value(); |
+ return *desc.ToObject(isolate); |
+} |
+ |
+ |
namespace { |
Object* GetOwnPropertyKeys(Isolate* isolate, |