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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 Isolate::ExceptionScope exception_scope(isolate); | 77 Isolate::ExceptionScope exception_scope(isolate); |
78 isolate->clear_pending_exception(); | 78 isolate->clear_pending_exception(); |
79 isolate->set_external_caught_exception(false); | 79 isolate->set_external_caught_exception(false); |
80 | 80 |
81 // Turn the exception on the message into a string if it is an object. | 81 // Turn the exception on the message into a string if it is an object. |
82 if (message->argument()->IsJSObject()) { | 82 if (message->argument()->IsJSObject()) { |
83 HandleScope scope(isolate); | 83 HandleScope scope(isolate); |
84 Handle<Object> argument(message->argument(), isolate); | 84 Handle<Object> argument(message->argument(), isolate); |
85 Handle<Object> args[] = {argument}; | 85 Handle<Object> args[] = {argument}; |
86 MaybeHandle<Object> maybe_stringified = Execution::TryCall( | 86 MaybeHandle<Object> maybe_stringified = Execution::TryCall( |
87 isolate->to_detail_string_fun(), isolate->factory()->undefined_value(), | 87 isolate, isolate->to_detail_string_fun(), |
88 arraysize(args), args); | 88 isolate->factory()->undefined_value(), arraysize(args), args); |
89 Handle<Object> stringified; | 89 Handle<Object> stringified; |
90 if (!maybe_stringified.ToHandle(&stringified)) { | 90 if (!maybe_stringified.ToHandle(&stringified)) { |
91 stringified = isolate->factory()->NewStringFromAsciiChecked("exception"); | 91 stringified = isolate->factory()->NewStringFromAsciiChecked("exception"); |
92 } | 92 } |
93 message->set_argument(*stringified); | 93 message->set_argument(*stringified); |
94 } | 94 } |
95 | 95 |
96 v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message); | 96 v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message); |
97 v8::Local<v8::Value> api_exception_obj = v8::Utils::ToLocal(exception); | 97 v8::Local<v8::Value> api_exception_obj = v8::Utils::ToLocal(exception); |
98 | 98 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 int template_index, | 312 int template_index, |
313 Handle<Object> arg) { | 313 Handle<Object> arg) { |
314 Factory* factory = isolate->factory(); | 314 Factory* factory = isolate->factory(); |
315 Handle<String> result_string; | 315 Handle<String> result_string; |
316 if (arg->IsString()) { | 316 if (arg->IsString()) { |
317 result_string = Handle<String>::cast(arg); | 317 result_string = Handle<String>::cast(arg); |
318 } else { | 318 } else { |
319 Handle<JSFunction> fun = isolate->no_side_effect_to_string_fun(); | 319 Handle<JSFunction> fun = isolate->no_side_effect_to_string_fun(); |
320 | 320 |
321 MaybeHandle<Object> maybe_result = | 321 MaybeHandle<Object> maybe_result = |
322 Execution::TryCall(fun, factory->undefined_value(), 1, &arg); | 322 Execution::TryCall(isolate, fun, factory->undefined_value(), 1, &arg); |
323 Handle<Object> result; | 323 Handle<Object> result; |
324 if (!maybe_result.ToHandle(&result) || !result->IsString()) { | 324 if (!maybe_result.ToHandle(&result) || !result->IsString()) { |
325 return factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("<error>")); | 325 return factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("<error>")); |
326 } | 326 } |
327 result_string = Handle<String>::cast(result); | 327 result_string = Handle<String>::cast(result); |
328 } | 328 } |
329 MaybeHandle<String> maybe_result_string = MessageTemplate::FormatMessage( | 329 MaybeHandle<String> maybe_result_string = MessageTemplate::FormatMessage( |
330 template_index, result_string, factory->empty_string(), | 330 template_index, result_string, factory->empty_string(), |
331 factory->empty_string()); | 331 factory->empty_string()); |
332 if (!maybe_result_string.ToHandle(&result_string)) { | 332 if (!maybe_result_string.ToHandle(&result_string)) { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 if (obj->IsUndefined()) return default_value; | 474 if (obj->IsUndefined()) return default_value; |
475 if (!obj->IsString()) { | 475 if (!obj->IsString()) { |
476 ASSIGN_RETURN_ON_EXCEPTION(isolate, obj, Object::ToString(isolate, obj), | 476 ASSIGN_RETURN_ON_EXCEPTION(isolate, obj, Object::ToString(isolate, obj), |
477 String); | 477 String); |
478 } | 478 } |
479 return Handle<String>::cast(obj); | 479 return Handle<String>::cast(obj); |
480 } | 480 } |
481 | 481 |
482 } // namespace internal | 482 } // namespace internal |
483 } // namespace v8 | 483 } // namespace v8 |
OLD | NEW |