| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/messages.h" | 5 #include "src/messages.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/execution.h" | 8 #include "src/execution.h" |
| 9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
| 10 #include "src/string-builder.h" | 10 #include "src/string-builder.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 v8::Local<v8::Value> api_exception_obj = v8::Utils::ToLocal(exception); | 109 v8::Local<v8::Value> api_exception_obj = v8::Utils::ToLocal(exception); |
| 110 | 110 |
| 111 v8::NeanderArray global_listeners(isolate->factory()->message_listeners()); | 111 v8::NeanderArray global_listeners(isolate->factory()->message_listeners()); |
| 112 int global_length = global_listeners.length(); | 112 int global_length = global_listeners.length(); |
| 113 if (global_length == 0) { | 113 if (global_length == 0) { |
| 114 DefaultMessageReport(isolate, loc, message); | 114 DefaultMessageReport(isolate, loc, message); |
| 115 if (isolate->has_scheduled_exception()) { | 115 if (isolate->has_scheduled_exception()) { |
| 116 isolate->clear_scheduled_exception(); | 116 isolate->clear_scheduled_exception(); |
| 117 } | 117 } |
| 118 } else { | 118 } else { |
| 119 for (int i = 0; i < global_length; i++) { | 119 FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < global_length, i++, { |
| 120 HandleScope scope(isolate); | |
| 121 if (global_listeners.get(i)->IsUndefined()) continue; | 120 if (global_listeners.get(i)->IsUndefined()) continue; |
| 122 v8::NeanderObject listener(JSObject::cast(global_listeners.get(i))); | 121 v8::NeanderObject listener(JSObject::cast(global_listeners.get(i))); |
| 123 Handle<Foreign> callback_obj(Foreign::cast(listener.get(0))); | 122 Handle<Foreign> callback_obj(Foreign::cast(listener.get(0))); |
| 124 v8::MessageCallback callback = | 123 v8::MessageCallback callback = |
| 125 FUNCTION_CAST<v8::MessageCallback>(callback_obj->foreign_address()); | 124 FUNCTION_CAST<v8::MessageCallback>(callback_obj->foreign_address()); |
| 126 Handle<Object> callback_data(listener.get(1), isolate); | 125 Handle<Object> callback_data(listener.get(1), isolate); |
| 127 { | 126 { |
| 128 // Do not allow exceptions to propagate. | 127 // Do not allow exceptions to propagate. |
| 129 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); | 128 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); |
| 130 callback(api_message_obj, callback_data->IsUndefined() | 129 callback(api_message_obj, callback_data->IsUndefined() |
| 131 ? api_exception_obj | 130 ? api_exception_obj |
| 132 : v8::Utils::ToLocal(callback_data)); | 131 : v8::Utils::ToLocal(callback_data)); |
| 133 } | 132 } |
| 134 if (isolate->has_scheduled_exception()) { | 133 if (isolate->has_scheduled_exception()) { |
| 135 isolate->clear_scheduled_exception(); | 134 isolate->clear_scheduled_exception(); |
| 136 } | 135 } |
| 137 } | 136 }); |
| 138 } | 137 } |
| 139 } | 138 } |
| 140 | 139 |
| 141 | 140 |
| 142 Handle<String> MessageHandler::GetMessage(Isolate* isolate, | 141 Handle<String> MessageHandler::GetMessage(Isolate* isolate, |
| 143 Handle<Object> data) { | 142 Handle<Object> data) { |
| 144 Handle<JSMessageObject> message = Handle<JSMessageObject>::cast(data); | 143 Handle<JSMessageObject> message = Handle<JSMessageObject>::cast(data); |
| 145 Handle<Object> arg = Handle<Object>(message->argument(), isolate); | 144 Handle<Object> arg = Handle<Object>(message->argument(), isolate); |
| 146 return MessageTemplate::FormatMessage(isolate, message->type(), arg); | 145 return MessageTemplate::FormatMessage(isolate, message->type(), arg); |
| 147 } | 146 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 HandleScope outer_scope(isolate_); | 254 HandleScope outer_scope(isolate_); |
| 256 Handle<Object> result; | 255 Handle<Object> result; |
| 257 for (PrototypeIterator iter(isolate_, obj, | 256 for (PrototypeIterator iter(isolate_, obj, |
| 258 PrototypeIterator::START_AT_RECEIVER); | 257 PrototypeIterator::START_AT_RECEIVER); |
| 259 !iter.IsAtEnd(); iter.Advance()) { | 258 !iter.IsAtEnd(); iter.Advance()) { |
| 260 Handle<Object> current = PrototypeIterator::GetCurrent(iter); | 259 Handle<Object> current = PrototypeIterator::GetCurrent(iter); |
| 261 if (!current->IsJSObject()) break; | 260 if (!current->IsJSObject()) break; |
| 262 Handle<JSObject> current_obj = Handle<JSObject>::cast(current); | 261 Handle<JSObject> current_obj = Handle<JSObject>::cast(current); |
| 263 if (current_obj->IsAccessCheckNeeded()) break; | 262 if (current_obj->IsAccessCheckNeeded()) break; |
| 264 Handle<FixedArray> keys = JSObject::GetEnumPropertyKeys(current_obj); | 263 Handle<FixedArray> keys = JSObject::GetEnumPropertyKeys(current_obj); |
| 265 for (int i = 0; i < keys->length(); i++) { | 264 FOR_WITH_HANDLE_SCOPE(isolate_, int, i = 0, i, i < keys->length(), i++, { |
| 266 HandleScope inner_scope(isolate_); | |
| 267 if (!keys->get(i)->IsName()) continue; | 265 if (!keys->get(i)->IsName()) continue; |
| 268 Handle<Name> name_key(Name::cast(keys->get(i)), isolate_); | 266 Handle<Name> name_key(Name::cast(keys->get(i)), isolate_); |
| 269 if (!CheckMethodName(isolate_, current_obj, name_key, fun_, | 267 if (!CheckMethodName(isolate_, current_obj, name_key, fun_, |
| 270 LookupIterator::OWN_SKIP_INTERCEPTOR)) | 268 LookupIterator::OWN_SKIP_INTERCEPTOR)) |
| 271 continue; | 269 continue; |
| 272 // Return null in case of duplicates to avoid confusion. | 270 // Return null in case of duplicates to avoid confusion. |
| 273 if (!result.is_null()) return isolate_->factory()->null_value(); | 271 if (!result.is_null()) return isolate_->factory()->null_value(); |
| 274 result = inner_scope.CloseAndEscape(name_key); | 272 result = loop_scope.CloseAndEscape(name_key); |
| 275 } | 273 }); |
| 276 } | 274 } |
| 277 | 275 |
| 278 if (!result.is_null()) return outer_scope.CloseAndEscape(result); | 276 if (!result.is_null()) return outer_scope.CloseAndEscape(result); |
| 279 return isolate_->factory()->null_value(); | 277 return isolate_->factory()->null_value(); |
| 280 } | 278 } |
| 281 | 279 |
| 282 | 280 |
| 283 int CallSite::GetLineNumber() { | 281 int CallSite::GetLineNumber() { |
| 284 if (pos_ >= 0) { | 282 if (pos_ >= 0) { |
| 285 Handle<Object> script_obj(fun_->shared()->script(), isolate_); | 283 Handle<Object> script_obj(fun_->shared()->script(), isolate_); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 builder.AppendCharacter(*c); | 409 builder.AppendCharacter(*c); |
| 412 } | 410 } |
| 413 } | 411 } |
| 414 | 412 |
| 415 return builder.Finish(); | 413 return builder.Finish(); |
| 416 } | 414 } |
| 417 | 415 |
| 418 | 416 |
| 419 } // namespace internal | 417 } // namespace internal |
| 420 } // namespace v8 | 418 } // namespace v8 |
| OLD | NEW |