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

Unified Diff: src/debug/mirrors.js

Issue 2228393002: Allow access to scopes of suspended generator objects (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove stale TODO comment Created 4 years, 4 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/debug/debug-scopes.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug/mirrors.js
diff --git a/src/debug/mirrors.js b/src/debug/mirrors.js
index fbe6da5d8605408bd0bad86467e5cdfa30ff3c19..165e1724492f106896475d3153227c9a1a4bf748 100644
--- a/src/debug/mirrors.js
+++ b/src/debug/mirrors.js
@@ -1022,7 +1022,7 @@ FunctionMirror.prototype.scopeCount = function() {
FunctionMirror.prototype.scope = function(index) {
if (this.resolved()) {
- return new ScopeMirror(UNDEFINED, this, index);
+ return new ScopeMirror(UNDEFINED, this, UNDEFINED, index);
}
};
@@ -1451,6 +1451,27 @@ GeneratorMirror.prototype.receiver = function() {
};
+GeneratorMirror.prototype.scopeCount = function() {
+ // This value can change over time as the underlying generator is suspended
+ // at different locations.
+ return %GetGeneratorScopeCount(this.value());
+};
+
+
+GeneratorMirror.prototype.scope = function(index) {
+ return new ScopeMirror(UNDEFINED, UNDEFINED, this, index);
+};
+
+
+GeneratorMirror.prototype.allScopes = function() {
+ var scopes = [];
+ for (let i = 0; i < this.scopeCount(); i++) {
+ scopes.push(this.scope(i));
+ }
+ return scopes;
+};
+
+
/**
* Base mirror object for properties.
* @param {ObjectMirror} mirror The mirror object having this property
@@ -1973,7 +1994,7 @@ FrameMirror.prototype.scopeCount = function() {
FrameMirror.prototype.scope = function(index) {
- return new ScopeMirror(this, UNDEFINED, index);
+ return new ScopeMirror(this, UNDEFINED, UNDEFINED, index);
};
@@ -1984,7 +2005,8 @@ FrameMirror.prototype.allScopes = function(opt_ignore_nested_scopes) {
!!opt_ignore_nested_scopes);
var result = [];
for (var i = 0; i < scopeDetails.length; ++i) {
- result.push(new ScopeMirror(this, UNDEFINED, i, scopeDetails[i]));
+ result.push(new ScopeMirror(this, UNDEFINED, UNDEFINED, i,
+ scopeDetails[i]));
}
return result;
};
@@ -2163,7 +2185,7 @@ var kScopeDetailsStartPositionIndex = 3;
var kScopeDetailsEndPositionIndex = 4;
var kScopeDetailsFunctionIndex = 5;
-function ScopeDetails(frame, fun, index, opt_details) {
+function ScopeDetails(frame, fun, gen, index, opt_details) {
if (frame) {
this.break_id_ = frame.break_id_;
this.details_ = opt_details ||
@@ -2173,10 +2195,15 @@ function ScopeDetails(frame, fun, index, opt_details) {
index);
this.frame_id_ = frame.details_.frameId();
this.inlined_frame_id_ = frame.details_.inlinedFrameIndex();
- } else {
+ } else if (fun) {
this.details_ = opt_details || %GetFunctionScopeDetails(fun.value(), index);
this.fun_value_ = fun.value();
this.break_id_ = UNDEFINED;
+ } else {
+ this.details_ =
+ opt_details || %GetGeneratorScopeDetails(gen.value(), index);
+ this.gen_value_ = gen.value();
+ this.break_id_ = UNDEFINED;
}
this.index_ = index;
}
@@ -2235,9 +2262,12 @@ ScopeDetails.prototype.setVariableValueImpl = function(name, new_value) {
%CheckExecutionState(this.break_id_);
raw_res = %SetScopeVariableValue(this.break_id_, this.frame_id_,
this.inlined_frame_id_, this.index_, name, new_value);
- } else {
+ } else if (!IS_UNDEFINED(this.fun_value_)) {
raw_res = %SetScopeVariableValue(this.fun_value_, null, null, this.index_,
name, new_value);
+ } else {
+ raw_res = %SetScopeVariableValue(this.gen_value_, null, null, this.index_,
+ name, new_value);
}
if (!raw_res) throw %make_error(kDebugger, "Failed to set variable value");
};
@@ -2248,12 +2278,13 @@ ScopeDetails.prototype.setVariableValueImpl = function(name, new_value) {
* be specified.
* @param {FrameMirror} frame The frame this scope is a part of
* @param {FunctionMirror} function The function this scope is a part of
+ * @param {GeneratorMirror} gen The generator this scope is a part of
* @param {number} index The scope index in the frame
* @param {Array=} opt_details Raw scope details data
* @constructor
* @extends Mirror
*/
-function ScopeMirror(frame, fun, index, opt_details) {
+function ScopeMirror(frame, fun, gen, index, opt_details) {
%_Call(Mirror, this, MirrorType.SCOPE_TYPE);
if (frame) {
this.frame_index_ = frame.index_;
@@ -2261,7 +2292,7 @@ function ScopeMirror(frame, fun, index, opt_details) {
this.frame_index_ = UNDEFINED;
}
this.scope_index_ = index;
- this.details_ = new ScopeDetails(frame, fun, index, opt_details);
+ this.details_ = new ScopeDetails(frame, fun, gen, index, opt_details);
}
inherits(ScopeMirror, Mirror);
« no previous file with comments | « src/debug/debug-scopes.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698