| 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 1735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1746 return *isolate->factory()->NewJSArrayWithElements(keys); | 1746 return *isolate->factory()->NewJSArrayWithElements(keys); |
| 1747 } | 1747 } |
| 1748 | 1748 |
| 1749 | 1749 |
| 1750 BUILTIN(ObjectValues) { | 1750 BUILTIN(ObjectValues) { |
| 1751 HandleScope scope(isolate); | 1751 HandleScope scope(isolate); |
| 1752 Handle<Object> object = args.atOrUndefined(isolate, 1); | 1752 Handle<Object> object = args.atOrUndefined(isolate, 1); |
| 1753 Handle<JSReceiver> receiver; | 1753 Handle<JSReceiver> receiver; |
| 1754 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, | 1754 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, |
| 1755 Object::ToObject(isolate, object)); | 1755 Object::ToObject(isolate, object)); |
| 1756 Handle<FixedArray> keys; | 1756 Handle<FixedArray> values; |
| 1757 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1757 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1758 isolate, keys, JSReceiver::GetKeys(receiver, OWN_ONLY, ENUMERABLE_STRINGS, | 1758 isolate, values, JSReceiver::GetOwnValues(receiver, ENUMERABLE_STRINGS)); |
| 1759 CONVERT_TO_STRING)); | 1759 return *isolate->factory()->NewJSArrayWithElements(values); |
| 1760 | |
| 1761 for (int i = 0; i < keys->length(); ++i) { | |
| 1762 auto key = Handle<Name>::cast(FixedArray::get(*keys, i, isolate)); | |
| 1763 Handle<Object> value; | |
| 1764 | |
| 1765 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
| 1766 isolate, value, Object::GetPropertyOrElement(receiver, key, STRICT)); | |
| 1767 | |
| 1768 keys->set(i, *value); | |
| 1769 } | |
| 1770 | |
| 1771 return *isolate->factory()->NewJSArrayWithElements(keys); | |
| 1772 } | 1760 } |
| 1773 | 1761 |
| 1774 | 1762 |
| 1775 BUILTIN(ObjectEntries) { | 1763 BUILTIN(ObjectEntries) { |
| 1776 HandleScope scope(isolate); | 1764 HandleScope scope(isolate); |
| 1777 Handle<Object> object = args.atOrUndefined(isolate, 1); | 1765 Handle<Object> object = args.atOrUndefined(isolate, 1); |
| 1778 Handle<JSReceiver> receiver; | 1766 Handle<JSReceiver> receiver; |
| 1779 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, | 1767 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, |
| 1780 Object::ToObject(isolate, object)); | 1768 Object::ToObject(isolate, object)); |
| 1781 Handle<FixedArray> keys; | 1769 Handle<FixedArray> entries; |
| 1782 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1770 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1783 isolate, keys, JSReceiver::GetKeys(receiver, OWN_ONLY, ENUMERABLE_STRINGS, | 1771 isolate, entries, |
| 1784 CONVERT_TO_STRING)); | 1772 JSReceiver::GetOwnEntries(receiver, ENUMERABLE_STRINGS)); |
| 1785 | 1773 return *isolate->factory()->NewJSArrayWithElements(entries); |
| 1786 for (int i = 0; i < keys->length(); ++i) { | |
| 1787 auto key = Handle<Name>::cast(FixedArray::get(*keys, i, isolate)); | |
| 1788 Handle<Object> value; | |
| 1789 | |
| 1790 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
| 1791 isolate, value, Object::GetPropertyOrElement(receiver, key, STRICT)); | |
| 1792 | |
| 1793 auto entry_storage = isolate->factory()->NewUninitializedFixedArray(2); | |
| 1794 entry_storage->set(0, *key); | |
| 1795 entry_storage->set(1, *value); | |
| 1796 auto entry = isolate->factory()->NewJSArrayWithElements(entry_storage); | |
| 1797 keys->set(i, *entry); | |
| 1798 } | |
| 1799 | |
| 1800 return *isolate->factory()->NewJSArrayWithElements(keys); | |
| 1801 } | 1774 } |
| 1802 | 1775 |
| 1803 | 1776 |
| 1804 // ES6 section 19.1.2.15 Object.preventExtensions ( O ) | 1777 // ES6 section 19.1.2.15 Object.preventExtensions ( O ) |
| 1805 BUILTIN(ObjectPreventExtensions) { | 1778 BUILTIN(ObjectPreventExtensions) { |
| 1806 HandleScope scope(isolate); | 1779 HandleScope scope(isolate); |
| 1807 Handle<Object> object = args.atOrUndefined(isolate, 1); | 1780 Handle<Object> object = args.atOrUndefined(isolate, 1); |
| 1808 if (object->IsJSReceiver()) { | 1781 if (object->IsJSReceiver()) { |
| 1809 MAYBE_RETURN(JSReceiver::PreventExtensions(Handle<JSReceiver>::cast(object), | 1782 MAYBE_RETURN(JSReceiver::PreventExtensions(Handle<JSReceiver>::cast(object), |
| 1810 Object::THROW_ON_ERROR), | 1783 Object::THROW_ON_ERROR), |
| (...skipping 2374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4185 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 4158 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
| 4186 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 4159 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 4187 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 4160 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
| 4188 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 4161 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 4189 #undef DEFINE_BUILTIN_ACCESSOR_C | 4162 #undef DEFINE_BUILTIN_ACCESSOR_C |
| 4190 #undef DEFINE_BUILTIN_ACCESSOR_A | 4163 #undef DEFINE_BUILTIN_ACCESSOR_A |
| 4191 | 4164 |
| 4192 | 4165 |
| 4193 } // namespace internal | 4166 } // namespace internal |
| 4194 } // namespace v8 | 4167 } // namespace v8 |
| OLD | NEW |