diff options
Diffstat (limited to 'deps/v8/src/mirror-debugger.js')
-rw-r--r-- | deps/v8/src/mirror-debugger.js | 88 |
1 files changed, 75 insertions, 13 deletions
diff --git a/deps/v8/src/mirror-debugger.js b/deps/v8/src/mirror-debugger.js index c43dd228ec..c7f0dccb7b 100644 --- a/deps/v8/src/mirror-debugger.js +++ b/deps/v8/src/mirror-debugger.js @@ -596,6 +596,23 @@ ObjectMirror.prototype.protoObject = function() { }; +/** + * Return the primitive value if this is object of Boolean, Number or String + * type (but not Date). Otherwise return undefined. + */ +ObjectMirror.prototype.primitiveValue = function() { + if (!IS_STRING_WRAPPER(this.value_) && !IS_NUMBER_WRAPPER(this.value_) && + !IS_BOOLEAN_WRAPPER(this.value_)) { + return void 0; + } + var primitiveValue = %_ValueOf(this.value_); + if (IS_UNDEFINED(primitiveValue)) { + return void 0; + } + return MakeMirror(primitiveValue); +}; + + ObjectMirror.prototype.hasNamedInterceptor = function() { // Get information on interceptors for this object. var x = %GetInterceptorInfo(this.value_); @@ -896,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(); }; @@ -1572,7 +1605,7 @@ FrameMirror.prototype.scopeCount = function() { FrameMirror.prototype.scope = function(index) { - return new ScopeMirror(this, index); + return new ScopeMirror(this, void 0, index); }; @@ -1735,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); @@ -2234,6 +2282,11 @@ JSONProtocolSerializer.prototype.serializeObject_ = function(mirror, content, content.protoObject = this.serializeReference(mirror.protoObject()); content.prototypeObject = this.serializeReference(mirror.prototypeObject()); + var primitiveValue = mirror.primitiveValue(); + if (!IS_UNDEFINED(primitiveValue)) { + content.primitiveValue = this.serializeReference(primitiveValue); + } + // Add flags to indicate whether there are interceptors. if (mirror.hasNamedInterceptor()) { content.namedInterceptor = true; @@ -2259,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. |