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 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1584 "Reflect.preventExtensions"))); | 1584 "Reflect.preventExtensions"))); |
1585 } | 1585 } |
1586 | 1586 |
1587 Maybe<bool> result = JSReceiver::PreventExtensions( | 1587 Maybe<bool> result = JSReceiver::PreventExtensions( |
1588 Handle<JSReceiver>::cast(target), Object::DONT_THROW); | 1588 Handle<JSReceiver>::cast(target), Object::DONT_THROW); |
1589 return result.IsJust() ? *isolate->factory()->ToBoolean(result.FromJust()) | 1589 return result.IsJust() ? *isolate->factory()->ToBoolean(result.FromJust()) |
1590 : isolate->heap()->exception(); | 1590 : isolate->heap()->exception(); |
1591 } | 1591 } |
1592 | 1592 |
1593 | 1593 |
| 1594 // ES6 section 26.1.13 Reflect.set |
| 1595 BUILTIN(ReflectSet) { |
| 1596 HandleScope scope(isolate); |
| 1597 Handle<Object> undef = isolate->factory()->undefined_value(); |
| 1598 Handle<Object> target = args.length() > 1 ? args.at<Object>(1) : undef; |
| 1599 Handle<Object> key = args.length() > 2 ? args.at<Object>(2) : undef; |
| 1600 Handle<Object> value = args.length() > 3 ? args.at<Object>(3) : undef; |
| 1601 Handle<Object> receiver = args.length() > 4 ? args.at<Object>(4) : target; |
| 1602 |
| 1603 if (!target->IsJSReceiver()) { |
| 1604 THROW_NEW_ERROR_RETURN_FAILURE( |
| 1605 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, |
| 1606 isolate->factory()->NewStringFromAsciiChecked( |
| 1607 "Reflect.set"))); |
| 1608 } |
| 1609 |
| 1610 Handle<Name> name; |
| 1611 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
| 1612 Object::ToName(isolate, key)); |
| 1613 |
| 1614 LookupIterator it = LookupIterator::PropertyOrElement( |
| 1615 isolate, receiver, name, Handle<JSReceiver>::cast(target)); |
| 1616 Maybe<bool> result = Object::SetSuperProperty( |
| 1617 &it, value, SLOPPY, Object::MAY_BE_STORE_FROM_KEYED); |
| 1618 MAYBE_RETURN(result, isolate->heap()->exception()); |
| 1619 return *isolate->factory()->ToBoolean(result.FromJust()); |
| 1620 } |
| 1621 |
| 1622 |
1594 // ES6 section 26.1.14 Reflect.setPrototypeOf | 1623 // ES6 section 26.1.14 Reflect.setPrototypeOf |
1595 BUILTIN(ReflectSetPrototypeOf) { | 1624 BUILTIN(ReflectSetPrototypeOf) { |
1596 HandleScope scope(isolate); | 1625 HandleScope scope(isolate); |
1597 DCHECK_EQ(3, args.length()); | 1626 DCHECK_EQ(3, args.length()); |
1598 Handle<Object> target = args.at<Object>(1); | 1627 Handle<Object> target = args.at<Object>(1); |
1599 Handle<Object> proto = args.at<Object>(2); | 1628 Handle<Object> proto = args.at<Object>(2); |
1600 | 1629 |
1601 if (!target->IsJSReceiver()) { | 1630 if (!target->IsJSReceiver()) { |
1602 THROW_NEW_ERROR_RETURN_FAILURE( | 1631 THROW_NEW_ERROR_RETURN_FAILURE( |
1603 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, | 1632 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2265 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 2294 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
2266 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 2295 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
2267 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 2296 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
2268 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 2297 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
2269 #undef DEFINE_BUILTIN_ACCESSOR_C | 2298 #undef DEFINE_BUILTIN_ACCESSOR_C |
2270 #undef DEFINE_BUILTIN_ACCESSOR_A | 2299 #undef DEFINE_BUILTIN_ACCESSOR_A |
2271 | 2300 |
2272 | 2301 |
2273 } // namespace internal | 2302 } // namespace internal |
2274 } // namespace v8 | 2303 } // namespace v8 |
OLD | NEW |