| 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 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 DCHECK_EQ(2, args.length()); | 1614 DCHECK_EQ(2, args.length()); |
| 1615 Handle<Object> target = args.at<Object>(1); | 1615 Handle<Object> target = args.at<Object>(1); |
| 1616 | 1616 |
| 1617 if (!target->IsJSReceiver()) { | 1617 if (!target->IsJSReceiver()) { |
| 1618 THROW_NEW_ERROR_RETURN_FAILURE( | 1618 THROW_NEW_ERROR_RETURN_FAILURE( |
| 1619 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, | 1619 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, |
| 1620 isolate->factory()->NewStringFromAsciiChecked( | 1620 isolate->factory()->NewStringFromAsciiChecked( |
| 1621 "Reflect.isExtensible"))); | 1621 "Reflect.isExtensible"))); |
| 1622 } | 1622 } |
| 1623 | 1623 |
| 1624 // TODO(neis): For now, we ignore proxies. Once proxies are fully | 1624 Maybe<bool> result = |
| 1625 // implemented, do something like the following: | 1625 JSReceiver::IsExtensible(Handle<JSReceiver>::cast(target)); |
| 1626 /* | 1626 MAYBE_RETURN(result, isolate->heap()->exception()); |
| 1627 Maybe<bool> maybe = JSReceiver::IsExtensible( | 1627 return *isolate->factory()->ToBoolean(result.FromJust()); |
| 1628 Handle<JSReceiver>::cast(target)); | |
| 1629 if (!maybe.IsJust()) return isolate->heap()->exception(); | |
| 1630 return *isolate->factory()->ToBoolean(maybe.FromJust()); | |
| 1631 */ | |
| 1632 | |
| 1633 if (target->IsJSObject()) { | |
| 1634 return *isolate->factory()->ToBoolean( | |
| 1635 JSObject::IsExtensible(Handle<JSObject>::cast(target))); | |
| 1636 } | |
| 1637 return *isolate->factory()->false_value(); | |
| 1638 } | 1628 } |
| 1639 | 1629 |
| 1640 | 1630 |
| 1641 // ES6 section 26.1.11 Reflect.ownKeys | 1631 // ES6 section 26.1.11 Reflect.ownKeys |
| 1642 BUILTIN(ReflectOwnKeys) { | 1632 BUILTIN(ReflectOwnKeys) { |
| 1643 HandleScope scope(isolate); | 1633 HandleScope scope(isolate); |
| 1644 DCHECK_EQ(2, args.length()); | 1634 DCHECK_EQ(2, args.length()); |
| 1645 Handle<Object> target = args.at<Object>(1); | 1635 Handle<Object> target = args.at<Object>(1); |
| 1646 | 1636 |
| 1647 if (!target->IsJSReceiver()) { | 1637 if (!target->IsJSReceiver()) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1669 | 1659 |
| 1670 if (!target->IsJSReceiver()) { | 1660 if (!target->IsJSReceiver()) { |
| 1671 THROW_NEW_ERROR_RETURN_FAILURE( | 1661 THROW_NEW_ERROR_RETURN_FAILURE( |
| 1672 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, | 1662 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, |
| 1673 isolate->factory()->NewStringFromAsciiChecked( | 1663 isolate->factory()->NewStringFromAsciiChecked( |
| 1674 "Reflect.preventExtensions"))); | 1664 "Reflect.preventExtensions"))); |
| 1675 } | 1665 } |
| 1676 | 1666 |
| 1677 Maybe<bool> result = JSReceiver::PreventExtensions( | 1667 Maybe<bool> result = JSReceiver::PreventExtensions( |
| 1678 Handle<JSReceiver>::cast(target), Object::DONT_THROW); | 1668 Handle<JSReceiver>::cast(target), Object::DONT_THROW); |
| 1679 return result.IsJust() ? *isolate->factory()->ToBoolean(result.FromJust()) | 1669 MAYBE_RETURN(result, isolate->heap()->exception()); |
| 1680 : isolate->heap()->exception(); | 1670 return *isolate->factory()->ToBoolean(result.FromJust()); |
| 1681 } | 1671 } |
| 1682 | 1672 |
| 1683 | 1673 |
| 1684 // ES6 section 26.1.13 Reflect.set | 1674 // ES6 section 26.1.13 Reflect.set |
| 1685 BUILTIN(ReflectSet) { | 1675 BUILTIN(ReflectSet) { |
| 1686 HandleScope scope(isolate); | 1676 HandleScope scope(isolate); |
| 1687 Handle<Object> undef = isolate->factory()->undefined_value(); | 1677 Handle<Object> undef = isolate->factory()->undefined_value(); |
| 1688 Handle<Object> target = args.length() > 1 ? args.at<Object>(1) : undef; | 1678 Handle<Object> target = args.length() > 1 ? args.at<Object>(1) : undef; |
| 1689 Handle<Object> key = args.length() > 2 ? args.at<Object>(2) : undef; | 1679 Handle<Object> key = args.length() > 2 ? args.at<Object>(2) : undef; |
| 1690 Handle<Object> value = args.length() > 3 ? args.at<Object>(3) : undef; | 1680 Handle<Object> value = args.length() > 3 ? args.at<Object>(3) : undef; |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2412 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 2402 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
| 2413 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 2403 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 2414 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 2404 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
| 2415 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 2405 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 2416 #undef DEFINE_BUILTIN_ACCESSOR_C | 2406 #undef DEFINE_BUILTIN_ACCESSOR_C |
| 2417 #undef DEFINE_BUILTIN_ACCESSOR_A | 2407 #undef DEFINE_BUILTIN_ACCESSOR_A |
| 2418 | 2408 |
| 2419 | 2409 |
| 2420 } // namespace internal | 2410 } // namespace internal |
| 2421 } // namespace v8 | 2411 } // namespace v8 |
| OLD | NEW |