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 3065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3076 | 3076 |
3077 | 3077 |
3078 bool v8::Object::SetPrivate(v8::Handle<Private> key, v8::Handle<Value> value) { | 3078 bool v8::Object::SetPrivate(v8::Handle<Private> key, v8::Handle<Value> value) { |
3079 return ForceSet(v8::Handle<Value>(reinterpret_cast<Value*>(*key)), | 3079 return ForceSet(v8::Handle<Value>(reinterpret_cast<Value*>(*key)), |
3080 value, DontEnum); | 3080 value, DontEnum); |
3081 } | 3081 } |
3082 | 3082 |
3083 | 3083 |
3084 i::MaybeHandle<i::Object> DeleteObjectProperty( | 3084 i::MaybeHandle<i::Object> DeleteObjectProperty( |
3085 i::Isolate* isolate, i::Handle<i::JSReceiver> receiver, | 3085 i::Isolate* isolate, i::Handle<i::JSReceiver> receiver, |
3086 i::Handle<i::Object> key, i::StrictMode strict_mode) { | 3086 i::Handle<i::Object> key, i::LanguageMode language_mode) { |
3087 // Check if the given key is an array index. | 3087 // Check if the given key is an array index. |
3088 uint32_t index; | 3088 uint32_t index; |
3089 if (key->ToArrayIndex(&index)) { | 3089 if (key->ToArrayIndex(&index)) { |
3090 // In Firefox/SpiderMonkey, Safari and Opera you can access the | 3090 // In Firefox/SpiderMonkey, Safari and Opera you can access the |
3091 // characters of a string using [] notation. In the case of a | 3091 // characters of a string using [] notation. In the case of a |
3092 // String object we just need to redirect the deletion to the | 3092 // String object we just need to redirect the deletion to the |
3093 // underlying string if the index is in range. Since the | 3093 // underlying string if the index is in range. Since the |
3094 // underlying string does nothing with the deletion, we can ignore | 3094 // underlying string does nothing with the deletion, we can ignore |
3095 // such deletions. | 3095 // such deletions. |
3096 if (receiver->IsStringObjectWithCharacterAt(index)) { | 3096 if (receiver->IsStringObjectWithCharacterAt(index)) { |
3097 return isolate->factory()->true_value(); | 3097 return isolate->factory()->true_value(); |
3098 } | 3098 } |
3099 | 3099 |
3100 return i::JSReceiver::DeleteElement(receiver, index, strict_mode); | 3100 return i::JSReceiver::DeleteElement(receiver, index, language_mode); |
3101 } | 3101 } |
3102 | 3102 |
3103 i::Handle<i::Name> name; | 3103 i::Handle<i::Name> name; |
3104 if (key->IsName()) { | 3104 if (key->IsName()) { |
3105 name = i::Handle<i::Name>::cast(key); | 3105 name = i::Handle<i::Name>::cast(key); |
3106 } else { | 3106 } else { |
3107 // Call-back into JavaScript to convert the key to a string. | 3107 // Call-back into JavaScript to convert the key to a string. |
3108 i::Handle<i::Object> converted; | 3108 i::Handle<i::Object> converted; |
3109 if (!i::Execution::ToString(isolate, key).ToHandle(&converted)) { | 3109 if (!i::Execution::ToString(isolate, key).ToHandle(&converted)) { |
3110 return i::MaybeHandle<i::Object>(); | 3110 return i::MaybeHandle<i::Object>(); |
3111 } | 3111 } |
3112 name = i::Handle<i::String>::cast(converted); | 3112 name = i::Handle<i::String>::cast(converted); |
3113 } | 3113 } |
3114 | 3114 |
3115 if (name->IsString()) { | 3115 if (name->IsString()) { |
3116 name = i::String::Flatten(i::Handle<i::String>::cast(name)); | 3116 name = i::String::Flatten(i::Handle<i::String>::cast(name)); |
3117 } | 3117 } |
3118 return i::JSReceiver::DeleteProperty(receiver, name, strict_mode); | 3118 return i::JSReceiver::DeleteProperty(receiver, name, language_mode); |
3119 } | 3119 } |
3120 | 3120 |
3121 | 3121 |
3122 Local<Value> v8::Object::Get(v8::Handle<Value> key) { | 3122 Local<Value> v8::Object::Get(v8::Handle<Value> key) { |
3123 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3123 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3124 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>()); | 3124 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>()); |
3125 ENTER_V8(isolate); | 3125 ENTER_V8(isolate); |
3126 i::Handle<i::Object> self = Utils::OpenHandle(this); | 3126 i::Handle<i::Object> self = Utils::OpenHandle(this); |
3127 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 3127 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
3128 EXCEPTION_PREAMBLE(isolate); | 3128 EXCEPTION_PREAMBLE(isolate); |
(...skipping 4506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7635 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7635 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7636 Address callback_address = | 7636 Address callback_address = |
7637 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7637 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7638 VMState<EXTERNAL> state(isolate); | 7638 VMState<EXTERNAL> state(isolate); |
7639 ExternalCallbackScope call_scope(isolate, callback_address); | 7639 ExternalCallbackScope call_scope(isolate, callback_address); |
7640 callback(info); | 7640 callback(info); |
7641 } | 7641 } |
7642 | 7642 |
7643 | 7643 |
7644 } } // namespace v8::internal | 7644 } } // namespace v8::internal |
OLD | NEW |