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 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 THROW_NEW_ERROR_RETURN_FAILURE( | 1510 THROW_NEW_ERROR_RETURN_FAILURE( |
1511 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, | 1511 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, |
1512 isolate->factory()->NewStringFromAsciiChecked( | 1512 isolate->factory()->NewStringFromAsciiChecked( |
1513 "Reflect.has"))); | 1513 "Reflect.has"))); |
1514 } | 1514 } |
1515 | 1515 |
1516 Handle<Name> name; | 1516 Handle<Name> name; |
1517 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, | 1517 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name, |
1518 Object::ToName(isolate, key)); | 1518 Object::ToName(isolate, key)); |
1519 | 1519 |
1520 Maybe<bool> maybe = | 1520 Maybe<bool> result = |
1521 JSReceiver::HasProperty(Handle<JSReceiver>::cast(target), name); | 1521 JSReceiver::HasProperty(Handle<JSReceiver>::cast(target), name); |
1522 if (!maybe.IsJust()) return isolate->heap()->exception(); | 1522 return result.IsJust() ? *isolate->factory()->ToBoolean(result.FromJust()) |
1523 return *isolate->factory()->ToBoolean(maybe.FromJust()); | 1523 : isolate->heap()->exception(); |
1524 } | 1524 } |
1525 | 1525 |
1526 | 1526 |
1527 // ES6 section 26.1.10 Reflect.isExtensible | 1527 // ES6 section 26.1.10 Reflect.isExtensible |
1528 BUILTIN(ReflectIsExtensible) { | 1528 BUILTIN(ReflectIsExtensible) { |
1529 HandleScope scope(isolate); | 1529 HandleScope scope(isolate); |
1530 DCHECK_EQ(2, args.length()); | 1530 DCHECK_EQ(2, args.length()); |
1531 Handle<Object> target = args.at<Object>(1); | 1531 Handle<Object> target = args.at<Object>(1); |
1532 | 1532 |
1533 if (!target->IsJSReceiver()) { | 1533 if (!target->IsJSReceiver()) { |
(...skipping 13 matching lines...) Expand all Loading... |
1547 */ | 1547 */ |
1548 | 1548 |
1549 if (target->IsJSObject()) { | 1549 if (target->IsJSObject()) { |
1550 return *isolate->factory()->ToBoolean( | 1550 return *isolate->factory()->ToBoolean( |
1551 JSObject::IsExtensible(Handle<JSObject>::cast(target))); | 1551 JSObject::IsExtensible(Handle<JSObject>::cast(target))); |
1552 } | 1552 } |
1553 return *isolate->factory()->false_value(); | 1553 return *isolate->factory()->false_value(); |
1554 } | 1554 } |
1555 | 1555 |
1556 | 1556 |
| 1557 // ES6 section 26.1.12 Reflect.preventExtensions |
| 1558 BUILTIN(ReflectPreventExtensions) { |
| 1559 HandleScope scope(isolate); |
| 1560 DCHECK_EQ(2, args.length()); |
| 1561 Handle<Object> target = args.at<Object>(1); |
| 1562 |
| 1563 if (!target->IsJSReceiver()) { |
| 1564 THROW_NEW_ERROR_RETURN_FAILURE( |
| 1565 isolate, NewTypeError(MessageTemplate::kCalledOnNonObject, |
| 1566 isolate->factory()->NewStringFromAsciiChecked( |
| 1567 "Reflect.preventExtensions"))); |
| 1568 } |
| 1569 |
| 1570 Maybe<bool> result = JSReceiver::PreventExtensions( |
| 1571 Handle<JSReceiver>::cast(target), DONT_THROW); |
| 1572 return result.IsJust() ? *isolate->factory()->ToBoolean(result.FromJust()) |
| 1573 : isolate->heap()->exception(); |
| 1574 } |
| 1575 |
| 1576 |
1557 // ES6 section 20.3.4.45 Date.prototype [ @@toPrimitive ] ( hint ) | 1577 // ES6 section 20.3.4.45 Date.prototype [ @@toPrimitive ] ( hint ) |
1558 BUILTIN(DateToPrimitive) { | 1578 BUILTIN(DateToPrimitive) { |
1559 HandleScope scope(isolate); | 1579 HandleScope scope(isolate); |
1560 DCHECK_EQ(2, args.length()); | 1580 DCHECK_EQ(2, args.length()); |
1561 if (!args.receiver()->IsJSReceiver()) { | 1581 if (!args.receiver()->IsJSReceiver()) { |
1562 THROW_NEW_ERROR_RETURN_FAILURE( | 1582 THROW_NEW_ERROR_RETURN_FAILURE( |
1563 isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, | 1583 isolate, NewTypeError(MessageTemplate::kIncompatibleMethodReceiver, |
1564 isolate->factory()->NewStringFromAsciiChecked( | 1584 isolate->factory()->NewStringFromAsciiChecked( |
1565 "Date.prototype [ @@toPrimitive ]"), | 1585 "Date.prototype [ @@toPrimitive ]"), |
1566 args.receiver())); | 1586 args.receiver())); |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2199 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 2219 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
2200 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 2220 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
2201 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 2221 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
2202 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 2222 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
2203 #undef DEFINE_BUILTIN_ACCESSOR_C | 2223 #undef DEFINE_BUILTIN_ACCESSOR_C |
2204 #undef DEFINE_BUILTIN_ACCESSOR_A | 2224 #undef DEFINE_BUILTIN_ACCESSOR_A |
2205 | 2225 |
2206 | 2226 |
2207 } // namespace internal | 2227 } // namespace internal |
2208 } // namespace v8 | 2228 } // namespace v8 |
OLD | NEW |