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), DONT_THROW); | 1588 Handle<JSReceiver>::cast(target), 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.14 Reflect.setPrototypeOf |
| 1595 BUILTIN(ReflectSetPrototypeOf) { |
| 1596 HandleScope scope(isolate); |
| 1597 DCHECK_EQ(3, args.length()); |
| 1598 Handle<Object> target = args.at<Object>(1); |
| 1599 Handle<Object> proto = args.at<Object>(2); |
| 1600 |
| 1601 if (!target->IsJSReceiver()) { |
| 1602 THROW_NEW_ERROR_RETURN_FAILURE( |
| 1603 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, |
| 1604 isolate->factory()->NewStringFromAsciiChecked( |
| 1605 "Reflect.setPrototypeOf"))); |
| 1606 } |
| 1607 |
| 1608 if (!proto->IsJSReceiver() && !proto->IsNull()) { |
| 1609 THROW_NEW_ERROR_RETURN_FAILURE( |
| 1610 isolate, NewTypeError(MessageTemplate::kProtoObjectOrNull, proto)); |
| 1611 } |
| 1612 |
| 1613 Maybe<bool> result = JSReceiver::SetPrototype( |
| 1614 Handle<JSReceiver>::cast(target), proto, true, DONT_THROW); |
| 1615 MAYBE_RETURN(result, isolate->heap()->exception()); |
| 1616 return *isolate->factory()->ToBoolean(result.FromJust()); |
| 1617 } |
| 1618 |
| 1619 |
1594 // ES6 section 20.3.4.45 Date.prototype [ @@toPrimitive ] ( hint ) | 1620 // ES6 section 20.3.4.45 Date.prototype [ @@toPrimitive ] ( hint ) |
1595 BUILTIN(DateToPrimitive) { | 1621 BUILTIN(DateToPrimitive) { |
1596 HandleScope scope(isolate); | 1622 HandleScope scope(isolate); |
1597 DCHECK_EQ(2, args.length()); | 1623 DCHECK_EQ(2, args.length()); |
1598 if (!args.receiver()->IsJSReceiver()) { | 1624 if (!args.receiver()->IsJSReceiver()) { |
1599 THROW_NEW_ERROR_RETURN_FAILURE( | 1625 THROW_NEW_ERROR_RETURN_FAILURE( |
1600 isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, | 1626 isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, |
1601 isolate->factory()->NewStringFromAsciiChecked( | 1627 isolate->factory()->NewStringFromAsciiChecked( |
1602 "Date.prototype [ @@toPrimitive ]"), | 1628 "Date.prototype [ @@toPrimitive ]"), |
1603 args.receiver())); | 1629 args.receiver())); |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2239 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 2265 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
2240 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 2266 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
2241 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 2267 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
2242 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 2268 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
2243 #undef DEFINE_BUILTIN_ACCESSOR_C | 2269 #undef DEFINE_BUILTIN_ACCESSOR_C |
2244 #undef DEFINE_BUILTIN_ACCESSOR_A | 2270 #undef DEFINE_BUILTIN_ACCESSOR_A |
2245 | 2271 |
2246 | 2272 |
2247 } // namespace internal | 2273 } // namespace internal |
2248 } // namespace v8 | 2274 } // namespace v8 |
OLD | NEW |