OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 SmartArrayPointer<char> data_str; | 50 SmartArrayPointer<char> data_str; |
51 if (data->IsString()) | 51 if (data->IsString()) |
52 data_str = Handle<String>::cast(data)->ToCString(DISALLOW_NULLS); | 52 data_str = Handle<String>::cast(data)->ToCString(DISALLOW_NULLS); |
53 PrintF("%s:%i: %s\n", *data_str ? *data_str : "<unknown>", | 53 PrintF("%s:%i: %s\n", *data_str ? *data_str : "<unknown>", |
54 loc->start_pos(), *str); | 54 loc->start_pos(), *str); |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 | 58 |
59 Handle<JSMessageObject> MessageHandler::MakeMessageObject( | 59 Handle<JSMessageObject> MessageHandler::MakeMessageObject( |
| 60 Isolate* isolate, |
60 const char* type, | 61 const char* type, |
61 MessageLocation* loc, | 62 MessageLocation* loc, |
62 Vector< Handle<Object> > args, | 63 Vector< Handle<Object> > args, |
63 Handle<String> stack_trace, | 64 Handle<String> stack_trace, |
64 Handle<JSArray> stack_frames) { | 65 Handle<JSArray> stack_frames) { |
65 Handle<String> type_handle = FACTORY->InternalizeUtf8String(type); | 66 Factory* factory = isolate->factory(); |
| 67 Handle<String> type_handle = factory->InternalizeUtf8String(type); |
66 Handle<FixedArray> arguments_elements = | 68 Handle<FixedArray> arguments_elements = |
67 FACTORY->NewFixedArray(args.length()); | 69 factory->NewFixedArray(args.length()); |
68 for (int i = 0; i < args.length(); i++) { | 70 for (int i = 0; i < args.length(); i++) { |
69 arguments_elements->set(i, *args[i]); | 71 arguments_elements->set(i, *args[i]); |
70 } | 72 } |
71 Handle<JSArray> arguments_handle = | 73 Handle<JSArray> arguments_handle = |
72 FACTORY->NewJSArrayWithElements(arguments_elements); | 74 factory->NewJSArrayWithElements(arguments_elements); |
73 | 75 |
74 int start = 0; | 76 int start = 0; |
75 int end = 0; | 77 int end = 0; |
76 Handle<Object> script_handle = FACTORY->undefined_value(); | 78 Handle<Object> script_handle = factory->undefined_value(); |
77 if (loc) { | 79 if (loc) { |
78 start = loc->start_pos(); | 80 start = loc->start_pos(); |
79 end = loc->end_pos(); | 81 end = loc->end_pos(); |
80 script_handle = GetScriptWrapper(loc->script()); | 82 script_handle = GetScriptWrapper(loc->script()); |
81 } | 83 } |
82 | 84 |
83 Handle<Object> stack_trace_handle = stack_trace.is_null() | 85 Handle<Object> stack_trace_handle = stack_trace.is_null() |
84 ? Handle<Object>::cast(FACTORY->undefined_value()) | 86 ? Handle<Object>::cast(factory->undefined_value()) |
85 : Handle<Object>::cast(stack_trace); | 87 : Handle<Object>::cast(stack_trace); |
86 | 88 |
87 Handle<Object> stack_frames_handle = stack_frames.is_null() | 89 Handle<Object> stack_frames_handle = stack_frames.is_null() |
88 ? Handle<Object>::cast(FACTORY->undefined_value()) | 90 ? Handle<Object>::cast(factory->undefined_value()) |
89 : Handle<Object>::cast(stack_frames); | 91 : Handle<Object>::cast(stack_frames); |
90 | 92 |
91 Handle<JSMessageObject> message = | 93 Handle<JSMessageObject> message = |
92 FACTORY->NewJSMessageObject(type_handle, | 94 factory->NewJSMessageObject(type_handle, |
93 arguments_handle, | 95 arguments_handle, |
94 start, | 96 start, |
95 end, | 97 end, |
96 script_handle, | 98 script_handle, |
97 stack_trace_handle, | 99 stack_trace_handle, |
98 stack_frames_handle); | 100 stack_frames_handle); |
99 | 101 |
100 return message; | 102 return message; |
101 } | 103 } |
102 | 104 |
(...skipping 12 matching lines...) Expand all Loading... |
115 } | 117 } |
116 Handle<Object> exception_handle(exception_object, isolate); | 118 Handle<Object> exception_handle(exception_object, isolate); |
117 | 119 |
118 Isolate::ExceptionScope exception_scope(isolate); | 120 Isolate::ExceptionScope exception_scope(isolate); |
119 isolate->clear_pending_exception(); | 121 isolate->clear_pending_exception(); |
120 isolate->set_external_caught_exception(false); | 122 isolate->set_external_caught_exception(false); |
121 | 123 |
122 v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message); | 124 v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message); |
123 v8::Local<v8::Value> api_exception_obj = v8::Utils::ToLocal(exception_handle); | 125 v8::Local<v8::Value> api_exception_obj = v8::Utils::ToLocal(exception_handle); |
124 | 126 |
125 v8::NeanderArray global_listeners(FACTORY->message_listeners()); | 127 v8::NeanderArray global_listeners(isolate->factory()->message_listeners()); |
126 int global_length = global_listeners.length(); | 128 int global_length = global_listeners.length(); |
127 if (global_length == 0) { | 129 if (global_length == 0) { |
128 DefaultMessageReport(isolate, loc, message); | 130 DefaultMessageReport(isolate, loc, message); |
129 if (isolate->has_scheduled_exception()) { | 131 if (isolate->has_scheduled_exception()) { |
130 isolate->clear_scheduled_exception(); | 132 isolate->clear_scheduled_exception(); |
131 } | 133 } |
132 } else { | 134 } else { |
133 for (int i = 0; i < global_length; i++) { | 135 for (int i = 0; i < global_length; i++) { |
134 HandleScope scope(isolate); | 136 HandleScope scope(isolate); |
135 if (global_listeners.get(i)->IsUndefined()) continue; | 137 if (global_listeners.get(i)->IsUndefined()) continue; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 193 |
192 SmartArrayPointer<char> MessageHandler::GetLocalizedMessage( | 194 SmartArrayPointer<char> MessageHandler::GetLocalizedMessage( |
193 Isolate* isolate, | 195 Isolate* isolate, |
194 Handle<Object> data) { | 196 Handle<Object> data) { |
195 HandleScope scope(isolate); | 197 HandleScope scope(isolate); |
196 return GetMessage(isolate, data)->ToCString(DISALLOW_NULLS); | 198 return GetMessage(isolate, data)->ToCString(DISALLOW_NULLS); |
197 } | 199 } |
198 | 200 |
199 | 201 |
200 } } // namespace v8::internal | 202 } } // namespace v8::internal |
OLD | NEW |