Chromium Code Reviews| OLD | NEW | 
|---|---|
| 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" | 
| (...skipping 1782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1793 auto entry_storage = isolate->factory()->NewUninitializedFixedArray(2); | 1793 auto entry_storage = isolate->factory()->NewUninitializedFixedArray(2); | 
| 1794 entry_storage->set(0, *key); | 1794 entry_storage->set(0, *key); | 
| 1795 entry_storage->set(1, *value); | 1795 entry_storage->set(1, *value); | 
| 1796 auto entry = isolate->factory()->NewJSArrayWithElements(entry_storage); | 1796 auto entry = isolate->factory()->NewJSArrayWithElements(entry_storage); | 
| 1797 keys->set(i, *entry); | 1797 keys->set(i, *entry); | 
| 1798 } | 1798 } | 
| 1799 | 1799 | 
| 1800 return *isolate->factory()->NewJSArrayWithElements(keys); | 1800 return *isolate->factory()->NewJSArrayWithElements(keys); | 
| 1801 } | 1801 } | 
| 1802 | 1802 | 
| 1803 BUILTIN(ObjectGetOwnPropertyDescriptors) { | |
| 1804 HandleScope scope(isolate); | |
| 1805 Handle<Object> object = args.atOrUndefined(isolate, 1); | |
| 1806 Handle<Object> undefined = isolate->factory()->undefined_value(); | |
| 1807 | |
| 1808 Handle<JSReceiver> receiver; | |
| 1809 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, | |
| 1810 Object::ToObject(isolate, object)); | |
| 1811 | |
| 1812 Handle<FixedArray> keys; | |
| 1813 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
| 1814 isolate, keys, JSReceiver::GetKeys(receiver, OWN_ONLY, ALL_PROPERTIES, | |
| 1815 CONVERT_TO_STRING)); | |
| 1816 | |
| 1817 Handle<Object> descriptors = | |
| 1818 isolate->factory()->NewJSObject(isolate->object_function()); | |
| 1819 | |
| 1820 for (int i = 0; i < keys->length(); ++i) { | |
| 1821 Handle<Name> key = Handle<Name>::cast(FixedArray::get(*keys, i, isolate)); | |
| 1822 PropertyDescriptor descriptor; | |
| 1823 Maybe<bool> did_get_descriptor = JSReceiver::GetOwnPropertyDescriptor( | |
| 1824 isolate, receiver, key, &descriptor); | |
| 1825 MAYBE_RETURN(did_get_descriptor, isolate->heap()->exception()); | |
| 1826 | |
| 1827 Handle<Object> from_descriptor = did_get_descriptor.FromJust() | |
| 
 
adamk
2016/02/04 20:13:48
Isn't this guaranteed to return true since we MAYB
 
caitp (gmail)
2016/02/04 20:14:49
nope, it can return false if the property doesn't
 
 | |
| 1828 ? descriptor.ToObject(isolate) | |
| 1829 : undefined; | |
| 1830 | |
| 1831 LookupIterator it = LookupIterator::PropertyOrElement( | |
| 1832 isolate, descriptors, key, LookupIterator::OWN); | |
| 1833 Maybe<bool> success = JSReceiver::CreateDataProperty(&it, from_descriptor, | |
| 1834 Object::DONT_THROW); | |
| 1835 CHECK(success.FromJust()); | |
| 1836 } | |
| 1837 | |
| 1838 return *descriptors; | |
| 1839 } | |
| 1803 | 1840 | 
| 1804 // ES6 section 19.1.2.15 Object.preventExtensions ( O ) | 1841 // ES6 section 19.1.2.15 Object.preventExtensions ( O ) | 
| 1805 BUILTIN(ObjectPreventExtensions) { | 1842 BUILTIN(ObjectPreventExtensions) { | 
| 1806 HandleScope scope(isolate); | 1843 HandleScope scope(isolate); | 
| 1807 Handle<Object> object = args.atOrUndefined(isolate, 1); | 1844 Handle<Object> object = args.atOrUndefined(isolate, 1); | 
| 1808 if (object->IsJSReceiver()) { | 1845 if (object->IsJSReceiver()) { | 
| 1809 MAYBE_RETURN(JSReceiver::PreventExtensions(Handle<JSReceiver>::cast(object), | 1846 MAYBE_RETURN(JSReceiver::PreventExtensions(Handle<JSReceiver>::cast(object), | 
| 1810 Object::THROW_ON_ERROR), | 1847 Object::THROW_ON_ERROR), | 
| 1811 isolate->heap()->exception()); | 1848 isolate->heap()->exception()); | 
| 1812 } | 1849 } | 
| (...skipping 2372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4185 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 4222 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 
| 4186 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 4223 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 
| 4187 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 4224 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 
| 4188 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 4225 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 
| 4189 #undef DEFINE_BUILTIN_ACCESSOR_C | 4226 #undef DEFINE_BUILTIN_ACCESSOR_C | 
| 4190 #undef DEFINE_BUILTIN_ACCESSOR_A | 4227 #undef DEFINE_BUILTIN_ACCESSOR_A | 
| 4191 | 4228 | 
| 4192 | 4229 | 
| 4193 } // namespace internal | 4230 } // namespace internal | 
| 4194 } // namespace v8 | 4231 } // namespace v8 | 
| OLD | NEW |