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 3643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3654 return true; | 3654 return true; |
3655 } | 3655 } |
3656 | 3656 |
3657 | 3657 |
3658 namespace { | 3658 namespace { |
3659 | 3659 |
3660 i::MaybeHandle<i::Object> DeleteObjectProperty( | 3660 i::MaybeHandle<i::Object> DeleteObjectProperty( |
3661 i::Isolate* isolate, i::Handle<i::JSReceiver> receiver, | 3661 i::Isolate* isolate, i::Handle<i::JSReceiver> receiver, |
3662 i::Handle<i::Object> key, i::LanguageMode language_mode) { | 3662 i::Handle<i::Object> key, i::LanguageMode language_mode) { |
3663 // Check if the given key is an array index. | 3663 // Check if the given key is an array index. |
3664 uint32_t index; | 3664 uint32_t index = 0; |
3665 if (key->ToArrayIndex(&index)) { | 3665 if (key->ToArrayIndex(&index)) { |
3666 // In Firefox/SpiderMonkey, Safari and Opera you can access the | 3666 // In Firefox/SpiderMonkey, Safari and Opera you can access the |
3667 // characters of a string using [] notation. In the case of a | 3667 // characters of a string using [] notation. In the case of a |
3668 // String object we just need to redirect the deletion to the | 3668 // String object we just need to redirect the deletion to the |
3669 // underlying string if the index is in range. Since the | 3669 // underlying string if the index is in range. Since the |
3670 // underlying string does nothing with the deletion, we can ignore | 3670 // underlying string does nothing with the deletion, we can ignore |
3671 // such deletions. | 3671 // such deletions. |
3672 if (receiver->IsStringObjectWithCharacterAt(index)) { | 3672 if (receiver->IsStringObjectWithCharacterAt(index)) { |
3673 return isolate->factory()->false_value(); | 3673 return isolate->factory()->false_value(); |
3674 } | 3674 } |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3965 return Delete(context, key).FromMaybe(false); | 3965 return Delete(context, key).FromMaybe(false); |
3966 } | 3966 } |
3967 | 3967 |
3968 | 3968 |
3969 Maybe<bool> v8::Object::Has(Local<Context> context, Local<Value> key) { | 3969 Maybe<bool> v8::Object::Has(Local<Context> context, Local<Value> key) { |
3970 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Get()", bool); | 3970 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Get()", bool); |
3971 auto self = Utils::OpenHandle(this); | 3971 auto self = Utils::OpenHandle(this); |
3972 auto key_obj = Utils::OpenHandle(*key); | 3972 auto key_obj = Utils::OpenHandle(*key); |
3973 Maybe<bool> maybe = Nothing<bool>(); | 3973 Maybe<bool> maybe = Nothing<bool>(); |
3974 // Check if the given key is an array index. | 3974 // Check if the given key is an array index. |
3975 uint32_t index; | 3975 uint32_t index = 0; |
3976 if (key_obj->ToArrayIndex(&index)) { | 3976 if (key_obj->ToArrayIndex(&index)) { |
3977 maybe = i::JSReceiver::HasElement(self, index); | 3977 maybe = i::JSReceiver::HasElement(self, index); |
3978 } else { | 3978 } else { |
3979 // Convert the key to a name - possibly by calling back into JavaScript. | 3979 // Convert the key to a name - possibly by calling back into JavaScript. |
3980 i::Handle<i::Name> name; | 3980 i::Handle<i::Name> name; |
3981 if (i::Runtime::ToName(isolate, key_obj).ToHandle(&name)) { | 3981 if (i::Runtime::ToName(isolate, key_obj).ToHandle(&name)) { |
3982 maybe = i::JSReceiver::HasProperty(self, name); | 3982 maybe = i::JSReceiver::HasProperty(self, name); |
3983 } | 3983 } |
3984 } | 3984 } |
3985 has_pending_exception = maybe.IsNothing(); | 3985 has_pending_exception = maybe.IsNothing(); |
(...skipping 4400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8386 Address callback_address = | 8386 Address callback_address = |
8387 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8387 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8388 VMState<EXTERNAL> state(isolate); | 8388 VMState<EXTERNAL> state(isolate); |
8389 ExternalCallbackScope call_scope(isolate, callback_address); | 8389 ExternalCallbackScope call_scope(isolate, callback_address); |
8390 callback(info); | 8390 callback(info); |
8391 } | 8391 } |
8392 | 8392 |
8393 | 8393 |
8394 } // namespace internal | 8394 } // namespace internal |
8395 } // namespace v8 | 8395 } // namespace v8 |
OLD | NEW |