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 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1646 Object::ToObject(isolate, object)); | 1646 Object::ToObject(isolate, object)); |
1647 Handle<FixedArray> keys; | 1647 Handle<FixedArray> keys; |
1648 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1648 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1649 isolate, keys, | 1649 isolate, keys, |
1650 JSReceiver::GetKeys(receiver, JSReceiver::OWN_ONLY, ENUMERABLE_STRINGS, | 1650 JSReceiver::GetKeys(receiver, JSReceiver::OWN_ONLY, ENUMERABLE_STRINGS, |
1651 CONVERT_TO_STRING)); | 1651 CONVERT_TO_STRING)); |
1652 return *isolate->factory()->NewJSArrayWithElements(keys); | 1652 return *isolate->factory()->NewJSArrayWithElements(keys); |
1653 } | 1653 } |
1654 | 1654 |
1655 | 1655 |
| 1656 BUILTIN(ObjectValues) { |
| 1657 HandleScope scope(isolate); |
| 1658 Handle<Object> object = args.atOrUndefined(isolate, 1); |
| 1659 Handle<JSReceiver> receiver; |
| 1660 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, |
| 1661 Object::ToObject(isolate, object)); |
| 1662 Handle<FixedArray> keys; |
| 1663 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1664 isolate, keys, |
| 1665 JSReceiver::GetKeys(receiver, JSReceiver::OWN_ONLY, ENUMERABLE_STRINGS, |
| 1666 CONVERT_TO_STRING)); |
| 1667 |
| 1668 for (int i = 0; i < keys->length(); ++i) { |
| 1669 auto key = Handle<Name>::cast(FixedArray::get(keys, i)); |
| 1670 Handle<Object> value; |
| 1671 |
| 1672 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1673 isolate, value, Object::GetPropertyOrElement(receiver, key, STRICT)); |
| 1674 |
| 1675 keys->set(i, *value); |
| 1676 } |
| 1677 |
| 1678 return *isolate->factory()->NewJSArrayWithElements(keys); |
| 1679 } |
| 1680 |
| 1681 |
| 1682 BUILTIN(ObjectEntries) { |
| 1683 HandleScope scope(isolate); |
| 1684 Handle<Object> object = args.atOrUndefined(isolate, 1); |
| 1685 Handle<JSReceiver> receiver; |
| 1686 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, |
| 1687 Object::ToObject(isolate, object)); |
| 1688 Handle<FixedArray> keys; |
| 1689 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1690 isolate, keys, |
| 1691 JSReceiver::GetKeys(receiver, JSReceiver::OWN_ONLY, ENUMERABLE_STRINGS, |
| 1692 CONVERT_TO_STRING)); |
| 1693 |
| 1694 for (int i = 0; i < keys->length(); ++i) { |
| 1695 auto key = Handle<Name>::cast(FixedArray::get(keys, i)); |
| 1696 Handle<Object> value; |
| 1697 |
| 1698 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 1699 isolate, value, Object::GetPropertyOrElement(receiver, key, STRICT)); |
| 1700 |
| 1701 auto entry_storage = isolate->factory()->NewUninitializedFixedArray(2); |
| 1702 entry_storage->set(0, *key); |
| 1703 entry_storage->set(1, *value); |
| 1704 auto entry = isolate->factory()->NewJSArrayWithElements(entry_storage); |
| 1705 keys->set(i, *entry); |
| 1706 } |
| 1707 |
| 1708 return *isolate->factory()->NewJSArrayWithElements(keys); |
| 1709 } |
| 1710 |
| 1711 |
1656 // ES6 section 19.1.2.15 Object.preventExtensions ( O ) | 1712 // ES6 section 19.1.2.15 Object.preventExtensions ( O ) |
1657 BUILTIN(ObjectPreventExtensions) { | 1713 BUILTIN(ObjectPreventExtensions) { |
1658 HandleScope scope(isolate); | 1714 HandleScope scope(isolate); |
1659 Handle<Object> object = args.atOrUndefined(isolate, 1); | 1715 Handle<Object> object = args.atOrUndefined(isolate, 1); |
1660 if (object->IsJSReceiver()) { | 1716 if (object->IsJSReceiver()) { |
1661 MAYBE_RETURN(JSReceiver::PreventExtensions(Handle<JSReceiver>::cast(object), | 1717 MAYBE_RETURN(JSReceiver::PreventExtensions(Handle<JSReceiver>::cast(object), |
1662 Object::THROW_ON_ERROR), | 1718 Object::THROW_ON_ERROR), |
1663 isolate->heap()->exception()); | 1719 isolate->heap()->exception()); |
1664 } | 1720 } |
1665 return *object; | 1721 return *object; |
(...skipping 2332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3998 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 4054 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
3999 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 4055 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
4000 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 4056 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
4001 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 4057 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
4002 #undef DEFINE_BUILTIN_ACCESSOR_C | 4058 #undef DEFINE_BUILTIN_ACCESSOR_C |
4003 #undef DEFINE_BUILTIN_ACCESSOR_A | 4059 #undef DEFINE_BUILTIN_ACCESSOR_A |
4004 | 4060 |
4005 | 4061 |
4006 } // namespace internal | 4062 } // namespace internal |
4007 } // namespace v8 | 4063 } // namespace v8 |
OLD | NEW |