| 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 <memory> |
| 8 |
| 7 #include "src/api.h" | 9 #include "src/api.h" |
| 8 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| 9 #include "src/execution.h" | 11 #include "src/execution.h" |
| 10 #include "src/isolate-inl.h" | 12 #include "src/isolate-inl.h" |
| 11 #include "src/keys.h" | 13 #include "src/keys.h" |
| 12 #include "src/string-builder.h" | 14 #include "src/string-builder.h" |
| 13 #include "src/wasm/wasm-module.h" | 15 #include "src/wasm/wasm-module.h" |
| 14 | 16 |
| 15 namespace v8 { | 17 namespace v8 { |
| 16 namespace internal { | 18 namespace internal { |
| 17 | 19 |
| 18 MessageLocation::MessageLocation(Handle<Script> script, int start_pos, | 20 MessageLocation::MessageLocation(Handle<Script> script, int start_pos, |
| 19 int end_pos) | 21 int end_pos) |
| 20 : script_(script), start_pos_(start_pos), end_pos_(end_pos) {} | 22 : script_(script), start_pos_(start_pos), end_pos_(end_pos) {} |
| 21 MessageLocation::MessageLocation(Handle<Script> script, int start_pos, | 23 MessageLocation::MessageLocation(Handle<Script> script, int start_pos, |
| 22 int end_pos, Handle<JSFunction> function) | 24 int end_pos, Handle<JSFunction> function) |
| 23 : script_(script), | 25 : script_(script), |
| 24 start_pos_(start_pos), | 26 start_pos_(start_pos), |
| 25 end_pos_(end_pos), | 27 end_pos_(end_pos), |
| 26 function_(function) {} | 28 function_(function) {} |
| 27 MessageLocation::MessageLocation() : start_pos_(-1), end_pos_(-1) {} | 29 MessageLocation::MessageLocation() : start_pos_(-1), end_pos_(-1) {} |
| 28 | 30 |
| 29 // If no message listeners have been registered this one is called | 31 // If no message listeners have been registered this one is called |
| 30 // by default. | 32 // by default. |
| 31 void MessageHandler::DefaultMessageReport(Isolate* isolate, | 33 void MessageHandler::DefaultMessageReport(Isolate* isolate, |
| 32 const MessageLocation* loc, | 34 const MessageLocation* loc, |
| 33 Handle<Object> message_obj) { | 35 Handle<Object> message_obj) { |
| 34 base::SmartArrayPointer<char> str = GetLocalizedMessage(isolate, message_obj); | 36 std::unique_ptr<char[]> str = GetLocalizedMessage(isolate, message_obj); |
| 35 if (loc == NULL) { | 37 if (loc == NULL) { |
| 36 PrintF("%s\n", str.get()); | 38 PrintF("%s\n", str.get()); |
| 37 } else { | 39 } else { |
| 38 HandleScope scope(isolate); | 40 HandleScope scope(isolate); |
| 39 Handle<Object> data(loc->script()->name(), isolate); | 41 Handle<Object> data(loc->script()->name(), isolate); |
| 40 base::SmartArrayPointer<char> data_str; | 42 std::unique_ptr<char[]> data_str; |
| 41 if (data->IsString()) | 43 if (data->IsString()) |
| 42 data_str = Handle<String>::cast(data)->ToCString(DISALLOW_NULLS); | 44 data_str = Handle<String>::cast(data)->ToCString(DISALLOW_NULLS); |
| 43 PrintF("%s:%i: %s\n", data_str.get() ? data_str.get() : "<unknown>", | 45 PrintF("%s:%i: %s\n", data_str.get() ? data_str.get() : "<unknown>", |
| 44 loc->start_pos(), str.get()); | 46 loc->start_pos(), str.get()); |
| 45 } | 47 } |
| 46 } | 48 } |
| 47 | 49 |
| 48 | 50 |
| 49 Handle<JSMessageObject> MessageHandler::MakeMessageObject( | 51 Handle<JSMessageObject> MessageHandler::MakeMessageObject( |
| 50 Isolate* isolate, MessageTemplate::Template message, | 52 Isolate* isolate, MessageTemplate::Template message, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } | 154 } |
| 153 | 155 |
| 154 | 156 |
| 155 Handle<String> MessageHandler::GetMessage(Isolate* isolate, | 157 Handle<String> MessageHandler::GetMessage(Isolate* isolate, |
| 156 Handle<Object> data) { | 158 Handle<Object> data) { |
| 157 Handle<JSMessageObject> message = Handle<JSMessageObject>::cast(data); | 159 Handle<JSMessageObject> message = Handle<JSMessageObject>::cast(data); |
| 158 Handle<Object> arg = Handle<Object>(message->argument(), isolate); | 160 Handle<Object> arg = Handle<Object>(message->argument(), isolate); |
| 159 return MessageTemplate::FormatMessage(isolate, message->type(), arg); | 161 return MessageTemplate::FormatMessage(isolate, message->type(), arg); |
| 160 } | 162 } |
| 161 | 163 |
| 162 | 164 std::unique_ptr<char[]> MessageHandler::GetLocalizedMessage( |
| 163 base::SmartArrayPointer<char> MessageHandler::GetLocalizedMessage( | |
| 164 Isolate* isolate, Handle<Object> data) { | 165 Isolate* isolate, Handle<Object> data) { |
| 165 HandleScope scope(isolate); | 166 HandleScope scope(isolate); |
| 166 return GetMessage(isolate, data)->ToCString(DISALLOW_NULLS); | 167 return GetMessage(isolate, data)->ToCString(DISALLOW_NULLS); |
| 167 } | 168 } |
| 168 | 169 |
| 169 | 170 |
| 170 CallSite::CallSite(Isolate* isolate, Handle<JSObject> call_site_obj) | 171 CallSite::CallSite(Isolate* isolate, Handle<JSObject> call_site_obj) |
| 171 : isolate_(isolate) { | 172 : isolate_(isolate) { |
| 172 Handle<Object> maybe_function = JSObject::GetDataProperty( | 173 Handle<Object> maybe_function = JSObject::GetDataProperty( |
| 173 call_site_obj, isolate->factory()->call_site_function_symbol()); | 174 call_site_obj, isolate->factory()->call_site_function_symbol()); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 // Capture a simple stack trace for the stack property. | 516 // Capture a simple stack trace for the stack property. |
| 516 RETURN_ON_EXCEPTION(isolate, | 517 RETURN_ON_EXCEPTION(isolate, |
| 517 isolate->CaptureAndSetSimpleStackTrace(err, mode, caller), | 518 isolate->CaptureAndSetSimpleStackTrace(err, mode, caller), |
| 518 Object); | 519 Object); |
| 519 | 520 |
| 520 return err; | 521 return err; |
| 521 } | 522 } |
| 522 | 523 |
| 523 } // namespace internal | 524 } // namespace internal |
| 524 } // namespace v8 | 525 } // namespace v8 |
| OLD | NEW |