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

Unified Diff: src/mirror-debugger.js

Issue 10171003: Issue 2081: Expose function's (closure's) inner context in debugger. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: trailing whitespace Created 8 years, 8 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-debugger.js ('k') | src/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/mirror-debugger.js
diff --git a/src/mirror-debugger.js b/src/mirror-debugger.js
index 82e6fd261a41b20e9a07fd4434fd10a0326890ed..c7f0dccb7b1867b54e6aab592288d1ddd517cc36 100644
--- a/src/mirror-debugger.js
+++ b/src/mirror-debugger.js
@@ -913,6 +913,22 @@ FunctionMirror.prototype.constructedBy = function(opt_max_instances) {
};
+FunctionMirror.prototype.scopeCount = function() {
+ if (this.resolved()) {
+ return %GetFunctionScopeCount(this.value());
+ } else {
+ return 0;
+ }
+};
+
+
+FunctionMirror.prototype.scope = function(index) {
+ if (this.resolved()) {
+ return new ScopeMirror(void 0, this, index);
+ }
+};
+
+
FunctionMirror.prototype.toText = function() {
return this.source();
};
@@ -1589,7 +1605,7 @@ FrameMirror.prototype.scopeCount = function() {
FrameMirror.prototype.scope = function(index) {
- return new ScopeMirror(this, index);
+ return new ScopeMirror(this, void 0, index);
};
@@ -1752,39 +1768,54 @@ FrameMirror.prototype.toText = function(opt_locals) {
var kScopeDetailsTypeIndex = 0;
var kScopeDetailsObjectIndex = 1;
-function ScopeDetails(frame, index) {
- this.break_id_ = frame.break_id_;
- this.details_ = %GetScopeDetails(frame.break_id_,
- frame.details_.frameId(),
- frame.details_.inlinedFrameIndex(),
- index);
+function ScopeDetails(frame, fun, index) {
+ if (frame) {
+ this.break_id_ = frame.break_id_;
+ this.details_ = %GetScopeDetails(frame.break_id_,
+ frame.details_.frameId(),
+ frame.details_.inlinedFrameIndex(),
+ index);
+ } else {
+ this.details_ = %GetFunctionScopeDetails(fun.value(), index);
+ this.break_id_ = undefined;
+ }
}
ScopeDetails.prototype.type = function() {
- %CheckExecutionState(this.break_id_);
+ if (!IS_UNDEFINED(this.break_id_)) {
+ %CheckExecutionState(this.break_id_);
+ }
return this.details_[kScopeDetailsTypeIndex];
};
ScopeDetails.prototype.object = function() {
- %CheckExecutionState(this.break_id_);
+ if (!IS_UNDEFINED(this.break_id_)) {
+ %CheckExecutionState(this.break_id_);
+ }
return this.details_[kScopeDetailsObjectIndex];
};
/**
- * Mirror object for scope.
+ * Mirror object for scope of frame or function. Either frame or function must
+ * 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 {number} index The scope index in the frame
* @constructor
* @extends Mirror
*/
-function ScopeMirror(frame, index) {
+function ScopeMirror(frame, function, index) {
%_CallFunction(this, SCOPE_TYPE, Mirror);
- this.frame_index_ = frame.index_;
+ if (frame) {
+ this.frame_index_ = frame.index_;
+ } else {
+ this.frame_index_ = undefined;
+ }
this.scope_index_ = index;
- this.details_ = new ScopeDetails(frame, index);
+ this.details_ = new ScopeDetails(frame, function, index);
}
inherits(ScopeMirror, Mirror);
@@ -2281,6 +2312,15 @@ JSONProtocolSerializer.prototype.serializeObject_ = function(mirror, content,
serializeLocationFields(mirror.sourceLocation(), content);
}
+
+ content.scopes = [];
+ for (var i = 0; i < mirror.scopeCount(); i++) {
+ var scope = mirror.scope(i);
+ content.scopes.push({
+ type: scope.scopeType(),
+ index: i
+ });
+ }
}
// Add date specific properties.
« no previous file with comments | « src/debug-debugger.js ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698