OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 2649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2660 auto self = Utils::OpenHandle(this); | 2660 auto self = Utils::OpenHandle(this); |
2661 return self->start_position(); | 2661 return self->start_position(); |
2662 } | 2662 } |
2663 | 2663 |
2664 | 2664 |
2665 int Message::GetEndPosition() const { | 2665 int Message::GetEndPosition() const { |
2666 auto self = Utils::OpenHandle(this); | 2666 auto self = Utils::OpenHandle(this); |
2667 return self->end_position(); | 2667 return self->end_position(); |
2668 } | 2668 } |
2669 | 2669 |
| 2670 int Message::ErrorLevel() const { |
| 2671 auto self = Utils::OpenHandle(this); |
| 2672 return self->error_level(); |
| 2673 } |
2670 | 2674 |
2671 Maybe<int> Message::GetStartColumn(Local<Context> context) const { | 2675 Maybe<int> Message::GetStartColumn(Local<Context> context) const { |
2672 auto self = Utils::OpenHandle(this); | 2676 auto self = Utils::OpenHandle(this); |
2673 i::Isolate* isolate = self->GetIsolate(); | 2677 i::Isolate* isolate = self->GetIsolate(); |
2674 ENTER_V8(isolate); | 2678 ENTER_V8(isolate); |
2675 EscapableHandleScope handle_scope(reinterpret_cast<Isolate*>(isolate)); | 2679 EscapableHandleScope handle_scope(reinterpret_cast<Isolate*>(isolate)); |
2676 auto msg = i::Handle<i::JSMessageObject>::cast(self); | 2680 auto msg = i::Handle<i::JSMessageObject>::cast(self); |
2677 return Just(msg->GetColumnNumber()); | 2681 return Just(msg->GetColumnNumber()); |
2678 } | 2682 } |
2679 | 2683 |
(...skipping 5765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8445 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 8449 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
8446 isolate->set_allow_code_gen_callback(callback); | 8450 isolate->set_allow_code_gen_callback(callback); |
8447 } | 8451 } |
8448 | 8452 |
8449 | 8453 |
8450 bool Isolate::IsDead() { | 8454 bool Isolate::IsDead() { |
8451 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 8455 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
8452 return isolate->IsDead(); | 8456 return isolate->IsDead(); |
8453 } | 8457 } |
8454 | 8458 |
| 8459 bool Isolate::AddMessageListener(MessageCallback that, Local<Value> data) { |
| 8460 return AddMessageListenerWithErrorLevel(that, kMessageError, data); |
| 8461 } |
8455 | 8462 |
8456 bool Isolate::AddMessageListener(MessageCallback that, Local<Value> data) { | 8463 bool Isolate::AddMessageListenerWithErrorLevel(MessageCallback that, |
| 8464 int message_levels, |
| 8465 Local<Value> data) { |
8457 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 8466 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
8458 ENTER_V8(isolate); | 8467 ENTER_V8(isolate); |
8459 i::HandleScope scope(isolate); | 8468 i::HandleScope scope(isolate); |
8460 i::Handle<i::TemplateList> list = isolate->factory()->message_listeners(); | 8469 i::Handle<i::TemplateList> list = isolate->factory()->message_listeners(); |
8461 i::Handle<i::FixedArray> listener = isolate->factory()->NewFixedArray(2); | 8470 i::Handle<i::FixedArray> listener = isolate->factory()->NewFixedArray(3); |
8462 i::Handle<i::Foreign> foreign = | 8471 i::Handle<i::Foreign> foreign = |
8463 isolate->factory()->NewForeign(FUNCTION_ADDR(that)); | 8472 isolate->factory()->NewForeign(FUNCTION_ADDR(that)); |
8464 listener->set(0, *foreign); | 8473 listener->set(0, *foreign); |
8465 listener->set(1, data.IsEmpty() ? isolate->heap()->undefined_value() | 8474 listener->set(1, data.IsEmpty() ? isolate->heap()->undefined_value() |
8466 : *Utils::OpenHandle(*data)); | 8475 : *Utils::OpenHandle(*data)); |
| 8476 listener->set(2, i::Smi::FromInt(message_levels)); |
8467 list = i::TemplateList::Add(isolate, list, listener); | 8477 list = i::TemplateList::Add(isolate, list, listener); |
8468 isolate->heap()->SetMessageListeners(*list); | 8478 isolate->heap()->SetMessageListeners(*list); |
8469 return true; | 8479 return true; |
8470 } | 8480 } |
8471 | 8481 |
8472 | 8482 |
8473 void Isolate::RemoveMessageListeners(MessageCallback that) { | 8483 void Isolate::RemoveMessageListeners(MessageCallback that) { |
8474 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 8484 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
8475 ENTER_V8(isolate); | 8485 ENTER_V8(isolate); |
8476 i::HandleScope scope(isolate); | 8486 i::HandleScope scope(isolate); |
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9879 Address callback_address = | 9889 Address callback_address = |
9880 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9890 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
9881 VMState<EXTERNAL> state(isolate); | 9891 VMState<EXTERNAL> state(isolate); |
9882 ExternalCallbackScope call_scope(isolate, callback_address); | 9892 ExternalCallbackScope call_scope(isolate, callback_address); |
9883 callback(info); | 9893 callback(info); |
9884 } | 9894 } |
9885 | 9895 |
9886 | 9896 |
9887 } // namespace internal | 9897 } // namespace internal |
9888 } // namespace v8 | 9898 } // namespace v8 |
OLD | NEW |