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/string-builder.h" | 9 #include "src/string-builder.h" |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 base::SmartArrayPointer<char> data_str; | 26 base::SmartArrayPointer<char> data_str; |
27 if (data->IsString()) | 27 if (data->IsString()) |
28 data_str = Handle<String>::cast(data)->ToCString(DISALLOW_NULLS); | 28 data_str = Handle<String>::cast(data)->ToCString(DISALLOW_NULLS); |
29 PrintF("%s:%i: %s\n", data_str.get() ? data_str.get() : "<unknown>", | 29 PrintF("%s:%i: %s\n", data_str.get() ? data_str.get() : "<unknown>", |
30 loc->start_pos(), str.get()); | 30 loc->start_pos(), str.get()); |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 | 34 |
35 Handle<JSMessageObject> MessageHandler::MakeMessageObject( | 35 Handle<JSMessageObject> MessageHandler::MakeMessageObject( |
36 Isolate* isolate, MessageTemplate::Template message, MessageLocation* loc, | 36 Isolate* isolate, MessageTemplate::Template message, |
37 Handle<Object> argument, Handle<JSArray> stack_frames) { | 37 MessageLocation* location, Handle<Object> argument, |
| 38 Handle<JSArray> stack_frames) { |
38 Factory* factory = isolate->factory(); | 39 Factory* factory = isolate->factory(); |
39 | 40 |
40 int start = 0; | 41 int start = -1; |
41 int end = 0; | 42 int end = -1; |
42 Handle<Object> script_handle = factory->undefined_value(); | 43 Handle<Object> script_handle = factory->undefined_value(); |
43 if (loc) { | 44 if (location != NULL) { |
44 start = loc->start_pos(); | 45 start = location->start_pos(); |
45 end = loc->end_pos(); | 46 end = location->end_pos(); |
46 script_handle = Script::GetWrapper(loc->script()); | 47 script_handle = Script::GetWrapper(location->script()); |
| 48 } else { |
| 49 script_handle = Script::GetWrapper(isolate->factory()->empty_script()); |
47 } | 50 } |
48 | 51 |
49 Handle<Object> stack_frames_handle = stack_frames.is_null() | 52 Handle<Object> stack_frames_handle = stack_frames.is_null() |
50 ? Handle<Object>::cast(factory->undefined_value()) | 53 ? Handle<Object>::cast(factory->undefined_value()) |
51 : Handle<Object>::cast(stack_frames); | 54 : Handle<Object>::cast(stack_frames); |
52 | 55 |
53 Handle<JSMessageObject> message_obj = factory->NewJSMessageObject( | 56 Handle<JSMessageObject> message_obj = factory->NewJSMessageObject( |
54 message, argument, start, end, script_handle, stack_frames_handle); | 57 message, argument, start, end, script_handle, stack_frames_handle); |
55 | 58 |
56 return message_obj; | 59 return message_obj; |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 if (obj->IsUndefined()) return default_value; | 471 if (obj->IsUndefined()) return default_value; |
469 if (!obj->IsString()) { | 472 if (!obj->IsString()) { |
470 ASSIGN_RETURN_ON_EXCEPTION(isolate, obj, Execution::ToString(isolate, obj), | 473 ASSIGN_RETURN_ON_EXCEPTION(isolate, obj, Execution::ToString(isolate, obj), |
471 String); | 474 String); |
472 } | 475 } |
473 return Handle<String>::cast(obj); | 476 return Handle<String>::cast(obj); |
474 } | 477 } |
475 | 478 |
476 } // namespace internal | 479 } // namespace internal |
477 } // namespace v8 | 480 } // namespace v8 |
OLD | NEW |