Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 8c878b178a19ffe66b5d54428af94f7bbce5b796..07b967f2b8cf3bf37e093d1e3724b142d50663ad 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -9290,7 +9290,9 @@ debug::Location::Location(int line_number, int column_number) |
CHECK(column_number >= 0); |
} |
-debug::Location::Location() : line_number_(-1), column_number_(-1) {} |
+debug::Location::Location() |
+ : line_number_(v8::Function::kLineOffsetNotFound), |
+ column_number_(v8::Function::kLineOffsetNotFound) {} |
int debug::Location::GetLineNumber() const { |
CHECK(line_number_ >= 0); |
@@ -9414,6 +9416,41 @@ v8::MaybeLocal<v8::Array> debug::EntriesPreview(Isolate* v8_isolate, |
return v8::MaybeLocal<v8::Array>(); |
} |
+MaybeLocal<debug::Script> debug::GeneratorObject::Script() { |
+ i::Handle<i::JSGeneratorObject> obj = Utils::OpenHandle(this); |
+ i::Object* maybe_script = obj->function()->shared()->script(); |
+ if (!maybe_script->IsScript()) return MaybeLocal<debug::Script>(); |
+ i::Handle<i::Script> script(i::Script::cast(maybe_script), obj->GetIsolate()); |
+ return ToApiHandle<debug::Script>(script); |
+} |
+ |
+Local<Function> debug::GeneratorObject::Function() { |
+ i::Handle<i::JSGeneratorObject> obj = Utils::OpenHandle(this); |
+ return Utils::ToLocal(handle(obj->function())); |
+} |
+ |
+debug::Location debug::GeneratorObject::SuspendedLocation() { |
+ i::Handle<i::JSGeneratorObject> obj = Utils::OpenHandle(this); |
+ CHECK(obj->is_suspended()); |
+ i::Object* maybe_script = obj->function()->shared()->script(); |
+ if (!maybe_script->IsScript()) return debug::Location(); |
+ i::Handle<i::Script> script(i::Script::cast(maybe_script), obj->GetIsolate()); |
+ i::Script::PositionInfo info; |
+ i::Script::GetPositionInfo(script, obj->source_position(), &info, |
+ i::Script::WITH_OFFSET); |
+ return debug::Location(info.line, info.column); |
+} |
+ |
+bool debug::GeneratorObject::IsSuspended() { |
+ return Utils::OpenHandle(this)->is_suspended(); |
+} |
+ |
+v8::Local<debug::GeneratorObject> debug::GeneratorObject::Cast( |
+ v8::Local<v8::Value> value) { |
+ CHECK(value->IsGeneratorObject()); |
+ return ToApiHandle<debug::GeneratorObject>(Utils::OpenHandle(*value)); |
+} |
+ |
Local<String> CpuProfileNode::GetFunctionName() const { |
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
i::Isolate* isolate = node->isolate(); |