Index: src/mirror-debugger.js |
diff --git a/src/mirror-debugger.js b/src/mirror-debugger.js |
index c43dd228ec9d12c73a0d66a4102477649f85862f..9c05a07a6b27a9e114b016e318f89c3ccc08b408 100644 |
--- a/src/mirror-debugger.js |
+++ b/src/mirror-debugger.js |
@@ -896,6 +896,16 @@ FunctionMirror.prototype.constructedBy = function(opt_max_instances) { |
}; |
+FunctionMirror.prototype.scopeCount = function() { |
+ return %GetFunctionScopeCount(this.value()); |
+}; |
+ |
+ |
+FunctionMirror.prototype.scope = function(index) { |
+ return new ScopeMirror(undefined, this, index); |
+}; |
+ |
+ |
FunctionMirror.prototype.toText = function() { |
return this.source(); |
}; |
@@ -1572,7 +1582,7 @@ FrameMirror.prototype.scopeCount = function() { |
FrameMirror.prototype.scope = function(index) { |
- return new ScopeMirror(this, index); |
+ return new ScopeMirror(this, undefined, index); |
}; |
@@ -1735,39 +1745,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); |
@@ -2259,6 +2284,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. |