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-arguments.h" | 7 #include "src/api-arguments.h" |
8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/base/ieee754.h" | 10 #include "src/base/ieee754.h" |
(...skipping 2007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2018 Handle<FixedArray> entries; | 2018 Handle<FixedArray> entries; |
2019 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2019 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2020 isolate, entries, | 2020 isolate, entries, |
2021 JSReceiver::GetOwnEntries(receiver, ENUMERABLE_STRINGS)); | 2021 JSReceiver::GetOwnEntries(receiver, ENUMERABLE_STRINGS)); |
2022 return *isolate->factory()->NewJSArrayWithElements(entries); | 2022 return *isolate->factory()->NewJSArrayWithElements(entries); |
2023 } | 2023 } |
2024 | 2024 |
2025 BUILTIN(ObjectGetOwnPropertyDescriptors) { | 2025 BUILTIN(ObjectGetOwnPropertyDescriptors) { |
2026 HandleScope scope(isolate); | 2026 HandleScope scope(isolate); |
2027 Handle<Object> object = args.atOrUndefined(isolate, 1); | 2027 Handle<Object> object = args.atOrUndefined(isolate, 1); |
2028 Handle<Object> undefined = isolate->factory()->undefined_value(); | |
2029 | 2028 |
2030 Handle<JSReceiver> receiver; | 2029 Handle<JSReceiver> receiver; |
2031 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, | 2030 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, |
2032 Object::ToObject(isolate, object)); | 2031 Object::ToObject(isolate, object)); |
2033 | 2032 |
2034 Handle<FixedArray> keys; | 2033 Handle<FixedArray> keys; |
2035 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2034 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2036 isolate, keys, KeyAccumulator::GetKeys( | 2035 isolate, keys, KeyAccumulator::GetKeys( |
2037 receiver, KeyCollectionMode::kOwnOnly, ALL_PROPERTIES, | 2036 receiver, KeyCollectionMode::kOwnOnly, ALL_PROPERTIES, |
2038 GetKeysConversion::kConvertToString)); | 2037 GetKeysConversion::kConvertToString)); |
2039 | 2038 |
2040 Handle<JSObject> descriptors = | 2039 Handle<JSObject> descriptors = |
2041 isolate->factory()->NewJSObject(isolate->object_function()); | 2040 isolate->factory()->NewJSObject(isolate->object_function()); |
2042 | 2041 |
2043 for (int i = 0; i < keys->length(); ++i) { | 2042 for (int i = 0; i < keys->length(); ++i) { |
2044 Handle<Name> key = Handle<Name>::cast(FixedArray::get(*keys, i, isolate)); | 2043 Handle<Name> key = Handle<Name>::cast(FixedArray::get(*keys, i, isolate)); |
2045 PropertyDescriptor descriptor; | 2044 PropertyDescriptor descriptor; |
2046 Maybe<bool> did_get_descriptor = JSReceiver::GetOwnPropertyDescriptor( | 2045 Maybe<bool> did_get_descriptor = JSReceiver::GetOwnPropertyDescriptor( |
2047 isolate, receiver, key, &descriptor); | 2046 isolate, receiver, key, &descriptor); |
2048 MAYBE_RETURN(did_get_descriptor, isolate->heap()->exception()); | 2047 MAYBE_RETURN(did_get_descriptor, isolate->heap()->exception()); |
2049 | 2048 |
2050 Handle<Object> from_descriptor = did_get_descriptor.FromJust() | 2049 if (!did_get_descriptor.FromJust()) continue; |
2051 ? descriptor.ToObject(isolate) | 2050 Handle<Object> from_descriptor = descriptor.ToObject(isolate); |
2052 : undefined; | |
2053 | 2051 |
2054 LookupIterator it = LookupIterator::PropertyOrElement( | 2052 LookupIterator it = LookupIterator::PropertyOrElement( |
2055 isolate, descriptors, key, descriptors, LookupIterator::OWN); | 2053 isolate, descriptors, key, descriptors, LookupIterator::OWN); |
2056 Maybe<bool> success = JSReceiver::CreateDataProperty(&it, from_descriptor, | 2054 Maybe<bool> success = JSReceiver::CreateDataProperty(&it, from_descriptor, |
2057 Object::DONT_THROW); | 2055 Object::DONT_THROW); |
2058 CHECK(success.FromJust()); | 2056 CHECK(success.FromJust()); |
2059 } | 2057 } |
2060 | 2058 |
2061 return *descriptors; | 2059 return *descriptors; |
2062 } | 2060 } |
(...skipping 4365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6428 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 6426 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
6429 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 6427 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
6430 #undef DEFINE_BUILTIN_ACCESSOR_C | 6428 #undef DEFINE_BUILTIN_ACCESSOR_C |
6431 #undef DEFINE_BUILTIN_ACCESSOR_A | 6429 #undef DEFINE_BUILTIN_ACCESSOR_A |
6432 #undef DEFINE_BUILTIN_ACCESSOR_T | 6430 #undef DEFINE_BUILTIN_ACCESSOR_T |
6433 #undef DEFINE_BUILTIN_ACCESSOR_S | 6431 #undef DEFINE_BUILTIN_ACCESSOR_S |
6434 #undef DEFINE_BUILTIN_ACCESSOR_H | 6432 #undef DEFINE_BUILTIN_ACCESSOR_H |
6435 | 6433 |
6436 } // namespace internal | 6434 } // namespace internal |
6437 } // namespace v8 | 6435 } // namespace v8 |
OLD | NEW |