Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 4fadd54f7e6314f11db1debe5df65a2987261947..8d16f539d1d42a19ff985020dfe33b0be2f587a3 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -2447,16 +2447,12 @@ v8::Local<v8::StackTrace> Message::GetStackTrace() const { |
Maybe<int> Message::GetLineNumber(Local<Context> context) const { |
- PREPARE_FOR_EXECUTION_PRIMITIVE(context, Message, GetLineNumber, int); |
- i::Handle<i::JSFunction> fun = isolate->message_get_line_number(); |
- i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
- i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; |
- i::Handle<i::Object> result; |
- has_pending_exception = |
- !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
- .ToHandle(&result); |
- RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); |
- return Just(static_cast<int>(result->Number())); |
+ auto self = Utils::OpenHandle(this); |
+ i::Isolate* isolate = self->GetIsolate(); |
+ ENTER_V8(isolate); |
+ EscapableHandleScope handle_scope(reinterpret_cast<Isolate*>(isolate)); |
+ auto msg = i::Handle<i::JSMessageObject>::cast(self); |
+ return Just(msg->GetLineNumber()); |
} |
@@ -2479,16 +2475,12 @@ int Message::GetEndPosition() const { |
Maybe<int> Message::GetStartColumn(Local<Context> context) const { |
- PREPARE_FOR_EXECUTION_PRIMITIVE(context, Message, GetStartColumn, int); |
- i::Handle<i::JSFunction> fun = isolate->message_get_column_number(); |
- i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
- i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; |
- i::Handle<i::Object> result; |
- has_pending_exception = |
- !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
- .ToHandle(&result); |
- RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); |
- return Just(static_cast<int>(result->Number())); |
+ auto self = Utils::OpenHandle(this); |
+ i::Isolate* isolate = self->GetIsolate(); |
+ ENTER_V8(isolate); |
+ EscapableHandleScope handle_scope(reinterpret_cast<Isolate*>(isolate)); |
+ auto msg = i::Handle<i::JSMessageObject>::cast(self); |
+ return Just(msg->GetColumnNumber()); |
} |
@@ -2501,18 +2493,15 @@ int Message::GetStartColumn() const { |
Maybe<int> Message::GetEndColumn(Local<Context> context) const { |
auto self = Utils::OpenHandle(this); |
- PREPARE_FOR_EXECUTION_PRIMITIVE(context, Message, GetEndColumn, int); |
- i::Handle<i::JSFunction> fun = isolate->message_get_column_number(); |
- i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
- i::Handle<i::Object> args[] = {self}; |
- i::Handle<i::Object> result; |
- has_pending_exception = |
- !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
- .ToHandle(&result); |
- RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int); |
- int start = self->start_position(); |
- int end = self->end_position(); |
- return Just(static_cast<int>(result->Number()) + (end - start)); |
+ i::Isolate* isolate = self->GetIsolate(); |
+ ENTER_V8(isolate); |
+ EscapableHandleScope handle_scope(reinterpret_cast<Isolate*>(isolate)); |
+ auto msg = i::Handle<i::JSMessageObject>::cast(self); |
+ const int column_number = msg->GetColumnNumber(); |
+ if (column_number == -1) return Just(-1); |
+ const int start = self->start_position(); |
+ const int end = self->end_position(); |
+ return Just(column_number + (end - start)); |
} |
@@ -2545,20 +2534,12 @@ bool Message::IsOpaque() const { |
MaybeLocal<String> Message::GetSourceLine(Local<Context> context) const { |
- PREPARE_FOR_EXECUTION(context, Message, GetSourceLine, String); |
- i::Handle<i::JSFunction> fun = isolate->message_get_source_line(); |
- i::Handle<i::Object> undefined = isolate->factory()->undefined_value(); |
- i::Handle<i::Object> args[] = {Utils::OpenHandle(this)}; |
- i::Handle<i::Object> result; |
- has_pending_exception = |
- !i::Execution::Call(isolate, fun, undefined, arraysize(args), args) |
- .ToHandle(&result); |
- RETURN_ON_FAILED_EXECUTION(String); |
- Local<String> str; |
- if (result->IsString()) { |
- str = Utils::ToLocal(i::Handle<i::String>::cast(result)); |
- } |
- RETURN_ESCAPED(str); |
+ auto self = Utils::OpenHandle(this); |
+ i::Isolate* isolate = self->GetIsolate(); |
+ ENTER_V8(isolate); |
+ EscapableHandleScope handle_scope(reinterpret_cast<Isolate*>(isolate)); |
+ auto msg = i::Handle<i::JSMessageObject>::cast(self); |
+ RETURN_ESCAPED(Utils::ToLocal(msg->GetSourceLine())); |
} |