HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Nougat 7.0
|
7.0.0_r31
下载
查看原文件
收藏
根目录
external
v8
src
messages.cc
// Copyright 2011 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/messages.h" #include "src/api.h" #include "src/execution.h" #include "src/isolate-inl.h" #include "src/string-builder.h" namespace v8 { namespace internal { // If no message listeners have been registered this one is called // by default. void MessageHandler::DefaultMessageReport(Isolate* isolate, const MessageLocation* loc, Handle
message_obj) { base::SmartArrayPointer
str = GetLocalizedMessage(isolate, message_obj); if (loc == NULL) { PrintF("%s\n", str.get()); } else { HandleScope scope(isolate); Handle
data(loc->script()->name(), isolate); base::SmartArrayPointer
data_str; if (data->IsString()) data_str = Handle
::cast(data)->ToCString(DISALLOW_NULLS); PrintF("%s:%i: %s\n", data_str.get() ? data_str.get() : "
", loc->start_pos(), str.get()); } } Handle
MessageHandler::MakeMessageObject( Isolate* isolate, MessageTemplate::Template message, MessageLocation* location, Handle
argument, Handle
stack_frames) { Factory* factory = isolate->factory(); int start = -1; int end = -1; Handle
script_handle = factory->undefined_value(); if (location != NULL) { start = location->start_pos(); end = location->end_pos(); script_handle = Script::GetWrapper(location->script()); } else { script_handle = Script::GetWrapper(isolate->factory()->empty_script()); } Handle
stack_frames_handle = stack_frames.is_null() ? Handle
::cast(factory->undefined_value()) : Handle
::cast(stack_frames); Handle
message_obj = factory->NewJSMessageObject( message, argument, start, end, script_handle, stack_frames_handle); return message_obj; } void MessageHandler::ReportMessage(Isolate* isolate, MessageLocation* loc, Handle
message) { // We are calling into embedder's code which can throw exceptions. // Thus we need to save current exception state, reset it to the clean one // and ignore scheduled exceptions callbacks can throw. // We pass the exception object into the message handler callback though. Object* exception_object = isolate->heap()->undefined_value(); if (isolate->has_pending_exception()) { exception_object = isolate->pending_exception(); } Handle
exception(exception_object, isolate); Isolate::ExceptionScope exception_scope(isolate); isolate->clear_pending_exception(); isolate->set_external_caught_exception(false); // Turn the exception on the message into a string if it is an object. if (message->argument()->IsJSObject()) { HandleScope scope(isolate); Handle
argument(message->argument(), isolate); MaybeHandle
maybe_stringified; Handle
stringified; // Make sure we don't leak uncaught internally generated Error objects. if (Object::IsErrorObject(isolate, argument)) { Handle
args[] = {argument}; maybe_stringified = Execution::TryCall( isolate, isolate->no_side_effects_to_string_fun(), isolate->factory()->undefined_value(), arraysize(args), args); } else { v8::TryCatch catcher(reinterpret_cast
(isolate)); catcher.SetVerbose(false); catcher.SetCaptureMessage(false); maybe_stringified = Object::ToString(isolate, argument); } if (!maybe_stringified.ToHandle(&stringified)) { stringified = isolate->factory()->NewStringFromAsciiChecked("exception"); } message->set_argument(*stringified); } v8::Local
api_message_obj = v8::Utils::MessageToLocal(message); v8::Local
api_exception_obj = v8::Utils::ToLocal(exception); v8::NeanderArray global_listeners(isolate->factory()->message_listeners()); int global_length = global_listeners.length(); if (global_length == 0) { DefaultMessageReport(isolate, loc, message); if (isolate->has_scheduled_exception()) { isolate->clear_scheduled_exception(); } } else { for (int i = 0; i < global_length; i++) { HandleScope scope(isolate); if (global_listeners.get(i)->IsUndefined()) continue; v8::NeanderObject listener(JSObject::cast(global_listeners.get(i))); Handle
callback_obj(Foreign::cast(listener.get(0))); v8::MessageCallback callback = FUNCTION_CAST
(callback_obj->foreign_address()); Handle
callback_data(listener.get(1), isolate); { // Do not allow exceptions to propagate. v8::TryCatch try_catch(reinterpret_cast
(isolate)); callback(api_message_obj, callback_data->IsUndefined() ? api_exception_obj : v8::Utils::ToLocal(callback_data)); } if (isolate->has_scheduled_exception()) { isolate->clear_scheduled_exception(); } } } } Handle
MessageHandler::GetMessage(Isolate* isolate, Handle
data) { Handle
message = Handle
::cast(data); Handle
arg = Handle
(message->argument(), isolate); return MessageTemplate::FormatMessage(isolate, message->type(), arg); } base::SmartArrayPointer
MessageHandler::GetLocalizedMessage( Isolate* isolate, Handle
data) { HandleScope scope(isolate); return GetMessage(isolate, data)->ToCString(DISALLOW_NULLS); } CallSite::CallSite(Isolate* isolate, Handle
call_site_obj) : isolate_(isolate) { Handle
maybe_function = JSObject::GetDataProperty( call_site_obj, isolate->factory()->call_site_function_symbol()); if (!maybe_function->IsJSFunction()) return; fun_ = Handle
::cast(maybe_function); receiver_ = JSObject::GetDataProperty( call_site_obj, isolate->factory()->call_site_receiver_symbol()); CHECK(JSObject::GetDataProperty( call_site_obj, isolate->factory()->call_site_position_symbol()) ->ToInt32(&pos_)); } Handle
CallSite::GetFileName() { Handle
script(fun_->shared()->script(), isolate_); if (script->IsScript()) { return Handle
(Handle
登录后可以享受更多权益
您还没有登录,登录后您可以:
收藏Android系统代码
收藏喜欢的文章
多个平台共享账号
去登录
首次使用?从这里
注册