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 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1645 "Reflect.preventExtensions"))); | 1645 "Reflect.preventExtensions"))); |
1646 } | 1646 } |
1647 | 1647 |
1648 Maybe<bool> result = JSReceiver::PreventExtensions( | 1648 Maybe<bool> result = JSReceiver::PreventExtensions( |
1649 Handle<JSReceiver>::cast(target), Object::DONT_THROW); | 1649 Handle<JSReceiver>::cast(target), Object::DONT_THROW); |
1650 return result.IsJust() ? *isolate->factory()->ToBoolean(result.FromJust()) | 1650 return result.IsJust() ? *isolate->factory()->ToBoolean(result.FromJust()) |
1651 : isolate->heap()->exception(); | 1651 : isolate->heap()->exception(); |
1652 } | 1652 } |
1653 | 1653 |
1654 | 1654 |
| 1655 // ES6 section 26.1.13 Reflect.set |
| 1656 BUILTIN(ReflectSet) { |
| 1657 HandleScope scope(isolate); |
| 1658 Handle<Object> undef = isolate->factory()->undefined_value(); |
| 1659 Handle<Object> target = args.length() > 1 ? args.at<Object>(1) : undef; |
| 1660 Handle<Object> key = args.length() > 2 ? args.at<Object>(2) : undef; |
| 1661 Handle<Object> value = args.length() > 3 ? args.at<Object>(3) : undef; |
| 1662 Handle<Object> receiver = args.length() > 4 ? args.at<Object>(4) : target; |
| 1663 |
| 1664 if (!target->IsJSReceiver()) { |
| 1665 THROW_NEW_ERROR_RETURN_FAILURE( |
| 1666 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, |
| 1667 isolate->factory()->NewStringFromAsciiChecked( |
| 1668 "Reflect.set"))); |
| 1669 } |
| 1670 |
| 1671 Handle<Name> name; |
| 1672 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
| 1673 Object::ToName(isolate, key)); |
| 1674 |
| 1675 LookupIterator it = LookupIterator::PropertyOrElement( |
| 1676 isolate, receiver, name, Handle<JSReceiver>::cast(target)); |
| 1677 Maybe<bool> result = Object::SetSuperProperty( |
| 1678 &it, value, SLOPPY, Object::MAY_BE_STORE_FROM_KEYED); |
| 1679 MAYBE_RETURN(result, isolate->heap()->exception()); |
| 1680 return *isolate->factory()->ToBoolean(result.FromJust()); |
| 1681 } |
| 1682 |
| 1683 |
1655 // ES6 section 26.1.14 Reflect.setPrototypeOf | 1684 // ES6 section 26.1.14 Reflect.setPrototypeOf |
1656 BUILTIN(ReflectSetPrototypeOf) { | 1685 BUILTIN(ReflectSetPrototypeOf) { |
1657 HandleScope scope(isolate); | 1686 HandleScope scope(isolate); |
1658 DCHECK_EQ(3, args.length()); | 1687 DCHECK_EQ(3, args.length()); |
1659 Handle<Object> target = args.at<Object>(1); | 1688 Handle<Object> target = args.at<Object>(1); |
1660 Handle<Object> proto = args.at<Object>(2); | 1689 Handle<Object> proto = args.at<Object>(2); |
1661 | 1690 |
1662 if (!target->IsJSReceiver()) { | 1691 if (!target->IsJSReceiver()) { |
1663 THROW_NEW_ERROR_RETURN_FAILURE( | 1692 THROW_NEW_ERROR_RETURN_FAILURE( |
1664 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, | 1693 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2326 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 2355 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
2327 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 2356 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
2328 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 2357 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
2329 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 2358 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
2330 #undef DEFINE_BUILTIN_ACCESSOR_C | 2359 #undef DEFINE_BUILTIN_ACCESSOR_C |
2331 #undef DEFINE_BUILTIN_ACCESSOR_A | 2360 #undef DEFINE_BUILTIN_ACCESSOR_A |
2332 | 2361 |
2333 | 2362 |
2334 } // namespace internal | 2363 } // namespace internal |
2335 } // namespace v8 | 2364 } // namespace v8 |
OLD | NEW |