Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: src/api.cc

Issue 2678143002: [inspector] introduced debug::GeneratorObject (Closed)
Patch Set: addressed comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/api.h ('k') | src/debug/debug-interface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « src/api.h ('k') | src/debug/debug-interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698