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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.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/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 String::Flatten(str)->Get(index)); | 111 String::Flatten(str)->Get(index)); |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 // Fall back to GetObjectProperty. | 115 // Fall back to GetObjectProperty. |
116 return Runtime::GetObjectProperty(isolate, receiver_obj, key_obj, | 116 return Runtime::GetObjectProperty(isolate, receiver_obj, key_obj, |
117 language_mode); | 117 language_mode); |
118 } | 118 } |
119 | 119 |
120 | 120 |
121 MaybeHandle<Object> Runtime::DeleteObjectProperty(Isolate* isolate, | 121 Maybe<bool> Runtime::DeleteObjectProperty(Isolate* isolate, |
122 Handle<JSReceiver> receiver, | 122 Handle<JSReceiver> receiver, |
123 Handle<Object> key, | 123 Handle<Object> key, |
124 LanguageMode language_mode) { | 124 LanguageMode language_mode) { |
125 bool success = false; | 125 bool success = false; |
126 LookupIterator it = LookupIterator::PropertyOrElement( | 126 LookupIterator it = LookupIterator::PropertyOrElement( |
127 isolate, receiver, key, &success, LookupIterator::HIDDEN); | 127 isolate, receiver, key, &success, LookupIterator::HIDDEN); |
128 if (!success) return MaybeHandle<Object>(); | 128 if (!success) return Nothing<bool>(); |
129 | 129 |
130 return JSReceiver::DeleteProperty(&it, language_mode); | 130 return JSReceiver::DeleteProperty(&it, language_mode); |
131 } | 131 } |
132 | 132 |
133 | 133 |
134 MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, | 134 MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, |
135 Handle<Object> object, | 135 Handle<Object> object, |
136 Handle<Object> key, | 136 Handle<Object> key, |
137 Handle<Object> value, | 137 Handle<Object> value, |
138 LanguageMode language_mode) { | 138 LanguageMode language_mode) { |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 namespace { | 611 namespace { |
612 | 612 |
613 // ES6 section 12.5.4. | 613 // ES6 section 12.5.4. |
614 Object* DeleteProperty(Isolate* isolate, Handle<Object> object, | 614 Object* DeleteProperty(Isolate* isolate, Handle<Object> object, |
615 Handle<Object> key, LanguageMode language_mode) { | 615 Handle<Object> key, LanguageMode language_mode) { |
616 Handle<JSReceiver> receiver; | 616 Handle<JSReceiver> receiver; |
617 if (!JSReceiver::ToObject(isolate, object).ToHandle(&receiver)) { | 617 if (!JSReceiver::ToObject(isolate, object).ToHandle(&receiver)) { |
618 THROW_NEW_ERROR_RETURN_FAILURE( | 618 THROW_NEW_ERROR_RETURN_FAILURE( |
619 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject)); | 619 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject)); |
620 } | 620 } |
621 Handle<Object> result; | 621 Maybe<bool> result = |
622 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 622 Runtime::DeleteObjectProperty(isolate, receiver, key, language_mode); |
623 isolate, result, | 623 MAYBE_RETURN(result, isolate->heap()->exception()); |
624 Runtime::DeleteObjectProperty(isolate, receiver, key, language_mode)); | 624 return isolate->heap()->ToBoolean(result.FromJust()); |
625 return *result; | |
626 } | 625 } |
627 | 626 |
628 } // namespace | 627 } // namespace |
629 | 628 |
630 | 629 |
631 RUNTIME_FUNCTION(Runtime_DeleteProperty_Sloppy) { | 630 RUNTIME_FUNCTION(Runtime_DeleteProperty_Sloppy) { |
632 HandleScope scope(isolate); | 631 HandleScope scope(isolate); |
633 DCHECK_EQ(2, args.length()); | 632 DCHECK_EQ(2, args.length()); |
634 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 633 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
635 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 634 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1583 | 1582 |
1584 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) { | 1583 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) { |
1585 HandleScope scope(isolate); | 1584 HandleScope scope(isolate); |
1586 DCHECK(args.length() == 2); | 1585 DCHECK(args.length() == 2); |
1587 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); | 1586 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); |
1588 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); | 1587 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); |
1589 return JSReceiver::DefineProperties(isolate, o, properties); | 1588 return JSReceiver::DefineProperties(isolate, o, properties); |
1590 } | 1589 } |
1591 } // namespace internal | 1590 } // namespace internal |
1592 } // namespace v8 | 1591 } // namespace v8 |
OLD | NEW |