debugger: full scope evals
This commit is contained in:
parent
d87ab5450b
commit
533797a607
@ -235,23 +235,64 @@ Client.prototype.reqLookup = function(refs, cb) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// This is like reqEval, except it will look up the expression in each of the
|
||||||
|
// scopes associated with the current frame.
|
||||||
Client.prototype.reqEval = function(expression, cb) {
|
Client.prototype.reqEval = function(expression, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
if (this.currentFrame == NO_FRAME) {
|
||||||
|
// Only need to eval in global scope.
|
||||||
|
this.reqFrameEval(expression, NO_FRAME, cb);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise we need to get the current frame to see which scopes it has.
|
||||||
|
this.reqBacktrace(function (bt) {
|
||||||
|
var frame = bt.frames[self.currentFrame];
|
||||||
|
|
||||||
|
var evalFrames = frame.scopes.map(function(s) {
|
||||||
|
return bt.frames[s.index].index;
|
||||||
|
});
|
||||||
|
|
||||||
|
self._reqFramesEval(expression, evalFrames, cb);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Finds the first scope in the array in which the epxression evals.
|
||||||
|
Client.prototype._reqFramesEval = function(expression, evalFrames, cb) {
|
||||||
|
if (evalFrames.length == 0) {
|
||||||
|
// Just eval in global scope.
|
||||||
|
this.reqFrameEval(expression, NO_FRAME, cb);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
var i = evalFrames.shift();
|
||||||
|
|
||||||
|
this.reqFrameEval(expression, i, function(res) {
|
||||||
|
if (res.success) {
|
||||||
|
if (cb) cb(res);
|
||||||
|
} else {
|
||||||
|
self._reqFramesEval(expression, evalFrames, cb);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Client.prototype.reqFrameEval = function(expression, frame, cb) {
|
||||||
|
var self = this;
|
||||||
var req = {
|
var req = {
|
||||||
command: 'evaluate',
|
command: 'evaluate',
|
||||||
arguments: { expression: expression }
|
arguments: { expression: expression }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (frame == NO_FRAME) {
|
||||||
if (this.currentFrame == NO_FRAME) {
|
|
||||||
req.arguments.global = true;
|
req.arguments.global = true;
|
||||||
} else {
|
} else {
|
||||||
req.arguments.frame = this.currentFrame;
|
req.arguments.frame = frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.error("currentFrame: %d", this.currentFrame);
|
|
||||||
|
|
||||||
this.req(req, function(res) {
|
this.req(req, function(res) {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
self._addHandle(res.body);
|
self._addHandle(res.body);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user