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/v8.h" | 5 #include "src/v8.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/heap/spaces-inl.h" | 9 #include "src/heap/spaces-inl.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 SmartArrayPointer<char> data_str; | 27 SmartArrayPointer<char> data_str; |
28 if (data->IsString()) | 28 if (data->IsString()) |
29 data_str = Handle<String>::cast(data)->ToCString(DISALLOW_NULLS); | 29 data_str = Handle<String>::cast(data)->ToCString(DISALLOW_NULLS); |
30 PrintF("%s:%i: %s\n", data_str.get() ? data_str.get() : "<unknown>", | 30 PrintF("%s:%i: %s\n", data_str.get() ? data_str.get() : "<unknown>", |
31 loc->start_pos(), str.get()); | 31 loc->start_pos(), str.get()); |
32 } | 32 } |
33 } | 33 } |
34 | 34 |
35 | 35 |
36 Handle<JSMessageObject> MessageHandler::MakeMessageObject( | 36 Handle<JSMessageObject> MessageHandler::MakeMessageObject( |
37 Isolate* isolate, | 37 Isolate* isolate, const char* type, MessageLocation* loc, |
38 const char* type, | 38 Vector<Handle<Object> > args, Handle<JSObject> promise, |
39 MessageLocation* loc, | |
40 Vector< Handle<Object> > args, | |
41 Handle<JSArray> stack_frames) { | 39 Handle<JSArray> stack_frames) { |
42 Factory* factory = isolate->factory(); | 40 Factory* factory = isolate->factory(); |
43 Handle<String> type_handle = factory->InternalizeUtf8String(type); | 41 Handle<String> type_handle = factory->InternalizeUtf8String(type); |
44 Handle<FixedArray> arguments_elements = | 42 Handle<FixedArray> arguments_elements = |
45 factory->NewFixedArray(args.length()); | 43 factory->NewFixedArray(args.length()); |
46 for (int i = 0; i < args.length(); i++) { | 44 for (int i = 0; i < args.length(); i++) { |
47 arguments_elements->set(i, *args[i]); | 45 arguments_elements->set(i, *args[i]); |
48 } | 46 } |
49 Handle<JSArray> arguments_handle = | 47 Handle<JSArray> arguments_handle = |
50 factory->NewJSArrayWithElements(arguments_elements); | 48 factory->NewJSArrayWithElements(arguments_elements); |
51 | 49 |
52 int start = 0; | 50 int start = 0; |
53 int end = 0; | 51 int end = 0; |
54 Handle<Object> script_handle = factory->undefined_value(); | 52 Handle<Object> script_handle = factory->undefined_value(); |
55 if (loc) { | 53 if (loc) { |
56 start = loc->start_pos(); | 54 start = loc->start_pos(); |
57 end = loc->end_pos(); | 55 end = loc->end_pos(); |
58 script_handle = Script::GetWrapper(loc->script()); | 56 script_handle = Script::GetWrapper(loc->script()); |
59 } | 57 } |
60 | 58 |
61 Handle<Object> stack_frames_handle = stack_frames.is_null() | 59 Handle<Object> stack_frames_handle = stack_frames.is_null() |
62 ? Handle<Object>::cast(factory->undefined_value()) | 60 ? Handle<Object>::cast(factory->undefined_value()) |
63 : Handle<Object>::cast(stack_frames); | 61 : Handle<Object>::cast(stack_frames); |
64 | 62 |
65 Handle<JSMessageObject> message = | 63 Handle<Object> promise_handle = |
66 factory->NewJSMessageObject(type_handle, | 64 promise.is_null() ? Handle<Object>::cast(factory->undefined_value()) |
67 arguments_handle, | 65 : Handle<Object>::cast(promise); |
68 start, | 66 |
69 end, | 67 Handle<JSMessageObject> message = factory->NewJSMessageObject( |
70 script_handle, | 68 type_handle, arguments_handle, promise_handle, start, end, script_handle, |
71 stack_frames_handle); | 69 stack_frames_handle); |
72 | 70 |
73 return message; | 71 return message; |
74 } | 72 } |
75 | 73 |
76 | 74 |
77 void MessageHandler::ReportMessage(Isolate* isolate, | 75 void MessageHandler::ReportMessage(Isolate* isolate, |
78 MessageLocation* loc, | 76 MessageLocation* loc, |
79 Handle<Object> message) { | 77 Handle<Object> message) { |
80 // We are calling into embedder's code which can throw exceptions. | 78 // We are calling into embedder's code which can throw exceptions. |
81 // Thus we need to save current exception state, reset it to the clean one | 79 // Thus we need to save current exception state, reset it to the clean one |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 154 |
157 SmartArrayPointer<char> MessageHandler::GetLocalizedMessage( | 155 SmartArrayPointer<char> MessageHandler::GetLocalizedMessage( |
158 Isolate* isolate, | 156 Isolate* isolate, |
159 Handle<Object> data) { | 157 Handle<Object> data) { |
160 HandleScope scope(isolate); | 158 HandleScope scope(isolate); |
161 return GetMessage(isolate, data)->ToCString(DISALLOW_NULLS); | 159 return GetMessage(isolate, data)->ToCString(DISALLOW_NULLS); |
162 } | 160 } |
163 | 161 |
164 | 162 |
165 } } // namespace v8::internal | 163 } } // namespace v8::internal |
OLD | NEW |