| 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/api.h" | 5 #include "src/api.h" |
| 6 | 6 |
| 7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
| 8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
| 9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
| 10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
| (...skipping 3591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3602 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 3602 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
| 3603 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); | 3603 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); |
| 3604 has_pending_exception = | 3604 has_pending_exception = |
| 3605 DefineObjectProperty(self, key_obj, value_obj, | 3605 DefineObjectProperty(self, key_obj, value_obj, |
| 3606 static_cast<PropertyAttributes>(attribs)).is_null(); | 3606 static_cast<PropertyAttributes>(attribs)).is_null(); |
| 3607 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); | 3607 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); |
| 3608 return true; | 3608 return true; |
| 3609 } | 3609 } |
| 3610 | 3610 |
| 3611 | 3611 |
| 3612 MUST_USE_RESULT | |
| 3613 static i::MaybeHandle<i::Object> DeleteObjectProperty( | |
| 3614 i::Isolate* isolate, i::Handle<i::JSReceiver> receiver, | |
| 3615 i::Handle<i::Object> key, i::LanguageMode language_mode) { | |
| 3616 // Check if the given key is an array index. | |
| 3617 uint32_t index = 0; | |
| 3618 if (key->ToArrayIndex(&index)) { | |
| 3619 return i::JSReceiver::DeleteElement(receiver, index, language_mode); | |
| 3620 } | |
| 3621 | |
| 3622 i::Handle<i::Name> name; | |
| 3623 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, name, | |
| 3624 i::Runtime::ToName(isolate, key), | |
| 3625 i::MaybeHandle<i::Object>()); | |
| 3626 | |
| 3627 return i::JSReceiver::DeletePropertyOrElement(receiver, name, language_mode); | |
| 3628 } | |
| 3629 | |
| 3630 | |
| 3631 MaybeLocal<Value> v8::Object::Get(Local<v8::Context> context, | 3612 MaybeLocal<Value> v8::Object::Get(Local<v8::Context> context, |
| 3632 Local<Value> key) { | 3613 Local<Value> key) { |
| 3633 PREPARE_FOR_EXECUTION(context, "v8::Object::Get()", Value); | 3614 PREPARE_FOR_EXECUTION(context, "v8::Object::Get()", Value); |
| 3634 auto self = Utils::OpenHandle(this); | 3615 auto self = Utils::OpenHandle(this); |
| 3635 auto key_obj = Utils::OpenHandle(*key); | 3616 auto key_obj = Utils::OpenHandle(*key); |
| 3636 i::Handle<i::Object> result; | 3617 i::Handle<i::Object> result; |
| 3637 has_pending_exception = | 3618 has_pending_exception = |
| 3638 !i::Runtime::GetObjectProperty(isolate, self, key_obj).ToHandle(&result); | 3619 !i::Runtime::GetObjectProperty(isolate, self, key_obj).ToHandle(&result); |
| 3639 RETURN_ON_FAILED_EXECUTION(Value); | 3620 RETURN_ON_FAILED_EXECUTION(Value); |
| 3640 RETURN_ESCAPED(Utils::ToLocal(result)); | 3621 RETURN_ESCAPED(Utils::ToLocal(result)); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3878 return Utils::ToLocal(name); | 3859 return Utils::ToLocal(name); |
| 3879 } | 3860 } |
| 3880 | 3861 |
| 3881 | 3862 |
| 3882 Maybe<bool> v8::Object::Delete(Local<Context> context, Local<Value> key) { | 3863 Maybe<bool> v8::Object::Delete(Local<Context> context, Local<Value> key) { |
| 3883 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Delete()", bool); | 3864 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Delete()", bool); |
| 3884 auto self = Utils::OpenHandle(this); | 3865 auto self = Utils::OpenHandle(this); |
| 3885 auto key_obj = Utils::OpenHandle(*key); | 3866 auto key_obj = Utils::OpenHandle(*key); |
| 3886 i::Handle<i::Object> obj; | 3867 i::Handle<i::Object> obj; |
| 3887 has_pending_exception = | 3868 has_pending_exception = |
| 3888 !DeleteObjectProperty(isolate, self, key_obj, i::SLOPPY).ToHandle(&obj); | 3869 !i::Runtime::DeleteObjectProperty(isolate, self, key_obj, i::SLOPPY) |
| 3870 .ToHandle(&obj); |
| 3889 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); | 3871 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 3890 return Just(obj->IsTrue()); | 3872 return Just(obj->IsTrue()); |
| 3891 } | 3873 } |
| 3892 | 3874 |
| 3893 | 3875 |
| 3894 bool v8::Object::Delete(v8::Handle<Value> key) { | 3876 bool v8::Object::Delete(v8::Handle<Value> key) { |
| 3895 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 3877 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
| 3896 return Delete(context, key).FromMaybe(false); | 3878 return Delete(context, key).FromMaybe(false); |
| 3897 } | 3879 } |
| 3898 | 3880 |
| (...skipping 4578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8477 Address callback_address = | 8459 Address callback_address = |
| 8478 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8460 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8479 VMState<EXTERNAL> state(isolate); | 8461 VMState<EXTERNAL> state(isolate); |
| 8480 ExternalCallbackScope call_scope(isolate, callback_address); | 8462 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8481 callback(info); | 8463 callback(info); |
| 8482 } | 8464 } |
| 8483 | 8465 |
| 8484 | 8466 |
| 8485 } // namespace internal | 8467 } // namespace internal |
| 8486 } // namespace v8 | 8468 } // namespace v8 |
| OLD | NEW |