| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
| 9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
| 10 #include "src/messages.h" | 10 #include "src/messages.h" |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 LanguageMode language_mode = language_mode_arg; | 664 LanguageMode language_mode = language_mode_arg; |
| 665 | 665 |
| 666 Handle<Object> result; | 666 Handle<Object> result; |
| 667 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 667 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 668 isolate, result, | 668 isolate, result, |
| 669 Runtime::SetObjectProperty(isolate, object, key, value, language_mode)); | 669 Runtime::SetObjectProperty(isolate, object, key, value, language_mode)); |
| 670 return *result; | 670 return *result; |
| 671 } | 671 } |
| 672 | 672 |
| 673 | 673 |
| 674 RUNTIME_FUNCTION(Runtime_DeleteProperty) { | 674 namespace { |
| 675 HandleScope scope(isolate); | 675 |
| 676 DCHECK(args.length() == 3); | 676 // ES6 section 12.5.4. |
| 677 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | 677 Object* DeleteProperty(Isolate* isolate, Handle<Object> object, |
| 678 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 678 Handle<Object> key, LanguageMode language_mode) { |
| 679 CONVERT_LANGUAGE_MODE_ARG_CHECKED(language_mode, 2); | 679 Handle<JSReceiver> receiver; |
| 680 if (!JSReceiver::ToObject(isolate, object).ToHandle(&receiver)) { |
| 681 THROW_NEW_ERROR_RETURN_FAILURE( |
| 682 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject)); |
| 683 } |
| 680 Handle<Object> result; | 684 Handle<Object> result; |
| 681 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 685 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 682 isolate, result, | 686 isolate, result, |
| 683 Runtime::DeleteObjectProperty(isolate, receiver, key, language_mode)); | 687 Runtime::DeleteObjectProperty(isolate, receiver, key, language_mode)); |
| 684 return *result; | 688 return *result; |
| 685 } | 689 } |
| 686 | 690 |
| 691 } // namespace |
| 692 |
| 693 |
| 694 RUNTIME_FUNCTION(Runtime_DeleteProperty_Sloppy) { |
| 695 HandleScope scope(isolate); |
| 696 DCHECK_EQ(2, args.length()); |
| 697 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 698 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 699 return DeleteProperty(isolate, object, key, SLOPPY); |
| 700 } |
| 701 |
| 702 |
| 703 RUNTIME_FUNCTION(Runtime_DeleteProperty_Strict) { |
| 704 HandleScope scope(isolate); |
| 705 DCHECK_EQ(2, args.length()); |
| 706 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 707 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
| 708 return DeleteProperty(isolate, object, key, STRICT); |
| 709 } |
| 710 |
| 687 | 711 |
| 688 static Object* HasOwnPropertyImplementation(Isolate* isolate, | 712 static Object* HasOwnPropertyImplementation(Isolate* isolate, |
| 689 Handle<JSObject> object, | 713 Handle<JSObject> object, |
| 690 Handle<Name> key) { | 714 Handle<Name> key) { |
| 691 Maybe<bool> maybe = JSReceiver::HasOwnProperty(object, key); | 715 Maybe<bool> maybe = JSReceiver::HasOwnProperty(object, key); |
| 692 if (!maybe.IsJust()) return isolate->heap()->exception(); | 716 if (!maybe.IsJust()) return isolate->heap()->exception(); |
| 693 if (maybe.FromJust()) return isolate->heap()->true_value(); | 717 if (maybe.FromJust()) return isolate->heap()->true_value(); |
| 694 // Handle hidden prototypes. If there's a hidden prototype above this thing | 718 // Handle hidden prototypes. If there's a hidden prototype above this thing |
| 695 // then we have to check it for properties, because they are supposed to | 719 // then we have to check it for properties, because they are supposed to |
| 696 // look like they are on this object. | 720 // look like they are on this object. |
| (...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1437 Handle<JSReceiver> receiver; | 1461 Handle<JSReceiver> receiver; |
| 1438 if (JSReceiver::ToObject(isolate, object).ToHandle(&receiver)) { | 1462 if (JSReceiver::ToObject(isolate, object).ToHandle(&receiver)) { |
| 1439 return *receiver; | 1463 return *receiver; |
| 1440 } | 1464 } |
| 1441 THROW_NEW_ERROR_RETURN_FAILURE( | 1465 THROW_NEW_ERROR_RETURN_FAILURE( |
| 1442 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject)); | 1466 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject)); |
| 1443 } | 1467 } |
| 1444 | 1468 |
| 1445 } // namespace internal | 1469 } // namespace internal |
| 1446 } // namespace v8 | 1470 } // namespace v8 |
| OLD | NEW |